SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate symbol
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / LegacyBios.h
CommitLineData
79964ac8 1/** @file\r
2 The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage\r
87d63447 3 under EFI and Legacy OS boot. This file also includes all the related\r
4 COMPATIBILIY16 structures and defintions.\r
79964ac8 5\r
6 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow\r
7 well known naming conventions.\r
8\r
5259c97d 9 Thunk is the code that switches from 32-bit protected environment into the 16-bit real-mode\r
10 environment. Reverse thunk is the code that does the opposite.\r
79964ac8 11\r
881644d7 12Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
f22f941e 13This program and the accompanying materials are licensed and made available under \r
14the terms and conditions of the BSD License that accompanies this distribution. \r
15The full text of the license may be found at\r
16http://opensource.org/licenses/bsd-license.php. \r
17 \r
18THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
19WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
79964ac8 20\r
79964ac8 21 @par Revision Reference:\r
22 This protocol is defined in Framework for EFI Compatibility Support Module spec\r
881644d7 23 Version 0.98.\r
79964ac8 24\r
25**/\r
26\r
27#ifndef _EFI_LEGACY_BIOS_H_\r
28#define _EFI_LEGACY_BIOS_H_\r
29\r
87d63447 30///\r
31/// \r
32///\r
33#pragma pack(1)\r
34\r
35typedef UINT8 SERIAL_MODE;\r
36typedef UINT8 PARALLEL_MODE;\r
37\r
38#define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$')\r
39\r
40///\r
41/// There is a table located within the traditional BIOS in either the 0xF000:xxxx or 0xE000:xxxx\r
42/// physical address range. It is located on a 16-byte boundary and provides the physical address of the\r
43/// entry point for the Compatibility16 functions. These functions provide the platform-specific\r
44/// information that is required by the generic EfiCompatibility code. The functions are invoked via\r
45/// thunking by using EFI_LEGACY_BIOS_PROTOCOL.FarCall86() with the 32-bit physical\r
46/// entry point.\r
47///\r
48typedef struct {\r
49 ///\r
50 /// The string "$EFI" denotes the start of the EfiCompatibility table. Byte 0 is "I," byte\r
51 /// 1 is "F," byte 2 is "E," and byte 3 is "$" and is normally accessed as a DWORD or UINT32.\r
52 ///\r
53 UINT32 Signature;\r
54 \r
55 ///\r
56 /// The value required such that byte checksum of TableLength equals zero.\r
57 ///\r
58 UINT8 TableChecksum;\r
59 \r
60 ///\r
61 /// The length of this table.\r
62 ///\r
63 UINT8 TableLength;\r
64 \r
65 ///\r
66 /// The major EFI revision for which this table was generated.\r
67 /// \r
68 UINT8 EfiMajorRevision;\r
69 \r
70 ///\r
71 /// The minor EFI revision for which this table was generated.\r
72 ///\r
73 UINT8 EfiMinorRevision;\r
74 \r
75 ///\r
76 /// The major revision of this table.\r
77 ///\r
78 UINT8 TableMajorRevision;\r
79 \r
80 ///\r
81 /// The minor revision of this table.\r
82 ///\r
83 UINT8 TableMinorRevision;\r
84 \r
85 ///\r
86 /// Reserved for future usage.\r
87 ///\r
88 UINT16 Reserved;\r
89 \r
90 ///\r
91 /// The segment of the entry point within the traditional BIOS for Compatibility16 functions.\r
92 ///\r
93 UINT16 Compatibility16CallSegment;\r
94 \r
95 ///\r
96 /// The offset of the entry point within the traditional BIOS for Compatibility16 functions.\r
97 ///\r
98 UINT16 Compatibility16CallOffset;\r
99 \r
100 ///\r
f22f941e 101 /// The segment of the entry point within the traditional BIOS for EfiCompatibility \r
102 /// to invoke the PnP installation check.\r
87d63447 103 ///\r
104 UINT16 PnPInstallationCheckSegment;\r
105 \r
106 ///\r
f22f941e 107 /// The Offset of the entry point within the traditional BIOS for EfiCompatibility \r
108 /// to invoke the PnP installation check.\r
87d63447 109 ///\r
110 UINT16 PnPInstallationCheckOffset;\r
111 \r
112 ///\r
f22f941e 113 /// EFI system resources table. Type EFI_SYSTEM_TABLE is defined in the IntelPlatform \r
114 ///Innovation Framework for EFI Driver Execution Environment Core Interface Specification (DXE CIS).\r
87d63447 115 ///\r
116 UINT32 EfiSystemTable; \r
117 \r
118 ///\r
119 /// The address of an OEM-provided identifier string. The string is null terminated.\r
120 ///\r
121 UINT32 OemIdStringPointer;\r
122 \r
123 ///\r
124 /// The 32-bit physical address where ACPI RSD PTR is stored within the traditional\r
125 /// BIOS. The remained of the ACPI tables are located at their EFI addresses. The size\r
126 /// reserved is the maximum for ACPI 2.0. The EfiCompatibility will fill in the ACPI\r
127 /// RSD PTR with either the ACPI 1.0b or 2.0 values.\r
128 ///\r
129 UINT32 AcpiRsdPtrPointer;\r
130 \r
131 ///\r
132 /// The OEM revision number. Usage is undefined but provided for OEM module usage.\r
133 ///\r
134 UINT16 OemRevision;\r
135 \r
136 ///\r
137 /// The 32-bit physical address where INT15 E820 data is stored within the traditional\r
138 /// BIOS. The EfiCompatibility code will fill in the E820Pointer value and copy the\r
139 /// data to the indicated area.\r
140 ///\r
141 UINT32 E820Pointer;\r
142 \r
143 ///\r
144 /// The length of the E820 data and is filled in by the EfiCompatibility code.\r
145 ///\r
146 UINT32 E820Length;\r
147 \r
148 ///\r
149 /// The 32-bit physical address where the $PIR table is stored in the traditional BIOS.\r
150 /// The EfiCompatibility code will fill in the IrqRoutingTablePointer value and\r
151 /// copy the data to the indicated area.\r
152 ///\r
153 UINT32 IrqRoutingTablePointer;\r
154 \r
155 ///\r
156 /// The length of the $PIR table and is filled in by the EfiCompatibility code.\r
157 ///\r
158 UINT32 IrqRoutingTableLength;\r
159 \r
160 ///\r
161 /// The 32-bit physical address where the MP table is stored in the traditional BIOS.\r
f22f941e 162 /// The EfiCompatibility code will fill in the MpTablePtr value and copy the data \r
163 /// to the indicated area.\r
87d63447 164 ///\r
165 UINT32 MpTablePtr;\r
166 \r
167 ///\r
168 /// The length of the MP table and is filled in by the EfiCompatibility code.\r
169 ///\r
170 UINT32 MpTableLength;\r
171 \r
172 ///\r
173 /// The segment of the OEM-specific INT table/code.\r
174 /// \r
175 UINT16 OemIntSegment;\r
176 \r
177 ///\r
178 /// The offset of the OEM-specific INT table/code.\r
179 ///\r
180 UINT16 OemIntOffset;\r
181 \r
182 ///\r
183 /// The segment of the OEM-specific 32-bit table/code.\r
184 ///\r
185 UINT16 Oem32Segment;\r
186 \r
187 ///\r
188 /// The offset of the OEM-specific 32-bit table/code.\r
189 ///\r
190 UINT16 Oem32Offset;\r
191 \r
192 ///\r
193 /// The segment of the OEM-specific 16-bit table/code.\r
194 ///\r
195 UINT16 Oem16Segment;\r
196 \r
197 ///\r
198 /// The offset of the OEM-specific 16-bit table/code.\r
199 ///\r
200 UINT16 Oem16Offset;\r
201 \r
202 ///\r
203 /// The segment of the TPM binary passed to 16-bit CSM.\r
204 ///\r
205 UINT16 TpmSegment;\r
206 \r
207 ///\r
208 /// The offset of the TPM binary passed to 16-bit CSM.\r
209 ///\r
210 UINT16 TpmOffset;\r
211 \r
212 ///\r
213 /// A pointer to a string identifying the independent BIOS vendor.\r
214 ///\r
215 UINT32 IbvPointer;\r
216 \r
217 ///\r
218 /// This field is NULL for all systems not supporting PCI Express. This field is the base\r
219 /// value of the start of the PCI Express memory-mapped configuration registers and\r
220 /// must be filled in prior to EfiCompatibility code issuing the Compatibility16 function\r
221 /// Compatibility16InitializeYourself().\r
222 /// Compatibility16InitializeYourself() is defined in Compatability16\r
223 /// Functions.\r
224 ///\r
225 UINT32 PciExpressBase;\r
226 \r
227 ///\r
228 /// Maximum PCI bus number assigned.\r
229 ///\r
230 UINT8 LastPciBus;\r
881644d7
DW
231\r
232 ///\r
233 /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If\r
234 /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region\r
ed6fde41 235 /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.\r
881644d7
DW
236 ///\r
237 UINT32 UmaAddress;\r
238\r
239 ///\r
240 /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region\r
241 /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).\r
242 ///\r
243 UINT32 UmaSize;\r
244\r
245 ///\r
246 /// Start Address of high memory that can be used for permanent allocation. If zero,\r
247 /// high memory is not available for permanent allocation.\r
248 ///\r
249 UINT32 HiPermanentMemoryAddress;\r
250\r
251 ///\r
252 /// Size of high memory that can be used for permanent allocation in bytes. If zero,\r
253 /// high memory is not available for permanent allocation.\r
254 ///\r
255 UINT32 HiPermanentMemorySize;\r
87d63447 256} EFI_COMPATIBILITY16_TABLE;\r
257\r
258///\r
259/// Functions provided by the CSM binary which communicate between the EfiCompatibility \r
260/// and Compatability16 code.\r
261///\r
f22f941e 262/// Inconsistent with the specification here: \r
263/// The member's name started with "Compatibility16" [defined in Intel Framework \r
264/// Compatibility Support Module Specification / 0.97 version] \r
87d63447 265/// has been changed to "Legacy16" since keeping backward compatible.\r
266///\r
267typedef enum {\r
268 ///\r
269 /// Causes the Compatibility16 code to do any internal initialization required.\r
270 /// Input:\r
271 /// AX = Compatibility16InitializeYourself\r
272 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE\r
273 /// Return:\r
274 /// AX = Return Status codes\r
275 ///\r
276 Legacy16InitializeYourself = 0x0000,\r
277 \r
278 ///\r
279 /// Causes the Compatibility16 BIOS to perform any drive number translations to match the boot sequence.\r
280 /// Input:\r
281 /// AX = Compatibility16UpdateBbs\r
282 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
283 /// Return:\r
284 /// AX = Returned status codes\r
285 ///\r
286 Legacy16UpdateBbs = 0x0001,\r
287 \r
288 ///\r
289 /// Allows the Compatibility16 code to perform any final actions before booting. The Compatibility16\r
290 /// code is read/write.\r
291 /// Input:\r
292 /// AX = Compatibility16PrepareToBoot\r
293 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE structure \r
294 /// Return:\r
295 /// AX = Returned status codes\r
296 ///\r
297 Legacy16PrepareToBoot = 0x0002,\r
298 \r
299 ///\r
300 /// Causes the Compatibility16 BIOS to boot. The Compatibility16 code is Read/Only.\r
301 /// Input:\r
302 /// AX = Compatibility16Boot\r
303 /// Output:\r
304 /// AX = Returned status codes\r
305 ///\r
306 Legacy16Boot = 0x0003,\r
307 \r
308 ///\r
309 /// Allows the Compatibility16 code to get the last device from which a boot was attempted. This is\r
310 /// stored in CMOS and is the priority number of the last attempted boot device.\r
311 /// Input:\r
312 /// AX = Compatibility16RetrieveLastBootDevice\r
313 /// Output:\r
314 /// AX = Returned status codes\r
315 /// BX = Priority number of the boot device.\r
316 ///\r
317 Legacy16RetrieveLastBootDevice = 0x0004,\r
318 \r
319 ///\r
320 /// Allows the Compatibility16 code rehook INT13, INT18, and/or INT19 after dispatching a legacy OpROM.\r
321 /// Input:\r
322 /// AX = Compatibility16DispatchOprom\r
323 /// ES:BX = Pointer to EFI_DISPATCH_OPROM_TABLE\r
324 /// Output:\r
325 /// AX = Returned status codes\r
326 /// BX = Number of non-BBS-compliant devices found. Equals 0 if BBS compliant.\r
327 ///\r
328 Legacy16DispatchOprom = 0x0005,\r
329 \r
330 ///\r
331 /// Finds a free area in the 0xFxxxx or 0xExxxx region of the specified length and returns the address\r
332 /// of that region.\r
333 /// Input:\r
334 /// AX = Compatibility16GetTableAddress\r
335 /// BX = Allocation region\r
336 /// 00 = Allocate from either 0xE0000 or 0xF0000 64 KB blocks.\r
337 /// Bit 0 = 1 Allocate from 0xF0000 64 KB block\r
338 /// Bit 1 = 1 Allocate from 0xE0000 64 KB block\r
339 /// CX = Requested length in bytes.\r
340 /// DX = Required address alignment. Bit mapped. First non-zero bit from the right is the alignment.\r
341 /// Output:\r
342 /// AX = Returned status codes\r
343 /// DS:BX = Address of the region\r
344 ///\r
345 Legacy16GetTableAddress = 0x0006,\r
346 \r
347 ///\r
348 /// Enables the EfiCompatibility module to do any nonstandard processing of keyboard LEDs or state.\r
349 /// Input:\r
350 /// AX = Compatibility16SetKeyboardLeds\r
351 /// CL = LED status.\r
352 /// Bit 0 Scroll Lock 0 = Off\r
353 /// Bit 1 NumLock\r
354 /// Bit 2 Caps Lock\r
355 /// Output:\r
356 /// AX = Returned status codes\r
357 ///\r
358 Legacy16SetKeyboardLeds = 0x0007,\r
359 \r
360 ///\r
361 /// Enables the EfiCompatibility module to install an interrupt handler for PCI mass media devices that\r
362 /// do not have an OpROM associated with them. An example is SATA.\r
363 /// Input:\r
364 /// AX = Compatibility16InstallPciHandler\r
365 /// ES:BX = Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure\r
366 /// Output:\r
367 /// AX = Returned status codes\r
368 ///\r
369 Legacy16InstallPciHandler = 0x0008\r
370} EFI_COMPATIBILITY_FUNCTIONS;\r
371\r
372\r
373///\r
374/// EFI_DISPATCH_OPROM_TABLE\r
375///\r
376typedef struct {\r
f22f941e 377 UINT16 PnPInstallationCheckSegment; ///< A pointer to the PnpInstallationCheck data structure.\r
378 UINT16 PnPInstallationCheckOffset; ///< A pointer to the PnpInstallationCheck data structure.\r
87d63447 379 UINT16 OpromSegment; ///< The segment where the OpROM was placed. Offset is assumed to be 3.\r
380 UINT8 PciBus; ///< The PCI bus.\r
381 UINT8 PciDeviceFunction; ///< The PCI device * 0x08 | PCI function.\r
382 UINT8 NumberBbsEntries; ///< The number of valid BBS table entries upon entry and exit. The IBV code may\r
383 ///< increase this number, if BBS-compliant devices also hook INTs in order to force the\r
384 ///< OpROM BIOS Setup to be executed.\r
c5b900be 385 UINT32 BbsTablePointer; ///< A pointer to the BBS table.\r
87d63447 386 UINT16 RuntimeSegment; ///< The segment where the OpROM can be relocated to. If this value is 0x0000, this\r
387 ///< means that the relocation of this run time code is not supported.\r
388 ///< Inconsistent with specification here: \r
389 ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version] \r
390 ///< has been changed to "RuntimeSegment" since keeping backward compatible.\r
391\r
392} EFI_DISPATCH_OPROM_TABLE;\r
393\r
394///\r
395/// EFI_TO_COMPATIBILITY16_INIT_TABLE\r
396///\r
397typedef struct {\r
398 ///\r
399 /// Starting address of memory under 1 MB. The ending address is assumed to be 640 KB or 0x9FFFF.\r
400 ///\r
401 UINT32 BiosLessThan1MB;\r
402 \r
403 ///\r
f22f941e 404 /// The starting address of the high memory block.\r
87d63447 405 ///\r
406 UINT32 HiPmmMemory;\r
407 \r
408 ///\r
f22f941e 409 /// The length of high memory block.\r
87d63447 410 ///\r
411 UINT32 HiPmmMemorySizeInBytes;\r
412 \r
413 ///\r
414 /// The segment of the reverse thunk call code.\r
415 ///\r
416 UINT16 ReverseThunkCallSegment;\r
417 \r
418 ///\r
419 /// The offset of the reverse thunk call code.\r
420 ///\r
421 UINT16 ReverseThunkCallOffset;\r
422 \r
423 ///\r
424 /// The number of E820 entries copied to the Compatibility16 BIOS.\r
425 ///\r
426 UINT32 NumberE820Entries;\r
427 \r
428 ///\r
429 /// The amount of usable memory above 1 MB, e.g., E820 type 1 memory.\r
430 ///\r
431 UINT32 OsMemoryAbove1Mb;\r
432 \r
433 ///\r
434 /// The start of thunk code in main memory. Memory cannot be used by BIOS or PMM.\r
435 ///\r
436 UINT32 ThunkStart;\r
437 \r
438 ///\r
439 /// The size of the thunk code.\r
440 ///\r
441 UINT32 ThunkSizeInBytes;\r
442 \r
443 ///\r
444 /// Starting address of memory under 1 MB.\r
445 ///\r
446 UINT32 LowPmmMemory;\r
447 \r
448 ///\r
f22f941e 449 /// The length of low Memory block.\r
87d63447 450 ///\r
451 UINT32 LowPmmMemorySizeInBytes;\r
452} EFI_TO_COMPATIBILITY16_INIT_TABLE;\r
453\r
454///\r
f22f941e 455/// DEVICE_PRODUCER_SERIAL.\r
87d63447 456///\r
457typedef struct {\r
f22f941e 458 UINT16 Address; ///< I/O address assigned to the serial port.\r
87d63447 459 UINT8 Irq; ///< IRQ assigned to the serial port.\r
460 SERIAL_MODE Mode; ///< Mode of serial port. Values are defined below.\r
461} DEVICE_PRODUCER_SERIAL;\r
462\r
463///\r
f22f941e 464/// DEVICE_PRODUCER_SERIAL's modes.\r
87d63447 465///@{\r
466#define DEVICE_SERIAL_MODE_NORMAL 0x00\r
467#define DEVICE_SERIAL_MODE_IRDA 0x01\r
468#define DEVICE_SERIAL_MODE_ASK_IR 0x02\r
469#define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00\r
470#define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10\r
471///@)\r
472\r
473///\r
f22f941e 474/// DEVICE_PRODUCER_PARALLEL.\r
87d63447 475///\r
476typedef struct {\r
f22f941e 477 UINT16 Address; ///< I/O address assigned to the parallel port.\r
87d63447 478 UINT8 Irq; ///< IRQ assigned to the parallel port.\r
479 UINT8 Dma; ///< DMA assigned to the parallel port.\r
480 PARALLEL_MODE Mode; ///< Mode of the parallel port. Values are defined below.\r
481} DEVICE_PRODUCER_PARALLEL;\r
482\r
483///\r
f22f941e 484/// DEVICE_PRODUCER_PARALLEL's modes.\r
87d63447 485///@{\r
486#define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00\r
487#define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01\r
488#define DEVICE_PARALLEL_MODE_MODE_EPP 0x02\r
489#define DEVICE_PARALLEL_MODE_MODE_ECP 0x03\r
490///@}\r
491\r
492///\r
493/// DEVICE_PRODUCER_FLOPPY\r
494///\r
495typedef struct {\r
f22f941e 496 UINT16 Address; ///< I/O address assigned to the floppy.\r
87d63447 497 UINT8 Irq; ///< IRQ assigned to the floppy.\r
498 UINT8 Dma; ///< DMA assigned to the floppy.\r
499 UINT8 NumberOfFloppy; ///< Number of floppies in the system.\r
500} DEVICE_PRODUCER_FLOPPY;\r
501\r
502///\r
503/// LEGACY_DEVICE_FLAGS\r
504///\r
505typedef struct {\r
506 UINT32 A20Kybd : 1; ///< A20 controller by keyboard controller.\r
507 UINT32 A20Port90 : 1; ///< A20 controlled by port 0x92.\r
508 UINT32 Reserved : 30; ///< Reserved for future usage.\r
509} LEGACY_DEVICE_FLAGS;\r
510\r
511///\r
512/// DEVICE_PRODUCER_DATA_HEADER\r
513///\r
514typedef struct {\r
515 DEVICE_PRODUCER_SERIAL Serial[4]; ///< Data for serial port x. Type DEVICE_PRODUCER_SERIAL is defined below.\r
516 DEVICE_PRODUCER_PARALLEL Parallel[3]; ///< Data for parallel port x. Type DEVICE_PRODUCER_PARALLEL is defined below.\r
517 DEVICE_PRODUCER_FLOPPY Floppy; ///< Data for floppy. Type DEVICE_PRODUCER_FLOPPY is defined below.\r
518 UINT8 MousePresent; ///< Flag to indicate if mouse is present.\r
519 LEGACY_DEVICE_FLAGS Flags; ///< Miscellaneous Boolean state information passed to CSM.\r
520} DEVICE_PRODUCER_DATA_HEADER;\r
521\r
522///\r
523/// ATAPI_IDENTIFY\r
524///\r
525typedef struct {\r
526 UINT16 Raw[256]; ///< Raw data from the IDE IdentifyDrive command.\r
527} ATAPI_IDENTIFY;\r
528\r
529///\r
530/// HDD_INFO\r
531///\r
532typedef struct {\r
533 ///\r
534 /// Status of IDE device. Values are defined below. There is one HDD_INFO structure\r
535 /// per IDE controller. The IdentifyDrive is per drive. Index 0 is master and index\r
536 /// 1 is slave.\r
537 ///\r
538 UINT16 Status; \r
539 \r
540 ///\r
541 /// PCI bus of IDE controller.\r
542 ///\r
543 UINT32 Bus;\r
544 \r
545 ///\r
546 /// PCI device of IDE controller.\r
547 ///\r
548 UINT32 Device;\r
549 \r
550 ///\r
551 /// PCI function of IDE controller.\r
552 ///\r
553 UINT32 Function;\r
554 \r
555 ///\r
556 /// Command ports base address.\r
557 ///\r
558 UINT16 CommandBaseAddress;\r
559 \r
560 ///\r
561 /// Control ports base address.\r
562 ///\r
563 UINT16 ControlBaseAddress;\r
564 \r
565 ///\r
f22f941e 566 /// Bus master address.\r
87d63447 567 ///\r
568 UINT16 BusMasterAddress;\r
569 \r
570 UINT8 HddIrq;\r
571 \r
572 ///\r
f22f941e 573 /// Data that identifies the drive data; one per possible attached drive.\r
87d63447 574 ///\r
575 ATAPI_IDENTIFY IdentifyDrive[2];\r
576} HDD_INFO;\r
577\r
578///\r
579/// HDD_INFO status bits\r
580///\r
581#define HDD_PRIMARY 0x01\r
582#define HDD_SECONDARY 0x02\r
583#define HDD_MASTER_ATAPI_CDROM 0x04\r
584#define HDD_SLAVE_ATAPI_CDROM 0x08\r
585#define HDD_MASTER_IDE 0x20\r
586#define HDD_SLAVE_IDE 0x40\r
587#define HDD_MASTER_ATAPI_ZIPDISK 0x10\r
588#define HDD_SLAVE_ATAPI_ZIPDISK 0x80\r
589\r
590///\r
f22f941e 591/// BBS_STATUS_FLAGS;\.\r
87d63447 592///\r
593typedef struct {\r
594 UINT16 OldPosition : 4; ///< Prior priority.\r
595 UINT16 Reserved1 : 4; ///< Reserved for future use.\r
596 UINT16 Enabled : 1; ///< If 0, ignore this entry.\r
597 UINT16 Failed : 1; ///< 0 = Not known if boot failure occurred.\r
598 ///< 1 = Boot attempted failed.\r
599 \r
600 ///\r
601 /// State of media present.\r
602 /// 00 = No bootable media is present in the device.\r
603 /// 01 = Unknown if a bootable media present.\r
604 /// 10 = Media is present and appears bootable.\r
605 /// 11 = Reserved.\r
606 ///\r
607 UINT16 MediaPresent : 2;\r
608 UINT16 Reserved2 : 4; ///< Reserved for future use.\r
609} BBS_STATUS_FLAGS;\r
610\r
611///\r
f22f941e 612/// BBS_TABLE, device type values & boot priority values.\r
87d63447 613///\r
614typedef struct {\r
615 ///\r
616 /// The boot priority for this boot device. Values are defined below.\r
617 ///\r
618 UINT16 BootPriority;\r
619 \r
620 ///\r
621 /// The PCI bus for this boot device.\r
622 ///\r
623 UINT32 Bus;\r
624 \r
625 ///\r
626 /// The PCI device for this boot device.\r
627 ///\r
628 UINT32 Device;\r
629 \r
630 ///\r
631 /// The PCI function for the boot device.\r
632 ///\r
633 UINT32 Function;\r
634 \r
635 ///\r
636 /// The PCI class for this boot device.\r
637 ///\r
638 UINT8 Class;\r
639 \r
640 ///\r
641 /// The PCI Subclass for this boot device.\r
642 ///\r
643 UINT8 SubClass;\r
644 \r
645 ///\r
646 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.\r
647 ///\r
648 UINT16 MfgStringOffset;\r
649 \r
650 ///\r
651 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.\r
652 /// \r
653 UINT16 MfgStringSegment;\r
654 \r
655 ///\r
656 /// BBS device type. BBS device types are defined below.\r
657 ///\r
658 UINT16 DeviceType;\r
659 \r
660 ///\r
661 /// Status of this boot device. Type BBS_STATUS_FLAGS is defined below.\r
662 ///\r
663 BBS_STATUS_FLAGS StatusFlags;\r
664 \r
665 ///\r
666 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for\r
667 /// BCV devices.\r
668 ///\r
669 UINT16 BootHandlerOffset;\r
670 \r
671 ///\r
672 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for\r
673 /// BCV devices.\r
674 /// \r
675 UINT16 BootHandlerSegment;\r
676 \r
677 ///\r
678 /// Segment:offset address of an ASCIIZ description string describing this device.\r
679 ///\r
680 UINT16 DescStringOffset;\r
681\r
682 ///\r
683 /// Segment:offset address of an ASCIIZ description string describing this device.\r
684 ///\r
685 UINT16 DescStringSegment;\r
686 \r
687 ///\r
688 /// Reserved.\r
689 ///\r
690 UINT32 InitPerReserved;\r
691 \r
692 ///\r
693 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
694 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
695 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
696 ///\r
697 UINT32 AdditionalIrq13Handler;\r
698 \r
699 ///\r
700 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
701 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
702 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
703 /// \r
704 UINT32 AdditionalIrq18Handler;\r
705 \r
706 ///\r
707 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
708 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
709 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
710 /// \r
711 UINT32 AdditionalIrq19Handler;\r
712 \r
713 ///\r
714 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM\r
715 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI\r
716 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup\r
717 /// \r
718 UINT32 AdditionalIrq40Handler;\r
719 UINT8 AssignedDriveNumber;\r
720 UINT32 AdditionalIrq41Handler;\r
721 UINT32 AdditionalIrq46Handler;\r
722 UINT32 IBV1;\r
723 UINT32 IBV2;\r
724} BBS_TABLE;\r
725\r
726///\r
727/// BBS device type values\r
728///@{\r
729#define BBS_FLOPPY 0x01\r
730#define BBS_HARDDISK 0x02\r
731#define BBS_CDROM 0x03\r
732#define BBS_PCMCIA 0x04\r
733#define BBS_USB 0x05\r
734#define BBS_EMBED_NETWORK 0x06\r
735#define BBS_BEV_DEVICE 0x80\r
736#define BBS_UNKNOWN 0xff\r
737///@}\r
738\r
739///\r
740/// BBS boot priority values\r
741///@{\r
742#define BBS_DO_NOT_BOOT_FROM 0xFFFC\r
743#define BBS_LOWEST_PRIORITY 0xFFFD\r
744#define BBS_UNPRIORITIZED_ENTRY 0xFFFE\r
745#define BBS_IGNORE_ENTRY 0xFFFF\r
746///@}\r
747\r
748///\r
749/// SMM_ATTRIBUTES\r
750///\r
751typedef struct {\r
752 ///\r
753 /// Access mechanism used to generate the soft SMI. Defined types are below. The other\r
754 /// values are reserved for future usage.\r
755 ///\r
756 UINT16 Type : 3;\r
757 \r
758 ///\r
f22f941e 759 /// The size of "port" in bits. Defined values are below.\r
87d63447 760 ///\r
761 UINT16 PortGranularity : 3;\r
762 \r
763 ///\r
f22f941e 764 /// The size of data in bits. Defined values are below.\r
87d63447 765 ///\r
766 UINT16 DataGranularity : 3;\r
767 \r
768 ///\r
769 /// Reserved for future use.\r
770 ///\r
771 UINT16 Reserved : 7;\r
772} SMM_ATTRIBUTES;\r
773\r
774///\r
f22f941e 775/// SMM_ATTRIBUTES type values.\r
87d63447 776///@{\r
777#define STANDARD_IO 0x00\r
778#define STANDARD_MEMORY 0x01\r
779///@}\r
780\r
781///\r
f22f941e 782/// SMM_ATTRIBUTES port size constants.\r
87d63447 783///@{\r
784#define PORT_SIZE_8 0x00\r
785#define PORT_SIZE_16 0x01\r
786#define PORT_SIZE_32 0x02\r
787#define PORT_SIZE_64 0x03\r
788///@}\r
789\r
790///\r
f22f941e 791/// SMM_ATTRIBUTES data size constants.\r
87d63447 792///@{\r
793#define DATA_SIZE_8 0x00\r
794#define DATA_SIZE_16 0x01\r
795#define DATA_SIZE_32 0x02\r
796#define DATA_SIZE_64 0x03\r
797///@}\r
798\r
799///\r
f22f941e 800/// SMM_FUNCTION & relating constants.\r
87d63447 801///\r
802typedef struct {\r
803 UINT16 Function : 15;\r
804 UINT16 Owner : 1;\r
805} SMM_FUNCTION;\r
806\r
807///\r
f22f941e 808/// SMM_FUNCTION Function constants.\r
87d63447 809///@{\r
810#define INT15_D042 0x0000\r
811#define GET_USB_BOOT_INFO 0x0001\r
812#define DMI_PNP_50_57 0x0002\r
813///@}\r
814\r
815///\r
f22f941e 816/// SMM_FUNCTION Owner constants.\r
87d63447 817///@{\r
818#define STANDARD_OWNER 0x0\r
819#define OEM_OWNER 0x1\r
820///@}\r
821\r
050b79eb 822///\r
823/// This structure assumes both port and data sizes are 1. SmmAttribute must be\r
824/// properly to reflect that assumption.\r
825///\r
87d63447 826typedef struct {\r
827 ///\r
828 /// Describes the access mechanism, SmmPort, and SmmData sizes. Type\r
829 /// SMM_ATTRIBUTES is defined below.\r
830 ///\r
831 SMM_ATTRIBUTES SmmAttributes;\r
832 \r
833 ///\r
834 /// Function Soft SMI is to perform. Type SMM_FUNCTION is defined below.\r
835 ///\r
836 SMM_FUNCTION SmmFunction;\r
837 \r
838 ///\r
f22f941e 839 /// SmmPort size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.\r
87d63447 840 ///\r
841 UINT8 SmmPort;\r
842 \r
843 ///\r
f22f941e 844 /// SmmData size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.\r
87d63447 845 ///\r
846 UINT8 SmmData;\r
847} SMM_ENTRY;\r
848\r
849///\r
850/// SMM_TABLE\r
851///\r
852typedef struct {\r
853 UINT16 NumSmmEntries; ///< Number of entries represented by SmmEntry.\r
854 SMM_ENTRY SmmEntry; ///< One entry per function. Type SMM_ENTRY is defined below.\r
855} SMM_TABLE;\r
856\r
857///\r
858/// UDC_ATTRIBUTES\r
859///\r
860typedef struct {\r
861 ///\r
862 /// This bit set indicates that the ServiceAreaData is valid.\r
863 ///\r
864 UINT8 DirectoryServiceValidity : 1;\r
865 \r
866 ///\r
867 /// This bit set indicates to use the Reserve Area Boot Code Address (RACBA) only if\r
868 /// DirectoryServiceValidity is 0.\r
869 ///\r
870 UINT8 RabcaUsedFlag : 1;\r
871 \r
872 ///\r
873 /// This bit set indicates to execute hard disk diagnostics.\r
874 ///\r
875 UINT8 ExecuteHddDiagnosticsFlag : 1;\r
876 \r
877 ///\r
878 /// Reserved for future use. Set to 0.\r
879 ///\r
880 UINT8 Reserved : 5;\r
881} UDC_ATTRIBUTES;\r
882\r
883///\r
884/// UD_TABLE\r
885///\r
886typedef struct {\r
887 ///\r
888 /// This field contains the bit-mapped attributes of the PARTIES information. Type\r
889 /// UDC_ATTRIBUTES is defined below.\r
890 ///\r
891 UDC_ATTRIBUTES Attributes;\r
892 \r
893 ///\r
894 /// This field contains the zero-based device on which the selected\r
895 /// ServiceDataArea is present. It is 0 for master and 1 for the slave device. \r
896 ///\r
897 UINT8 DeviceNumber;\r
898 \r
899 ///\r
900 /// This field contains the zero-based index into the BbsTable for the parent device.\r
901 /// This index allows the user to reference the parent device information such as PCI\r
902 /// bus, device function.\r
903 ///\r
904 UINT8 BbsTableEntryNumberForParentDevice;\r
905 \r
906 ///\r
907 /// This field contains the zero-based index into the BbsTable for the boot entry.\r
908 ///\r
909 UINT8 BbsTableEntryNumberForBoot;\r
910 \r
911 ///\r
912 /// This field contains the zero-based index into the BbsTable for the HDD diagnostics entry.\r
913 ///\r
914 UINT8 BbsTableEntryNumberForHddDiag;\r
915 \r
916 ///\r
917 /// The raw Beer data.\r
918 ///\r
919 UINT8 BeerData[128];\r
920 \r
921 ///\r
922 /// The raw data of selected service area.\r
923 ///\r
924 UINT8 ServiceAreaData[64];\r
925} UD_TABLE;\r
926\r
927#define EFI_TO_LEGACY_MAJOR_VERSION 0x02\r
928#define EFI_TO_LEGACY_MINOR_VERSION 0x00\r
929#define MAX_IDE_CONTROLLER 8\r
930\r
931///\r
932/// EFI_TO_COMPATIBILITY16_BOOT_TABLE\r
933///\r
934typedef struct {\r
935 UINT16 MajorVersion; ///< The EfiCompatibility major version number.\r
936 UINT16 MinorVersion; ///< The EfiCompatibility minor version number.\r
f22f941e 937 UINT32 AcpiTable; ///< The location of the RSDT ACPI table. < 4G range.\r
938 UINT32 SmbiosTable; ///< The location of the SMBIOS table in EFI memory. < 4G range.\r
87d63447 939 UINT32 SmbiosTableLength;\r
940 //\r
941 // Legacy SIO state\r
942 //\r
943 DEVICE_PRODUCER_DATA_HEADER SioData; ///< Standard traditional device information.\r
944 UINT16 DevicePathType; ///< The default boot type.\r
945 UINT16 PciIrqMask; ///< Mask of which IRQs have been assigned to PCI.\r
946 UINT32 NumberE820Entries; ///< Number of E820 entries. The number can change from the\r
947 ///< Compatibility16InitializeYourself() function.\r
948 //\r
949 // Controller & Drive Identify[2] per controller information\r
950 //\r
951 HDD_INFO HddInfo[MAX_IDE_CONTROLLER]; ///< Hard disk drive information, including raw Identify Drive data.\r
952 UINT32 NumberBbsEntries; ///< Number of entries in the BBS table\r
f22f941e 953 UINT32 BbsTable; ///< A pointer to the BBS table. Type BBS_TABLE is defined below.\r
954 UINT32 SmmTable; ///< A pointer to the SMM table. Type SMM_TABLE is defined below.\r
87d63447 955 UINT32 OsMemoryAbove1Mb; ///< The amount of usable memory above 1 MB, i.e. E820 type 1 memory. This value can\r
956 ///< differ from the value in EFI_TO_COMPATIBILITY16_INIT_TABLE as more\r
957 ///< memory may have been discovered.\r
958 UINT32 UnconventionalDeviceTable; ///< Information to boot off an unconventional device like a PARTIES partition. Type\r
959 ///< UD_TABLE is defined below.\r
960} EFI_TO_COMPATIBILITY16_BOOT_TABLE;\r
961\r
962///\r
963/// EFI_LEGACY_INSTALL_PCI_HANDLER\r
964///\r
965typedef struct {\r
966 UINT8 PciBus; ///< The PCI bus of the device.\r
967 UINT8 PciDeviceFun; ///< The PCI device in bits 7:3 and function in bits 2:0.\r
968 UINT8 PciSegment; ///< The PCI segment of the device.\r
969 UINT8 PciClass; ///< The PCI class code of the device.\r
970 UINT8 PciSubclass; ///< The PCI subclass code of the device.\r
971 UINT8 PciInterface; ///< The PCI interface code of the device.\r
972 //\r
973 // Primary section\r
974 //\r
975 UINT8 PrimaryIrq; ///< The primary device IRQ.\r
976 UINT8 PrimaryReserved; ///< Reserved.\r
977 UINT16 PrimaryControl; ///< The primary device control I/O base.\r
978 UINT16 PrimaryBase; ///< The primary device I/O base.\r
979 UINT16 PrimaryBusMaster; ///< The primary device bus master I/O base.\r
980 //\r
981 // Secondary Section\r
982 //\r
983 UINT8 SecondaryIrq; ///< The secondary device IRQ.\r
984 UINT8 SecondaryReserved; ///< Reserved.\r
985 UINT16 SecondaryControl; ///< The secondary device control I/O base.\r
986 UINT16 SecondaryBase; ///< The secondary device I/O base.\r
987 UINT16 SecondaryBusMaster; ///< The secondary device bus master I/O base.\r
988} EFI_LEGACY_INSTALL_PCI_HANDLER;\r
989\r
990//\r
991// Restore default pack value\r
992//\r
993#pragma pack()\r
b80fbe85 994\r
79964ac8 995#define EFI_LEGACY_BIOS_PROTOCOL_GUID \\r
996 { \\r
997 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \\r
998 }\r
999\r
1000typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL;\r
1001\r
050b79eb 1002///\r
f22f941e 1003/// Flags returned by CheckPciRom().\r
050b79eb 1004///\r
9226e4ee 1005#define NO_ROM 0x00\r
1006#define ROM_FOUND 0x01\r
1007#define VALID_LEGACY_ROM 0x02\r
f22f941e 1008#define ROM_WITH_CONFIG 0x04 ///< Not defined in the Framework CSM Specification.\r
9226e4ee 1009\r
050b79eb 1010///\r
1011/// The following macros do not appear in the Framework CSM Specification and \r
1012/// are kept for backward compatibility only. They convert 32-bit address (_Adr) \r
1013/// to Segment:Offset 16-bit form.\r
1014///\r
ce9b1e3a 1015///@{\r
79964ac8 1016#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)\r
1017#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)\r
ce9b1e3a 1018///@}\r
79964ac8 1019\r
1020#define CARRY_FLAG 0x01\r
1021\r
050b79eb 1022///\r
1023/// EFI_EFLAGS_REG\r
1024///\r
79964ac8 1025typedef struct {\r
1026 UINT32 CF:1;\r
1027 UINT32 Reserved1:1;\r
1028 UINT32 PF:1;\r
1029 UINT32 Reserved2:1;\r
1030 UINT32 AF:1;\r
1031 UINT32 Reserved3:1;\r
1032 UINT32 ZF:1;\r
1033 UINT32 SF:1;\r
1034 UINT32 TF:1;\r
1035 UINT32 IF:1;\r
1036 UINT32 DF:1;\r
1037 UINT32 OF:1;\r
1038 UINT32 IOPL:2;\r
1039 UINT32 NT:1;\r
1040 UINT32 Reserved4:2;\r
1041 UINT32 VM:1;\r
1042 UINT32 Reserved5:14;\r
1043} EFI_EFLAGS_REG;\r
1044\r
050b79eb 1045///\r
1046/// EFI_DWORD_REGS\r
1047///\r
79964ac8 1048typedef struct {\r
1049 UINT32 EAX;\r
1050 UINT32 EBX;\r
1051 UINT32 ECX;\r
1052 UINT32 EDX;\r
1053 UINT32 ESI;\r
1054 UINT32 EDI;\r
1055 EFI_EFLAGS_REG EFlags;\r
1056 UINT16 ES;\r
1057 UINT16 CS;\r
1058 UINT16 SS;\r
1059 UINT16 DS;\r
1060 UINT16 FS;\r
1061 UINT16 GS;\r
1062 UINT32 EBP;\r
1063 UINT32 ESP;\r
1064} EFI_DWORD_REGS;\r
1065\r
050b79eb 1066///\r
1067/// EFI_FLAGS_REG\r
1068///\r
79964ac8 1069typedef struct {\r
1070 UINT16 CF:1;\r
1071 UINT16 Reserved1:1;\r
1072 UINT16 PF:1;\r
1073 UINT16 Reserved2:1;\r
1074 UINT16 AF:1;\r
1075 UINT16 Reserved3:1;\r
1076 UINT16 ZF:1;\r
1077 UINT16 SF:1;\r
1078 UINT16 TF:1;\r
1079 UINT16 IF:1;\r
1080 UINT16 DF:1;\r
1081 UINT16 OF:1;\r
1082 UINT16 IOPL:2;\r
1083 UINT16 NT:1;\r
1084 UINT16 Reserved4:1;\r
1085} EFI_FLAGS_REG;\r
1086\r
050b79eb 1087///\r
1088/// EFI_WORD_REGS\r
1089///\r
79964ac8 1090typedef struct {\r
1091 UINT16 AX;\r
1092 UINT16 ReservedAX;\r
1093 UINT16 BX;\r
1094 UINT16 ReservedBX;\r
1095 UINT16 CX;\r
1096 UINT16 ReservedCX;\r
1097 UINT16 DX;\r
1098 UINT16 ReservedDX;\r
1099 UINT16 SI;\r
1100 UINT16 ReservedSI;\r
1101 UINT16 DI;\r
1102 UINT16 ReservedDI;\r
1103 EFI_FLAGS_REG Flags;\r
1104 UINT16 ReservedFlags;\r
1105 UINT16 ES;\r
1106 UINT16 CS;\r
1107 UINT16 SS;\r
1108 UINT16 DS;\r
1109 UINT16 FS;\r
1110 UINT16 GS;\r
1111 UINT16 BP;\r
1112 UINT16 ReservedBP;\r
1113 UINT16 SP;\r
1114 UINT16 ReservedSP;\r
1115} EFI_WORD_REGS;\r
1116\r
050b79eb 1117///\r
1118/// EFI_BYTE_REGS\r
1119///\r
79964ac8 1120typedef struct {\r
1121 UINT8 AL, AH;\r
1122 UINT16 ReservedAX;\r
1123 UINT8 BL, BH;\r
1124 UINT16 ReservedBX;\r
1125 UINT8 CL, CH;\r
1126 UINT16 ReservedCX;\r
1127 UINT8 DL, DH;\r
1128 UINT16 ReservedDX;\r
1129} EFI_BYTE_REGS;\r
1130\r
050b79eb 1131///\r
1132/// EFI_IA32_REGISTER_SET\r
1133///\r
79964ac8 1134typedef union {\r
1135 EFI_DWORD_REGS E;\r
1136 EFI_WORD_REGS X;\r
1137 EFI_BYTE_REGS H;\r
1138} EFI_IA32_REGISTER_SET;\r
1139\r
1140/**\r
1141 Thunk to 16-bit real mode and execute a software interrupt with a vector\r
1142 of BiosInt. Regs will contain the 16-bit register context on entry and\r
1143 exit.\r
1144\r
f22f941e 1145 @param[in] This The protocol instance pointer.\r
1146 @param[in] BiosInt The processor interrupt vector to invoke.\r
050b79eb 1147 @param[in,out] Reg Register contexted passed into (and returned) from thunk to\r
f22f941e 1148 16-bit mode.\r
79964ac8 1149\r
5259c97d 1150 @retval TRUE Thunk completed with no BIOS errors in the target code. See Regs for status. \r
1151 @retval FALSE There was a BIOS error in the target code.\r
79964ac8 1152**/\r
1153typedef\r
1154BOOLEAN\r
69686d56 1155(EFIAPI *EFI_LEGACY_BIOS_INT86)(\r
050b79eb 1156 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1157 IN UINT8 BiosInt,\r
1158 IN OUT EFI_IA32_REGISTER_SET *Regs\r
79964ac8 1159 );\r
1160\r
1161/**\r
1162 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the\r
1163 16-bit register context on entry and exit. Arguments can be passed on\r
1164 the Stack argument\r
1165\r
f22f941e 1166 @param[in] This The protocol instance pointer.\r
1167 @param[in] Segment The segemnt of 16-bit mode call.\r
1168 @param[in] Offset The offset of 16-bit mdoe call.\r
050b79eb 1169 @param[in] Reg Register contexted passed into (and returned) from thunk to\r
f22f941e 1170 16-bit mode.\r
1171 @param[in] Stack The caller allocated stack used to pass arguments.\r
1172 @param[in] StackSize The size of Stack in bytes.\r
79964ac8 1173\r
5259c97d 1174 @retval FALSE Thunk completed with no BIOS errors in the target code. See Regs for status. @retval TRUE There was a BIOS error in the target code.\r
79964ac8 1175**/\r
1176typedef\r
1177BOOLEAN\r
69686d56 1178(EFIAPI *EFI_LEGACY_BIOS_FARCALL86)(\r
050b79eb 1179 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1180 IN UINT16 Segment,\r
1181 IN UINT16 Offset,\r
1182 IN EFI_IA32_REGISTER_SET *Regs,\r
1183 IN VOID *Stack,\r
1184 IN UINTN StackSize\r
79964ac8 1185 );\r
1186\r
1187/**\r
1188 Test to see if a legacy PCI ROM exists for this device. Optionally return\r
1189 the Legacy ROM instance for this PCI device.\r
1190\r
f22f941e 1191 @param[in] This The protocol instance pointer.\r
050b79eb 1192 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded\r
f22f941e 1193 @param[out] RomImage Return the legacy PCI ROM for this device.\r
1194 @param[out] RomSize The size of ROM Image.\r
050b79eb 1195 @param[out] Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:\r
f22f941e 1196 - 00 = No ROM.\r
1197 - 01 = ROM Found.\r
1198 - 02 = ROM is a valid legacy ROM.\r
79964ac8 1199\r
d6a1c70d 1200 @retval EFI_SUCCESS The Legacy Option ROM available for this device\r
f22f941e 1201 @retval EFI_UNSUPPORTED The Legacy Option ROM is not supported.\r
79964ac8 1202\r
1203**/\r
1204typedef\r
1205EFI_STATUS\r
69686d56 1206(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM)(\r
050b79eb 1207 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1208 IN EFI_HANDLE PciHandle,\r
1209 OUT VOID **RomImage, OPTIONAL\r
1210 OUT UINTN *RomSize, OPTIONAL\r
1211 OUT UINTN *Flags\r
79964ac8 1212 );\r
1213\r
1214/**\r
1215 Load a legacy PC-AT OPROM on the PciHandle device. Return information\r
1216 about how many disks were added by the OPROM and the shadow address and\r
1217 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:\r
1218\r
f22f941e 1219 @param[in] This The protocol instance pointer.\r
050b79eb 1220 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.\r
1221 This value is NULL if RomImage is non-NULL. This is the normal\r
1222 case.\r
1223 @param[in] RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is\r
1224 no hardware associated with the ROM and thus no PciHandle,\r
1225 otherwise is must be NULL.\r
1226 Example is PXE base code.\r
1227 @param[out] Flags The type of ROM discovered. Multiple bits can be set, as follows:\r
1228 - 00 = No ROM.\r
1229 - 01 = ROM found.\r
1230 - 02 = ROM is a valid legacy ROM.\r
f22f941e 1231 @param[out] DiskStart The disk number of first device hooked by the ROM. If DiskStart\r
050b79eb 1232 is the same as DiskEnd no disked were hooked.\r
1233 @param[out] DiskEnd disk number of the last device hooked by the ROM.\r
f22f941e 1234 @param[out] RomShadowAddress Shadow address of PC-AT ROM.\r
1235 @param[out] RomShadowSize Size of RomShadowAddress in bytes.\r
050b79eb 1236\r
1237 @retval EFI_SUCCESS Thunk completed, see Regs for status.\r
1238 @retval EFI_INVALID_PARAMETER PciHandle not found\r
79964ac8 1239\r
1240**/\r
1241typedef\r
1242EFI_STATUS\r
69686d56 1243(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM)(\r
050b79eb 1244 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1245 IN EFI_HANDLE PciHandle,\r
1246 IN VOID **RomImage,\r
1247 OUT UINTN *Flags,\r
1248 OUT UINT8 *DiskStart, OPTIONAL\r
1249 OUT UINT8 *DiskEnd, OPTIONAL\r
1250 OUT VOID **RomShadowAddress, OPTIONAL\r
1251 OUT UINT32 *ShadowedRomSize OPTIONAL\r
79964ac8 1252 );\r
1253\r
1254/**\r
ef1ac015 1255 This function attempts to traditionally boot the specified BootOption. If the EFI context has\r
5259c97d 1256 been compromised, this function will not return. This procedure is not used for loading an EFI-aware\r
ef1ac015 1257 OS off a traditional device. The following actions occur:\r
1258 - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to\r
1259 Compatibility16.\r
1260 - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.\r
1261 - Find the traditional SMI handler from a firmware volume and register the traditional SMI\r
1262 handler with the EFI SMI handler.\r
1263 - Build onboard IDE information and pass this information to the Compatibility16 code.\r
1264 - Make sure all PCI Interrupt Line registers are programmed to match 8259.\r
1265 - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).\r
1266 - Shadow all PCI ROMs.\r
1267 - Set up BDA and EBDA standard areas before the legacy boot.\r
1268 - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.\r
1269 - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This\r
1270 invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal\r
1271 data structures. The boot device list is a parameter.\r
1272 - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation\r
1273 causes a thunk into the Compatibility16 code, which does an INT19.\r
1274 - If the Compatibility16Boot() function returns, then the boot failed in a graceful\r
5259c97d 1275 manner--meaning that the EFI code is still valid. An ungraceful boot failure causes a reset because the state\r
ef1ac015 1276 of EFI code is unknown.\r
79964ac8 1277\r
f22f941e 1278 @param[in] This The protocol instance pointer.\r
1279 @param[in] BootOption The EFI Device Path from BootXXXX variable.\r
1280 @param[in] LoadOptionSize The size of LoadOption in size.\r
1281 @param[in] LoadOption LThe oadOption from BootXXXX variable.\r
79964ac8 1282\r
5259c97d 1283 @retval EFI_DEVICE_ERROR Failed to boot from any boot device and memory is uncorrupted. Note: This function normally does not returns. It will either boot the OS or reset the system if memory has been "corrupted" by loading a boot sector and passing control to it.\r
79964ac8 1284**/\r
1285typedef\r
1286EFI_STATUS\r
69686d56 1287(EFIAPI *EFI_LEGACY_BIOS_BOOT)(\r
050b79eb 1288 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1289 IN BBS_BBS_DEVICE_PATH *BootOption,\r
1290 IN UINT32 LoadOptionsSize,\r
1291 IN VOID *LoadOptions\r
79964ac8 1292 );\r
1293\r
1294/**\r
ef1ac015 1295 This function takes the Leds input parameter and sets/resets the BDA accordingly. \r
1296 Leds is also passed to Compatibility16 code, in case any special processing is required. \r
5259c97d 1297 This function is normally called from EFI Setup drivers that handle user-selectable\r
ef1ac015 1298 keyboard options such as boot with NUM LOCK on/off. This function does not\r
1299 touch the keyboard or keyboard LEDs but only the BDA.\r
79964ac8 1300\r
f22f941e 1301 @param[in] This The protocol instance pointer.\r
1302 @param[in] Leds The status of current Scroll, Num & Cap lock LEDS:\r
1303 - Bit 0 is Scroll Lock 0 = Not locked.\r
1304 - Bit 1 is Num Lock.\r
1305 - Bit 2 is Caps Lock.\r
79964ac8 1306\r
050b79eb 1307 @retval EFI_SUCCESS The BDA was updated successfully.\r
79964ac8 1308\r
1309**/\r
1310typedef\r
1311EFI_STATUS\r
69686d56 1312(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS)(\r
050b79eb 1313 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1314 IN UINT8 Leds\r
79964ac8 1315 );\r
1316\r
1317/**\r
1318 Retrieve legacy BBS info and assign boot priority.\r
1319\r
f22f941e 1320 @param[in] This The protocol instance pointer.\r
1321 @param[out] HddCount The number of HDD_INFO structures.\r
1322 @param[out] HddInfo Onboard IDE controller information.\r
1323 @param[out] BbsCount The number of BBS_TABLE structures.\r
1324 @param[in,out] BbsTable Points to List of BBS_TABLE.\r
79964ac8 1325\r
f22f941e 1326 @retval EFI_SUCCESS Tables were returned.\r
79964ac8 1327\r
1328**/\r
1329typedef\r
1330EFI_STATUS\r
69686d56 1331(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO)(\r
050b79eb 1332 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1333 OUT UINT16 *HddCount,\r
1334 OUT HDD_INFO **HddInfo,\r
1335 OUT UINT16 *BbsCount,\r
1336 IN OUT BBS_TABLE **BbsTable\r
79964ac8 1337 );\r
1338\r
1339/**\r
1340 Assign drive number to legacy HDD drives prior to booting an EFI\r
1341 aware OS so the OS can access drives without an EFI driver.\r
1342\r
f22f941e 1343 @param[in] This The protocol instance pointer.\r
1344 @param[out] BbsCount The number of BBS_TABLE structures\r
1345 @param[out] BbsTable List of BBS entries\r
79964ac8 1346\r
f22f941e 1347 @retval EFI_SUCCESS Drive numbers assigned.\r
79964ac8 1348\r
1349**/\r
1350typedef\r
1351EFI_STATUS\r
69686d56 1352(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI)(\r
050b79eb 1353 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1354 OUT UINT16 *BbsCount,\r
1355 OUT BBS_TABLE **BbsTable\r
79964ac8 1356 );\r
1357\r
1358/**\r
1359 To boot from an unconventional device like parties and/or execute\r
1360 HDD diagnostics.\r
1361\r
f22f941e 1362 @param[in] This The protocol instance pointer.\r
1363 @param[in] Attributes How to interpret the other input parameters.\r
050b79eb 1364 @param[in] BbsEntry The 0-based index into the BbsTable for the parent\r
79964ac8 1365 device.\r
f22f941e 1366 @param[in] BeerData A pointer to the 128 bytes of ram BEER data.\r
1367 @param[in] ServiceAreaData A pointer to the 64 bytes of raw Service Area data. The\r
79964ac8 1368 caller must provide a pointer to the specific Service\r
1369 Area and not the start all Service Areas.\r
1370\r
050b79eb 1371 @retval EFI_INVALID_PARAMETER If error. Does NOT return if no error.\r
79964ac8 1372\r
1373**/\r
1374typedef\r
1375EFI_STATUS\r
69686d56 1376(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE)(\r
050b79eb 1377 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1378 IN UDC_ATTRIBUTES Attributes,\r
1379 IN UINTN BbsEntry,\r
1380 IN VOID *BeerData,\r
1381 IN VOID *ServiceAreaData\r
79964ac8 1382 );\r
1383\r
1384/**\r
1385 Shadow all legacy16 OPROMs that haven't been shadowed.\r
1386 Warning: Use this with caution. This routine disconnects all EFI\r
f22f941e 1387 drivers. If used externally, then the caller must re-connect EFI\r
79964ac8 1388 drivers.\r
050b79eb 1389 \r
f22f941e 1390 @param[in] This The protocol instance pointer.\r
050b79eb 1391 \r
f22f941e 1392 @retval EFI_SUCCESS OPROMs were shadowed.\r
79964ac8 1393\r
1394**/\r
1395typedef\r
1396EFI_STATUS\r
69686d56 1397(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS)(\r
050b79eb 1398 IN EFI_LEGACY_BIOS_PROTOCOL *This\r
79964ac8 1399 );\r
1400\r
1401/**\r
1402 Get a region from the LegacyBios for S3 usage.\r
1403\r
f22f941e 1404 @param[in] This The protocol instance pointer.\r
1405 @param[in] LegacyMemorySize The size of required region.\r
1406 @param[in] Region The region to use.\r
1407 00 = Either 0xE0000 or 0xF0000 block.\r
1408 - Bit0 = 1 0xF0000 block.\r
1409 - Bit1 = 1 0xE0000 block.\r
1410 @param[in] Alignment Address alignment. Bit mapped. The first non-zero\r
050b79eb 1411 bit from right is alignment.\r
f22f941e 1412 @param[out] LegacyMemoryAddress The Region Assigned\r
79964ac8 1413\r
f22f941e 1414 @retval EFI_SUCCESS The Region was assigned.\r
ef1ac015 1415 @retval EFI_ACCESS_DENIED The function was previously invoked.\r
f22f941e 1416 @retval Other The Region was not assigned.\r
79964ac8 1417\r
1418**/\r
1419typedef\r
1420EFI_STATUS\r
69686d56 1421(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION)(\r
050b79eb 1422 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1423 IN UINTN LegacyMemorySize,\r
1424 IN UINTN Region,\r
1425 IN UINTN Alignment,\r
1426 OUT VOID **LegacyMemoryAddress\r
79964ac8 1427 );\r
1428\r
1429/**\r
1430 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.\r
1431\r
f22f941e 1432 @param[in] This The protocol instance pointer.\r
1433 @param[in] LegacyMemorySize The size of data to copy.\r
1434 @param[in] LegacyMemoryAddress The Legacy Region destination address.\r
050b79eb 1435 Note: must be in region assigned by\r
f22f941e 1436 LegacyBiosGetLegacyRegion.\r
1437 @param[in] LegacyMemorySourceAddress The source of the data to copy.\r
79964ac8 1438\r
f22f941e 1439 @retval EFI_SUCCESS The Region assigned.\r
1440 @retval EFI_ACCESS_DENIED Destination was outside an assigned region.\r
79964ac8 1441\r
1442**/\r
1443typedef\r
1444EFI_STATUS\r
69686d56 1445(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION)(\r
050b79eb 1446 IN EFI_LEGACY_BIOS_PROTOCOL *This,\r
1447 IN UINTN LegacyMemorySize,\r
1448 IN VOID *LegacyMemoryAddress,\r
1449 IN VOID *LegacyMemorySourceAddress\r
79964ac8 1450 );\r
1451\r
050b79eb 1452///\r
1453/// Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()\r
1454/// member function allows the BDS to support booting a traditional OS.\r
1455/// EFI thunks drivers that make EFI bindings for BIOS INT services use\r
1456/// all the other member functions.\r
1457///\r
79964ac8 1458struct _EFI_LEGACY_BIOS_PROTOCOL {\r
2bbaeb0d 1459 ///\r
1460 /// Performs traditional software INT. See the Int86() function description.\r
1461 ///\r
79964ac8 1462 EFI_LEGACY_BIOS_INT86 Int86;\r
2bbaeb0d 1463 \r
1464 ///\r
1465 /// Performs a far call into Compatibility16 or traditional OpROM code.\r
1466 ///\r
79964ac8 1467 EFI_LEGACY_BIOS_FARCALL86 FarCall86;\r
2bbaeb0d 1468 \r
1469 ///\r
1470 /// Checks if a traditional OpROM exists for this device.\r
1471 ///\r
79964ac8 1472 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;\r
2bbaeb0d 1473 \r
1474 ///\r
1475 /// Loads a traditional OpROM in traditional OpROM address space.\r
1476 ///\r
79964ac8 1477 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;\r
2bbaeb0d 1478 \r
1479 ///\r
1480 /// Boots a traditional OS.\r
1481 ///\r
79964ac8 1482 EFI_LEGACY_BIOS_BOOT LegacyBoot;\r
2bbaeb0d 1483 \r
1484 ///\r
1485 /// Updates BDA to reflect the current EFI keyboard LED status.\r
1486 ///\r
79964ac8 1487 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;\r
2bbaeb0d 1488 \r
1489 ///\r
1490 /// Allows an external agent, such as BIOS Setup, to get the BBS data.\r
1491 ///\r
79964ac8 1492 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;\r
2bbaeb0d 1493 \r
1494 ///\r
1495 /// Causes all legacy OpROMs to be shadowed.\r
1496 ///\r
79964ac8 1497 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;\r
2bbaeb0d 1498 \r
1499 ///\r
1500 /// Performs all actions prior to boot. Used when booting an EFI-aware OS\r
1501 /// rather than a legacy OS. \r
1502 ///\r
79964ac8 1503 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;\r
2bbaeb0d 1504 \r
1505 ///\r
1506 /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.\r
1507 ///\r
79964ac8 1508 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;\r
2bbaeb0d 1509 \r
1510 ///\r
1511 /// Allows EFI to copy data to the area specified by GetLegacyRegion.\r
1512 ///\r
79964ac8 1513 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;\r
2bbaeb0d 1514 \r
1515 ///\r
1516 /// Allows the user to boot off an unconventional device such as a PARTIES partition.\r
1517 ///\r
79964ac8 1518 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;\r
1519};\r
1520\r
1521extern EFI_GUID gEfiLegacyBiosProtocolGuid;\r
1522\r
1523#endif\r