1 #ifndef _PCBIOS_H_ 2 #define _PCBIOS_H_ 3 4 #ifdef __ASM__ 5 #define EFLAGS_CF HEX(01) 6 #define EFLAGS_ZF HEX(40) 7 #define EFLAGS_SF HEX(80) 8 #endif 9 10 #ifndef __ASM__ 11 12 #define MAX_BIOS_DESCRIPTORS 80 13 14 typedef enum 15 { 16 // ACPI 1.0. 17 BiosMemoryUsable = 1, 18 BiosMemoryReserved = 2, 19 BiosMemoryAcpiReclaim = 3, 20 BiosMemoryAcpiNvs = 4, 21 // ACPI 3.0. 22 BiosMemoryUnusable = 5, 23 // ACPI 4.0. 24 BiosMemoryDisabled = 6, 25 // ACPI 6.0. 26 BiosMemoryPersistent = 7, 27 BiosMemoryUndefined08 = 8, 28 BiosMemoryUndefined09 = 9, 29 BiosMemoryUndefined10 = 10, 30 BiosMemoryUndefined11 = 11, 31 BiosMemoryOemDefined12 = 12 32 // BiosMemoryUndefinedNN = 13-0xEFFFFFFF 33 // BiosMemoryOemDefinedNN = 0xF0000000-0xFFFFFFFF 34 } BIOS_MEMORY_TYPE; 35 36 typedef struct 37 { 38 // ACPI 1.0. 39 ULONGLONG BaseAddress; 40 ULONGLONG Length; 41 ULONG Type; 42 // ACPI 3.0. 43 union 44 { 45 ULONG ExtendedAttributesAsULONG; 46 47 struct 48 { 49 // Bit 0. ACPI 3.0. 50 // As of ACPI 4.0, became "Reserved -> must be 1". 51 ULONG Enabled_Reserved : 1; 52 // Bit 1. ACPI 3.0. 53 // As of ACPI 6.1, became "Unimplemented -> Deprecated". 54 // As of ACPI 6.3, became "Reserved -> must be 0". 55 ULONG NonVolatile_Deprecated_Reserved : 1; 56 // Bit 2. ACPI 4.0. 57 // As of ACPI 6.1, became "Unimplemented -> Deprecated". 58 // As of ACPI 6.3, became "Reserved -> must be 0". 59 ULONG SlowAccess_Deprecated_Reserved : 1; 60 // Bit 3. ACPI 4.0. 61 // ACPI 5.0-A added "Used only on PC-AT BIOS" (not UEFI). 62 ULONG ErrorLog : 1; 63 // Bits 4-31. ACPI 3.0. 64 ULONG Reserved : 28; 65 } ExtendedAttributes; 66 }; 67 } BIOS_MEMORY_MAP, *PBIOS_MEMORY_MAP; 68 69 /* Int 15h AX=E820h Entry minimal size. */ 70 C_ASSERT(FIELD_OFFSET(BIOS_MEMORY_MAP, ExtendedAttributes) == 20); 71 /* Int 15h AX=E820h Entry maximal size. */ 72 C_ASSERT(sizeof(BIOS_MEMORY_MAP) == 24); 73 74 /* FIXME: Should be moved to NDK, and respective ACPI header files */ 75 typedef struct _ACPI_BIOS_DATA 76 { 77 PHYSICAL_ADDRESS RSDTAddress; 78 ULONGLONG Count; 79 BIOS_MEMORY_MAP MemoryMap[1]; /* Count of BIOS memory map entries */ 80 } ACPI_BIOS_DATA, *PACPI_BIOS_DATA; 81 82 typedef struct _DOCKING_STATE_INFORMATION 83 { 84 USHORT Unused[5]; 85 USHORT ReturnCode; 86 } DOCKING_STATE_INFORMATION, *PDOCKING_STATE_INFORMATION; 87 88 #include <pshpack1.h> 89 typedef struct 90 { 91 unsigned long eax; 92 unsigned long ebx; 93 unsigned long ecx; 94 unsigned long edx; 95 96 unsigned long esi; 97 unsigned long edi; 98 unsigned long ebp; 99 100 unsigned short ds; 101 unsigned short es; 102 unsigned short fs; 103 unsigned short gs; 104 105 unsigned long eflags; 106 107 } DWORDREGS; 108 109 typedef struct 110 { 111 unsigned short ax, _upper_ax; 112 unsigned short bx, _upper_bx; 113 unsigned short cx, _upper_cx; 114 unsigned short dx, _upper_dx; 115 116 unsigned short si, _upper_si; 117 unsigned short di, _upper_di; 118 unsigned short bp, _upper_bp; 119 120 unsigned short ds; 121 unsigned short es; 122 unsigned short fs; 123 unsigned short gs; 124 125 unsigned short flags, _upper_flags; 126 127 } WORDREGS; 128 129 typedef struct 130 { 131 unsigned char al; 132 unsigned char ah; 133 unsigned short _upper_ax; 134 unsigned char bl; 135 unsigned char bh; 136 unsigned short _upper_bx; 137 unsigned char cl; 138 unsigned char ch; 139 unsigned short _upper_cx; 140 unsigned char dl; 141 unsigned char dh; 142 unsigned short _upper_dx; 143 144 unsigned short si, _upper_si; 145 unsigned short di, _upper_di; 146 unsigned short bp, _upper_bp; 147 148 unsigned short ds; 149 unsigned short es; 150 unsigned short fs; 151 unsigned short gs; 152 153 unsigned short flags, _upper_flags; 154 155 } BYTEREGS; 156 157 158 typedef union 159 { 160 DWORDREGS x; 161 DWORDREGS d; 162 WORDREGS w; 163 BYTEREGS b; 164 } REGS; 165 #include <poppack.h> 166 167 // Int386() 168 // 169 // Real mode interrupt vector interface 170 // 171 // (E)FLAGS can *only* be returned by this function, not set. 172 // Make sure all memory pointers are in SEG:OFFS format and 173 // not linear addresses, unless the interrupt handler 174 // specifically handles linear addresses. 175 int __cdecl Int386(int ivec, REGS* in, REGS* out); 176 177 // This macro tests the Carry Flag 178 // If CF is set then the call failed (usually) 179 #define INT386_SUCCESS(regs) ((regs.x.eflags & EFLAGS_CF) == 0) 180 181 VOID __cdecl ChainLoadBiosBootSectorCode( 182 IN UCHAR BootDrive OPTIONAL, 183 IN ULONG BootPartition OPTIONAL); 184 185 VOID __cdecl Relocator16Boot( 186 IN REGS* In, 187 IN USHORT StackSegment, 188 IN USHORT StackPointer, 189 IN USHORT CodeSegment, 190 IN USHORT CodePointer); 191 192 VOID __cdecl Reboot(VOID); 193 VOID DetectHardware(VOID); 194 195 #endif /* ! __ASM__ */ 196 197 /* Layout of the REGS structure */ 198 #define REGS_EAX 0 199 #define REGS_EBX 4 200 #define REGS_ECX 8 201 #define REGS_EDX 12 202 #define REGS_ESI 16 203 #define REGS_EDI 20 204 #define REGS_EBP 24 205 #define REGS_DS 28 206 #define REGS_ES 30 207 #define REGS_FS 32 208 #define REGS_GS 34 209 #define REGS_EFLAGS 36 210 #define REGS_SIZE 40 211 212 #endif /* _PCBIOS_H_ */ 213