3 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "LegacyBiosInterface.h"
17 #include <IndustryStandard/Pci.h>
19 #define BOOT_LEGACY_OS 0
21 #define BOOT_UNCONVENTIONAL_DEVICE 2
23 UINT32 mLoadOptionsSize
= 0;
24 UINTN mBootMode
= BOOT_LEGACY_OS
;
25 VOID
*mLoadOptions
= NULL
;
26 BBS_BBS_DEVICE_PATH
*mBbsDevicePathPtr
= NULL
;
27 BBS_BBS_DEVICE_PATH mBbsDevicePathNode
;
28 UDC_ATTRIBUTES mAttributes
= { 0, 0, 0, 0 };
30 VOID
*mBeerData
= NULL
;
31 VOID
*mServiceAreaData
= NULL
;
32 UINT64 mLowWater
= 0xffffffffffffffffULL
;
34 extern BBS_TABLE
*mBbsTable
;
36 extern VOID
*mRuntimeSmbiosEntryPoint
;
37 extern EFI_PHYSICAL_ADDRESS mReserveSmbiosEntryPoint
;
38 extern EFI_PHYSICAL_ADDRESS mStructureTableAddress
;
43 @param BbsTable The BBS table.
49 IN BBS_TABLE
*BbsTable
56 DEBUG ((EFI_D_INFO
, "\n"));
57 DEBUG ((EFI_D_INFO
, " NO Prio bb/dd/ff cl/sc Type Stat segm:offs mfgs:mfgo dess:deso\n"));
58 DEBUG ((EFI_D_INFO
, "=================================================================\n"));
59 for (Index
= 0; Index
< MAX_BBS_ENTRIES
; Index
++) {
63 if (BbsTable
[Index
].BootPriority
== BBS_IGNORE_ENTRY
) {
69 " %02x: %04x %02x/%02x/%02x %02x/%02x %04x %04x",
71 (UINTN
) BbsTable
[Index
].BootPriority
,
72 (UINTN
) BbsTable
[Index
].Bus
,
73 (UINTN
) BbsTable
[Index
].Device
,
74 (UINTN
) BbsTable
[Index
].Function
,
75 (UINTN
) BbsTable
[Index
].Class
,
76 (UINTN
) BbsTable
[Index
].SubClass
,
77 (UINTN
) BbsTable
[Index
].DeviceType
,
78 (UINTN
) * (UINT16
*) &BbsTable
[Index
].StatusFlags
82 " %04x:%04x %04x:%04x %04x:%04x",
83 (UINTN
) BbsTable
[Index
].BootHandlerSegment
,
84 (UINTN
) BbsTable
[Index
].BootHandlerOffset
,
85 (UINTN
) BbsTable
[Index
].MfgStringSegment
,
86 (UINTN
) BbsTable
[Index
].MfgStringOffset
,
87 (UINTN
) BbsTable
[Index
].DescStringSegment
,
88 (UINTN
) BbsTable
[Index
].DescStringOffset
94 String
= (CHAR8
*)(((UINTN
)BbsTable
[Index
].DescStringSegment
<< 4) + BbsTable
[Index
].DescStringOffset
);
96 DEBUG ((EFI_D_INFO
," ("));
97 for (SubIndex
= 0; String
[SubIndex
] != 0; SubIndex
++) {
98 DEBUG ((EFI_D_INFO
, "%c", String
[SubIndex
]));
100 DEBUG ((EFI_D_INFO
,")"));
102 DEBUG ((EFI_D_INFO
,"\n"));
105 DEBUG ((EFI_D_INFO
, "\n"));
113 @param HddInfo The HddInfo table.
124 DEBUG ((EFI_D_INFO
, "\n"));
125 for (Index
= 0; Index
< MAX_IDE_CONTROLLER
; Index
++) {
126 DEBUG ((EFI_D_INFO
, "Index - %04x\n", Index
));
127 DEBUG ((EFI_D_INFO
, " Status - %04x\n", (UINTN
)HddInfo
[Index
].Status
));
128 DEBUG ((EFI_D_INFO
, " B/D/F - %02x/%02x/%02x\n", (UINTN
)HddInfo
[Index
].Bus
, (UINTN
)HddInfo
[Index
].Device
, (UINTN
)HddInfo
[Index
].Function
));
129 DEBUG ((EFI_D_INFO
, " Command - %04x\n", HddInfo
[Index
].CommandBaseAddress
));
130 DEBUG ((EFI_D_INFO
, " Control - %04x\n", HddInfo
[Index
].ControlBaseAddress
));
131 DEBUG ((EFI_D_INFO
, " BusMaster - %04x\n", HddInfo
[Index
].BusMasterAddress
));
132 DEBUG ((EFI_D_INFO
, " HddIrq - %02x\n", HddInfo
[Index
].HddIrq
));
133 DEBUG ((EFI_D_INFO
, " IdentifyDrive[0].Raw[0] - %x\n", HddInfo
[Index
].IdentifyDrive
[0].Raw
[0]));
134 DEBUG ((EFI_D_INFO
, " IdentifyDrive[1].Raw[0] - %x\n", HddInfo
[Index
].IdentifyDrive
[1].Raw
[0]));
137 DEBUG ((EFI_D_INFO
, "\n"));
143 Print the PCI Interrupt Line and Interrupt Pin registers.
146 PrintPciInterruptRegister (
154 EFI_PCI_IO_PROTOCOL
*PciIo
;
161 gBS
->LocateHandleBuffer (
163 &gEfiPciIoProtocolGuid
,
173 DEBUG ((EFI_D_INFO
, "\n"));
174 DEBUG ((EFI_D_INFO
, " bb/dd/ff interrupt line interrupt pin\n"));
175 DEBUG ((EFI_D_INFO
, "======================================\n"));
176 for (Index
= 0; Index
< HandleNum
; Index
++) {
177 Status
= gBS
->HandleProtocol (Handles
[Index
], &gEfiPciIoProtocolGuid
, (VOID
**) &PciIo
);
178 if (!EFI_ERROR (Status
)) {
179 Status
= PciIo
->Pci
.Read (
187 if (!EFI_ERROR (Status
)) {
188 Status
= PciIo
->GetLocation (
196 if (!EFI_ERROR (Status
)) {
197 DEBUG ((EFI_D_INFO
, " %02x/%02x/%02x 0x%02x 0x%02x\n",
198 Bus
, Device
, Function
, Interrupt
[0], Interrupt
[1]));
201 DEBUG ((EFI_D_INFO
, "\n"));
203 if (Handles
!= NULL
) {
209 Identify drive data must be updated to actual parameters before boot.
211 @param IdentifyDriveData ATA Identify Data
215 UpdateIdentifyDriveData (
216 IN UINT8
*IdentifyDriveData
222 @param Private Legacy BIOS Instance data
224 @retval EFI_SUCCESS Removable media not present
229 IN LEGACY_BIOS_INSTANCE
*Private
235 UINT8 LegacyInterrupts
[16];
236 EFI_LEGACY_IRQ_ROUTING_ENTRY
*RoutingTable
;
237 UINTN RoutingTableEntries
;
238 EFI_LEGACY_IRQ_PRIORITY_TABLE_ENTRY
*IrqPriorityTable
;
239 UINTN NumberPriorityEntries
;
240 EFI_TO_COMPATIBILITY16_BOOT_TABLE
*EfiToLegacy16BootTable
;
246 EFI_HANDLE
*HandleBuffer
;
247 EFI_ISA_IO_PROTOCOL
*IsaIo
;
252 EfiToLegacy16BootTable
= &Private
->IntThunk
->EfiToLegacy16BootTable
;
253 LegacyBiosBuildSioData (Private
);
254 SetMem (LegacyInterrupts
, sizeof (LegacyInterrupts
), 0);
257 // Create list of legacy interrupts.
259 for (Index
= 0; Index
< 4; Index
++) {
260 LegacyInterrupts
[Index
] = EfiToLegacy16BootTable
->SioData
.Serial
[Index
].Irq
;
263 for (Index
= 4; Index
< 7; Index
++) {
264 LegacyInterrupts
[Index
] = EfiToLegacy16BootTable
->SioData
.Parallel
[Index
- 4].Irq
;
267 LegacyInterrupts
[7] = EfiToLegacy16BootTable
->SioData
.Floppy
.Irq
;
270 // Get Legacy Hdd IRQs. If native mode treat as PCI
272 for (Index
= 0; Index
< 2; Index
++) {
273 HddIrq
= EfiToLegacy16BootTable
->HddInfo
[Index
].HddIrq
;
274 if ((HddIrq
!= 0) && ((HddIrq
== 15) || (HddIrq
== 14))) {
275 LegacyInterrupts
[Index
+ 8] = HddIrq
;
279 Private
->LegacyBiosPlatform
->GetRoutingTable (
280 Private
->LegacyBiosPlatform
,
281 (VOID
*) &RoutingTable
,
282 &RoutingTableEntries
,
285 (VOID
**) &IrqPriorityTable
,
286 &NumberPriorityEntries
289 // Remove legacy interrupts from the list of PCI interrupts available.
291 for (Index
= 0; Index
<= 0x0b; Index
++) {
292 for (Index1
= 0; Index1
<= NumberPriorityEntries
; Index1
++) {
293 if (LegacyInterrupts
[Index
] != 0) {
294 LegacyInt
= (UINT16
) (LegacyInt
| (1 << LegacyInterrupts
[Index
]));
295 if (LegacyInterrupts
[Index
] == IrqPriorityTable
[Index1
].Irq
) {
296 IrqPriorityTable
[Index1
].Used
= LEGACY_USED
;
302 Private
->Legacy8259
->GetMask (
311 // Set SIO interrupts and disable mouse. Let mouse driver
314 LegMask
= (UINT16
) ((LegMask
&~LegacyInt
) | 0x1000);
315 Private
->Legacy8259
->SetMask (
324 // Disable mouse in keyboard controller
327 Status
= gBS
->LocateHandleBuffer (
329 &gEfiIsaIoProtocolGuid
,
334 if (EFI_ERROR (Status
)) {
338 for (Index
= 0; Index
< HandleCount
; Index
++) {
339 Status
= gBS
->HandleProtocol (
341 &gEfiIsaIoProtocolGuid
,
344 ASSERT_EFI_ERROR (Status
);
345 IsaIo
->Io
.Write (IsaIo
, EfiIsaIoWidthUint8
, 0x64, 1, &Register
);
349 if (HandleBuffer
!= NULL
) {
350 FreePool (HandleBuffer
);
358 Identify drive data must be updated to actual parameters before boot.
359 This requires updating the checksum, if it exists.
361 @param IdentifyDriveData ATA Identify Data
362 @param Checksum checksum of the ATA Identify Data
364 @retval EFI_SUCCESS checksum calculated
365 @retval EFI_SECURITY_VIOLATION IdentifyData invalid
369 CalculateIdentifyDriveChecksum (
370 IN UINT8
*IdentifyDriveData
,
378 if (IdentifyDriveData
[510] != 0xA5) {
379 return EFI_SECURITY_VIOLATION
;
382 for (Index
= 0; Index
< 512; Index
++) {
383 LocalChecksum
= (UINT8
) (LocalChecksum
+ IdentifyDriveData
[Index
]);
386 *Checksum
= LocalChecksum
;
392 Identify drive data must be updated to actual parameters before boot.
394 @param IdentifyDriveData ATA Identify Data
399 UpdateIdentifyDriveData (
400 IN UINT8
*IdentifyDriveData
403 UINT16 NumberCylinders
;
405 UINT16 NumberSectorsTrack
;
406 UINT32 CapacityInSectors
;
407 UINT8 OriginalChecksum
;
410 ATAPI_IDENTIFY
*ReadInfo
;
413 // Status indicates if Integrity byte is correct. Checksum should be
416 ReadInfo
= (ATAPI_IDENTIFY
*) IdentifyDriveData
;
417 Status
= CalculateIdentifyDriveChecksum (IdentifyDriveData
, &OriginalChecksum
);
418 if (OriginalChecksum
!= 0) {
419 Status
= EFI_SECURITY_VIOLATION
;
422 // If NumberCylinders = 0 then do data(Controller present but don drive attached).
424 NumberCylinders
= ReadInfo
->Raw
[1];
425 if (NumberCylinders
!= 0) {
426 ReadInfo
->Raw
[54] = NumberCylinders
;
428 NumberHeads
= ReadInfo
->Raw
[3];
429 ReadInfo
->Raw
[55] = NumberHeads
;
431 NumberSectorsTrack
= ReadInfo
->Raw
[6];
432 ReadInfo
->Raw
[56] = NumberSectorsTrack
;
435 // Copy Multisector info and set valid bit.
437 ReadInfo
->Raw
[59] = (UINT16
) (ReadInfo
->Raw
[47] + 0x100);
438 CapacityInSectors
= (UINT32
) ((UINT32
) (NumberCylinders
) * (UINT32
) (NumberHeads
) * (UINT32
) (NumberSectorsTrack
));
439 ReadInfo
->Raw
[57] = (UINT16
) (CapacityInSectors
>> 16);
440 ReadInfo
->Raw
[58] = (UINT16
) (CapacityInSectors
& 0xffff);
441 if (Status
== EFI_SUCCESS
) {
443 // Forece checksum byte to 0 and get new checksum.
445 ReadInfo
->Raw
[255] &= 0xff;
446 CalculateIdentifyDriveChecksum (IdentifyDriveData
, &FinalChecksum
);
449 // Force new checksum such that sum is 0.
451 FinalChecksum
= (UINT8
) ((UINT8
)0 - FinalChecksum
);
452 ReadInfo
->Raw
[255] = (UINT16
) (ReadInfo
->Raw
[255] | (FinalChecksum
<< 8));
458 Identify drive data must be updated to actual parameters before boot.
461 @param Private Legacy BIOS Instance data
466 UpdateAllIdentifyDriveData (
467 IN LEGACY_BIOS_INSTANCE
*Private
473 HddInfo
= &Private
->IntThunk
->EfiToLegacy16BootTable
.HddInfo
[0];
475 for (Index
= 0; Index
< MAX_IDE_CONTROLLER
; Index
++) {
477 // Each controller can have 2 devices. Update for each device
479 if ((HddInfo
[Index
].Status
& HDD_MASTER_IDE
) != 0) {
480 UpdateIdentifyDriveData ((UINT8
*) (&HddInfo
[Index
].IdentifyDrive
[0].Raw
[0]));
483 if ((HddInfo
[Index
].Status
& HDD_SLAVE_IDE
) != 0) {
484 UpdateIdentifyDriveData ((UINT8
*) (&HddInfo
[Index
].IdentifyDrive
[1].Raw
[0]));
490 Enable ide controller. This gets disabled when LegacyBoot.c is about
491 to run the Option ROMs.
493 @param Private Legacy BIOS Instance data
498 EnableIdeController (
499 IN LEGACY_BIOS_INSTANCE
*Private
502 EFI_PCI_IO_PROTOCOL
*PciIo
;
504 EFI_HANDLE IdeController
;
507 EFI_HANDLE
*HandleBuffer
;
509 Status
= Private
->LegacyBiosPlatform
->GetPlatformHandle (
510 Private
->LegacyBiosPlatform
,
511 EfiGetPlatformIdeHandle
,
517 if (!EFI_ERROR (Status
)) {
518 IdeController
= HandleBuffer
[0];
519 Status
= gBS
->HandleProtocol (
521 &gEfiPciIoProtocolGuid
,
525 if (!EFI_ERROR (Status
)) {
526 PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint8
, 0x04, 1, &ByteBuffer
);
533 Enable ide controller. This gets disabled when LegacyBoot.c is about
534 to run the Option ROMs.
536 @param Private Legacy BIOS Instance data
541 EnableAllControllers (
542 IN LEGACY_BIOS_INSTANCE
*Private
546 EFI_HANDLE
*HandleBuffer
;
548 EFI_PCI_IO_PROTOCOL
*PciIo
;
549 PCI_TYPE01 PciConfigHeader
;
555 EnableIdeController (Private
);
558 // Assumption is table is built from low bus to high bus numbers.
560 Status
= gBS
->LocateHandleBuffer (
562 &gEfiPciIoProtocolGuid
,
567 ASSERT_EFI_ERROR (Status
);
569 for (Index
= 0; Index
< HandleCount
; Index
++) {
570 Status
= gBS
->HandleProtocol (
572 &gEfiPciIoProtocolGuid
,
575 ASSERT_EFI_ERROR (Status
);
581 sizeof (PciConfigHeader
) / sizeof (UINT32
),
586 // We do not enable PPB here. This is for HotPlug Consideration.
587 // The Platform HotPlug Driver is responsible for Padding enough hot plug
588 // resources. It is also responsible for enable this bridge. If it
589 // does not pad it. It will cause some early Windows fail to installation.
590 // If the platform driver does not pad resource for PPB, PPB should be in
591 // un-enabled state to let Windows know that this PPB is not configured by
592 // BIOS. So Windows will allocate default resource for PPB.
594 // The reason for why we enable the command register is:
595 // The CSM will use the IO bar to detect some IRQ status, if the command
596 // is disabled, the IO resource will be out of scope.
598 // We installed a legacy IRQ handle for a PCI IDE controller. When IRQ
599 // comes up, the handle will check the IO space to identify is the
600 // controller generated the IRQ source.
601 // If the IO command is not enabled, the IRQ handler will has wrong
602 // information. It will cause IRQ storm when the correctly IRQ handler fails
605 if (!(IS_PCI_VGA (&PciConfigHeader
) ||
606 IS_PCI_OLD_VGA (&PciConfigHeader
) ||
607 IS_PCI_IDE (&PciConfigHeader
) ||
608 IS_PCI_P2P (&PciConfigHeader
) ||
609 IS_PCI_P2P_SUB (&PciConfigHeader
) ||
610 IS_PCI_LPC (&PciConfigHeader
) )) {
612 PciConfigHeader
.Hdr
.Command
|= 0x1f;
614 PciIo
->Pci
.Write (PciIo
, EfiPciIoWidthUint32
, 4, 1, &PciConfigHeader
.Hdr
.Command
);
620 The following routines are identical in operation, so combine
622 EfiGetPlatformBinaryGetMpTable
623 EfiGetPlatformBinaryGetOemIntData
624 EfiGetPlatformBinaryGetOem32Data
625 EfiGetPlatformBinaryGetOem16Data
627 @param This Protocol instance pointer.
628 @param Id Table/Data identifier
630 @retval EFI_SUCCESS Success
631 @retval EFI_INVALID_PARAMETER Invalid ID
632 @retval EFI_OUT_OF_RESOURCES no resource to get data or table
636 LegacyGetDataOrTable (
637 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
638 IN EFI_GET_PLATFORM_INFO_MODE Id
647 EFI_LEGACY_BIOS_PLATFORM_PROTOCOL
*LegacyBiosPlatform
;
648 EFI_COMPATIBILITY16_TABLE
*Legacy16Table
;
649 EFI_IA32_REGISTER_SET Regs
;
650 LEGACY_BIOS_INSTANCE
*Private
;
652 Private
= LEGACY_BIOS_INSTANCE_FROM_THIS (This
);
654 LegacyBiosPlatform
= Private
->LegacyBiosPlatform
;
655 Legacy16Table
= Private
->Legacy16Table
;
658 // Phase 1 - get an address allocated in 16-bit code
662 case EfiGetPlatformBinaryMpTable
:
663 case EfiGetPlatformBinaryOemIntData
:
664 case EfiGetPlatformBinaryOem32Data
:
665 case EfiGetPlatformBinaryOem16Data
:
667 Status
= LegacyBiosPlatform
->GetPlatformInfo (
677 DEBUG ((EFI_D_INFO
, "LegacyGetDataOrTable - ID: %x, %r\n", (UINTN
)Id
, Status
));
678 DEBUG ((EFI_D_INFO
, " Table - %x, Size - %x, Location - %x, Alignment - %x\n", (UINTN
)Table
, (UINTN
)TableSize
, (UINTN
)Location
, (UINTN
)Alignment
));
684 return EFI_INVALID_PARAMETER
;
688 if (EFI_ERROR (Status
)) {
692 ZeroMem (&Regs
, sizeof (EFI_IA32_REGISTER_SET
));
693 Regs
.X
.AX
= Legacy16GetTableAddress
;
694 Regs
.X
.CX
= (UINT16
) TableSize
;
695 Regs
.X
.BX
= (UINT16
) Location
;
696 Regs
.X
.DX
= (UINT16
) Alignment
;
697 Private
->LegacyBios
.FarCall86 (
699 Private
->Legacy16CallSegment
,
700 Private
->Legacy16CallOffset
,
706 if (Regs
.X
.AX
!= 0) {
707 DEBUG ((EFI_D_ERROR
, "Table ID %x length insufficient\n", Id
));
708 return EFI_OUT_OF_RESOURCES
;
714 // Phase 2 Call routine second time with address to allow address adjustment
716 Status
= LegacyBiosPlatform
->GetPlatformInfo (
727 case EfiGetPlatformBinaryMpTable
:
729 Legacy16Table
->MpTablePtr
= (UINT32
) (Regs
.X
.DS
* 16 + Regs
.X
.BX
);
730 Legacy16Table
->MpTableLength
= (UINT32
)TableSize
;
731 DEBUG ((EFI_D_INFO
, "MP table in legacy region - %x\n", (UINTN
)Legacy16Table
->MpTablePtr
));
735 case EfiGetPlatformBinaryOemIntData
:
738 Legacy16Table
->OemIntSegment
= Regs
.X
.DS
;
739 Legacy16Table
->OemIntOffset
= Regs
.X
.BX
;
740 DEBUG ((EFI_D_INFO
, "OemInt table in legacy region - %04x:%04x\n", (UINTN
)Legacy16Table
->OemIntSegment
, (UINTN
)Legacy16Table
->OemIntOffset
));
744 case EfiGetPlatformBinaryOem32Data
:
746 Legacy16Table
->Oem32Segment
= Regs
.X
.DS
;
747 Legacy16Table
->Oem32Offset
= Regs
.X
.BX
;
748 DEBUG ((EFI_D_INFO
, "Oem32 table in legacy region - %04x:%04x\n", (UINTN
)Legacy16Table
->Oem32Segment
, (UINTN
)Legacy16Table
->Oem32Offset
));
752 case EfiGetPlatformBinaryOem16Data
:
755 // Legacy16Table->Oem16Segment = Regs.X.DS;
756 // Legacy16Table->Oem16Offset = Regs.X.BX;
757 DEBUG ((EFI_D_INFO
, "Oem16 table in legacy region - %04x:%04x\n", (UINTN
)Legacy16Table
->Oem16Segment
, (UINTN
)Legacy16Table
->Oem16Offset
));
763 return EFI_INVALID_PARAMETER
;
767 if (EFI_ERROR (Status
)) {
771 // Phase 3 Copy table to final location
773 TablePtr
= (UINT32
) (Regs
.X
.DS
* 16 + Regs
.X
.BX
);
776 (VOID
*) (UINTN
)TablePtr
,
785 Copy SMBIOS table to EfiReservedMemoryType of memory for legacy boot.
789 CreateSmbiosTableInReservedMemory (
793 SMBIOS_TABLE_ENTRY_POINT
*EntryPointStructure
;
795 if ((mRuntimeSmbiosEntryPoint
== NULL
) ||
796 (mReserveSmbiosEntryPoint
== 0) ||
797 (mStructureTableAddress
== 0)) {
801 EntryPointStructure
= (SMBIOS_TABLE_ENTRY_POINT
*) mRuntimeSmbiosEntryPoint
;
804 // Copy SMBIOS Entry Point Structure
807 (VOID
*)(UINTN
) mReserveSmbiosEntryPoint
,
809 EntryPointStructure
->EntryPointLength
813 // Copy SMBIOS Structure Table into EfiReservedMemoryType memory
816 (VOID
*)(UINTN
) mStructureTableAddress
,
817 (VOID
*)(UINTN
) EntryPointStructure
->TableAddress
,
818 EntryPointStructure
->TableLength
822 // Update TableAddress in Entry Point Structure
824 EntryPointStructure
= (SMBIOS_TABLE_ENTRY_POINT
*)(UINTN
) mReserveSmbiosEntryPoint
;
825 EntryPointStructure
->TableAddress
= (UINT32
)(UINTN
) mStructureTableAddress
;
828 // Fixup checksums in the Entry Point Structure
830 EntryPointStructure
->IntermediateChecksum
= 0;
831 EntryPointStructure
->EntryPointStructureChecksum
= 0;
833 EntryPointStructure
->IntermediateChecksum
=
835 (UINT8
*) EntryPointStructure
+ OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT
, IntermediateAnchorString
),
836 EntryPointStructure
->EntryPointLength
- OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT
, IntermediateAnchorString
)
838 EntryPointStructure
->EntryPointStructureChecksum
=
839 CalculateCheckSum8 ((UINT8
*) EntryPointStructure
, EntryPointStructure
->EntryPointLength
);
843 Assign drive number to legacy HDD drives prior to booting an EFI
844 aware OS so the OS can access drives without an EFI driver.
845 Note: BBS compliant drives ARE NOT available until this call by
848 @param This Protocol instance pointer.
850 @retval EFI_SUCCESS Drive numbers assigned
855 IN EFI_LEGACY_BIOS_PROTOCOL
*This
859 LEGACY_BIOS_INSTANCE
*Private
;
860 EFI_IA32_REGISTER_SET Regs
;
861 EFI_TO_COMPATIBILITY16_BOOT_TABLE
*EfiToLegacy16BootTable
;
862 EFI_LEGACY_BIOS_PLATFORM_PROTOCOL
*LegacyBiosPlatform
;
866 HDD_INFO
*LocalHddInfo
;
868 EFI_COMPATIBILITY16_TABLE
*Legacy16Table
;
872 BBS_TABLE
*LocalBbsTable
;
873 UINT32
*BaseVectorMaster
;
876 EFI_HANDLE IdeController
;
878 EFI_HANDLE
*HandleBuffer
;
886 LocalBbsTable
= NULL
;
888 Private
= LEGACY_BIOS_INSTANCE_FROM_THIS (This
);
890 DEBUG ((EFI_D_ERROR
, "Start of legacy boot\n"));
893 Legacy16Table
= Private
->Legacy16Table
;
894 EfiToLegacy16BootTable
= &Private
->IntThunk
->EfiToLegacy16BootTable
;
895 HddInfo
= &EfiToLegacy16BootTable
->HddInfo
[0];
897 LegacyBiosPlatform
= Private
->LegacyBiosPlatform
;
899 EfiToLegacy16BootTable
->MajorVersion
= EFI_TO_LEGACY_MAJOR_VERSION
;
900 EfiToLegacy16BootTable
->MinorVersion
= EFI_TO_LEGACY_MINOR_VERSION
;
903 // If booting to a legacy OS then force HDD drives to the appropriate
904 // boot mode by calling GetIdeHandle.
905 // A reconnect -r can force all HDDs back to native mode.
907 IdeController
= NULL
;
908 if ((mBootMode
== BOOT_LEGACY_OS
) || (mBootMode
== BOOT_UNCONVENTIONAL_DEVICE
)) {
909 Status
= LegacyBiosPlatform
->GetPlatformHandle (
910 Private
->LegacyBiosPlatform
,
911 EfiGetPlatformIdeHandle
,
917 if (!EFI_ERROR (Status
)) {
918 IdeController
= HandleBuffer
[0];
922 // Unlock the Legacy BIOS region
924 Private
->LegacyRegion
->UnLock (
925 Private
->LegacyRegion
,
932 // Reconstruct the Legacy16 boot memory map
934 LegacyBiosBuildE820 (Private
, &CopySize
);
935 if (CopySize
> Private
->Legacy16Table
->E820Length
) {
936 ZeroMem (&Regs
, sizeof (EFI_IA32_REGISTER_SET
));
937 Regs
.X
.AX
= Legacy16GetTableAddress
;
938 Regs
.X
.CX
= (UINT16
) CopySize
;
939 Private
->LegacyBios
.FarCall86 (
940 &Private
->LegacyBios
,
941 Private
->Legacy16Table
->Compatibility16CallSegment
,
942 Private
->Legacy16Table
->Compatibility16CallOffset
,
948 Private
->Legacy16Table
->E820Pointer
= (UINT32
) (Regs
.X
.DS
* 16 + Regs
.X
.BX
);
949 Private
->Legacy16Table
->E820Length
= (UINT32
) CopySize
;
950 if (Regs
.X
.AX
!= 0) {
951 DEBUG ((EFI_D_ERROR
, "Legacy16 E820 length insufficient\n"));
954 (VOID
*)(UINTN
) Private
->Legacy16Table
->E820Pointer
,
961 (VOID
*)(UINTN
) Private
->Legacy16Table
->E820Pointer
,
965 Private
->Legacy16Table
->E820Length
= (UINT32
) CopySize
;
969 // We do not ASSERT if SmbiosTable not found. It is possbile that a platform does not produce SmbiosTable.
971 if (mReserveSmbiosEntryPoint
== 0) {
972 DEBUG ((EFI_D_INFO
, "Smbios table is not found!\n"));
974 CreateSmbiosTableInReservedMemory ();
975 EfiToLegacy16BootTable
->SmbiosTable
= (UINT32
)(UINTN
)mReserveSmbiosEntryPoint
;
978 Status
= EfiGetSystemConfigurationTable (
979 &gEfiAcpi20TableGuid
,
982 if (EFI_ERROR (Status
)) {
983 Status
= EfiGetSystemConfigurationTable (
984 &gEfiAcpi10TableGuid
,
989 // We do not ASSERT if AcpiTable not found. It is possbile that a platform does not produce AcpiTable.
991 if (AcpiTable
== NULL
) {
992 DEBUG ((EFI_D_INFO
, "ACPI table is not found!\n"));
994 EfiToLegacy16BootTable
->AcpiTable
= (UINT32
)(UINTN
)AcpiTable
;
997 // Get RSD Ptr table rev at offset 15 decimal
998 // Rev = 0 Length is 20 decimal
999 // Rev != 0 Length is UINT32 at offset 20 decimal
1001 if (AcpiTable
!= NULL
) {
1003 AcpiPtr
= AcpiTable
;
1004 if (*((UINT8
*) AcpiPtr
+ 15) == 0) {
1007 AcpiPtr
= ((UINT8
*) AcpiPtr
+ 20);
1008 CopySize
= (*(UINT32
*) AcpiPtr
);
1012 (VOID
*)(UINTN
) Private
->Legacy16Table
->AcpiRsdPtrPointer
,
1018 // Make sure all PCI Interrupt Line register are programmed to match 8259
1020 PciProgramAllInterruptLineRegisters (Private
);
1023 // Unlock the Legacy BIOS region as PciProgramAllInterruptLineRegisters
1026 Private
->LegacyRegion
->UnLock (
1027 Private
->LegacyRegion
,
1029 Private
->LegacyBiosImageSize
,
1034 // Configure Legacy Device Magic
1036 // Only do this code if booting legacy OS
1038 if ((mBootMode
== BOOT_LEGACY_OS
) || (mBootMode
== BOOT_UNCONVENTIONAL_DEVICE
)) {
1039 UpdateSioData (Private
);
1042 // Setup BDA and EBDA standard areas before Legacy Boot
1045 LegacyBiosCompleteBdaBeforeBoot (Private
);
1047 LegacyBiosCompleteStandardCmosBeforeBoot (Private
);
1050 // We must build IDE data, if it hasn't been done, before PciShadowRoms
1051 // to insure EFI drivers are connected.
1053 LegacyBiosBuildIdeData (Private
, &HddInfo
, 1);
1054 UpdateAllIdentifyDriveData (Private
);
1057 // Clear IO BAR, if IDE controller in legacy mode.
1059 InitLegacyIdeController (IdeController
);
1062 // Generate number of ticks since midnight for BDA. DOS requires this
1063 // for its time. We have to make assumptions as to how long following
1064 // code takes since after PciShadowRoms PciIo is gone. Place result in
1067 // Adjust value by 1 second.
1069 gRT
->GetTime (&BootTime
, NULL
);
1070 LocalTime
= BootTime
.Hour
* 3600 + BootTime
.Minute
* 60 + BootTime
.Second
;
1074 // Multiply result by 18.2 for number of ticks since midnight.
1075 // Use 182/10 to avoid floating point math.
1077 LocalTime
= (LocalTime
* 182) / 10;
1079 BdaPtr
= (UINT32
*) (UINTN
)0x46C;
1080 *BdaPtr
= LocalTime
;
1084 // Shadow PCI ROMs. We must do this near the end since this will kick
1085 // of Native EFI drivers that may be needed to collect info for Legacy16
1087 // WARNING: PciIo is gone after this call.
1089 PciShadowRoms (Private
);
1092 // Shadow PXE base code, BIS etc.
1094 Private
->LegacyRegion
->UnLock (Private
->LegacyRegion
, 0xc0000, 0x40000, &Granularity
);
1095 ShadowAddress
= Private
->OptionRom
;
1096 Private
->LegacyBiosPlatform
->PlatformHooks (
1097 Private
->LegacyBiosPlatform
,
1098 EfiPlatformHookShadowServiceRoms
,
1105 Private
->OptionRom
= (UINT32
)ShadowAddress
;
1107 // Register Legacy SMI Handler
1109 LegacyBiosPlatform
->SmmInit (
1111 EfiToLegacy16BootTable
1115 // Let platform code know the boot options
1117 LegacyBiosGetBbsInfo (
1126 PrintPciInterruptRegister ();
1127 PrintBbsTable (LocalBbsTable
);
1128 PrintHddInfo (LocalHddInfo
);
1131 // If drive wasn't spun up then BuildIdeData may have found new drives.
1132 // Need to update BBS boot priority.
1134 for (Index
= 0; Index
< MAX_IDE_CONTROLLER
; Index
++) {
1135 if ((LocalHddInfo
[Index
].IdentifyDrive
[0].Raw
[0] != 0) &&
1136 (LocalBbsTable
[2 * Index
+ 1].BootPriority
== BBS_IGNORE_ENTRY
)
1138 LocalBbsTable
[2 * Index
+ 1].BootPriority
= BBS_UNPRIORITIZED_ENTRY
;
1141 if ((LocalHddInfo
[Index
].IdentifyDrive
[1].Raw
[0] != 0) &&
1142 (LocalBbsTable
[2 * Index
+ 2].BootPriority
== BBS_IGNORE_ENTRY
)
1144 LocalBbsTable
[2 * Index
+ 2].BootPriority
= BBS_UNPRIORITIZED_ENTRY
;
1148 Private
->LegacyRegion
->UnLock (
1149 Private
->LegacyRegion
,
1155 LegacyBiosPlatform
->PrepareToBoot (
1161 (VOID
*) &Private
->IntThunk
->EfiToLegacy16BootTable
1165 // If no boot device return to BDS
1167 if ((mBootMode
== BOOT_LEGACY_OS
) || (mBootMode
== BOOT_UNCONVENTIONAL_DEVICE
)) {
1168 for (Index
= 0; Index
< BbsCount
; Index
++){
1169 if ((LocalBbsTable
[Index
].BootPriority
!= BBS_DO_NOT_BOOT_FROM
) &&
1170 (LocalBbsTable
[Index
].BootPriority
!= BBS_UNPRIORITIZED_ENTRY
) &&
1171 (LocalBbsTable
[Index
].BootPriority
!= BBS_IGNORE_ENTRY
)) {
1175 if (Index
== BbsCount
) {
1176 return EFI_DEVICE_ERROR
;
1180 // Let the Legacy16 code know the device path type for legacy boot
1182 EfiToLegacy16BootTable
->DevicePathType
= mBbsDevicePathPtr
->DeviceType
;
1185 // Copy MP table, if it exists.
1187 LegacyGetDataOrTable (This
, EfiGetPlatformBinaryMpTable
);
1189 if (!Private
->LegacyBootEntered
) {
1191 // Copy OEM INT Data, if it exists. Note: This code treats any data
1192 // as a bag of bits and knows nothing of the contents nor cares.
1193 // Contents are IBV specific.
1195 LegacyGetDataOrTable (This
, EfiGetPlatformBinaryOemIntData
);
1198 // Copy OEM16 Data, if it exists.Note: This code treats any data
1199 // as a bag of bits and knows nothing of the contents nor cares.
1200 // Contents are IBV specific.
1202 LegacyGetDataOrTable (This
, EfiGetPlatformBinaryOem16Data
);
1205 // Copy OEM32 Data, if it exists.Note: This code treats any data
1206 // as a bag of bits and knows nothing of the contents nor cares.
1207 // Contents are IBV specific.
1209 LegacyGetDataOrTable (This
, EfiGetPlatformBinaryOem32Data
);
1213 // Call into Legacy16 code to prepare for INT 19h
1215 ZeroMem (&Regs
, sizeof (EFI_IA32_REGISTER_SET
));
1216 Regs
.X
.AX
= Legacy16PrepareToBoot
;
1219 // Pass in handoff data
1221 Regs
.X
.ES
= NORMALIZE_EFI_SEGMENT ((UINTN
)EfiToLegacy16BootTable
);
1222 Regs
.X
.BX
= NORMALIZE_EFI_OFFSET ((UINTN
)EfiToLegacy16BootTable
);
1224 Private
->LegacyBios
.FarCall86 (
1226 Private
->Legacy16CallSegment
,
1227 Private
->Legacy16CallOffset
,
1233 if (Regs
.X
.AX
!= 0) {
1234 return EFI_DEVICE_ERROR
;
1237 // Lock the Legacy BIOS region
1239 Private
->LegacyRegion
->Lock (
1240 Private
->LegacyRegion
,
1246 if ((Private
->Legacy16Table
->TableLength
>= OFFSET_OF (EFI_COMPATIBILITY16_TABLE
, HiPermanentMemoryAddress
)) &&
1247 ((Private
->Legacy16Table
->UmaAddress
!= 0) && (Private
->Legacy16Table
->UmaSize
!= 0))) {
1249 // Here we could reduce UmaAddress down as far as Private->OptionRom, taking into
1250 // account the granularity of the access control.
1252 DEBUG((EFI_D_INFO
, "Unlocking UMB RAM region 0x%x-0x%x\n", Private
->Legacy16Table
->UmaAddress
,
1253 Private
->Legacy16Table
->UmaAddress
+ Private
->Legacy16Table
->UmaSize
));
1255 Private
->LegacyRegion
->UnLock (
1256 Private
->LegacyRegion
,
1257 Private
->Legacy16Table
->UmaAddress
,
1258 Private
->Legacy16Table
->UmaSize
,
1264 // Lock attributes of the Legacy Region if chipset supports
1266 Private
->LegacyRegion
->BootLock (
1267 Private
->LegacyRegion
,
1274 // Call into Legacy16 code to do the INT 19h
1276 EnableAllControllers (Private
);
1277 if ((mBootMode
== BOOT_LEGACY_OS
) || (mBootMode
== BOOT_UNCONVENTIONAL_DEVICE
)) {
1280 // Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT
1282 EfiSignalEventLegacyBoot ();
1285 // Report Status Code to indicate legacy boot event was signalled
1287 REPORT_STATUS_CODE (
1289 (EFI_SOFTWARE_DXE_BS_DRIVER
| EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT
)
1292 DEBUG ((EFI_D_INFO
, "Legacy INT19 Boot...\n"));
1295 // Disable DXE Timer while executing in real mode
1297 Private
->Timer
->SetTimerPeriod (Private
->Timer
, 0);
1300 // Save and disable interrupt of debug timer
1302 SaveAndSetDebugTimerInterrupt (FALSE
);
1306 // Put the 8259 into its legacy mode by reprogramming the vector bases
1308 Private
->Legacy8259
->SetVectorBase (Private
->Legacy8259
, LEGACY_MODE_BASE_VECTOR_MASTER
, LEGACY_MODE_BASE_VECTOR_SLAVE
);
1311 // The original PC used INT8-F for master PIC. Since these mapped over
1312 // processor exceptions TIANO moved the master PIC to INT68-6F.
1313 // We need to set these back to the Legacy16 unexpected interrupt(saved
1314 // in LegacyBios.c) since some OS see that these have values different from
1315 // what is expected and invoke them. Since the legacy OS corrupts EFI
1316 // memory, there is no handler for these interrupts and OS blows up.
1318 // We need to save the TIANO values for the rare case that the Legacy16
1319 // code cannot boot but knows memory hasn't been destroyed.
1321 // To compound the problem, video takes over one of these INTS and must be
1323 // @bug - determine if video hooks INT(in which case we must find new
1324 // set of TIANO vectors) or takes it over.
1328 BaseVectorMaster
= (UINT32
*) (sizeof (UINT32
) * PROTECTED_MODE_BASE_VECTOR_MASTER
);
1329 for (Index
= 0; Index
< 8; Index
++) {
1330 Private
->ThunkSavedInt
[Index
] = BaseVectorMaster
[Index
];
1331 if (Private
->ThunkSeg
== (UINT16
) (BaseVectorMaster
[Index
] >> 16)) {
1332 BaseVectorMaster
[Index
] = (UINT32
) (Private
->BiosUnexpectedInt
);
1337 ZeroMem (&Regs
, sizeof (EFI_IA32_REGISTER_SET
));
1338 Regs
.X
.AX
= Legacy16Boot
;
1340 Private
->LegacyBios
.FarCall86 (
1342 Private
->Legacy16CallSegment
,
1343 Private
->Legacy16CallOffset
,
1350 BaseVectorMaster
= (UINT32
*) (sizeof (UINT32
) * PROTECTED_MODE_BASE_VECTOR_MASTER
);
1351 for (Index
= 0; Index
< 8; Index
++) {
1352 BaseVectorMaster
[Index
] = Private
->ThunkSavedInt
[Index
];
1356 Private
->LegacyBootEntered
= TRUE
;
1357 if ((mBootMode
== BOOT_LEGACY_OS
) || (mBootMode
== BOOT_UNCONVENTIONAL_DEVICE
)) {
1359 // Should never return unless never passed control to 0:7c00(first stage
1360 // OS loader) and only then if no bootable device found.
1362 return EFI_DEVICE_ERROR
;
1365 // If boot to EFI then expect to return to caller
1373 Assign drive number to legacy HDD drives prior to booting an EFI
1374 aware OS so the OS can access drives without an EFI driver.
1375 Note: BBS compliant drives ARE NOT available until this call by
1376 either shell or EFI.
1378 @param This Protocol instance pointer.
1379 @param BbsCount Number of BBS_TABLE structures
1380 @param BbsTable List BBS entries
1382 @retval EFI_SUCCESS Drive numbers assigned
1387 LegacyBiosPrepareToBootEfi (
1388 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1389 OUT UINT16
*BbsCount
,
1390 OUT BBS_TABLE
**BbsTable
1394 EFI_TO_COMPATIBILITY16_BOOT_TABLE
*EfiToLegacy16BootTable
;
1395 LEGACY_BIOS_INSTANCE
*Private
;
1397 Private
= LEGACY_BIOS_INSTANCE_FROM_THIS (This
);
1398 EfiToLegacy16BootTable
= &Private
->IntThunk
->EfiToLegacy16BootTable
;
1399 mBootMode
= BOOT_EFI_OS
;
1400 mBbsDevicePathPtr
= NULL
;
1401 Status
= GenericLegacyBoot (This
);
1402 *BbsTable
= (BBS_TABLE
*)(UINTN
)EfiToLegacy16BootTable
->BbsTable
;
1403 *BbsCount
= (UINT16
) (sizeof (Private
->IntThunk
->BbsTable
) / sizeof (BBS_TABLE
));
1408 To boot from an unconventional device like parties and/or execute HDD diagnostics.
1410 @param This Protocol instance pointer.
1411 @param Attributes How to interpret the other input parameters
1412 @param BbsEntry The 0-based index into the BbsTable for the parent
1414 @param BeerData Pointer to the 128 bytes of ram BEER data.
1415 @param ServiceAreaData Pointer to the 64 bytes of raw Service Area data. The
1416 caller must provide a pointer to the specific Service
1417 Area and not the start all Service Areas.
1419 @retval EFI_INVALID_PARAMETER if error. Does NOT return if no error.
1424 LegacyBiosBootUnconventionalDevice (
1425 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1426 IN UDC_ATTRIBUTES Attributes
,
1429 IN VOID
*ServiceAreaData
1433 EFI_TO_COMPATIBILITY16_BOOT_TABLE
*EfiToLegacy16BootTable
;
1434 LEGACY_BIOS_INSTANCE
*Private
;
1437 UINT16 BootPriority
;
1438 BBS_TABLE
*BbsTable
;
1441 Private
= LEGACY_BIOS_INSTANCE_FROM_THIS (This
);
1442 mBootMode
= BOOT_UNCONVENTIONAL_DEVICE
;
1443 mBbsDevicePathPtr
= &mBbsDevicePathNode
;
1444 mAttributes
= Attributes
;
1445 mBbsEntry
= BbsEntry
;
1446 mBeerData
= BeerData
, mServiceAreaData
= ServiceAreaData
;
1448 EfiToLegacy16BootTable
= &Private
->IntThunk
->EfiToLegacy16BootTable
;
1451 // Do input parameter checking
1453 if ((Attributes
.DirectoryServiceValidity
== 0) &&
1454 (Attributes
.RabcaUsedFlag
== 0) &&
1455 (Attributes
.ExecuteHddDiagnosticsFlag
== 0)
1457 return EFI_INVALID_PARAMETER
;
1460 if (((Attributes
.DirectoryServiceValidity
!= 0) && (ServiceAreaData
== NULL
)) ||
1461 (((Attributes
.DirectoryServiceValidity
| Attributes
.RabcaUsedFlag
) != 0) && (BeerData
== NULL
))
1463 return EFI_INVALID_PARAMETER
;
1466 UcdTable
= (UD_TABLE
*) AllocatePool (
1469 if (NULL
== UcdTable
) {
1470 return EFI_OUT_OF_RESOURCES
;
1473 EfiToLegacy16BootTable
->UnconventionalDeviceTable
= (UINT32
)(UINTN
)UcdTable
;
1474 UcdTable
->Attributes
= Attributes
;
1475 UcdTable
->BbsTableEntryNumberForParentDevice
= (UINT8
) BbsEntry
;
1477 // Force all existing BBS entries to DoNotBoot. This allows 16-bit CSM
1478 // to assign drive numbers but bot boot from. Only newly created entries
1481 BbsTable
= (BBS_TABLE
*)(UINTN
)EfiToLegacy16BootTable
->BbsTable
;
1482 for (Index
= 0; Index
< EfiToLegacy16BootTable
->NumberBbsEntries
; Index
++) {
1483 BbsTable
[Index
].BootPriority
= BBS_DO_NOT_BOOT_FROM
;
1486 // If parent is onboard IDE then assign controller & device number
1489 if (BbsEntry
< MAX_IDE_CONTROLLER
* 2) {
1490 UcdTable
->DeviceNumber
= (UINT8
) ((BbsEntry
- 1) % 2);
1493 if (BeerData
!= NULL
) {
1495 (VOID
*) UcdTable
->BeerData
,
1501 if (ServiceAreaData
!= NULL
) {
1503 (VOID
*) UcdTable
->ServiceAreaData
,
1509 // For each new entry do the following:
1510 // 1. Increment current number of BBS entries
1511 // 2. Copy parent entry to new entry.
1512 // 3. Zero out BootHandler Offset & segment
1513 // 4. Set appropriate device type. BEV(0x80) for HDD diagnostics
1514 // and Floppy(0x01) for PARTIES boot.
1515 // 5. Assign new priority.
1517 if ((Attributes
.ExecuteHddDiagnosticsFlag
) != 0) {
1518 EfiToLegacy16BootTable
->NumberBbsEntries
+= 1;
1521 (VOID
*) &BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootPriority
,
1522 (VOID
*) &BbsTable
[BbsEntry
].BootPriority
,
1526 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootHandlerOffset
= 0;
1527 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootHandlerSegment
= 0;
1528 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].DeviceType
= 0x80;
1530 UcdTable
->BbsTableEntryNumberForHddDiag
= (UINT8
) (EfiToLegacy16BootTable
->NumberBbsEntries
- 1);
1532 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootPriority
= BootPriority
;
1536 // Set device type as BBS_TYPE_DEV for PARTIES diagnostic
1538 mBbsDevicePathNode
.DeviceType
= BBS_TYPE_BEV
;
1541 if (((Attributes
.DirectoryServiceValidity
| Attributes
.RabcaUsedFlag
)) != 0) {
1542 EfiToLegacy16BootTable
->NumberBbsEntries
+= 1;
1544 (VOID
*) &BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootPriority
,
1545 (VOID
*) &BbsTable
[BbsEntry
].BootPriority
,
1549 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootHandlerOffset
= 0;
1550 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootHandlerSegment
= 0;
1551 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].DeviceType
= 0x01;
1552 UcdTable
->BbsTableEntryNumberForBoot
= (UINT8
) (EfiToLegacy16BootTable
->NumberBbsEntries
- 1);
1553 BbsTable
[EfiToLegacy16BootTable
->NumberBbsEntries
].BootPriority
= BootPriority
;
1556 // Set device type as BBS_TYPE_FLOPPY for PARTIES boot as floppy
1558 mBbsDevicePathNode
.DeviceType
= BBS_TYPE_FLOPPY
;
1561 // Build the BBS Device Path for this boot selection
1563 mBbsDevicePathNode
.Header
.Type
= BBS_DEVICE_PATH
;
1564 mBbsDevicePathNode
.Header
.SubType
= BBS_BBS_DP
;
1565 SetDevicePathNodeLength (&mBbsDevicePathNode
.Header
, sizeof (BBS_BBS_DEVICE_PATH
));
1566 mBbsDevicePathNode
.StatusFlag
= 0;
1567 mBbsDevicePathNode
.String
[0] = 0;
1569 Status
= GenericLegacyBoot (This
);
1574 Attempt to legacy boot the BootOption. If the EFI contexted has been
1575 compromised this function will not return.
1577 @param This Protocol instance pointer.
1578 @param BbsDevicePath EFI Device Path from BootXXXX variable.
1579 @param LoadOptionsSize Size of LoadOption in size.
1580 @param LoadOptions LoadOption from BootXXXX variable
1582 @retval EFI_SUCCESS Removable media not present
1587 LegacyBiosLegacyBoot (
1588 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
1589 IN BBS_BBS_DEVICE_PATH
*BbsDevicePath
,
1590 IN UINT32 LoadOptionsSize
,
1591 IN VOID
*LoadOptions
1596 mBbsDevicePathPtr
= BbsDevicePath
;
1597 mLoadOptionsSize
= LoadOptionsSize
;
1598 mLoadOptions
= LoadOptions
;
1599 mBootMode
= BOOT_LEGACY_OS
;
1600 Status
= GenericLegacyBoot (This
);
1606 Convert EFI Memory Type to E820 Memory Type.
1608 @param Type EFI Memory Type
1610 @return ACPI Memory Type for EFI Memory Type
1613 EFI_ACPI_MEMORY_TYPE
1614 EfiMemoryTypeToE820Type (
1621 case EfiBootServicesCode
:
1622 case EfiBootServicesData
:
1623 case EfiConventionalMemory
:
1625 // The memory of EfiRuntimeServicesCode and EfiRuntimeServicesData are
1626 // usable memory for legacy OS, because legacy OS is not aware of EFI runtime concept.
1627 // In ACPI specification, EfiRuntimeServiceCode and EfiRuntimeServiceData
1628 // should be mapped to AddressRangeReserved. This statement is for UEFI OS, not for legacy OS.
1630 case EfiRuntimeServicesCode
:
1631 case EfiRuntimeServicesData
:
1632 return EfiAcpiAddressRangeMemory
;
1634 case EfiPersistentMemory
:
1635 return EfiAddressRangePersistentMemory
;
1637 case EfiACPIReclaimMemory
:
1638 return EfiAcpiAddressRangeACPI
;
1640 case EfiACPIMemoryNVS
:
1641 return EfiAcpiAddressRangeNVS
;
1644 // All other types map to reserved.
1645 // Adding the code just waists FLASH space.
1647 // case EfiReservedMemoryType:
1648 // case EfiUnusableMemory:
1649 // case EfiMemoryMappedIO:
1650 // case EfiMemoryMappedIOPortSpace:
1654 return EfiAcpiAddressRangeReserved
;
1659 Build the E820 table.
1661 @param Private Legacy BIOS Instance data
1662 @param Size Size of E820 Table
1664 @retval EFI_SUCCESS It should always work.
1668 LegacyBiosBuildE820 (
1669 IN LEGACY_BIOS_INSTANCE
*Private
,
1674 EFI_E820_ENTRY64
*E820Table
;
1675 EFI_MEMORY_DESCRIPTOR
*EfiMemoryMap
;
1676 EFI_MEMORY_DESCRIPTOR
*EfiMemoryMapEnd
;
1677 EFI_MEMORY_DESCRIPTOR
*EfiEntry
;
1678 EFI_MEMORY_DESCRIPTOR
*NextEfiEntry
;
1679 EFI_MEMORY_DESCRIPTOR TempEfiEntry
;
1680 UINTN EfiMemoryMapSize
;
1682 UINTN EfiDescriptorSize
;
1683 UINT32 EfiDescriptorVersion
;
1685 EFI_PEI_HOB_POINTERS Hob
;
1686 EFI_HOB_RESOURCE_DESCRIPTOR
*ResourceHob
;
1689 UINTN TempNextIndex
;
1690 EFI_E820_ENTRY64 TempE820
;
1691 EFI_ACPI_MEMORY_TYPE TempType
;
1692 BOOLEAN ChangedFlag
;
1694 UINT64 MemoryBlockLength
;
1696 E820Table
= (EFI_E820_ENTRY64
*) Private
->E820Table
;
1699 // Get the EFI memory map.
1701 EfiMemoryMapSize
= 0;
1702 EfiMemoryMap
= NULL
;
1703 Status
= gBS
->GetMemoryMap (
1708 &EfiDescriptorVersion
1710 ASSERT (Status
== EFI_BUFFER_TOO_SMALL
);
1714 // Use size returned back plus 1 descriptor for the AllocatePool.
1715 // We don't just multiply by 2 since the "for" loop below terminates on
1716 // EfiMemoryMapEnd which is dependent upon EfiMemoryMapSize. Otherwize
1717 // we process bogus entries and create bogus E820 entries.
1719 EfiMemoryMap
= (EFI_MEMORY_DESCRIPTOR
*) AllocatePool (EfiMemoryMapSize
);
1720 ASSERT (EfiMemoryMap
!= NULL
);
1721 Status
= gBS
->GetMemoryMap (
1726 &EfiDescriptorVersion
1728 if (EFI_ERROR (Status
)) {
1729 FreePool (EfiMemoryMap
);
1731 } while (Status
== EFI_BUFFER_TOO_SMALL
);
1733 ASSERT_EFI_ERROR (Status
);
1736 // Punch in the E820 table for memory less than 1 MB.
1737 // Assume ZeroMem () has been done on data structure.
1740 // First entry is 0 to (640k - EBDA)
1743 E820Table
[0].BaseAddr
= 0;
1744 E820Table
[0].Length
= (UINT64
) ((*(UINT16
*) (UINTN
)0x40E) << 4);
1745 E820Table
[0].Type
= EfiAcpiAddressRangeMemory
;
1749 // Second entry is (640k - EBDA) to 640k
1751 E820Table
[1].BaseAddr
= E820Table
[0].Length
;
1752 E820Table
[1].Length
= (UINT64
) ((640 * 1024) - E820Table
[0].Length
);
1753 E820Table
[1].Type
= EfiAcpiAddressRangeReserved
;
1756 // Third Entry is legacy BIOS
1757 // DO NOT CLAIM region from 0xA0000-0xDFFFF. OS can use free areas
1758 // to page in memory under 1MB.
1759 // Omit region from 0xE0000 to start of BIOS, if any. This can be
1760 // used for a multiple reasons including OPROMS.
1764 // The CSM binary image size is not the actually size that CSM binary used,
1765 // to avoid memory corrupt, we declare the 0E0000 - 0FFFFF is used by CSM binary.
1767 E820Table
[2].BaseAddr
= 0xE0000;
1768 E820Table
[2].Length
= 0x20000;
1769 E820Table
[2].Type
= EfiAcpiAddressRangeReserved
;
1774 // Process the EFI map to produce E820 map;
1778 // Sort memory map from low to high
1780 EfiEntry
= EfiMemoryMap
;
1781 NextEfiEntry
= NEXT_MEMORY_DESCRIPTOR (EfiEntry
, EfiDescriptorSize
);
1782 EfiMemoryMapEnd
= (EFI_MEMORY_DESCRIPTOR
*) ((UINT8
*) EfiMemoryMap
+ EfiMemoryMapSize
);
1783 while (EfiEntry
< EfiMemoryMapEnd
) {
1784 while (NextEfiEntry
< EfiMemoryMapEnd
) {
1785 if (EfiEntry
->PhysicalStart
> NextEfiEntry
->PhysicalStart
) {
1786 CopyMem (&TempEfiEntry
, EfiEntry
, sizeof (EFI_MEMORY_DESCRIPTOR
));
1787 CopyMem (EfiEntry
, NextEfiEntry
, sizeof (EFI_MEMORY_DESCRIPTOR
));
1788 CopyMem (NextEfiEntry
, &TempEfiEntry
, sizeof (EFI_MEMORY_DESCRIPTOR
));
1791 NextEfiEntry
= NEXT_MEMORY_DESCRIPTOR (NextEfiEntry
, EfiDescriptorSize
);
1794 EfiEntry
= NEXT_MEMORY_DESCRIPTOR (EfiEntry
, EfiDescriptorSize
);
1795 NextEfiEntry
= NEXT_MEMORY_DESCRIPTOR (EfiEntry
, EfiDescriptorSize
);
1798 EfiEntry
= EfiMemoryMap
;
1799 EfiMemoryMapEnd
= (EFI_MEMORY_DESCRIPTOR
*) ((UINT8
*) EfiMemoryMap
+ EfiMemoryMapSize
);
1800 for (Index
= Above1MIndex
; (EfiEntry
< EfiMemoryMapEnd
) && (Index
< EFI_MAX_E820_ENTRY
- 1); ) {
1801 MemoryBlockLength
= (UINT64
) (LShiftU64 (EfiEntry
->NumberOfPages
, 12));
1802 if ((EfiEntry
->PhysicalStart
+ MemoryBlockLength
) < 0x100000) {
1804 // Skip the memory block is under 1MB
1807 if (EfiEntry
->PhysicalStart
< 0x100000) {
1809 // When the memory block spans below 1MB, ensure the memory block start address is at least 1MB
1811 MemoryBlockLength
-= 0x100000 - EfiEntry
->PhysicalStart
;
1812 EfiEntry
->PhysicalStart
= 0x100000;
1816 // Convert memory type to E820 type
1818 TempType
= EfiMemoryTypeToE820Type (EfiEntry
->Type
);
1820 if ((E820Table
[Index
].Type
== TempType
) && (EfiEntry
->PhysicalStart
== (E820Table
[Index
].BaseAddr
+ E820Table
[Index
].Length
))) {
1822 // Grow an existing entry
1824 E820Table
[Index
].Length
+= MemoryBlockLength
;
1830 E820Table
[Index
].BaseAddr
= EfiEntry
->PhysicalStart
;
1831 E820Table
[Index
].Length
= MemoryBlockLength
;
1832 E820Table
[Index
].Type
= TempType
;
1835 EfiEntry
= NEXT_MEMORY_DESCRIPTOR (EfiEntry
, EfiDescriptorSize
);
1838 FreePool (EfiMemoryMap
);
1841 // Process the reserved memory map to produce E820 map ;
1843 for (Hob
.Raw
= GetHobList (); !END_OF_HOB_LIST (Hob
); Hob
.Raw
= GET_NEXT_HOB (Hob
)) {
1844 if (Hob
.Raw
!= NULL
&& GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
) {
1845 ResourceHob
= Hob
.ResourceDescriptor
;
1846 if (((ResourceHob
->ResourceType
== EFI_RESOURCE_MEMORY_MAPPED_IO
) ||
1847 (ResourceHob
->ResourceType
== EFI_RESOURCE_FIRMWARE_DEVICE
) ||
1848 (ResourceHob
->ResourceType
== EFI_RESOURCE_MEMORY_RESERVED
) ) &&
1849 (ResourceHob
->PhysicalStart
> 0x100000) &&
1850 (Index
< EFI_MAX_E820_ENTRY
- 1)) {
1852 E820Table
[Index
].BaseAddr
= ResourceHob
->PhysicalStart
;
1853 E820Table
[Index
].Length
= ResourceHob
->ResourceLength
;
1854 E820Table
[Index
].Type
= EfiAcpiAddressRangeReserved
;
1860 Private
->IntThunk
->EfiToLegacy16InitTable
.NumberE820Entries
= (UINT32
)Index
;
1861 Private
->IntThunk
->EfiToLegacy16BootTable
.NumberE820Entries
= (UINT32
)Index
;
1862 Private
->NumberE820Entries
= (UINT32
)Index
;
1863 *Size
= (UINTN
) (Index
* sizeof (EFI_E820_ENTRY64
));
1866 // Sort E820Table from low to high
1868 for (TempIndex
= 0; TempIndex
< Index
; TempIndex
++) {
1869 ChangedFlag
= FALSE
;
1870 for (TempNextIndex
= 1; TempNextIndex
< Index
- TempIndex
; TempNextIndex
++) {
1871 if (E820Table
[TempNextIndex
- 1].BaseAddr
> E820Table
[TempNextIndex
].BaseAddr
) {
1873 TempE820
.BaseAddr
= E820Table
[TempNextIndex
- 1].BaseAddr
;
1874 TempE820
.Length
= E820Table
[TempNextIndex
- 1].Length
;
1875 TempE820
.Type
= E820Table
[TempNextIndex
- 1].Type
;
1877 E820Table
[TempNextIndex
- 1].BaseAddr
= E820Table
[TempNextIndex
].BaseAddr
;
1878 E820Table
[TempNextIndex
- 1].Length
= E820Table
[TempNextIndex
].Length
;
1879 E820Table
[TempNextIndex
- 1].Type
= E820Table
[TempNextIndex
].Type
;
1881 E820Table
[TempNextIndex
].BaseAddr
= TempE820
.BaseAddr
;
1882 E820Table
[TempNextIndex
].Length
= TempE820
.Length
;
1883 E820Table
[TempNextIndex
].Type
= TempE820
.Type
;
1893 // Remove the overlap range
1895 for (TempIndex
= 1; TempIndex
< Index
; TempIndex
++) {
1896 if (E820Table
[TempIndex
- 1].BaseAddr
<= E820Table
[TempIndex
].BaseAddr
&&
1897 ((E820Table
[TempIndex
- 1].BaseAddr
+ E820Table
[TempIndex
- 1].Length
) >=
1898 (E820Table
[TempIndex
].BaseAddr
+E820Table
[TempIndex
].Length
))) {
1900 //Overlap range is found
1902 ASSERT (E820Table
[TempIndex
- 1].Type
== E820Table
[TempIndex
].Type
);
1904 if (TempIndex
== Index
- 1) {
1905 E820Table
[TempIndex
].BaseAddr
= 0;
1906 E820Table
[TempIndex
].Length
= 0;
1907 E820Table
[TempIndex
].Type
= (EFI_ACPI_MEMORY_TYPE
) 0;
1911 for (IndexSort
= TempIndex
; IndexSort
< Index
- 1; IndexSort
++) {
1912 E820Table
[IndexSort
].BaseAddr
= E820Table
[IndexSort
+ 1].BaseAddr
;
1913 E820Table
[IndexSort
].Length
= E820Table
[IndexSort
+ 1].Length
;
1914 E820Table
[IndexSort
].Type
= E820Table
[IndexSort
+ 1].Type
;
1923 Private
->IntThunk
->EfiToLegacy16InitTable
.NumberE820Entries
= (UINT32
)Index
;
1924 Private
->IntThunk
->EfiToLegacy16BootTable
.NumberE820Entries
= (UINT32
)Index
;
1925 Private
->NumberE820Entries
= (UINT32
)Index
;
1926 *Size
= (UINTN
) (Index
* sizeof (EFI_E820_ENTRY64
));
1929 // Determine OS usable memory above 1Mb
1931 Private
->IntThunk
->EfiToLegacy16BootTable
.OsMemoryAbove1Mb
= 0x0000;
1932 for (TempIndex
= Above1MIndex
; TempIndex
< Index
; TempIndex
++) {
1933 if (E820Table
[TempIndex
].BaseAddr
>= 0x100000 && E820Table
[TempIndex
].BaseAddr
< 0x100000000ULL
) { // not include above 4G memory
1935 // ACPIReclaimMemory is also usable memory for ACPI OS, after OS dumps all ACPI tables.
1937 if ((E820Table
[TempIndex
].Type
== EfiAcpiAddressRangeMemory
) || (E820Table
[TempIndex
].Type
== EfiAcpiAddressRangeACPI
)) {
1938 Private
->IntThunk
->EfiToLegacy16BootTable
.OsMemoryAbove1Mb
+= (UINT32
) (E820Table
[TempIndex
].Length
);
1940 break; // break at first not normal memory, because SMM may use reserved memory.
1945 Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
= Private
->IntThunk
->EfiToLegacy16BootTable
.OsMemoryAbove1Mb
;
1948 // Print DEBUG information
1950 for (TempIndex
= 0; TempIndex
< Index
; TempIndex
++) {
1951 DEBUG((EFI_D_INFO
, "E820[%2d]: 0x%16lx ---- 0x%16lx, Type = 0x%x \n",
1953 E820Table
[TempIndex
].BaseAddr
,
1954 (E820Table
[TempIndex
].BaseAddr
+ E820Table
[TempIndex
].Length
),
1955 E820Table
[TempIndex
].Type
1964 Fill in the standard BDA and EBDA stuff prior to legacy Boot
1966 @param Private Legacy BIOS Instance data
1968 @retval EFI_SUCCESS It should always work.
1972 LegacyBiosCompleteBdaBeforeBoot (
1973 IN LEGACY_BIOS_INSTANCE
*Private
1977 UINT16 MachineConfig
;
1978 DEVICE_PRODUCER_DATA_HEADER
*SioPtr
;
1980 Bda
= (BDA_STRUC
*) ((UINTN
) 0x400);
1983 SioPtr
= &(Private
->IntThunk
->EfiToLegacy16BootTable
.SioData
);
1984 Bda
->Com1
= SioPtr
->Serial
[0].Address
;
1985 Bda
->Com2
= SioPtr
->Serial
[1].Address
;
1986 Bda
->Com3
= SioPtr
->Serial
[2].Address
;
1987 Bda
->Com4
= SioPtr
->Serial
[3].Address
;
1989 if (SioPtr
->Serial
[0].Address
!= 0x00) {
1990 MachineConfig
+= 0x200;
1993 if (SioPtr
->Serial
[1].Address
!= 0x00) {
1994 MachineConfig
+= 0x200;
1997 if (SioPtr
->Serial
[2].Address
!= 0x00) {
1998 MachineConfig
+= 0x200;
2001 if (SioPtr
->Serial
[3].Address
!= 0x00) {
2002 MachineConfig
+= 0x200;
2005 Bda
->Lpt1
= SioPtr
->Parallel
[0].Address
;
2006 Bda
->Lpt2
= SioPtr
->Parallel
[1].Address
;
2007 Bda
->Lpt3
= SioPtr
->Parallel
[2].Address
;
2009 if (SioPtr
->Parallel
[0].Address
!= 0x00) {
2010 MachineConfig
+= 0x4000;
2013 if (SioPtr
->Parallel
[1].Address
!= 0x00) {
2014 MachineConfig
+= 0x4000;
2017 if (SioPtr
->Parallel
[2].Address
!= 0x00) {
2018 MachineConfig
+= 0x4000;
2021 Bda
->NumberOfDrives
= (UINT8
) (Bda
->NumberOfDrives
+ Private
->IdeDriveCount
);
2022 if (SioPtr
->Floppy
.NumberOfFloppy
!= 0x00) {
2023 MachineConfig
= (UINT16
) (MachineConfig
+ 0x01 + (SioPtr
->Floppy
.NumberOfFloppy
- 1) * 0x40);
2024 Bda
->FloppyXRate
= 0x07;
2027 Bda
->Lpt1_2Timeout
= 0x1414;
2028 Bda
->Lpt3_4Timeout
= 0x1414;
2029 Bda
->Com1_2Timeout
= 0x0101;
2030 Bda
->Com3_4Timeout
= 0x0101;
2033 // Force VGA and Coprocessor, indicate 101/102 keyboard
2035 MachineConfig
= (UINT16
) (MachineConfig
+ 0x00 + 0x02 + (SioPtr
->MousePresent
* 0x04));
2036 Bda
->MachineConfig
= MachineConfig
;
2042 Fill in the standard BDA for Keyboard LEDs
2044 @param This Protocol instance pointer.
2045 @param Leds Current LED status
2047 @retval EFI_SUCCESS It should always work.
2052 LegacyBiosUpdateKeyboardLedStatus (
2053 IN EFI_LEGACY_BIOS_PROTOCOL
*This
,
2057 LEGACY_BIOS_INSTANCE
*Private
;
2060 EFI_IA32_REGISTER_SET Regs
;
2062 Private
= LEGACY_BIOS_INSTANCE_FROM_THIS (This
);
2065 Bda
= (BDA_STRUC
*) ((UINTN
) 0x400);
2067 Bda
->LedStatus
= (UINT8
) ((Bda
->LedStatus
&~0x07) | LocalLeds
);
2068 LocalLeds
= (UINT8
) (LocalLeds
<< 4);
2069 Bda
->ShiftStatus
= (UINT8
) ((Bda
->ShiftStatus
&~0x70) | LocalLeds
);
2070 LocalLeds
= (UINT8
) (Leds
& 0x20);
2071 Bda
->KeyboardStatus
= (UINT8
) ((Bda
->KeyboardStatus
&~0x20) | LocalLeds
);
2075 // Call into Legacy16 code to allow it to do any processing
2077 ZeroMem (&Regs
, sizeof (EFI_IA32_REGISTER_SET
));
2078 Regs
.X
.AX
= Legacy16SetKeyboardLeds
;
2081 Private
->LegacyBios
.FarCall86 (
2082 &Private
->LegacyBios
,
2083 Private
->Legacy16Table
->Compatibility16CallSegment
,
2084 Private
->Legacy16Table
->Compatibility16CallOffset
,
2095 Fill in the standard CMOS stuff prior to legacy Boot
2097 @param Private Legacy BIOS Instance data
2099 @retval EFI_SUCCESS It should always work.
2103 LegacyBiosCompleteStandardCmosBeforeBoot (
2104 IN LEGACY_BIOS_INSTANCE
*Private
2112 // Update CMOS locations
2114 // 12,19,1A - ignore as OS don't use them and there is no standard due
2115 // to large capacity drives
2116 // CMOS 14 = BDA 40:10 plus bit 3(display enabled)
2119 Bda
= (UINT8
)(*((UINT8
*)((UINTN
)0x410)) | BIT3
);
2123 // Force display enabled
2126 if ((Bda
& BIT0
) != 0) {
2131 // Check if 2.88MB floppy set
2133 if ((Bda
& (BIT7
| BIT6
)) != 0) {
2134 Floppy
= (UINT8
)(Floppy
| BIT1
);
2137 LegacyWriteStandardCmos (CMOS_10
, Floppy
);
2138 LegacyWriteStandardCmos (CMOS_14
, Bda
);
2141 // Force Status Register A to set rate selection bits and divider
2143 LegacyWriteStandardCmos (CMOS_0A
, 0x26);
2146 // redo memory size since it can change
2148 Size
= (15 * SIZE_1MB
) >> 10;
2149 if (Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
< (15 * SIZE_1MB
)) {
2150 Size
= Private
->IntThunk
->EfiToLegacy16InitTable
.OsMemoryAbove1Mb
>> 10;
2153 LegacyWriteStandardCmos (CMOS_17
, (UINT8
)(Size
& 0xFF));
2154 LegacyWriteStandardCmos (CMOS_30
, (UINT8
)(Size
& 0xFF));
2155 LegacyWriteStandardCmos (CMOS_18
, (UINT8
)(Size
>> 8));
2156 LegacyWriteStandardCmos (CMOS_31
, (UINT8
)(Size
>> 8));
2158 LegacyCalculateWriteStandardCmosChecksum ();
2164 Relocate this image under 4G memory for IPF.
2166 @param ImageHandle Handle of driver image.
2167 @param SystemTable Pointer to system table.
2169 @retval EFI_SUCCESS Image successfully relocated.
2170 @retval EFI_ABORTED Failed to relocate image.
2174 RelocateImageUnder4GIfNeeded (
2175 IN EFI_HANDLE ImageHandle
,
2176 IN EFI_SYSTEM_TABLE
*SystemTable