x86bios.h revision 197493
1/*- 2 * Written by paradox <ddkprog@yahoo.com> 3 * Public domain. 4 * 5 * x86 registers were borrowed from x86emu.h x86emu_regs.h 6 * for compatability. 7 * 8 * $FreeBSD: head/sys/compat/x86bios/x86bios.h 197493 2009-09-25 17:56:32Z jkim $ 9 */ 10 11#ifndef _X86BIOS_H_ 12#define _X86BIOS_H_ 13 14#include <sys/types.h> 15#include <sys/endian.h> 16#include <sys/systm.h> 17 18#ifdef __BIG_ENDIAN__ 19 20struct x86_register32 { 21 uint32_t e_reg; 22}; 23 24struct x86_register16 { 25 uint16_t filler0; 26 uint16_t x_reg; 27}; 28 29struct x86_register8 { 30 uint8_t filler0, filler1; 31 uint8_t h_reg, l_reg; 32}; 33 34#else /* !__BIG_ENDIAN__ */ 35 36struct x86_register32 { 37 uint32_t e_reg; 38}; 39 40struct x86_register16 { 41 uint16_t x_reg; 42}; 43 44struct x86_register8 { 45 uint8_t l_reg, h_reg; 46}; 47 48#endif /* __BIG_ENDIAN__ */ 49 50union x86_register { 51 struct x86_register32 I32_reg; 52 struct x86_register16 I16_reg; 53 struct x86_register8 I8_reg; 54}; 55 56struct x86regs { 57 uint16_t padding; /* CS is unused. */ 58 uint16_t register_ds; 59 uint16_t register_es; 60 uint16_t register_fs; 61 uint16_t register_gs; 62 uint16_t register_ss; 63 uint32_t register_flags; 64 union x86_register register_a; 65 union x86_register register_b; 66 union x86_register register_c; 67 union x86_register register_d; 68 69 union x86_register register_sp; 70 union x86_register register_bp; 71 union x86_register register_si; 72 union x86_register register_di; 73}; 74 75typedef struct x86regs x86regs_t; 76 77/* 8 bit registers */ 78#define R_AH register_a.I8_reg.h_reg 79#define R_AL register_a.I8_reg.l_reg 80#define R_BH register_b.I8_reg.h_reg 81#define R_BL register_b.I8_reg.l_reg 82#define R_CH register_c.I8_reg.h_reg 83#define R_CL register_c.I8_reg.l_reg 84#define R_DH register_d.I8_reg.h_reg 85#define R_DL register_d.I8_reg.l_reg 86 87/* 16 bit registers */ 88#define R_AX register_a.I16_reg.x_reg 89#define R_BX register_b.I16_reg.x_reg 90#define R_CX register_c.I16_reg.x_reg 91#define R_DX register_d.I16_reg.x_reg 92 93/* 32 bit extended registers */ 94#define R_EAX register_a.I32_reg.e_reg 95#define R_EBX register_b.I32_reg.e_reg 96#define R_ECX register_c.I32_reg.e_reg 97#define R_EDX register_d.I32_reg.e_reg 98 99/* special registers */ 100#define R_SP register_sp.I16_reg.x_reg 101#define R_BP register_bp.I16_reg.x_reg 102#define R_SI register_si.I16_reg.x_reg 103#define R_DI register_di.I16_reg.x_reg 104#define R_FLG register_flags 105 106/* special registers */ 107#define R_ESP register_sp.I32_reg.e_reg 108#define R_EBP register_bp.I32_reg.e_reg 109#define R_ESI register_si.I32_reg.e_reg 110#define R_EDI register_di.I32_reg.e_reg 111#define R_EFLG register_flags 112 113/* segment registers */ 114#define R_DS register_ds 115#define R_SS register_ss 116#define R_ES register_es 117#define R_FS register_fs 118#define R_GS register_gs 119 120#define SEG_ADDR(x) (((x) >> 4) & 0x00F000) 121#define SEG_OFF(x) ((x) & 0x0FFFF) 122#define FARP(x) ((le32toh(x) & 0xffff) + ((le32toh(x) >> 12) & 0xffff00)) 123 124#define MAPPED_MEMORY_SIZE (1024 * 1024) 125#define PAGE_RESERV (4096 * 5) 126 127__BEGIN_DECLS 128void *x86bios_alloc(int count, int *segs); 129void x86bios_free(void *pbuf, int count); 130void x86bios_intr(struct x86regs *regs, int intno); 131void *x86bios_offset(uint32_t offs); 132__END_DECLS 133 134#endif /* !_X86BIOS_H_ */ 135