x86bios.h revision 197444
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 197383 2009-09-21 08:17:57Z delphij $ 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 register_cs; 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 union x86_register register_ip; 74}; 75 76typedef struct x86regs x86regs_t; 77 78/* 8 bit registers */ 79#define R_AH register_a.I8_reg.h_reg 80#define R_AL register_a.I8_reg.l_reg 81#define R_BH register_b.I8_reg.h_reg 82#define R_BL register_b.I8_reg.l_reg 83#define R_CH register_c.I8_reg.h_reg 84#define R_CL register_c.I8_reg.l_reg 85#define R_DH register_d.I8_reg.h_reg 86#define R_DL register_d.I8_reg.l_reg 87 88/* 16 bit registers */ 89#define R_AX register_a.I16_reg.x_reg 90#define R_BX register_b.I16_reg.x_reg 91#define R_CX register_c.I16_reg.x_reg 92#define R_DX register_d.I16_reg.x_reg 93 94/* 32 bit extended registers */ 95#define R_EAX register_a.I32_reg.e_reg 96#define R_EBX register_b.I32_reg.e_reg 97#define R_ECX register_c.I32_reg.e_reg 98#define R_EDX register_d.I32_reg.e_reg 99 100/* special registers */ 101#define R_SP register_sp.I16_reg.x_reg 102#define R_BP register_bp.I16_reg.x_reg 103#define R_SI register_si.I16_reg.x_reg 104#define R_DI register_di.I16_reg.x_reg 105#define R_IP register_ip.I16_reg.x_reg 106#define R_FLG register_flags 107 108/* special registers */ 109#define R_ESP register_sp.I32_reg.e_reg 110#define R_EBP register_bp.I32_reg.e_reg 111#define R_ESI register_si.I32_reg.e_reg 112#define R_EDI register_di.I32_reg.e_reg 113#define R_EIP register_ip.I32_reg.e_reg 114#define R_EFLG register_flags 115 116/* segment registers */ 117#define R_CS register_cs 118#define R_DS register_ds 119#define R_SS register_ss 120#define R_ES register_es 121#define R_FS register_fs 122#define R_GS register_gs 123 124#define SEG_ADDR(x) (((x) >> 4) & 0x00F000) 125#define SEG_OFF(x) ((x) & 0x0FFFF) 126#define FARP(x) ((le32toh(x) & 0xffff) + ((le32toh(x) >> 12) & 0xffff00)) 127 128#define MAPPED_MEMORY_SIZE 0xc00000 129#define PAGE_RESERV (4096*5) 130 131__BEGIN_DECLS 132void x86biosCall(struct x86regs *regs, int intno); 133void *x86biosAlloc(int count, int *segs); 134void x86biosFree(void *pbuf, int count); 135void *x86biosOffs(uint32_t offs); 136__END_DECLS 137 138#endif /* !_X86BIOS_H_ */ 139