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) 2007 - 2009, 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 #include <Framework/Legacy16.h>
37 #define EFI_LEGACY_BIOS_PROTOCOL_GUID \
39 0xdb9a1e3d, 0x45cb, 0x4abb, {0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d } \
42 typedef struct _EFI_LEGACY_BIOS_PROTOCOL EFI_LEGACY_BIOS_PROTOCOL
;
45 // Flags returned by CheckPciRom()
48 #define ROM_FOUND 0x01
49 #define VALID_LEGACY_ROM 0x02
50 #define ROM_WITH_CONFIG 0x04 // Not defined in CSM Specification0.96
53 /// @bug These macros appear in no specifications and are kept for backward
54 // compatibility only.
55 // Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form
57 #define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
58 #define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
59 #define BYTE_GRANULARITY 0x01
60 #define WORD_GRANULARITY 0x02
61 #define DWORD_GRANULARITY 0x04
62 #define QWORD_GRANULARITY 0x08
63 #define PARAGRAPH_GRANULARITY 0x10
65 #define CARRY_FLAG 0x01
67 //*********************************************************
69 //*********************************************************
90 //*********************************************************
92 //*********************************************************
101 EFI_EFLAGS_REG EFlags
;
112 //*******************************************
114 //*******************************************
134 //*********************************************************
136 //*********************************************************
152 UINT16 ReservedFlags
;
165 //*********************************************************
167 //*********************************************************
184 } EFI_IA32_REGISTER_SET
;
187 Thunk to 16-bit real mode and execute a software interrupt with a vector
188 of BiosInt. Regs will contain the 16-bit register context on entry and
191 @param This Protocol instance pointer.
192 @param BiosInt Processor interrupt vector to invoke
193 @param Reg Register contexted passed into (and returned) from thunk to
196 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
198 @retval TRUE There was a BIOS erro in the target code.
203 (EFIAPI
*EFI_LEGACY_BIOS_INT86
)(
204 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
206 IN OUT EFI_IA32_REGISTER_SET
*Regs
210 Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
211 16-bit register context on entry and exit. Arguments can be passed on
214 @param This Protocol instance pointer.
215 @param Segment Segemnt of 16-bit mode call
216 @param Offset Offset of 16-bit mdoe call
217 @param Reg Register contexted passed into (and returned) from thunk to
219 @param Stack Caller allocated stack used to pass arguments
220 @param StackSize Size of Stack in bytes
222 @retval FALSE Thunk completed, and there were no BIOS errors in the target code.
224 @retval TRUE There was a BIOS erro in the target code.
229 (EFIAPI
*EFI_LEGACY_BIOS_FARCALL86
)(
230 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
233 IN EFI_IA32_REGISTER_SET
*Regs
,
239 Test to see if a legacy PCI ROM exists for this device. Optionally return
240 the Legacy ROM instance for this PCI device.
242 @param This Protocol instance pointer.
243 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded
244 @param RomImage Return the legacy PCI ROM for this device
245 @param RomSize Size of ROM Image
246 @param Flags Indicates if ROM found and if PC-AT. Multiple bits can be set as follows:
249 02 = ROM is a valid legacy ROM
251 @retval EFI_SUCCESS Legacy Option ROM availible for this device
252 @retval EFI_UNSUPPORTED Legacy Option ROM not supported.
257 (EFIAPI
*EFI_LEGACY_BIOS_CHECK_ROM
)(
258 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
259 IN EFI_HANDLE PciHandle
,
260 OUT VOID
**RomImage
, OPTIONAL
261 OUT UINTN
*RomSize
, OPTIONAL
266 Load a legacy PC-AT OPROM on the PciHandle device. Return information
267 about how many disks were added by the OPROM and the shadow address and
268 size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
270 @param This Protocol instance pointer.
271 @param PciHandle The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
272 This value is NULL if RomImage is non-NULL. This is the normal
274 @param RomImage A PCI PC-AT ROM image. This argument is non-NULL if there is
275 no hardware associated with the ROM and thus no PciHandle,
276 otherwise is must be NULL.
277 Example is PXE base code.
278 @param Flags The type of ROM discovered. Multiple bits can be set, as follows:
281 02 = ROM is a valid legacy ROM.
282 @param DiskStart Disk number of first device hooked by the ROM. If DiskStart
283 is the same as DiskEnd no disked were hooked.
284 @param DiskEnd Disk number of the last device hooked by the ROM.
285 @param RomShadowAddress Shadow address of PC-AT ROM
286 @param RomShadowSize Size of RomShadowAddress in bytes
288 @retval EFI_SUCCESS Thunk completed, see Regs for status.
289 @retval EFI_INVALID_PARAMETER PciHandle not found
294 (EFIAPI
*EFI_LEGACY_BIOS_INSTALL_ROM
)(
295 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
296 IN EFI_HANDLE PciHandle
,
299 OUT UINT8
*DiskStart
, OPTIONAL
300 OUT UINT8
*DiskEnd
, OPTIONAL
301 OUT VOID
**RomShadowAddress
, OPTIONAL
302 OUT UINT32
*ShadowedRomSize OPTIONAL
306 This function attempts to traditionally boot the specified BootOption. If the EFI context has
307 been compromised, this function will not return. This procedure is not used for loading an EFIaware
308 OS off a traditional device. The following actions occur:
309 - Get EFI SMBIOS data structures, convert them to a traditional format, and copy to
311 - Get a pointer to ACPI data structures and copy the Compatibility16 RSD PTR to F0000 block.
312 - Find the traditional SMI handler from a firmware volume and register the traditional SMI
313 handler with the EFI SMI handler.
314 - Build onboard IDE information and pass this information to the Compatibility16 code.
315 - Make sure all PCI Interrupt Line registers are programmed to match 8259.
316 - Reconfigure SIO devices from EFI mode (polled) into traditional mode (interrupt driven).
317 - Shadow all PCI ROMs.
318 - Set up BDA and EBDA standard areas before the legacy boot.
319 - Construct the Compatibility16 boot memory map and pass it to the Compatibility16 code.
320 - Invoke the Compatibility16 table function Compatibility16PrepareToBoot(). This
321 invocation causes a thunk into the Compatibility16 code, which sets all appropriate internal
322 data structures. The boot device list is a parameter.
323 - Invoke the Compatibility16 Table function Compatibility16Boot(). This invocation
324 causes a thunk into the Compatibility16 code, which does an INT19.
325 - If the Compatibility16Boot() function returns, then the boot failed in a graceful
326 manner—i.e., EFI code is still valid. An ungraceful boot failure causes a reset because the state
327 of EFI code is unknown.
329 @param This Protocol instance pointer.
330 @param BootOption EFI Device Path from BootXXXX variable.
331 @param LoadOptionSize Size of LoadOption in size.
332 @param LoadOption LoadOption from BootXXXX variable
334 @retval EFI_DEVICE_ERROR Failed to boot from any boot device and memory is uncorrupted.
335 Note: This function normally never returns. It will either boot the
336 OS or reset the system if memory has been "corrupted" by loading
337 a boot sector and passing control to it.
342 (EFIAPI
*EFI_LEGACY_BIOS_BOOT
)(
343 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
344 IN BBS_BBS_DEVICE_PATH
*BootOption
,
345 IN UINT32 LoadOptionsSize
,
350 This function takes the Leds input parameter and sets/resets the BDA accordingly.
351 Leds is also passed to Compatibility16 code, in case any special processing is required.
352 This function is normally called from EFI Setup drivers that handle userselectable
353 keyboard options such as boot with NUM LOCK on/off. This function does not
354 touch the keyboard or keyboard LEDs but only the BDA.
356 @param This Protocol instance pointer.
357 @param Leds Status of current Scroll, Num & Cap lock LEDS
358 Bit 0 is Scroll Lock 0 = Not locked
362 @retval EFI_SUCCESS The BDA was updated successfully.
367 (EFIAPI
*EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS
)(
368 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
373 Retrieve legacy BBS info and assign boot priority.
375 @param This Protocol instance pointer.
376 @param HddCount Number of HDD_INFO structures
377 @param HddInfo Onboard IDE controller information
378 @param BbsCount Number of BBS_TABLE structures
379 @param BbsTable Point to List of BBS_TABLE
381 @retval EFI_SUCCESS Tables returned
386 (EFIAPI
*EFI_LEGACY_BIOS_GET_BBS_INFO
)(
387 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
388 OUT UINT16
*HddCount
,
389 OUT HDD_INFO
**HddInfo
,
390 OUT UINT16
*BbsCount
,
391 IN OUT BBS_TABLE
**BbsTable
395 Assign drive number to legacy HDD drives prior to booting an EFI
396 aware OS so the OS can access drives without an EFI driver.
398 @param This Protocol instance pointer.
399 @param BbsCount Number of BBS_TABLE structures
400 @param BbsTable List BBS entries
402 @retval EFI_SUCCESS Drive numbers assigned
407 (EFIAPI
*EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI
)(
408 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
409 OUT UINT16
*BbsCount
,
410 OUT BBS_TABLE
**BbsTable
414 To boot from an unconventional device like parties and/or execute
417 @param This Protocol instance pointer.
418 @param Attributes How to interpret the other input parameters
419 @param BbsEntry The 0-based index into the BbsTable for the parent
421 @param BeerData Pointer to the 128 bytes of ram BEER data.
422 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data. The
423 caller must provide a pointer to the specific Service
424 Area and not the start all Service Areas.
426 @retval EFI_INVALID_PARAMETER if error. Does NOT return if no error.
431 (EFIAPI
*EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE
)(
432 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
433 IN UDC_ATTRIBUTES Attributes
,
436 IN VOID
*ServiceAreaData
440 Shadow all legacy16 OPROMs that haven't been shadowed.
441 Warning: Use this with caution. This routine disconnects all EFI
442 drivers. If used externally then caller must re-connect EFI
445 @retval EFI_SUCCESS OPROMs shadowed
450 (EFIAPI
*EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS
)(
451 IN EFI_LEGACY_BIOS_PROTOCOL
*This
455 Get a region from the LegacyBios for S3 usage.
457 @param This Protocol instance pointer.
458 @param LegacyMemorySize Size of required region
459 @param Region Region to use.
460 00 = Either 0xE0000 or 0xF0000 block
461 Bit0 = 1 0xF0000 block
462 Bit1 = 1 0xE0000 block
463 @param Alignment Address alignment. Bit mapped. First non-zero
464 bit from right is alignment.
465 @param LegacyMemoryAddress Region Assigned
467 @retval EFI_SUCCESS Region assigned
468 @retval EFI_ACCESS_DENIED The function was previously invoked.
469 @retval Other Region not assigned
474 (EFIAPI
*EFI_LEGACY_BIOS_GET_LEGACY_REGION
)(
475 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
476 IN UINTN LegacyMemorySize
,
479 OUT VOID
**LegacyMemoryAddress
483 Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
485 @param This Protocol instance pointer.
486 @param LegacyMemorySize Size of data to copy
487 @param LegacyMemoryAddress Legacy Region destination address
488 Note: must be in region assigned by
489 LegacyBiosGetLegacyRegion
490 @param LegacyMemorySourceAddress
491 Source of the data to copy.
493 @retval EFI_SUCCESS Region assigned
494 @retval EFI_ACCESS_DENIED Destination outside assigned region
499 (EFIAPI
*EFI_LEGACY_BIOS_COPY_LEGACY_REGION
)(
500 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
501 IN UINTN LegacyMemorySize
,
502 IN VOID
*LegacyMemoryAddress
,
503 IN VOID
*LegacyMemorySourceAddress
507 Abstracts the traditional BIOS from the rest of EFI. The LegacyBoot()
508 member function allows the BDS to support booting a traditional OS.
509 EFI thunks drivers that make EFI bindings for BIOS INT services use
510 all the other member functions.
512 struct _EFI_LEGACY_BIOS_PROTOCOL
{
514 /// Performs traditional software INT. See the Int86() function description.
516 EFI_LEGACY_BIOS_INT86 Int86
;
519 /// Performs a far call into Compatibility16 or traditional OpROM code.
521 EFI_LEGACY_BIOS_FARCALL86 FarCall86
;
524 /// Checks if a traditional OpROM exists for this device.
526 EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom
;
529 /// Loads a traditional OpROM in traditional OpROM address space.
531 EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom
;
534 /// Boots a traditional OS.
536 EFI_LEGACY_BIOS_BOOT LegacyBoot
;
539 /// Updates BDA to reflect the current EFI keyboard LED status.
541 EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus
;
544 /// Allows an external agent, such as BIOS Setup, to get the BBS data.
546 EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo
;
549 /// Causes all legacy OpROMs to be shadowed.
551 EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms
;
554 /// Performs all actions prior to boot. Used when booting an EFI-aware OS
555 /// rather than a legacy OS.
557 EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi
;
560 /// Allows EFI to reserve an area in the 0xE0000 or 0xF0000 block.
562 EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion
;
565 /// Allows EFI to copy data to the area specified by GetLegacyRegion.
567 EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion
;
570 /// Allows the user to boot off an unconventional device such as a PARTIES partition.
572 EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice
;
575 extern EFI_GUID gEfiLegacyBiosProtocolGuid
;