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