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