Path: blob/master/drivers/gpu/drm/amd/include/atom-bits.h
26517 views
/*1* Copyright 2008 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21* Author: Stanislaw Skowronek22*/2324#ifndef ATOM_BITS_H25#define ATOM_BITS_H2627static inline uint8_t get_u8(void *bios, int ptr)28{29return ((unsigned char *)bios)[ptr];30}31#define U8(ptr) get_u8(ctx->ctx->bios, (ptr))32#define CU8(ptr) get_u8(ctx->bios, (ptr))33static inline uint16_t get_u16(void *bios, int ptr)34{35return get_u8(bios, ptr)|(((uint16_t)get_u8(bios, ptr+1))<<8);36}37#define U16(ptr) get_u16(ctx->ctx->bios, (ptr))38#define CU16(ptr) get_u16(ctx->bios, (ptr))39static inline uint32_t get_u32(void *bios, int ptr)40{41return get_u16(bios, ptr)|(((uint32_t)get_u16(bios, ptr+2))<<16);42}43#define U32(ptr) get_u32(ctx->ctx->bios, (ptr))44#define CU32(ptr) get_u32(ctx->bios, (ptr))45#define CSTR(ptr) (((char *)(ctx->bios))+(ptr))4647#endif484950