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