]>
Commit | Line | Data |
---|---|---|
8d129536 | 1 | /** @file |
2 | API between 16-bit Legacy BIOS and EFI | |
3 | ||
4 | We need to figure out what the 16-bit code is going to use to | |
5 | represent these data structures. Is a pointer SEG:OFF or 32-bit... | |
6 | ||
7 | Copyright (c) 2007-2009, Intel Corporation | |
8 | All rights reserved. This program and the accompanying materials | |
9 | are licensed and made available under the terms and conditions of the BSD License | |
10 | which accompanies this distribution. The full text of the license may be found at | |
11 | http://opensource.org/licenses/bsd-license.php | |
12 | ||
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
15 | ||
16 | @par Revision Reference: | |
17 | These definitions are from Compatibility Support Module Spec | |
18 | Version 0.97. | |
19 | ||
20 | **/ | |
21 | ||
22 | #ifndef _FRAMEWORK_LEGACY_16_H_ | |
23 | #define _FRAMEWORK_LEGACY_16_H_ | |
24 | ||
25 | #include <Base.h> | |
26 | ||
27 | #pragma pack(1) | |
28 | ||
29 | typedef UINT8 SERIAL_MODE; | |
30 | typedef UINT8 PARALLEL_MODE; | |
31 | ||
32 | #define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$') | |
33 | ||
34 | /// | |
35 | /// EFI_COMPATIBILITY16_TABLE is located at a 16-byte boundary starting with the | |
36 | /// signature "$EFI" | |
37 | /// | |
38 | typedef struct { | |
39 | UINT32 Signature; | |
40 | UINT8 TableChecksum; | |
41 | UINT8 TableLength; | |
42 | UINT8 EfiMajorRevision; | |
43 | UINT8 EfiMinorRevision; | |
44 | UINT8 TableMajorRevision; | |
45 | UINT8 TableMinorRevision; | |
46 | UINT16 Reserved; | |
47 | UINT16 Compatibility16CallSegment; | |
48 | UINT16 Compatibility16CallOffset; | |
49 | UINT16 PnPInstallationCheckSegment; | |
50 | UINT16 PnPInstallationCheckOffset; | |
51 | UINT32 EfiSystemTable; ///< The physical address of EFI_SYSTEM_TABLE | |
52 | UINT32 OemIdStringPointer; | |
53 | UINT32 AcpiRsdPtrPointer; | |
54 | UINT16 OemRevision; | |
55 | UINT32 E820Pointer; | |
56 | UINT32 E820Length; | |
57 | UINT32 IrqRoutingTablePointer; | |
58 | UINT32 IrqRoutingTableLength; | |
59 | UINT32 MpTablePtr; | |
60 | UINT32 MpTableLength; | |
61 | UINT16 OemIntSegment; | |
62 | UINT16 OemIntOffset; | |
63 | UINT16 Oem32Segment; | |
64 | UINT16 Oem32Offset; | |
65 | UINT16 Oem16Segment; | |
66 | UINT16 Oem16Offset; | |
67 | UINT16 TpmSegment; | |
68 | UINT16 TpmOffset; | |
69 | UINT32 IbvPointer; | |
70 | UINT32 PciExpressBase; | |
71 | UINT8 LastPciBus; | |
72 | } EFI_COMPATIBILITY16_TABLE; | |
73 | ||
74 | /// | |
75 | /// Functions provided by the CSM binary | |
76 | /// | |
77 | typedef enum { | |
78 | Legacy16InitializeYourself = 0x0000, | |
79 | Legacy16UpdateBbs = 0x0001, | |
80 | Legacy16PrepareToBoot = 0x0002, | |
81 | Legacy16Boot = 0x0003, | |
82 | Legacy16RetrieveLastBootDevice= 0x0004, | |
83 | Legacy16DispatchOprom = 0x0005, | |
84 | Legacy16GetTableAddress = 0x0006, | |
85 | Legacy16SetKeyboardLeds = 0x0007, | |
86 | Legacy16InstallPciHandler = 0x0008 | |
87 | } EFI_COMPATIBILITY_FUNCTIONS; | |
88 | ||
89 | ||
90 | /// | |
91 | /// EFI_DISPATCH_OPROM_TABLE | |
92 | /// | |
93 | typedef struct { | |
94 | UINT16 PnPInstallationCheckSegment; | |
95 | UINT16 PnPInstallationCheckOffset; | |
96 | UINT16 OpromSegment; | |
97 | UINT8 PciBus; | |
98 | UINT8 PciDeviceFunction; | |
99 | UINT8 NumberBbsEntries; | |
100 | VOID *BbsTablePointer; ///< @bug: variable size on 32/64-bit systems. | |
101 | UINT16 RuntimeSegment; | |
102 | } EFI_DISPATCH_OPROM_TABLE; | |
103 | ||
104 | /// | |
105 | /// EFI_TO_COMPATIBILITY16_INIT_TABLE | |
106 | /// | |
107 | typedef struct { | |
108 | UINT32 BiosLessThan1MB; | |
109 | UINT32 HiPmmMemory; | |
110 | UINT32 HiPmmMemorySizeInBytes; | |
111 | UINT16 ReverseThunkCallSegment; | |
112 | UINT16 ReverseThunkCallOffset; | |
113 | UINT32 NumberE820Entries; | |
114 | UINT32 OsMemoryAbove1Mb; | |
115 | UINT32 ThunkStart; | |
116 | UINT32 ThunkSizeInBytes; | |
117 | UINT32 LowPmmMemory; | |
118 | UINT32 LowPmmMemorySizeInBytes; | |
119 | } EFI_TO_COMPATIBILITY16_INIT_TABLE; | |
120 | ||
121 | /// | |
122 | /// DEVICE_PRODUCER_SERIAL & its modes | |
123 | /// | |
124 | typedef struct { | |
125 | UINT16 Address; | |
126 | UINT8 Irq; | |
127 | SERIAL_MODE Mode; | |
128 | } DEVICE_PRODUCER_SERIAL; | |
129 | ||
130 | #define DEVICE_SERIAL_MODE_NORMAL 0x00 | |
131 | #define DEVICE_SERIAL_MODE_IRDA 0x01 | |
132 | #define DEVICE_SERIAL_MODE_ASK_IR 0x02 | |
133 | #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00 | |
134 | #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10 | |
135 | ||
136 | /// | |
137 | /// DEVICE_PRODUCER_PARALLEL & its modes | |
138 | /// | |
139 | typedef struct { | |
140 | UINT16 Address; | |
141 | UINT8 Irq; | |
142 | UINT8 Dma; | |
143 | PARALLEL_MODE Mode; | |
144 | } DEVICE_PRODUCER_PARALLEL; | |
145 | ||
146 | #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00 | |
147 | #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01 | |
148 | #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02 | |
149 | #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03 | |
150 | ||
151 | /// | |
152 | /// DEVICE_PRODUCER_FLOPPY | |
153 | /// | |
154 | typedef struct { | |
155 | UINT16 Address; | |
156 | UINT8 Irq; | |
157 | UINT8 Dma; | |
158 | UINT8 NumberOfFloppy; | |
159 | } DEVICE_PRODUCER_FLOPPY; | |
160 | ||
161 | /// | |
162 | /// LEGACY_DEVICE_FLAGS | |
163 | /// | |
164 | typedef struct { | |
165 | UINT32 A20Kybd : 1; | |
166 | UINT32 A20Port90 : 1; | |
167 | UINT32 Reserved : 30; | |
168 | } LEGACY_DEVICE_FLAGS; | |
169 | ||
170 | /// | |
171 | /// DEVICE_PRODUCER_DATA_HEADER | |
172 | /// | |
173 | typedef struct { | |
174 | DEVICE_PRODUCER_SERIAL Serial[4]; | |
175 | DEVICE_PRODUCER_PARALLEL Parallel[3]; | |
176 | DEVICE_PRODUCER_FLOPPY Floppy; | |
177 | UINT8 MousePresent; | |
178 | LEGACY_DEVICE_FLAGS Flags; | |
179 | } DEVICE_PRODUCER_DATA_HEADER; | |
180 | ||
181 | /// | |
182 | /// ATAPI_IDENTIFY | |
183 | /// | |
184 | typedef struct { | |
185 | UINT16 Raw[256]; | |
186 | } ATAPI_IDENTIFY; | |
187 | ||
188 | /// | |
189 | /// HDD_INFO & its status | |
190 | /// | |
191 | typedef struct { | |
192 | UINT16 Status; | |
193 | UINT32 Bus; | |
194 | UINT32 Device; | |
195 | UINT32 Function; | |
196 | UINT16 CommandBaseAddress; | |
197 | UINT16 ControlBaseAddress; | |
198 | UINT16 BusMasterAddress; | |
199 | UINT8 HddIrq; | |
200 | ATAPI_IDENTIFY IdentifyDrive[2]; | |
201 | } HDD_INFO; | |
202 | ||
203 | #define HDD_PRIMARY 0x01 | |
204 | #define HDD_SECONDARY 0x02 | |
205 | #define HDD_MASTER_ATAPI_CDROM 0x04 | |
206 | #define HDD_SLAVE_ATAPI_CDROM 0x08 | |
207 | #define HDD_MASTER_IDE 0x20 | |
208 | #define HDD_SLAVE_IDE 0x40 | |
209 | #define HDD_MASTER_ATAPI_ZIPDISK 0x10 | |
210 | #define HDD_SLAVE_ATAPI_ZIPDISK 0x80 | |
211 | ||
212 | /// | |
213 | /// BBS_STATUS_FLAGS | |
214 | /// | |
215 | typedef struct { | |
216 | UINT16 OldPosition : 4; | |
217 | UINT16 Reserved1 : 4; | |
218 | UINT16 Enabled : 1; | |
219 | UINT16 Failed : 1; | |
220 | UINT16 MediaPresent : 2; | |
221 | UINT16 Reserved2 : 4; | |
222 | } BBS_STATUS_FLAGS; | |
223 | ||
224 | /// | |
225 | /// BBS_TABLE, device type values & boot priority values | |
226 | /// | |
227 | typedef struct { | |
228 | UINT16 BootPriority; | |
229 | UINT32 Bus; | |
230 | UINT32 Device; | |
231 | UINT32 Function; | |
232 | UINT8 Class; | |
233 | UINT8 SubClass; | |
234 | UINT16 MfgStringOffset; | |
235 | UINT16 MfgStringSegment; | |
236 | UINT16 DeviceType; | |
237 | BBS_STATUS_FLAGS StatusFlags; | |
238 | UINT16 BootHandlerOffset; | |
239 | UINT16 BootHandlerSegment; | |
240 | UINT16 DescStringOffset; | |
241 | UINT16 DescStringSegment; | |
242 | UINT32 InitPerReserved; | |
243 | UINT32 AdditionalIrq13Handler; | |
244 | UINT32 AdditionalIrq18Handler; | |
245 | UINT32 AdditionalIrq19Handler; | |
246 | UINT32 AdditionalIrq40Handler; | |
247 | UINT8 AssignedDriveNumber; | |
248 | UINT32 AdditionalIrq41Handler; | |
249 | UINT32 AdditionalIrq46Handler; | |
250 | UINT32 IBV1; | |
251 | UINT32 IBV2; | |
252 | } BBS_TABLE; | |
253 | ||
254 | #define BBS_FLOPPY 0x01 | |
255 | #define BBS_HARDDISK 0x02 | |
256 | #define BBS_CDROM 0x03 | |
257 | #define BBS_PCMCIA 0x04 | |
258 | #define BBS_USB 0x05 | |
259 | #define BBS_EMBED_NETWORK 0x06 | |
260 | #define BBS_BEV_DEVICE 0x80 | |
261 | #define BBS_UNKNOWN 0xff | |
262 | ||
263 | #define BBS_DO_NOT_BOOT_FROM 0xFFFC | |
264 | #define BBS_LOWEST_PRIORITY 0xFFFD | |
265 | #define BBS_UNPRIORITIZED_ENTRY 0xFFFE | |
266 | #define BBS_IGNORE_ENTRY 0xFFFF | |
267 | ||
268 | /// | |
269 | /// SMM_ATTRIBUTES & relating type, port and data size constants | |
270 | /// | |
271 | typedef struct { | |
272 | UINT16 Type : 3; | |
273 | UINT16 PortGranularity : 3; | |
274 | UINT16 DataGranularity : 3; | |
275 | UINT16 Reserved : 7; | |
276 | } SMM_ATTRIBUTES; | |
277 | ||
278 | #define STANDARD_IO 0x00 | |
279 | #define STANDARD_MEMORY 0x01 | |
280 | ||
281 | #define PORT_SIZE_8 0x00 | |
282 | #define PORT_SIZE_16 0x01 | |
283 | #define PORT_SIZE_32 0x02 | |
284 | #define PORT_SIZE_64 0x03 | |
285 | ||
286 | #define DATA_SIZE_8 0x00 | |
287 | #define DATA_SIZE_16 0x01 | |
288 | #define DATA_SIZE_32 0x02 | |
289 | #define DATA_SIZE_64 0x03 | |
290 | ||
291 | /// | |
292 | /// SMM_FUNCTION & relating constants | |
293 | /// | |
294 | typedef struct { | |
295 | UINT16 Function : 15; | |
296 | UINT16 Owner : 1; | |
297 | } SMM_FUNCTION; | |
298 | ||
299 | #define INT15_D042 0x0000 | |
300 | #define GET_USB_BOOT_INFO 0x0001 | |
301 | #define DMI_PNP_50_57 0x0002 | |
302 | ||
303 | #define STANDARD_OWNER 0x0 | |
304 | #define OEM_OWNER 0x1 | |
305 | ||
306 | /** | |
307 | * SMM_ENTRY | |
308 | * | |
309 | * This structure assumes both port and data sizes are 1. SmmAttribute must be | |
310 | * properly to reflect that assumption. | |
311 | **/ | |
312 | typedef struct { | |
313 | SMM_ATTRIBUTES SmmAttributes; | |
314 | SMM_FUNCTION SmmFunction; | |
315 | UINT8 SmmPort; | |
316 | UINT8 SmmData; | |
317 | } SMM_ENTRY; | |
318 | ||
319 | /// | |
320 | /// SMM_TABLE | |
321 | /// | |
322 | typedef struct { | |
323 | UINT16 NumSmmEntries; | |
324 | SMM_ENTRY SmmEntry; | |
325 | } SMM_TABLE; | |
326 | ||
327 | /// | |
328 | /// UDC_ATTRIBUTES | |
329 | /// | |
330 | typedef struct { | |
331 | UINT8 DirectoryServiceValidity : 1; | |
332 | UINT8 RabcaUsedFlag : 1; | |
333 | UINT8 ExecuteHddDiagnosticsFlag : 1; | |
334 | UINT8 Reserved : 5; | |
335 | } UDC_ATTRIBUTES; | |
336 | ||
337 | /// | |
338 | /// UD_TABLE | |
339 | /// | |
340 | typedef struct { | |
341 | UDC_ATTRIBUTES Attributes; | |
342 | UINT8 DeviceNumber; | |
343 | UINT8 BbsTableEntryNumberForParentDevice; | |
344 | UINT8 BbsTableEntryNumberForBoot; | |
345 | UINT8 BbsTableEntryNumberForHddDiag; | |
346 | UINT8 BeerData[128]; | |
347 | UINT8 ServiceAreaData[64]; | |
348 | } UD_TABLE; | |
349 | ||
350 | #define EFI_TO_LEGACY_MAJOR_VERSION 0x02 | |
351 | #define EFI_TO_LEGACY_MINOR_VERSION 0x00 | |
352 | #define MAX_IDE_CONTROLLER 8 | |
353 | ||
354 | /// | |
355 | /// EFI_TO_COMPATIBILITY16_BOOT_TABLE | |
356 | /// | |
357 | typedef struct { | |
358 | UINT16 MajorVersion; | |
359 | UINT16 MinorVersion; | |
360 | UINT32 AcpiTable; ///< 4 GB range | |
361 | UINT32 SmbiosTable; ///< 4 GB range | |
362 | UINT32 SmbiosTableLength; | |
363 | // | |
364 | // Legacy SIO state | |
365 | // | |
366 | DEVICE_PRODUCER_DATA_HEADER SioData; | |
367 | UINT16 DevicePathType; | |
368 | UINT16 PciIrqMask; | |
369 | UINT32 NumberE820Entries; | |
370 | // | |
371 | // Controller & Drive Identify[2] per controller information | |
372 | // | |
373 | HDD_INFO HddInfo[MAX_IDE_CONTROLLER]; | |
374 | UINT32 NumberBbsEntries; | |
375 | UINT32 BbsTable; | |
376 | UINT32 SmmTable; | |
377 | UINT32 OsMemoryAbove1Mb; | |
378 | UINT32 UnconventionalDeviceTable; | |
379 | } EFI_TO_COMPATIBILITY16_BOOT_TABLE; | |
380 | ||
381 | /// | |
382 | /// EFI_LEGACY_INSTALL_PCI_HANDLER | |
383 | /// | |
384 | typedef struct { | |
385 | UINT8 PciBus; | |
386 | UINT8 PciDeviceFun; | |
387 | UINT8 PciSegment; | |
388 | UINT8 PciClass; | |
389 | UINT8 PciSubclass; | |
390 | UINT8 PciInterface; | |
391 | // | |
392 | // Primary section | |
393 | // | |
394 | UINT8 PrimaryIrq; | |
395 | UINT8 PrimaryReserved; | |
396 | UINT16 PrimaryControl; | |
397 | UINT16 PrimaryBase; | |
398 | UINT16 PrimaryBusMaster; | |
399 | // | |
400 | // Secondary Section | |
401 | // | |
402 | UINT8 SecondaryIrq; | |
403 | UINT8 SecondaryReserved; | |
404 | UINT16 SecondaryControl; | |
405 | UINT16 SecondaryBase; | |
406 | UINT16 SecondaryBusMaster; | |
407 | } EFI_LEGACY_INSTALL_PCI_HANDLER; | |
408 | ||
409 | // | |
410 | // Restore default pack value | |
411 | // | |
412 | #pragma pack() | |
413 | ||
414 | #endif /* _FRAMEWORK_LEGACY_16_H_ */ |