3 Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage
19 under EFI and Legacy OS boot.
21 Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
22 well known naming conventions.
24 Thunk - A thunk is a transition from one processor mode to another. A Thunk
25 is a transition from native EFI mode to 16-bit mode. A reverse thunk
26 would be a transition from 16-bit mode to native EFI mode.
29 Note: Note: Note: Note: Note: Note: Note:
31 You most likely should not use this protocol! Find the EFI way to solve the
32 problem to make your code portable
34 Note: Note: Note: Note: Note: Note: Note:
38 The EFI Legacy BIOS Protocol is compliant with CSM spec 0.96.
42 #ifndef _EFI_LEGACY_BIOS_H
43 #define _EFI_LEGACY_BIOS_H
45 #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
47 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d} \
50 EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PROTOCOL
);
53 // Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form
55 #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
56 #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
57 #define BYTE_GRANULARITY 0x01
58 #define WORD_GRANULARITY 0x02
59 #define DWORD_GRANULARITY 0x04
60 #define QWORD_GRANULARITY 0x08
61 #define PARAGRAPH_GRANULARITY 0x10
63 #define CARRY_FLAG 0x01
100 UINT16 Reserved4
: 1;
110 EFI_EFLAGS_REG EFlags
;
135 UINT16 ReservedFlags
;
167 } EFI_IA32_REGISTER_SET
;
171 // $EFI table created by Legacy16 code and consumed by EFI Legacy driver
174 UINT32 Signature
; // "$EFI"
177 UINT8 EfiMajorRevision
;
178 UINT8 EfiMinorRevision
;
179 UINT8 TableMajorRevision
;
180 UINT8 TableMinorRevision
;
182 UINT16 Compatibility16CallSegment
;
183 UINT16 Compatibility16CallOffset
;
185 UINT16 PnPInstallationCheckSegment
;
186 UINT16 PnPInstallationCheckOffset
;
188 UINT32 EfiSystemTable
; // IPF - CSM Integration
189 UINT32 OemIdStringPointer
;
190 UINT32 AcpiRsdPtrPointer
;
194 UINT32 IrqRoutingTablePointer
;
195 UINT32 IrqRoutingTableLength
;
197 UINT32 MpTableLength
;
198 UINT16 OemIntSegment
;
207 UINT32 PciExpressBase
;
210 } EFI_COMPATIBILITY16_TABLE
;
213 Compatibility16InitializeYourself
= 0x0000,
214 Compatibility16UpdateBbs
= 0x0001,
215 Compatibility16PrepareToBoot
= 0x0002,
216 Compatibility16Boot
= 0x0003,
217 Compatibility16RetrieveLastBootDevice
= 0x0004,
218 Compatibility16DispatchOprom
= 0x0005,
219 Compatibility16GetTableAddress
= 0x0006,
220 Compatibility16SetKeyboardLeds
= 0x0007,
221 Compatibility16InstallPciHandler
= 0x0008
222 } EFI_COMPATIBILITY_FUNCTIONS
;
225 // define maximum number of HDD system supports
227 #define MAX_HDD_ENTRIES 0x30
236 #define HDD_PRIMARY 0x01
237 #define HDD_SECONDARY 0x02
238 #define HDD_MASTER_ATAPI_CDROM 0x04
239 #define HDD_SLAVE_ATAPI_CDROM 0x08
240 #define HDD_MASTER_IDE 0x20
241 #define HDD_SLAVE_IDE 0x40
242 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
243 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
250 UINT16 CommandBaseAddress
;
251 UINT16 ControlBaseAddress
;
252 UINT16 BusMasterAddress
;
254 ATAPI_IDENTIFY IdentifyDrive
[2];
258 // Parties data structures
261 UINT8 DirectoryServiceValidity
: 1;
262 UINT8 RabcaUsedFlag
: 1;
263 UINT8 ExecuteHddDiagnosticsFlag
: 1;
268 UDC_ATTRIBUTES Attributes
;
270 UINT8 BbsTableEntryNumberForParentDevice
;
271 UINT8 BbsTableEntryNumberForBoot
;
272 UINT8 BbsTableEntryNumberForHddDiag
;
274 UINT8 ServiceAreaData
[64];
278 // define BBS Device Types
280 #define BBS_FLOPPY 0x01
281 #define BBS_HARDDISK 0x02
282 #define BBS_CDROM 0x03
283 #define BBS_PCMCIA 0x04
285 #define BBS_EMBED_NETWORK 0x06
286 #define BBS_BEV_DEVICE 0x80
287 #define BBS_UNKNOWN 0xff
290 UINT16 OldPosition
: 4;
291 UINT16 Reserved1
: 4;
294 UINT16 MediaPresent
: 2;
295 UINT16 Reserved2
: 4;
298 #define MAX_BBS_ENTRIES 0x100
300 // BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to
302 // BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before
303 // priority has been assigned but indicates valid entry.
304 // BBS_LOWEST_PRIORITY is normally used for removable media with no media
305 // inserted. This allows the 16-bit CSM to allocate a drive letter to
307 // BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign
308 // a drive letter to but never boot from.
310 // AdditionalIrq??Handler usage is IBV specific. The fields have been added
312 // 1. Saving non-BBS card info about IRQs taken by card.
313 // 2. For BBS compliant cards that hook IRQs in order to have their SETUP
316 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
317 #define BBS_LOWEST_PRIORITY 0xFFFD
318 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
319 #define BBS_IGNORE_ENTRY 0xFFFF
328 UINT16 MfgStringOffset
;
329 UINT16 MfgStringSegment
;
331 BBS_STATUS_FLAGS StatusFlags
;
332 UINT16 BootHandlerOffset
;
333 UINT16 BootHandlerSegment
;
334 UINT16 DescStringOffset
;
335 UINT16 DescStringSegment
;
336 UINT32 InitPerReserved
;
337 UINT32 AdditionalIrq13Handler
;
338 UINT32 AdditionalIrq18Handler
;
339 UINT32 AdditionalIrq19Handler
;
340 UINT32 AdditionalIrq40Handler
;
341 UINT8 AssignedDriveNumber
;
342 UINT32 AdditionalIrq41Handler
;
343 UINT32 AdditionalIrq46Handler
;
352 (EFIAPI
*EFI_LEGACY_BIOS_INT86
) (
353 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
355 IN OUT EFI_IA32_REGISTER_SET
* Regs
360 Thunk to 16-bit real mode and execute a software interrupt with a vector
361 of BiosInt. Regs will contain the 16-bit register context on entry and
365 This - Protocol instance pointer.
366 BiosInt - Processor interrupt vector to invoke
367 Reg - Register contexted passed into (and returned) from thunk to
371 FALSE - Thunk completed, and there were no BIOS errors in the target code.
373 TRUE - There was a BIOS erro in the target code.
380 (EFIAPI
*EFI_LEGACY_BIOS_FARCALL86
) (
381 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
384 IN EFI_IA32_REGISTER_SET
* Regs
,
391 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
392 16-bit register context on entry and exit. Arguments can be passed on
396 This - Protocol instance pointer.
397 Segment - Segemnt of 16-bit mode call
398 Offset - Offset of 16-bit mdoe call
399 Reg - Register contexted passed into (and returned) from thunk to
401 Stack - Caller allocated stack used to pass arguments
402 StackSize - Size of Stack in bytes
405 FALSE - Thunk completed, and there were no BIOS errors in the target code.
407 TRUE - There was a BIOS erro in the target code.
414 (EFIAPI
*EFI_LEGACY_BIOS_CHECK_ROM
) (
415 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
416 IN EFI_HANDLE PciHandle
,
417 OUT VOID
**RomImage
, OPTIONAL
418 OUT UINTN
*RomSize
, OPTIONAL
425 Test to see if a legacy PCI ROM exists for this device. Optionally return
426 the Legacy ROM instance for this PCI device.
429 This - Protocol instance pointer.
430 PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded
431 RomImage - Return the legacy PCI ROM for this device
432 RomSize - Size of ROM Image
433 Flags - Indicates if ROM found and if PC-AT.
436 EFI_SUCCESS - Legacy Option ROM availible for this device
437 EFI_UNSUPPORTED - Legacy Option ROM not supported.
444 (EFIAPI
*EFI_LEGACY_BIOS_INSTALL_ROM
) (
445 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
446 IN EFI_HANDLE PciHandle
,
449 OUT UINT8
*DiskStart
, OPTIONAL
450 OUT UINT8
*DiskEnd
, OPTIONAL
451 OUT VOID
**RomShadowAddress
, OPTIONAL
452 OUT UINT32
*ShadowedRomSize OPTIONAL
457 Load a legacy PC-AT OPROM on the PciHandle device. Return information
458 about how many disks were added by the OPROM and the shadow address and
459 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
462 This - Protocol instance pointer.
463 PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
464 This value is NULL if RomImage is non-NULL. This is the normal
466 RomImage - A PCI PC-AT ROM image. This argument is non-NULL if there is
467 no hardware associated with the ROM and thus no PciHandle,
468 otherwise is must be NULL.
469 Example is PXE base code.
470 Flags - Return Status if ROM was found and if was Legacy OPROM.
471 DiskStart - Disk number of first device hooked by the ROM. If DiskStart
472 is the same as DiskEnd no disked were hooked.
473 DiskEnd - Disk number of the last device hooked by the ROM.
474 RomShadowAddress - Shadow address of PC-AT ROM
475 RomShadowSize - Size of RomShadowAddress in bytes
478 EFI_SUCCESS - Thunk completed, see Regs for status.
479 EFI_INVALID_PARAMETER - PciHandle not found
486 (EFIAPI
*EFI_LEGACY_BIOS_BOOT
) (
487 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
488 IN BBS_BBS_DEVICE_PATH
* BootOption
,
489 IN UINT32 LoadOptionsSize
,
495 Attempt to legacy boot the BootOption. If the EFI contexted has been
496 compromised this function will not return.
499 This - Protocol instance pointer.
500 BootOption - EFI Device Path from BootXXXX variable.
501 LoadOptionSize - Size of LoadOption in size.
502 LoadOption - LoadOption from BootXXXX variable
505 EFI_SUCCESS - Removable media not present
511 (EFIAPI
*EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS
) (
512 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
518 Update BDA with current Scroll, Num & Cap lock LEDS
521 This - Protocol instance pointer.
522 Leds - Status of current Scroll, Num & Cap lock LEDS
523 Bit 0 is Scroll Lock 0 = Not locked
528 EFI_SUCCESS - Removable media not present
535 (EFIAPI
*EFI_LEGACY_BIOS_GET_BBS_INFO
) (
536 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
537 OUT UINT16
*HddCount
,
538 OUT HDD_INFO
**HddInfo
,
539 OUT UINT16
*BbsCount
,
540 IN OUT BBS_TABLE
**BbsTable
545 Retrieve legacy BBS info and assign boot priority.
548 This - Protocol instance pointer.
549 HddCount - Number of HDD_INFO structures
550 HddInfo - Onboard IDE controller information
551 BbsCount - Number of BBS_TABLE structures
552 BbsTable - List BBS entries
555 EFI_SUCCESS - Tables returned
562 (EFIAPI
*EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI
) (
563 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
564 OUT UINT16
*BbsCount
,
565 OUT BBS_TABLE
**BbsTable
570 Assign drive number to legacy HDD drives prior to booting an EFI
571 aware OS so the OS can access drives without an EFI driver.
574 This - Protocol instance pointer.
575 BbsCount - Number of BBS_TABLE structures
576 BbsTable - List BBS entries
579 EFI_SUCCESS - Drive numbers assigned
586 (EFIAPI
*EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE
) (
587 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
588 IN UDC_ATTRIBUTES Attributes
,
591 IN VOID
*ServiceAreaData
596 To boot from an unconventional device like parties and/or execute
600 This - Protocol instance pointer.
601 Attributes - How to interpret the other input parameters
602 BbsEntry - The 0-based index into the BbsTable for the parent
604 BeerData - Pointer to the 128 bytes of ram BEER data.
605 ServiceAreaData - Pointer to the 64 bytes of raw Service Area data. The
606 caller must provide a pointer to the specific Service
607 Area and not the start all Service Areas.
609 EFI_INVALID_PARAMETER if error. Does NOT return if no error.
616 (EFIAPI
*EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS
) (
617 IN EFI_LEGACY_BIOS_PROTOCOL
* This
622 Shadow all legacy16 OPROMs that haven't been shadowed.
623 Warning: Use this with caution. This routine disconnects all EFI
624 drivers. If used externally then caller must re-connect EFI
629 EFI_SUCCESS - OPROMs shadowed
636 (EFIAPI
*EFI_LEGACY_BIOS_GET_LEGACY_REGION
) (
637 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
638 IN UINTN LegacyMemorySize
,
641 OUT VOID
**LegacyMemoryAddress
646 Get a region from the LegacyBios for S3 usage.
649 This - Protocol instance pointer.
650 LegacyMemorySize - Size of required region
651 Region - Region to use.
652 00 = Either 0xE0000 or 0xF0000 block
653 Bit0 = 1 0xF0000 block
654 Bit1 = 1 0xE0000 block
655 Alignment - Address alignment. Bit mapped. First non-zero
656 bit from right is alignment.
657 LegacyMemoryAddress - Region Assigned
661 EFI_SUCCESS - Region assigned
663 Other - Region not assigned
670 (EFIAPI
*EFI_LEGACY_BIOS_COPY_LEGACY_REGION
) (
671 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
672 IN UINTN LegacyMemorySize
,
673 IN VOID
*LegacyMemoryAddress
,
674 IN VOID
*LegacyMemorySourceAddress
679 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
682 This - Protocol instance pointer.
683 LegacyMemorySize - Size of data to copy
684 LegacyMemoryAddress - Legacy Region destination address
685 Note: must be in region assigned by
686 LegacyBiosGetLegacyRegion
687 LegacyMemorySourceAddress - Source of data
691 EFI_SUCCESS - Region assigned
692 EFI_ACCESS_DENIED - Destination outside assigned region
697 struct _EFI_LEGACY_BIOS_PROTOCOL
{
698 EFI_LEGACY_BIOS_INT86 Int86
;
699 EFI_LEGACY_BIOS_FARCALL86 FarCall86
;
700 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom
;
701 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom
;
702 EFI_LEGACY_BIOS_BOOT LegacyBoot
;
703 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus
;
704 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo
;
705 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms
;
706 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi
;
707 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion
;
708 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion
;
709 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice
;
712 extern EFI_GUID gEfiLegacyBiosProtocolGuid
;