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