1 // Structure layout of cpu registers the the bios uses.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
5 // This file may be distributed under the terms of the GNU GPLv3 license.
16 #define CR0_PG (1<<31) // Paging
17 #define CR0_CD (1<<30) // Cache disable
18 #define CR0_NW (1<<29) // Not Write-through
19 #define CR0_PE (1<<0) // Protection enable
24 /****************************************************************
25 * Registers saved/restored in romlayout.S
26 ****************************************************************/
28 #include "types.h" // u16
30 #define UREG(ER, R, RH, RL) union { u32 ER; struct { u16 R; u16 R ## _hi; }; struct { u8 RL; u8 RH; u8 R ## _hilo; u8 R ## _hihi; }; }
32 // Layout of registers passed in to irq handlers. Note that this
33 // layout corresponds to code in romlayout.S - don't change it here
34 // without also updating the assembler code.
38 UREG(edi, di, di_hi, di_lo);
39 UREG(esi, si, si_hi, si_lo);
40 UREG(ebx, bx, bh, bl);
41 UREG(edx, dx, dh, dl);
42 UREG(ecx, cx, ch, cl);
43 UREG(eax, ax, ah, al);
50 /****************************************************************
52 ****************************************************************/
55 set_cf(struct bregs *regs, int cond)
63 // Frequently used return codes
64 #define RET_EUNSUPPORTED 0x86
67 set_success(struct bregs *regs)
73 set_code_success(struct bregs *regs)
80 set_fail_silent(struct bregs *regs)
86 set_code_fail_silent(struct bregs *regs, u8 code)
92 #define set_fail(regs) \
93 __set_fail((regs), __LINE__, __func__)
94 #define set_code_fail(regs, code) \
95 __set_code_fail((regs), (code) | (__LINE__ << 8), __func__)
98 void __set_fail(struct bregs *regs, int lineno, const char *fname);
99 void __set_code_fail(struct bregs *regs, u32 linecode, const char *fname);
101 #endif // !__ASSEMBLY__