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 COMPATIBILITY16 structures and definitions.
6 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
7 well known naming conventions.
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.
12 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
13 SPDX-License-Identifier: BSD-2-Clause-Patent
15 @par Revision Reference:
16 This protocol is defined in Framework for EFI Compatibility Support Module spec
21 #ifndef _EFI_LEGACY_BIOS_H_
22 #define _EFI_LEGACY_BIOS_H_
29 typedef UINT8 SERIAL_MODE
;
30 typedef UINT8 PARALLEL_MODE
;
32 #define EFI_COMPATIBILITY16_TABLE_SIGNATURE SIGNATURE_32 ('I', 'F', 'E', '$')
35 /// There is a table located within the traditional BIOS in either the 0xF000:xxxx or 0xE000:xxxx
36 /// physical address range. It is located on a 16-byte boundary and provides the physical address of the
37 /// entry point for the Compatibility16 functions. These functions provide the platform-specific
38 /// information that is required by the generic EfiCompatibility code. The functions are invoked via
39 /// thunking by using EFI_LEGACY_BIOS_PROTOCOL.FarCall86() with the 32-bit physical
44 /// The string "$EFI" denotes the start of the EfiCompatibility table. Byte 0 is "I," byte
45 /// 1 is "F," byte 2 is "E," and byte 3 is "$" and is normally accessed as a DWORD or UINT32.
50 /// The value required such that byte checksum of TableLength equals zero.
55 /// The length of this table.
60 /// The major EFI revision for which this table was generated.
62 UINT8 EfiMajorRevision
;
65 /// The minor EFI revision for which this table was generated.
67 UINT8 EfiMinorRevision
;
70 /// The major revision of this table.
72 UINT8 TableMajorRevision
;
75 /// The minor revision of this table.
77 UINT8 TableMinorRevision
;
80 /// Reserved for future usage.
85 /// The segment of the entry point within the traditional BIOS for Compatibility16 functions.
87 UINT16 Compatibility16CallSegment
;
90 /// The offset of the entry point within the traditional BIOS for Compatibility16 functions.
92 UINT16 Compatibility16CallOffset
;
95 /// The segment of the entry point within the traditional BIOS for EfiCompatibility
96 /// to invoke the PnP installation check.
98 UINT16 PnPInstallationCheckSegment
;
101 /// The Offset of the entry point within the traditional BIOS for EfiCompatibility
102 /// to invoke the PnP installation check.
104 UINT16 PnPInstallationCheckOffset
;
107 /// EFI system resources table. Type EFI_SYSTEM_TABLE is defined in the IntelPlatform
108 ///Innovation Framework for EFI Driver Execution Environment Core Interface Specification (DXE CIS).
110 UINT32 EfiSystemTable
;
113 /// The address of an OEM-provided identifier string. The string is null terminated.
115 UINT32 OemIdStringPointer
;
118 /// The 32-bit physical address where ACPI RSD PTR is stored within the traditional
119 /// BIOS. The remained of the ACPI tables are located at their EFI addresses. The size
120 /// reserved is the maximum for ACPI 2.0. The EfiCompatibility will fill in the ACPI
121 /// RSD PTR with either the ACPI 1.0b or 2.0 values.
123 UINT32 AcpiRsdPtrPointer
;
126 /// The OEM revision number. Usage is undefined but provided for OEM module usage.
131 /// The 32-bit physical address where INT15 E820 data is stored within the traditional
132 /// BIOS. The EfiCompatibility code will fill in the E820Pointer value and copy the
133 /// data to the indicated area.
138 /// The length of the E820 data and is filled in by the EfiCompatibility code.
143 /// The 32-bit physical address where the $PIR table is stored in the traditional BIOS.
144 /// The EfiCompatibility code will fill in the IrqRoutingTablePointer value and
145 /// copy the data to the indicated area.
147 UINT32 IrqRoutingTablePointer
;
150 /// The length of the $PIR table and is filled in by the EfiCompatibility code.
152 UINT32 IrqRoutingTableLength
;
155 /// The 32-bit physical address where the MP table is stored in the traditional BIOS.
156 /// The EfiCompatibility code will fill in the MpTablePtr value and copy the data
157 /// to the indicated area.
162 /// The length of the MP table and is filled in by the EfiCompatibility code.
164 UINT32 MpTableLength
;
167 /// The segment of the OEM-specific INT table/code.
169 UINT16 OemIntSegment
;
172 /// The offset of the OEM-specific INT table/code.
177 /// The segment of the OEM-specific 32-bit table/code.
182 /// The offset of the OEM-specific 32-bit table/code.
187 /// The segment of the OEM-specific 16-bit table/code.
192 /// The offset of the OEM-specific 16-bit table/code.
197 /// The segment of the TPM binary passed to 16-bit CSM.
202 /// The offset of the TPM binary passed to 16-bit CSM.
207 /// A pointer to a string identifying the independent BIOS vendor.
212 /// This field is NULL for all systems not supporting PCI Express. This field is the base
213 /// value of the start of the PCI Express memory-mapped configuration registers and
214 /// must be filled in prior to EfiCompatibility code issuing the Compatibility16 function
215 /// Compatibility16InitializeYourself().
216 /// Compatibility16InitializeYourself() is defined in Compatibility16
219 UINT32 PciExpressBase
;
222 /// Maximum PCI bus number assigned.
227 /// Start Address of Upper Memory Area (UMA) to be set as Read/Write. If
228 /// UmaAddress is a valid address in the shadow RAM, it also indicates that the region
229 /// from 0xC0000 to (UmaAddress - 1) can be used for Option ROM.
234 /// Upper Memory Area size in bytes to be set as Read/Write. If zero, no UMA region
235 /// will be set as Read/Write (i.e. all Shadow RAM is set as Read-Only).
240 /// Start Address of high memory that can be used for permanent allocation. If zero,
241 /// high memory is not available for permanent allocation.
243 UINT32 HiPermanentMemoryAddress
;
246 /// Size of high memory that can be used for permanent allocation in bytes. If zero,
247 /// high memory is not available for permanent allocation.
249 UINT32 HiPermanentMemorySize
;
250 } EFI_COMPATIBILITY16_TABLE
;
253 /// Functions provided by the CSM binary which communicate between the EfiCompatibility
254 /// and Compatibility16 code.
256 /// Inconsistent with the specification here:
257 /// The member's name started with "Compatibility16" [defined in Intel Framework
258 /// Compatibility Support Module Specification / 0.97 version]
259 /// has been changed to "Legacy16" since keeping backward compatible.
263 /// Causes the Compatibility16 code to do any internal initialization required.
265 /// AX = Compatibility16InitializeYourself
266 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_INIT_TABLE
268 /// AX = Return Status codes
270 Legacy16InitializeYourself
= 0x0000,
273 /// Causes the Compatibility16 BIOS to perform any drive number translations to match the boot sequence.
275 /// AX = Compatibility16UpdateBbs
276 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE
278 /// AX = Returned status codes
280 Legacy16UpdateBbs
= 0x0001,
283 /// Allows the Compatibility16 code to perform any final actions before booting. The Compatibility16
284 /// code is read/write.
286 /// AX = Compatibility16PrepareToBoot
287 /// ES:BX = Pointer to EFI_TO_COMPATIBILITY16_BOOT_TABLE structure
289 /// AX = Returned status codes
291 Legacy16PrepareToBoot
= 0x0002,
294 /// Causes the Compatibility16 BIOS to boot. The Compatibility16 code is Read/Only.
296 /// AX = Compatibility16Boot
298 /// AX = Returned status codes
300 Legacy16Boot
= 0x0003,
303 /// Allows the Compatibility16 code to get the last device from which a boot was attempted. This is
304 /// stored in CMOS and is the priority number of the last attempted boot device.
306 /// AX = Compatibility16RetrieveLastBootDevice
308 /// AX = Returned status codes
309 /// BX = Priority number of the boot device.
311 Legacy16RetrieveLastBootDevice
= 0x0004,
314 /// Allows the Compatibility16 code rehook INT13, INT18, and/or INT19 after dispatching a legacy OpROM.
316 /// AX = Compatibility16DispatchOprom
317 /// ES:BX = Pointer to EFI_DISPATCH_OPROM_TABLE
319 /// AX = Returned status codes
320 /// BX = Number of non-BBS-compliant devices found. Equals 0 if BBS compliant.
322 Legacy16DispatchOprom
= 0x0005,
325 /// Finds a free area in the 0xFxxxx or 0xExxxx region of the specified length and returns the address
328 /// AX = Compatibility16GetTableAddress
329 /// BX = Allocation region
330 /// 00 = Allocate from either 0xE0000 or 0xF0000 64 KB blocks.
331 /// Bit 0 = 1 Allocate from 0xF0000 64 KB block
332 /// Bit 1 = 1 Allocate from 0xE0000 64 KB block
333 /// CX = Requested length in bytes.
334 /// DX = Required address alignment. Bit mapped. First non-zero bit from the right is the alignment.
336 /// AX = Returned status codes
337 /// DS:BX = Address of the region
339 Legacy16GetTableAddress
= 0x0006,
342 /// Enables the EfiCompatibility module to do any nonstandard processing of keyboard LEDs or state.
344 /// AX = Compatibility16SetKeyboardLeds
346 /// Bit 0 Scroll Lock 0 = Off
350 /// AX = Returned status codes
352 Legacy16SetKeyboardLeds
= 0x0007,
355 /// Enables the EfiCompatibility module to install an interrupt handler for PCI mass media devices that
356 /// do not have an OpROM associated with them. An example is SATA.
358 /// AX = Compatibility16InstallPciHandler
359 /// ES:BX = Pointer to EFI_LEGACY_INSTALL_PCI_HANDLER structure
361 /// AX = Returned status codes
363 Legacy16InstallPciHandler
= 0x0008
364 } EFI_COMPATIBILITY_FUNCTIONS
;
368 /// EFI_DISPATCH_OPROM_TABLE
371 UINT16 PnPInstallationCheckSegment
; ///< A pointer to the PnpInstallationCheck data structure.
372 UINT16 PnPInstallationCheckOffset
; ///< A pointer to the PnpInstallationCheck data structure.
373 UINT16 OpromSegment
; ///< The segment where the OpROM was placed. Offset is assumed to be 3.
374 UINT8 PciBus
; ///< The PCI bus.
375 UINT8 PciDeviceFunction
; ///< The PCI device * 0x08 | PCI function.
376 UINT8 NumberBbsEntries
; ///< The number of valid BBS table entries upon entry and exit. The IBV code may
377 ///< increase this number, if BBS-compliant devices also hook INTs in order to force the
378 ///< OpROM BIOS Setup to be executed.
379 UINT32 BbsTablePointer
; ///< A pointer to the BBS table.
380 UINT16 RuntimeSegment
; ///< The segment where the OpROM can be relocated to. If this value is 0x0000, this
381 ///< means that the relocation of this run time code is not supported.
382 ///< Inconsistent with specification here:
383 ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version]
384 ///< has been changed to "RuntimeSegment" since keeping backward compatible.
386 } EFI_DISPATCH_OPROM_TABLE
;
389 /// EFI_TO_COMPATIBILITY16_INIT_TABLE
393 /// Starting address of memory under 1 MB. The ending address is assumed to be 640 KB or 0x9FFFF.
395 UINT32 BiosLessThan1MB
;
398 /// The starting address of the high memory block.
403 /// The length of high memory block.
405 UINT32 HiPmmMemorySizeInBytes
;
408 /// The segment of the reverse thunk call code.
410 UINT16 ReverseThunkCallSegment
;
413 /// The offset of the reverse thunk call code.
415 UINT16 ReverseThunkCallOffset
;
418 /// The number of E820 entries copied to the Compatibility16 BIOS.
420 UINT32 NumberE820Entries
;
423 /// The amount of usable memory above 1 MB, e.g., E820 type 1 memory.
425 UINT32 OsMemoryAbove1Mb
;
428 /// The start of thunk code in main memory. Memory cannot be used by BIOS or PMM.
433 /// The size of the thunk code.
435 UINT32 ThunkSizeInBytes
;
438 /// Starting address of memory under 1 MB.
443 /// The length of low Memory block.
445 UINT32 LowPmmMemorySizeInBytes
;
446 } EFI_TO_COMPATIBILITY16_INIT_TABLE
;
449 /// DEVICE_PRODUCER_SERIAL.
452 UINT16 Address
; ///< I/O address assigned to the serial port.
453 UINT8 Irq
; ///< IRQ assigned to the serial port.
454 SERIAL_MODE Mode
; ///< Mode of serial port. Values are defined below.
455 } DEVICE_PRODUCER_SERIAL
;
458 /// DEVICE_PRODUCER_SERIAL's modes.
460 #define DEVICE_SERIAL_MODE_NORMAL 0x00
461 #define DEVICE_SERIAL_MODE_IRDA 0x01
462 #define DEVICE_SERIAL_MODE_ASK_IR 0x02
463 #define DEVICE_SERIAL_MODE_DUPLEX_HALF 0x00
464 #define DEVICE_SERIAL_MODE_DUPLEX_FULL 0x10
468 /// DEVICE_PRODUCER_PARALLEL.
471 UINT16 Address
; ///< I/O address assigned to the parallel port.
472 UINT8 Irq
; ///< IRQ assigned to the parallel port.
473 UINT8 Dma
; ///< DMA assigned to the parallel port.
474 PARALLEL_MODE Mode
; ///< Mode of the parallel port. Values are defined below.
475 } DEVICE_PRODUCER_PARALLEL
;
478 /// DEVICE_PRODUCER_PARALLEL's modes.
480 #define DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY 0x00
481 #define DEVICE_PARALLEL_MODE_MODE_BIDIRECTIONAL 0x01
482 #define DEVICE_PARALLEL_MODE_MODE_EPP 0x02
483 #define DEVICE_PARALLEL_MODE_MODE_ECP 0x03
487 /// DEVICE_PRODUCER_FLOPPY
490 UINT16 Address
; ///< I/O address assigned to the floppy.
491 UINT8 Irq
; ///< IRQ assigned to the floppy.
492 UINT8 Dma
; ///< DMA assigned to the floppy.
493 UINT8 NumberOfFloppy
; ///< Number of floppies in the system.
494 } DEVICE_PRODUCER_FLOPPY
;
497 /// LEGACY_DEVICE_FLAGS
500 UINT32 A20Kybd
: 1; ///< A20 controller by keyboard controller.
501 UINT32 A20Port90
: 1; ///< A20 controlled by port 0x92.
502 UINT32 Reserved
: 30; ///< Reserved for future usage.
503 } LEGACY_DEVICE_FLAGS
;
506 /// DEVICE_PRODUCER_DATA_HEADER
509 DEVICE_PRODUCER_SERIAL Serial
[4]; ///< Data for serial port x. Type DEVICE_PRODUCER_SERIAL is defined below.
510 DEVICE_PRODUCER_PARALLEL Parallel
[3]; ///< Data for parallel port x. Type DEVICE_PRODUCER_PARALLEL is defined below.
511 DEVICE_PRODUCER_FLOPPY Floppy
; ///< Data for floppy. Type DEVICE_PRODUCER_FLOPPY is defined below.
512 UINT8 MousePresent
; ///< Flag to indicate if mouse is present.
513 LEGACY_DEVICE_FLAGS Flags
; ///< Miscellaneous Boolean state information passed to CSM.
514 } DEVICE_PRODUCER_DATA_HEADER
;
520 UINT16 Raw
[256]; ///< Raw data from the IDE IdentifyDrive command.
528 /// Status of IDE device. Values are defined below. There is one HDD_INFO structure
529 /// per IDE controller. The IdentifyDrive is per drive. Index 0 is master and index
535 /// PCI bus of IDE controller.
540 /// PCI device of IDE controller.
545 /// PCI function of IDE controller.
550 /// Command ports base address.
552 UINT16 CommandBaseAddress
;
555 /// Control ports base address.
557 UINT16 ControlBaseAddress
;
560 /// Bus master address.
562 UINT16 BusMasterAddress
;
567 /// Data that identifies the drive data; one per possible attached drive.
569 ATAPI_IDENTIFY IdentifyDrive
[2];
573 /// HDD_INFO status bits
575 #define HDD_PRIMARY 0x01
576 #define HDD_SECONDARY 0x02
577 #define HDD_MASTER_ATAPI_CDROM 0x04
578 #define HDD_SLAVE_ATAPI_CDROM 0x08
579 #define HDD_MASTER_IDE 0x20
580 #define HDD_SLAVE_IDE 0x40
581 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
582 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
585 /// BBS_STATUS_FLAGS;\.
588 UINT16 OldPosition
: 4; ///< Prior priority.
589 UINT16 Reserved1
: 4; ///< Reserved for future use.
590 UINT16 Enabled
: 1; ///< If 0, ignore this entry.
591 UINT16 Failed
: 1; ///< 0 = Not known if boot failure occurred.
592 ///< 1 = Boot attempted failed.
595 /// State of media present.
596 /// 00 = No bootable media is present in the device.
597 /// 01 = Unknown if a bootable media present.
598 /// 10 = Media is present and appears bootable.
601 UINT16 MediaPresent
: 2;
602 UINT16 Reserved2
: 4; ///< Reserved for future use.
606 /// BBS_TABLE, device type values & boot priority values.
610 /// The boot priority for this boot device. Values are defined below.
615 /// The PCI bus for this boot device.
620 /// The PCI device for this boot device.
625 /// The PCI function for the boot device.
630 /// The PCI class for this boot device.
635 /// The PCI Subclass for this boot device.
640 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
642 UINT16 MfgStringOffset
;
645 /// Segment:offset address of an ASCIIZ description string describing the manufacturer.
647 UINT16 MfgStringSegment
;
650 /// BBS device type. BBS device types are defined below.
655 /// Status of this boot device. Type BBS_STATUS_FLAGS is defined below.
657 BBS_STATUS_FLAGS StatusFlags
;
660 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
663 UINT16 BootHandlerOffset
;
666 /// Segment:Offset address of boot loader for IPL devices or install INT13 handler for
669 UINT16 BootHandlerSegment
;
672 /// Segment:offset address of an ASCIIZ description string describing this device.
674 UINT16 DescStringOffset
;
677 /// Segment:offset address of an ASCIIZ description string describing this device.
679 UINT16 DescStringSegment
;
684 UINT32 InitPerReserved
;
687 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
688 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
689 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
691 UINT32 AdditionalIrq13Handler
;
694 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
695 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
696 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
698 UINT32 AdditionalIrq18Handler
;
701 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
702 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
703 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
705 UINT32 AdditionalIrq19Handler
;
708 /// The use of these fields is IBV dependent. They can be used to flag that an OpROM
709 /// has hooked the specified IRQ. The OpROM may be BBS compliant as some SCSI
710 /// BBS-compliant OpROMs also hook IRQ vectors in order to run their BIOS Setup
712 UINT32 AdditionalIrq40Handler
;
713 UINT8 AssignedDriveNumber
;
714 UINT32 AdditionalIrq41Handler
;
715 UINT32 AdditionalIrq46Handler
;
721 /// BBS device type values
723 #define BBS_FLOPPY 0x01
724 #define BBS_HARDDISK 0x02
725 #define BBS_CDROM 0x03
726 #define BBS_PCMCIA 0x04
728 #define BBS_EMBED_NETWORK 0x06
729 #define BBS_BEV_DEVICE 0x80
730 #define BBS_UNKNOWN 0xff
734 /// BBS boot priority values
736 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
737 #define BBS_LOWEST_PRIORITY 0xFFFD
738 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
739 #define BBS_IGNORE_ENTRY 0xFFFF
747 /// Access mechanism used to generate the soft SMI. Defined types are below. The other
748 /// values are reserved for future usage.
753 /// The size of "port" in bits. Defined values are below.
755 UINT16 PortGranularity
: 3;
758 /// The size of data in bits. Defined values are below.
760 UINT16 DataGranularity
: 3;
763 /// Reserved for future use.
769 /// SMM_ATTRIBUTES type values.
771 #define STANDARD_IO 0x00
772 #define STANDARD_MEMORY 0x01
776 /// SMM_ATTRIBUTES port size constants.
778 #define PORT_SIZE_8 0x00
779 #define PORT_SIZE_16 0x01
780 #define PORT_SIZE_32 0x02
781 #define PORT_SIZE_64 0x03
785 /// SMM_ATTRIBUTES data size constants.
787 #define DATA_SIZE_8 0x00
788 #define DATA_SIZE_16 0x01
789 #define DATA_SIZE_32 0x02
790 #define DATA_SIZE_64 0x03
794 /// SMM_FUNCTION & relating constants.
797 UINT16 Function
: 15;
802 /// SMM_FUNCTION Function constants.
804 #define INT15_D042 0x0000
805 #define GET_USB_BOOT_INFO 0x0001
806 #define DMI_PNP_50_57 0x0002
810 /// SMM_FUNCTION Owner constants.
812 #define STANDARD_OWNER 0x0
813 #define OEM_OWNER 0x1
817 /// This structure assumes both port and data sizes are 1. SmmAttribute must be
818 /// properly to reflect that assumption.
822 /// Describes the access mechanism, SmmPort, and SmmData sizes. Type
823 /// SMM_ATTRIBUTES is defined below.
825 SMM_ATTRIBUTES SmmAttributes
;
828 /// Function Soft SMI is to perform. Type SMM_FUNCTION is defined below.
830 SMM_FUNCTION SmmFunction
;
833 /// SmmPort size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
838 /// SmmData size depends upon SmmAttributes and ranges from2 bytes to 16 bytes.
847 UINT16 NumSmmEntries
; ///< Number of entries represented by SmmEntry.
848 SMM_ENTRY SmmEntry
; ///< One entry per function. Type SMM_ENTRY is defined below.
856 /// This bit set indicates that the ServiceAreaData is valid.
858 UINT8 DirectoryServiceValidity
: 1;
861 /// This bit set indicates to use the Reserve Area Boot Code Address (RACBA) only if
862 /// DirectoryServiceValidity is 0.
864 UINT8 RabcaUsedFlag
: 1;
867 /// This bit set indicates to execute hard disk diagnostics.
869 UINT8 ExecuteHddDiagnosticsFlag
: 1;
872 /// Reserved for future use. Set to 0.
882 /// This field contains the bit-mapped attributes of the PARTIES information. Type
883 /// UDC_ATTRIBUTES is defined below.
885 UDC_ATTRIBUTES Attributes
;
888 /// This field contains the zero-based device on which the selected
889 /// ServiceDataArea is present. It is 0 for master and 1 for the slave device.
894 /// This field contains the zero-based index into the BbsTable for the parent device.
895 /// This index allows the user to reference the parent device information such as PCI
896 /// bus, device function.
898 UINT8 BbsTableEntryNumberForParentDevice
;
901 /// This field contains the zero-based index into the BbsTable for the boot entry.
903 UINT8 BbsTableEntryNumberForBoot
;
906 /// This field contains the zero-based index into the BbsTable for the HDD diagnostics entry.
908 UINT8 BbsTableEntryNumberForHddDiag
;
911 /// The raw Beer data.
916 /// The raw data of selected service area.
918 UINT8 ServiceAreaData
[64];
921 #define EFI_TO_LEGACY_MAJOR_VERSION 0x02
922 #define EFI_TO_LEGACY_MINOR_VERSION 0x00
923 #define MAX_IDE_CONTROLLER 8
926 /// EFI_TO_COMPATIBILITY16_BOOT_TABLE
929 UINT16 MajorVersion
; ///< The EfiCompatibility major version number.
930 UINT16 MinorVersion
; ///< The EfiCompatibility minor version number.
931 UINT32 AcpiTable
; ///< The location of the RSDT ACPI table. < 4G range.
932 UINT32 SmbiosTable
; ///< The location of the SMBIOS table in EFI memory. < 4G range.
933 UINT32 SmbiosTableLength
;
937 DEVICE_PRODUCER_DATA_HEADER SioData
; ///< Standard traditional device information.
938 UINT16 DevicePathType
; ///< The default boot type.
939 UINT16 PciIrqMask
; ///< Mask of which IRQs have been assigned to PCI.
940 UINT32 NumberE820Entries
; ///< Number of E820 entries. The number can change from the
941 ///< Compatibility16InitializeYourself() function.
943 // Controller & Drive Identify[2] per controller information
945 HDD_INFO HddInfo
[MAX_IDE_CONTROLLER
]; ///< Hard disk drive information, including raw Identify Drive data.
946 UINT32 NumberBbsEntries
; ///< Number of entries in the BBS table
947 UINT32 BbsTable
; ///< A pointer to the BBS table. Type BBS_TABLE is defined below.
948 UINT32 SmmTable
; ///< A pointer to the SMM table. Type SMM_TABLE is defined below.
949 UINT32 OsMemoryAbove1Mb
; ///< The amount of usable memory above 1 MB, i.e. E820 type 1 memory. This value can
950 ///< differ from the value in EFI_TO_COMPATIBILITY16_INIT_TABLE as more
951 ///< memory may have been discovered.
952 UINT32 UnconventionalDeviceTable
; ///< Information to boot off an unconventional device like a PARTIES partition. Type
953 ///< UD_TABLE is defined below.
954 } EFI_TO_COMPATIBILITY16_BOOT_TABLE
;
957 /// EFI_LEGACY_INSTALL_PCI_HANDLER
960 UINT8 PciBus
; ///< The PCI bus of the device.
961 UINT8 PciDeviceFun
; ///< The PCI device in bits 7:3 and function in bits 2:0.
962 UINT8 PciSegment
; ///< The PCI segment of the device.
963 UINT8 PciClass
; ///< The PCI class code of the device.
964 UINT8 PciSubclass
; ///< The PCI subclass code of the device.
965 UINT8 PciInterface
; ///< The PCI interface code of the device.
969 UINT8 PrimaryIrq
; ///< The primary device IRQ.
970 UINT8 PrimaryReserved
; ///< Reserved.
971 UINT16 PrimaryControl
; ///< The primary device control I/O base.
972 UINT16 PrimaryBase
; ///< The primary device I/O base.
973 UINT16 PrimaryBusMaster
; ///< The primary device bus master I/O base.
977 UINT8 SecondaryIrq
; ///< The secondary device IRQ.
978 UINT8 SecondaryReserved
; ///< Reserved.
979 UINT16 SecondaryControl
; ///< The secondary device control I/O base.
980 UINT16 SecondaryBase
; ///< The secondary device I/O base.
981 UINT16 SecondaryBusMaster
; ///< The secondary device bus master I/O base.
982 } EFI_LEGACY_INSTALL_PCI_HANDLER
;
985 // Restore default pack value
989 #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
991 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \
994 typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL
;
997 /// Flags returned by CheckPciRom().
1000 #define ROM_FOUND 0x01
1001 #define VALID_LEGACY_ROM 0x02
1002 #define ROM_WITH_CONFIG 0x04 ///< Not defined in the Framework CSM Specification.
1005 /// The following macros do not appear in the Framework CSM Specification and
1006 /// are kept for backward compatibility only. They convert 32-bit address (_Adr)
1007 /// to Segment:Offset 16-bit form.
1010 #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
1011 #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
1014 #define CARRY_FLAG 0x01
1036 UINT32 Reserved5
:14;
1049 EFI_EFLAGS_REG EFlags
;
1097 EFI_FLAGS_REG Flags
;
1098 UINT16 ReservedFlags
;
1126 /// EFI_IA32_REGISTER_SET
1132 } EFI_IA32_REGISTER_SET
;
1135 Thunk to 16-bit real mode and execute a software interrupt with a vector
1136 of BiosInt. Regs will contain the 16-bit register context on entry and
1139 @param[in] This The protocol instance pointer.
1140 @param[in] BiosInt The processor interrupt vector to invoke.
1141 @param[in,out] Reg Register contexted passed into (and returned) from thunk to
1144 @retval TRUE Thunk completed with no BIOS errors in the target code. See Regs for status.
1145 @retval FALSE There was a BIOS error in the target code.
1149 (EFIAPI
*EFI_LEGACY_BIOS_INT86
)(
1150 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1152 IN OUT EFI_IA32_REGISTER_SET
*Regs
1156 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
1157 16-bit register context on entry and exit. Arguments can be passed on
1160 @param[in] This The protocol instance pointer.
1161 @param[in] Segment The segemnt of 16-bit mode call.
1162 @param[in] Offset The offset of 16-bit mdoe call.
1163 @param[in] Reg Register contexted passed into (and returned) from thunk to
1165 @param[in] Stack The caller allocated stack used to pass arguments.
1166 @param[in] StackSize The size of Stack in bytes.
1168 @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.
1172 (EFIAPI
*EFI_LEGACY_BIOS_FARCALL86
)(
1173 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1176 IN EFI_IA32_REGISTER_SET
*Regs
,
1182 Test to see if a legacy PCI ROM exists for this device. Optionally return
1183 the Legacy ROM instance for this PCI device.
1185 @param[in] This The protocol instance pointer.
1186 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
1187 @param[out] RomImage Return the legacy PCI ROM for this device.
1188 @param[out] RomSize The size of ROM Image.
1189 @param[out] Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:
1192 - 02 = ROM is a valid legacy ROM.
1194 @retval EFI_SUCCESS The Legacy Option ROM available for this device
1195 @retval EFI_UNSUPPORTED The Legacy Option ROM is not supported.
1200 (EFIAPI
*EFI_LEGACY_BIOS_CHECK_ROM
)(
1201 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1202 IN EFI_HANDLE PciHandle
,
1203 OUT VOID
**RomImage OPTIONAL
,
1204 OUT UINTN
*RomSize OPTIONAL
,
1209 Load a legacy PC-AT OPROM on the PciHandle device. Return information
1210 about how many disks were added by the OPROM and the shadow address and
1211 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
1213 @param[in] This The protocol instance pointer.
1214 @param[in] PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
1215 This value is NULL if RomImage is non-NULL. This is the normal
1217 @param[in] RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is
1218 no hardware associated with the ROM and thus no PciHandle,
1219 otherwise is must be NULL.
1220 Example is PXE base code.
1221 @param[out] Flags The type of ROM discovered. Multiple bits can be set, as follows:
1224 - 02 = ROM is a valid legacy ROM.
1225 @param[out] DiskStart The disk number of first device hooked by the ROM. If DiskStart
1226 is the same as DiskEnd no disked were hooked.
1227 @param[out] DiskEnd disk number of the last device hooked by the ROM.
1228 @param[out] RomShadowAddress Shadow address of PC-AT ROM.
1229 @param[out] RomShadowSize Size of RomShadowAddress in bytes.
1231 @retval EFI_SUCCESS Thunk completed, see Regs for status.
1232 @retval EFI_INVALID_PARAMETER PciHandle not found
1237 (EFIAPI
*EFI_LEGACY_BIOS_INSTALL_ROM
)(
1238 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1239 IN EFI_HANDLE PciHandle
,
1242 OUT UINT8
*DiskStart OPTIONAL
,
1243 OUT UINT8
*DiskEnd OPTIONAL
,
1244 OUT VOID
**RomShadowAddress OPTIONAL
,
1245 OUT UINT32
*ShadowedRomSize OPTIONAL
1249 This function attempts to traditionally boot the specified BootOption. If the EFI context has
1250 been compromised, this function will not return. This procedure is not used for loading an EFI-aware
1251 OS off a traditional device. The following actions occur:
1252 - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to
1254 - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.
1255 - Find the traditional SMI handler from a firmware volume and register the traditional SMI
1256 handler with the EFI SMI handler.
1257 - Build onboard IDE information and pass this information to the Compatibility16 code.
1258 - Make sure all PCI Interrupt Line registers are programmed to match 8259.
1259 - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).
1260 - Shadow all PCI ROMs.
1261 - Set up BDA and EBDA standard areas before the legacy boot.
1262 - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.
1263 - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This
1264 invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal
1265 data structures. The boot device list is a parameter.
1266 - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation
1267 causes a thunk into the Compatibility16 code, which does an INT19.
1268 - If the Compatibility16Boot() function returns, then the boot failed in a graceful
1269 manner--meaning that the EFI code is still valid. An ungraceful boot failure causes a reset because the state
1270 of EFI code is unknown.
1272 @param[in] This The protocol instance pointer.
1273 @param[in] BootOption The EFI Device Path from BootXXXX variable.
1274 @param[in] LoadOptionSize The size of LoadOption in size.
1275 @param[in] LoadOption LThe oadOption from BootXXXX variable.
1277 @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.
1281 (EFIAPI
*EFI_LEGACY_BIOS_BOOT
)(
1282 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1283 IN BBS_BBS_DEVICE_PATH
*BootOption
,
1284 IN UINT32 LoadOptionsSize
,
1285 IN VOID
*LoadOptions
1289 This function takes the Leds input parameter and sets/resets the BDA accordingly.
1290 Leds is also passed to Compatibility16 code, in case any special processing is required.
1291 This function is normally called from EFI Setup drivers that handle user-selectable
1292 keyboard options such as boot with NUM LOCK on/off. This function does not
1293 touch the keyboard or keyboard LEDs but only the BDA.
1295 @param[in] This The protocol instance pointer.
1296 @param[in] Leds The status of current Scroll, Num & Cap lock LEDS:
1297 - Bit 0 is Scroll Lock 0 = Not locked.
1298 - Bit 1 is Num Lock.
1299 - Bit 2 is Caps Lock.
1301 @retval EFI_SUCCESS The BDA was updated successfully.
1306 (EFIAPI
*EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS
)(
1307 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1312 Retrieve legacy BBS info and assign boot priority.
1314 @param[in] This The protocol instance pointer.
1315 @param[out] HddCount The number of HDD_INFO structures.
1316 @param[out] HddInfo Onboard IDE controller information.
1317 @param[out] BbsCount The number of BBS_TABLE structures.
1318 @param[in,out] BbsTable Points to List of BBS_TABLE.
1320 @retval EFI_SUCCESS Tables were returned.
1325 (EFIAPI
*EFI_LEGACY_BIOS_GET_BBS_INFO
)(
1326 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1327 OUT UINT16
*HddCount
,
1328 OUT HDD_INFO
**HddInfo
,
1329 OUT UINT16
*BbsCount
,
1330 IN OUT BBS_TABLE
**BbsTable
1334 Assign drive number to legacy HDD drives prior to booting an EFI
1335 aware OS so the OS can access drives without an EFI driver.
1337 @param[in] This The protocol instance pointer.
1338 @param[out] BbsCount The number of BBS_TABLE structures
1339 @param[out] BbsTable List of BBS entries
1341 @retval EFI_SUCCESS Drive numbers assigned.
1346 (EFIAPI
*EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI
)(
1347 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1348 OUT UINT16
*BbsCount
,
1349 OUT BBS_TABLE
**BbsTable
1353 To boot from an unconventional device like parties and/or execute
1356 @param[in] This The protocol instance pointer.
1357 @param[in] Attributes How to interpret the other input parameters.
1358 @param[in] BbsEntry The 0-based index into the BbsTable for the parent
1360 @param[in] BeerData A pointer to the 128 bytes of ram BEER data.
1361 @param[in] ServiceAreaData A pointer to the 64 bytes of raw Service Area data. The
1362 caller must provide a pointer to the specific Service
1363 Area and not the start all Service Areas.
1365 @retval EFI_INVALID_PARAMETER If error. Does NOT return if no error.
1370 (EFIAPI
*EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE
)(
1371 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1372 IN UDC_ATTRIBUTES Attributes
,
1375 IN VOID
*ServiceAreaData
1379 Shadow all legacy16 OPROMs that haven't been shadowed.
1380 Warning: Use this with caution. This routine disconnects all EFI
1381 drivers. If used externally, then the caller must re-connect EFI
1384 @param[in] This The protocol instance pointer.
1386 @retval EFI_SUCCESS OPROMs were shadowed.
1391 (EFIAPI
*EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS
)(
1392 IN EFI_LEGACY_BIOS_PROTOCOL
*This
1396 Get a region from the LegacyBios for S3 usage.
1398 @param[in] This The protocol instance pointer.
1399 @param[in] LegacyMemorySize The size of required region.
1400 @param[in] Region The region to use.
1401 00 = Either 0xE0000 or 0xF0000 block.
1402 - Bit0 = 1 0xF0000 block.
1403 - Bit1 = 1 0xE0000 block.
1404 @param[in] Alignment Address alignment. Bit mapped. The first non-zero
1405 bit from right is alignment.
1406 @param[out] LegacyMemoryAddress The Region Assigned
1408 @retval EFI_SUCCESS The Region was assigned.
1409 @retval EFI_ACCESS_DENIED The function was previously invoked.
1410 @retval Other The Region was not assigned.
1415 (EFIAPI
*EFI_LEGACY_BIOS_GET_LEGACY_REGION
)(
1416 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1417 IN UINTN LegacyMemorySize
,
1420 OUT VOID
**LegacyMemoryAddress
1424 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
1426 @param[in] This The protocol instance pointer.
1427 @param[in] LegacyMemorySize The size of data to copy.
1428 @param[in] LegacyMemoryAddress The Legacy Region destination address.
1429 Note: must be in region assigned by
1430 LegacyBiosGetLegacyRegion.
1431 @param[in] LegacyMemorySourceAddress The source of the data to copy.
1433 @retval EFI_SUCCESS The Region assigned.
1434 @retval EFI_ACCESS_DENIED Destination was outside an assigned region.
1439 (EFIAPI
*EFI_LEGACY_BIOS_COPY_LEGACY_REGION
)(
1440 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1441 IN UINTN LegacyMemorySize
,
1442 IN VOID
*LegacyMemoryAddress
,
1443 IN VOID
*LegacyMemorySourceAddress
1447 /// Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()
1448 /// member function allows the BDS to support booting a traditional OS.
1449 /// EFI thunks drivers that make EFI bindings for BIOS INT services use
1450 /// all the other member functions.
1452 struct _EFI_LEGACY_BIOS_PROTOCOL
{
1454 /// Performs traditional software INT. See the Int86() function description.
1456 EFI_LEGACY_BIOS_INT86 Int86
;
1459 /// Performs a far call into Compatibility16 or traditional OpROM code.
1461 EFI_LEGACY_BIOS_FARCALL86 FarCall86
;
1464 /// Checks if a traditional OpROM exists for this device.
1466 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom
;
1469 /// Loads a traditional OpROM in traditional OpROM address space.
1471 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom
;
1474 /// Boots a traditional OS.
1476 EFI_LEGACY_BIOS_BOOT LegacyBoot
;
1479 /// Updates BDA to reflect the current EFI keyboard LED status.
1481 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus
;
1484 /// Allows an external agent, such as BIOS Setup, to get the BBS data.
1486 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo
;
1489 /// Causes all legacy OpROMs to be shadowed.
1491 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms
;
1494 /// Performs all actions prior to boot. Used when booting an EFI-aware OS
1495 /// rather than a legacy OS.
1497 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi
;
1500 /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.
1502 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion
;
1505 /// Allows EFI to copy data to the area specified by GetLegacyRegion.
1507 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion
;
1510 /// Allows the user to boot off an unconventional device such as a PARTIES partition.
1512 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice
;
1516 // Legacy BIOS needs to access memory in page 0 (0-4095), which is disabled if
1517 // NULL pointer detection feature is enabled. Following macro can be used to
1518 // enable/disable page 0 before/after accessing it.
1520 #define ACCESS_PAGE0_CODE(statements) \
1522 EFI_STATUS Status_; \
1523 EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc_; \
1525 Desc_.Attributes = 0; \
1526 Status_ = gDS->GetMemorySpaceDescriptor (0, &Desc_); \
1527 ASSERT_EFI_ERROR (Status_); \
1528 if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
1529 Status_ = gDS->SetMemorySpaceAttributes ( \
1531 EFI_PAGES_TO_SIZE(1), \
1532 Desc_.Attributes & ~(UINT64)EFI_MEMORY_RP \
1534 ASSERT_EFI_ERROR (Status_); \
1541 if ((Desc_.Attributes & EFI_MEMORY_RP) != 0) { \
1542 Status_ = gDS->SetMemorySpaceAttributes ( \
1544 EFI_PAGES_TO_SIZE(1), \
1547 ASSERT_EFI_ERROR (Status_); \
1551 extern EFI_GUID gEfiLegacyBiosProtocolGuid
;