1*c59a5c48SFrançois Tigeot /*
2*c59a5c48SFrançois Tigeot * Copyright 2008 Advanced Micro Devices, Inc.
3*c59a5c48SFrançois Tigeot *
4*c59a5c48SFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a
5*c59a5c48SFrançois Tigeot * copy of this software and associated documentation files (the "Software"),
6*c59a5c48SFrançois Tigeot * to deal in the Software without restriction, including without limitation
7*c59a5c48SFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*c59a5c48SFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the
9*c59a5c48SFrançois Tigeot * Software is furnished to do so, subject to the following conditions:
10*c59a5c48SFrançois Tigeot *
11*c59a5c48SFrançois Tigeot * The above copyright notice and this permission notice shall be included in
12*c59a5c48SFrançois Tigeot * all copies or substantial portions of the Software.
13*c59a5c48SFrançois Tigeot *
14*c59a5c48SFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*c59a5c48SFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*c59a5c48SFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17*c59a5c48SFrançois Tigeot * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*c59a5c48SFrançois Tigeot * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*c59a5c48SFrançois Tigeot * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*c59a5c48SFrançois Tigeot * OTHER DEALINGS IN THE SOFTWARE.
21*c59a5c48SFrançois Tigeot *
22*c59a5c48SFrançois Tigeot * Author: Stanislaw Skowronek
23*c59a5c48SFrançois Tigeot */
24*c59a5c48SFrançois Tigeot
25*c59a5c48SFrançois Tigeot #ifndef ATOM_BITS_H
26*c59a5c48SFrançois Tigeot #define ATOM_BITS_H
27*c59a5c48SFrançois Tigeot
get_u8(void * bios,int ptr)28*c59a5c48SFrançois Tigeot static inline uint8_t get_u8(void *bios, int ptr)
29*c59a5c48SFrançois Tigeot {
30*c59a5c48SFrançois Tigeot return ((unsigned char *)bios)[ptr];
31*c59a5c48SFrançois Tigeot }
32*c59a5c48SFrançois Tigeot #define U8(ptr) get_u8(ctx->ctx->bios, (ptr))
33*c59a5c48SFrançois Tigeot #define CU8(ptr) get_u8(ctx->bios, (ptr))
get_u16(void * bios,int ptr)34*c59a5c48SFrançois Tigeot static inline uint16_t get_u16(void *bios, int ptr)
35*c59a5c48SFrançois Tigeot {
36*c59a5c48SFrançois Tigeot return get_u8(bios ,ptr)|(((uint16_t)get_u8(bios, ptr+1))<<8);
37*c59a5c48SFrançois Tigeot }
38*c59a5c48SFrançois Tigeot #define U16(ptr) get_u16(ctx->ctx->bios, (ptr))
39*c59a5c48SFrançois Tigeot #define CU16(ptr) get_u16(ctx->bios, (ptr))
get_u32(void * bios,int ptr)40*c59a5c48SFrançois Tigeot static inline uint32_t get_u32(void *bios, int ptr)
41*c59a5c48SFrançois Tigeot {
42*c59a5c48SFrançois Tigeot return get_u16(bios, ptr)|(((uint32_t)get_u16(bios, ptr+2))<<16);
43*c59a5c48SFrançois Tigeot }
44*c59a5c48SFrançois Tigeot #define U32(ptr) get_u32(ctx->ctx->bios, (ptr))
45*c59a5c48SFrançois Tigeot #define CU32(ptr) get_u32(ctx->bios, (ptr))
46*c59a5c48SFrançois Tigeot #define CSTR(ptr) (((char *)(ctx->bios))+(ptr))
47*c59a5c48SFrançois Tigeot
48*c59a5c48SFrançois Tigeot #endif
49