1254885Sdumbbell/* 2254885Sdumbbell * Copyright 2008 Advanced Micro Devices, Inc. 3254885Sdumbbell * 4254885Sdumbbell * Permission is hereby granted, free of charge, to any person obtaining a 5254885Sdumbbell * copy of this software and associated documentation files (the "Software"), 6254885Sdumbbell * to deal in the Software without restriction, including without limitation 7254885Sdumbbell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8254885Sdumbbell * and/or sell copies of the Software, and to permit persons to whom the 9254885Sdumbbell * Software is furnished to do so, subject to the following conditions: 10254885Sdumbbell * 11254885Sdumbbell * The above copyright notice and this permission notice shall be included in 12254885Sdumbbell * all copies or substantial portions of the Software. 13254885Sdumbbell * 14254885Sdumbbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15254885Sdumbbell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16254885Sdumbbell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17254885Sdumbbell * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18254885Sdumbbell * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19254885Sdumbbell * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20254885Sdumbbell * OTHER DEALINGS IN THE SOFTWARE. 21254885Sdumbbell * 22254885Sdumbbell * Author: Stanislaw Skowronek 23254885Sdumbbell */ 24254885Sdumbbell 25254885Sdumbbell#ifndef ATOM_BITS_H 26254885Sdumbbell#define ATOM_BITS_H 27254885Sdumbbell 28254885Sdumbbell#include <sys/cdefs.h> 29254885Sdumbbell__FBSDID("$FreeBSD$"); 30254885Sdumbbell 31254885Sdumbbellstatic inline uint8_t get_u8(void *bios, int ptr) 32254885Sdumbbell{ 33254885Sdumbbell return ((unsigned char *)bios)[ptr]; 34254885Sdumbbell} 35254885Sdumbbell#define U8(ptr) get_u8(ctx->ctx->bios, (ptr)) 36254885Sdumbbell#define CU8(ptr) get_u8(ctx->bios, (ptr)) 37254885Sdumbbellstatic inline uint16_t get_u16(void *bios, int ptr) 38254885Sdumbbell{ 39254885Sdumbbell return get_u8(bios ,ptr)|(((uint16_t)get_u8(bios, ptr+1))<<8); 40254885Sdumbbell} 41254885Sdumbbell#define U16(ptr) get_u16(ctx->ctx->bios, (ptr)) 42254885Sdumbbell#define CU16(ptr) get_u16(ctx->bios, (ptr)) 43254885Sdumbbellstatic inline uint32_t get_u32(void *bios, int ptr) 44254885Sdumbbell{ 45254885Sdumbbell return get_u16(bios, ptr)|(((uint32_t)get_u16(bios, ptr+2))<<16); 46254885Sdumbbell} 47254885Sdumbbell#define U32(ptr) get_u32(ctx->ctx->bios, (ptr)) 48254885Sdumbbell#define CU32(ptr) get_u32(ctx->bios, (ptr)) 49254885Sdumbbell#define CSTR(ptr) (((char *)(ctx->bios))+(ptr)) 50254885Sdumbbell 51254885Sdumbbell#endif 52