2 The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage
3 under EFI and Legacy OS boot.
5 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
6 well known naming conventions.
8 Thunk - A thunk is a transition from one processor mode to another. A Thunk
9 is a transition from native EFI mode to 16-bit mode. A reverse thunk
10 would be a transition from 16-bit mode to native EFI mode.
12 You most likely should not use this protocol! Find the EFI way to solve the
13 problem to make your code portable
15 Copyright (c) 2006, Intel Corporation
16 All rights reserved. This program and the accompanying materials
17 are licensed and made available under the terms and conditions of the BSD License
18 which accompanies this distribution. The full text of the license may be found at
19 http://opensource.org/licenses/bsd-license.php
21 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
22 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 Module Name: LegacyBios.h
26 @par Revision Reference:
27 This protocol is defined in Framework for EFI Compatibility Support Module spec
32 #ifndef _EFI_LEGACY_BIOS_H
33 #define _EFI_LEGACY_BIOS_H
35 #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
37 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \
40 typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL
;
43 // Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form
45 #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
46 #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
47 #define BYTE_GRANULARITY 0x01
48 #define WORD_GRANULARITY 0x02
49 #define DWORD_GRANULARITY 0x04
50 #define QWORD_GRANULARITY 0x08
51 #define PARAGRAPH_GRANULARITY 0x10
53 #define CARRY_FLAG 0x01
55 //*********************************************************
57 //*********************************************************
78 //*********************************************************
80 //*********************************************************
89 EFI_EFLAGS_REG EFlags
;
100 //*******************************************
102 //*******************************************
122 //*********************************************************
124 //*********************************************************
140 UINT16 ReservedFlags
;
153 //*********************************************************
155 //*********************************************************
172 } EFI_IA32_REGISTER_SET
;
176 // $EFI table created by Legacy16 code and consumed by EFI Legacy driver
179 UINT32 Signature
; // "$EFI"
182 UINT8 EfiMajorRevision
;
183 UINT8 EfiMinorRevision
;
184 UINT8 TableMajorRevision
;
185 UINT8 TableMinorRevision
;
187 UINT16 Legacy16CallSegment
;
188 UINT16 Legacy16CallOffset
;
190 UINT16 PnPInstallationCheckSegment
;
191 UINT16 PnPInstallationCheckOffset
;
193 UINT32 EfiSystemTable
;
194 UINT32 OemStringPointer
;
195 UINT32 AcpiRsdPtrPointer
;
199 UINT32 IrqRoutingTablePointer
;
200 UINT32 IrqRoutingTableLength
;
202 UINT32 MpTableLength
;
203 UINT16 OemIntSegment
;
212 UINT32 PciExpressBase
;
214 } EFI_COMPATIBILITY16_TABLE
;
216 // define maximum number of HDD system supports
218 #define MAX_HDD_ENTRIES 0x30
227 #define HDD_PRIMARY 0x01
228 #define HDD_SECONDARY 0x02
229 #define HDD_MASTER_ATAPI_CDROM 0x04
230 #define HDD_SLAVE_ATAPI_CDROM 0x08
231 #define HDD_MASTER_IDE 0x20
232 #define HDD_SLAVE_IDE 0x40
233 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
234 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
241 UINT16 CommandBaseAddress
;
242 UINT16 ControlBaseAddress
;
243 UINT16 BusMasterAddress
;
245 ATAPI_IDENTIFY IdentifyDrive
[2];
249 // Parties data structures
252 UINT8 DirectoryServiceValidity
: 1;
253 UINT8 RabcaUsedFlag
: 1;
254 UINT8 ExecuteHddDiagnosticsFlag
: 1;
259 UDC_ATTRIBUTES Attributes
;
261 UINT8 BbsTableEntryNumberForParentDevice
;
262 UINT8 BbsTableEntryNumberForBoot
;
263 UINT8 BbsTableEntryNumberForHddDiag
;
265 UINT8 ServiceAreaData
[64];
269 // define BBS Device Types
271 #define BBS_FLOPPY 0x01
272 #define BBS_HARDDISK 0x02
273 #define BBS_CDROM 0x03
274 #define BBS_PCMCIA 0x04
276 #define BBS_EMBED_NETWORK 0x06
277 #define BBS_BEV_DEVICE 0x80
278 #define BBS_UNKNOWN 0xff
281 UINT16 OldPosition
: 4;
282 UINT16 Reserved1
: 4;
285 UINT16 MediaPresent
: 2;
286 UINT16 Reserved2
: 4;
289 #define MAX_BBS_ENTRIES 0x100
291 // BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to
293 // BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before
294 // priority has been assigned but indicates valid entry.
295 // BBS_LOWEST_PRIORITY is normally used for removable media with no media
296 // inserted. This allows the 16-bit CSM to allocate a drive letter to
298 // BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign
299 // a drive letter to but never boot from.
301 // AdditionalIrq??Handler usage is IBV specific. The fields have been added
303 // 1. Saving non-BBS card info about IRQs taken by card.
304 // 2. For BBS compliant cards that hook IRQs in order to have their SETUP
307 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
308 #define BBS_LOWEST_PRIORITY 0xFFFD
309 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
310 #define BBS_IGNORE_ENTRY 0xFFFF
319 UINT16 MfgStringOffset
;
320 UINT16 MfgStringSegment
;
322 BBS_STATUS_FLAGS StatusFlags
;
323 UINT16 BootHandlerOffset
;
324 UINT16 BootHandlerSegment
;
325 UINT16 DescStringOffset
;
326 UINT16 DescStringSegment
;
327 UINT32 InitPerReserved
;
328 UINT32 AdditionalIrq13Handler
;
329 UINT32 AdditionalIrq18Handler
;
330 UINT32 AdditionalIrq19Handler
;
331 UINT32 AdditionalIrq40Handler
;
332 UINT8 AssignedDriveNumber
;
333 UINT32 AdditionalIrq41Handler
;
334 UINT32 AdditionalIrq46Handler
;
342 Thunk to 16-bit real mode and execute a software interrupt with a vector
343 of BiosInt. Regs will contain the 16-bit register context on entry and
346 @param This Protocol instance pointer.
347 @param BiosInt Processor interrupt vector to invoke
348 @param Reg Register contexted passed into (and returned) from thunk to
351 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
353 @retval TRUE There was a BIOS erro in the target code.
358 (EFIAPI
*EFI_LEGACY_BIOS_INT86
) (
359 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
361 IN OUT EFI_IA32_REGISTER_SET
*Regs
366 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
367 16-bit register context on entry and exit. Arguments can be passed on
370 @param This Protocol instance pointer.
371 @param Segment Segemnt of 16-bit mode call
372 @param Offset Offset of 16-bit mdoe call
373 @param Reg Register contexted passed into (and returned) from thunk to
375 @param Stack Caller allocated stack used to pass arguments
376 @param StackSize Size of Stack in bytes
378 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
380 @retval TRUE There was a BIOS erro in the target code.
385 (EFIAPI
*EFI_LEGACY_BIOS_FARCALL86
) (
386 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
389 IN EFI_IA32_REGISTER_SET
*Regs
,
397 (EFIAPI
*EFI_LEGACY_BIOS_CHECK_ROM
) (
398 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
399 IN EFI_HANDLE PciHandle
,
400 OUT VOID
**RomImage
, OPTIONAL
401 OUT UINTN
*RomSize
, OPTIONAL
405 Test to see if a legacy PCI ROM exists for this device. Optionally return
406 the Legacy ROM instance for this PCI device.
408 @param This Protocol instance pointer.
409 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
410 @param RomImage Return the legacy PCI ROM for this device
411 @param RomSize Size of ROM Image
412 @param Flags Indicates if ROM found and if PC-AT.
414 @retval EFI_SUCCESS Legacy Option ROM availible for this device
415 @retval EFI_UNSUPPORTED Legacy Option ROM not supported.
422 Load a legacy PC-AT OPROM on the PciHandle device. Return information
423 about how many disks were added by the OPROM and the shadow address and
424 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
426 @param This Protocol instance pointer.
427 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
428 This value is NULL if RomImage is non-NULL. This is the normal
430 @param RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is
431 no hardware associated with the ROM and thus no PciHandle,
432 otherwise is must be NULL.
433 Example is PXE base code.
434 @param Flags Return Status if ROM was found and if was Legacy OPROM.
435 @param DiskStart Disk number of first device hooked by the ROM. If DiskStart
436 is the same as DiskEnd no disked were hooked.
437 @param DiskEnd Disk number of the last device hooked by the ROM.
438 @param RomShadowAddress Shadow address of PC-AT ROM
439 @param RomShadowSize Size of RomShadowAddress in bytes
441 @retval EFI_SUCCESS Thunk completed, see Regs for status.
442 @retval EFI_INVALID_PARAMETER PciHandle not found
447 (EFIAPI
*EFI_LEGACY_BIOS_INSTALL_ROM
) (
448 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
449 IN EFI_HANDLE PciHandle
,
452 OUT UINT8
*DiskStart
, OPTIONAL
453 OUT UINT8
*DiskEnd
, OPTIONAL
454 OUT VOID
**RomShadowAddress
, OPTIONAL
455 OUT UINT32
*ShadowedRomSize OPTIONAL
460 Attempt to legacy boot the BootOption. If the EFI contexted has been
461 compromised this function will not return.
463 @param This Protocol instance pointer.
464 @param BootOption EFI Device Path from BootXXXX variable.
465 @param LoadOptionSize Size of LoadOption in size.
466 @param LoadOption LoadOption from BootXXXX variable
468 @retval EFI_SUCCESS Removable media not present
472 Update BDA with current Scroll, Num & Cap lock LEDS
474 @param This Protocol instance pointer.
475 @param Leds Status of current Scroll, Num & Cap lock LEDS
476 Bit 0 is Scroll Lock 0 = Not locked
480 @retval EFI_SUCCESS Removable media not present
485 (EFIAPI
*EFI_LEGACY_BIOS_BOOT
) (
486 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
487 IN BBS_BBS_DEVICE_PATH
*BootOption
,
488 IN UINT32 LoadOptionsSize
,
494 (EFIAPI
*EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS
) (
495 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
501 Retrieve legacy BBS info and assign boot priority.
503 @param This Protocol instance pointer.
504 @param HddCount Number of HDD_INFO structures
505 @param HddInfo Onboard IDE controller information
506 @param BbsCount Number of BBS_TABLE structures
507 @param BbsTable List BBS entries
509 @retval EFI_SUCCESS Tables returned
514 (EFIAPI
*EFI_LEGACY_BIOS_GET_BBS_INFO
) (
515 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
516 OUT UINT16
*HddCount
,
517 OUT HDD_INFO
**HddInfo
,
518 OUT UINT16
*BbsCount
,
519 OUT IN BBS_TABLE
**BbsTable
524 Assign drive number to legacy HDD drives prior to booting an EFI
525 aware OS so the OS can access drives without an EFI driver.
527 @param This Protocol instance pointer.
528 @param BbsCount Number of BBS_TABLE structures
529 @param BbsTable List BBS entries
531 @retval EFI_SUCCESS Drive numbers assigned
536 (EFIAPI
*EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI
) (
537 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
538 OUT UINT16
*BbsCount
,
539 OUT IN BBS_TABLE
**BbsTable
544 To boot from an unconventional device like parties and/or execute
547 @param This Protocol instance pointer.
548 @param Attributes How to interpret the other input parameters
549 @param BbsEntry The 0-based index into the BbsTable for the parent
551 @param BeerData Pointer to the 128 bytes of ram BEER data.
552 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data. The
553 caller must provide a pointer to the specific Service
554 Area and not the start all Service Areas.
556 EFI_INVALID_PARAMETER if error. Does NOT return if no error.
561 (EFIAPI
*EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE
) (
562 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
563 IN UDC_ATTRIBUTES Attributes
,
566 IN VOID
*ServiceAreaData
571 Shadow all legacy16 OPROMs that haven't been shadowed.
572 Warning: Use this with caution. This routine disconnects all EFI
573 drivers. If used externally then caller must re-connect EFI
576 @retval EFI_SUCCESS OPROMs shadowed
581 (EFIAPI
*EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS
) (
582 IN EFI_LEGACY_BIOS_PROTOCOL
*This
587 Get a region from the LegacyBios for S3 usage.
589 @param This Protocol instance pointer.
590 @param LegacyMemorySize Size of required region
591 @param Region Region to use.
592 00 = Either 0xE0000 or 0xF0000 block
593 Bit0 = 1 0xF0000 block
594 Bit1 = 1 0xE0000 block
595 @param Alignment Address alignment. Bit mapped. First non-zero
596 bit from right is alignment.
597 @param LegacyMemoryAddress Region Assigned
599 @retval EFI_SUCCESS Region assigned
601 @retval Other Region not assigned
606 (EFIAPI
*EFI_LEGACY_BIOS_GET_LEGACY_REGION
) (
607 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
608 IN UINTN LegacyMemorySize
,
611 OUT VOID
**LegacyMemoryAddress
616 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
618 @param This Protocol instance pointer.
619 @param LegacyMemorySize Size of data to copy
620 @param LegacyMemoryAddress Legacy Region destination address
621 Note: must be in region assigned by
622 LegacyBiosGetLegacyRegion
623 @param LegacyMemorySourceAddress Source of data
625 @retval EFI_SUCCESS Region assigned
626 @retval EFI_ACCESS_DENIED Destination outside assigned region
631 (EFIAPI
*EFI_LEGACY_BIOS_COPY_LEGACY_REGION
) (
632 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
633 IN UINTN LegacyMemorySize
,
634 IN VOID
*LegacyMemoryAddress
,
635 IN VOID
*LegacyMemorySourceAddress
640 @par Protocol Description:
641 Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()
642 member function allows the BDS to support booting a traditional OS.
643 EFI thunks drivers that make EFI bindings for BIOS INT services use
644 all the other member functions.
647 Performs traditional software INT. See the Int86() function description.
650 Performs a far call into Compatibility16 or traditional OpROM code.
653 Checks if a traditional OpROM exists for this device.
656 Loads a traditional OpROM in traditional OpROM address space.
659 Boots a traditional OS.
661 @param UpdateKeyboardLedStatus
662 Updates BDA to reflect the current EFI keyboard LED status.
665 Allows an external agent, such as BIOS Setup, to get the BBS data.
667 @param ShadowAllLegacyOproms
668 Causes all legacy OpROMs to be shadowed.
670 @param PrepareToBootEfi
671 Performs all actions prior to boot. Used when booting an EFI-aware OS
672 rather than a legacy OS.
674 @param GetLegacyRegion
675 Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.
677 @param CopyLegacyRegion
678 Allows EFI to copy data to the area specified by GetLegacyRegion.
680 @param BootUnconventionalDevice
681 Allows the user to boot off an unconventional device such as a PARTIES partition.
684 struct _EFI_LEGACY_BIOS_PROTOCOL
{
685 EFI_LEGACY_BIOS_INT86 Int86
;
686 EFI_LEGACY_BIOS_FARCALL86 FarCall86
;
687 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom
;
688 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom
;
689 EFI_LEGACY_BIOS_BOOT LegacyBoot
;
690 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus
;
691 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo
;
692 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi
;
693 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms
;
694 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion
;
695 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion
;
696 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice
;
699 extern EFI_GUID gEfiLegacyBiosProtocolGuid
;