3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. 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
;
212 // define maximum number of HDD system supports
214 #define MAX_HDD_ENTRIES 0x30
223 #define HDD_PRIMARY 0x01
224 #define HDD_SECONDARY 0x02
225 #define HDD_MASTER_ATAPI_CDROM 0x04
226 #define HDD_SLAVE_ATAPI_CDROM 0x08
227 #define HDD_MASTER_IDE 0x20
228 #define HDD_SLAVE_IDE 0x40
229 #define HDD_MASTER_ATAPI_ZIPDISK 0x10
230 #define HDD_SLAVE_ATAPI_ZIPDISK 0x80
237 UINT16 CommandBaseAddress
;
238 UINT16 ControlBaseAddress
;
239 UINT16 BusMasterAddress
;
241 ATAPI_IDENTIFY IdentifyDrive
[2];
245 // Parties data structures
248 UINT8 DirectoryServiceValidity
: 1;
249 UINT8 RabcaUsedFlag
: 1;
250 UINT8 ExecuteHddDiagnosticsFlag
: 1;
255 UDC_ATTRIBUTES Attributes
;
257 UINT8 BbsTableEntryNumberForParentDevice
;
258 UINT8 BbsTableEntryNumberForBoot
;
259 UINT8 BbsTableEntryNumberForHddDiag
;
261 UINT8 ServiceAreaData
[64];
265 // define BBS Device Types
267 #define BBS_FLOPPY 0x01
268 #define BBS_HARDDISK 0x02
269 #define BBS_CDROM 0x03
270 #define BBS_PCMCIA 0x04
272 #define BBS_EMBED_NETWORK 0x06
273 #define BBS_BEV_DEVICE 0x80
274 #define BBS_UNKNOWN 0xff
277 UINT16 OldPosition
: 4;
278 UINT16 Reserved1
: 4;
281 UINT16 MediaPresent
: 2;
282 UINT16 Reserved2
: 4;
285 #define MAX_BBS_ENTRIES 0x100
287 // BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to
289 // BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before
290 // priority has been assigned but indicates valid entry.
291 // BBS_LOWEST_PRIORITY is normally used for removable media with no media
292 // inserted. This allows the 16-bit CSM to allocate a drive letter to
294 // BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign
295 // a drive letter to but never boot from.
297 // AdditionalIrq??Handler usage is IBV specific. The fields have been added
299 // 1. Saving non-BBS card info about IRQs taken by card.
300 // 2. For BBS compliant cards that hook IRQs in order to have their SETUP
303 #define BBS_DO_NOT_BOOT_FROM 0xFFFC
304 #define BBS_LOWEST_PRIORITY 0xFFFD
305 #define BBS_UNPRIORITIZED_ENTRY 0xFFFE
306 #define BBS_IGNORE_ENTRY 0xFFFF
315 UINT16 MfgStringOffset
;
316 UINT16 MfgStringSegment
;
318 BBS_STATUS_FLAGS StatusFlags
;
319 UINT16 BootHandlerOffset
;
320 UINT16 BootHandlerSegment
;
321 UINT16 DescStringOffset
;
322 UINT16 DescStringSegment
;
323 UINT32 InitPerReserved
;
324 UINT32 AdditionalIrq13Handler
;
325 UINT32 AdditionalIrq18Handler
;
326 UINT32 AdditionalIrq19Handler
;
327 UINT32 AdditionalIrq40Handler
;
328 UINT8 AssignedDriveNumber
;
329 UINT32 AdditionalIrq41Handler
;
330 UINT32 AdditionalIrq46Handler
;
339 (EFIAPI
*EFI_LEGACY_BIOS_INT86
) (
340 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
342 IN OUT EFI_IA32_REGISTER_SET
* Regs
347 Thunk to 16-bit real mode and execute a software interrupt with a vector
348 of BiosInt. Regs will contain the 16-bit register context on entry and
352 This - Protocol instance pointer.
353 BiosInt - Processor interrupt vector to invoke
354 Reg - Register contexted passed into (and returned) from thunk to
358 FALSE - Thunk completed, and there were no BIOS errors in the target code.
360 TRUE - There was a BIOS erro in the target code.
367 (EFIAPI
*EFI_LEGACY_BIOS_FARCALL86
) (
368 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
371 IN EFI_IA32_REGISTER_SET
* Regs
,
378 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
379 16-bit register context on entry and exit. Arguments can be passed on
383 This - Protocol instance pointer.
384 Segment - Segemnt of 16-bit mode call
385 Offset - Offset of 16-bit mdoe call
386 Reg - Register contexted passed into (and returned) from thunk to
388 Stack - Caller allocated stack used to pass arguments
389 StackSize - Size of Stack in bytes
392 FALSE - Thunk completed, and there were no BIOS errors in the target code.
394 TRUE - There was a BIOS erro in the target code.
401 (EFIAPI
*EFI_LEGACY_BIOS_CHECK_ROM
) (
402 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
403 IN EFI_HANDLE PciHandle
,
404 OUT VOID
**RomImage
, OPTIONAL
405 OUT UINTN
*RomSize
, OPTIONAL
412 Test to see if a legacy PCI ROM exists for this device. Optionally return
413 the Legacy ROM instance for this PCI device.
416 This - Protocol instance pointer.
417 PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded
418 RomImage - Return the legacy PCI ROM for this device
419 RomSize - Size of ROM Image
420 Flags - Indicates if ROM found and if PC-AT.
423 EFI_SUCCESS - Legacy Option ROM availible for this device
424 EFI_UNSUPPORTED - Legacy Option ROM not supported.
431 (EFIAPI
*EFI_LEGACY_BIOS_INSTALL_ROM
) (
432 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
433 IN EFI_HANDLE PciHandle
,
436 OUT UINT8
*DiskStart
, OPTIONAL
437 OUT UINT8
*DiskEnd
, OPTIONAL
438 OUT VOID
**RomShadowAddress
, OPTIONAL
439 OUT UINT32
*ShadowedRomSize OPTIONAL
444 Load a legacy PC-AT OPROM on the PciHandle device. Return information
445 about how many disks were added by the OPROM and the shadow address and
446 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
449 This - Protocol instance pointer.
450 PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
451 This value is NULL if RomImage is non-NULL. This is the normal
453 RomImage - A PCI PC-AT ROM image. This argument is non-NULL if there is
454 no hardware associated with the ROM and thus no PciHandle,
455 otherwise is must be NULL.
456 Example is PXE base code.
457 Flags - Return Status if ROM was found and if was Legacy OPROM.
458 DiskStart - Disk number of first device hooked by the ROM. If DiskStart
459 is the same as DiskEnd no disked were hooked.
460 DiskEnd - Disk number of the last device hooked by the ROM.
461 RomShadowAddress - Shadow address of PC-AT ROM
462 RomShadowSize - Size of RomShadowAddress in bytes
465 EFI_SUCCESS - Thunk completed, see Regs for status.
466 EFI_INVALID_PARAMETER - PciHandle not found
473 (EFIAPI
*EFI_LEGACY_BIOS_BOOT
) (
474 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
475 IN BBS_BBS_DEVICE_PATH
* BootOption
,
476 IN UINT32 LoadOptionsSize
,
482 Attempt to legacy boot the BootOption. If the EFI contexted has been
483 compromised this function will not return.
486 This - Protocol instance pointer.
487 BootOption - EFI Device Path from BootXXXX variable.
488 LoadOptionSize - Size of LoadOption in size.
489 LoadOption - LoadOption from BootXXXX variable
492 EFI_SUCCESS - Removable media not present
498 (EFIAPI
*EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS
) (
499 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
505 Update BDA with current Scroll, Num & Cap lock LEDS
508 This - Protocol instance pointer.
509 Leds - Status of current Scroll, Num & Cap lock LEDS
510 Bit 0 is Scroll Lock 0 = Not locked
515 EFI_SUCCESS - Removable media not present
522 (EFIAPI
*EFI_LEGACY_BIOS_GET_BBS_INFO
) (
523 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
524 OUT UINT16
*HddCount
,
525 OUT HDD_INFO
**HddInfo
,
526 OUT UINT16
*BbsCount
,
527 IN OUT BBS_TABLE
**BbsTable
532 Retrieve legacy BBS info and assign boot priority.
535 This - Protocol instance pointer.
536 HddCount - Number of HDD_INFO structures
537 HddInfo - Onboard IDE controller information
538 BbsCount - Number of BBS_TABLE structures
539 BbsTable - List BBS entries
542 EFI_SUCCESS - Tables returned
549 (EFIAPI
*EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI
) (
550 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
551 OUT UINT16
*BbsCount
,
552 OUT BBS_TABLE
**BbsTable
557 Assign drive number to legacy HDD drives prior to booting an EFI
558 aware OS so the OS can access drives without an EFI driver.
561 This - Protocol instance pointer.
562 BbsCount - Number of BBS_TABLE structures
563 BbsTable - List BBS entries
566 EFI_SUCCESS - Drive numbers assigned
573 (EFIAPI
*EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE
) (
574 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
575 IN UDC_ATTRIBUTES Attributes
,
578 IN VOID
*ServiceAreaData
583 To boot from an unconventional device like parties and/or execute
587 This - Protocol instance pointer.
588 Attributes - How to interpret the other input parameters
589 BbsEntry - The 0-based index into the BbsTable for the parent
591 BeerData - Pointer to the 128 bytes of ram BEER data.
592 ServiceAreaData - Pointer to the 64 bytes of raw Service Area data. The
593 caller must provide a pointer to the specific Service
594 Area and not the start all Service Areas.
596 EFI_INVALID_PARAMETER if error. Does NOT return if no error.
603 (EFIAPI
*EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS
) (
604 IN EFI_LEGACY_BIOS_PROTOCOL
* This
609 Shadow all legacy16 OPROMs that haven't been shadowed.
610 Warning: Use this with caution. This routine disconnects all EFI
611 drivers. If used externally then caller must re-connect EFI
616 EFI_SUCCESS - OPROMs shadowed
623 (EFIAPI
*EFI_LEGACY_BIOS_GET_LEGACY_REGION
) (
624 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
625 IN UINTN LegacyMemorySize
,
628 OUT VOID
**LegacyMemoryAddress
633 Get a region from the LegacyBios for S3 usage.
636 This - Protocol instance pointer.
637 LegacyMemorySize - Size of required region
638 Region - Region to use.
639 00 = Either 0xE0000 or 0xF0000 block
640 Bit0 = 1 0xF0000 block
641 Bit1 = 1 0xE0000 block
642 Alignment - Address alignment. Bit mapped. First non-zero
643 bit from right is alignment.
644 LegacyMemoryAddress - Region Assigned
648 EFI_SUCCESS - Region assigned
650 Other - Region not assigned
657 (EFIAPI
*EFI_LEGACY_BIOS_COPY_LEGACY_REGION
) (
658 IN EFI_LEGACY_BIOS_PROTOCOL
* This
,
659 IN UINTN LegacyMemorySize
,
660 IN VOID
*LegacyMemoryAddress
,
661 IN VOID
*LegacyMemorySourceAddress
666 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
669 This - Protocol instance pointer.
670 LegacyMemorySize - Size of data to copy
671 LegacyMemoryAddress - Legacy Region destination address
672 Note: must be in region assigned by
673 LegacyBiosGetLegacyRegion
674 LegacyMemorySourceAddress - Source of data
678 EFI_SUCCESS - Region assigned
679 EFI_ACCESS_DENIED - Destination outside assigned region
684 typedef 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_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms
;
693 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi
;
694 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion
;
695 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion
;
696 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice
;
697 } EFI_LEGACY_BIOS_PROTOCOL
;
699 extern EFI_GUID gEfiLegacyBiosProtocolGuid
;