OvmfPkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the OvmfPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Andrew Fish <afish@apple.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:09 -08:00
committed by mergify[bot]
parent d1050b9dff
commit ac0a286f4d
445 changed files with 30894 additions and 26369 deletions

View File

@ -47,6 +47,7 @@ volatile UINT64 mTimerPeriod = 0;
// //
// Worker Functions // Worker Functions
// //
/** /**
Sets the counter value for Timer #0 in a legacy 8254 timer. Sets the counter value for Timer #0 in a legacy 8254 timer.
@ -133,11 +134,11 @@ TimerDriverRegisterHandler (
// //
// Check for invalid parameters // Check for invalid parameters
// //
if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) { if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) { if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
@ -203,7 +204,6 @@ TimerDriverSetTimerPeriod (
// //
mLegacy8259->DisableIrq (mLegacy8259, Efi8259Irq0); mLegacy8259->DisableIrq (mLegacy8259, Efi8259Irq0);
} else { } else {
// //
// Convert TimerPeriod into 8254 counts // Convert TimerPeriod into 8254 counts
// //
@ -216,6 +216,7 @@ TimerDriverSetTimerPeriod (
TimerCount = 0; TimerCount = 0;
TimerPeriod = MAX_TIMER_TICK_DURATION; TimerPeriod = MAX_TIMER_TICK_DURATION;
} }
// //
// Program the 8254 timer with the new count value // Program the 8254 timer with the new count value
// //
@ -226,6 +227,7 @@ TimerDriverSetTimerPeriod (
// //
mLegacy8259->EnableIrq (mLegacy8259, Efi8259Irq0, FALSE); mLegacy8259->EnableIrq (mLegacy8259, Efi8259Irq0, FALSE);
} }
// //
// Save the new timer period // Save the new timer period
// //
@ -392,11 +394,11 @@ TimerDriverInitialize (
// //
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&mTimerHandle, &mTimerHandle,
&gEfiTimerArchProtocolGuid, &mTimer, &gEfiTimerArchProtocolGuid,
&mTimer,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

View File

@ -43,6 +43,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
// Function Prototypes // Function Prototypes
// //
/** /**
Initialize the Timer Architectural Protocol driver Initialize the Timer Architectural Protocol driver

View File

@ -69,4 +69,3 @@ TransferS3ContextToBootScript (
); );
#endif #endif

View File

@ -14,7 +14,6 @@
#include "AcpiPlatform.h" #include "AcpiPlatform.h"
// //
// Condensed structure for capturing the fw_cfg operations -- select, skip, // Condensed structure for capturing the fw_cfg operations -- select, skip,
// write -- inherent in executing a QEMU_LOADER_WRITE_POINTER command. // write -- inherent in executing a QEMU_LOADER_WRITE_POINTER command.
@ -27,7 +26,6 @@ typedef struct {
// and QEMU_LOADER_WRITE_POINTER.PointeeOffset // and QEMU_LOADER_WRITE_POINTER.PointeeOffset
} CONDENSED_WRITE_POINTER; } CONDENSED_WRITE_POINTER;
// //
// Context structure to accumulate CONDENSED_WRITE_POINTER objects from // Context structure to accumulate CONDENSED_WRITE_POINTER objects from
// QEMU_LOADER_WRITE_POINTER commands. // QEMU_LOADER_WRITE_POINTER commands.
@ -45,7 +43,6 @@ struct S3_CONTEXT {
// WritePointers // WritePointers
}; };
// //
// Scratch buffer, allocated in EfiReservedMemoryType type memory, for the ACPI // Scratch buffer, allocated in EfiReservedMemoryType type memory, for the ACPI
// S3 Boot Script opcodes to work on. // S3 Boot Script opcodes to work on.
@ -56,7 +53,6 @@ typedef union {
} SCRATCH_BUFFER; } SCRATCH_BUFFER;
#pragma pack () #pragma pack ()
/** /**
Allocate an S3_CONTEXT object. Allocate an S3_CONTEXT object.
@ -91,8 +87,10 @@ AllocateS3Context (
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Context->WritePointers = AllocatePool (WritePointerCount * Context->WritePointers = AllocatePool (
sizeof *Context->WritePointers); WritePointerCount *
sizeof *Context->WritePointers
);
if (Context->WritePointers == NULL) { if (Context->WritePointers == NULL) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto FreeContext; goto FreeContext;
@ -108,7 +106,6 @@ FreeContext:
return Status; return Status;
} }
/** /**
Release an S3_CONTEXT object. Release an S3_CONTEXT object.
@ -123,7 +120,6 @@ ReleaseS3Context (
FreePool (S3Context); FreePool (S3Context);
} }
/** /**
Save the information necessary to replicate a QEMU_LOADER_WRITE_POINTER Save the information necessary to replicate a QEMU_LOADER_WRITE_POINTER
command during S3 resume, in condensed format. command during S3 resume, in condensed format.
@ -170,19 +166,26 @@ SaveCondensedWritePointerToS3Context (
if (S3Context->Used == S3Context->Allocated) { if (S3Context->Used == S3Context->Allocated) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Condensed = S3Context->WritePointers + S3Context->Used; Condensed = S3Context->WritePointers + S3Context->Used;
Condensed->PointerItem = PointerItem; Condensed->PointerItem = PointerItem;
Condensed->PointerSize = PointerSize; Condensed->PointerSize = PointerSize;
Condensed->PointerOffset = PointerOffset; Condensed->PointerOffset = PointerOffset;
Condensed->PointerValue = PointerValue; Condensed->PointerValue = PointerValue;
DEBUG ((DEBUG_VERBOSE, "%a: 0x%04x/[0x%08x+%d] := 0x%Lx (%Lu)\n", DEBUG ((
__FUNCTION__, PointerItem, PointerOffset, PointerSize, PointerValue, DEBUG_VERBOSE,
(UINT64)S3Context->Used)); "%a: 0x%04x/[0x%08x+%d] := 0x%Lx (%Lu)\n",
__FUNCTION__,
PointerItem,
PointerOffset,
PointerSize,
PointerValue,
(UINT64)S3Context->Used
));
++S3Context->Used; ++S3Context->Used;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION provided to QemuFwCfgS3Lib. FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION provided to QemuFwCfgS3Lib.
**/ **/
@ -207,8 +210,10 @@ AppendFwCfgBootScript (
Condensed = &S3Context->WritePointers[Index]; Condensed = &S3Context->WritePointers[Index];
Status = QemuFwCfgS3ScriptSkipBytes (Condensed->PointerItem, Status = QemuFwCfgS3ScriptSkipBytes (
Condensed->PointerOffset); Condensed->PointerItem,
Condensed->PointerOffset
);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
goto FatalError; goto FatalError;
} }
@ -230,7 +235,6 @@ FatalError:
CpuDeadLoop (); CpuDeadLoop ();
} }
/** /**
Translate and append the information from an S3_CONTEXT object to the ACPI S3 Translate and append the information from an S3_CONTEXT object to the ACPI S3
Boot Script. Boot Script.
@ -263,7 +267,10 @@ TransferS3ContextToBootScript (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Status = QemuFwCfgS3CallWhenBootScriptReady (AppendFwCfgBootScript, Status = QemuFwCfgS3CallWhenBootScriptReady (
S3Context, sizeof (SCRATCH_BUFFER)); AppendFwCfgBootScript,
S3Context,
sizeof (SCRATCH_BUFFER)
);
return (EFI_STATUS)Status; return (EFI_STATUS)Status;
} }

View File

@ -33,7 +33,6 @@ FindAcpiTableProtocol (
return AcpiTable; return AcpiTable;
} }
STATIC STATIC
VOID VOID
EFIAPI EFIAPI
@ -44,17 +43,19 @@ OnRootBridgesConnected (
{ {
EFI_STATUS Status; EFI_STATUS Status;
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: root bridges have been connected, installing ACPI tables\n", "%a: root bridges have been connected, installing ACPI tables\n",
__FUNCTION__)); __FUNCTION__
));
Status = InstallAcpiTables (FindAcpiTableProtocol ()); Status = InstallAcpiTables (FindAcpiTableProtocol ());
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
} }
gBS->CloseEvent (Event); gBS->CloseEvent (Event);
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AcpiPlatformEntryPoint ( AcpiPlatformEntryPoint (
@ -71,8 +72,12 @@ AcpiPlatformEntryPoint (
// the full functionality. // the full functionality.
// //
if (PcdGetBool (PcdPciDisableBusEnumeration)) { if (PcdGetBool (PcdPciDisableBusEnumeration)) {
DEBUG ((DEBUG_INFO, "%a: PCI or its enumeration disabled, installing " DEBUG ((
"ACPI tables\n", __FUNCTION__)); DEBUG_INFO,
"%a: PCI or its enumeration disabled, installing "
"ACPI tables\n",
__FUNCTION__
));
return InstallAcpiTables (FindAcpiTableProtocol ()); return InstallAcpiTables (FindAcpiTableProtocol ());
} }
@ -82,13 +87,20 @@ AcpiPlatformEntryPoint (
// setup. (Note that we're a DXE_DRIVER; our entry point function is invoked // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked
// strictly before BDS is entered and can connect the root bridges.) // strictly before BDS is entered and can connect the root bridges.)
// //
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, Status = gBS->CreateEventEx (
OnRootBridgesConnected, NULL /* Context */, EVT_NOTIFY_SIGNAL,
&gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected); TPL_CALLBACK,
OnRootBridgesConnected,
NULL /* Context */,
&gRootBridgesConnectedEventGroupGuid,
&RootBridgesConnected
);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: waiting for root bridges to be connected, registered callback\n", "%a: waiting for root bridges to be connected, registered callback\n",
__FUNCTION__)); __FUNCTION__
));
} }
return Status; return Status;

View File

@ -13,7 +13,6 @@
#include "AcpiPlatform.h" #include "AcpiPlatform.h"
/** /**
Collect all PciIo protocol instances in the system. Save their original Collect all PciIo protocol instances in the system. Save their original
attributes, and enable IO and MMIO decoding for each. attributes, and enable IO and MMIO decoding for each.
@ -61,8 +60,13 @@ EnablePciDecoding (
return; return;
} }
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, Status = gBS->LocateHandleBuffer (
NULL /* SearchKey */, &NoHandles, &Handles); ByProtocol,
&gEfiPciIoProtocolGuid,
NULL /* SearchKey */,
&NoHandles,
&Handles
);
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
// //
// No PCI devices were found on either of the root bridges. We're done. // No PCI devices were found on either of the root bridges. We're done.
@ -71,15 +75,22 @@ EnablePciDecoding (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_WARN,
"%a: LocateHandleBuffer(): %r\n",
__FUNCTION__,
Status
));
return; return;
} }
OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs); OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);
if (OrigAttrs == NULL) { if (OrigAttrs == NULL) {
DEBUG ((DEBUG_WARN, "%a: AllocatePool(): out of resources\n", DEBUG ((
__FUNCTION__)); DEBUG_WARN,
"%a: AllocatePool(): out of resources\n",
__FUNCTION__
));
goto FreeHandles; goto FreeHandles;
} }
@ -90,30 +101,49 @@ EnablePciDecoding (
// //
// Look up PciIo on the handle and stash it // Look up PciIo on the handle and stash it
// //
Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid, Status = gBS->HandleProtocol (
(VOID**)&PciIo); Handles[Idx],
&gEfiPciIoProtocolGuid,
(VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
OrigAttrs[Idx].PciIo = PciIo; OrigAttrs[Idx].PciIo = PciIo;
// //
// Stash the current attributes // Stash the current attributes
// //
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0, Status = PciIo->Attributes (
&OrigAttrs[Idx].PciAttributes); PciIo,
EfiPciIoAttributeOperationGet,
0,
&OrigAttrs[Idx].PciAttributes
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationGet: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
// //
// Retrieve supported attributes // Retrieve supported attributes
// //
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0, Status = PciIo->Attributes (
&Attributes); PciIo,
EfiPciIoAttributeOperationSupported,
0,
&Attributes
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationSupported: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
@ -121,11 +151,19 @@ EnablePciDecoding (
// Enable IO and MMIO decoding // Enable IO and MMIO decoding
// //
Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY; Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, Status = PciIo->Attributes (
Attributes, NULL); PciIo,
EfiPciIoAttributeOperationEnable,
Attributes,
NULL
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationEnable: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
} }
@ -141,19 +179,20 @@ EnablePciDecoding (
RestoreAttributes: RestoreAttributes:
while (Idx > 0) { while (Idx > 0) {
--Idx; --Idx;
OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo, OrigAttrs[Idx].PciIo->Attributes (
OrigAttrs[Idx].PciIo,
EfiPciIoAttributeOperationSet, EfiPciIoAttributeOperationSet,
OrigAttrs[Idx].PciAttributes, OrigAttrs[Idx].PciAttributes,
NULL NULL
); );
} }
FreePool (OrigAttrs); FreePool (OrigAttrs);
FreeHandles: FreeHandles:
FreePool (Handles); FreePool (Handles);
} }
/** /**
Restore the original PCI attributes saved with EnablePciDecoding(). Restore the original PCI attributes saved with EnablePciDecoding().
@ -190,5 +229,6 @@ RestorePciDecoding (
NULL NULL
); );
} }
FreePool (OriginalAttributes); FreePool (OriginalAttributes);
} }

View File

@ -36,7 +36,6 @@ typedef struct {
// part of ACPI tables. // part of ACPI tables.
} BLOB; } BLOB;
/** /**
Compare a standalone key against a user structure containing an embedded key. Compare a standalone key against a user structure containing an embedded key.
@ -65,7 +64,6 @@ BlobKeyCompare (
return AsciiStrCmp (StandaloneKey, (CONST CHAR8 *)Blob->File); return AsciiStrCmp (StandaloneKey, (CONST CHAR8 *)Blob->File);
} }
/** /**
Comparator function for two user structures. Comparator function for two user structures.
@ -93,7 +91,6 @@ BlobCompare (
return BlobKeyCompare (Blob1->File, UserStruct2); return BlobKeyCompare (Blob1->File, UserStruct2);
} }
/** /**
Comparator function for two opaque pointers, ordering on (unsigned) pointer Comparator function for two opaque pointers, ordering on (unsigned) pointer
value itself. value itself.
@ -120,13 +117,14 @@ PointerCompare (
if (Pointer1 == Pointer2) { if (Pointer1 == Pointer2) {
return 0; return 0;
} }
if ((UINTN)Pointer1 < (UINTN)Pointer2) { if ((UINTN)Pointer1 < (UINTN)Pointer2) {
return -1; return -1;
} }
return 1; return 1;
} }
/** /**
Comparator function for two ASCII strings. Can be used as both Key and Comparator function for two ASCII strings. Can be used as both Key and
UserStruct comparator. UserStruct comparator.
@ -151,7 +149,6 @@ AsciiStringCompare (
return AsciiStrCmp (AsciiString1, AsciiString2); return AsciiStrCmp (AsciiString1, AsciiString2);
} }
/** /**
Release the ORDERED_COLLECTION structure populated by Release the ORDERED_COLLECTION structure populated by
CollectAllocationsRestrictedTo32Bit() (below). CollectAllocationsRestrictedTo32Bit() (below).
@ -172,14 +169,15 @@ ReleaseAllocationsRestrictedTo32Bit (
for (Entry = OrderedCollectionMin (AllocationsRestrictedTo32Bit); for (Entry = OrderedCollectionMin (AllocationsRestrictedTo32Bit);
Entry != NULL; Entry != NULL;
Entry = Entry2) { Entry = Entry2)
{
Entry2 = OrderedCollectionNext (Entry); Entry2 = OrderedCollectionNext (Entry);
OrderedCollectionDelete (AllocationsRestrictedTo32Bit, Entry, NULL); OrderedCollectionDelete (AllocationsRestrictedTo32Bit, Entry, NULL);
} }
OrderedCollectionUninit (AllocationsRestrictedTo32Bit); OrderedCollectionUninit (AllocationsRestrictedTo32Bit);
} }
/** /**
Iterate over the linker/loader script, and collect the names of the fw_cfg Iterate over the linker/loader script, and collect the names of the fw_cfg
blobs that are referenced by QEMU_LOADER_ADD_POINTER.PointeeFile fields, such blobs that are referenced by QEMU_LOADER_ADD_POINTER.PointeeFile fields, such
@ -230,6 +228,7 @@ CollectAllocationsRestrictedTo32Bit (
if (LoaderEntry->Type != QemuLoaderCmdAddPointer) { if (LoaderEntry->Type != QemuLoaderCmdAddPointer) {
continue; continue;
} }
AddPointer = &LoaderEntry->Command.AddPointer; AddPointer = &LoaderEntry->Command.AddPointer;
if (AddPointer->PointerSize >= 8) { if (AddPointer->PointerSize >= 8) {
@ -276,7 +275,6 @@ RollBack:
return Status; return Status;
} }
/** /**
Process a QEMU_LOADER_ALLOCATE command. Process a QEMU_LOADER_ALLOCATE command.
@ -335,15 +333,24 @@ ProcessCmdAllocate (
} }
if (Allocate->Alignment > EFI_PAGE_SIZE) { if (Allocate->Alignment > EFI_PAGE_SIZE) {
DEBUG ((DEBUG_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__, DEBUG ((
Allocate->Alignment)); DEBUG_ERROR,
"%a: unsupported alignment 0x%x\n",
__FUNCTION__,
Allocate->Alignment
));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize); Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__, DEBUG ((
Allocate->File, Status)); DEBUG_ERROR,
"%a: QemuFwCfgFindFile(\"%a\"): %r\n",
__FUNCTION__,
Allocate->File,
Status
));
return Status; return Status;
} }
@ -352,11 +359,17 @@ ProcessCmdAllocate (
if (OrderedCollectionFind ( if (OrderedCollectionFind (
AllocationsRestrictedTo32Bit, AllocationsRestrictedTo32Bit,
Allocate->File Allocate->File
) != NULL) { ) != NULL)
{
Address = MAX_UINT32; Address = MAX_UINT32;
} }
Status = gBS->AllocatePages (AllocateMaxAddress, EfiACPIMemoryNVS, NumPages,
&Address); Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiACPIMemoryNVS,
NumPages,
&Address
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
@ -366,6 +379,7 @@ ProcessCmdAllocate (
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto FreePages; goto FreePages;
} }
CopyMem (Blob->File, Allocate->File, QEMU_LOADER_FNAME_SIZE); CopyMem (Blob->File, Allocate->File, QEMU_LOADER_FNAME_SIZE);
Blob->Size = FwCfgSize; Blob->Size = FwCfgSize;
Blob->Base = (VOID *)(UINTN)Address; Blob->Base = (VOID *)(UINTN)Address;
@ -373,10 +387,15 @@ ProcessCmdAllocate (
Status = OrderedCollectionInsert (Tracker, NULL, Blob); Status = OrderedCollectionInsert (Tracker, NULL, Blob);
if (Status == RETURN_ALREADY_STARTED) { if (Status == RETURN_ALREADY_STARTED) {
DEBUG ((DEBUG_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__, DEBUG ((
Allocate->File)); DEBUG_ERROR,
"%a: duplicated file \"%a\"\n",
__FUNCTION__,
Allocate->File
));
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreeBlob; goto FreeBlob;
} }
@ -385,9 +404,17 @@ ProcessCmdAllocate (
QemuFwCfgReadBytes (FwCfgSize, Blob->Base); QemuFwCfgReadBytes (FwCfgSize, Blob->Base);
ZeroMem (Blob->Base + Blob->Size, EFI_PAGES_TO_SIZE (NumPages) - Blob->Size); ZeroMem (Blob->Base + Blob->Size, EFI_PAGES_TO_SIZE (NumPages) - Blob->Size);
DEBUG ((DEBUG_VERBOSE, "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx " DEBUG ((
"Address=0x%Lx\n", __FUNCTION__, Allocate->File, Allocate->Alignment, DEBUG_VERBOSE,
Allocate->Zone, (UINT64)Blob->Size, (UINT64)(UINTN)Blob->Base)); "%a: File=\"%a\" Alignment=0x%x Zone=%d Size=0x%Lx "
"Address=0x%Lx\n",
__FUNCTION__,
Allocate->File,
Allocate->Alignment,
Allocate->Zone,
(UINT64)Blob->Size,
(UINT64)(UINTN)Blob->Base
));
return EFI_SUCCESS; return EFI_SUCCESS;
FreeBlob: FreeBlob:
@ -399,7 +426,6 @@ FreePages:
return Status; return Status;
} }
/** /**
Process a QEMU_LOADER_ADD_POINTER command. Process a QEMU_LOADER_ADD_POINTER command.
@ -431,28 +457,39 @@ ProcessCmdAddPointer (
UINT8 *PointerField; UINT8 *PointerField;
UINT64 PointerValue; UINT64 PointerValue;
if (AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' || if ((AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') ||
AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { (AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0'))
{
DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile); TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile);
TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile); TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile);
if (TrackerEntry == NULL || TrackerEntry2 == NULL) { if ((TrackerEntry == NULL) || (TrackerEntry2 == NULL)) {
DEBUG ((DEBUG_ERROR, "%a: invalid blob reference(s) \"%a\" / \"%a\"\n", DEBUG ((
__FUNCTION__, AddPointer->PointerFile, AddPointer->PointeeFile)); DEBUG_ERROR,
"%a: invalid blob reference(s) \"%a\" / \"%a\"\n",
__FUNCTION__,
AddPointer->PointerFile,
AddPointer->PointeeFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
Blob = OrderedCollectionUserStruct (TrackerEntry); Blob = OrderedCollectionUserStruct (TrackerEntry);
Blob2 = OrderedCollectionUserStruct (TrackerEntry2); Blob2 = OrderedCollectionUserStruct (TrackerEntry2);
if ((AddPointer->PointerSize != 1 && AddPointer->PointerSize != 2 && if (((AddPointer->PointerSize != 1) && (AddPointer->PointerSize != 2) &&
AddPointer->PointerSize != 4 && AddPointer->PointerSize != 8) || (AddPointer->PointerSize != 4) && (AddPointer->PointerSize != 8)) ||
Blob->Size < AddPointer->PointerSize || (Blob->Size < AddPointer->PointerSize) ||
Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset) { (Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset))
DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n", {
__FUNCTION__, AddPointer->PointerFile)); DEBUG ((
DEBUG_ERROR,
"%a: invalid pointer location or size in \"%a\"\n",
__FUNCTION__,
AddPointer->PointerFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -460,8 +497,12 @@ ProcessCmdAddPointer (
PointerValue = 0; PointerValue = 0;
CopyMem (&PointerValue, PointerField, AddPointer->PointerSize); CopyMem (&PointerValue, PointerField, AddPointer->PointerSize);
if (PointerValue >= Blob2->Size) { if (PointerValue >= Blob2->Size) {
DEBUG ((DEBUG_ERROR, "%a: invalid pointer value in \"%a\"\n", __FUNCTION__, DEBUG ((
AddPointer->PointerFile)); DEBUG_ERROR,
"%a: invalid pointer value in \"%a\"\n",
__FUNCTION__,
AddPointer->PointerFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -472,23 +513,34 @@ ProcessCmdAddPointer (
ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size); ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size);
PointerValue += (UINT64)(UINTN)Blob2->Base; PointerValue += (UINT64)(UINTN)Blob2->Base;
if (AddPointer->PointerSize < 8 && if ((AddPointer->PointerSize < 8) &&
RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) { (RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0))
DEBUG ((DEBUG_ERROR, "%a: relocated pointer value unrepresentable in " {
"\"%a\"\n", __FUNCTION__, AddPointer->PointerFile)); DEBUG ((
DEBUG_ERROR,
"%a: relocated pointer value unrepresentable in "
"\"%a\"\n",
__FUNCTION__,
AddPointer->PointerFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
CopyMem (PointerField, &PointerValue, AddPointer->PointerSize); CopyMem (PointerField, &PointerValue, AddPointer->PointerSize);
DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" " DEBUG ((
"PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__, DEBUG_VERBOSE,
AddPointer->PointerFile, AddPointer->PointeeFile, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
AddPointer->PointerOffset, AddPointer->PointerSize)); "PointerOffset=0x%x PointerSize=%d\n",
__FUNCTION__,
AddPointer->PointerFile,
AddPointer->PointeeFile,
AddPointer->PointerOffset,
AddPointer->PointerSize
));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Process a QEMU_LOADER_ADD_CHECKSUM command. Process a QEMU_LOADER_ADD_CHECKSUM command.
@ -522,17 +574,26 @@ ProcessCmdAddChecksum (
TrackerEntry = OrderedCollectionFind (Tracker, AddChecksum->File); TrackerEntry = OrderedCollectionFind (Tracker, AddChecksum->File);
if (TrackerEntry == NULL) { if (TrackerEntry == NULL) {
DEBUG ((DEBUG_ERROR, "%a: invalid blob reference \"%a\"\n", __FUNCTION__, DEBUG ((
AddChecksum->File)); DEBUG_ERROR,
"%a: invalid blob reference \"%a\"\n",
__FUNCTION__,
AddChecksum->File
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
Blob = OrderedCollectionUserStruct (TrackerEntry); Blob = OrderedCollectionUserStruct (TrackerEntry);
if (Blob->Size <= AddChecksum->ResultOffset || if ((Blob->Size <= AddChecksum->ResultOffset) ||
Blob->Size < AddChecksum->Length || (Blob->Size < AddChecksum->Length) ||
Blob->Size - AddChecksum->Length < AddChecksum->Start) { (Blob->Size - AddChecksum->Length < AddChecksum->Start))
DEBUG ((DEBUG_ERROR, "%a: invalid checksum range in \"%a\"\n", {
__FUNCTION__, AddChecksum->File)); DEBUG ((
DEBUG_ERROR,
"%a: invalid checksum range in \"%a\"\n",
__FUNCTION__,
AddChecksum->File
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -540,13 +601,19 @@ ProcessCmdAddChecksum (
Blob->Base + AddChecksum->Start, Blob->Base + AddChecksum->Start,
AddChecksum->Length AddChecksum->Length
); );
DEBUG ((DEBUG_VERBOSE, "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x " DEBUG ((
"Length=0x%x\n", __FUNCTION__, AddChecksum->File, DEBUG_VERBOSE,
AddChecksum->ResultOffset, AddChecksum->Start, AddChecksum->Length)); "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x "
"Length=0x%x\n",
__FUNCTION__,
AddChecksum->File,
AddChecksum->ResultOffset,
AddChecksum->Start,
AddChecksum->Length
));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Process a QEMU_LOADER_WRITE_POINTER command. Process a QEMU_LOADER_WRITE_POINTER command.
@ -593,29 +660,42 @@ ProcessCmdWritePointer (
BLOB *PointeeBlob; BLOB *PointeeBlob;
UINT64 PointerValue; UINT64 PointerValue;
if (WritePointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' || if ((WritePointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') ||
WritePointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') { (WritePointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0'))
{
DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile, Status = QemuFwCfgFindFile (
&PointerItem, &PointerItemSize); (CONST CHAR8 *)WritePointer->PointerFile,
&PointerItem,
&PointerItemSize
);
PointeeEntry = OrderedCollectionFind (Tracker, WritePointer->PointeeFile); PointeeEntry = OrderedCollectionFind (Tracker, WritePointer->PointeeFile);
if (RETURN_ERROR (Status) || PointeeEntry == NULL) { if (RETURN_ERROR (Status) || (PointeeEntry == NULL)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: invalid fw_cfg file or blob reference \"%a\" / \"%a\"\n", "%a: invalid fw_cfg file or blob reference \"%a\" / \"%a\"\n",
__FUNCTION__, WritePointer->PointerFile, WritePointer->PointeeFile)); __FUNCTION__,
WritePointer->PointerFile,
WritePointer->PointeeFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
if ((WritePointer->PointerSize != 1 && WritePointer->PointerSize != 2 && if (((WritePointer->PointerSize != 1) && (WritePointer->PointerSize != 2) &&
WritePointer->PointerSize != 4 && WritePointer->PointerSize != 8) || (WritePointer->PointerSize != 4) && (WritePointer->PointerSize != 8)) ||
(PointerItemSize < WritePointer->PointerSize) || (PointerItemSize < WritePointer->PointerSize) ||
(PointerItemSize - WritePointer->PointerSize < (PointerItemSize - WritePointer->PointerSize <
WritePointer->PointerOffset)) { WritePointer->PointerOffset))
DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n", {
__FUNCTION__, WritePointer->PointerFile)); DEBUG ((
DEBUG_ERROR,
"%a: invalid pointer location or size in \"%a\"\n",
__FUNCTION__,
WritePointer->PointerFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -633,10 +713,15 @@ ProcessCmdWritePointer (
ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size); ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size);
PointerValue += (UINT64)(UINTN)PointeeBlob->Base; PointerValue += (UINT64)(UINTN)PointeeBlob->Base;
if (WritePointer->PointerSize < 8 && if ((WritePointer->PointerSize < 8) &&
RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0) { (RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0))
DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n", {
__FUNCTION__, WritePointer->PointerFile)); DEBUG ((
DEBUG_ERROR,
"%a: pointer value unrepresentable in \"%a\"\n",
__FUNCTION__,
WritePointer->PointerFile
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -670,15 +755,20 @@ ProcessCmdWritePointer (
// //
PointeeBlob->HostsOnlyTableData = FALSE; PointeeBlob->HostsOnlyTableData = FALSE;
DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" " DEBUG ((
"PointerOffset=0x%x PointeeOffset=0x%x PointerSize=%d\n", __FUNCTION__, DEBUG_VERBOSE,
WritePointer->PointerFile, WritePointer->PointeeFile, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
WritePointer->PointerOffset, WritePointer->PointeeOffset, "PointerOffset=0x%x PointeeOffset=0x%x PointerSize=%d\n",
WritePointer->PointerSize)); __FUNCTION__,
WritePointer->PointerFile,
WritePointer->PointeeFile,
WritePointer->PointerOffset,
WritePointer->PointeeOffset,
WritePointer->PointerSize
));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Undo a QEMU_LOADER_WRITE_POINTER command. Undo a QEMU_LOADER_WRITE_POINTER command.
@ -700,8 +790,11 @@ UndoCmdWritePointer (
UINTN PointerItemSize; UINTN PointerItemSize;
UINT64 PointerValue; UINT64 PointerValue;
Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile, Status = QemuFwCfgFindFile (
&PointerItem, &PointerItemSize); (CONST CHAR8 *)WritePointer->PointerFile,
&PointerItem,
&PointerItemSize
);
ASSERT_RETURN_ERROR (Status); ASSERT_RETURN_ERROR (Status);
PointerValue = 0; PointerValue = 0;
@ -709,13 +802,16 @@ UndoCmdWritePointer (
QemuFwCfgSkipBytes (WritePointer->PointerOffset); QemuFwCfgSkipBytes (WritePointer->PointerOffset);
QemuFwCfgWriteBytes (WritePointer->PointerSize, &PointerValue); QemuFwCfgWriteBytes (WritePointer->PointerSize, &PointerValue);
DEBUG ((DEBUG_VERBOSE, DEBUG ((
"%a: PointerFile=\"%a\" PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__, DEBUG_VERBOSE,
WritePointer->PointerFile, WritePointer->PointerOffset, "%a: PointerFile=\"%a\" PointerOffset=0x%x PointerSize=%d\n",
WritePointer->PointerSize)); __FUNCTION__,
WritePointer->PointerFile,
WritePointer->PointerOffset,
WritePointer->PointerSize
));
} }
// //
// We'll be saving the keys of installed tables so that we can roll them back // We'll be saving the keys of installed tables so that we can roll them back
// in case of failure. 128 tables should be enough for anyone (TM). // in case of failure. 128 tables should be enough for anyone (TM).
@ -806,7 +902,7 @@ Process2ndPassCmdAddPointer (
CONST EFI_ACPI_DESCRIPTION_HEADER *Header; CONST EFI_ACPI_DESCRIPTION_HEADER *Header;
EFI_STATUS Status; EFI_STATUS Status;
if (*NumInstalled < 0 || *NumInstalled > INSTALLED_TABLES_MAX) { if ((*NumInstalled < 0) || (*NumInstalled > INSTALLED_TABLES_MAX)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -845,13 +941,20 @@ Process2ndPassCmdAddPointer (
)); ));
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
return Status; return Status;
} }
Blob2Remaining -= (UINTN)PointerValue; Blob2Remaining -= (UINTN)PointerValue;
DEBUG ((DEBUG_VERBOSE, "%a: checking for ACPI header in \"%a\" at 0x%Lx " DEBUG ((
"(remaining: 0x%Lx): ", __FUNCTION__, AddPointer->PointeeFile, DEBUG_VERBOSE,
PointerValue, (UINT64)Blob2Remaining)); "%a: checking for ACPI header in \"%a\" at 0x%Lx "
"(remaining: 0x%Lx): ",
__FUNCTION__,
AddPointer->PointeeFile,
PointerValue,
(UINT64)Blob2Remaining
));
TableSize = 0; TableSize = 0;
@ -861,12 +964,17 @@ Process2ndPassCmdAddPointer (
if (sizeof *Facs <= Blob2Remaining) { if (sizeof *Facs <= Blob2Remaining) {
Facs = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)PointerValue; Facs = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)PointerValue;
if (Facs->Length >= sizeof *Facs && if ((Facs->Length >= sizeof *Facs) &&
Facs->Length <= Blob2Remaining && (Facs->Length <= Blob2Remaining) &&
Facs->Signature == (Facs->Signature ==
EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) { EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE))
DEBUG ((DEBUG_VERBOSE, "found \"%-4.4a\" size 0x%x\n", {
(CONST CHAR8 *)&Facs->Signature, Facs->Length)); DEBUG ((
DEBUG_VERBOSE,
"found \"%-4.4a\" size 0x%x\n",
(CONST CHAR8 *)&Facs->Signature,
Facs->Length
));
TableSize = Facs->Length; TableSize = Facs->Length;
} }
} }
@ -874,28 +982,34 @@ Process2ndPassCmdAddPointer (
// //
// check for the uniform tables // check for the uniform tables
// //
if (TableSize == 0 && sizeof *Header <= Blob2Remaining) { if ((TableSize == 0) && (sizeof *Header <= Blob2Remaining)) {
Header = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)PointerValue; Header = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)PointerValue;
if (Header->Length >= sizeof *Header && if ((Header->Length >= sizeof *Header) &&
Header->Length <= Blob2Remaining && (Header->Length <= Blob2Remaining) &&
CalculateSum8 ((CONST UINT8 *)Header, Header->Length) == 0) { (CalculateSum8 ((CONST UINT8 *)Header, Header->Length) == 0))
{
// //
// This looks very much like an ACPI table from QEMU: // This looks very much like an ACPI table from QEMU:
// - Length field consistent with both ACPI and containing blob size // - Length field consistent with both ACPI and containing blob size
// - checksum is correct // - checksum is correct
// //
DEBUG ((DEBUG_VERBOSE, "found \"%-4.4a\" size 0x%x\n", DEBUG ((
(CONST CHAR8 *)&Header->Signature, Header->Length)); DEBUG_VERBOSE,
"found \"%-4.4a\" size 0x%x\n",
(CONST CHAR8 *)&Header->Signature,
Header->Length
));
TableSize = Header->Length; TableSize = Header->Length;
// //
// Skip RSDT and XSDT because those are handled by // Skip RSDT and XSDT because those are handled by
// EFI_ACPI_TABLE_PROTOCOL automatically. // EFI_ACPI_TABLE_PROTOCOL automatically.
if (Header->Signature == if ((Header->Signature ==
EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE || EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) ||
Header->Signature == (Header->Signature ==
EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
@ -908,20 +1022,32 @@ Process2ndPassCmdAddPointer (
} }
if (*NumInstalled == INSTALLED_TABLES_MAX) { if (*NumInstalled == INSTALLED_TABLES_MAX) {
DEBUG ((DEBUG_ERROR, "%a: can't install more than %d tables\n", DEBUG ((
__FUNCTION__, INSTALLED_TABLES_MAX)); DEBUG_ERROR,
"%a: can't install more than %d tables\n",
__FUNCTION__,
INSTALLED_TABLES_MAX
));
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto RollbackSeenPointer; goto RollbackSeenPointer;
} }
Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol, Status = AcpiProtocol->InstallAcpiTable (
(VOID *)(UINTN)PointerValue, TableSize, AcpiProtocol,
&InstalledKey[*NumInstalled]); (VOID *)(UINTN)PointerValue,
TableSize,
&InstalledKey[*NumInstalled]
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_ERROR,
"%a: InstallAcpiTable(): %r\n",
__FUNCTION__,
Status
));
goto RollbackSeenPointer; goto RollbackSeenPointer;
} }
++*NumInstalled; ++*NumInstalled;
return EFI_SUCCESS; return EFI_SUCCESS;
@ -930,7 +1056,6 @@ RollbackSeenPointer:
return Status; return Status;
} }
/** /**
Download, process, and install ACPI table data from the QEMU loader Download, process, and install ACPI table data from the QEMU loader
interface. interface.
@ -980,9 +1105,14 @@ InstallQemuFwCfgTables (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
if (FwCfgSize % sizeof *LoaderEntry != 0) { if (FwCfgSize % sizeof *LoaderEntry != 0) {
DEBUG ((DEBUG_ERROR, "%a: \"etc/table-loader\" has invalid size 0x%Lx\n", DEBUG ((
__FUNCTION__, (UINT64)FwCfgSize)); DEBUG_ERROR,
"%a: \"etc/table-loader\" has invalid size 0x%Lx\n",
__FUNCTION__,
(UINT64)FwCfgSize
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -990,6 +1120,7 @@ InstallQemuFwCfgTables (
if (LoaderStart == NULL) { if (LoaderStart == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
EnablePciDecoding (&OriginalPciAttributes, &OriginalPciAttributesCount); EnablePciDecoding (&OriginalPciAttributes, &OriginalPciAttributesCount);
QemuFwCfgSelectItem (FwCfgItem); QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (FwCfgSize, LoaderStart); QemuFwCfgReadBytes (FwCfgSize, LoaderStart);
@ -1043,26 +1174,38 @@ InstallQemuFwCfgTables (
break; break;
case QemuLoaderCmdAddPointer: case QemuLoaderCmdAddPointer:
Status = ProcessCmdAddPointer (&LoaderEntry->Command.AddPointer, Status = ProcessCmdAddPointer (
Tracker); &LoaderEntry->Command.AddPointer,
Tracker
);
break; break;
case QemuLoaderCmdAddChecksum: case QemuLoaderCmdAddChecksum:
Status = ProcessCmdAddChecksum (&LoaderEntry->Command.AddChecksum, Status = ProcessCmdAddChecksum (
Tracker); &LoaderEntry->Command.AddChecksum,
Tracker
);
break; break;
case QemuLoaderCmdWritePointer: case QemuLoaderCmdWritePointer:
Status = ProcessCmdWritePointer (&LoaderEntry->Command.WritePointer, Status = ProcessCmdWritePointer (
Tracker, S3Context); &LoaderEntry->Command.WritePointer,
Tracker,
S3Context
);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
WritePointerSubsetEnd = LoaderEntry + 1; WritePointerSubsetEnd = LoaderEntry + 1;
} }
break; break;
default: default:
DEBUG ((DEBUG_VERBOSE, "%a: unknown loader command: 0x%x\n", DEBUG ((
__FUNCTION__, LoaderEntry->Type)); DEBUG_VERBOSE,
"%a: unknown loader command: 0x%x\n",
__FUNCTION__,
LoaderEntry->Type
));
break; break;
} }
@ -1113,6 +1256,7 @@ InstallQemuFwCfgTables (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto UninstallAcpiTables; goto UninstallAcpiTables;
} }
// //
// Ownership of S3Context has been transferred. // Ownership of S3Context has been transferred.
// //
@ -1134,10 +1278,12 @@ UninstallAcpiTables:
for (SeenPointerEntry = OrderedCollectionMin (SeenPointers); for (SeenPointerEntry = OrderedCollectionMin (SeenPointers);
SeenPointerEntry != NULL; SeenPointerEntry != NULL;
SeenPointerEntry = SeenPointerEntry2) { SeenPointerEntry = SeenPointerEntry2)
{
SeenPointerEntry2 = OrderedCollectionNext (SeenPointerEntry); SeenPointerEntry2 = OrderedCollectionNext (SeenPointerEntry);
OrderedCollectionDelete (SeenPointers, SeenPointerEntry, NULL); OrderedCollectionDelete (SeenPointers, SeenPointerEntry, NULL);
} }
OrderedCollectionUninit (SeenPointers); OrderedCollectionUninit (SeenPointers);
FreeKeys: FreeKeys:
@ -1164,7 +1310,8 @@ RollbackWritePointersAndFreeTracker:
// not directly part of some ACPI table. // not directly part of some ACPI table.
// //
for (TrackerEntry = OrderedCollectionMin (Tracker); TrackerEntry != NULL; for (TrackerEntry = OrderedCollectionMin (Tracker); TrackerEntry != NULL;
TrackerEntry = TrackerEntry2) { TrackerEntry = TrackerEntry2)
{
VOID *UserStruct; VOID *UserStruct;
BLOB *Blob; BLOB *Blob;
@ -1173,12 +1320,18 @@ RollbackWritePointersAndFreeTracker:
Blob = UserStruct; Blob = UserStruct;
if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) { if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) {
DEBUG ((DEBUG_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__, DEBUG ((
Blob->File)); DEBUG_VERBOSE,
"%a: freeing \"%a\"\n",
__FUNCTION__,
Blob->File
));
gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size)); gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size));
} }
FreePool (Blob); FreePool (Blob);
} }
OrderedCollectionUninit (Tracker); OrderedCollectionUninit (Tracker);
FreeS3Context: FreeS3Context:

View File

@ -97,17 +97,23 @@ VerifyBlob (
INT32 Remaining; INT32 Remaining;
HASH_TABLE *Entry; HASH_TABLE *Entry;
if (mHashesTable == NULL || mHashesTableSize == 0) { if ((mHashesTable == NULL) || (mHashesTableSize == 0)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: Verifier called but no hashes table discoverd in MEMFD\n", "%a: Verifier called but no hashes table discoverd in MEMFD\n",
__FUNCTION__)); __FUNCTION__
));
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
Guid = FindBlobEntryGuid (BlobName); Guid = FindBlobEntryGuid (BlobName);
if (Guid == NULL) { if (Guid == NULL) {
DEBUG ((DEBUG_ERROR, "%a: Unknown blob name \"%s\"\n", __FUNCTION__, DEBUG ((
BlobName)); DEBUG_ERROR,
"%a: Unknown blob name \"%s\"\n",
__FUNCTION__,
BlobName
));
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
@ -118,7 +124,8 @@ VerifyBlob (
for (Entry = mHashesTable, Remaining = mHashesTableSize; for (Entry = mHashesTable, Remaining = mHashesTableSize;
Remaining >= sizeof *Entry && Remaining >= Entry->Len; Remaining >= sizeof *Entry && Remaining >= Entry->Len;
Remaining -= Entry->Len, Remaining -= Entry->Len,
Entry = (HASH_TABLE *)((UINT8 *)Entry + Entry->Len)) { Entry = (HASH_TABLE *)((UINT8 *)Entry + Entry->Len))
{
UINTN EntrySize; UINTN EntrySize;
EFI_STATUS Status; EFI_STATUS Status;
UINT8 Hash[SHA256_DIGEST_SIZE]; UINT8 Hash[SHA256_DIGEST_SIZE];
@ -131,8 +138,13 @@ VerifyBlob (
EntrySize = Entry->Len - sizeof Entry->Guid - sizeof Entry->Len; EntrySize = Entry->Len - sizeof Entry->Guid - sizeof Entry->Len;
if (EntrySize != SHA256_DIGEST_SIZE) { if (EntrySize != SHA256_DIGEST_SIZE) {
DEBUG ((DEBUG_ERROR, "%a: Hash has the wrong size %d != %d\n", DEBUG ((
__FUNCTION__, EntrySize, SHA256_DIGEST_SIZE)); DEBUG_ERROR,
"%a: Hash has the wrong size %d != %d\n",
__FUNCTION__,
EntrySize,
SHA256_DIGEST_SIZE
));
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
@ -144,18 +156,31 @@ VerifyBlob (
if (CompareMem (Entry->Data, Hash, EntrySize) == 0) { if (CompareMem (Entry->Data, Hash, EntrySize) == 0) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
DEBUG ((DEBUG_INFO, "%a: Hash comparison succeeded for \"%s\"\n", DEBUG ((
__FUNCTION__, BlobName)); DEBUG_INFO,
"%a: Hash comparison succeeded for \"%s\"\n",
__FUNCTION__,
BlobName
));
} else { } else {
Status = EFI_ACCESS_DENIED; Status = EFI_ACCESS_DENIED;
DEBUG ((DEBUG_ERROR, "%a: Hash comparison failed for \"%s\"\n", DEBUG ((
__FUNCTION__, BlobName)); DEBUG_ERROR,
"%a: Hash comparison failed for \"%s\"\n",
__FUNCTION__,
BlobName
));
} }
return Status; return Status;
} }
DEBUG ((DEBUG_ERROR, "%a: Hash GUID %g not found in table\n", __FUNCTION__, DEBUG ((
Guid)); DEBUG_ERROR,
"%a: Hash GUID %g not found in table\n",
__FUNCTION__,
Guid
));
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
@ -183,20 +208,29 @@ BlobVerifierLibSevHashesConstructor (
Ptr = (void *)(UINTN)FixedPcdGet64 (PcdQemuHashTableBase); Ptr = (void *)(UINTN)FixedPcdGet64 (PcdQemuHashTableBase);
Size = FixedPcdGet32 (PcdQemuHashTableSize); Size = FixedPcdGet32 (PcdQemuHashTableSize);
if (Ptr == NULL || Size < sizeof *Ptr || if ((Ptr == NULL) || (Size < sizeof *Ptr) ||
!CompareGuid (&Ptr->Guid, &SEV_HASH_TABLE_GUID) || !CompareGuid (&Ptr->Guid, &SEV_HASH_TABLE_GUID) ||
Ptr->Len < sizeof *Ptr || Ptr->Len > Size) { (Ptr->Len < sizeof *Ptr) || (Ptr->Len > Size))
{
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
DEBUG ((DEBUG_INFO, "%a: Found injected hashes table in secure location\n", DEBUG ((
__FUNCTION__)); DEBUG_INFO,
"%a: Found injected hashes table in secure location\n",
__FUNCTION__
));
mHashesTable = (HASH_TABLE *)Ptr->Data; mHashesTable = (HASH_TABLE *)Ptr->Data;
mHashesTableSize = Ptr->Len - sizeof Ptr->Guid - sizeof Ptr->Len; mHashesTableSize = Ptr->Len - sizeof Ptr->Guid - sizeof Ptr->Len;
DEBUG ((DEBUG_VERBOSE, "%a: mHashesTable=0x%p, Size=%u\n", __FUNCTION__, DEBUG ((
mHashesTable, mHashesTableSize)); DEBUG_VERBOSE,
"%a: mHashesTable=0x%p, Size=%u\n",
__FUNCTION__,
mHashesTable,
mHashesTableSize
));
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }

View File

@ -51,8 +51,9 @@ AmdSevDxeEntryPoint (
CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc; CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;
Desc = &AllDescMap[Index]; Desc = &AllDescMap[Index];
if (Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo || if ((Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) ||
Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent) { (Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent))
{
Status = MemEncryptSevClearMmioPageEncMask ( Status = MemEncryptSevClearMmioPageEncMask (
0, 0,
Desc->BaseAddress, Desc->BaseAddress,
@ -123,8 +124,12 @@ AmdSevDxeEntryPoint (
MapPagesCount // NumPages MapPagesCount // NumPages
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: MemEncryptSevClearPageEncMask(): %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_ERROR,
"%a: MemEncryptSevClearPageEncMask(): %r\n",
__FUNCTION__,
Status
));
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }

View File

@ -27,7 +27,6 @@ InstallAcpiTable (
); );
} }
/** /**
Locate the first instance of a protocol. If the protocol requested is an Locate the first instance of a protocol. If the protocol requested is an
FV protocol, then it will return the first FV that contains the ACPI table FV protocol, then it will return the first FV that contains the ACPI table
@ -124,7 +123,6 @@ LocateFvInstanceWithTables (
return Status; return Status;
} }
/** /**
Find ACPI tables in an FV and install them. Find ACPI tables in an FV and install them.
@ -171,13 +169,13 @@ InstallOvmfFvTables (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_ABORTED; return EFI_ABORTED;
} }
ASSERT (FwVol != NULL); ASSERT (FwVol != NULL);
// //
// Read tables from the storage file. // Read tables from the storage file.
// //
while (Status == EFI_SUCCESS) { while (Status == EFI_SUCCESS) {
Status = FwVol->ReadSection ( Status = FwVol->ReadSection (
FwVol, FwVol,
(EFI_GUID *)PcdGetPtr (PcdAcpiTableStorageFile), (EFI_GUID *)PcdGetPtr (PcdAcpiTableStorageFile),
@ -249,4 +247,3 @@ InstallAcpiTables (
return Status; return Status;
} }

View File

@ -71,6 +71,7 @@ BhyveInstallAcpiMadtTable (
LocalApic->Flags = 1; // enabled LocalApic->Flags = 1; // enabled
++LocalApic; ++LocalApic;
} }
Ptr = LocalApic; Ptr = LocalApic;
IoApic = Ptr; IoApic = Ptr;

View File

@ -28,7 +28,6 @@ FindAcpiTableProtocol (
return AcpiTable; return AcpiTable;
} }
STATIC STATIC
VOID VOID
EFIAPI EFIAPI
@ -39,17 +38,19 @@ OnRootBridgesConnected (
{ {
EFI_STATUS Status; EFI_STATUS Status;
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: root bridges have been connected, installing ACPI tables\n", "%a: root bridges have been connected, installing ACPI tables\n",
__FUNCTION__)); __FUNCTION__
));
Status = InstallAcpiTables (FindAcpiTableProtocol ()); Status = InstallAcpiTables (FindAcpiTableProtocol ());
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
} }
gBS->CloseEvent (Event); gBS->CloseEvent (Event);
} }
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
AcpiPlatformEntryPoint ( AcpiPlatformEntryPoint (
@ -66,8 +67,12 @@ AcpiPlatformEntryPoint (
// the full functionality. // the full functionality.
// //
if (PcdGetBool (PcdPciDisableBusEnumeration)) { if (PcdGetBool (PcdPciDisableBusEnumeration)) {
DEBUG ((DEBUG_INFO, "%a: PCI or its enumeration disabled, installing " DEBUG ((
"ACPI tables\n", __FUNCTION__)); DEBUG_INFO,
"%a: PCI or its enumeration disabled, installing "
"ACPI tables\n",
__FUNCTION__
));
return InstallAcpiTables (FindAcpiTableProtocol ()); return InstallAcpiTables (FindAcpiTableProtocol ());
} }
@ -77,13 +82,20 @@ AcpiPlatformEntryPoint (
// setup. (Note that we're a DXE_DRIVER; our entry point function is invoked // setup. (Note that we're a DXE_DRIVER; our entry point function is invoked
// strictly before BDS is entered and can connect the root bridges.) // strictly before BDS is entered and can connect the root bridges.)
// //
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, Status = gBS->CreateEventEx (
OnRootBridgesConnected, NULL /* Context */, EVT_NOTIFY_SIGNAL,
&gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected); TPL_CALLBACK,
OnRootBridgesConnected,
NULL /* Context */,
&gRootBridgesConnectedEventGroupGuid,
&RootBridgesConnected
);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: waiting for root bridges to be connected, registered callback\n", "%a: waiting for root bridges to be connected, registered callback\n",
__FUNCTION__)); __FUNCTION__
));
} }
return Status; return Status;

View File

@ -11,7 +11,6 @@
#include "AcpiPlatform.h" #include "AcpiPlatform.h"
/** /**
Collect all PciIo protocol instances in the system. Save their original Collect all PciIo protocol instances in the system. Save their original
attributes, and enable IO and MMIO decoding for each. attributes, and enable IO and MMIO decoding for each.
@ -59,8 +58,13 @@ EnablePciDecoding (
return; return;
} }
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid, Status = gBS->LocateHandleBuffer (
NULL /* SearchKey */, &NoHandles, &Handles); ByProtocol,
&gEfiPciIoProtocolGuid,
NULL /* SearchKey */,
&NoHandles,
&Handles
);
if (Status == EFI_NOT_FOUND) { if (Status == EFI_NOT_FOUND) {
// //
// No PCI devices were found on either of the root bridges. We're done. // No PCI devices were found on either of the root bridges. We're done.
@ -69,15 +73,22 @@ EnablePciDecoding (
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_WARN,
"%a: LocateHandleBuffer(): %r\n",
__FUNCTION__,
Status
));
return; return;
} }
OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs); OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);
if (OrigAttrs == NULL) { if (OrigAttrs == NULL) {
DEBUG ((DEBUG_WARN, "%a: AllocatePool(): out of resources\n", DEBUG ((
__FUNCTION__)); DEBUG_WARN,
"%a: AllocatePool(): out of resources\n",
__FUNCTION__
));
goto FreeHandles; goto FreeHandles;
} }
@ -88,30 +99,49 @@ EnablePciDecoding (
// //
// Look up PciIo on the handle and stash it // Look up PciIo on the handle and stash it
// //
Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid, Status = gBS->HandleProtocol (
(VOID**)&PciIo); Handles[Idx],
&gEfiPciIoProtocolGuid,
(VOID **)&PciIo
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
OrigAttrs[Idx].PciIo = PciIo; OrigAttrs[Idx].PciIo = PciIo;
// //
// Stash the current attributes // Stash the current attributes
// //
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0, Status = PciIo->Attributes (
&OrigAttrs[Idx].PciAttributes); PciIo,
EfiPciIoAttributeOperationGet,
0,
&OrigAttrs[Idx].PciAttributes
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationGet: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
// //
// Retrieve supported attributes // Retrieve supported attributes
// //
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0, Status = PciIo->Attributes (
&Attributes); PciIo,
EfiPciIoAttributeOperationSupported,
0,
&Attributes
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationSupported: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
@ -119,11 +149,19 @@ EnablePciDecoding (
// Enable IO and MMIO decoding // Enable IO and MMIO decoding
// //
Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY; Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, Status = PciIo->Attributes (
Attributes, NULL); PciIo,
EfiPciIoAttributeOperationEnable,
Attributes,
NULL
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_WARN,
"%a: EfiPciIoAttributeOperationEnable: %r\n",
__FUNCTION__,
Status
));
goto RestoreAttributes; goto RestoreAttributes;
} }
} }
@ -139,19 +177,20 @@ EnablePciDecoding (
RestoreAttributes: RestoreAttributes:
while (Idx > 0) { while (Idx > 0) {
--Idx; --Idx;
OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo, OrigAttrs[Idx].PciIo->Attributes (
OrigAttrs[Idx].PciIo,
EfiPciIoAttributeOperationSet, EfiPciIoAttributeOperationSet,
OrigAttrs[Idx].PciAttributes, OrigAttrs[Idx].PciAttributes,
NULL NULL
); );
} }
FreePool (OrigAttrs); FreePool (OrigAttrs);
FreeHandles: FreeHandles:
FreePool (Handles); FreePool (Handles);
} }
/** /**
Restore the original PCI attributes saved with EnablePciDecoding(). Restore the original PCI attributes saved with EnablePciDecoding().
@ -188,5 +227,6 @@ RestorePciDecoding (
NULL NULL
); );
} }
FreePool (OriginalAttributes); FreePool (OriginalAttributes);
} }

View File

@ -55,13 +55,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2
"en" "en"
}; };
EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = { EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
{ "eng", L"Emulator GOP Driver" }, { "eng", L"Emulator GOP Driver" },
{ NULL, NULL } { NULL, NULL }
}; };
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -118,7 +116,6 @@ EmuGopComponentNameGetDriverName (
); );
} }
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.

View File

@ -87,7 +87,6 @@ typedef struct {
UINT32 FbSize; UINT32 FbSize;
} GOP_PRIVATE_DATA; } GOP_PRIVATE_DATA;
#define GOP_PRIVATE_DATA_FROM_THIS(a) \ #define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE) CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)

View File

@ -19,7 +19,6 @@ BhyveGetGraphicsMode (
UINT16 *Depth UINT16 *Depth
); );
/** /**
Tests to see if this driver supports a given controller. If a child device is provided, Tests to see if this driver supports a given controller. If a child device is provided,
it further tests to see if this driver supports creating a handle for the specified child device. it further tests to see if this driver supports creating a handle for the specified child device.
@ -107,7 +106,7 @@ EmuGopDriverBindingSupported (
} }
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
if (Pci.Hdr.VendorId == 0xFB5D && Pci.Hdr.DeviceId == 0x40FB) { if ((Pci.Hdr.VendorId == 0xFB5D) && (Pci.Hdr.DeviceId == 0x40FB)) {
DEBUG ((DEBUG_INFO, "BHYVE framebuffer device detected\n")); DEBUG ((DEBUG_INFO, "BHYVE framebuffer device detected\n"));
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -130,7 +129,6 @@ Done:
return Status; return Status;
} }
/** /**
Starts a device controller or a bus controller. Starts a device controller or a bus controller.
@ -224,17 +222,23 @@ EmuGopDriverBindingStart (
(VOID **)&MmioDesc (VOID **)&MmioDesc
); );
if (EFI_ERROR (Status) || if (EFI_ERROR (Status) ||
MmioDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM) { (MmioDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM))
{
DEBUG ((DEBUG_INFO, "BHYVE GOP: No mmio bar\n")); DEBUG ((DEBUG_INFO, "BHYVE GOP: No mmio bar\n"));
} else { } else {
DEBUG ((DEBUG_INFO, "BHYVE GOP: Using mmio bar @ 0x%lx\n", DEBUG ((
MmioDesc->AddrRangeMin)); DEBUG_INFO,
"BHYVE GOP: Using mmio bar @ 0x%lx\n",
MmioDesc->AddrRangeMin
));
BhyveGetMemregs (Private, &Memregs); BhyveGetMemregs (Private, &Memregs);
Private->FbSize = Memregs.FbSize; Private->FbSize = Memregs.FbSize;
} }
if (MmioDesc != NULL) { if (MmioDesc != NULL) {
FreePool (MmioDesc); FreePool (MmioDesc);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
@ -250,11 +254,15 @@ EmuGopDriverBindingStart (
(VOID **)&MmioDesc (VOID **)&MmioDesc
); );
if (EFI_ERROR (Status) || if (EFI_ERROR (Status) ||
MmioDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM) { (MmioDesc->ResType != ACPI_ADDRESS_SPACE_TYPE_MEM))
{
DEBUG ((DEBUG_INFO, "BHYVE GOP: No frame-buffer bar\n")); DEBUG ((DEBUG_INFO, "BHYVE GOP: No frame-buffer bar\n"));
} else { } else {
DEBUG ((DEBUG_INFO, "BHYVE GOP: Using frame-buffer bar @ 0x%lx\n", DEBUG ((
MmioDesc->AddrRangeMin)); DEBUG_INFO,
"BHYVE GOP: Using frame-buffer bar @ 0x%lx\n",
MmioDesc->AddrRangeMin
));
Private->FbAddr = MmioDesc->AddrRangeMin; Private->FbAddr = MmioDesc->AddrRangeMin;
// XXX assert BAR is >= size // XXX assert BAR is >= size
} }
@ -262,12 +270,17 @@ EmuGopDriverBindingStart (
if (MmioDesc != NULL) { if (MmioDesc != NULL) {
FreePool (MmioDesc); FreePool (MmioDesc);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
DEBUG ((DEBUG_INFO, "BHYVE GOP: Framebuf addr 0x%lx, size %x\n", DEBUG ((
Private->FbAddr, Private->FbSize)); DEBUG_INFO,
"BHYVE GOP: Framebuf addr 0x%lx, size %x\n",
Private->FbAddr,
Private->FbSize
));
Status = EmuGopConstructor (Private); Status = EmuGopConstructor (Private);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -279,7 +292,8 @@ EmuGopDriverBindingStart (
// //
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle, &Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&Private->GraphicsOutput,
NULL NULL
); );
@ -309,8 +323,6 @@ Done:
return Status; return Status;
} }
/** /**
Stops a device controller or a bus controller. Stops a device controller or a bus controller.
@ -377,7 +389,8 @@ EmuGopDriverBindingStop (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle, Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&Private->GraphicsOutput,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -402,13 +415,11 @@ EmuGopDriverBindingStop (
FreeUnicodeStringTable (Private->ControllerNameTable); FreeUnicodeStringTable (Private->ControllerNameTable);
gBS->FreePool (Private); gBS->FreePool (Private);
} }
return Status; return Status;
} }
/// ///
/// This protocol provides the services required to determine if a driver supports a given controller. /// This protocol provides the services required to determine if a driver supports a given controller.
/// If a controller is supported, then it also provides routines to start and stop the controller. /// If a controller is supported, then it also provides routines to start and stop the controller.
@ -422,8 +433,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
NULL NULL
}; };
/** /**
The user Entry Point for module EmuGop. The user code starts with this function. The user Entry Point for module EmuGop. The user code starts with this function.
@ -453,7 +462,6 @@ InitializeEmuGop (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }
@ -469,7 +477,6 @@ BhyveGetGraphicsMode (
UINT64 Offset; UINT64 Offset;
EFI_STATUS Status; EFI_STATUS Status;
Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs; Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs;
Status = PciIo->Mem.Read ( Status = PciIo->Mem.Read (
@ -538,6 +545,11 @@ BhyveGetMemregs (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
DEBUG ((DEBUG_INFO, "BHYVE Get Memregs, size %d width %d height %d\n", DEBUG ((
Memregs->FbSize, Memregs->Width, Memregs->Height)); DEBUG_INFO,
"BHYVE Get Memregs, size %d width %d height %d\n",
Memregs->FbSize,
Memregs->Width,
Memregs->Height
));
} }

View File

@ -22,7 +22,6 @@ Abstract:
#include "Gop.h" #include "Gop.h"
#include <Library/FrameBufferBltLib.h> #include <Library/FrameBufferBltLib.h>
EFI_EVENT mGopScreenExitBootServicesEvent; EFI_EVENT mGopScreenExitBootServicesEvent;
GOP_MODE_DATA mGopModeData[] = { GOP_MODE_DATA mGopModeData[] = {
@ -53,14 +52,18 @@ BhyveGopCompleteModeInfo (
Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK; Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK;
Info->PixelInformation.ReservedMask = 0; Info->PixelInformation.ReservedMask = 0;
} else if (ModeData->ColorDepth == 32) { } else if (ModeData->ColorDepth == 32) {
DEBUG ((DEBUG_INFO, "%dx%d PixelBlueGreenRedReserved8BitPerColor\n", DEBUG ((
ModeData->HorizontalResolution, ModeData->VerticalResolution)); DEBUG_INFO,
"%dx%d PixelBlueGreenRedReserved8BitPerColor\n",
ModeData->HorizontalResolution,
ModeData->VerticalResolution
));
Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
} }
Info->PixelsPerScanLine = Info->HorizontalResolution; Info->PixelsPerScanLine = Info->HorizontalResolution;
} }
/** /**
Returns information for an available graphics mode that the graphics device Returns information for an available graphics mode that the graphics device
and the set of active video output devices supports. and the set of active video output devices supports.
@ -91,7 +94,7 @@ EmuGopQuerytMode (
Private = GOP_PRIVATE_DATA_FROM_THIS (This); Private = GOP_PRIVATE_DATA_FROM_THIS (This);
if (Info == NULL || SizeOfInfo == NULL || (UINTN) ModeNumber >= This->Mode->MaxMode) { if ((Info == NULL) || (SizeOfInfo == NULL) || ((UINTN)ModeNumber >= This->Mode->MaxMode)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -112,8 +115,6 @@ EmuGopQuerytMode (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Set the video device into the specified mode and clears the visible portions of Set the video device into the specified mode and clears the visible portions of
the output display to black. the output display to black.
@ -142,6 +143,7 @@ EmuGopSetMode (
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info; EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
UINTN confsize = 0; UINTN confsize = 0;
fbconf = NULL; fbconf = NULL;
Private = GOP_PRIVATE_DATA_FROM_THIS (This); Private = GOP_PRIVATE_DATA_FROM_THIS (This);
@ -179,13 +181,19 @@ EmuGopSetMode (
RETURN_STATUS ret = FrameBufferBltConfigure ( RETURN_STATUS ret = FrameBufferBltConfigure (
(VOID *)(UINTN)This->Mode->FrameBufferBase, (VOID *)(UINTN)This->Mode->FrameBufferBase,
This->Mode->Info, fbconf, &confsize This->Mode->Info,
fbconf,
&confsize
); );
if (ret == EFI_BUFFER_TOO_SMALL || ret == EFI_INVALID_PARAMETER) {
if ((ret == EFI_BUFFER_TOO_SMALL) || (ret == EFI_INVALID_PARAMETER)) {
fbconf = AllocatePool (confsize); fbconf = AllocatePool (confsize);
ret = FrameBufferBltConfigure ( ret = FrameBufferBltConfigure (
(VOID *)(UINTN)This->Mode->FrameBufferBase, (VOID *)(UINTN)This->Mode->FrameBufferBase,
This->Mode->Info, fbconf, &confsize); This->Mode->Info,
fbconf,
&confsize
);
ASSERT (ret == EFI_SUCCESS); ASSERT (ret == EFI_SUCCESS);
} }
@ -207,8 +215,6 @@ EmuGopSetMode (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer. Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
@ -251,7 +257,7 @@ EmuGopBlt (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Width == 0 || Height == 0) { if ((Width == 0) || (Height == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -291,7 +297,6 @@ EmuGopBlt (
return Status; return Status;
} }
// //
// Construction and Destruction functions // Construction and Destruction functions
// //
@ -318,12 +323,12 @@ EmuGopConstructor (
if (Private->GraphicsOutput.Mode == NULL) { if (Private->GraphicsOutput.Mode == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION)); Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
if (Private->GraphicsOutput.Mode->Info == NULL) { if (Private->GraphicsOutput.Mode->Info == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
DEBUG ((DEBUG_INFO, "BHYVE Gop Constructor\n")); DEBUG ((DEBUG_INFO, "BHYVE Gop Constructor\n"));
Private->GraphicsOutput.Mode->MaxMode = sizeof (mGopModeData) / sizeof (GOP_MODE_DATA); Private->GraphicsOutput.Mode->MaxMode = sizeof (mGopModeData) / sizeof (GOP_MODE_DATA);
@ -342,8 +347,6 @@ EmuGopConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
EmuGopDestructor ( EmuGopDestructor (
GOP_PRIVATE_DATA *Private GOP_PRIVATE_DATA *Private
@ -356,6 +359,7 @@ EmuGopDestructor (
if (Private->GraphicsOutput.Mode->Info != NULL) { if (Private->GraphicsOutput.Mode->Info != NULL) {
FreePool (Private->GraphicsOutput.Mode->Info); FreePool (Private->GraphicsOutput.Mode->Info);
} }
FreePool (Private->GraphicsOutput.Mode); FreePool (Private->GraphicsOutput.Mode);
Private->GraphicsOutput.Mode = NULL; Private->GraphicsOutput.Mode = NULL;
} }
@ -363,13 +367,13 @@ EmuGopDestructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
VOID VOID
EFIAPI EFIAPI
ShutdownGopEvent ( ShutdownGopEvent (
IN EFI_EVENT Event, IN EFI_EVENT Event,
IN VOID *Context IN VOID *Context
) )
/*++ /*++
Routine Description: Routine Description:

View File

@ -52,7 +52,6 @@ STATIC CONST UINT16 vbeModeIds[] = {
STATIC VBE2_MODE_INFO vbeModes[] = { STATIC VBE2_MODE_INFO vbeModes[] = {
{ // 0x13f 640x480x32 { // 0x13f 640x480x32
// ModeAttr - BytesPerScanLine // ModeAttr - BytesPerScanLine
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4, VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
// Width, Height..., Vbe3 // Width, Height..., Vbe3
@ -63,7 +62,6 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
0xdeadbeef, 0x0000, 0x0000 0xdeadbeef, 0x0000, 0x0000
}, },
{ // 0x140 800x600x32 { // 0x140 800x600x32
// ModeAttr - BytesPerScanLine // ModeAttr - BytesPerScanLine
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4, VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
// Width, Height..., Vbe3 // Width, Height..., Vbe3
@ -74,7 +72,6 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
0xdeadbeef, 0x0000, 0x0000 0xdeadbeef, 0x0000, 0x0000
}, },
{ // 0x141 1024x768x32 { // 0x141 1024x768x32
// ModeAttr - BytesPerScanLine // ModeAttr - BytesPerScanLine
VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4, VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
// Width, Height..., Vbe3 // Width, Height..., Vbe3
@ -130,8 +127,12 @@ InstallVbeShim (
// //
Segment0Pages = 1; Segment0Pages = 1;
Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10; Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10;
Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode, Status = gBS->AllocatePages (
Segment0Pages, &Segment0); AllocateAddress,
EfiBootServicesCode,
Segment0Pages,
&Segment0
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
EFI_PHYSICAL_ADDRESS Handler; EFI_PHYSICAL_ADDRESS Handler;
@ -142,9 +143,14 @@ InstallVbeShim (
// it's already present. // it's already present.
// //
Handler = (Int0x10->Segment << 4) + Int0x10->Offset; Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
if (Handler >= SegmentC && Handler < SegmentF) { if ((Handler >= SegmentC) && (Handler < SegmentF)) {
DEBUG ((DEBUG_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n", DEBUG ((
__FUNCTION__, Int0x10->Segment, Int0x10->Offset)); DEBUG_VERBOSE,
"%a: Video BIOS handler found at %04x:%04x\n",
__FUNCTION__,
Int0x10->Segment,
Int0x10->Offset
));
return; return;
} }
@ -152,8 +158,12 @@ InstallVbeShim (
// Otherwise we'll overwrite the Int10h vector, even though we may not own // Otherwise we'll overwrite the Int10h vector, even though we may not own
// the page at zero. // the page at zero.
// //
DEBUG ((DEBUG_VERBOSE, "%a: failed to allocate page at zero: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_VERBOSE,
"%a: failed to allocate page at zero: %r\n",
__FUNCTION__,
Status
));
} else { } else {
// //
// We managed to allocate the page at zero. SVN r14218 guarantees that it // We managed to allocate the page at zero. SVN r14218 guarantees that it
@ -207,6 +217,7 @@ InstallVbeShim (
*(UINT16 *)Ptr = vbeModeIds[i]; // mode number *(UINT16 *)Ptr = vbeModeIds[i]; // mode number
Ptr += 2; Ptr += 2;
} }
*(UINT16 *)Ptr = 0xFFFF; // mode list terminator *(UINT16 *)Ptr = 0xFFFF; // mode list terminator
Ptr += 2; Ptr += 2;
@ -218,9 +229,12 @@ InstallVbeShim (
Ptr += 5; Ptr += 5;
VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC); VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
Printed = AsciiSPrint ((CHAR8 *)Ptr, Printed = AsciiSPrint (
sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s", (CHAR8 *)Ptr,
CardName); sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer),
"%s",
CardName
);
Ptr += Printed + 1; Ptr += Printed + 1;
VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC); VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
@ -254,6 +268,11 @@ InstallVbeShim (
Int0x10->Segment = (UINT16)((UINT32)SegmentC >> 4); Int0x10->Segment = (UINT16)((UINT32)SegmentC >> 4);
Int0x10->Offset = (UINT16)((UINTN)(VbeModeInfo + 1) - SegmentC); Int0x10->Offset = (UINT16)((UINTN)(VbeModeInfo + 1) - SegmentC);
DEBUG ((DEBUG_INFO, "%a: VBE shim installed to %x:%x\n", DEBUG ((
__FUNCTION__, Int0x10->Segment, Int0x10->Offset)); DEBUG_INFO,
"%a: VBE shim installed to %x:%x\n",
__FUNCTION__,
Int0x10->Segment,
Int0x10->Offset
));
} }

View File

@ -1,6 +1,7 @@
// //
// THIS FILE WAS GENERATED BY "VbeShim.sh". DO NOT EDIT. // THIS FILE WAS GENERATED BY "VbeShim.sh". DO NOT EDIT.
// //
#ifndef _VBE_SHIM_H_ #ifndef _VBE_SHIM_H_
#define _VBE_SHIM_H_ #define _VBE_SHIM_H_
STATIC CONST UINT8 mVbeShim[] = { STATIC CONST UINT8 mVbeShim[] = {

View File

@ -73,7 +73,7 @@ ClearCacheOnMpServicesAvailable (
0, // TimeoutInMicroSeconds: inf. 0, // TimeoutInMicroSeconds: inf.
NULL // ProcedureArgument NULL // ProcedureArgument
); );
if (EFI_ERROR (Status) && Status != EFI_NOT_STARTED) { if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status));
return Status; return Status;
} }
@ -105,7 +105,11 @@ InstallClearCacheCallback (
Status = PeiServicesNotifyPpi (&mMpServicesNotify); Status = PeiServicesNotifyPpi (&mMpServicesNotify);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to set up MP Services callback: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_ERROR,
"%a: failed to set up MP Services callback: %r\n",
__FUNCTION__,
Status
));
} }
} }

View File

@ -6,7 +6,6 @@
**/ **/
#include "Cmos.h" #include "Cmos.h"
#include "Library/IoLib.h" #include "Library/IoLib.h"
@ -31,7 +30,6 @@ CmosRead8 (
return IoRead8 (0x71); return IoRead8 (0x71);
} }
/** /**
Writes 8-bits of CMOS data. Writes 8-bits of CMOS data.
@ -55,4 +53,3 @@ CmosWrite8 (
IoWrite8 (0x71, Value); IoWrite8 (0x71, Value);
return Value; return Value;
} }

View File

@ -45,6 +45,4 @@ CmosWrite8 (
IN UINT8 Value IN UINT8 Value
); );
#endif /* _CMOS_H_ */ #endif /* _CMOS_H_ */

View File

@ -13,7 +13,6 @@
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/PeiServicesLib.h> #include <Library/PeiServicesLib.h>
/** /**
Publish PEI & DXE (Decompressed) Memory based FVs to let PEI Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
and DXE know about them. and DXE know about them.
@ -91,4 +90,3 @@ PeiFvInitialization (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -100,7 +100,6 @@ Q35TsegMbytesInitialization (
mQ35TsegMbytes = ExtendedTsegMbytes; mQ35TsegMbytes = ExtendedTsegMbytes;
} }
UINT32 UINT32
GetSystemMemorySizeBelow4gb ( GetSystemMemorySizeBelow4gb (
VOID VOID
@ -124,7 +123,6 @@ GetSystemMemorySizeBelow4gb (
return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB); return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
} }
STATIC STATIC
UINT64 UINT64
GetSystemMemorySizeAbove4gb ( GetSystemMemorySizeAbove4gb (
@ -149,7 +147,6 @@ GetSystemMemorySizeAbove4gb (
return LShiftU64 (Size, 16); return LShiftU64 (Size, 16);
} }
/** /**
Return the highest address that DXE could possibly use, plus one. Return the highest address that DXE could possibly use, plus one.
**/ **/
@ -174,6 +171,7 @@ GetFirstNonAddress (
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
return FirstNonAddress; return FirstNonAddress;
} }
#endif #endif
// //
@ -184,8 +182,11 @@ GetFirstNonAddress (
if (Pci64Size == 0) { if (Pci64Size == 0) {
if (mBootMode != BOOT_ON_S3_RESUME) { if (mBootMode != BOOT_ON_S3_RESUME) {
DEBUG ((DEBUG_INFO, "%a: disabling 64-bit PCI host aperture\n", DEBUG ((
__FUNCTION__)); DEBUG_INFO,
"%a: disabling 64-bit PCI host aperture\n",
__FUNCTION__
));
PcdStatus = PcdSet64S (PcdPciMmio64Size, 0); PcdStatus = PcdSet64S (PcdPciMmio64Size, 0);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
} }
@ -224,8 +225,13 @@ GetFirstNonAddress (
PcdStatus = PcdSet64S (PcdPciMmio64Size, Pci64Size); PcdStatus = PcdSet64S (PcdPciMmio64Size, Pci64Size);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
DEBUG ((DEBUG_INFO, "%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n", DEBUG ((
__FUNCTION__, Pci64Base, Pci64Size)); DEBUG_INFO,
"%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n",
__FUNCTION__,
Pci64Base,
Pci64Size
));
} }
// //
@ -235,7 +241,6 @@ GetFirstNonAddress (
return FirstNonAddress; return FirstNonAddress;
} }
/** /**
Initialize the mPhysMemAddressWidth variable, based on guest RAM size. Initialize the mPhysMemAddressWidth variable, based on guest RAM size.
**/ **/
@ -272,10 +277,10 @@ AddressWidthInitialization (
if (mPhysMemAddressWidth <= 36) { if (mPhysMemAddressWidth <= 36) {
mPhysMemAddressWidth = 36; mPhysMemAddressWidth = 36;
} }
ASSERT (mPhysMemAddressWidth <= 48); ASSERT (mPhysMemAddressWidth <= 48);
} }
/** /**
Calculate the cap for the permanent PEI memory. Calculate the cap for the permanent PEI memory.
**/ **/
@ -299,6 +304,7 @@ GetPeiMemoryCap (
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) { if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
return SIZE_64MB; return SIZE_64MB;
} }
#endif #endif
// //
@ -340,7 +346,6 @@ GetPeiMemoryCap (
return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB); return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB);
} }
/** /**
Publish PEI core memory Publish PEI core memory
@ -384,8 +389,13 @@ PublishPeiMemory (
MemorySize = mS3AcpiReservedMemorySize; MemorySize = mS3AcpiReservedMemorySize;
} else { } else {
PeiMemoryCap = GetPeiMemoryCap (); PeiMemoryCap = GetPeiMemoryCap ();
DEBUG ((DEBUG_INFO, "%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n", DEBUG ((
__FUNCTION__, mPhysMemAddressWidth, PeiMemoryCap >> 10)); DEBUG_INFO,
"%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
__FUNCTION__,
mPhysMemAddressWidth,
PeiMemoryCap >> 10
));
// //
// Determine the range of memory to use during PEI // Determine the range of memory to use during PEI
@ -416,7 +426,6 @@ PublishPeiMemory (
return Status; return Status;
} }
/** /**
Peform Memory Detection for QEMU / KVM Peform Memory Detection for QEMU / KVM
@ -473,8 +482,11 @@ QemuInitializeRam (
TsegSize = mQ35TsegMbytes * SIZE_1MB; TsegSize = mQ35TsegMbytes * SIZE_1MB;
AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize);
AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize, AddReservedMemoryBaseSizeHob (
TRUE); LowerMemorySize - TsegSize,
TsegSize,
TRUE
);
} else { } else {
AddMemoryRangeHob (BASE_1MB, LowerMemorySize); AddMemoryRangeHob (BASE_1MB, LowerMemorySize);
} }
@ -516,16 +528,22 @@ QemuInitializeRam (
// //
// Set memory range from 640KB to 1MB to uncacheable // Set memory range from 640KB to 1MB to uncacheable
// //
Status = MtrrSetMemoryAttribute (BASE_512KB + BASE_128KB, Status = MtrrSetMemoryAttribute (
BASE_1MB - (BASE_512KB + BASE_128KB), CacheUncacheable); BASE_512KB + BASE_128KB,
BASE_1MB - (BASE_512KB + BASE_128KB),
CacheUncacheable
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Set memory range from the "top of lower RAM" (RAM below 4GB) to 4GB as // Set memory range from the "top of lower RAM" (RAM below 4GB) to 4GB as
// uncacheable // uncacheable
// //
Status = MtrrSetMemoryAttribute (LowerMemorySize, Status = MtrrSetMemoryAttribute (
SIZE_4GB - LowerMemorySize, CacheUncacheable); LowerMemorySize,
SIZE_4GB - LowerMemorySize,
CacheUncacheable
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
} }
@ -541,7 +559,7 @@ InitializeRamRegions (
{ {
QemuInitializeRam (); QemuInitializeRam ();
if (mS3Supported && mBootMode != BOOT_ON_S3_RESUME) { if (mS3Supported && (mBootMode != BOOT_ON_S3_RESUME)) {
// //
// This is the memory range that will be used for PEI on S3 resume // This is the memory range that will be used for PEI on S3 resume
// //

View File

@ -47,7 +47,6 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
{ EfiMaxMemoryType, 0x000 } { EfiMaxMemoryType, 0x000 }
}; };
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@ -56,7 +55,6 @@ EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
} }
}; };
UINT16 mHostBridgeDevId; UINT16 mHostBridgeDevId;
EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION; EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
@ -115,7 +113,6 @@ AddIoMemoryRangeHob (
AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
} }
VOID VOID
AddMemoryBaseSizeHob ( AddMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase, EFI_PHYSICAL_ADDRESS MemoryBase,
@ -136,7 +133,6 @@ AddMemoryBaseSizeHob (
); );
} }
VOID VOID
AddMemoryRangeHob ( AddMemoryRangeHob (
EFI_PHYSICAL_ADDRESS MemoryBase, EFI_PHYSICAL_ADDRESS MemoryBase,
@ -146,7 +142,6 @@ AddMemoryRangeHob (
AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
} }
VOID VOID
MemMapInitialization ( MemMapInitialization (
VOID VOID
@ -192,9 +187,10 @@ MemMapInitialization (
PciBase = (UINT32)(PciExBarBase + SIZE_256MB); PciBase = (UINT32)(PciExBarBase + SIZE_256MB);
} else { } else {
PciBase = (UINT32)PcdGet64 (PcdPciMmio32Base); PciBase = (UINT32)PcdGet64 (PcdPciMmio32Base);
if (PciBase == 0) if (PciBase == 0) {
PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam; PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;
} }
}
// //
// address purpose size // address purpose size
@ -242,9 +238,13 @@ MemMapInitialization (
// uncacheable reserved memory right here. // uncacheable reserved memory right here.
// //
AddReservedMemoryBaseSizeHob (PciExBarBase, SIZE_256MB, FALSE); AddReservedMemoryBaseSizeHob (PciExBarBase, SIZE_256MB, FALSE);
BuildMemoryAllocationHob (PciExBarBase, SIZE_256MB, BuildMemoryAllocationHob (
EfiReservedMemoryType); PciExBarBase,
SIZE_256MB,
EfiReservedMemoryType
);
} }
AddIoMemoryBaseSizeHob (PcdGet32 (PcdCpuLocalApicBaseAddress), SIZE_1MB); AddIoMemoryBaseSizeHob (PcdGet32 (PcdCpuLocalApicBaseAddress), SIZE_1MB);
// //
@ -370,11 +370,16 @@ MiscInitialization (
AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN; AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN;
break; break;
default: default:
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", DEBUG ((
__FUNCTION__, mHostBridgeDevId)); DEBUG_ERROR,
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
__FUNCTION__,
mHostBridgeDevId
));
ASSERT (FALSE); ASSERT (FALSE);
return; return;
} }
PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, mHostBridgeDevId); PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, mHostBridgeDevId);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
@ -417,7 +422,6 @@ MiscInitialization (
} }
} }
VOID VOID
BootModeInitialization ( BootModeInitialization (
VOID VOID
@ -428,6 +432,7 @@ BootModeInitialization (
if (CmosRead8 (0xF) == 0xFE) { if (CmosRead8 (0xF) == 0xFE) {
mBootMode = BOOT_ON_S3_RESUME; mBootMode = BOOT_ON_S3_RESUME;
} }
CmosWrite8 (0xF, 0x00); CmosWrite8 (0xF, 0x00);
Status = PeiServicesSetBootMode (mBootMode); Status = PeiServicesSetBootMode (mBootMode);
@ -437,7 +442,6 @@ BootModeInitialization (
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
VOID VOID
ReserveEmuVariableNvStore ( ReserveEmuVariableNvStore (
) )
@ -456,7 +460,8 @@ ReserveEmuVariableNvStore (
AllocateRuntimePages ( AllocateRuntimePages (
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
); );
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"Reserved variable store memory: 0x%lX; size: %dkb\n", "Reserved variable store memory: 0x%lX; size: %dkb\n",
VariableStore, VariableStore,
(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
@ -465,7 +470,6 @@ ReserveEmuVariableNvStore (
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
} }
VOID VOID
DebugDumpCmos ( DebugDumpCmos (
VOID VOID
@ -479,6 +483,7 @@ DebugDumpCmos (
if ((Loop % 0x10) == 0) { if ((Loop % 0x10) == 0) {
DEBUG ((DEBUG_INFO, "%02x:", Loop)); DEBUG ((DEBUG_INFO, "%02x:", Loop));
} }
DEBUG ((DEBUG_INFO, " %02x", CmosRead8 (Loop))); DEBUG ((DEBUG_INFO, " %02x", CmosRead8 (Loop)));
if ((Loop % 0x10) == 0xf) { if ((Loop % 0x10) == 0xf) {
DEBUG ((DEBUG_INFO, "\n")); DEBUG ((DEBUG_INFO, "\n"));
@ -486,7 +491,6 @@ DebugDumpCmos (
} }
} }
VOID VOID
S3Verification ( S3Verification (
VOID VOID
@ -494,20 +498,28 @@ S3Verification (
{ {
#if defined (MDE_CPU_X64) #if defined (MDE_CPU_X64)
if (FeaturePcdGet (PcdSmmSmramRequire) && mS3Supported) { if (FeaturePcdGet (PcdSmmSmramRequire) && mS3Supported) {
DEBUG ((DEBUG_ERROR, DEBUG ((
"%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n", __FUNCTION__)); DEBUG_ERROR,
DEBUG ((DEBUG_ERROR, "%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n",
__FUNCTION__
));
DEBUG ((
DEBUG_ERROR,
"%a: Please disable S3 on the QEMU command line (see the README),\n", "%a: Please disable S3 on the QEMU command line (see the README),\n",
__FUNCTION__)); __FUNCTION__
DEBUG ((DEBUG_ERROR, ));
"%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n", __FUNCTION__)); DEBUG ((
DEBUG_ERROR,
"%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n",
__FUNCTION__
));
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }
#endif #endif
} }
/** /**
Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modules. Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modules.
Set the mMaxCpuCount variable. Set the mMaxCpuCount variable.
@ -528,6 +540,7 @@ MaxCpuCountInitialization (
mMaxCpuCount = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); mMaxCpuCount = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
return; return;
} }
// //
// Otherwise, set mMaxCpuCount to the value reported by QEMU. // Otherwise, set mMaxCpuCount to the value reported by QEMU.
// //
@ -542,11 +555,14 @@ MaxCpuCountInitialization (
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
PcdStatus = PcdSet32S (PcdCpuApInitTimeOutInMicroSeconds, MAX_UINT32); PcdStatus = PcdSet32S (PcdCpuApInitTimeOutInMicroSeconds, MAX_UINT32);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processor(s)\n", __FUNCTION__, DEBUG ((
ProcessorCount)); DEBUG_INFO,
"%a: QEMU reports %d processor(s)\n",
__FUNCTION__,
ProcessorCount
));
} }
/** /**
Perform Platform PEI initialization. Perform Platform PEI initialization.
@ -596,6 +612,7 @@ InitializePlatform (
if (!FeaturePcdGet (PcdSmmSmramRequire)) { if (!FeaturePcdGet (PcdSmmSmramRequire)) {
ReserveEmuVariableNvStore (); ReserveEmuVariableNvStore ();
} }
PeiFvInitialization (); PeiFvInitialization ();
MemMapInitialization (); MemMapInitialization ();
NoexecDxeInitialization (); NoexecDxeInitialization ();

View File

@ -26,16 +26,15 @@ GetBhyveSmbiosTables (
for (BhyveSmbiosPtr = (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_ADDRESS; for (BhyveSmbiosPtr = (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_ADDRESS;
BhyveSmbiosPtr < (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_END; BhyveSmbiosPtr < (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_END;
BhyveSmbiosPtr += 0x10) { BhyveSmbiosPtr += 0x10)
{
BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)BhyveSmbiosPtr; BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)BhyveSmbiosPtr;
if (!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) && if (!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) && !AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure)) { IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure))
{
return BhyveSmbiosEntryPointStructure; return BhyveSmbiosEntryPointStructure;
} }
} }

View File

@ -58,7 +58,6 @@ STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
TYPE0_STRINGS TYPE0_STRINGS
}; };
/** /**
Validates the SMBIOS entry point structure Validates the SMBIOS entry point structure
@ -93,7 +92,6 @@ IsEntryPointStructureValid (
} }
} }
/** /**
Get SMBIOS record length. Get SMBIOS record length.
@ -116,12 +114,12 @@ SmbiosTableLength (
while ((*AChar != 0) || (*(AChar + 1) != 0)) { while ((*AChar != 0) || (*(AChar + 1) != 0)) {
AChar++; AChar++;
} }
Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2); Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);
return Length; return Length;
} }
/** /**
Install all structures from the given SMBIOS structures block Install all structures from the given SMBIOS structures block
@ -187,7 +185,6 @@ InstallAllStructures (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Installs SMBIOS information for OVMF Installs SMBIOS information for OVMF

View File

@ -21,7 +21,6 @@
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
/** /**
Locates the bhyve SMBIOS data if it exists Locates the bhyve SMBIOS data if it exists
@ -33,7 +32,6 @@ GetBhyveSmbiosTables (
VOID VOID
); );
/** /**
Validates the SMBIOS entry point structure Validates the SMBIOS entry point structure

View File

@ -74,18 +74,21 @@ GetCompatEntryPoint (
PeCompatEnd = (UINTN)(VOID *)PeCompat + Section->Misc.VirtualSize; PeCompatEnd = (UINTN)(VOID *)PeCompat + Section->Misc.VirtualSize;
while (PeCompat->Type != 0 && (UINTN)(VOID *)PeCompat < PeCompatEnd) { while (PeCompat->Type != 0 && (UINTN)(VOID *)PeCompat < PeCompatEnd) {
if (PeCompat->Type == 1 && if ((PeCompat->Type == 1) &&
PeCompat->Size >= sizeof (PE_COMPAT_TYPE1) && (PeCompat->Size >= sizeof (PE_COMPAT_TYPE1)) &&
EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCompat->MachineType)) { EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCompat->MachineType))
{
return (EFI_IMAGE_ENTRY_POINT)((UINTN)ImageBase + PeCompat->EntryPoint); return (EFI_IMAGE_ENTRY_POINT)((UINTN)ImageBase + PeCompat->EntryPoint);
} }
PeCompat = (PE_COMPAT_TYPE1 *)((UINTN)PeCompat + PeCompat->Size); PeCompat = (PE_COMPAT_TYPE1 *)((UINTN)PeCompat + PeCompat->Size);
ASSERT ((UINTN)(VOID *)PeCompat < PeCompatEnd); ASSERT ((UINTN)(VOID *)PeCompat < PeCompatEnd);
} }
} }
Section++; Section++;
} }
return NULL; return NULL;
} }
@ -136,8 +139,10 @@ CompatImageLoaderDxeEntryPoint (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
return gBS->InstallProtocolInterface (&ImageHandle, return gBS->InstallProtocolInterface (
&ImageHandle,
&gEdkiiPeCoffImageEmulatorProtocolGuid, &gEdkiiPeCoffImageEmulatorProtocolGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
&mCompatLoaderPeCoffEmuProtocol); &mCompatLoaderPeCoffEmuProtocol
);
} }

View File

@ -123,14 +123,21 @@ ProcessHotAddedCpus (
// //
for (CheckSlot = 0; for (CheckSlot = 0;
CheckSlot < mCpuHotPlugData->ArrayLength; CheckSlot < mCpuHotPlugData->ArrayLength;
CheckSlot++) { CheckSlot++)
{
if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) { if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) {
break; break;
} }
} }
if (CheckSlot < mCpuHotPlugData->ArrayLength) { if (CheckSlot < mCpuHotPlugData->ArrayLength) {
DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " DEBUG ((
"before; ignoring it\n", __FUNCTION__, NewApicId)); DEBUG_VERBOSE,
"%a: APIC ID " FMT_APIC_ID " was hot-plugged "
"before; ignoring it\n",
__FUNCTION__,
NewApicId
));
PluggedIdx++; PluggedIdx++;
continue; continue;
} }
@ -139,12 +146,18 @@ ProcessHotAddedCpus (
// Find the first empty slot in CPU_HOT_PLUG_DATA. // Find the first empty slot in CPU_HOT_PLUG_DATA.
// //
while (NewSlot < mCpuHotPlugData->ArrayLength && while (NewSlot < mCpuHotPlugData->ArrayLength &&
mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64) { mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64)
{
NewSlot++; NewSlot++;
} }
if (NewSlot == mCpuHotPlugData->ArrayLength) { if (NewSlot == mCpuHotPlugData->ArrayLength) {
DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", DEBUG ((
__FUNCTION__, NewApicId)); DEBUG_ERROR,
"%a: no room for APIC ID " FMT_APIC_ID "\n",
__FUNCTION__,
NewApicId
));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -156,8 +169,11 @@ ProcessHotAddedCpus (
// //
// Relocate the SMBASE of the new CPU. // Relocate the SMBASE of the new CPU.
// //
Status = SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], Status = SmbaseRelocate (
mPostSmmPenAddress); NewApicId,
mCpuHotPlugData->SmBase[NewSlot],
mPostSmmPenAddress
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto RevokeNewSlot; goto RevokeNewSlot;
} }
@ -165,18 +181,31 @@ ProcessHotAddedCpus (
// //
// Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL.
// //
Status = mMmCpuService->AddProcessor (mMmCpuService, NewApicId, Status = mMmCpuService->AddProcessor (
&NewProcessorNumberByProtocol); mMmCpuService,
NewApicId,
&NewProcessorNumberByProtocol
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", DEBUG ((
__FUNCTION__, NewApicId, Status)); DEBUG_ERROR,
"%a: AddProcessor(" FMT_APIC_ID "): %r\n",
__FUNCTION__,
NewApicId,
Status
));
goto RevokeNewSlot; goto RevokeNewSlot;
} }
DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, " DEBUG ((
"EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, DEBUG_INFO,
NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, "
(UINT64)NewProcessorNumberByProtocol)); "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n",
__FUNCTION__,
NewApicId,
(UINT64)mCpuHotPlugData->SmBase[NewSlot],
(UINT64)NewProcessorNumberByProtocol
));
NewSlot++; NewSlot++;
PluggedIdx++; PluggedIdx++;
@ -277,8 +306,14 @@ EjectCpu (
mCpuHotEjectData->QemuSelectorMap[Idx] = mCpuHotEjectData->QemuSelectorMap[Idx] =
CPU_EJECT_QEMU_SELECTOR_INVALID; CPU_EJECT_QEMU_SELECTOR_INVALID;
DEBUG ((DEBUG_INFO, "%a: Unplugged ProcessorNum %u, " DEBUG ((
"QemuSelector %Lu\n", __FUNCTION__, Idx, QemuSelector)); DEBUG_INFO,
"%a: Unplugged ProcessorNum %u, "
"QemuSelector %Lu\n",
__FUNCTION__,
Idx,
QemuSelector
));
} }
} }
@ -404,7 +439,8 @@ UnplugCpus (
for (ProcessorNum = 0; for (ProcessorNum = 0;
ProcessorNum < mCpuHotPlugData->ArrayLength; ProcessorNum < mCpuHotPlugData->ArrayLength;
ProcessorNum++) { ProcessorNum++)
{
if (mCpuHotPlugData->ApicId[ProcessorNum] == RemoveApicId) { if (mCpuHotPlugData->ApicId[ProcessorNum] == RemoveApicId) {
break; break;
} }
@ -414,8 +450,13 @@ UnplugCpus (
// Ignore the unplug if APIC ID not found // Ignore the unplug if APIC ID not found
// //
if (ProcessorNum == mCpuHotPlugData->ArrayLength) { if (ProcessorNum == mCpuHotPlugData->ArrayLength) {
DEBUG ((DEBUG_VERBOSE, "%a: did not find APIC ID " FMT_APIC_ID DEBUG ((
" to unplug\n", __FUNCTION__, RemoveApicId)); DEBUG_VERBOSE,
"%a: did not find APIC ID " FMT_APIC_ID
" to unplug\n",
__FUNCTION__,
RemoveApicId
));
ToUnplugIdx++; ToUnplugIdx++;
continue; continue;
} }
@ -425,13 +466,19 @@ UnplugCpus (
// //
Status = mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum); Status = mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", DEBUG ((
__FUNCTION__, RemoveApicId, Status)); DEBUG_ERROR,
"%a: RemoveProcessor(" FMT_APIC_ID "): %r\n",
__FUNCTION__,
RemoveApicId,
Status
));
return Status; return Status;
} }
if (mCpuHotEjectData->QemuSelectorMap[ProcessorNum] != if (mCpuHotEjectData->QemuSelectorMap[ProcessorNum] !=
CPU_EJECT_QEMU_SELECTOR_INVALID) { CPU_EJECT_QEMU_SELECTOR_INVALID)
{
// //
// mCpuHotEjectData->QemuSelectorMap[ProcessorNum] is set to // mCpuHotEjectData->QemuSelectorMap[ProcessorNum] is set to
// CPU_EJECT_QEMU_SELECTOR_INVALID when mCpuHotEjectData->QemuSelectorMap // CPU_EJECT_QEMU_SELECTOR_INVALID when mCpuHotEjectData->QemuSelectorMap
@ -442,9 +489,15 @@ UnplugCpus (
// never match more than one APIC ID -- nor, by transitivity, designate // never match more than one APIC ID -- nor, by transitivity, designate
// more than one QemuSelector -- in a single invocation of UnplugCpus(). // more than one QemuSelector -- in a single invocation of UnplugCpus().
// //
DEBUG ((DEBUG_ERROR, "%a: ProcessorNum %Lu maps to QemuSelector %Lu, " DEBUG ((
"cannot also map to %u\n", __FUNCTION__, (UINT64)ProcessorNum, DEBUG_ERROR,
mCpuHotEjectData->QemuSelectorMap[ProcessorNum], QemuSelector)); "%a: ProcessorNum %Lu maps to QemuSelector %Lu, "
"cannot also map to %u\n",
__FUNCTION__,
(UINT64)ProcessorNum,
mCpuHotEjectData->QemuSelectorMap[ProcessorNum],
QemuSelector
));
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
@ -454,9 +507,15 @@ UnplugCpus (
// //
mCpuHotEjectData->QemuSelectorMap[ProcessorNum] = (UINT64)QemuSelector; mCpuHotEjectData->QemuSelectorMap[ProcessorNum] = (UINT64)QemuSelector;
DEBUG ((DEBUG_INFO, "%a: Started hot-unplug on ProcessorNum %Lu, APIC ID " DEBUG ((
FMT_APIC_ID ", QemuSelector %u\n", __FUNCTION__, (UINT64)ProcessorNum, DEBUG_INFO,
RemoveApicId, QemuSelector)); "%a: Started hot-unplug on ProcessorNum %Lu, APIC ID "
FMT_APIC_ID ", QemuSelector %u\n",
__FUNCTION__,
(UINT64)ProcessorNum,
RemoveApicId,
QemuSelector
));
EjectCount++; EjectCount++;
ToUnplugIdx++; ToUnplugIdx++;
@ -565,11 +624,20 @@ CpuHotplugMmi (
// Read the MMI command value from the APM Control Port, to see if this is an // Read the MMI command value from the APM Control Port, to see if this is an
// MMI we should care about. // MMI we should care about.
// //
Status = mMmCpuIo->Io.Read (mMmCpuIo, MM_IO_UINT8, ICH9_APM_CNT, 1, Status = mMmCpuIo->Io.Read (
&ApmControl); mMmCpuIo,
MM_IO_UINT8,
ICH9_APM_CNT,
1,
&ApmControl
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to read ICH9_APM_CNT: %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_ERROR,
"%a: failed to read ICH9_APM_CNT: %r\n",
__FUNCTION__,
Status
));
// //
// We couldn't even determine if the MMI was for us or not. // We couldn't even determine if the MMI was for us or not.
// //
@ -628,7 +696,6 @@ Fatal:
return EFI_INTERRUPT_PENDING; return EFI_INTERRUPT_PENDING;
} }
// //
// Entry point function of this driver. // Entry point function of this driver.
// //
@ -663,17 +730,28 @@ CpuHotplugEntry (
// First, collect the protocols needed later. All of these protocols are // First, collect the protocols needed later. All of these protocols are
// listed in our module DEPEX. // listed in our module DEPEX.
// //
Status = gMmst->MmLocateProtocol (&gEfiMmCpuIoProtocolGuid, Status = gMmst->MmLocateProtocol (
NULL /* Registration */, (VOID **)&mMmCpuIo); &gEfiMmCpuIoProtocolGuid,
NULL /* Registration */,
(VOID **)&mMmCpuIo
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: locate MmCpuIo: %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: locate MmCpuIo: %r\n", __FUNCTION__, Status));
goto Fatal; goto Fatal;
} }
Status = gMmst->MmLocateProtocol (&gEfiSmmCpuServiceProtocolGuid,
NULL /* Registration */, (VOID **)&mMmCpuService); Status = gMmst->MmLocateProtocol (
&gEfiSmmCpuServiceProtocolGuid,
NULL /* Registration */,
(VOID **)&mMmCpuService
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: locate MmCpuService: %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_ERROR,
"%a: locate MmCpuService: %r\n",
__FUNCTION__,
Status
));
goto Fatal; goto Fatal;
} }
@ -692,6 +770,7 @@ CpuHotplugEntry (
DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_PLUG_DATA: %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_PLUG_DATA: %r\n", __FUNCTION__, Status));
goto Fatal; goto Fatal;
} }
// //
// If the possible CPU count is 1, there's nothing for this driver to do. // If the possible CPU count is 1, there's nothing for this driver to do.
// //
@ -706,6 +785,7 @@ CpuHotplugEntry (
} else { } else {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_EJECT_DATA: %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_EJECT_DATA: %r\n", __FUNCTION__, Status));
goto Fatal; goto Fatal;
@ -716,25 +796,38 @@ CpuHotplugEntry (
// //
if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Len)) || if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Len)) ||
RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Len, &Size)) || RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Len, &Size)) ||
RETURN_ERROR (SafeUintnMult (sizeof (UINT32), Len, &SizeSel))) { RETURN_ERROR (SafeUintnMult (sizeof (UINT32), Len, &SizeSel)))
{
Status = EFI_ABORTED; Status = EFI_ABORTED;
DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_PLUG_DATA\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_PLUG_DATA\n", __FUNCTION__));
goto Fatal; goto Fatal;
} }
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, Size,
(VOID **)&mPluggedApicIds); Status = gMmst->MmAllocatePool (
EfiRuntimeServicesData,
Size,
(VOID **)&mPluggedApicIds
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
goto Fatal; goto Fatal;
} }
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, Size,
(VOID **)&mToUnplugApicIds); Status = gMmst->MmAllocatePool (
EfiRuntimeServicesData,
Size,
(VOID **)&mToUnplugApicIds
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
goto ReleasePluggedApicIds; goto ReleasePluggedApicIds;
} }
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, SizeSel,
(VOID **)&mToUnplugSelectors); Status = gMmst->MmAllocatePool (
EfiRuntimeServicesData,
SizeSel,
(VOID **)&mToUnplugSelectors
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
goto ReleaseToUnplugApicIds; goto ReleaseToUnplugApicIds;
@ -743,8 +836,10 @@ CpuHotplugEntry (
// //
// Allocate the Post-SMM Pen for hot-added CPUs. // Allocate the Post-SMM Pen for hot-added CPUs.
// //
Status = SmbaseAllocatePostSmmPen (&mPostSmmPenAddress, Status = SmbaseAllocatePostSmmPen (
SystemTable->BootServices); &mPostSmmPenAddress,
SystemTable->BootServices
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto ReleaseToUnplugSelectors; goto ReleaseToUnplugSelectors;
} }
@ -776,8 +871,12 @@ CpuHotplugEntry (
QemuCpuhpWriteCommand (mMmCpuIo, QEMU_CPUHP_CMD_GET_PENDING); QemuCpuhpWriteCommand (mMmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);
if (QemuCpuhpReadCommandData2 (mMmCpuIo) != 0) { if (QemuCpuhpReadCommandData2 (mMmCpuIo) != 0) {
Status = EFI_NOT_FOUND; Status = EFI_NOT_FOUND;
DEBUG ((DEBUG_ERROR, "%a: modern CPU hotplug interface: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_ERROR,
"%a: modern CPU hotplug interface: %r\n",
__FUNCTION__,
Status
));
goto ReleasePostSmmPen; goto ReleasePostSmmPen;
} }
@ -790,8 +889,12 @@ CpuHotplugEntry (
&mDispatchHandle &mDispatchHandle
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: MmiHandlerRegister(): %r\n", __FUNCTION__, DEBUG ((
Status)); DEBUG_ERROR,
"%a: MmiHandlerRegister(): %r\n",
__FUNCTION__,
Status
));
goto ReleasePostSmmPen; goto ReleasePostSmmPen;
} }

View File

@ -40,6 +40,7 @@ QemuCpuhpReadCommandData2 (
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }
return CommandData2; return CommandData2;
} }
@ -64,6 +65,7 @@ QemuCpuhpReadCpuStatus (
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }
return CpuStatus; return CpuStatus;
} }
@ -88,6 +90,7 @@ QemuCpuhpReadCommandData (
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }
return CommandData; return CommandData;
} }
@ -218,7 +221,7 @@ QemuCpuhpCollectApicIds (
{ {
UINT32 CurrentSelector; UINT32 CurrentSelector;
if (PossibleCpuCount == 0 || ApicIdCount == 0) { if ((PossibleCpuCount == 0) || (ApicIdCount == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -259,10 +262,17 @@ QemuCpuhpCollectApicIds (
QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_PENDING); QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);
PendingSelector = QemuCpuhpReadCommandData (MmCpuIo); PendingSelector = QemuCpuhpReadCommandData (MmCpuIo);
if (PendingSelector < CurrentSelector) { if (PendingSelector < CurrentSelector) {
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u PendingSelector=%u: " DEBUG ((
"wrap-around\n", __FUNCTION__, CurrentSelector, PendingSelector)); DEBUG_VERBOSE,
"%a: CurrentSelector=%u PendingSelector=%u: "
"wrap-around\n",
__FUNCTION__,
CurrentSelector,
PendingSelector
));
break; break;
} }
CurrentSelector = PendingSelector; CurrentSelector = PendingSelector;
// //
@ -274,16 +284,26 @@ QemuCpuhpCollectApicIds (
// The "insert" event guarantees the "enabled" status; plus it excludes // The "insert" event guarantees the "enabled" status; plus it excludes
// the "fw_remove" event. // the "fw_remove" event.
// //
if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0 || if (((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0) ||
(CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) != 0) { ((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) != 0))
DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=%u CpuStatus=0x%x: " {
"inconsistent CPU status\n", __FUNCTION__, CurrentSelector, DEBUG ((
CpuStatus)); DEBUG_ERROR,
"%a: CurrentSelector=%u CpuStatus=0x%x: "
"inconsistent CPU status\n",
__FUNCTION__,
CurrentSelector,
CpuStatus
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: insert\n", __FUNCTION__, DEBUG ((
CurrentSelector)); DEBUG_VERBOSE,
"%a: CurrentSelector=%u: insert\n",
__FUNCTION__,
CurrentSelector
));
ExtendIds = PluggedApicIds; ExtendIds = PluggedApicIds;
ExtendSels = NULL; ExtendSels = NULL;
@ -293,14 +313,23 @@ QemuCpuhpCollectApicIds (
// "fw_remove" event guarantees "enabled". // "fw_remove" event guarantees "enabled".
// //
if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0) { if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0) {
DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=%u CpuStatus=0x%x: " DEBUG ((
"inconsistent CPU status\n", __FUNCTION__, CurrentSelector, DEBUG_ERROR,
CpuStatus)); "%a: CurrentSelector=%u CpuStatus=0x%x: "
"inconsistent CPU status\n",
__FUNCTION__,
CurrentSelector,
CpuStatus
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: fw_remove\n", DEBUG ((
__FUNCTION__, CurrentSelector)); DEBUG_VERBOSE,
"%a: CurrentSelector=%u: fw_remove\n",
__FUNCTION__,
CurrentSelector
));
ExtendIds = ToUnplugApicIds; ExtendIds = ToUnplugApicIds;
ExtendSels = ToUnplugSelectors; ExtendSels = ToUnplugSelectors;
@ -309,15 +338,23 @@ QemuCpuhpCollectApicIds (
// //
// Let the OSPM deal with the "remove" event. // Let the OSPM deal with the "remove" event.
// //
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: remove (ignored)\n", DEBUG ((
__FUNCTION__, CurrentSelector)); DEBUG_VERBOSE,
"%a: CurrentSelector=%u: remove (ignored)\n",
__FUNCTION__,
CurrentSelector
));
ExtendIds = NULL; ExtendIds = NULL;
ExtendSels = NULL; ExtendSels = NULL;
ExtendCount = NULL; ExtendCount = NULL;
} else { } else {
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: no event\n", DEBUG ((
__FUNCTION__, CurrentSelector)); DEBUG_VERBOSE,
"%a: CurrentSelector=%u: no event\n",
__FUNCTION__,
CurrentSelector
));
break; break;
} }
@ -334,15 +371,22 @@ QemuCpuhpCollectApicIds (
DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__));
return EFI_BUFFER_TOO_SMALL; return EFI_BUFFER_TOO_SMALL;
} }
QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID);
NewApicId = QemuCpuhpReadCommandData (MmCpuIo); NewApicId = QemuCpuhpReadCommandData (MmCpuIo);
DEBUG ((DEBUG_VERBOSE, "%a: ApicId=" FMT_APIC_ID "\n", __FUNCTION__, DEBUG ((
NewApicId)); DEBUG_VERBOSE,
"%a: ApicId=" FMT_APIC_ID "\n",
__FUNCTION__,
NewApicId
));
if (ExtendSels != NULL) { if (ExtendSels != NULL) {
ExtendSels[(*ExtendCount)] = CurrentSelector; ExtendSels[(*ExtendCount)] = CurrentSelector;
} }
ExtendIds[(*ExtendCount)++] = NewApicId; ExtendIds[(*ExtendCount)++] = NewApicId;
} }
// //
// We've processed the CPU with (known) pending events, but we must never // We've processed the CPU with (known) pending events, but we must never
// clear events. Therefore we need to advance past this CPU manually; // clear events. Therefore we need to advance past this CPU manually;
@ -352,7 +396,12 @@ QemuCpuhpCollectApicIds (
CurrentSelector++; CurrentSelector++;
} while (CurrentSelector < PossibleCpuCount); } while (CurrentSelector < PossibleCpuCount);
DEBUG ((DEBUG_VERBOSE, "%a: PluggedCount=%u ToUnplugCount=%u\n", DEBUG ((
__FUNCTION__, *PluggedCount, *ToUnplugCount)); DEBUG_VERBOSE,
"%a: PluggedCount=%u ToUnplugCount=%u\n",
__FUNCTION__,
*PluggedCount,
*ToUnplugCount
));
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -59,14 +59,23 @@ SmbaseAllocatePostSmmPen (
// //
if (mPostSmmPenSize >= EFI_PAGE_SIZE) { if (mPostSmmPenSize >= EFI_PAGE_SIZE) {
Status = EFI_BAD_BUFFER_SIZE; Status = EFI_BAD_BUFFER_SIZE;
DEBUG ((DEBUG_ERROR, "%a: mPostSmmPenSize=%u: %r\n", __FUNCTION__, DEBUG ((
mPostSmmPenSize, Status)); DEBUG_ERROR,
"%a: mPostSmmPenSize=%u: %r\n",
__FUNCTION__,
mPostSmmPenSize,
Status
));
return Status; return Status;
} }
Address = BASE_1MB - 1; Address = BASE_1MB - 1;
Status = BootServices->AllocatePages (AllocateMaxAddress, Status = BootServices->AllocatePages (
EfiReservedMemoryType, 1, &Address); AllocateMaxAddress,
EfiReservedMemoryType,
1,
&Address
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: AllocatePages(): %r\n", __FUNCTION__, Status)); DEBUG ((DEBUG_ERROR, "%a: AllocatePages(): %r\n", __FUNCTION__, Status));
return Status; return Status;
@ -135,8 +144,11 @@ SmbaseInstallFirstSmiHandler (
{ {
FIRST_SMI_HANDLER_CONTEXT *Context; FIRST_SMI_HANDLER_CONTEXT *Context;
CopyMem ((VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET), CopyMem (
mFirstSmiHandler, mFirstSmiHandlerSize); (VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
mFirstSmiHandler,
mFirstSmiHandlerSize
);
Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE; Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
Context->ApicIdGate = MAX_UINT64; Context->ApicIdGate = MAX_UINT64;
@ -196,8 +208,14 @@ SmbaseRelocate (
if (Smbase > MAX_UINT32) { if (Smbase > MAX_UINT32) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n", DEBUG ((
__FUNCTION__, ApicId, (UINT64)Smbase, Status)); DEBUG_ERROR,
"%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n",
__FUNCTION__,
ApicId,
(UINT64)Smbase,
Status
));
return Status; return Status;
} }
@ -261,12 +279,21 @@ SmbaseRelocate (
// //
// Un-gate SMBASE relocation for the hot-added CPU whose APIC ID is ApicId. // Un-gate SMBASE relocation for the hot-added CPU whose APIC ID is ApicId.
// //
ExchangeResult = InterlockedCompareExchange64 (&Context->ApicIdGate, ExchangeResult = InterlockedCompareExchange64 (
MAX_UINT64, ApicId); &Context->ApicIdGate,
MAX_UINT64,
ApicId
);
if (ExchangeResult != MAX_UINT64) { if (ExchangeResult != MAX_UINT64) {
Status = EFI_PROTOCOL_ERROR; Status = EFI_PROTOCOL_ERROR;
DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n", DEBUG ((
__FUNCTION__, ApicId, ExchangeResult, Status)); DEBUG_ERROR,
"%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n",
__FUNCTION__,
ApicId,
ExchangeResult,
Status
));
return Status; return Status;
} }

View File

@ -95,6 +95,7 @@ AllocateZeroPages (
return Buffer; return Buffer;
} }
/** /**
Callback function executed when the EndOfDxe event group is signaled. Callback function executed when the EndOfDxe event group is signaled.
@ -209,6 +210,7 @@ CpuS3DataInitialize (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;
// //

View File

@ -154,6 +154,7 @@ BiosVideoDriverBindingSupported (
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
} }
// //
// See if this is a PCI Graphics Controller by looking at the Command register and // See if this is a PCI Graphics Controller by looking at the Command register and
// Class Code Register // Class Code Register
@ -171,8 +172,7 @@ BiosVideoDriverBindingSupported (
} }
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
if (Pci.Hdr.ClassCode[2] == 0x03 || (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01)) { if ((Pci.Hdr.ClassCode[2] == 0x03) || ((Pci.Hdr.ClassCode[2] == 0x00) && (Pci.Hdr.ClassCode[1] == 0x01))) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
// //
// If this is a graphics controller, // If this is a graphics controller,
@ -189,9 +189,10 @@ BiosVideoDriverBindingSupported (
// If RemainingDevicePath isn't the End of Device Path Node, // If RemainingDevicePath isn't the End of Device Path Node,
// check its validation // check its validation
// //
if (Node->DevPath.Type != ACPI_DEVICE_PATH || if ((Node->DevPath.Type != ACPI_DEVICE_PATH) ||
Node->DevPath.SubType != ACPI_ADR_DP || (Node->DevPath.SubType != ACPI_ADR_DP) ||
DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) { (DevicePathNodeLength (&Node->DevPath) < sizeof (ACPI_ADR_DEVICE_PATH)))
{
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
} }
@ -209,7 +210,6 @@ Done:
return Status; return Status;
} }
/** /**
Install Graphics Output Protocol onto VGA device handles. Install Graphics Output Protocol onto VGA device handles.
@ -292,6 +292,7 @@ BiosVideoDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
mPciAttributesSaved = TRUE; mPciAttributesSaved = TRUE;
} }
@ -309,7 +310,7 @@ BiosVideoDriverBindingStart (
} }
Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16); Supports &= (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16);
if (Supports == 0 || Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16)) { if ((Supports == 0) || (Supports == (EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_VGA_IO_16))) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
goto Done; goto Done;
} }
@ -336,6 +337,7 @@ BiosVideoDriverBindingStart (
); );
goto Done; goto Done;
} }
// //
// Check to see if there is a legacy option ROM image associated with this PCI device // Check to see if there is a legacy option ROM image associated with this PCI device
// //
@ -349,6 +351,7 @@ BiosVideoDriverBindingStart (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
// //
// Post the legacy option ROM if it is available. // Post the legacy option ROM if it is available.
// //
@ -378,7 +381,8 @@ BiosVideoDriverBindingStart (
if (RemainingDevicePath != NULL) { if (RemainingDevicePath != NULL) {
if (IsDevicePathEnd (RemainingDevicePath) && if (IsDevicePathEnd (RemainingDevicePath) &&
(FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdBiosVideoCheckVgaEnable))) { (FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdBiosVideoCheckVgaEnable)))
{
// //
// If RemainingDevicePath is the End of Device Path Node, // If RemainingDevicePath is the End of Device Path Node,
// don't create any child device and return EFI_SUCCESS // don't create any child device and return EFI_SUCCESS
@ -425,6 +429,7 @@ Done:
); );
} }
} }
// //
// Release PCI I/O Protocols on the controller handle. // Release PCI I/O Protocols on the controller handle.
// //
@ -439,7 +444,6 @@ Done:
return Status; return Status;
} }
/** /**
Stop. Stop.
@ -516,11 +520,9 @@ BiosVideoDriverBindingStop (
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Install child handles if the Handle supports MBR format. Install child handles if the Handle supports MBR format.
@ -580,12 +582,13 @@ BiosVideoChildHandleInstall (
); );
goto Done; goto Done;
} }
BiosVideoPrivate->VgaCompatible = FALSE; BiosVideoPrivate->VgaCompatible = FALSE;
if (Pci.Hdr.ClassCode[2] == 0x00 && Pci.Hdr.ClassCode[1] == 0x01) { if ((Pci.Hdr.ClassCode[2] == 0x00) && (Pci.Hdr.ClassCode[1] == 0x01)) {
BiosVideoPrivate->VgaCompatible = TRUE; BiosVideoPrivate->VgaCompatible = TRUE;
} }
if (Pci.Hdr.ClassCode[2] == 0x03 && Pci.Hdr.ClassCode[1] == 0x00 && Pci.Hdr.ClassCode[0] == 0x00) { if ((Pci.Hdr.ClassCode[2] == 0x03) && (Pci.Hdr.ClassCode[1] == 0x00) && (Pci.Hdr.ClassCode[0] == 0x00)) {
BiosVideoPrivate->VgaCompatible = TRUE; BiosVideoPrivate->VgaCompatible = TRUE;
} }
@ -626,7 +629,6 @@ BiosVideoChildHandleInstall (
BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode; BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode;
BiosVideoPrivate->GraphicsOutput.SetMode = BiosVideoGraphicsOutputSetMode; BiosVideoPrivate->GraphicsOutput.SetMode = BiosVideoGraphicsOutputSetMode;
// //
// Allocate buffer for Graphics Output Protocol mode information // Allocate buffer for Graphics Output Protocol mode information
// //
@ -715,6 +717,7 @@ BiosVideoChildHandleInstall (
} else { } else {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
// //
// The VESA BIOS Extensions are not compatible with Graphics Output, so check for support // The VESA BIOS Extensions are not compatible with Graphics Output, so check for support
@ -740,6 +743,7 @@ BiosVideoChildHandleInstall (
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL; BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
} }
FreePool (BiosVideoPrivate->GraphicsOutput.Mode); FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
BiosVideoPrivate->GraphicsOutput.Mode = NULL; BiosVideoPrivate->GraphicsOutput.Mode = NULL;
} }
@ -789,6 +793,7 @@ BiosVideoChildHandleInstall (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
ProtocolInstalled = TRUE; ProtocolInstalled = TRUE;
} }
} }
@ -810,6 +815,7 @@ Done:
if ((BiosVideoPrivate != NULL) && (BiosVideoPrivate->ExitBootServicesEvent != NULL)) { if ((BiosVideoPrivate != NULL) && (BiosVideoPrivate->ExitBootServicesEvent != NULL)) {
gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent); gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent);
} }
// //
// Free private data structure // Free private data structure
// //
@ -819,7 +825,6 @@ Done:
return Status; return Status;
} }
/** /**
Deregister an video child handle and free resources. Deregister an video child handle and free resources.
@ -918,6 +923,7 @@ BiosVideoChildHandleUninstall (
NULL NULL
); );
} }
if (!BiosVideoPrivate->ProduceGraphicsOutput) { if (!BiosVideoPrivate->ProduceGraphicsOutput) {
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Controller, Controller,
@ -954,7 +960,6 @@ BiosVideoChildHandleUninstall (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Release resource for biso video instance. Release resource for biso video instance.
@ -980,24 +985,28 @@ BiosVideoDeviceReleaseResource (
if (BiosVideoPrivate->VgaFrameBuffer != NULL) { if (BiosVideoPrivate->VgaFrameBuffer != NULL) {
FreePool (BiosVideoPrivate->VgaFrameBuffer); FreePool (BiosVideoPrivate->VgaFrameBuffer);
} }
// //
// Free VBE Frame Buffer // Free VBE Frame Buffer
// //
if (BiosVideoPrivate->VbeFrameBuffer != NULL) { if (BiosVideoPrivate->VbeFrameBuffer != NULL) {
FreePool (BiosVideoPrivate->VbeFrameBuffer); FreePool (BiosVideoPrivate->VbeFrameBuffer);
} }
// //
// Free line buffer // Free line buffer
// //
if (BiosVideoPrivate->LineBuffer != NULL) { if (BiosVideoPrivate->LineBuffer != NULL) {
FreePool (BiosVideoPrivate->LineBuffer); FreePool (BiosVideoPrivate->LineBuffer);
} }
// //
// Free mode data // Free mode data
// //
if (BiosVideoPrivate->ModeData != NULL) { if (BiosVideoPrivate->ModeData != NULL) {
FreePool (BiosVideoPrivate->ModeData); FreePool (BiosVideoPrivate->ModeData);
} }
// //
// Free memory allocated below 1MB // Free memory allocated below 1MB
// //
@ -1017,15 +1026,18 @@ BiosVideoDeviceReleaseResource (
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL; BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
} }
FreePool (BiosVideoPrivate->GraphicsOutput.Mode); FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
BiosVideoPrivate->GraphicsOutput.Mode = NULL; BiosVideoPrivate->GraphicsOutput.Mode = NULL;
} }
// //
// Free EDID discovered protocol occupied resource // Free EDID discovered protocol occupied resource
// //
if (BiosVideoPrivate->EdidDiscovered.Edid != NULL) { if (BiosVideoPrivate->EdidDiscovered.Edid != NULL) {
FreePool (BiosVideoPrivate->EdidDiscovered.Edid); FreePool (BiosVideoPrivate->EdidDiscovered.Edid);
} }
// //
// Free EDID active protocol occupied resource // Free EDID active protocol occupied resource
// //
@ -1042,7 +1054,6 @@ BiosVideoDeviceReleaseResource (
return; return;
} }
/** /**
Generate a search key for a specified timing data. Generate a search key for a specified timing data.
@ -1065,7 +1076,6 @@ CalculateEdidKey (
return Key; return Key;
} }
/** /**
Parse the Established Timing and Standard Timing in EDID data block. Parse the Established Timing and Standard Timing in EDID data block.
@ -1103,6 +1113,7 @@ ParseEdidData (
for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index++) { for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_BLOCK_SIZE; Index++) {
CheckSum = (UINT8)(CheckSum + EdidBuffer[Index]); CheckSum = (UINT8)(CheckSum + EdidBuffer[Index]);
} }
if (CheckSum != 0) { if (CheckSum != 0) {
return FALSE; return FALSE;
} }
@ -1113,7 +1124,8 @@ ParseEdidData (
if ((EdidDataBlock->EstablishedTimings[0] != 0) || if ((EdidDataBlock->EstablishedTimings[0] != 0) ||
(EdidDataBlock->EstablishedTimings[1] != 0) || (EdidDataBlock->EstablishedTimings[1] != 0) ||
(EdidDataBlock->EstablishedTimings[2] != 0) (EdidDataBlock->EstablishedTimings[2] != 0)
) { )
{
// //
// Established timing data // Established timing data
// //
@ -1122,11 +1134,16 @@ ParseEdidData (
((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9); ((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9);
for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER; Index++) { for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER; Index++) {
if ((TimingBits & 0x1) != 0) { if ((TimingBits & 0x1) != 0) {
DEBUG ((DEBUG_INFO, "Established Timing: %d x %d\n", DEBUG ((
mEstablishedEdidTiming[Index].HorizontalResolution, mEstablishedEdidTiming[Index].VerticalResolution)); DEBUG_INFO,
"Established Timing: %d x %d\n",
mEstablishedEdidTiming[Index].HorizontalResolution,
mEstablishedEdidTiming[Index].VerticalResolution
));
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&mEstablishedEdidTiming[Index]); ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&mEstablishedEdidTiming[Index]);
ValidNumber++; ValidNumber++;
} }
TimingBits = TimingBits >> 1; TimingBits = TimingBits >> 1;
} }
} }
@ -1163,6 +1180,7 @@ ParseEdidData (
VerticalResolution = (UINT16)(HorizontalResolution / 4 * 3); VerticalResolution = (UINT16)(HorizontalResolution / 4 * 3);
break; break;
} }
RefreshRate = (UINT8)((BufferIndex[1] & 0x1f) + 60); RefreshRate = (UINT8)((BufferIndex[1] & 0x1f) + 60);
DEBUG ((DEBUG_INFO, "Standard Timing: %d x %d\n", HorizontalResolution, VerticalResolution)); DEBUG ((DEBUG_INFO, "Standard Timing: %d x %d\n", HorizontalResolution, VerticalResolution));
TempTiming.HorizontalResolution = HorizontalResolution; TempTiming.HorizontalResolution = HorizontalResolution;
@ -1171,6 +1189,7 @@ ParseEdidData (
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming); ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);
ValidNumber++; ValidNumber++;
} }
BufferIndex += 2; BufferIndex += 2;
} }
@ -1186,13 +1205,19 @@ ParseEdidData (
// //
continue; continue;
} }
// //
// Calculate Horizontal and Vertical resolution // Calculate Horizontal and Vertical resolution
// //
TempTiming.HorizontalResolution = ((UINT16)(BufferIndex[4] & 0xF0) << 4) | (BufferIndex[2]); TempTiming.HorizontalResolution = ((UINT16)(BufferIndex[4] & 0xF0) << 4) | (BufferIndex[2]);
TempTiming.VerticalResolution = ((UINT16)(BufferIndex[7] & 0xF0) << 4) | (BufferIndex[5]); TempTiming.VerticalResolution = ((UINT16)(BufferIndex[7] & 0xF0) << 4) | (BufferIndex[5]);
DEBUG ((DEBUG_INFO, "Detailed Timing %d: %d x %d\n", DEBUG ((
Index, TempTiming.HorizontalResolution, TempTiming.VerticalResolution)); DEBUG_INFO,
"Detailed Timing %d: %d x %d\n",
Index,
TempTiming.HorizontalResolution,
TempTiming.VerticalResolution
));
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming); ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);
ValidNumber++; ValidNumber++;
} }
@ -1201,7 +1226,6 @@ ParseEdidData (
return TRUE; return TRUE;
} }
/** /**
Search a specified Timing in all the valid EDID timings. Search a specified Timing in all the valid EDID timings.
@ -1367,12 +1391,14 @@ BiosVideoCheckForVbe (
if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {
return Status; return Status;
} }
// //
// Check for 'VESA' signature // Check for 'VESA' signature
// //
if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) { if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) {
return Status; return Status;
} }
// //
// Check to see if this is VBE 2.0 or higher // Check to see if this is VBE 2.0 or higher
// //
@ -1410,8 +1436,9 @@ BiosVideoCheckForVbe (
(UINT8 **)&EdidOverrideDataBlock (UINT8 **)&EdidOverrideDataBlock
); );
if (!EFI_ERROR (Status) && if (!EFI_ERROR (Status) &&
EdidAttributes == 0 && (EdidAttributes == 0) &&
EdidOverrideDataSize != 0) { (EdidOverrideDataSize != 0))
{
// //
// Succeeded to get EDID Override Data // Succeeded to get EDID Override Data
// //
@ -1419,7 +1446,7 @@ BiosVideoCheckForVbe (
} }
} }
if (!EdidOverrideFound || EdidAttributes == EFI_EDID_OVERRIDE_DONT_OVERRIDE) { if (!EdidOverrideFound || (EdidAttributes == EFI_EDID_OVERRIDE_DONT_OVERRIDE)) {
// //
// If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERRIDE returned, // If EDID Override data doesn't exist or EFI_EDID_OVERRIDE_DONT_OVERRIDE returned,
// read EDID information through INT10 call // read EDID information through INT10 call
@ -1506,13 +1533,15 @@ BiosVideoCheckForVbe (
// //
for (VbeModeNumber = ReadUnaligned16 (ModeNumberPtr); for (VbeModeNumber = ReadUnaligned16 (ModeNumberPtr);
VbeModeNumber != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST; VbeModeNumber != VESA_BIOS_EXTENSIONS_END_OF_MODE_LIST;
VbeModeNumber = ReadUnaligned16 (++ModeNumberPtr)) { VbeModeNumber = ReadUnaligned16 (++ModeNumberPtr))
{
// //
// Make sure this is a mode number defined by the VESA VBE specification. If it isn'tm then skip this mode number. // Make sure this is a mode number defined by the VESA VBE specification. If it isn'tm then skip this mode number.
// //
if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) { if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {
continue; continue;
} }
// //
// Get the information about the mode // Get the information about the mode
// //
@ -1531,24 +1560,28 @@ BiosVideoCheckForVbe (
if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) { if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {
continue; continue;
} }
// //
// See if the mode supports color. If it doesn't then try the next mode. // See if the mode supports color. If it doesn't then try the next mode.
// //
if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR) == 0) { if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_COLOR) == 0) {
continue; continue;
} }
// //
// See if the mode supports graphics. If it doesn't then try the next mode. // See if the mode supports graphics. If it doesn't then try the next mode.
// //
if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS) == 0) { if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_GRAPHICS) == 0) {
continue; continue;
} }
// //
// See if the mode supports a linear frame buffer. If it doesn't then try the next mode. // See if the mode supports a linear frame buffer. If it doesn't then try the next mode.
// //
if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER) == 0) { if ((BiosVideoPrivate->VbeModeInformationBlock->ModeAttributes & VESA_BIOS_EXTENSIONS_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER) == 0) {
continue; continue;
} }
// //
// See if the mode supports 32 bit color. If it doesn't then try the next mode. // See if the mode supports 32 bit color. If it doesn't then try the next mode.
// 32 bit mode can be implemented by 24 Bits Per Pixels. Also make sure the // 32 bit mode can be implemented by 24 Bits Per Pixels. Also make sure the
@ -1565,6 +1598,7 @@ BiosVideoCheckForVbe (
if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) != 0) { if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) != 0) {
continue; continue;
} }
// //
// See if the physical base pointer for the linear mode is valid. If it isn't then try the next mode. // See if the physical base pointer for the linear mode is valid. If it isn't then try the next mode.
// //
@ -1572,8 +1606,13 @@ BiosVideoCheckForVbe (
continue; continue;
} }
DEBUG ((DEBUG_INFO, "Video Controller Mode 0x%x: %d x %d\n", DEBUG ((
VbeModeNumber, BiosVideoPrivate->VbeModeInformationBlock->XResolution, BiosVideoPrivate->VbeModeInformationBlock->YResolution)); DEBUG_INFO,
"Video Controller Mode 0x%x: %d x %d\n",
VbeModeNumber,
BiosVideoPrivate->VbeModeInformationBlock->XResolution,
BiosVideoPrivate->VbeModeInformationBlock->YResolution
));
if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) { if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) {
// //
@ -1587,9 +1626,10 @@ BiosVideoCheckForVbe (
// but INT10 can support these modes, we add them into GOP mode. // but INT10 can support these modes, we add them into GOP mode.
// //
if ((BiosVideoPrivate->EdidDiscovered.SizeOfEdid != 0) && if ((BiosVideoPrivate->EdidDiscovered.SizeOfEdid != 0) &&
!((Timing.HorizontalResolution) == 1024 && (Timing.VerticalResolution == 768)) && !(((Timing.HorizontalResolution) == 1024) && (Timing.VerticalResolution == 768)) &&
!((Timing.HorizontalResolution) == 800 && (Timing.VerticalResolution == 600)) && !(((Timing.HorizontalResolution) == 800) && (Timing.VerticalResolution == 600)) &&
!((Timing.HorizontalResolution) == 640 && (Timing.VerticalResolution == 480))) { !(((Timing.HorizontalResolution) == 640) && (Timing.VerticalResolution == 480)))
{
continue; continue;
} }
} }
@ -1600,20 +1640,25 @@ BiosVideoCheckForVbe (
// //
ModeFound = FALSE; ModeFound = FALSE;
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024 && if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024) &&
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768 (BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768)
) { )
{
ModeFound = TRUE; ModeFound = TRUE;
} }
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800 &&
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600 if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800) &&
) { (BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600)
)
{
ModeFound = TRUE; ModeFound = TRUE;
PreferMode = ModeNumber; PreferMode = ModeNumber;
} }
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640 &&
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480 if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640) &&
) { (BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480)
)
{
ModeFound = TRUE; ModeFound = TRUE;
} }
@ -1629,7 +1674,8 @@ BiosVideoCheckForVbe (
// //
if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution > HighestHorizontalResolution) || if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution > HighestHorizontalResolution) ||
((BiosVideoPrivate->VbeModeInformationBlock->XResolution == HighestHorizontalResolution) && ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == HighestHorizontalResolution) &&
(BiosVideoPrivate->VbeModeInformationBlock->YResolution > HighestVerticalResolution))) { (BiosVideoPrivate->VbeModeInformationBlock->YResolution > HighestVerticalResolution)))
{
HighestHorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution; HighestHorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;
HighestVerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution; HighestVerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;
HighestResolutionMode = ModeNumber; HighestResolutionMode = ModeNumber;
@ -1685,7 +1731,8 @@ BiosVideoCheckForVbe (
CurrentModeData->PixelFormat = PixelBitMask; CurrentModeData->PixelFormat = PixelBitMask;
if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel == 32) && if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel == 32) &&
(CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff)) { (CurrentModeData->Red.Mask == 0xff) && (CurrentModeData->Green.Mask == 0xff) && (CurrentModeData->Blue.Mask == 0xff))
{
if ((CurrentModeData->Red.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 16)) { if ((CurrentModeData->Red.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Blue.Position == 16)) {
CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor; CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
} else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) { } else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {
@ -1711,6 +1758,7 @@ BiosVideoCheckForVbe (
BiosVideoPrivate->ModeData = ModeBuffer; BiosVideoPrivate->ModeData = ModeBuffer;
} }
// //
// Check to see if we found any modes that are compatible with GRAPHICS OUTPUT // Check to see if we found any modes that are compatible with GRAPHICS OUTPUT
// //
@ -1737,11 +1785,16 @@ BiosVideoCheckForVbe (
DEBUG_CODE ( DEBUG_CODE (
BIOS_VIDEO_MODE_DATA *ModeData; BIOS_VIDEO_MODE_DATA *ModeData;
ModeData = &BiosVideoPrivate->ModeData[HighestResolutionMode]; ModeData = &BiosVideoPrivate->ModeData[HighestResolutionMode];
DEBUG ((DEBUG_INFO, "BiosVideo set highest resolution %d x %d\n", DEBUG ((
ModeData->HorizontalResolution, ModeData->VerticalResolution)); DEBUG_INFO,
"BiosVideo set highest resolution %d x %d\n",
ModeData->HorizontalResolution,
ModeData->VerticalResolution
));
); );
PreferMode = HighestResolutionMode; PreferMode = HighestResolutionMode;
} }
Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, (UINT32)PreferMode); Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, (UINT32)PreferMode);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
for (PreferMode = 0; PreferMode < ModeNumber; PreferMode++) { for (PreferMode = 0; PreferMode < ModeNumber; PreferMode++) {
@ -1753,6 +1806,7 @@ BiosVideoCheckForVbe (
break; break;
} }
} }
if (PreferMode == ModeNumber) { if (PreferMode == ModeNumber) {
// //
// None mode is set successfully. // None mode is set successfully.
@ -1771,6 +1825,7 @@ Done:
BiosVideoPrivate->ModeData = NULL; BiosVideoPrivate->ModeData = NULL;
BiosVideoPrivate->MaxMode = 0; BiosVideoPrivate->MaxMode = 0;
} }
if (EdidOverrideDataBlock != NULL) { if (EdidOverrideDataBlock != NULL) {
FreePool (EdidOverrideDataBlock); FreePool (EdidOverrideDataBlock);
} }
@ -1779,7 +1834,6 @@ Done:
return Status; return Status;
} }
/** /**
Check for VGA device. Check for VGA device.
@ -1845,15 +1899,18 @@ Done:
FreePool (BiosVideoPrivate->ModeData); FreePool (BiosVideoPrivate->ModeData);
BiosVideoPrivate->ModeData = NULL; BiosVideoPrivate->ModeData = NULL;
} }
if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) { if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {
if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) { if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info); FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL; BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
} }
FreePool (BiosVideoPrivate->GraphicsOutput.Mode); FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
BiosVideoPrivate->GraphicsOutput.Mode = NULL; BiosVideoPrivate->GraphicsOutput.Mode = NULL;
} }
} }
return Status; return Status;
} }
@ -1901,7 +1958,7 @@ BiosVideoGraphicsOutputQueryMode (
return EFI_NOT_STARTED; return EFI_NOT_STARTED;
} }
if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) { if ((This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1967,6 +2024,7 @@ BiosVideoSetModeWorker (
if (NULL == BiosVideoPrivate->LineBuffer) { if (NULL == BiosVideoPrivate->LineBuffer) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Clear all registers // Clear all registers
// //
@ -1980,12 +2038,12 @@ BiosVideoSetModeWorker (
if (NULL == BiosVideoPrivate->VgaFrameBuffer) { if (NULL == BiosVideoPrivate->VgaFrameBuffer) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Set VGA Mode // Set VGA Mode
// //
Regs.X.AX = ModeData->VbeModeNumber; Regs.X.AX = ModeData->VbeModeNumber;
BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs); BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);
} else { } else {
// //
// Allocate a working buffer for BLT operations to the VBE frame buffer // Allocate a working buffer for BLT operations to the VBE frame buffer
@ -1997,6 +2055,7 @@ BiosVideoSetModeWorker (
if (NULL == BiosVideoPrivate->VbeFrameBuffer) { if (NULL == BiosVideoPrivate->VbeFrameBuffer) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Set VBE mode // Set VBE mode
// //
@ -2018,6 +2077,7 @@ BiosVideoSetModeWorker (
); );
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Initialize the state of the VbeFrameBuffer // Initialize the state of the VbeFrameBuffer
// //
@ -2291,9 +2351,10 @@ BiosVideoVbeBltWorker (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (Width == 0 || Height == 0) { if ((Width == 0) || (Height == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// We need to fill the Virtual Screen buffer with the blt data. // We need to fill the Virtual Screen buffer with the blt data.
// The virtual screen is upside down, as the first row is the bootom row of // The virtual screen is upside down, as the first row is the bootom row of
@ -2322,6 +2383,7 @@ BiosVideoVbeBltWorker (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// If Delta is zero, then the entire BltBuffer is being used, so Delta // If Delta is zero, then the entire BltBuffer is being used, so Delta
// is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
@ -2330,6 +2392,7 @@ BiosVideoVbeBltWorker (
if (Delta == 0) { if (Delta == 0) {
Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
} }
// //
// We have to raise to TPL Notify, so we make an atomic write the frame buffer. // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are // We would not want a timer based event (Cursor, ...) to come in while we are
@ -2354,8 +2417,8 @@ BiosVideoVbeBltWorker (
Blt++; Blt++;
VbeBuffer += VbePixelWidth; VbeBuffer += VbePixelWidth;
} }
} }
break; break;
case EfiBltVideoToVideo: case EfiBltVideoToVideo:
@ -2391,6 +2454,7 @@ BiosVideoVbeBltWorker (
BytesPerScanLine BytesPerScanLine
); );
} }
break; break;
case EfiBltVideoFill: case EfiBltVideoFill:
@ -2439,6 +2503,7 @@ BiosVideoVbeBltWorker (
BytesPerScanLine BytesPerScanLine
); );
} }
break; break;
case EfiBltBufferToVideo: case EfiBltBufferToVideo:
@ -2477,6 +2542,7 @@ BiosVideoVbeBltWorker (
BytesPerScanLine BytesPerScanLine
); );
} }
break; break;
default:; default:;
@ -2583,7 +2649,6 @@ WriteGraphicsController (
); );
} }
/** /**
Read the four bit plane of VGA frame buffer. Read the four bit plane of VGA frame buffer.
@ -2624,7 +2689,8 @@ VgaReadBitPlanes (
for (BitPlane = 0, FrameBufferOffset = 0; for (BitPlane = 0, FrameBufferOffset = 0;
BitPlane < VGA_NUMBER_OF_BIT_PLANES; BitPlane < VGA_NUMBER_OF_BIT_PLANES;
BitPlane++, FrameBufferOffset += VGA_BYTES_PER_BIT_PLANE BitPlane++, FrameBufferOffset += VGA_BYTES_PER_BIT_PLANE
) { )
{
// //
// Program the Read Map Select Register to select the correct bit plane // Program the Read Map Select Register to select the correct bit plane
// //
@ -2650,7 +2716,6 @@ VgaReadBitPlanes (
} }
} }
/** /**
Internal routine to convert VGA color to Grahpics Output color. Internal routine to convert VGA color to Grahpics Output color.
@ -2708,7 +2773,6 @@ VgaConvertColor (
return Color; return Color;
} }
/** /**
Grahpics Output protocol instance to block transfer for VGA device. Grahpics Output protocol instance to block transfer for VGA device.
@ -2780,7 +2844,7 @@ BiosVideoGraphicsOutputVgaBlt (
UINTN CoordinateY; UINTN CoordinateY;
UINTN CurrentMode; UINTN CurrentMode;
if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) { if ((This == NULL) || (((UINTN)BltOperation) >= EfiGraphicsOutputBltOperationMax)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -2792,10 +2856,10 @@ BiosVideoGraphicsOutputVgaBlt (
BytesPerScanLine = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3; BytesPerScanLine = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3;
VgaFrameBuffer = BiosVideoPrivate->VgaFrameBuffer; VgaFrameBuffer = BiosVideoPrivate->VgaFrameBuffer;
if ((Width == 0) || (Height == 0)) {
if (Width == 0 || Height == 0) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
// //
// We need to fill the Virtual Screen buffer with the blt data. // We need to fill the Virtual Screen buffer with the blt data.
// The virtual screen is upside down, as the first row is the bootom row of // The virtual screen is upside down, as the first row is the bootom row of
@ -2824,6 +2888,7 @@ BiosVideoGraphicsOutputVgaBlt (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} }
// //
// If Delta is zero, then the entire BltBuffer is being used, so Delta // If Delta is zero, then the entire BltBuffer is being used, so Delta
// is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size, // is the number of bytes in each row of BltBuffer. Since BltBuffer is Width pixels size,
@ -2832,6 +2897,7 @@ BiosVideoGraphicsOutputVgaBlt (
if (Delta == 0) { if (Delta == 0) {
Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL); Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
} }
// //
// We have to raise to TPL Notify, so we make an atomic write the frame buffer. // We have to raise to TPL Notify, so we make an atomic write the frame buffer.
// We would not want a timer based event (Cursor, ...) to come in while we are // We would not want a timer based event (Cursor, ...) to come in while we are
@ -2877,7 +2943,7 @@ BiosVideoGraphicsOutputVgaBlt (
// //
// Check for an aligned Video to Video operation // Check for an aligned Video to Video operation
// //
if ((SourceX & 0x07) == 0x00 && (DestinationX & 0x07) == 0x00 && (Width & 0x07) == 0x00) { if (((SourceX & 0x07) == 0x00) && ((DestinationX & 0x07) == 0x00) && ((Width & 0x07) == 0x00)) {
// //
// Program the Mode Register Write mode 1, Read mode 0 // Program the Mode Register Write mode 1, Read mode 0
// //
@ -3053,6 +3119,7 @@ BiosVideoGraphicsOutputVgaBlt (
); );
} }
} }
break; break;
case EfiBltBufferToVideo: case EfiBltBufferToVideo:
@ -3081,6 +3148,7 @@ BiosVideoGraphicsOutputVgaBlt (
for (Index1 = 0; Index1 < Width; Index1++) { for (Index1 = 0; Index1 < Width; Index1++) {
BiosVideoPrivate->LineBuffer[Index1] = VgaConvertColor (&BltBuffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]); BiosVideoPrivate->LineBuffer[Index1] = VgaConvertColor (&BltBuffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]);
} }
AddressFix = Address; AddressFix = Address;
for (Bit = 0; Bit < 8; Bit++) { for (Bit = 0; Bit < 8; Bit++) {
@ -3168,6 +3236,7 @@ BiosVideoVgaMiniPortSetMode (
if (ModeNumber >= This->MaxMode) { if (ModeNumber >= This->MaxMode) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
// //
// Get the device structure for this device // Get the device structure for this device
// //

View File

@ -164,7 +164,6 @@ BiosVideoDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
); );
/** /**
Install Graphics Output Protocol onto VGA device handles. Install Graphics Output Protocol onto VGA device handles.
@ -184,7 +183,6 @@ BiosVideoDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
); );
/** /**
Stop. Stop.
@ -223,7 +221,6 @@ BiosVideoCheckForVbe (
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
); );
/** /**
Check for VGA device. Check for VGA device.
@ -237,9 +234,6 @@ BiosVideoCheckForVga (
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
); );
/** /**
Release resource for BIOS video instance. Release resource for BIOS video instance.
@ -282,7 +276,6 @@ BiosVideoGraphicsOutputQueryMode (
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
); );
/** /**
Graphics Output protocol interface to set video mode. Graphics Output protocol interface to set video mode.
@ -302,7 +295,6 @@ BiosVideoGraphicsOutputSetMode (
IN UINT32 ModeNumber IN UINT32 ModeNumber
); );
/** /**
Graphics Output protocol instance to block transfer for VBE device. Graphics Output protocol instance to block transfer for VBE device.
@ -345,7 +337,6 @@ BiosVideoGraphicsOutputVbeBlt (
IN UINTN Delta IN UINTN Delta
); );
/** /**
Graphics Output protocol instance to block transfer for VGA device. Graphics Output protocol instance to block transfer for VGA device.
@ -529,4 +520,5 @@ BOOLEAN
HasChildHandle ( HasChildHandle (
IN EFI_HANDLE Controller IN EFI_HANDLE Controller
); );
#endif #endif

View File

@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
// EFI Component Name Functions // EFI Component Name Functions
// //
/** /**
Retrieves a Unicode string that is the user readable name of the driver. Retrieves a Unicode string that is the user readable name of the driver.
@ -58,7 +59,6 @@ BiosVideoComponentNameGetDriverName (
OUT CHAR16 **DriverName OUT CHAR16 **DriverName
); );
/** /**
Retrieves a Unicode string that is the user readable name of the controller Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver. that is being managed by a driver.
@ -137,7 +137,6 @@ BiosVideoComponentNameGetControllerName (
OUT CHAR16 **ControllerName OUT CHAR16 **ControllerName
); );
// //
// EFI Component Name Protocol // EFI Component Name Protocol
// //
@ -156,7 +155,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentNa
"en" "en"
}; };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = { GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = {
{ {
"eng;en", "eng;en",

View File

@ -29,4 +29,3 @@ CsmSupportLibConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -46,4 +46,3 @@ LegacyBiosPlatformInstall (
); );
#endif #endif

View File

@ -31,7 +31,6 @@ STATIC EFI_LEGACY_INTERRUPT_PROTOCOL mLegacyInterrupt = {
STATIC UINT8 PirqReg[MAX_PIRQ_NUMBER] = { PIRQA, PIRQB, PIRQC, PIRQD, PIRQE, PIRQF, PIRQG, PIRQH }; STATIC UINT8 PirqReg[MAX_PIRQ_NUMBER] = { PIRQA, PIRQB, PIRQC, PIRQD, PIRQE, PIRQF, PIRQG, PIRQH };
/** /**
Return the number of PIRQs supported by this chipset. Return the number of PIRQs supported by this chipset.
@ -53,7 +52,6 @@ GetNumberPirqs (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Return PCI location of this device. Return PCI location of this device.
$PIR table requires this info. $PIR table requires this info.
@ -82,7 +80,6 @@ GetLocation (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Builds the PCI configuration address for the register specified by PirqNumber Builds the PCI configuration address for the register specified by PirqNumber
@ -132,7 +129,6 @@ ReadPirq (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Write the given PIRQ register Write the given PIRQ register
@ -160,7 +156,6 @@ WritePirq (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Initialize Legacy Interrupt support Initialize Legacy Interrupt support
@ -192,8 +187,12 @@ LegacyInterruptInstall (
mLegacyInterruptDevice = LEGACY_INT_DEV_Q35; mLegacyInterruptDevice = LEGACY_INT_DEV_Q35;
break; break;
default: default:
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", DEBUG ((
__FUNCTION__, HostBridgeDevId)); DEBUG_ERROR,
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
__FUNCTION__,
HostBridgeDevId
));
ASSERT (FALSE); ASSERT (FALSE);
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -211,4 +210,3 @@ LegacyInterruptInstall (
return Status; return Status;
} }

View File

@ -20,7 +20,6 @@
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <OvmfPlatforms.h> #include <OvmfPlatforms.h>
#define LEGACY_INT_BUS 0 #define LEGACY_INT_BUS 0
#define LEGACY_INT_DEV_PIIX4 0x01 #define LEGACY_INT_DEV_PIIX4 0x01
#define LEGACY_INT_DEV_Q35 0x1f #define LEGACY_INT_DEV_Q35 0x1f
@ -114,4 +113,3 @@ WritePirq (
); );
#endif #endif

View File

@ -76,12 +76,24 @@ EFI_LEGACY_PIRQ_TABLE PirqTableHead = {
// -- Pin 1 -- -- Pin 2 -- -- Pin 3 -- -- Pin 4 -- // -- Pin 1 -- -- Pin 2 -- -- Pin 3 -- -- Pin 4 --
// Bus Dev Reg Map Reg Map Reg Map Reg Map // Bus Dev Reg Map Reg Map Reg Map Reg Map
// //
{0x00,0x08,{{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8}},0x00,0x00}, { 0x00, 0x08, {
{0x00,0x10,{{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8}},0x01,0x00}, { 0x60, 0xDEB8 }, { 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }
{0x00,0x18,{{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8},{0x61,0xDEB8}},0x02,0x00}, }, 0x00, 0x00 },
{0x00,0x20,{{0x63,0xDEB8},{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8}},0x03,0x00}, { 0x00, 0x10, {
{0x00,0x28,{{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8}},0x04,0x00}, { 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }, { 0x60, 0xDEB8 }
{0x00,0x30,{{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8}},0x05,0x00}, }, 0x01, 0x00 },
{ 0x00, 0x18, {
{ 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }, { 0x60, 0xDEB8 }, { 0x61, 0xDEB8 }
}, 0x02, 0x00 },
{ 0x00, 0x20, {
{ 0x63, 0xDEB8 }, { 0x60, 0xDEB8 }, { 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }
}, 0x03, 0x00 },
{ 0x00, 0x28, {
{ 0x60, 0xDEB8 }, { 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }
}, 0x04, 0x00 },
{ 0x00, 0x30, {
{ 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }, { 0x60, 0xDEB8 }
}, 0x05, 0x00 },
} }
}; };
@ -155,7 +167,8 @@ FindAllDeviceTypes (
); );
for (Index2 = 0; PciClasses[Index2].Class != 0xff; Index2++) { for (Index2 = 0; PciClasses[Index2].Class != 0xff; Index2++) {
if ((PciConfigHeader.Hdr.ClassCode[2] == PciClasses[Index2].Class) && if ((PciConfigHeader.Hdr.ClassCode[2] == PciClasses[Index2].Class) &&
(PciConfigHeader.Hdr.ClassCode[1] == PciClasses[Index2].SubClass)) { (PciConfigHeader.Hdr.ClassCode[1] == PciClasses[Index2].SubClass))
{
LegacyBios->CheckPciRom ( LegacyBios->CheckPciRom (
LegacyBios, LegacyBios,
HandleBuffer[Index], HandleBuffer[Index],
@ -173,7 +186,8 @@ FindAllDeviceTypes (
if ( if (
((DeviceFlags != 0) && (Flags == NO_ROM)) || ((DeviceFlags != 0) && (Flags == NO_ROM)) ||
((Flags & (ROM_FOUND | VALID_LEGACY_ROM)) == (ROM_FOUND | VALID_LEGACY_ROM)) ((Flags & (ROM_FOUND | VALID_LEGACY_ROM)) == (ROM_FOUND | VALID_LEGACY_ROM))
) { )
{
DeviceTable->Handle = HandleBuffer[Index]; DeviceTable->Handle = HandleBuffer[Index];
DeviceTable->Vid = PciConfigHeader.Hdr.VendorId; DeviceTable->Vid = PciConfigHeader.Hdr.VendorId;
DeviceTable->Did = PciConfigHeader.Hdr.DeviceId; DeviceTable->Did = PciConfigHeader.Hdr.DeviceId;
@ -285,7 +299,7 @@ GetSelectedVgaDeviceInfo (
// Determine if this is in the correct bus range. // Determine if this is in the correct bus range.
// //
Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function); Status = PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);
if (EFI_ERROR(Status) || (Bus < MinBus || Bus > MaxBus)) { if (EFI_ERROR (Status) || ((Bus < MinBus) || (Bus > MaxBus))) {
continue; continue;
} }
@ -309,7 +323,9 @@ GetSelectedVgaDeviceInfo (
if (!IS_PCI_VGA (&Pci)) { if (!IS_PCI_VGA (&Pci)) {
continue; continue;
} }
DEBUG ((DEBUG_INFO,
DEBUG ((
DEBUG_INFO,
"PCI VGA: 0x%04x:0x%04x\n", "PCI VGA: 0x%04x:0x%04x\n",
Pci.Hdr.VendorId, Pci.Hdr.VendorId,
Pci.Hdr.DeviceId Pci.Hdr.DeviceId
@ -330,7 +346,6 @@ GetSelectedVgaDeviceInfo (
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
/** /**
Returns a buffer of handles for the requested subfunction. Returns a buffer of handles for the requested subfunction.
@ -449,7 +464,7 @@ GetPlatformHandle (
// //
PriorityIndex = 0; PriorityIndex = 0;
for (Index = 0; Index < LocalIndex; Index++) { for (Index = 0; Index < LocalIndex; Index++) {
if (LocalDevice[Index].Handle == IdeHandle && PriorityIndex == 0) { if ((LocalDevice[Index].Handle == IdeHandle) && (PriorityIndex == 0)) {
TempDevice = LocalDevice[PriorityIndex]; TempDevice = LocalDevice[PriorityIndex];
LocalDevice[PriorityIndex] = LocalDevice[Index]; LocalDevice[PriorityIndex] = LocalDevice[Index];
LocalDevice[Index] = TempDevice; LocalDevice[Index] = TempDevice;
@ -464,6 +479,7 @@ GetPlatformHandle (
for (Index = 0; Index < LocalIndex; Index++) { for (Index = 0; Index < LocalIndex; Index++) {
mDiskHandles[Index] = LocalDevice[Index].Handle; mDiskHandles[Index] = LocalDevice[Index].Handle;
} }
*HandleBuffer = &mDiskHandles[0]; *HandleBuffer = &mDiskHandles[0];
*HandleCount = LocalIndex; *HandleCount = LocalIndex;
@ -477,7 +493,8 @@ GetPlatformHandle (
// //
for (Index = 0; (Index < LocalIndex) && (AdditionalData != NULL); Index++) { for (Index = 0; (Index < LocalIndex) && (AdditionalData != NULL); Index++) {
if ((LocalDevice[Index].Handle != NULL) && if ((LocalDevice[Index].Handle != NULL) &&
(LocalDevice[Index].Handle == IdeHandle)) { (LocalDevice[Index].Handle == IdeHandle))
{
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
LocalDevice[Index].Handle, LocalDevice[Index].Handle,
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -529,6 +546,7 @@ GetPlatformHandle (
HddInfo[HddIndex].ControlBaseAddress = 0x3f6; HddInfo[HddIndex].ControlBaseAddress = 0x3f6;
HddInfo[HddIndex].BusMasterAddress = 0; HddInfo[HddIndex].BusMasterAddress = 0;
} }
HddIndex++; HddIndex++;
// //
@ -548,10 +566,12 @@ GetPlatformHandle (
HddInfo[HddIndex].ControlBaseAddress = 0x376; HddInfo[HddIndex].ControlBaseAddress = 0x376;
HddInfo[HddIndex].BusMasterAddress = 0; HddInfo[HddIndex].BusMasterAddress = 0;
} }
HddIndex++; HddIndex++;
} }
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
case EfiGetPlatformIsaBusHandle: case EfiGetPlatformIsaBusHandle:
ClassLists[0].Class = (UINT8)PCI_CLASS_BRIDGE; ClassLists[0].Class = (UINT8)PCI_CLASS_BRIDGE;
@ -585,13 +605,14 @@ GetPlatformHandle (
for (Index = 0; Index < LocalIndex; Index++) { for (Index = 0; Index < LocalIndex; Index++) {
mIsaHandles[Index] = LocalDevice[Index].Handle; mIsaHandles[Index] = LocalDevice[Index].Handle;
} }
*HandleBuffer = &mIsaHandles[0]; *HandleBuffer = &mIsaHandles[0];
*HandleCount = LocalIndex; *HandleCount = LocalIndex;
return EFI_SUCCESS; return EFI_SUCCESS;
case EfiGetPlatformUsbHandle: case EfiGetPlatformUsbHandle:
default: default:
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
}; }
} }
/** /**
@ -646,7 +667,7 @@ PlatformHooks (
case EfiPlatformHookAfterRomInit: case EfiPlatformHookAfterRomInit:
default: default:
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
}; }
} }
/** /**
@ -724,6 +745,7 @@ GetRoutingTable (
Checksum = (UINT8)(Checksum + (UINT8)*Ptr); Checksum = (UINT8)(Checksum + (UINT8)*Ptr);
Ptr += 1; Ptr += 1;
} }
Checksum = (UINT8)(0x00 - Checksum); Checksum = (UINT8)(0x00 - Checksum);
PirqTableHead.PirqTable.Checksum = Checksum; PirqTableHead.PirqTable.Checksum = Checksum;
@ -796,6 +818,7 @@ GetPlatformInfo (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -808,7 +831,7 @@ GetPlatformInfo (
case EfiGetPlatformPciExpressBase: case EfiGetPlatformPciExpressBase:
default: default:
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
}; }
} }
/** /**
@ -856,7 +879,8 @@ TranslatePirq (
for (Index = 0; Index < MAX_IRQ_ROUTING_ENTRIES; Index++) { for (Index = 0; Index < MAX_IRQ_ROUTING_ENTRIES; Index++) {
if ((PirqTableHead.IrqRoutingEntry[Index].Bus == PciBus) && if ((PirqTableHead.IrqRoutingEntry[Index].Bus == PciBus) &&
(PirqTableHead.IrqRoutingEntry[Index].Device == PciDevice)) { (PirqTableHead.IrqRoutingEntry[Index].Device == PciDevice))
{
LocalPirq = (UINT8)(PirqTableHead.IrqRoutingEntry[Index].PirqEntry[LocalPirq].Pirq & 0x0f); LocalPirq = (UINT8)(PirqTableHead.IrqRoutingEntry[Index].PirqEntry[LocalPirq].Pirq & 0x0f);
if (LocalPirq > 4) { if (LocalPirq > 4) {
LocalPirq -= 4; LocalPirq -= 4;
@ -867,7 +891,8 @@ TranslatePirq (
while (PirqData == 0) { while (PirqData == 0) {
for (Index1 = 0; Index1 < MAX_IRQ_PRIORITY_ENTRIES; Index1++) { for (Index1 = 0; Index1 < MAX_IRQ_PRIORITY_ENTRIES; Index1++) {
if ((IrqPriorityTable[Index1].Used == MatchData) && if ((IrqPriorityTable[Index1].Used == MatchData) &&
(IrqPriorityTable[Index1].Irq != 0)) { (IrqPriorityTable[Index1].Irq != 0))
{
PirqData = IrqPriorityTable[Index1].Irq; PirqData = IrqPriorityTable[Index1].Irq;
IrqPriorityTable[Index1].Used = 0xff; IrqPriorityTable[Index1].Used = 0xff;
LegacyInterrupt->WritePirq ( LegacyInterrupt->WritePirq (
@ -880,7 +905,6 @@ TranslatePirq (
} }
if (PirqData == 0) { if (PirqData == 0) {
// //
// No unused interrupts, so start reusing them. // No unused interrupts, so start reusing them.
// //
@ -896,7 +920,6 @@ TranslatePirq (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Attempt to legacy boot the BootOption. If the EFI contexted has been Attempt to legacy boot the BootOption. If the EFI contexted has been
compromised this function will not return. compromised this function will not return.
@ -966,7 +989,8 @@ PrepareToBoot (
if ((LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) && if ((LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&
(LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY) && (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY) &&
(LocalBbsTable[Index].BootPriority != BBS_LOWEST_PRIORITY) && (LocalBbsTable[Index].BootPriority != BBS_LOWEST_PRIORITY) &&
(Priority <= LocalBbsTable[Index].BootPriority)) { (Priority <= LocalBbsTable[Index].BootPriority))
{
Priority = (UINT16)(LocalBbsTable[Index].BootPriority + 1); Priority = (UINT16)(LocalBbsTable[Index].BootPriority + 1);
} }
} }
@ -978,28 +1002,32 @@ PrepareToBoot (
case BBS_EMBED_NETWORK: case BBS_EMBED_NETWORK:
for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) {
if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) && if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) &&
(LocalBbsTable[Index].DeviceType == DevicePathType)) { (LocalBbsTable[Index].DeviceType == DevicePathType))
{
LocalBbsTable[Index].BootPriority = Priority; LocalBbsTable[Index].BootPriority = Priority;
++Priority; ++Priority;
} }
} }
break; break;
case BBS_BEV_DEVICE: case BBS_BEV_DEVICE:
for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) { for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) {
if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) && if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) &&
(LocalBbsTable[Index].Class == 01) && (LocalBbsTable[Index].Class == 01) &&
(LocalBbsTable[Index].SubClass == 01)) { (LocalBbsTable[Index].SubClass == 01))
{
LocalBbsTable[Index].BootPriority = Priority; LocalBbsTable[Index].BootPriority = Priority;
++Priority; ++Priority;
} }
} }
break; break;
case BBS_USB: case BBS_USB:
case BBS_PCMCIA: case BBS_PCMCIA:
case BBS_UNKNOWN: case BBS_UNKNOWN:
default: default:
break; break;
}; }
// //
// Set priority for rest of devices // Set priority for rest of devices
@ -1014,7 +1042,6 @@ PrepareToBoot (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Initialize Legacy Platform support Initialize Legacy Platform support

View File

@ -95,4 +95,3 @@ typedef struct {
) )
#endif #endif

View File

@ -112,11 +112,12 @@ LegacyRegionManipulationInternal (
// //
// Validate input parameters. // Validate input parameters.
// //
if (Length == 0 || Granularity == NULL) { if ((Length == 0) || (Granularity == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
EndAddress = Start + Length - 1; EndAddress = Start + Length - 1;
if ((Start < PAM_BASE_ADDRESS) || EndAddress > PAM_LIMIT_ADDRESS) { if ((Start < PAM_BASE_ADDRESS) || (EndAddress > PAM_LIMIT_ADDRESS)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -130,6 +131,7 @@ LegacyRegionManipulationInternal (
break; break;
} }
} }
ASSERT (Index < ARRAY_SIZE (mSectionArray)); ASSERT (Index < ARRAY_SIZE (mSectionArray));
// //
@ -149,6 +151,7 @@ LegacyRegionManipulationInternal (
); );
} }
} }
if (WriteEnable != NULL) { if (WriteEnable != NULL) {
if (*WriteEnable) { if (*WriteEnable) {
PciOr8 ( PciOr8 (
@ -171,6 +174,7 @@ LegacyRegionManipulationInternal (
break; break;
} }
} }
ASSERT (Index < ARRAY_SIZE (mSectionArray)); ASSERT (Index < ARRAY_SIZE (mSectionArray));
return EFI_SUCCESS; return EFI_SUCCESS;
@ -189,7 +193,7 @@ LegacyRegionGetInfoInternal (
// //
// Check input parameters // Check input parameters
// //
if (DescriptorCount == NULL || Descriptor == NULL) { if ((DescriptorCount == NULL) || (Descriptor == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -203,6 +207,7 @@ LegacyRegionGetInfoInternal (
if ((PamValue & mRegisterValues[Index].ReadEnableData) != 0) { if ((PamValue & mRegisterValues[Index].ReadEnableData) != 0) {
mSectionArray[Index].ReadEnabled = TRUE; mSectionArray[Index].ReadEnabled = TRUE;
} }
mSectionArray[Index].WriteEnabled = FALSE; mSectionArray[Index].WriteEnabled = FALSE;
if ((PamValue & mRegisterValues[Index].WriteEnableData) != 0) { if ((PamValue & mRegisterValues[Index].WriteEnableData) != 0) {
mSectionArray[Index].WriteEnabled = TRUE; mSectionArray[Index].WriteEnabled = TRUE;
@ -250,7 +255,6 @@ LegacyRegion2Decode (
return LegacyRegionManipulationInternal (Start, Length, On, NULL, Granularity); return LegacyRegionManipulationInternal (Start, Length, On, NULL, Granularity);
} }
/** /**
Modify the hardware to disallow memory attribute changes in a region. Modify the hardware to disallow memory attribute changes in a region.
@ -292,7 +296,6 @@ LegacyRegion2BootLock (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
/** /**
Modify the hardware to disallow memory writes in a region. Modify the hardware to disallow memory writes in a region.
@ -328,7 +331,6 @@ LegacyRegion2Lock (
return LegacyRegionManipulationInternal (Start, Length, NULL, &WriteEnable, Granularity); return LegacyRegionManipulationInternal (Start, Length, NULL, &WriteEnable, Granularity);
} }
/** /**
Modify the hardware to allow memory writes in a region. Modify the hardware to allow memory writes in a region.
@ -420,6 +422,7 @@ LegacyRegionGetInfo (
} else { } else {
DescriptorArray[DescriptorIndex].Attribute = LegacyRegionNotDecoded; DescriptorArray[DescriptorIndex].Attribute = LegacyRegionNotDecoded;
} }
DescriptorIndex++; DescriptorIndex++;
// //
@ -433,6 +436,7 @@ LegacyRegionGetInfo (
} else { } else {
DescriptorArray[DescriptorIndex].Attribute = LegacyRegionWriteDisabled; DescriptorArray[DescriptorIndex].Attribute = LegacyRegionWriteDisabled;
} }
DescriptorIndex++; DescriptorIndex++;
// //
@ -477,8 +481,12 @@ LegacyRegionInit (
mRegisterValues = mRegisterValuesQ35; mRegisterValues = mRegisterValuesQ35;
break; break;
default: default:
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n", DEBUG ((
__FUNCTION__, HostBridgeDevId)); DEBUG_ERROR,
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
__FUNCTION__,
HostBridgeDevId
));
ASSERT (FALSE); ASSERT (FALSE);
return RETURN_UNSUPPORTED; return RETURN_UNSUPPORTED;
} }
@ -488,11 +496,11 @@ LegacyRegionInit (
// //
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&mHandle, &mHandle,
&gEfiLegacyRegion2ProtocolGuid, &mLegacyRegion2, &gEfiLegacyRegion2ProtocolGuid,
&mLegacyRegion2,
NULL NULL
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }

View File

@ -200,4 +200,3 @@ LegacyRegionGetInfo (
); );
#endif #endif

View File

@ -37,5 +37,4 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// ///
#define FRAMEWORK_EFI_BOOT_SCRIPT_TERMINATE_OPCODE 0xFF #define FRAMEWORK_EFI_BOOT_SCRIPT_TERMINATE_OPCODE 0xFF
#endif #endif

View File

@ -167,4 +167,3 @@ typedef struct {
#define EFI_EVENT_SIGNAL_LEGACY_BOOT 0x00000204 #define EFI_EVENT_SIGNAL_LEGACY_BOOT 0x00000204
#endif #endif

View File

@ -96,7 +96,6 @@ typedef UINT16 STRING_REF;
/// ///
#define EFI_IFR_FLAG_CREATED 128 #define EFI_IFR_FLAG_CREATED 128
#pragma pack(1) #pragma pack(1)
// //
// IFR Structure definitions // IFR Structure definitions

View File

@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _FIRMWARE_VOLUME_H_ #ifndef _FIRMWARE_VOLUME_H_
#define _FIRMWARE_VOLUME_H_ #define _FIRMWARE_VOLUME_H_
// //
// Firmware Volume Protocol GUID definition // Firmware Volume Protocol GUID definition
// //

View File

@ -363,7 +363,6 @@ typedef enum {
Legacy16InstallPciHandler = 0x0008 Legacy16InstallPciHandler = 0x0008
} EFI_COMPATIBILITY_FUNCTIONS; } EFI_COMPATIBILITY_FUNCTIONS;
/// ///
/// EFI_DISPATCH_OPROM_TABLE /// EFI_DISPATCH_OPROM_TABLE
/// ///
@ -382,7 +381,6 @@ typedef struct {
///< Inconsistent with specification here: ///< Inconsistent with specification here:
///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version] ///< The member's name "OpromDestinationSegment" [defined in Intel Framework Compatibility Support Module Specification / 0.97 version]
///< has been changed to "RuntimeSegment" since keeping backward compatible. ///< has been changed to "RuntimeSegment" since keeping backward compatible.
} EFI_DISPATCH_OPROM_TABLE; } EFI_DISPATCH_OPROM_TABLE;
/// ///

View File

@ -496,7 +496,6 @@ typedef struct {
UINT8 Checksum; UINT8 Checksum;
} EFI_LEGACY_PIRQ_TABLE_HEADER; } EFI_LEGACY_PIRQ_TABLE_HEADER;
typedef struct { typedef struct {
/// ///
/// If nonzero, a value assigned by the IBV. /// If nonzero, a value assigned by the IBV.
@ -533,7 +532,6 @@ typedef struct {
#pragma pack() #pragma pack()
/** /**
Finds the binary data or other platform information. Finds the binary data or other platform information.

View File

@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _EFI_LEGACY_INTERRUPT_H_ #ifndef _EFI_LEGACY_INTERRUPT_H_
#define _EFI_LEGACY_INTERRUPT_H_ #define _EFI_LEGACY_INTERRUPT_H_
#define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \ #define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \
{ \ { \
0x31ce593d, 0x108a, 0x485d, {0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe } \ 0x31ce593d, 0x108a, 0x485d, {0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe } \

View File

@ -85,6 +85,7 @@ HasMediaInFloppy (
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) { if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
continue; continue;
} }
// //
// Update blockio in case the floppy is inserted in during BdsTimeout // Update blockio in case the floppy is inserted in during BdsTimeout
// //
@ -121,10 +122,8 @@ HasMediaInFloppy (
FreePool (HandleBuffer); FreePool (HandleBuffer);
return FLOPPY_NOT_PRESENT; return FLOPPY_NOT_PRESENT;
} }
/** /**
Complete build of BBS TABLE. Complete build of BBS TABLE.
@ -196,10 +195,8 @@ LegacyBiosBuildBbs (
LegacyBiosBuildIdeData (Private, &HddInfo, 0); LegacyBiosBuildIdeData (Private, &HddInfo, 0);
for (HddIndex = 0; HddIndex < MAX_IDE_CONTROLLER; HddIndex++) { for (HddIndex = 0; HddIndex < MAX_IDE_CONTROLLER; HddIndex++) {
BbsIndex = HddIndex * 2 + 1; BbsIndex = HddIndex * 2 + 1;
for (Index = 0; Index < 2; ++Index) { for (Index = 0; Index < 2; ++Index) {
BbsTable[BbsIndex + Index].Bus = HddInfo[HddIndex].Bus; BbsTable[BbsIndex + Index].Bus = HddInfo[HddIndex].Bus;
BbsTable[BbsIndex + Index].Device = HddInfo[HddIndex].Device; BbsTable[BbsIndex + Index].Device = HddInfo[HddIndex].Device;
BbsTable[BbsIndex + Index].Function = HddInfo[HddIndex].Function; BbsTable[BbsIndex + Index].Function = HddInfo[HddIndex].Function;
@ -324,12 +321,15 @@ LegacyBiosBuildBbs (
// //
DevicePathNode = DevicePath; DevicePathNode = DevicePath;
while (!IsDevicePathEnd (DevicePathNode)) { while (!IsDevicePathEnd (DevicePathNode)) {
if (DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH && if ((DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) &&
DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP) { (DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP))
{
break; break;
} }
DevicePathNode = NextDevicePathNode (DevicePathNode); DevicePathNode = NextDevicePathNode (DevicePathNode);
} }
if (!IsDevicePathEnd (DevicePathNode)) { if (!IsDevicePathEnd (DevicePathNode)) {
continue; continue;
} }
@ -367,13 +367,21 @@ LegacyBiosBuildBbs (
} }
if (SegNum != 0) { if (SegNum != 0) {
DEBUG ((DEBUG_WARN, "CSM cannot use PCI devices in segment %Lu\n", DEBUG ((
(UINT64) SegNum)); DEBUG_WARN,
"CSM cannot use PCI devices in segment %Lu\n",
(UINT64)SegNum
));
continue; continue;
} }
DEBUG ((DEBUG_INFO, "Add Legacy Bbs entry for PCI %d/%d/%d\n", DEBUG ((
BusNum, DevNum, FuncNum)); DEBUG_INFO,
"Add Legacy Bbs entry for PCI %d/%d/%d\n",
BusNum,
DevNum,
FuncNum
));
BbsTable[BbsIndex].Bus = BusNum; BbsTable[BbsIndex].Bus = BusNum;
BbsTable[BbsIndex].Device = DevNum; BbsTable[BbsIndex].Device = DevNum;
@ -403,7 +411,6 @@ LegacyBiosBuildBbs (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get all BBS info Get all BBS info
@ -475,7 +482,6 @@ LegacyBiosGetBbsInfo (
// PCI bus driver enumerate all subsequent handles // PCI bus driver enumerate all subsequent handles
// //
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE); gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
} }
LegacyBiosBuildBbs (Private, mBbsTable); LegacyBiosBuildBbs (Private, mBbsTable);

View File

@ -81,13 +81,14 @@ AllocateLegacyMemory (
// Make sure that the buffer can be used to store code. // Make sure that the buffer can be used to store code.
// //
Status = gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc); Status = gDS->GetMemorySpaceDescriptor (MemPage, &MemDesc);
if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) { if (!EFI_ERROR (Status) && ((MemDesc.Attributes & EFI_MEMORY_XP) != 0)) {
Status = gDS->SetMemorySpaceAttributes ( Status = gDS->SetMemorySpaceAttributes (
MemPage, MemPage,
EFI_PAGES_TO_SIZE (Pages), EFI_PAGES_TO_SIZE (Pages),
MemDesc.Attributes & (~EFI_MEMORY_XP) MemDesc.Attributes & (~EFI_MEMORY_XP)
); );
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePages (MemPage, Pages); gBS->FreePages (MemPage, Pages);
} }
@ -101,7 +102,6 @@ AllocateLegacyMemory (
return Status; return Status;
} }
/** /**
This function is called when EFI needs to reserve an area in the 0xE0000 or 0xF0000 This function is called when EFI needs to reserve an area in the 0xE0000 or 0xF0000
64 KB blocks. 64 KB blocks.
@ -133,7 +133,6 @@ LegacyBiosGetLegacyRegion (
OUT VOID **LegacyMemoryAddress OUT VOID **LegacyMemoryAddress
) )
{ {
LEGACY_BIOS_INSTANCE *Private; LEGACY_BIOS_INSTANCE *Private;
EFI_IA32_REGISTER_SET Regs; EFI_IA32_REGISTER_SET Regs;
EFI_STATUS Status; EFI_STATUS Status;
@ -169,7 +168,6 @@ LegacyBiosGetLegacyRegion (
return Status; return Status;
} }
/** /**
This function is called when copying data to the region assigned by This function is called when copying data to the region assigned by
EFI_LEGACY_BIOS_PROTOCOL.GetLegacyRegion(). EFI_LEGACY_BIOS_PROTOCOL.GetLegacyRegion().
@ -193,15 +191,16 @@ LegacyBiosCopyLegacyRegion (
IN VOID *LegacyMemorySourceAddress IN VOID *LegacyMemorySourceAddress
) )
{ {
LEGACY_BIOS_INSTANCE *Private; LEGACY_BIOS_INSTANCE *Private;
UINT32 Granularity; UINT32 Granularity;
if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000) || if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000) ||
((UINTN)LegacyMemoryAddress + LegacyMemorySize > (UINTN)0x100000) ((UINTN)LegacyMemoryAddress + LegacyMemorySize > (UINTN)0x100000)
) { )
{
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
// //
// There is no protection from writes over lapping if this function is // There is no protection from writes over lapping if this function is
// called multiple times. // called multiple times.
@ -216,7 +215,6 @@ LegacyBiosCopyLegacyRegion (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find Find Legacy16 BIOS image in the FLASH device and shadow it into memory. Find
the $EFI table in the shadow area. Thunk into the Legacy16 code after it had the $EFI table in the shadow area. Thunk into the Legacy16 code after it had
@ -488,6 +486,7 @@ ShadowAndStartLegacy16 (
TempData = Table->E820Pointer; TempData = Table->E820Pointer;
CopyMem ((VOID *)TempData, Private->E820Table, E820Size); CopyMem ((VOID *)TempData, Private->E820Table, E820Size);
} }
// //
// Get PnPInstallationCheck Info. // Get PnPInstallationCheck Info.
// //
@ -511,6 +510,7 @@ ShadowAndStartLegacy16 (
Private->Legacy16Table->PciExpressBase = (UINT32)Location; Private->Legacy16Table->PciExpressBase = (UINT32)Location;
Location = 0; Location = 0;
} }
// //
// Check if TPM is supported. If yes get a region in E0000,F0000 to copy it // Check if TPM is supported. If yes get a region in E0000,F0000 to copy it
// into, copy it and update pointer to binary image. This needs to be // into, copy it and update pointer to binary image. This needs to be
@ -527,7 +527,6 @@ ShadowAndStartLegacy16 (
0 0
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET)); ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
Regs.X.AX = Legacy16GetTableAddress; Regs.X.AX = Legacy16GetTableAddress;
Regs.X.CX = (UINT16)TpmBinaryImageSize; Regs.X.CX = (UINT16)TpmBinaryImageSize;
@ -548,9 +547,9 @@ ShadowAndStartLegacy16 (
CopyMem ((VOID *)(UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize); CopyMem ((VOID *)(UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize);
Table->TpmSegment = Regs.X.DS; Table->TpmSegment = Regs.X.DS;
Table->TpmOffset = Regs.X.BX; Table->TpmOffset = Regs.X.BX;
}
}
}
}
// //
// Lock the Legacy BIOS region // Lock the Legacy BIOS region
// //
@ -574,6 +573,7 @@ ShadowAndStartLegacy16 (
for (Index = 0; Index < MAX_BBS_ENTRIES; Index++) { for (Index = 0; Index < MAX_BBS_ENTRIES; Index++) {
BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY; BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY;
} }
// //
// Allocate space for Legacy HDD table // Allocate space for Legacy HDD table
// //
@ -684,6 +684,7 @@ GetPciInterfaceVersion (
PciInterfaceVersion = Reg.X.BX; PciInterfaceVersion = Reg.X.BX;
} }
} }
return PciInterfaceVersion; return PciInterfaceVersion;
} }
@ -738,11 +739,13 @@ InstallSmbiosEventCallback (
mReserveSmbiosEntryPoint = 0; mReserveSmbiosEntryPoint = 0;
return; return;
} }
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Entry Point Structure\n")); DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Entry Point Structure\n"));
} }
if ((mStructureTableAddress != 0) && if ((mStructureTableAddress != 0) &&
(mStructureTablePages < EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength))) { (mStructureTablePages < EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength)))
{
// //
// If original buffer is not enough for the new SMBIOS table, free original buffer and re-allocate // If original buffer is not enough for the new SMBIOS table, free original buffer and re-allocate
// //
@ -775,6 +778,7 @@ InstallSmbiosEventCallback (
mStructureTablePages = 0; mStructureTablePages = 0;
return; return;
} }
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Structure Table\n")); DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Structure Table\n"));
} }
} }
@ -904,6 +908,7 @@ LegacyBiosInstall (
StartAddress = Descriptor.BaseAddress + Descriptor.Length; StartAddress = Descriptor.BaseAddress + Descriptor.Length;
continue; continue;
} }
Length = MIN (Descriptor.Length, 0xa0000 - StartAddress); Length = MIN (Descriptor.Length, 0xa0000 - StartAddress);
Private->GenericMemoryTest->CompatibleRangeTest ( Private->GenericMemoryTest->CompatibleRangeTest (
Private->GenericMemoryTest, Private->GenericMemoryTest,
@ -912,6 +917,7 @@ LegacyBiosInstall (
); );
StartAddress = StartAddress + Length; StartAddress = StartAddress + Length;
} }
// //
// Make sure all memory from 1MB to 16MB is tested and added to memory map // Make sure all memory from 1MB to 16MB is tested and added to memory map
// //
@ -921,6 +927,7 @@ LegacyBiosInstall (
StartAddress = Descriptor.BaseAddress + Descriptor.Length; StartAddress = Descriptor.BaseAddress + Descriptor.Length;
continue; continue;
} }
Length = MIN (Descriptor.Length, BASE_16MB - StartAddress); Length = MIN (Descriptor.Length, BASE_16MB - StartAddress);
Private->GenericMemoryTest->CompatibleRangeTest ( Private->GenericMemoryTest->CompatibleRangeTest (
Private->GenericMemoryTest, Private->GenericMemoryTest,
@ -1121,6 +1128,7 @@ LegacyBiosInstall (
&MemoryAddress &MemoryAddress
); );
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
EfiToLegacy16InitTable->HiPmmMemory = (UINT32)(EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress; EfiToLegacy16InitTable->HiPmmMemory = (UINT32)(EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize; EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;
@ -1135,6 +1143,7 @@ LegacyBiosInstall (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Initialize interrupt redirection code and entries; // Initialize interrupt redirection code and entries;
// IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f. // IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
@ -1155,6 +1164,7 @@ LegacyBiosInstall (
for (Index = 0; Index < 8; Index++) { for (Index = 0; Index < 8; Index++) {
BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4); BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);
} }
); );
// //
@ -1206,7 +1216,9 @@ LegacyBiosInstall (
); );
Private->Csm16PciInterfaceVersion = GetPciInterfaceVersion (Private); Private->Csm16PciInterfaceVersion = GetPciInterfaceVersion (Private);
DEBUG ((DEBUG_INFO, "CSM16 PCI BIOS Interface Version: %02x.%02x\n", DEBUG ((
DEBUG_INFO,
"CSM16 PCI BIOS Interface Version: %02x.%02x\n",
(UINT8)(Private->Csm16PciInterfaceVersion >> 8), (UINT8)(Private->Csm16PciInterfaceVersion >> 8),
(UINT8)Private->Csm16PciInterfaceVersion (UINT8)Private->Csm16PciInterfaceVersion
)); ));

View File

@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _LEGACY_BIOS_INTERFACE_ #ifndef _LEGACY_BIOS_INTERFACE_
#define _LEGACY_BIOS_INTERFACE_ #define _LEGACY_BIOS_INTERFACE_
#include <FrameworkDxe.h> #include <FrameworkDxe.h>
#include <IndustryStandard/Pci.h> #include <IndustryStandard/Pci.h>
#include <IndustryStandard/SmBios.h> #include <IndustryStandard/SmBios.h>
@ -591,10 +590,8 @@ typedef struct {
// CSM16 PCI Interface Version // CSM16 PCI Interface Version
// //
UINT16 Csm16PciInterfaceVersion; UINT16 Csm16PciInterfaceVersion;
} LEGACY_BIOS_INSTANCE; } LEGACY_BIOS_INSTANCE;
#pragma pack(1) #pragma pack(1)
/* /*
@ -699,7 +696,6 @@ LegacyBiosInt86 (
IN EFI_IA32_REGISTER_SET *Regs IN EFI_IA32_REGISTER_SET *Regs
); );
/** /**
Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
16-bit register context on entry and exit. Arguments can be passed on 16-bit register context on entry and exit. Arguments can be passed on
@ -729,7 +725,6 @@ LegacyBiosFarCall86 (
IN UINTN StackSize IN UINTN StackSize
); );
/** /**
Test to see if a legacy PCI ROM exists for this device. Optionally return Test to see if a legacy PCI ROM exists for this device. Optionally return
the Legacy ROM instance for this PCI device. the Legacy ROM instance for this PCI device.
@ -755,7 +750,6 @@ LegacyBiosCheckPciRom (
OUT UINTN *Flags OUT UINTN *Flags
); );
/** /**
Assign drive number to legacy HDD drives prior to booting an EFI Assign drive number to legacy HDD drives prior to booting an EFI
aware OS so the OS can access drives without an EFI driver. aware OS so the OS can access drives without an EFI driver.
@ -777,7 +771,6 @@ LegacyBiosPrepareToBootEfi (
OUT BBS_TABLE **BbsTable OUT BBS_TABLE **BbsTable
); );
/** /**
To boot from an unconventional device like parties and/or execute To boot from an unconventional device like parties and/or execute
HDD diagnostics. HDD diagnostics.
@ -803,7 +796,6 @@ LegacyBiosBootUnconventionalDevice (
IN VOID *ServiceAreaData IN VOID *ServiceAreaData
); );
/** /**
Load a legacy PC-AT OPROM on the PciHandle device. Return information Load a legacy PC-AT OPROM on the PciHandle device. Return information
about how many disks were added by the OPROM and the shadow address and about how many disks were added by the OPROM and the shadow address and
@ -844,7 +836,6 @@ LegacyBiosInstallPciRom (
OUT UINT32 *RomShadowedSize OPTIONAL OUT UINT32 *RomShadowedSize OPTIONAL
); );
/** /**
Fill in the standard BDA for Keyboard LEDs Fill in the standard BDA for Keyboard LEDs
@ -861,7 +852,6 @@ LegacyBiosUpdateKeyboardLedStatus (
IN UINT8 Leds IN UINT8 Leds
); );
/** /**
Get all BBS info Get all BBS info
@ -886,7 +876,6 @@ LegacyBiosGetBbsInfo (
OUT BBS_TABLE **BbsTable OUT BBS_TABLE **BbsTable
); );
/** /**
Shadow all legacy16 OPROMs that haven't been shadowed. Shadow all legacy16 OPROMs that haven't been shadowed.
Warning: Use this with caution. This routine disconnects all EFI Warning: Use this with caution. This routine disconnects all EFI
@ -904,7 +893,6 @@ LegacyBiosShadowAllLegacyOproms (
IN EFI_LEGACY_BIOS_PROTOCOL *This IN EFI_LEGACY_BIOS_PROTOCOL *This
); );
/** /**
Attempt to legacy boot the BootOption. If the EFI contexted has been Attempt to legacy boot the BootOption. If the EFI contexted has been
compromised this function will not return. compromised this function will not return.
@ -926,7 +914,6 @@ LegacyBiosLegacyBoot (
IN VOID *LoadOptions IN VOID *LoadOptions
); );
/** /**
Allocate memory < 1 MB and copy the thunker code into low memory. Se up Allocate memory < 1 MB and copy the thunker code into low memory. Se up
all the descriptors. all the descriptors.
@ -941,7 +928,6 @@ LegacyBiosInitializeThunk (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Fill in the standard BDA and EBDA stuff before Legacy16 load Fill in the standard BDA and EBDA stuff before Legacy16 load
@ -955,7 +941,6 @@ LegacyBiosInitBda (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Collect IDE Inquiry data from the IDE disks Collect IDE Inquiry data from the IDE disks
@ -973,7 +958,6 @@ LegacyBiosBuildIdeData (
IN UINT16 Flag IN UINT16 Flag
); );
/** /**
Enable ide controller. This gets disabled when LegacyBoot.c is about Enable ide controller. This gets disabled when LegacyBoot.c is about
to run the Option ROMs. to run the Option ROMs.
@ -987,7 +971,6 @@ EnableIdeController (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
If the IDE channel is in compatibility (legacy) mode, remove all If the IDE channel is in compatibility (legacy) mode, remove all
PCI I/O BAR addresses from the controller. PCI I/O BAR addresses from the controller.
@ -1001,7 +984,6 @@ InitLegacyIdeController (
IN EFI_HANDLE IdeController IN EFI_HANDLE IdeController
); );
/** /**
Program the interrupt routing register in all the PCI devices. On a PC AT system Program the interrupt routing register in all the PCI devices. On a PC AT system
this register contains the 8259 IRQ vector that matches its PCI interrupt. this register contains the 8259 IRQ vector that matches its PCI interrupt.
@ -1017,7 +999,6 @@ PciProgramAllInterruptLineRegisters (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Collect EFI Info about legacy devices. Collect EFI Info about legacy devices.
@ -1031,7 +1012,6 @@ LegacyBiosBuildSioData (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol
to chose the order. Skip any devices that have already have legacy to chose the order. Skip any devices that have already have legacy
@ -1048,7 +1028,6 @@ PciShadowRoms (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Fill in the standard BDA and EBDA stuff prior to legacy Boot Fill in the standard BDA and EBDA stuff prior to legacy Boot
@ -1062,7 +1041,6 @@ LegacyBiosCompleteBdaBeforeBoot (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Fill in the standard CMOS stuff before Legacy16 load Fill in the standard CMOS stuff before Legacy16 load
@ -1076,7 +1054,6 @@ LegacyBiosInitCmos (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Fill in the standard CMOS stuff prior to legacy Boot Fill in the standard CMOS stuff prior to legacy Boot
@ -1090,7 +1067,6 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
IN LEGACY_BIOS_INSTANCE *Private IN LEGACY_BIOS_INSTANCE *Private
); );
/** /**
Contains the code that is copied into low memory (below 640K). Contains the code that is copied into low memory (below 640K).
This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f. This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.
@ -1105,7 +1081,6 @@ InterruptRedirectionTemplate (
VOID VOID
); );
/** /**
Build the E820 table. Build the E820 table.

View File

@ -90,8 +90,10 @@ PrintBbsTable (
for (SubIndex = 0; String[SubIndex] != 0; SubIndex++) { for (SubIndex = 0; String[SubIndex] != 0; SubIndex++) {
DEBUG ((DEBUG_INFO, "%c", String[SubIndex])); DEBUG ((DEBUG_INFO, "%c", String[SubIndex]));
} }
DEBUG ((DEBUG_INFO, ")")); DEBUG ((DEBUG_INFO, ")"));
} }
DEBUG ((DEBUG_INFO, "\n")); DEBUG ((DEBUG_INFO, "\n"));
} }
@ -177,6 +179,7 @@ PrintPciInterruptRegister (
Interrupt Interrupt
); );
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = PciIo->GetLocation ( Status = PciIo->GetLocation (
PciIo, PciIo,
@ -186,11 +189,20 @@ PrintPciInterruptRegister (
&Function &Function
); );
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, " %02x/%02x/%02x 0x%02x 0x%02x\n", DEBUG ((
Bus, Device, Function, Interrupt[0], Interrupt[1])); DEBUG_INFO,
" %02x/%02x/%02x 0x%02x 0x%02x\n",
Bus,
Device,
Function,
Interrupt[0],
Interrupt[1]
));
} }
} }
DEBUG ((DEBUG_INFO, "\n")); DEBUG ((DEBUG_INFO, "\n"));
if (Handles != NULL) { if (Handles != NULL) {
@ -336,7 +348,6 @@ UpdateSioData (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, 0x64, 1, &Register); IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, 0x64, 1, &Register);
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
@ -344,7 +355,6 @@ UpdateSioData (
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -366,6 +376,7 @@ CalculateIdentifyDriveChecksum (
{ {
UINTN Index; UINTN Index;
UINT8 LocalChecksum; UINT8 LocalChecksum;
LocalChecksum = 0; LocalChecksum = 0;
*Checksum = 0; *Checksum = 0;
if (IdentifyDriveData[510] != 0xA5) { if (IdentifyDriveData[510] != 0xA5) {
@ -380,7 +391,6 @@ CalculateIdentifyDriveChecksum (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Identify drive data must be updated to actual parameters before boot. Identify drive data must be updated to actual parameters before boot.
@ -411,6 +421,7 @@ UpdateIdentifyDriveData (
if (OriginalChecksum != 0) { if (OriginalChecksum != 0) {
Status = EFI_SECURITY_VIOLATION; Status = EFI_SECURITY_VIOLATION;
} }
// //
// If NumberCylinders = 0 then do data(Controller present but don drive attached). // If NumberCylinders = 0 then do data(Controller present but don drive attached).
// //
@ -521,7 +532,6 @@ EnableIdeController (
} }
} }
/** /**
Enable ide controller. This gets disabled when LegacyBoot.c is about Enable ide controller. This gets disabled when LegacyBoot.c is about
to run the Option ROMs. to run the Option ROMs.
@ -600,8 +610,8 @@ EnableAllControllers (
IS_PCI_IDE (&PciConfigHeader) || IS_PCI_IDE (&PciConfigHeader) ||
IS_PCI_P2P (&PciConfigHeader) || IS_PCI_P2P (&PciConfigHeader) ||
IS_PCI_P2P_SUB (&PciConfigHeader) || IS_PCI_P2P_SUB (&PciConfigHeader) ||
IS_PCI_LPC (&PciConfigHeader) )) { IS_PCI_LPC (&PciConfigHeader)))
{
PciConfigHeader.Hdr.Command |= 0x1f; PciConfigHeader.Hdr.Command |= 0x1f;
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 4, 1, &PciConfigHeader.Hdr.Command); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 4, 1, &PciConfigHeader.Hdr.Command);
@ -703,6 +713,7 @@ LegacyGetDataOrTable (
break; break;
} }
} }
// //
// Phase 2 Call routine second time with address to allow address adjustment // Phase 2 Call routine second time with address to allow address adjustment
// //
@ -727,7 +738,6 @@ LegacyGetDataOrTable (
case EfiGetPlatformBinaryOemIntData: case EfiGetPlatformBinaryOemIntData:
{ {
Legacy16Table->OemIntSegment = Regs.X.DS; Legacy16Table->OemIntSegment = Regs.X.DS;
Legacy16Table->OemIntOffset = Regs.X.BX; Legacy16Table->OemIntOffset = Regs.X.BX;
DEBUG ((DEBUG_INFO, "OemInt table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->OemIntSegment, (UINTN)Legacy16Table->OemIntOffset)); DEBUG ((DEBUG_INFO, "OemInt table in legacy region - %04x:%04x\n", (UINTN)Legacy16Table->OemIntSegment, (UINTN)Legacy16Table->OemIntOffset));
@ -760,6 +770,7 @@ LegacyGetDataOrTable (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Phase 3 Copy table to final location // Phase 3 Copy table to final location
// //
@ -787,7 +798,8 @@ CreateSmbiosTableInReservedMemory (
if ((mRuntimeSmbiosEntryPoint == NULL) || if ((mRuntimeSmbiosEntryPoint == NULL) ||
(mReserveSmbiosEntryPoint == 0) || (mReserveSmbiosEntryPoint == 0) ||
(mStructureTableAddress == 0)) { (mStructureTableAddress == 0))
{
return; return;
} }
@ -911,6 +923,7 @@ GenericLegacyBoot (
IdeController = HandleBuffer[0]; IdeController = HandleBuffer[0];
} }
} }
// //
// Unlock the Legacy BIOS region // Unlock the Legacy BIOS region
// //
@ -967,6 +980,7 @@ GenericLegacyBoot (
if (mReserveSmbiosEntryPoint == 0) { if (mReserveSmbiosEntryPoint == 0) {
DEBUG ((DEBUG_INFO, "Smbios table is not found!\n")); DEBUG ((DEBUG_INFO, "Smbios table is not found!\n"));
} }
CreateSmbiosTableInReservedMemory (); CreateSmbiosTableInReservedMemory ();
EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint; EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint;
@ -981,12 +995,14 @@ GenericLegacyBoot (
&AcpiTable &AcpiTable
); );
} }
// //
// We do not ASSERT if AcpiTable not found. It is possible that a platform does not produce AcpiTable. // We do not ASSERT if AcpiTable not found. It is possible that a platform does not produce AcpiTable.
// //
if (AcpiTable == NULL) { if (AcpiTable == NULL) {
DEBUG ((DEBUG_INFO, "ACPI table is not found!\n")); DEBUG ((DEBUG_INFO, "ACPI table is not found!\n"));
} }
EfiToLegacy16BootTable->AcpiTable = (UINT32)(UINTN)AcpiTable; EfiToLegacy16BootTable->AcpiTable = (UINT32)(UINTN)AcpiTable;
// //
@ -995,7 +1011,6 @@ GenericLegacyBoot (
// Rev != 0 Length is UINT32 at offset 20 decimal // Rev != 0 Length is UINT32 at offset 20 decimal
// //
if (AcpiTable != NULL) { if (AcpiTable != NULL) {
AcpiPtr = AcpiTable; AcpiPtr = AcpiTable;
if (*((UINT8 *)AcpiPtr + 15) == 0) { if (*((UINT8 *)AcpiPtr + 15) == 0) {
CopySize = 20; CopySize = 20;
@ -1010,6 +1025,7 @@ GenericLegacyBoot (
CopySize CopySize
); );
} }
// //
// Make sure all PCI Interrupt Line register are programmed to match 8259 // Make sure all PCI Interrupt Line register are programmed to match 8259
// //
@ -1034,6 +1050,7 @@ GenericLegacyBoot (
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) { if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
UpdateSioData (Private); UpdateSioData (Private);
} }
// //
// Setup BDA and EBDA standard areas before Legacy Boot // Setup BDA and EBDA standard areas before Legacy Boot
// //
@ -1130,13 +1147,15 @@ GenericLegacyBoot (
for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) { for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {
if ((LocalHddInfo[Index].IdentifyDrive[0].Raw[0] != 0) && if ((LocalHddInfo[Index].IdentifyDrive[0].Raw[0] != 0) &&
(LocalBbsTable[2 * Index + 1].BootPriority == BBS_IGNORE_ENTRY) (LocalBbsTable[2 * Index + 1].BootPriority == BBS_IGNORE_ENTRY)
) { )
{
LocalBbsTable[2 * Index + 1].BootPriority = BBS_UNPRIORITIZED_ENTRY; LocalBbsTable[2 * Index + 1].BootPriority = BBS_UNPRIORITIZED_ENTRY;
} }
if ((LocalHddInfo[Index].IdentifyDrive[1].Raw[0] != 0) && if ((LocalHddInfo[Index].IdentifyDrive[1].Raw[0] != 0) &&
(LocalBbsTable[2 * Index + 2].BootPriority == BBS_IGNORE_ENTRY) (LocalBbsTable[2 * Index + 2].BootPriority == BBS_IGNORE_ENTRY)
) { )
{
LocalBbsTable[2 * Index + 2].BootPriority = BBS_UNPRIORITIZED_ENTRY; LocalBbsTable[2 * Index + 2].BootPriority = BBS_UNPRIORITIZED_ENTRY;
} }
} }
@ -1164,14 +1183,17 @@ GenericLegacyBoot (
for (Index = 0; Index < BbsCount; Index++) { for (Index = 0; Index < BbsCount; Index++) {
if ((LocalBbsTable[Index].BootPriority != BBS_DO_NOT_BOOT_FROM) && if ((LocalBbsTable[Index].BootPriority != BBS_DO_NOT_BOOT_FROM) &&
(LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) && (LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&
(LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY)) { (LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY))
{
break; break;
} }
} }
if (Index == BbsCount) { if (Index == BbsCount) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
} }
// //
// Let the Legacy16 code know the device path type for legacy boot // Let the Legacy16 code know the device path type for legacy boot
// //
@ -1229,6 +1251,7 @@ GenericLegacyBoot (
if (Regs.X.AX != 0) { if (Regs.X.AX != 0) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
// //
// Lock the Legacy BIOS region // Lock the Legacy BIOS region
// //
@ -1240,13 +1263,18 @@ GenericLegacyBoot (
); );
if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) && if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
((Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaSize != 0))) { ((Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaSize != 0)))
{
// //
// Here we could reduce UmaAddress down as far as Private->OptionRom, taking into // Here we could reduce UmaAddress down as far as Private->OptionRom, taking into
// account the granularity of the access control. // account the granularity of the access control.
// //
DEBUG((DEBUG_INFO, "Unlocking UMB RAM region 0x%x-0x%x\n", Private->Legacy16Table->UmaAddress, DEBUG ((
Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize)); DEBUG_INFO,
"Unlocking UMB RAM region 0x%x-0x%x\n",
Private->Legacy16Table->UmaAddress,
Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize
));
Private->LegacyRegion->UnLock ( Private->LegacyRegion->UnLock (
Private->LegacyRegion, Private->LegacyRegion,
@ -1271,7 +1299,6 @@ GenericLegacyBoot (
// //
EnableAllControllers (Private); EnableAllControllers (Private);
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) { if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
// //
// Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT // Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT
// //
@ -1297,7 +1324,6 @@ GenericLegacyBoot (
// //
SaveAndSetDebugTimerInterrupt (FALSE); SaveAndSetDebugTimerInterrupt (FALSE);
// //
// Put the 8259 into its legacy mode by reprogramming the vector bases // Put the 8259 into its legacy mode by reprogramming the vector bases
// //
@ -1328,6 +1354,7 @@ GenericLegacyBoot (
BaseVectorMaster[Index] = (UINT32)(Private->BiosUnexpectedInt); BaseVectorMaster[Index] = (UINT32)(Private->BiosUnexpectedInt);
} }
} }
); );
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET)); ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
@ -1347,8 +1374,10 @@ GenericLegacyBoot (
for (Index = 0; Index < 8; Index++) { for (Index = 0; Index < 8; Index++) {
BaseVectorMaster[Index] = Private->ThunkSavedInt[Index]; BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
} }
); );
} }
Private->LegacyBootEntered = TRUE; Private->LegacyBootEntered = TRUE;
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) { if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
// //
@ -1364,7 +1393,6 @@ GenericLegacyBoot (
} }
} }
/** /**
Assign drive number to legacy HDD drives prior to booting an EFI Assign drive number to legacy HDD drives prior to booting an EFI
aware OS so the OS can access drives without an EFI driver. aware OS so the OS can access drives without an EFI driver.
@ -1449,13 +1477,15 @@ LegacyBiosBootUnconventionalDevice (
if ((Attributes.DirectoryServiceValidity == 0) && if ((Attributes.DirectoryServiceValidity == 0) &&
(Attributes.RabcaUsedFlag == 0) && (Attributes.RabcaUsedFlag == 0) &&
(Attributes.ExecuteHddDiagnosticsFlag == 0) (Attributes.ExecuteHddDiagnosticsFlag == 0)
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (((Attributes.DirectoryServiceValidity != 0) && (ServiceAreaData == NULL)) || if (((Attributes.DirectoryServiceValidity != 0) && (ServiceAreaData == NULL)) ||
(((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag) != 0) && (BeerData == NULL)) (((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag) != 0) && (BeerData == NULL))
) { )
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -1478,6 +1508,7 @@ LegacyBiosBootUnconventionalDevice (
for (Index = 0; Index < EfiToLegacy16BootTable->NumberBbsEntries; Index++) { for (Index = 0; Index < EfiToLegacy16BootTable->NumberBbsEntries; Index++) {
BbsTable[Index].BootPriority = BBS_DO_NOT_BOOT_FROM; BbsTable[Index].BootPriority = BBS_DO_NOT_BOOT_FROM;
} }
// //
// If parent is onboard IDE then assign controller & device number // If parent is onboard IDE then assign controller & device number
// else they are 0. // else they are 0.
@ -1501,6 +1532,7 @@ LegacyBiosBootUnconventionalDevice (
(UINTN)64 (UINTN)64
); );
} }
// //
// For each new entry do the following: // For each new entry do the following:
// 1. Increment current number of BBS entries // 1. Increment current number of BBS entries
@ -1553,6 +1585,7 @@ LegacyBiosBootUnconventionalDevice (
// //
mBbsDevicePathNode.DeviceType = BBS_TYPE_FLOPPY; mBbsDevicePathNode.DeviceType = BBS_TYPE_FLOPPY;
} }
// //
// Build the BBS Device Path for this boot selection // Build the BBS Device Path for this boot selection
// //
@ -1828,6 +1861,7 @@ LegacyBiosBuildE820 (
E820Table[Index].Type = TempType; E820Table[Index].Type = TempType;
} }
} }
EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize); EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
} }
@ -1837,13 +1871,14 @@ LegacyBiosBuildE820 (
// Process the reserved memory map to produce E820 map ; // Process the reserved memory map to produce E820 map ;
// //
for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) { for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
if (Hob.Raw != NULL && GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) { if ((Hob.Raw != NULL) && (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR)) {
ResourceHob = Hob.ResourceDescriptor; ResourceHob = Hob.ResourceDescriptor;
if (((ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO) || if (((ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO) ||
(ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE) || (ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE) ||
(ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED)) && (ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED)) &&
(ResourceHob->PhysicalStart > 0x100000) && (ResourceHob->PhysicalStart > 0x100000) &&
(Index < EFI_MAX_E820_ENTRY - 1)) { (Index < EFI_MAX_E820_ENTRY - 1))
{
++Index; ++Index;
E820Table[Index].BaseAddr = ResourceHob->PhysicalStart; E820Table[Index].BaseAddr = ResourceHob->PhysicalStart;
E820Table[Index].Length = ResourceHob->ResourceLength; E820Table[Index].Length = ResourceHob->ResourceLength;
@ -1889,9 +1924,10 @@ LegacyBiosBuildE820 (
// Remove the overlap range // Remove the overlap range
// //
for (TempIndex = 1; TempIndex < Index; TempIndex++) { for (TempIndex = 1; TempIndex < Index; TempIndex++) {
if (E820Table[TempIndex - 1].BaseAddr <= E820Table[TempIndex].BaseAddr && if ((E820Table[TempIndex - 1].BaseAddr <= E820Table[TempIndex].BaseAddr) &&
((E820Table[TempIndex - 1].BaseAddr + E820Table[TempIndex - 1].Length) >= ((E820Table[TempIndex - 1].BaseAddr + E820Table[TempIndex - 1].Length) >=
(E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length))) { (E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length)))
{
// //
// Overlap range is found // Overlap range is found
// //
@ -1909,13 +1945,12 @@ LegacyBiosBuildE820 (
E820Table[IndexSort].Length = E820Table[IndexSort + 1].Length; E820Table[IndexSort].Length = E820Table[IndexSort + 1].Length;
E820Table[IndexSort].Type = E820Table[IndexSort + 1].Type; E820Table[IndexSort].Type = E820Table[IndexSort + 1].Type;
} }
Index--; Index--;
} }
} }
} }
Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index; Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;
Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index; Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;
Private->NumberE820Entries = (UINT32)Index; Private->NumberE820Entries = (UINT32)Index;
@ -1926,7 +1961,8 @@ LegacyBiosBuildE820 (
// //
Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb = 0x0000; Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb = 0x0000;
for (TempIndex = Above1MIndex; TempIndex < Index; TempIndex++) { for (TempIndex = Above1MIndex; TempIndex < Index; TempIndex++) {
if (E820Table[TempIndex].BaseAddr >= 0x100000 && E820Table[TempIndex].BaseAddr < 0x100000000ULL) { // not include above 4G memory if ((E820Table[TempIndex].BaseAddr >= 0x100000) && (E820Table[TempIndex].BaseAddr < 0x100000000ULL)) {
// not include above 4G memory
// //
// ACPIReclaimMemory is also usable memory for ACPI OS, after OS dumps all ACPI tables. // ACPIReclaimMemory is also usable memory for ACPI OS, after OS dumps all ACPI tables.
// //
@ -1944,7 +1980,9 @@ LegacyBiosBuildE820 (
// Print DEBUG information // Print DEBUG information
// //
for (TempIndex = 0; TempIndex < Index; TempIndex++) { for (TempIndex = 0; TempIndex < Index; TempIndex++) {
DEBUG((DEBUG_INFO, "E820[%2d]: 0x%016lx - 0x%016lx, Type = %d\n", DEBUG ((
DEBUG_INFO,
"E820[%2d]: 0x%016lx - 0x%016lx, Type = %d\n",
TempIndex, TempIndex,
E820Table[TempIndex].BaseAddr, E820Table[TempIndex].BaseAddr,
(E820Table[TempIndex].BaseAddr + E820Table[TempIndex].Length), (E820Table[TempIndex].BaseAddr + E820Table[TempIndex].Length),
@ -1955,7 +1993,6 @@ LegacyBiosBuildE820 (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Fill in the standard BDA and EBDA stuff prior to legacy Boot Fill in the standard BDA and EBDA stuff prior to legacy Boot
@ -2086,7 +2123,6 @@ LegacyBiosUpdateKeyboardLedStatus (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Fill in the standard CMOS stuff prior to legacy Boot Fill in the standard CMOS stuff prior to legacy Boot

View File

@ -66,12 +66,12 @@ LegacyCalculateWriteStandardCmosChecksum (
for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) { for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) {
Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register)); Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register));
} }
LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8)); LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8));
LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff)); LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Fill in the standard CMOS stuff before Legacy16 load Fill in the standard CMOS stuff before Legacy16 load

View File

@ -136,10 +136,12 @@ LegacyBiosBuildIdeData (
if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) && if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&
(DevicePathSubType (DevicePathNode) == HW_PCI_DP) && (DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&
(DevicePathType (TempDevicePathNode) == MESSAGING_DEVICE_PATH) && (DevicePathType (TempDevicePathNode) == MESSAGING_DEVICE_PATH) &&
( DevicePathSubType(TempDevicePathNode) == MSG_ATAPI_DP) ) { (DevicePathSubType (TempDevicePathNode) == MSG_ATAPI_DP))
{
PciDevicePath = (PCI_DEVICE_PATH *)DevicePathNode; PciDevicePath = (PCI_DEVICE_PATH *)DevicePathNode;
break; break;
} }
DevicePathNode = NextDevicePathNode (DevicePathNode); DevicePathNode = NextDevicePathNode (DevicePathNode);
} }
@ -161,7 +163,8 @@ LegacyBiosBuildIdeData (
for (PciIndex = 0; PciIndex < 8; PciIndex++) { for (PciIndex = 0; PciIndex < 8; PciIndex++) {
if ((PciDevicePath->Device == LocalHddInfo[PciIndex].Device) && if ((PciDevicePath->Device == LocalHddInfo[PciIndex].Device) &&
(PciDevicePath->Function == LocalHddInfo[PciIndex].Function) (PciDevicePath->Function == LocalHddInfo[PciIndex].Function)
) { )
{
break; break;
} }
} }
@ -227,6 +230,7 @@ LegacyBiosBuildIdeData (
LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_ZIPDISK; LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_ZIPDISK;
} }
} }
FreePool (InquiryData); FreePool (InquiryData);
} else { } else {
if (IdeDevice == 0) { if (IdeDevice == 0) {
@ -246,7 +250,6 @@ LegacyBiosBuildIdeData (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
If the IDE channel is in compatibility (legacy) mode, remove all If the IDE channel is in compatibility (legacy) mode, remove all
PCI I/O BAR addresses from the controller. PCI I/O BAR addresses from the controller.
@ -289,7 +292,8 @@ InitLegacyIdeController (
// Check whether this is IDE // Check whether this is IDE
// //
if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) || if ((PciData.Hdr.ClassCode[2] != PCI_CLASS_MASS_STORAGE) ||
(PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE)) { (PciData.Hdr.ClassCode[1] != PCI_CLASS_MASS_STORAGE_IDE))
{
return; return;
} }
@ -301,6 +305,7 @@ InitLegacyIdeController (
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);
} }
if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) { if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);

View File

@ -93,7 +93,8 @@ GetShadowedRomParameters (
if ((mRomEntry[Index].PciSegment == PciSegment) && if ((mRomEntry[Index].PciSegment == PciSegment) &&
(mRomEntry[Index].PciBus == PciBus) && (mRomEntry[Index].PciBus == PciBus) &&
(mRomEntry[Index].PciDevice == PciDevice) && (mRomEntry[Index].PciDevice == PciDevice) &&
(mRomEntry[Index].PciFunction == PciFunction)) { (mRomEntry[Index].PciFunction == PciFunction))
{
break; break;
} }
} }
@ -157,6 +158,7 @@ RomShadow (
if (mRomCount >= ROM_MAX_ENTRIES) { if (mRomCount >= ROM_MAX_ENTRIES) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Get the PCI I/O Protocol on PciHandle // Get the PCI I/O Protocol on PciHandle
// //
@ -168,6 +170,7 @@ RomShadow (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Get the location of the PCI device // Get the location of the PCI device
// //
@ -188,7 +191,6 @@ RomShadow (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Return EFI_SUCCESS if PciHandle has had a legacy BIOS ROM shadowed. This Return EFI_SUCCESS if PciHandle has had a legacy BIOS ROM shadowed. This
information represents every call to RomShadow () information represents every call to RomShadow ()
@ -223,6 +225,7 @@ IsLegacyRom (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Get the location of the PCI device // Get the location of the PCI device
// //
@ -238,11 +241,12 @@ IsLegacyRom (
// See if the option ROM from PciHandle has been previously posted // See if the option ROM from PciHandle has been previously posted
// //
for (Index = 0; Index < mRomCount; Index++) { for (Index = 0; Index < mRomCount; Index++) {
if (mRomEntry[Index].PciSegment == Segment && if ((mRomEntry[Index].PciSegment == Segment) &&
mRomEntry[Index].PciBus == Bus && (mRomEntry[Index].PciBus == Bus) &&
mRomEntry[Index].PciDevice == Device && (mRomEntry[Index].PciDevice == Device) &&
mRomEntry[Index].PciFunction == Function (mRomEntry[Index].PciFunction == Function)
) { )
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
} }
@ -288,7 +292,6 @@ GetPciLegacyRom (
VOID *BackupImage; VOID *BackupImage;
VOID *BestImage; VOID *BestImage;
if (*ImageSize < sizeof (EFI_PCI_ROM_HEADER)) { if (*ImageSize < sizeof (EFI_PCI_ROM_HEADER)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -297,9 +300,10 @@ GetPciLegacyRom (
BackupImage = NULL; BackupImage = NULL;
RomHeader.Raw = *Rom; RomHeader.Raw = *Rom;
while (RomHeader.Generic->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE) { while (RomHeader.Generic->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
if (RomHeader.Generic->PcirOffset == 0 || if ((RomHeader.Generic->PcirOffset == 0) ||
(RomHeader.Generic->PcirOffset & 3) !=0 || ((RomHeader.Generic->PcirOffset & 3) != 0) ||
*ImageSize < RomHeader.Raw - (UINT8 *) *Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)) { (*ImageSize < RomHeader.Raw - (UINT8 *)*Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)))
{
break; break;
} }
@ -330,6 +334,7 @@ GetPciLegacyRom (
Match = TRUE; Match = TRUE;
break; break;
} }
DeviceIdList++; DeviceIdList++;
} }
} }
@ -389,11 +394,13 @@ GetPciLegacyRom (
if (BackupImage == NULL) { if (BackupImage == NULL) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// The versions of CSM16 and OpRom don't match exactly // The versions of CSM16 and OpRom don't match exactly
// //
BestImage = BackupImage; BestImage = BackupImage;
} }
RomHeader.Raw = BestImage; RomHeader.Raw = BestImage;
Pcir = (PCI_3_0_DATA_STRUCTURE *)(RomHeader.Raw + RomHeader.Generic->PcirOffset); Pcir = (PCI_3_0_DATA_STRUCTURE *)(RomHeader.Raw + RomHeader.Generic->PcirOffset);
*Rom = BestImage; *Rom = BestImage;
@ -475,6 +482,7 @@ CreateBridgeTable (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
for (Index = 0; Index < HandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
@ -514,7 +522,8 @@ CreateBridgeTable (
// Once we find one, store it in the SlotBridges[] // Once we find one, store it in the SlotBridges[]
// //
if ( (RoutingTable[Index1].Slot != 0) && (Bridges[BridgeIndex].PrimaryBus == RoutingTable[Index1].Bus) if ( (RoutingTable[Index1].Slot != 0) && (Bridges[BridgeIndex].PrimaryBus == RoutingTable[Index1].Bus)
&& ((Bridges[BridgeIndex].PciDevice << 3) == RoutingTable[Index1].Device)) { && ((Bridges[BridgeIndex].PciDevice << 3) == RoutingTable[Index1].Device))
{
CopyMem (&SlotBridges[SlotBridgeIndex], &Bridges[BridgeIndex], sizeof (BRIDGE_TABLE)); CopyMem (&SlotBridges[SlotBridgeIndex], &Bridges[BridgeIndex], sizeof (BRIDGE_TABLE));
SlotBridgeIndex++; SlotBridgeIndex++;
@ -532,7 +541,8 @@ CreateBridgeTable (
for (Index = 0; Index < BridgeIndex;) { for (Index = 0; Index < BridgeIndex;) {
for (Index1 = 0; Index1 < SlotBridgeIndex; Index1++) { for (Index1 = 0; Index1 < SlotBridgeIndex; Index1++) {
if (((Bridges[Index].PciBus == SlotBridges[Index1].PrimaryBus) && (Bridges[Index].PciDevice == SlotBridges[Index1].PciDevice)) || if (((Bridges[Index].PciBus == SlotBridges[Index1].PrimaryBus) && (Bridges[Index].PciDevice == SlotBridges[Index1].PciDevice)) ||
((Bridges[Index].PciBus >= SlotBridges[Index1].SecondaryBus) && (Bridges[Index].PciBus <= SlotBridges[Index1].SubordinateBus))) { ((Bridges[Index].PciBus >= SlotBridges[Index1].SecondaryBus) && (Bridges[Index].PciBus <= SlotBridges[Index1].SubordinateBus)))
{
// //
// We have found one that meets our criteria // We have found one that meets our criteria
// //
@ -574,18 +584,19 @@ CreateBridgeTable (
if ((Bridges[Index].SecondaryBus == Bridges[Index1].SecondaryBus) && if ((Bridges[Index].SecondaryBus == Bridges[Index1].SecondaryBus) &&
(Bridges[Index].SubordinateBus > Bridges[Index1].SubordinateBus) (Bridges[Index].SubordinateBus > Bridges[Index1].SubordinateBus)
) { )
{
SortedBridgeIndex[Index] = Index1; SortedBridgeIndex[Index] = Index1;
SortedBridgeIndex[Index1] = Index; SortedBridgeIndex[Index1] = Index;
} }
} }
} }
} }
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Find base Bridge for device. Find base Bridge for device.
@ -609,6 +620,7 @@ GetBaseBus (
) )
{ {
UINTN Index; UINTN Index;
for (Index = 0; Index < RoutingTableEntries; Index++) { for (Index = 0; Index < RoutingTableEntries; Index++) {
if ((RoutingTable[Index].Bus == PciBus) && (RoutingTable[Index].Device == (PciDevice << 3))) { if ((RoutingTable[Index].Bus == PciBus) && (RoutingTable[Index].Device == (PciDevice << 3))) {
return EFI_SUCCESS; return EFI_SUCCESS;
@ -698,6 +710,7 @@ Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
BOOLEAN BaseIndexFlag; BOOLEAN BaseIndexFlag;
UINTN BridgeIndex; UINTN BridgeIndex;
UINTN SBridgeIndex; UINTN SBridgeIndex;
BaseIndexFlag = FALSE; BaseIndexFlag = FALSE;
BridgeIndex = 0x00; BridgeIndex = 0x00;
@ -763,7 +776,6 @@ Rotate (B,C,D,A) by 1 giving C,D,A,B. Translated PIRQ is C.
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Copy the $PIR table as required. Copy the $PIR table as required.
@ -964,6 +976,7 @@ InstallLegacyIrqHandler (
Private->IntThunk->PciHandler.PrimaryBase = 0x1f0; Private->IntThunk->PciHandler.PrimaryBase = 0x1f0;
Private->IntThunk->PciHandler.PrimaryControl = 0x3f6; Private->IntThunk->PciHandler.PrimaryControl = 0x3f6;
} }
// //
// Secondary controller data // Secondary controller data
// //
@ -977,7 +990,6 @@ InstallLegacyIrqHandler (
// //
IoWrite16 (PrimaryMaster, 0x04); IoWrite16 (PrimaryMaster, 0x04);
IoWrite16 (SecondaryMaster, 0x04); IoWrite16 (SecondaryMaster, 0x04);
} }
// //
@ -991,7 +1003,6 @@ InstallLegacyIrqHandler (
Private->IntThunk->PciHandler.SecondaryBase = (UINT16)(PciConfigHeader->Device.Bar[2] & 0xfffc); Private->IntThunk->PciHandler.SecondaryBase = (UINT16)(PciConfigHeader->Device.Bar[2] & 0xfffc);
Private->IntThunk->PciHandler.SecondaryControl = (UINT16)((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2); Private->IntThunk->PciHandler.SecondaryControl = (UINT16)((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2);
} else { } else {
Private->IntThunk->PciHandler.SecondaryIrq = 15; Private->IntThunk->PciHandler.SecondaryIrq = 15;
Private->IntThunk->PciHandler.SecondaryBase = 0x170; Private->IntThunk->PciHandler.SecondaryBase = 0x170;
Private->IntThunk->PciHandler.SecondaryControl = 0x376; Private->IntThunk->PciHandler.SecondaryControl = 0x376;
@ -1043,10 +1054,8 @@ InstallLegacyIrqHandler (
0x20000, 0x20000,
&Granularity &Granularity
); );
} }
/** /**
Program the interrupt routing register in all the PCI devices. On a PC AT system Program the interrupt routing register in all the PCI devices. On a PC AT system
this register contains the 8259 IRQ vector that matches its PCI interrupt. this register contains the 8259 IRQ vector that matches its PCI interrupt.
@ -1136,6 +1145,7 @@ PciProgramAllInterruptLineRegisters (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (HandleCount == mHandleCount) { if (HandleCount == mHandleCount) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
@ -1199,6 +1209,7 @@ PciProgramAllInterruptLineRegisters (
NULL NULL
); );
} }
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x04, 1, &Command); PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x04, 1, &Command);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -1238,6 +1249,7 @@ PciProgramAllInterruptLineRegisters (
&InterruptPin &InterruptPin
); );
} }
// //
// Translate InterruptPin(0-3) into PIRQ // Translate InterruptPin(0-3) into PIRQ
// //
@ -1327,6 +1339,7 @@ PciProgramAllInterruptLineRegisters (
} }
} }
} }
// //
// Write InterruptPin and enable 8259. // Write InterruptPin and enable 8259.
// //
@ -1358,11 +1371,11 @@ PciProgramAllInterruptLineRegisters (
); );
} }
} }
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Find & verify PnP Expansion header in ROM image Find & verify PnP Expansion header in ROM image
@ -1385,6 +1398,7 @@ FindNextPnpExpansionHeader (
{ {
UINTN TempData; UINTN TempData;
LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr; LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr;
LocalPnpPtr = *PnpPtr; LocalPnpPtr = *PnpPtr;
if (FirstHeader == FIRST_INSTANCE) { if (FirstHeader == FIRST_INSTANCE) {
mBasePnpPtr = LocalPnpPtr; mBasePnpPtr = LocalPnpPtr;
@ -1413,7 +1427,6 @@ FindNextPnpExpansionHeader (
} }
} }
/** /**
Update list of Bev or BCV table entries. Update list of Bev or BCV table entries.
@ -1445,6 +1458,7 @@ UpdateBevBcvTable (
UINTN Function; UINTN Function;
UINT8 Class; UINT8 Class;
UINT16 DeviceType; UINT16 DeviceType;
Segment = 0; Segment = 0;
Bus = 0; Bus = 0;
Device = 0; Device = 0;
@ -1499,6 +1513,7 @@ UpdateBevBcvTable (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
break; break;
} }
// //
// There can be additional $PnP headers within the OPROM. // There can be additional $PnP headers within the OPROM.
// Example: SCSI can have one per drive. // Example: SCSI can have one per drive.
@ -1547,7 +1562,6 @@ UpdateBevBcvTable (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol Shadow all the PCI legacy ROMs. Use data from the Legacy BIOS Protocol
to chose the order. Skip any devices that have already have legacy to chose the order. Skip any devices that have already have legacy
@ -1606,6 +1620,7 @@ PciShadowRoms (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
// //
// Place the VGA handle as first. // Place the VGA handle as first.
// //
@ -1617,6 +1632,7 @@ PciShadowRoms (
break; break;
} }
} }
// //
// Allocate memory to save Command WORD from each device. We do this // Allocate memory to save Command WORD from each device. We do this
// to restore devices to same state as EFI after switching to legacy. // to restore devices to same state as EFI after switching to legacy.
@ -1628,12 +1644,12 @@ PciShadowRoms (
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
// //
// Disconnect all EFI devices first. This covers cases where alegacy BIOS // Disconnect all EFI devices first. This covers cases where alegacy BIOS
// may control multiple PCI devices. // may control multiple PCI devices.
// //
for (Index = 0; Index < HandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -1659,6 +1675,7 @@ PciShadowRoms (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
continue; continue;
} }
// //
// Stop EFI Drivers with oprom. // Stop EFI Drivers with oprom.
// //
@ -1668,11 +1685,11 @@ PciShadowRoms (
NULL NULL
); );
} }
// //
// For every device that has not had a legacy ROM started. Start a legacy ROM. // For every device that has not had a legacy ROM started. Start a legacy ROM.
// //
for (Index = 0; Index < HandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
HandleBuffer[Index], HandleBuffer[Index],
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -1698,9 +1715,10 @@ PciShadowRoms (
// one will work in legacy mode (OPROM will be given control) and // one will work in legacy mode (OPROM will be given control) and
// other Video devices will work in native mode (OS driver will handle these devices). // other Video devices will work in native mode (OS driver will handle these devices).
// //
if (IS_PCI_DISPLAY (&Pci) && Index != 0) { if (IS_PCI_DISPLAY (&Pci) && (Index != 0)) {
continue; continue;
} }
// //
// Skip any device that already has a legacy ROM run // Skip any device that already has a legacy ROM run
// //
@ -1712,7 +1730,7 @@ PciShadowRoms (
// //
// If legacy VBIOS Oprom has not been dispatched before, install legacy VBIOS here. // If legacy VBIOS Oprom has not been dispatched before, install legacy VBIOS here.
// //
if (IS_PCI_DISPLAY (&Pci) && Index == 0) { if (IS_PCI_DISPLAY (&Pci) && (Index == 0)) {
Status = LegacyBiosInstallVgaRom (Private); Status = LegacyBiosInstallVgaRom (Private);
// //
// A return status of EFI_NOT_FOUND is considered valid (No EFI // A return status of EFI_NOT_FOUND is considered valid (No EFI
@ -1740,6 +1758,7 @@ PciShadowRoms (
continue; continue;
} }
} }
// //
// Restore Command register so legacy has same devices enabled or disabled // Restore Command register so legacy has same devices enabled or disabled
// as EFI. // as EFI.
@ -1773,6 +1792,7 @@ PciShadowRoms (
NULL NULL
); );
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Command[Index] = 0x1f; Command[Index] = 0x1f;
} }
@ -1793,7 +1813,6 @@ PciShadowRoms (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Test to see if a legacy PCI ROM exists for this device. Optionally return Test to see if a legacy PCI ROM exists for this device. Optionally return
the Legacy ROM instance for this PCI device. the Legacy ROM instance for this PCI device.
@ -1829,7 +1848,6 @@ LegacyBiosCheckPciRom (
NULL, NULL,
NULL NULL
); );
} }
/** /**
@ -1891,6 +1909,7 @@ LegacyBiosCheckPciRomEx (
*Flags |= (UINTN)(ROM_FOUND | VALID_LEGACY_ROM); *Flags |= (UINTN)(ROM_FOUND | VALID_LEGACY_ROM);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// Check for PCI ROM Bar // Check for PCI ROM Bar
// //
@ -1983,6 +2002,7 @@ EnablePs2Keyboard (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
for (Index = 0; Index < HandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
// //
// Open the IO Abstraction(s) needed to perform the supported test // Open the IO Abstraction(s) needed to perform the supported test
@ -2001,7 +2021,7 @@ EnablePs2Keyboard (
// Use the ISA I/O Protocol to see if Controller is the Keyboard // Use the ISA I/O Protocol to see if Controller is the Keyboard
// controller // controller
// //
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303) || IsaIo->ResourceList->Device.UID != 0) { if ((IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x303)) || (IsaIo->ResourceList->Device.UID != 0)) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} }
@ -2017,11 +2037,11 @@ EnablePs2Keyboard (
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE); gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
} }
} }
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Load a legacy PC-AT OpROM for VGA controller. Load a legacy PC-AT OpROM for VGA controller.
@ -2132,6 +2152,7 @@ LegacyBiosInstallVgaRom (
return Status; return Status;
} }
} }
// //
// Find all the Thunk Driver // Find all the Thunk Driver
// //
@ -2208,7 +2229,6 @@ LegacyBiosInstallVgaRom (
FreePool (ConnectHandleBuffer); FreePool (ConnectHandleBuffer);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
Private->VgaInstalled = FALSE; Private->VgaInstalled = FALSE;
// //
@ -2221,7 +2241,6 @@ LegacyBiosInstallVgaRom (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Load a legacy PC-AT OpROM. Load a legacy PC-AT OpROM.
@ -2300,11 +2319,11 @@ LegacyBiosInstallRom (
if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) && if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
(Private->Legacy16Table->UmaAddress != 0) && (Private->Legacy16Table->UmaAddress != 0) &&
(Private->Legacy16Table->UmaSize != 0) && (Private->Legacy16Table->UmaSize != 0) &&
(MaxRomAddr > (Private->Legacy16Table->UmaAddress))) { (MaxRomAddr > (Private->Legacy16Table->UmaAddress)))
{
MaxRomAddr = Private->Legacy16Table->UmaAddress; MaxRomAddr = Private->Legacy16Table->UmaAddress;
} }
PciProgramAllInterruptLineRegisters (Private); PciProgramAllInterruptLineRegisters (Private);
if ((OpromRevision >= 3) && (Private->Csm16PciInterfaceVersion >= 0x0300)) { if ((OpromRevision >= 3) && (Private->Csm16PciInterfaceVersion >= 0x0300)) {
@ -2331,6 +2350,7 @@ LegacyBiosInstallRom (
); );
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
InitAddress = (UINTN)PhysicalAddress; InitAddress = (UINTN)PhysicalAddress;
// //
// then test if there is enough space for its RT code // then test if there is enough space for its RT code
@ -2414,7 +2434,6 @@ LegacyBiosInstallRom (
} }
if (PciHandle != mVgaHandle) { if (PciHandle != mVgaHandle) {
EnablePs2Keyboard (); EnablePs2Keyboard ();
// //
@ -2422,6 +2441,7 @@ LegacyBiosInstallRom (
// //
VideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE)); VideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
} }
); );
// //
@ -2476,7 +2496,6 @@ LegacyBiosInstallRom (
PciEnableStatus = EFI_UNSUPPORTED; PciEnableStatus = EFI_UNSUPPORTED;
ZeroMem (&Regs, sizeof (Regs)); ZeroMem (&Regs, sizeof (Regs));
if (PciHandle != NULL) { if (PciHandle != NULL) {
Status = gBS->HandleProtocol ( Status = gBS->HandleProtocol (
PciHandle, PciHandle,
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -2543,6 +2562,7 @@ LegacyBiosInstallRom (
Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT8)Private->IntThunk->DispatchOpromTable.NumberBbsEntries; Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT8)Private->IntThunk->DispatchOpromTable.NumberBbsEntries;
mIgnoreBbsUpdateFlag = TRUE; mIgnoreBbsUpdateFlag = TRUE;
} }
// //
// Check if non-BBS compliant drives found // Check if non-BBS compliant drives found
// //
@ -2557,6 +2577,7 @@ LegacyBiosInstallRom (
Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd; Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
Private->LegacyEfiHddTableIndex += 1; Private->LegacyEfiHddTableIndex += 1;
} }
// //
// Skip video mode set, if installing VGA // Skip video mode set, if installing VGA
// //
@ -2564,9 +2585,11 @@ LegacyBiosInstallRom (
// //
// Set mode settings since PrepareToScanRom may change mode // Set mode settings since PrepareToScanRom may change mode
// //
ACCESS_PAGE0_CODE ({ ACCESS_PAGE0_CODE (
{
OldVideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE)); OldVideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
}); }
);
if (VideoMode != OldVideoMode) { if (VideoMode != OldVideoMode) {
// //
@ -2577,6 +2600,7 @@ LegacyBiosInstallRom (
Private->LegacyBios.Int86 (&Private->LegacyBios, 0x10, &Regs); Private->LegacyBios.Int86 (&Private->LegacyBios, 0x10, &Regs);
} }
} }
// //
// Regs.X.AX from the adapter initializion is ignored since some adapters // Regs.X.AX from the adapter initializion is ignored since some adapters
// do not follow the standard of setting AX = 0 on success. // do not follow the standard of setting AX = 0 on success.
@ -2650,6 +2674,7 @@ LegacyBiosInstallRom (
Private->LegacyEfiHddTableIndex += 1; Private->LegacyEfiHddTableIndex += 1;
} }
} }
// //
// Mark PCI device as having a legacy BIOS ROM loaded. // Mark PCI device as having a legacy BIOS ROM loaded.
// //
@ -2730,6 +2755,7 @@ IoMmuGrantAccess (
if (mIoMmu == NULL) { if (mIoMmu == NULL) {
gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu); gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu);
} }
if (mIoMmu != NULL) { if (mIoMmu != NULL) {
Status = mIoMmu->Map ( Status = mIoMmu->Map (
mIoMmu, mIoMmu,
@ -2754,6 +2780,7 @@ IoMmuGrantAccess (
} }
} }
} }
return Status; return Status;
} }
@ -2903,7 +2930,8 @@ LegacyBiosInstallPciRom (
) )
&& &&
(!Private->VgaInstalled) (!Private->VgaInstalled)
) { )
{
mVgaInstallationInProgress = TRUE; mVgaInstallationInProgress = TRUE;
// //
@ -2911,6 +2939,7 @@ LegacyBiosInstallPciRom (
// //
} }
} }
// //
// To run any legacy image, the VGA needs to be installed first. // To run any legacy image, the VGA needs to be installed first.
// if installing the video, then don't need the thunk as already installed. // if installing the video, then don't need the thunk as already installed.
@ -2943,6 +2972,7 @@ LegacyBiosInstallPciRom (
} }
} }
} }
// //
// See if the option ROM for PciHandle has already been executed // See if the option ROM for PciHandle has already been executed
// //
@ -3012,9 +3042,10 @@ LegacyBiosInstallPciRom (
} }
LocalRomImage = *RomImage; LocalRomImage = *RomImage;
if (((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE || if ((((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) ||
((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset == 0 || (((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->PcirOffset == 0) ||
(((PCI_EXPANSION_ROM_HEADER *) LocalRomImage)->PcirOffset & 3 ) != 0) { ((((PCI_EXPANSION_ROM_HEADER *)LocalRomImage)->PcirOffset & 3) != 0))
{
mVgaInstallationInProgress = FALSE; mVgaInstallationInProgress = FALSE;
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -3033,6 +3064,7 @@ LegacyBiosInstallPciRom (
} else { } else {
OpromRevision = 0; OpromRevision = 0;
} }
if (Pcir->Revision < 3) { if (Pcir->Revision < 3) {
RuntimeImageLength = 0; RuntimeImageLength = 0;
} else { } else {

View File

@ -61,6 +61,7 @@ LegacyBiosBuildSioDataFromSio (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Collect legacy information from each of the ISA controllers in the system // Collect legacy information from each of the ISA controllers in the system
// //
@ -132,7 +133,8 @@ LegacyBiosBuildSioDataFromSio (
if ((Acpi == NULL) || (DevicePathType (Acpi) != ACPI_DEVICE_PATH) || if ((Acpi == NULL) || (DevicePathType (Acpi) != ACPI_DEVICE_PATH) ||
((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP)) ((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP))
) { )
{
continue; continue;
} }
@ -141,9 +143,8 @@ LegacyBiosBuildSioDataFromSio (
// //
// Ignore DMA resource since it is always returned NULL // Ignore DMA resource since it is always returned NULL
// //
if (Acpi->HID == EISA_PNP_ID (0x500) || Acpi->HID == EISA_PNP_ID (0x501)) { if ((Acpi->HID == EISA_PNP_ID (0x500)) || (Acpi->HID == EISA_PNP_ID (0x501))) {
if ((Acpi->UID < 4) && (Address != MAX_UINT16) && (Irq != MAX_UINT8)) {
if (Acpi->UID < 4 && Address != MAX_UINT16 && Irq != MAX_UINT8) {
// //
// Get the handle of the child device that has opened the Super I/O Protocol // Get the handle of the child device that has opened the Super I/O Protocol
// //
@ -156,6 +157,7 @@ LegacyBiosBuildSioDataFromSio (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) { for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {
if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) { if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo); Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
@ -172,14 +174,15 @@ LegacyBiosBuildSioDataFromSio (
FreePool (OpenInfoBuffer); FreePool (OpenInfoBuffer);
} }
} }
// //
// See if this is an ISA parallel port // See if this is an ISA parallel port
// //
// Ignore DMA resource since it is always returned NULL, port // Ignore DMA resource since it is always returned NULL, port
// only used in output mode. // only used in output mode.
// //
if (Acpi->HID == EISA_PNP_ID (0x400) || Acpi->HID == EISA_PNP_ID (0x401)) { if ((Acpi->HID == EISA_PNP_ID (0x400)) || (Acpi->HID == EISA_PNP_ID (0x401))) {
if (Acpi->UID < 3 && Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) { if ((Acpi->UID < 3) && (Address != MAX_UINT16) && (Irq != MAX_UINT8) && (Dma != MAX_UINT8)) {
SioParallel = &SioPtr->Parallel[Acpi->UID]; SioParallel = &SioPtr->Parallel[Acpi->UID];
SioParallel->Address = Address; SioParallel->Address = Address;
SioParallel->Irq = Irq; SioParallel->Irq = Irq;
@ -187,11 +190,12 @@ LegacyBiosBuildSioDataFromSio (
SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY; SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
} }
} }
// //
// See if this is an ISA floppy controller // See if this is an ISA floppy controller
// //
if (Acpi->HID == EISA_PNP_ID (0x604)) { if (Acpi->HID == EISA_PNP_ID (0x604)) {
if (Address != MAX_UINT16 && Irq != MAX_UINT8 && Dma != MAX_UINT8) { if ((Address != MAX_UINT16) && (Irq != MAX_UINT8) && (Dma != MAX_UINT8)) {
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo); Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
SioFloppy = &SioPtr->Floppy; SioFloppy = &SioPtr->Floppy;
@ -202,6 +206,7 @@ LegacyBiosBuildSioDataFromSio (
} }
} }
} }
// //
// See if this is a mouse // See if this is a mouse
// Always set mouse found so USB hot plug will work // Always set mouse found so USB hot plug will work
@ -225,7 +230,6 @@ LegacyBiosBuildSioDataFromSio (
FreePool (HandleBuffer); FreePool (HandleBuffer);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
@ -274,11 +278,11 @@ LegacyBiosBuildSioDataFromIsaIo (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Collect legacy information from each of the ISA controllers in the system // Collect legacy information from each of the ISA controllers in the system
// //
for (Index = 0; Index < HandleCount; Index++) { for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **)&IsaIo); Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **)&IsaIo);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
@ -289,6 +293,7 @@ LegacyBiosBuildSioDataFromIsaIo (
if (ResourceList == NULL) { if (ResourceList == NULL) {
continue; continue;
} }
// //
// Collect the resource types neededto fill in the SIO data structure // Collect the resource types neededto fill in the SIO data structure
// //
@ -298,7 +303,8 @@ LegacyBiosBuildSioDataFromIsaIo (
for (ResourceIndex = 0; for (ResourceIndex = 0;
ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList; ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList;
ResourceIndex++ ResourceIndex++
) { )
{
switch (ResourceList->ResourceItem[ResourceIndex].Type) { switch (ResourceList->ResourceItem[ResourceIndex].Type) {
case EfiIsaAcpiResourceIo: case EfiIsaAcpiResourceIo:
IoResource = &ResourceList->ResourceItem[ResourceIndex]; IoResource = &ResourceList->ResourceItem[ResourceIndex];
@ -319,17 +325,18 @@ LegacyBiosBuildSioDataFromIsaIo (
break; break;
} }
} }
// //
// See if this is an ISA serial port // See if this is an ISA serial port
// //
// Ignore DMA resource since it is always returned NULL // Ignore DMA resource since it is always returned NULL
// //
if (ResourceList->Device.HID == EISA_PNP_ID (0x500) || ResourceList->Device.HID == EISA_PNP_ID (0x501)) { if ((ResourceList->Device.HID == EISA_PNP_ID (0x500)) || (ResourceList->Device.HID == EISA_PNP_ID (0x501))) {
if ((ResourceList->Device.UID <= 3) &&
if (ResourceList->Device.UID <= 3 && (IoResource != NULL) &&
IoResource != NULL && (InterruptResource != NULL)
InterruptResource != NULL )
) { {
// //
// Get the handle of the child device that has opened the ISA I/O Protocol // Get the handle of the child device that has opened the ISA I/O Protocol
// //
@ -342,6 +349,7 @@ LegacyBiosBuildSioDataFromIsaIo (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
// //
// We want resource for legacy even if no 32-bit driver installed // We want resource for legacy even if no 32-bit driver installed
// //
@ -361,18 +369,20 @@ LegacyBiosBuildSioDataFromIsaIo (
FreePool (OpenInfoBuffer); FreePool (OpenInfoBuffer);
} }
} }
// //
// See if this is an ISA parallel port // See if this is an ISA parallel port
// //
// Ignore DMA resource since it is always returned NULL, port // Ignore DMA resource since it is always returned NULL, port
// only used in output mode. // only used in output mode.
// //
if (ResourceList->Device.HID == EISA_PNP_ID (0x400) || ResourceList->Device.HID == EISA_PNP_ID (0x401)) { if ((ResourceList->Device.HID == EISA_PNP_ID (0x400)) || (ResourceList->Device.HID == EISA_PNP_ID (0x401))) {
if (ResourceList->Device.UID <= 2 && if ((ResourceList->Device.UID <= 2) &&
IoResource != NULL && (IoResource != NULL) &&
InterruptResource != NULL && (InterruptResource != NULL) &&
DmaResource != NULL (DmaResource != NULL)
) { )
{
SioParallel = &SioPtr->Parallel[ResourceList->Device.UID]; SioParallel = &SioPtr->Parallel[ResourceList->Device.UID];
SioParallel->Address = (UINT16)IoResource->StartRange; SioParallel->Address = (UINT16)IoResource->StartRange;
SioParallel->Irq = (UINT8)InterruptResource->StartRange; SioParallel->Irq = (UINT8)InterruptResource->StartRange;
@ -380,11 +390,12 @@ LegacyBiosBuildSioDataFromIsaIo (
SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY; SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
} }
} }
// //
// See if this is an ISA floppy controller // See if this is an ISA floppy controller
// //
if (ResourceList->Device.HID == EISA_PNP_ID (0x604)) { if (ResourceList->Device.HID == EISA_PNP_ID (0x604)) {
if (IoResource != NULL && InterruptResource != NULL && DmaResource != NULL) { if ((IoResource != NULL) && (InterruptResource != NULL) && (DmaResource != NULL)) {
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo); Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiBlockIoProtocolGuid, (VOID **)&BlockIo);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
SioFloppy = &SioPtr->Floppy; SioFloppy = &SioPtr->Floppy;
@ -395,6 +406,7 @@ LegacyBiosBuildSioDataFromIsaIo (
} }
} }
} }
// //
// See if this is a mouse // See if this is a mouse
// Always set mouse found so USB hot plug will work // Always set mouse found so USB hot plug will work

View File

@ -237,13 +237,16 @@ InternalLegacyBiosFarCall (
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
Count++; Count++;
} }
if (Status == EFI_SUCCESS) { if (Status == EFI_SUCCESS) {
Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL); Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL);
} }
} }
if (Count >= 2) { if (Count >= 2) {
DEBUG ((DEBUG_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n")); DEBUG ((DEBUG_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n"));
} }
ASSERT (Count < 2); ASSERT (Count < 2);
DEBUG_CODE_END (); DEBUG_CODE_END ();
@ -252,11 +255,11 @@ InternalLegacyBiosFarCall (
// period is less than the CSM required rate of 54.9254, then force the 8254 // period is less than the CSM required rate of 54.9254, then force the 8254
// PIT counter to 0, which is the CSM required rate of 54.9254 ms // PIT counter to 0, which is the CSM required rate of 54.9254 ms
// //
if (Private->TimerUses8254 && TimerPeriod < 549254) { if (Private->TimerUses8254 && (TimerPeriod < 549254)) {
SetPitCount (0); SetPitCount (0);
} }
if (Stack != NULL && StackSize != 0) { if ((Stack != NULL) && (StackSize != 0)) {
// //
// Copy Stack to low memory stack // Copy Stack to low memory stack
// //
@ -279,7 +282,7 @@ InternalLegacyBiosFarCall (
AsmThunk16 (&mThunkContext); AsmThunk16 (&mThunkContext);
if (Stack != NULL && StackSize != 0) { if ((Stack != NULL) && (StackSize != 0)) {
// //
// Copy low memory stack to Stack // Copy low memory stack to Stack
// //

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "LegacyBootMaintUi.h" #include "LegacyBootMaintUi.h"
LEGACY_BOOT_OPTION_CALLBACK_DATA *mLegacyBootOptionPrivate = NULL; LEGACY_BOOT_OPTION_CALLBACK_DATA *mLegacyBootOptionPrivate = NULL;
@ -16,7 +15,6 @@ CHAR16 mLegacyBootStorageName[] = L"LegacyBootData";
BBS_TYPE mBbsType[] = { BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM, BBS_EMBED_NETWORK, BBS_BEV_DEVICE, BBS_UNKNOWN }; BBS_TYPE mBbsType[] = { BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM, BBS_EMBED_NETWORK, BBS_BEV_DEVICE, BBS_UNKNOWN };
BOOLEAN mFirstEnterLegacyForm = FALSE; BOOLEAN mFirstEnterLegacyForm = FALSE;
/// ///
/// Legacy FD Info from LegacyBios.GetBbsInfo() /// Legacy FD Info from LegacyBios.GetBbsInfo()
/// ///
@ -62,13 +60,11 @@ LEGACY_MENU_OPTION LegacyBEVMenu = {
0 0
}; };
VOID *mLegacyStartOpCodeHandle = NULL; VOID *mLegacyStartOpCodeHandle = NULL;
VOID *mLegacyEndOpCodeHandle = NULL; VOID *mLegacyEndOpCodeHandle = NULL;
EFI_IFR_GUID_LABEL *mLegacyStartLabel = NULL; EFI_IFR_GUID_LABEL *mLegacyStartLabel = NULL;
EFI_IFR_GUID_LABEL *mLegacyEndLabel = NULL; EFI_IFR_GUID_LABEL *mLegacyEndLabel = NULL;
HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = { HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = {
{ {
{ {
@ -79,7 +75,8 @@ HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = {
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8) (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
} }
}, },
{ 0x6bc75598, 0x89b4, 0x483d, { 0x91, 0x60, 0x7f, 0x46, 0x9a, 0x96, 0x35, 0x31 } } { 0x6bc75598, 0x89b4, 0x483d, { 0x91, 0x60, 0x7f, 0x46, 0x9a, 0x96, 0x35, 0x31 }
}
}, },
{ {
END_DEVICE_PATH_TYPE, END_DEVICE_PATH_TYPE,
@ -101,7 +98,6 @@ GetLegacyOptions (
VOID VOID
); );
/** /**
Base on the L"LegacyDevOrder" variable to build the current order data. Base on the L"LegacyDevOrder" variable to build the current order data.
@ -170,13 +166,13 @@ OrderLegacyBootOption4SameType (
ASSERT (*DisBootOption != NULL); ASSERT (*DisBootOption != NULL);
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) { for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]); UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);
Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption); Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) && if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP)) { (DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP))
{
// //
// Legacy Boot Option // Legacy Boot Option
// //
@ -188,6 +184,7 @@ OrderLegacyBootOption4SameType (
DeviceTypeArray[Index] = BBS_TYPE_UNKNOWN; DeviceTypeArray[Index] = BBS_TYPE_UNKNOWN;
BbsIndexArray[Index] = 0xFFFF; BbsIndexArray[Index] = 0xFFFF;
} }
EfiBootManagerFreeLoadOption (&BootOption); EfiBootManagerFreeLoadOption (&BootOption);
} }
@ -211,6 +208,7 @@ OrderLegacyBootOption4SameType (
(*EnBootOption)[*EnBootOptionCount] = BootOrder[Index]; (*EnBootOption)[*EnBootOptionCount] = BootOrder[Index];
(*EnBootOptionCount)++; (*EnBootOptionCount)++;
} }
break; break;
} }
} }
@ -278,14 +276,12 @@ UpdateBBSOption (
UINTN DisBootOptionCount; UINTN DisBootOptionCount;
UINTN BufferSize; UINTN BufferSize;
DisMap = NULL; DisMap = NULL;
NewOrder = NULL; NewOrder = NULL;
CurrentType = 0; CurrentType = 0;
EnBootOption = NULL; EnBootOption = NULL;
DisBootOption = NULL; DisBootOption = NULL;
DisMap = mLegacyBootOptionPrivate->MaintainMapData->DisableMap; DisMap = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
@ -296,6 +292,7 @@ UpdateBBSOption (
if (VarData == NULL) { if (VarData == NULL) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
OriginalPtr = VarData; OriginalPtr = VarData;
while (mBbsType[CurrentType] != BBS_UNKNOWN) { while (mBbsType[CurrentType] != BBS_UNKNOWN) {
@ -458,7 +455,6 @@ UpdateBBSOption (
} }
} }
FreePool (EnBootOption); FreePool (EnBootOption);
FreePool (DisBootOption); FreePool (DisBootOption);
@ -517,9 +513,10 @@ LegacyBootOptionExtractConfig (
OUT EFI_STRING *Results OUT EFI_STRING *Results
) )
{ {
if (Progress == NULL || Results == NULL) { if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
*Progress = Request; *Progress = Request;
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -553,8 +550,7 @@ LegacyBootOptionRouteConfig (
LEGACY_BOOT_NV_DATA *CurrentNVMapData; LEGACY_BOOT_NV_DATA *CurrentNVMapData;
UINTN BufferSize; UINTN BufferSize;
if ((Configuration == NULL) || (Progress == NULL)) {
if (Configuration == NULL || Progress == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -610,6 +606,7 @@ RefreshLegacyUpdateData (
if (mLegacyStartOpCodeHandle != NULL) { if (mLegacyStartOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (mLegacyStartOpCodeHandle); HiiFreeOpCodeHandle (mLegacyStartOpCodeHandle);
} }
if (mLegacyEndOpCodeHandle != NULL) { if (mLegacyEndOpCodeHandle != NULL) {
HiiFreeOpCodeHandle (mLegacyEndOpCodeHandle); HiiFreeOpCodeHandle (mLegacyEndOpCodeHandle);
} }
@ -645,7 +642,6 @@ RefreshLegacyUpdateData (
mLegacyEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL; mLegacyEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
mLegacyEndLabel->Number = FORM_BOOT_LEGACY_LABEL_END; mLegacyEndLabel->Number = FORM_BOOT_LEGACY_LABEL_END;
} }
/** /**
@ -819,7 +815,6 @@ UpdateLegacyDeviceOrderPage (
OptionsOpCodeHandle = HiiAllocateOpCodeHandle (); OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (OptionsOpCodeHandle != NULL); ASSERT (OptionsOpCodeHandle != NULL);
for (Index = 0; Index < OptionMenu->MenuNumber; Index++) { for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {
NewMenuEntry = GetMenuEntry (OptionMenu, Index); NewMenuEntry = GetMenuEntry (OptionMenu, Index);
// //
@ -895,7 +890,6 @@ UpdateLegacyDeviceOrderPage (
HiiFreeOpCodeHandle (OptionsOpCodeHandle); HiiFreeOpCodeHandle (OptionsOpCodeHandle);
} }
/** /**
Adjust question value when one question value has been changed. Adjust question value when one question value has been changed.
@ -939,23 +933,23 @@ AdjustOptionValue (
HiiGetBrowserData (&mLegacyBootOptionGuid, mLegacyBootStorageName, sizeof (LEGACY_BOOT_NV_DATA), (UINT8 *)CurrentNVMap); HiiGetBrowserData (&mLegacyBootOptionGuid, mLegacyBootStorageName, sizeof (LEGACY_BOOT_NV_DATA), (UINT8 *)CurrentNVMap);
DisMap = mLegacyBootOptionPrivate->MaintainMapData->DisableMap; DisMap = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;
if (QuestionId >= LEGACY_FD_QUESTION_ID && QuestionId < LEGACY_FD_QUESTION_ID + MAX_MENU_NUMBER) { if ((QuestionId >= LEGACY_FD_QUESTION_ID) && (QuestionId < LEGACY_FD_QUESTION_ID + MAX_MENU_NUMBER)) {
Number = (UINT16)LegacyFDMenu.MenuNumber; Number = (UINT16)LegacyFDMenu.MenuNumber;
CurrentVal = CurrentNVMap->LegacyFD; CurrentVal = CurrentNVMap->LegacyFD;
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyFD; Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyFD;
} else if (QuestionId >= LEGACY_HD_QUESTION_ID && QuestionId < LEGACY_HD_QUESTION_ID + MAX_MENU_NUMBER) { } else if ((QuestionId >= LEGACY_HD_QUESTION_ID) && (QuestionId < LEGACY_HD_QUESTION_ID + MAX_MENU_NUMBER)) {
Number = (UINT16)LegacyHDMenu.MenuNumber; Number = (UINT16)LegacyHDMenu.MenuNumber;
CurrentVal = CurrentNVMap->LegacyHD; CurrentVal = CurrentNVMap->LegacyHD;
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyHD; Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyHD;
} else if (QuestionId >= LEGACY_CD_QUESTION_ID && QuestionId < LEGACY_CD_QUESTION_ID + MAX_MENU_NUMBER) { } else if ((QuestionId >= LEGACY_CD_QUESTION_ID) && (QuestionId < LEGACY_CD_QUESTION_ID + MAX_MENU_NUMBER)) {
Number = (UINT16)LegacyCDMenu.MenuNumber; Number = (UINT16)LegacyCDMenu.MenuNumber;
CurrentVal = CurrentNVMap->LegacyCD; CurrentVal = CurrentNVMap->LegacyCD;
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyCD; Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyCD;
} else if (QuestionId >= LEGACY_NET_QUESTION_ID && QuestionId < LEGACY_NET_QUESTION_ID + MAX_MENU_NUMBER) { } else if ((QuestionId >= LEGACY_NET_QUESTION_ID) && (QuestionId < LEGACY_NET_QUESTION_ID + MAX_MENU_NUMBER)) {
Number = (UINT16)LegacyNETMenu.MenuNumber; Number = (UINT16)LegacyNETMenu.MenuNumber;
CurrentVal = CurrentNVMap->LegacyNET; CurrentVal = CurrentNVMap->LegacyNET;
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyNET; Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyNET;
} else if (QuestionId >= LEGACY_BEV_QUESTION_ID && QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER) { } else if ((QuestionId >= LEGACY_BEV_QUESTION_ID) && (QuestionId < LEGACY_BEV_QUESTION_ID + MAX_MENU_NUMBER)) {
Number = (UINT16)LegacyBEVMenu.MenuNumber; Number = (UINT16)LegacyBEVMenu.MenuNumber;
CurrentVal = CurrentNVMap->LegacyBEV; CurrentVal = CurrentNVMap->LegacyBEV;
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyBEV; Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyBEV;
@ -1040,6 +1034,7 @@ AdjustOptionValue (
} }
} }
} }
// //
// To prevent DISABLE appears in the middle of the list // To prevent DISABLE appears in the middle of the list
// we should perform a re-ordering // we should perform a re-ordering
@ -1112,7 +1107,7 @@ LegacyBootOptionCallback (
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
) )
{ {
if (Action != EFI_BROWSER_ACTION_CHANGED && Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_FORM_OPEN) { if ((Action != EFI_BROWSER_ACTION_CHANGED) && (Action != EFI_BROWSER_ACTION_CHANGING) && (Action != EFI_BROWSER_ACTION_FORM_OPEN)) {
// //
// Do nothing for other UEFI Action. Only do call back when data is changed or the form is open. // Do nothing for other UEFI Action. Only do call back when data is changed or the form is open.
// //
@ -1160,10 +1155,10 @@ LegacyBootOptionCallback (
AdjustOptionValue (QuestionId, Value); AdjustOptionValue (QuestionId, Value);
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Create a menu entry by given menu type. Create a menu entry by given menu type.
@ -1343,9 +1338,11 @@ GetLegacyOptions (
for (Index = 0; Index < BootOptionCount; Index++) { for (Index = 0; Index < BootOptionCount; Index++) {
if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) || if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||
(DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP) (DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)
) { )
{
continue; continue;
} }
ASSERT (BootOption[Index].OptionalDataSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA)); ASSERT (BootOption[Index].OptionalDataSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA));
NewMenuEntry = CreateMenuEntry (); NewMenuEntry = CreateMenuEntry ();
ASSERT (NewMenuEntry != NULL); ASSERT (NewMenuEntry != NULL);
@ -1395,7 +1392,6 @@ GetLegacyOptions (
LegacyBEVMenu.MenuNumber = BEVNum; LegacyBEVMenu.MenuNumber = BEVNum;
} }
/** /**
Install Boot Manager Menu driver. Install Boot Manager Menu driver.
@ -1483,7 +1479,7 @@ LegacyBootMaintUiLibDestructor (
{ {
EFI_STATUS Status; EFI_STATUS Status;
if (mLegacyBootOptionPrivate != NULL && mLegacyBootOptionPrivate->DriverHandle != NULL) { if ((mLegacyBootOptionPrivate != NULL) && (mLegacyBootOptionPrivate->DriverHandle != NULL)) {
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
mLegacyBootOptionPrivate->DriverHandle, mLegacyBootOptionPrivate->DriverHandle,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
@ -1502,4 +1498,3 @@ LegacyBootMaintUiLibDestructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -6,13 +6,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _EFI_LEGACY_BOOT_OPTION_H_ #ifndef _EFI_LEGACY_BOOT_OPTION_H_
#define _EFI_LEGACY_BOOT_OPTION_H_ #define _EFI_LEGACY_BOOT_OPTION_H_
#include <PiDxe.h> #include <PiDxe.h>
#include <Guid/GlobalVariable.h> #include <Guid/GlobalVariable.h>
#include <Guid/LegacyDevOrder.h> #include <Guid/LegacyDevOrder.h>
#include <Guid/MdeModuleHii.h> #include <Guid/MdeModuleHii.h>
@ -52,14 +50,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// //
#define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET) #define QUESTION_ID(Field) (VAR_OFFSET (Field) + CONFIG_OPTION_OFFSET)
#define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD) #define LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
#define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD) #define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
#define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD) #define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
#define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET) #define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
#define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV) #define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
// //
// String Constant // String Constant
// //
@ -96,14 +92,11 @@ typedef struct {
EFI_DEVICE_PATH_PROTOCOL End; EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH; } HII_VENDOR_DEVICE_PATH;
// //
// Variable created with this flag will be "Efi:...." // Variable created with this flag will be "Efi:...."
// //
#define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE
#define LEGACY_BOOT_OPTION_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('L', 'G', 'C', 'B') #define LEGACY_BOOT_OPTION_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('L', 'G', 'C', 'B')
typedef struct { typedef struct {

View File

@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _EFI_LEGACY_BOOT_OPTION_VFR_H_ #ifndef _EFI_LEGACY_BOOT_OPTION_VFR_H_
#define _EFI_LEGACY_BOOT_OPTION_VFR_H_ #define _EFI_LEGACY_BOOT_OPTION_VFR_H_
@ -18,23 +17,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define VARSTORE_ID_LEGACY_BOOT 0x0001 #define VARSTORE_ID_LEGACY_BOOT 0x0001
#define LEGACY_BOOT_FORM_ID 0x1000 #define LEGACY_BOOT_FORM_ID 0x1000
#define LEGACY_ORDER_CHANGE_FORM_ID 0x1001 #define LEGACY_ORDER_CHANGE_FORM_ID 0x1001
#define FORM_FLOPPY_BOOT_ID 0x2000 #define FORM_FLOPPY_BOOT_ID 0x2000
#define FORM_HARDDISK_BOOT_ID 0x2001 #define FORM_HARDDISK_BOOT_ID 0x2001
#define FORM_CDROM_BOOT_ID 0x2002 #define FORM_CDROM_BOOT_ID 0x2002
#define FORM_NET_BOOT_ID 0x2003 #define FORM_NET_BOOT_ID 0x2003
#define FORM_BEV_BOOT_ID 0x2004 #define FORM_BEV_BOOT_ID 0x2004
#define FORM_BOOT_LEGACY_DEVICE_ID 0x9000 #define FORM_BOOT_LEGACY_DEVICE_ID 0x9000
#define FORM_BOOT_LEGACY_LABEL_END 0x9001 #define FORM_BOOT_LEGACY_LABEL_END 0x9001
#pragma pack(1) #pragma pack(1)
/// ///

View File

@ -48,8 +48,10 @@ LegacyBmDeviceType (
EFI_DEVICE_PATH_PROTOCOL *DevicePath EFI_DEVICE_PATH_PROTOCOL *DevicePath
) )
{ {
ASSERT ((DevicePathType (DevicePath) == BBS_DEVICE_PATH) && ASSERT (
(DevicePathSubType (DevicePath) == BBS_BBS_DP)); (DevicePathType (DevicePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (DevicePath) == BBS_BBS_DP)
);
return ((BBS_BBS_DEVICE_PATH *)DevicePath)->DeviceType; return ((BBS_BBS_DEVICE_PATH *)DevicePath)->DeviceType;
} }
@ -167,6 +169,7 @@ LegacyBmBuildLegacyDevNameString (
Type = L"Unknown"; Type = L"Unknown";
break; break;
} }
// //
// If current BBS entry has its description then use it. // If current BBS entry has its description then use it.
// //
@ -186,7 +189,7 @@ LegacyBmBuildLegacyDevNameString (
// BbsTable 16 entries are for onboard IDE. // BbsTable 16 entries are for onboard IDE.
// Set description string for SATA harddisks, Harddisk 0 ~ Harddisk 11 // Set description string for SATA harddisks, Harddisk 0 ~ Harddisk 11
// //
if (Index >= 5 && Index <= 16 && (CurBBSEntry->DeviceType == BBS_HARDDISK || CurBBSEntry->DeviceType == BBS_CDROM)) { if ((Index >= 5) && (Index <= 16) && ((CurBBSEntry->DeviceType == BBS_HARDDISK) || (CurBBSEntry->DeviceType == BBS_CDROM))) {
Fmt = L"%s %d"; Fmt = L"%s %d";
UnicodeSPrint (BootString, BufSize, Fmt, Type, Index - 5); UnicodeSPrint (BootString, BufSize, Fmt, Type, Index - 5);
} else { } else {
@ -222,7 +225,8 @@ LegacyBmFuzzyMatch (
// Directly check the BBS index stored in BootOption // Directly check the BBS index stored in BootOption
// //
if ((BbsData->BbsIndex < BbsCount) && if ((BbsData->BbsIndex < BbsCount) &&
(LegacyBmDeviceType (BootOption->FilePath) == BbsTable[BbsData->BbsIndex].DeviceType)) { (LegacyBmDeviceType (BootOption->FilePath) == BbsTable[BbsData->BbsIndex].DeviceType))
{
LegacyBmBuildLegacyDevNameString ( LegacyBmBuildLegacyDevNameString (
&BbsTable[BbsData->BbsIndex], &BbsTable[BbsData->BbsIndex],
BbsData->BbsIndex, BbsData->BbsIndex,
@ -246,7 +250,8 @@ LegacyBmFuzzyMatch (
// //
for (Index = 0; Index < BbsCount; Index++) { for (Index = 0; Index < BbsCount; Index++) {
if (!LegacyBmValidBbsEntry (&BbsTable[Index]) || if (!LegacyBmValidBbsEntry (&BbsTable[Index]) ||
(BbsTable[Index].DeviceType != LegacyBmDeviceType (BootOption->FilePath))) { (BbsTable[Index].DeviceType != LegacyBmDeviceType (BootOption->FilePath)))
{
continue; continue;
} }
@ -299,14 +304,16 @@ LegacyBmUpdateBbsIndex (
LEGACY_DEV_ORDER_ENTRY *Entry; LEGACY_DEV_ORDER_ENTRY *Entry;
UINTN Index; UINTN Index;
ASSERT (((LegacyDevOrder == NULL) && (*LegacyDevOrderSize == 0)) || ASSERT (
((LegacyDevOrder == NULL) && (*LegacyDevOrderSize == 0)) ||
((LegacyDevOrder != NULL) && (*LegacyDevOrderSize != 0)) ((LegacyDevOrder != NULL) && (*LegacyDevOrderSize != 0))
); );
for (Entry = LegacyDevOrder; for (Entry = LegacyDevOrder;
Entry < (LEGACY_DEV_ORDER_ENTRY *)((UINT8 *)LegacyDevOrder + *LegacyDevOrderSize); Entry < (LEGACY_DEV_ORDER_ENTRY *)((UINT8 *)LegacyDevOrder + *LegacyDevOrderSize);
Entry = (LEGACY_DEV_ORDER_ENTRY *)((UINTN)Entry + sizeof (BBS_TYPE) + Entry->Length) Entry = (LEGACY_DEV_ORDER_ENTRY *)((UINTN)Entry + sizeof (BBS_TYPE) + Entry->Length)
) { )
{
if (Entry->BbsType == DeviceType) { if (Entry->BbsType == DeviceType) {
for (Index = 0; Index < Entry->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Entry->Length / sizeof (UINT16) - 1; Index++) {
if (Entry->Data[Index] == OldBbsIndex) { if (Entry->Data[Index] == OldBbsIndex) {
@ -324,9 +331,11 @@ LegacyBmUpdateBbsIndex (
} else { } else {
Entry->Data[Index] = NewBbsIndex; Entry->Data[Index] = NewBbsIndex;
} }
break; break;
} }
} }
break; break;
} }
} }
@ -350,7 +359,8 @@ LegacyBmDeleteAllBootOptions (
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot); BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) { for (Index = 0; Index < BootOptionCount; Index++) {
if ((DevicePathType (BootOption[Index].FilePath) == BBS_DEVICE_PATH) && if ((DevicePathType (BootOption[Index].FilePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (BootOption[Index].FilePath) == BBS_BBS_DP)) { (DevicePathSubType (BootOption[Index].FilePath) == BBS_BBS_DP))
{
Status = EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType); Status = EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType);
// //
// Deleting variable with current variable implementation shouldn't fail. // Deleting variable with current variable implementation shouldn't fail.
@ -374,7 +384,6 @@ LegacyBmDeleteAllBootOptions (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Delete all the invalid legacy boot options. Delete all the invalid legacy boot options.
@ -434,7 +443,8 @@ LegacyBmDeleteAllInvalidBootOptions (
// Skip non legacy boot option // Skip non legacy boot option
// //
if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) || if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||
(DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)) { (DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP))
{
continue; continue;
} }
@ -454,8 +464,14 @@ LegacyBmDeleteAllInvalidBootOptions (
EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType); EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType);
} else { } else {
if (((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOption[Index].OptionalData)->BbsIndex != BbsIndex) { if (((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOption[Index].OptionalData)->BbsIndex != BbsIndex) {
DEBUG ((DEBUG_INFO, "[LegacyBds] Update Boot Option Boot%04x: %s Bbs0x%04x->Bbs0x%04x\n", (UINTN) BootOption[Index].OptionNumber, BootOption[Index].Description, DEBUG ((
(UINTN) ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex, (UINTN) BbsIndex)); DEBUG_INFO,
"[LegacyBds] Update Boot Option Boot%04x: %s Bbs0x%04x->Bbs0x%04x\n",
(UINTN)BootOption[Index].OptionNumber,
BootOption[Index].Description,
(UINTN)((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOption[Index].OptionalData)->BbsIndex,
(UINTN)BbsIndex
));
// //
// Update the BBS index in LegacyDevOrder // Update the BBS index in LegacyDevOrder
// //
@ -475,6 +491,7 @@ LegacyBmDeleteAllInvalidBootOptions (
} }
} }
} }
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount); EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
if (LegacyDevOrder != NULL) { if (LegacyDevOrder != NULL) {
@ -492,6 +509,7 @@ LegacyBmDeleteAllInvalidBootOptions (
FreePool (LegacyDevOrder); FreePool (LegacyDevOrder);
} }
FreePool (BbsIndexUsed); FreePool (BbsIndexUsed);
return Status; return Status;
} }
@ -697,6 +715,7 @@ LegacyBmCreateDevOrder (
if (NULL == DevOrder) { if (NULL == DevOrder) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
DevOrderPtr = DevOrder; DevOrderPtr = DevOrder;
DevOrderPtr->BbsType = BBS_FLOPPY; DevOrderPtr->BbsType = BBS_FLOPPY;
@ -818,6 +837,7 @@ LegacyBmUpdateDevOrder (
if (NULL == DevOrder) { if (NULL == DevOrder) {
return LegacyBmCreateDevOrder (LocalBbsTable, BbsCount); return LegacyBmCreateDevOrder (LocalBbsTable, BbsCount);
} }
// //
// First we figure out how many boot devices with same device type respectively // First we figure out how many boot devices with same device type respectively
// //
@ -872,14 +892,16 @@ LegacyBmUpdateDevOrder (
NewPtr->Length = (UINT16)(sizeof (UINT16) + FDCount * sizeof (UINT16)); NewPtr->Length = (UINT16)(sizeof (UINT16) + FDCount * sizeof (UINT16));
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY (LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY)
) { )
{
continue; continue;
} }
NewPtr->Data[FDIndex] = Ptr->Data[Index]; NewPtr->Data[FDIndex] = Ptr->Data[Index];
FDIndex++; FDIndex++;
} }
NewFDPtr = NewPtr->Data; NewFDPtr = NewPtr->Data;
// //
@ -891,14 +913,16 @@ LegacyBmUpdateDevOrder (
NewPtr->Length = (UINT16)(sizeof (UINT16) + HDCount * sizeof (UINT16)); NewPtr->Length = (UINT16)(sizeof (UINT16) + HDCount * sizeof (UINT16));
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK (LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK)
) { )
{
continue; continue;
} }
NewPtr->Data[HDIndex] = Ptr->Data[Index]; NewPtr->Data[HDIndex] = Ptr->Data[Index];
HDIndex++; HDIndex++;
} }
NewHDPtr = NewPtr->Data; NewHDPtr = NewPtr->Data;
// //
@ -910,14 +934,16 @@ LegacyBmUpdateDevOrder (
NewPtr->Length = (UINT16)(sizeof (UINT16) + CDCount * sizeof (UINT16)); NewPtr->Length = (UINT16)(sizeof (UINT16) + CDCount * sizeof (UINT16));
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM (LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM)
) { )
{
continue; continue;
} }
NewPtr->Data[CDIndex] = Ptr->Data[Index]; NewPtr->Data[CDIndex] = Ptr->Data[Index];
CDIndex++; CDIndex++;
} }
NewCDPtr = NewPtr->Data; NewCDPtr = NewPtr->Data;
// //
@ -929,14 +955,16 @@ LegacyBmUpdateDevOrder (
NewPtr->Length = (UINT16)(sizeof (UINT16) + NETCount * sizeof (UINT16)); NewPtr->Length = (UINT16)(sizeof (UINT16) + NETCount * sizeof (UINT16));
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_EMBED_NETWORK (LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_EMBED_NETWORK)
) { )
{
continue; continue;
} }
NewPtr->Data[NETIndex] = Ptr->Data[Index]; NewPtr->Data[NETIndex] = Ptr->Data[Index];
NETIndex++; NETIndex++;
} }
NewNETPtr = NewPtr->Data; NewNETPtr = NewPtr->Data;
// //
@ -948,14 +976,16 @@ LegacyBmUpdateDevOrder (
NewPtr->Length = (UINT16)(sizeof (UINT16) + BEVCount * sizeof (UINT16)); NewPtr->Length = (UINT16)(sizeof (UINT16) + BEVCount * sizeof (UINT16));
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) { for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) || if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_BEV_DEVICE (LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_BEV_DEVICE)
) { )
{
continue; continue;
} }
NewPtr->Data[BEVIndex] = Ptr->Data[Index]; NewPtr->Data[BEVIndex] = Ptr->Data[Index];
BEVIndex++; BEVIndex++;
} }
NewBEVPtr = NewPtr->Data; NewBEVPtr = NewPtr->Data;
for (Index = 0; Index < BbsCount; Index++) { for (Index = 0; Index < BbsCount; Index++) {
@ -993,6 +1023,7 @@ LegacyBmUpdateDevOrder (
Idx = NULL; Idx = NULL;
break; break;
} }
// //
// at this point we have copied those valid indexes to new buffer // at this point we have copied those valid indexes to new buffer
// and we should check if there is any new appeared boot device // and we should check if there is any new appeared boot device
@ -1015,6 +1046,7 @@ LegacyBmUpdateDevOrder (
break; break;
} }
} }
CopyMem (&NewDevPtr[Index2 + 1], &NewDevPtr[Index2], (*Idx - Index2) * sizeof (UINT16)); CopyMem (&NewDevPtr[Index2 + 1], &NewDevPtr[Index2], (*Idx - Index2) * sizeof (UINT16));
NewDevPtr[Index2] = (UINT16)(Index & 0xFF); NewDevPtr[Index2] = (UINT16)(Index & 0xFF);
(*Idx)++; (*Idx)++;
@ -1089,9 +1121,11 @@ LegacyBmSetPriorityForSameTypeDev (
FreePool (DevOrder); FreePool (DevOrder);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
LocalBbsTable[BbsIndex].BootPriority = *Priority; LocalBbsTable[BbsIndex].BootPriority = *Priority;
(*Priority)++; (*Priority)++;
} }
// //
// If the high byte of the DevIndex is 0xFF, it indicates that this device has been disabled. // If the high byte of the DevIndex is 0xFF, it indicates that this device has been disabled.
// //
@ -1215,12 +1249,14 @@ LegacyBmRefreshBbsTableForBoot (
LocalBbsTable[Index].BootPriority = BBS_UNPRIORITIZED_ENTRY; LocalBbsTable[Index].BootPriority = BBS_UNPRIORITIZED_ENTRY;
} }
} }
// //
// boot priority always starts at 0 // boot priority always starts at 0
// //
Priority = 0; Priority = 0;
if ((DevicePathType (BootOption->FilePath) == BBS_DEVICE_PATH) && if ((DevicePathType (BootOption->FilePath) == BBS_DEVICE_PATH) &&
(DevicePathSubType (BootOption->FilePath) == BBS_BBS_DP)) { (DevicePathSubType (BootOption->FilePath) == BBS_BBS_DP))
{
// //
// If BootOption stands for a legacy boot option, we prioritize the devices with the same type first. // If BootOption stands for a legacy boot option, we prioritize the devices with the same type first.
// //
@ -1236,6 +1272,7 @@ LegacyBmRefreshBbsTableForBoot (
return Status; return Status;
} }
} }
// //
// we have to set the boot priority for other BBS entries with different device types // we have to set the boot priority for other BBS entries with different device types
// //
@ -1246,7 +1283,8 @@ LegacyBmRefreshBbsTableForBoot (
DeviceTypeCount = 1; DeviceTypeCount = 1;
for (Index = 0; Index < OptionCount; Index++) { for (Index = 0; Index < OptionCount; Index++) {
if ((DevicePathType (Option[Index].FilePath) != BBS_DEVICE_PATH) || if ((DevicePathType (Option[Index].FilePath) != BBS_DEVICE_PATH) ||
(DevicePathSubType (Option[Index].FilePath) != BBS_BBS_DP)) { (DevicePathSubType (Option[Index].FilePath) != BBS_BBS_DP))
{
continue; continue;
} }
@ -1256,6 +1294,7 @@ LegacyBmRefreshBbsTableForBoot (
break; break;
} }
} }
if (DeviceTypeIndex < DeviceTypeCount) { if (DeviceTypeIndex < DeviceTypeCount) {
// //
// We don't want to process twice for a device type // We don't want to process twice for a device type
@ -1273,6 +1312,7 @@ LegacyBmRefreshBbsTableForBoot (
&Priority &Priority
); );
} }
EfiBootManagerFreeLoadOptions (Option, OptionCount); EfiBootManagerFreeLoadOptions (Option, OptionCount);
DEBUG_CODE_BEGIN (); DEBUG_CODE_BEGIN ();
@ -1282,7 +1322,6 @@ LegacyBmRefreshBbsTableForBoot (
return Status; return Status;
} }
/** /**
Boot the legacy system with the boot option. Boot the legacy system with the boot option.
@ -1309,6 +1348,7 @@ LegacyBmBoot (
BootOption->Status = EFI_UNSUPPORTED; BootOption->Status = EFI_UNSUPPORTED;
return; return;
} }
// //
// Notes: if we separate the int 19, then we don't need to refresh BBS // Notes: if we separate the int 19, then we don't need to refresh BBS
// //
@ -1413,7 +1453,8 @@ LegacyBmFindBootOption (
if ((StrCmp (Key->Description, Array[Index].Description) == 0) && if ((StrCmp (Key->Description, Array[Index].Description) == 0) &&
(CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) && (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
(Key->OptionalDataSize == Array[Index].OptionalDataSize) && (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
(CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) { (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0))
{
return (INTN)Index; return (INTN)Index;
} }
} }
@ -1450,6 +1491,7 @@ LegacyBmRefreshAllBootOption (
LegacyBmDeleteAllBootOptions (); LegacyBmDeleteAllBootOptions ();
return; return;
} }
PERF_START (NULL, "LegacyBootOptionEnum", "BDS", 0); PERF_START (NULL, "LegacyBootOptionEnum", "BDS", 0);
// //
@ -1506,7 +1548,8 @@ LegacyBmRefreshAllBootOption (
if (LegacyBmFindBootOption (&BootOptions[Index], ExistingBootOptions, ExistingBootOptionCount) == -1) { if (LegacyBmFindBootOption (&BootOptions[Index], ExistingBootOptions, ExistingBootOptionCount) == -1) {
Status = EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1); Status = EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1);
DEBUG (( DEBUG ((
DEBUG_INFO, "[LegacyBds] New Boot Option: Boot%04x Bbs0x%04x %s %r\n", DEBUG_INFO,
"[LegacyBds] New Boot Option: Boot%04x Bbs0x%04x %s %r\n",
(UINTN)BootOptions[Index].OptionNumber, (UINTN)BootOptions[Index].OptionNumber,
(UINTN)((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOptions[Index].OptionalData)->BbsIndex, (UINTN)((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOptions[Index].OptionalData)->BbsIndex,
BootOptions[Index].Description, BootOptions[Index].Description,

View File

@ -82,7 +82,6 @@ EFI_FW_VOL_BLOCK_DEVICE mEmuVarsFvb = {
}, },
}; };
/** /**
Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE. Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
@ -103,7 +102,6 @@ FvbVirtualAddressChangeEvent (
EfiConvertPointer (0x0, &mEmuVarsFvb.BufferPtr); EfiConvertPointer (0x0, &mEmuVarsFvb.BufferPtr);
} }
// //
// FVB protocol APIs // FVB protocol APIs
// //
@ -141,7 +139,6 @@ FvbProtocolGetPhysicalAddress (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The GetBlockSize() function retrieves the size of the requested The GetBlockSize() function retrieves the size of the requested
block. It also returns the number of additional blocks with block. It also returns the number of additional blocks with
@ -191,7 +188,6 @@ FvbProtocolGetBlockSize (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The GetAttributes() function retrieves the attributes and The GetAttributes() function retrieves the attributes and
current settings of the block. Status Codes Returned current settings of the block. Status Codes Returned
@ -226,7 +222,6 @@ FvbProtocolGetAttributes (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The SetAttributes() function sets configurable firmware volume The SetAttributes() function sets configurable firmware volume
attributes and returns the new settings of the firmware volume. attributes and returns the new settings of the firmware volume.
@ -259,7 +254,6 @@ FvbProtocolSetAttributes (
return EFI_ACCESS_DENIED; return EFI_ACCESS_DENIED;
} }
/** /**
Erases and initializes a firmware volume block. Erases and initializes a firmware volume block.
@ -333,14 +327,17 @@ FvbProtocolEraseBlocks (
if (StartingLba == EFI_LBA_LIST_TERMINATOR) { if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
break; break;
} }
NumOfLba = VA_ARG (Args, UINTN); NumOfLba = VA_ARG (Args, UINTN);
if (StartingLba > EMU_FVB_NUM_TOTAL_BLOCKS || if ((StartingLba > EMU_FVB_NUM_TOTAL_BLOCKS) ||
NumOfLba > EMU_FVB_NUM_TOTAL_BLOCKS - StartingLba) { (NumOfLba > EMU_FVB_NUM_TOTAL_BLOCKS - StartingLba))
{
VA_END (Args); VA_END (Args);
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
} while (1); } while (1);
VA_END (Args); VA_END (Args);
// //
@ -352,6 +349,7 @@ FvbProtocolEraseBlocks (
if (StartingLba == EFI_LBA_LIST_TERMINATOR) { if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
break; break;
} }
NumOfLba = VA_ARG (Args, UINTN); NumOfLba = VA_ARG (Args, UINTN);
ErasePtr = FvbDevice->BufferPtr; ErasePtr = FvbDevice->BufferPtr;
@ -360,6 +358,7 @@ FvbProtocolEraseBlocks (
SetMem (ErasePtr, EraseSize, ERASED_UINT8); SetMem (ErasePtr, EraseSize, ERASED_UINT8);
} while (1); } while (1);
VA_END (Args); VA_END (Args);
// //
@ -372,7 +371,6 @@ FvbProtocolEraseBlocks (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Writes the specified number of bytes from the input buffer to the block. Writes the specified number of bytes from the input buffer to the block.
@ -448,8 +446,9 @@ FvbProtocolWrite (
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
if (Lba >= EMU_FVB_NUM_TOTAL_BLOCKS || if ((Lba >= EMU_FVB_NUM_TOTAL_BLOCKS) ||
Offset > FvbDevice->BlockSize) { (Offset > FvbDevice->BlockSize))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -468,7 +467,6 @@ FvbProtocolWrite (
return Status; return Status;
} }
/** /**
Reads the specified number of bytes into a buffer from the specified block. Reads the specified number of bytes into a buffer from the specified block.
@ -532,8 +530,9 @@ FvbProtocolRead (
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
if (Lba >= EMU_FVB_NUM_TOTAL_BLOCKS || if ((Lba >= EMU_FVB_NUM_TOTAL_BLOCKS) ||
Offset > FvbDevice->BlockSize) { (Offset > FvbDevice->BlockSize))
{
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -552,7 +551,6 @@ FvbProtocolRead (
return Status; return Status;
} }
/** /**
Check the integrity of firmware volume header. Check the integrity of firmware volume header.
@ -578,10 +576,12 @@ ValidateFvHeader (
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
(FwVolHeader->FvLength != EMU_FVB_SIZE) || (FwVolHeader->FvLength != EMU_FVB_SIZE) ||
(FwVolHeader->HeaderLength != EMU_FV_HEADER_LENGTH) (FwVolHeader->HeaderLength != EMU_FV_HEADER_LENGTH)
) { )
{
DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n")); DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n"));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
// //
// Verify the header checksum // Verify the header checksum
// //
@ -595,7 +595,6 @@ ValidateFvHeader (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Initializes the FV Header and Variable Store Header Initializes the FV Header and Variable Store Header
to support variable operations. to support variable operations.
@ -724,21 +723,27 @@ FvbInitialize (
// //
// Verify that the PCD's are set correctly. // Verify that the PCD's are set correctly.
// //
ASSERT (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) % ASSERT (
EMU_FVB_BLOCK_SIZE == 0); FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) %
EMU_FVB_BLOCK_SIZE == 0
);
if ( if (
(PcdGet32 (PcdFlashNvStorageVariableSize) + (PcdGet32 (PcdFlashNvStorageVariableSize) +
PcdGet32 (PcdFlashNvStorageFtwWorkingSize) PcdGet32 (PcdFlashNvStorageFtwWorkingSize)
) > ) >
EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE
) { )
{
DEBUG ((DEBUG_ERROR, "EMU Variable invalid PCD sizes\n")); DEBUG ((DEBUG_ERROR, "EMU Variable invalid PCD sizes\n"));
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) { if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) {
DEBUG ((DEBUG_INFO, "Disabling EMU Variable FVB since " DEBUG ((
"flash variables appear to be supported.\n")); DEBUG_INFO,
"Disabling EMU Variable FVB since "
"flash variables appear to be supported.\n"
));
return EFI_ABORTED; return EFI_ABORTED;
} }
@ -776,6 +781,7 @@ FvbInitialize (
SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8); SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8);
InitializeFvAndVariableStoreHeaders (Ptr); InitializeFvAndVariableStoreHeaders (Ptr);
} }
PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN)Ptr); PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN)Ptr);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
@ -783,8 +789,10 @@ FvbInitialize (
// Initialize the Fault Tolerant Write data area // Initialize the Fault Tolerant Write data area
// //
SubPtr = (VOID *)((UINT8 *)Ptr + PcdGet32 (PcdFlashNvStorageVariableSize)); SubPtr = (VOID *)((UINT8 *)Ptr + PcdGet32 (PcdFlashNvStorageVariableSize));
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase, PcdStatus = PcdSet32S (
(UINT32)(UINTN) SubPtr); PcdFlashNvStorageFtwWorkingBase,
(UINT32)(UINTN)SubPtr
);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
// //
@ -792,8 +800,10 @@ FvbInitialize (
// //
SubPtr = (VOID *)((UINT8 *)Ptr + SubPtr = (VOID *)((UINT8 *)Ptr +
EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE); EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE);
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase, PcdStatus = PcdSet32S (
(UINT32)(UINTN) SubPtr); PcdFlashNvStorageFtwSpareBase,
(UINT32)(UINTN)SubPtr
);
ASSERT_RETURN_ERROR (PcdStatus); ASSERT_RETURN_ERROR (PcdStatus);
// //
@ -833,5 +843,3 @@ FvbInitialize (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -25,11 +25,9 @@ Abstract:
#pragma pack (1) #pragma pack (1)
typedef struct { typedef struct {
EFI_FIRMWARE_VOLUME_HEADER FvHdr; EFI_FIRMWARE_VOLUME_HEADER FvHdr;
EFI_FV_BLOCK_MAP_ENTRY EndBlockMap; EFI_FV_BLOCK_MAP_ENTRY EndBlockMap;
VARIABLE_STORE_HEADER VarHdr; VARIABLE_STORE_HEADER VarHdr;
} FVB_FV_HDR_AND_VARS_TEMPLATE; } FVB_FV_HDR_AND_VARS_TEMPLATE;
typedef struct { typedef struct {
@ -48,7 +46,6 @@ typedef struct {
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance; EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
} EFI_FW_VOL_BLOCK_DEVICE; } EFI_FW_VOL_BLOCK_DEVICE;
// //
// Constants // Constants
// //

View File

@ -8,7 +8,6 @@
#include "EnrollDefaultKeys.h" #include "EnrollDefaultKeys.h"
// //
// Second KEK: "Microsoft Corporation KEK CA 2011". // Second KEK: "Microsoft Corporation KEK CA 2011".
// SHA1: 31:59:0b:fd:89:c9:d7:4e:d0:87:df:ac:66:33:4b:39:31:25:4b:30 // SHA1: 31:59:0b:fd:89:c9:d7:4e:d0:87:df:ac:66:33:4b:39:31:25:4b:30
@ -137,7 +136,6 @@ CONST UINT8 mMicrosoftKek[] = {
CONST UINTN mSizeOfMicrosoftKek = sizeof mMicrosoftKek; CONST UINTN mSizeOfMicrosoftKek = sizeof mMicrosoftKek;
// //
// First DB entry: "Microsoft Windows Production PCA 2011" // First DB entry: "Microsoft Windows Production PCA 2011"
// SHA1: 58:0a:6f:4c:c4:e4:b6:69:b9:eb:dc:1b:2b:3e:08:7b:80:d0:67:8d // SHA1: 58:0a:6f:4c:c4:e4:b6:69:b9:eb:dc:1b:2b:3e:08:7b:80:d0:67:8d
@ -266,7 +264,6 @@ CONST UINT8 mMicrosoftPca[] = {
CONST UINTN mSizeOfMicrosoftPca = sizeof mMicrosoftPca; CONST UINTN mSizeOfMicrosoftPca = sizeof mMicrosoftPca;
// //
// Second DB entry: "Microsoft Corporation UEFI CA 2011" // Second DB entry: "Microsoft Corporation UEFI CA 2011"
// SHA1: 46:de:f6:3b:5c:e6:1c:f8:ba:0d:e2:e6:63:9c:10:19:d0:ed:14:f3 // SHA1: 46:de:f6:3b:5c:e6:1c:f8:ba:0d:e2:e6:63:9c:10:19:d0:ed:14:f3
@ -398,7 +395,6 @@ CONST UINT8 mMicrosoftUefiCa[] = {
CONST UINTN mSizeOfMicrosoftUefiCa = sizeof mMicrosoftUefiCa; CONST UINTN mSizeOfMicrosoftUefiCa = sizeof mMicrosoftUefiCa;
// //
// The Microsoft.UefiSecureBootLogo.Tests.OutOfBoxConfirmDBXisPresent test case // The Microsoft.UefiSecureBootLogo.Tests.OutOfBoxConfirmDBXisPresent test case
// of the Secure Boot Logo Test in the Microsoft Hardware Certification Kit // of the Secure Boot Logo Test in the Microsoft Hardware Certification Kit

View File

@ -24,7 +24,6 @@
#include "EnrollDefaultKeys.h" #include "EnrollDefaultKeys.h"
/** /**
Fetch the X509 certificate (to be used as Platform Key and first Key Exchange Fetch the X509 certificate (to be used as Platform Key and first Key Exchange
Key) from SMBIOS. Key) from SMBIOS.
@ -75,14 +74,21 @@ GetPkKek1 (
// //
// Format the application prefix, for OEM String matching. // Format the application prefix, for OEM String matching.
// //
AsciiSPrint (OvmfPkKek1AppPrefix, sizeof OvmfPkKek1AppPrefix, "%g:", AsciiSPrint (
&gOvmfPkKek1AppPrefixGuid); OvmfPkKek1AppPrefix,
sizeof OvmfPkKek1AppPrefix,
"%g:",
&gOvmfPkKek1AppPrefixGuid
);
// //
// Scan all "OEM Strings" tables. // Scan all "OEM Strings" tables.
// //
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&Smbios); &gEfiSmbiosProtocolGuid,
NULL,
(VOID **)&Smbios
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiPrint ("error: failed to locate EFI_SMBIOS_PROTOCOL: %r\n", Status); AsciiPrint ("error: failed to locate EFI_SMBIOS_PROTOCOL: %r\n", Status);
return Status; return Status;
@ -92,7 +98,8 @@ GetPkKek1 (
Type = SMBIOS_TYPE_OEM_STRINGS; Type = SMBIOS_TYPE_OEM_STRINGS;
for (Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL); for (Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL);
!EFI_ERROR (Status); !EFI_ERROR (Status);
Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL)) { Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL))
{
CONST CHAR8 *OemString; CONST CHAR8 *OemString;
UINTN Idx; UINTN Idx;
@ -102,6 +109,7 @@ GetPkKek1 (
// //
continue; continue;
} }
OemStringsTable = (SMBIOS_TABLE_TYPE11 *)Header; OemStringsTable = (SMBIOS_TABLE_TYPE11 *)Header;
// //
@ -115,8 +123,12 @@ GetPkKek1 (
// //
// NUL-terminate the candidate prefix for case-insensitive comparison. // NUL-terminate the candidate prefix for case-insensitive comparison.
// //
AsciiStrnCpyS (CandidatePrefix, sizeof CandidatePrefix, OemString, AsciiStrnCpyS (
GUID_STRING_LENGTH + 1); CandidatePrefix,
sizeof CandidatePrefix,
OemString,
GUID_STRING_LENGTH + 1
);
if (AsciiStriCmp (OvmfPkKek1AppPrefix, CandidatePrefix) == 0) { if (AsciiStriCmp (OvmfPkKek1AppPrefix, CandidatePrefix) == 0) {
// //
// The current string matches the prefix. // The current string matches the prefix.
@ -124,6 +136,7 @@ GetPkKek1 (
Base64Cert = OemString + GUID_STRING_LENGTH + 1; Base64Cert = OemString + GUID_STRING_LENGTH + 1;
break; break;
} }
OemString += AsciiStrSize (OemString); OemString += AsciiStrSize (OemString);
} }
@ -139,8 +152,11 @@ GetPkKek1 (
// //
// No table with a matching string has been found. // No table with a matching string has been found.
// //
AsciiPrint ("error: OEM String with app prefix %g not found: %r\n", AsciiPrint (
&gOvmfPkKek1AppPrefixGuid, Status); "error: OEM String with app prefix %g not found: %r\n",
&gOvmfPkKek1AppPrefixGuid,
Status
);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -157,12 +173,16 @@ GetPkKek1 (
ASSERT (DecodedCertSize > 0); ASSERT (DecodedCertSize > 0);
break; break;
case EFI_SUCCESS: case EFI_SUCCESS:
AsciiPrint ("error: empty certificate after app prefix %g\n", AsciiPrint (
&gOvmfPkKek1AppPrefixGuid); "error: empty certificate after app prefix %g\n",
&gOvmfPkKek1AppPrefixGuid
);
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
default: default:
AsciiPrint ("error: invalid base64 string after app prefix %g\n", AsciiPrint (
&gOvmfPkKek1AppPrefixGuid); "error: invalid base64 string after app prefix %g\n",
&gOvmfPkKek1AppPrefixGuid
);
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -178,8 +198,12 @@ GetPkKek1 (
// //
// Decoding will succeed at this point. // Decoding will succeed at this point.
// //
Status = Base64Decode (Base64Cert, Base64CertLen, DecodedCert, Status = Base64Decode (
&DecodedCertSize); Base64Cert,
Base64CertLen,
DecodedCert,
&DecodedCertSize
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
*PkKek1 = DecodedCert; *PkKek1 = DecodedCert;
@ -187,7 +211,6 @@ GetPkKek1 (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Enroll a set of certificates in a global variable, overwriting it. Enroll a set of certificates in a global variable, overwriting it.
@ -259,25 +282,30 @@ EnrollListOfCerts (
VA_START (Marker, CertType); VA_START (Marker, CertType);
for (Cert = VA_ARG (Marker, CONST UINT8 *); for (Cert = VA_ARG (Marker, CONST UINT8 *);
Cert != NULL; Cert != NULL;
Cert = VA_ARG (Marker, CONST UINT8 *)) { Cert = VA_ARG (Marker, CONST UINT8 *))
{
UINTN CertSize; UINTN CertSize;
CertSize = VA_ARG (Marker, UINTN); CertSize = VA_ARG (Marker, UINTN);
(VOID)VA_ARG (Marker, CONST EFI_GUID *); (VOID)VA_ARG (Marker, CONST EFI_GUID *);
if (CertSize == 0 || if ((CertSize == 0) ||
CertSize > MAX_UINT32 - sizeof *RepeatingHeader || (CertSize > MAX_UINT32 - sizeof *RepeatingHeader) ||
DataSize > MAX_UINT32 - sizeof *RepeatingHeader - CertSize) { (DataSize > MAX_UINT32 - sizeof *RepeatingHeader - CertSize))
{
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
break; break;
} }
DataSize += sizeof *RepeatingHeader + CertSize; DataSize += sizeof *RepeatingHeader + CertSize;
} }
VA_END (Marker); VA_END (Marker);
if (DataSize == sizeof *SingleHeader) { if (DataSize == sizeof *SingleHeader) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Out; goto Out;
} }
@ -295,6 +323,7 @@ EnrollListOfCerts (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreeData; goto FreeData;
} }
SingleHeader->TimeStamp.Pad1 = 0; SingleHeader->TimeStamp.Pad1 = 0;
SingleHeader->TimeStamp.Nanosecond = 0; SingleHeader->TimeStamp.Nanosecond = 0;
SingleHeader->TimeStamp.TimeZone = 0; SingleHeader->TimeStamp.TimeZone = 0;
@ -320,7 +349,8 @@ EnrollListOfCerts (
VA_START (Marker, CertType); VA_START (Marker, CertType);
for (Cert = VA_ARG (Marker, CONST UINT8 *); for (Cert = VA_ARG (Marker, CONST UINT8 *);
Cert != NULL; Cert != NULL;
Cert = VA_ARG (Marker, CONST UINT8 *)) { Cert = VA_ARG (Marker, CONST UINT8 *))
{
UINTN CertSize; UINTN CertSize;
CONST EFI_GUID *OwnerGuid; CONST EFI_GUID *OwnerGuid;
@ -340,28 +370,38 @@ EnrollListOfCerts (
CopyMem (Position, Cert, CertSize); CopyMem (Position, Cert, CertSize);
Position += CertSize; Position += CertSize;
} }
VA_END (Marker); VA_END (Marker);
ASSERT (Data + DataSize == Position); ASSERT (Data + DataSize == Position);
Status = gRT->SetVariable (VariableName, VendorGuid, Status = gRT->SetVariable (
VariableName,
VendorGuid,
(EFI_VARIABLE_NON_VOLATILE | (EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS), EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS),
DataSize, Data); DataSize,
Data
);
FreeData: FreeData:
FreePool (Data); FreePool (Data);
Out: Out:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiPrint ("error: %a(\"%s\", %g): %r\n", __FUNCTION__, VariableName, AsciiPrint (
VendorGuid, Status); "error: %a(\"%s\", %g): %r\n",
} __FUNCTION__,
return Status; VariableName,
VendorGuid,
Status
);
} }
return Status;
}
/** /**
Read a UEFI variable into a caller-allocated buffer, enforcing an exact size. Read a UEFI variable into a caller-allocated buffer, enforcing an exact size.
@ -417,26 +457,35 @@ GetExact (
Size = DataSize; Size = DataSize;
Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &Size, Data); Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &Size, Data);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
if (Status == EFI_NOT_FOUND && AllowMissing) { if ((Status == EFI_NOT_FOUND) && AllowMissing) {
ZeroMem (Data, DataSize); ZeroMem (Data, DataSize);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
AsciiPrint ("error: GetVariable(\"%s\", %g): %r\n", VariableName, AsciiPrint (
VendorGuid, Status); "error: GetVariable(\"%s\", %g): %r\n",
VariableName,
VendorGuid,
Status
);
return Status; return Status;
} }
if (Size != DataSize) { if (Size != DataSize) {
AsciiPrint ("error: GetVariable(\"%s\", %g): expected size 0x%Lx, " AsciiPrint (
"got 0x%Lx\n", VariableName, VendorGuid, (UINT64)DataSize, (UINT64)Size); "error: GetVariable(\"%s\", %g): expected size 0x%Lx, "
"got 0x%Lx\n",
VariableName,
VendorGuid,
(UINT64)DataSize,
(UINT64)Size
);
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Populate a SETTINGS structure from the underlying UEFI variables. Populate a SETTINGS structure from the underlying UEFI variables.
@ -469,37 +518,60 @@ GetSettings (
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = GetExact (EFI_SETUP_MODE_NAME, &gEfiGlobalVariableGuid, Status = GetExact (
&Settings->SetupMode, sizeof Settings->SetupMode, FALSE); EFI_SETUP_MODE_NAME,
&gEfiGlobalVariableGuid,
&Settings->SetupMode,
sizeof Settings->SetupMode,
FALSE
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = GetExact (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid, Status = GetExact (
&Settings->SecureBoot, sizeof Settings->SecureBoot, FALSE); EFI_SECURE_BOOT_MODE_NAME,
&gEfiGlobalVariableGuid,
&Settings->SecureBoot,
sizeof Settings->SecureBoot,
FALSE
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = GetExact (EFI_SECURE_BOOT_ENABLE_NAME, Status = GetExact (
&gEfiSecureBootEnableDisableGuid, &Settings->SecureBootEnable, EFI_SECURE_BOOT_ENABLE_NAME,
sizeof Settings->SecureBootEnable, TRUE); &gEfiSecureBootEnableDisableGuid,
&Settings->SecureBootEnable,
sizeof Settings->SecureBootEnable,
TRUE
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = GetExact (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, Status = GetExact (
&Settings->CustomMode, sizeof Settings->CustomMode, FALSE); EFI_CUSTOM_MODE_NAME,
&gEfiCustomModeEnableGuid,
&Settings->CustomMode,
sizeof Settings->CustomMode,
FALSE
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = GetExact (EFI_VENDOR_KEYS_VARIABLE_NAME, &gEfiGlobalVariableGuid, Status = GetExact (
&Settings->VendorKeys, sizeof Settings->VendorKeys, FALSE); EFI_VENDOR_KEYS_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
&Settings->VendorKeys,
sizeof Settings->VendorKeys,
FALSE
);
return Status; return Status;
} }
/** /**
Print the contents of a SETTINGS structure to the UEFI console. Print the contents of a SETTINGS structure to the UEFI console.
@ -511,12 +583,17 @@ PrintSettings (
IN CONST SETTINGS *Settings IN CONST SETTINGS *Settings
) )
{ {
AsciiPrint ("info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d " AsciiPrint (
"CustomMode=%d VendorKeys=%d\n", Settings->SetupMode, Settings->SecureBoot, "info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d "
Settings->SecureBootEnable, Settings->CustomMode, Settings->VendorKeys); "CustomMode=%d VendorKeys=%d\n",
Settings->SetupMode,
Settings->SecureBoot,
Settings->SecureBootEnable,
Settings->CustomMode,
Settings->VendorKeys
);
} }
/** /**
Entry point function of this shell application. Entry point function of this shell application.
**/ **/
@ -534,7 +611,7 @@ ShellAppMain (
UINTN SizeOfPkKek1; UINTN SizeOfPkKek1;
BOOLEAN NoDefault; BOOLEAN NoDefault;
if (Argc == 2 && StrCmp (Argv[1], L"--no-default") == 0) { if ((Argc == 2) && (StrCmp (Argv[1], L"--no-default") == 0)) {
NoDefault = TRUE; NoDefault = TRUE;
} else { } else {
NoDefault = FALSE; NoDefault = FALSE;
@ -552,6 +629,7 @@ ShellAppMain (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return RetVal; return RetVal;
} }
PrintSettings (&Settings); PrintSettings (&Settings);
if (Settings.SetupMode != 1) { if (Settings.SetupMode != 1) {
@ -581,13 +659,21 @@ ShellAppMain (
// //
if (Settings.CustomMode != CUSTOM_SECURE_BOOT_MODE) { if (Settings.CustomMode != CUSTOM_SECURE_BOOT_MODE) {
Settings.CustomMode = CUSTOM_SECURE_BOOT_MODE; Settings.CustomMode = CUSTOM_SECURE_BOOT_MODE;
Status = gRT->SetVariable (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, Status = gRT->SetVariable (
EFI_CUSTOM_MODE_NAME,
&gEfiCustomModeEnableGuid,
(EFI_VARIABLE_NON_VOLATILE | (EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS), EFI_VARIABLE_BOOTSERVICE_ACCESS),
sizeof Settings.CustomMode, &Settings.CustomMode); sizeof Settings.CustomMode,
&Settings.CustomMode
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiPrint ("error: SetVariable(\"%s\", %g): %r\n", EFI_CUSTOM_MODE_NAME, AsciiPrint (
&gEfiCustomModeEnableGuid, Status); "error: SetVariable(\"%s\", %g): %r\n",
EFI_CUSTOM_MODE_NAME,
&gEfiCustomModeEnableGuid,
Status
);
goto FreePkKek1; goto FreePkKek1;
} }
} }
@ -600,17 +686,26 @@ ShellAppMain (
EFI_IMAGE_SECURITY_DATABASE, EFI_IMAGE_SECURITY_DATABASE,
&gEfiImageSecurityDatabaseGuid, &gEfiImageSecurityDatabaseGuid,
&gEfiCertX509Guid, &gEfiCertX509Guid,
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid, PkKek1,
NULL); SizeOfPkKek1,
&gEfiCallerIdGuid,
NULL
);
} else { } else {
Status = EnrollListOfCerts ( Status = EnrollListOfCerts (
EFI_IMAGE_SECURITY_DATABASE, EFI_IMAGE_SECURITY_DATABASE,
&gEfiImageSecurityDatabaseGuid, &gEfiImageSecurityDatabaseGuid,
&gEfiCertX509Guid, &gEfiCertX509Guid,
mMicrosoftPca, mSizeOfMicrosoftPca, &gMicrosoftVendorGuid, mMicrosoftPca,
mMicrosoftUefiCa, mSizeOfMicrosoftUefiCa, &gMicrosoftVendorGuid, mSizeOfMicrosoftPca,
NULL); &gMicrosoftVendorGuid,
mMicrosoftUefiCa,
mSizeOfMicrosoftUefiCa,
&gMicrosoftVendorGuid,
NULL
);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreePkKek1; goto FreePkKek1;
} }
@ -622,8 +717,11 @@ ShellAppMain (
EFI_IMAGE_SECURITY_DATABASE1, EFI_IMAGE_SECURITY_DATABASE1,
&gEfiImageSecurityDatabaseGuid, &gEfiImageSecurityDatabaseGuid,
&gEfiCertSha256Guid, &gEfiCertSha256Guid,
mSha256OfDevNull, mSizeOfSha256OfDevNull, &gEfiCallerIdGuid, mSha256OfDevNull,
NULL); mSizeOfSha256OfDevNull,
&gEfiCallerIdGuid,
NULL
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreePkKek1; goto FreePkKek1;
} }
@ -636,17 +734,26 @@ ShellAppMain (
EFI_KEY_EXCHANGE_KEY_NAME, EFI_KEY_EXCHANGE_KEY_NAME,
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
&gEfiCertX509Guid, &gEfiCertX509Guid,
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid, PkKek1,
NULL); SizeOfPkKek1,
&gEfiCallerIdGuid,
NULL
);
} else { } else {
Status = EnrollListOfCerts ( Status = EnrollListOfCerts (
EFI_KEY_EXCHANGE_KEY_NAME, EFI_KEY_EXCHANGE_KEY_NAME,
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
&gEfiCertX509Guid, &gEfiCertX509Guid,
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid, PkKek1,
mMicrosoftKek, mSizeOfMicrosoftKek, &gMicrosoftVendorGuid, SizeOfPkKek1,
NULL); &gEfiCallerIdGuid,
mMicrosoftKek,
mSizeOfMicrosoftKek,
&gMicrosoftVendorGuid,
NULL
);
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreePkKek1; goto FreePkKek1;
} }
@ -658,8 +765,11 @@ ShellAppMain (
EFI_PLATFORM_KEY_NAME, EFI_PLATFORM_KEY_NAME,
&gEfiGlobalVariableGuid, &gEfiGlobalVariableGuid,
&gEfiCertX509Guid, &gEfiCertX509Guid,
PkKek1, SizeOfPkKek1, &gEfiGlobalVariableGuid, PkKek1,
NULL); SizeOfPkKek1,
&gEfiGlobalVariableGuid,
NULL
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreePkKek1; goto FreePkKek1;
} }
@ -669,12 +779,20 @@ ShellAppMain (
// signatures. // signatures.
// //
Settings.CustomMode = STANDARD_SECURE_BOOT_MODE; Settings.CustomMode = STANDARD_SECURE_BOOT_MODE;
Status = gRT->SetVariable (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid, Status = gRT->SetVariable (
EFI_CUSTOM_MODE_NAME,
&gEfiCustomModeEnableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof Settings.CustomMode, &Settings.CustomMode); sizeof Settings.CustomMode,
&Settings.CustomMode
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
AsciiPrint ("error: SetVariable(\"%s\", %g): %r\n", EFI_CUSTOM_MODE_NAME, AsciiPrint (
&gEfiCustomModeEnableGuid, Status); "error: SetVariable(\"%s\", %g): %r\n",
EFI_CUSTOM_MODE_NAME,
&gEfiCustomModeEnableGuid,
Status
);
goto FreePkKek1; goto FreePkKek1;
} }
@ -713,11 +831,13 @@ ShellAppMain (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto FreePkKek1; goto FreePkKek1;
} }
PrintSettings (&Settings); PrintSettings (&Settings);
if (Settings.SetupMode != 0 || Settings.SecureBoot != 1 || if ((Settings.SetupMode != 0) || (Settings.SecureBoot != 1) ||
Settings.SecureBootEnable != 1 || Settings.CustomMode != 0 || (Settings.SecureBootEnable != 1) || (Settings.CustomMode != 0) ||
Settings.VendorKeys != 0) { (Settings.VendorKeys != 0))
{
AsciiPrint ("error: unexpected\n"); AsciiPrint ("error: unexpected\n");
goto FreePkKek1; goto FreePkKek1;
} }

View File

@ -106,7 +106,6 @@ typedef struct {
} REPEATING_HEADER; } REPEATING_HEADER;
#pragma pack () #pragma pack ()
// //
// A structure that collects the values of UEFI variables related to Secure // A structure that collects the values of UEFI variables related to Secure
// Boot. // Boot.
@ -119,7 +118,6 @@ typedef struct {
UINT8 VendorKeys; UINT8 VendorKeys;
} SETTINGS; } SETTINGS;
// //
// Refer to "AuthData.c" for details on the following objects. // Refer to "AuthData.c" for details on the following objects.
// //

View File

@ -51,21 +51,34 @@ MapGcdMmioSpace (
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, Base, Size, Status = gDS->AddMemorySpace (
EFI_MEMORY_UC); EfiGcdMemoryTypeMemoryMappedIo,
Base,
Size,
EFI_MEMORY_UC
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n", "%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n",
__FUNCTION__, Base, Size)); __FUNCTION__,
Base,
Size
));
return Status; return Status;
} }
Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC); Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n", "%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n",
__FUNCTION__, Base, Size)); __FUNCTION__,
Base,
Size
));
} }
return Status; return Status;
} }
@ -114,16 +127,24 @@ ProcessPciHost (
*Mmio64Size = 0; *Mmio64Size = 0;
IoTranslation = 0; IoTranslation = 0;
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&FdtClient); &gFdtClientProtocolGuid,
NULL,
(VOID **)&FdtClient
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = FdtClient->FindCompatibleNode (FdtClient, "pci-host-ecam-generic", Status = FdtClient->FindCompatibleNode (
&Node); FdtClient,
"pci-host-ecam-generic",
&Node
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: No 'pci-host-ecam-generic' compatible DT node found\n", "%a: No 'pci-host-ecam-generic' compatible DT node found\n",
__FUNCTION__)); __FUNCTION__
));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -134,15 +155,22 @@ ProcessPciHost (
// A DT can legally describe multiple PCI host bridges, but we are not // A DT can legally describe multiple PCI host bridges, but we are not
// equipped to deal with that. So assert that there is only one. // equipped to deal with that. So assert that there is only one.
// //
Status = FdtClient->FindNextCompatibleNode (FdtClient, Status = FdtClient->FindNextCompatibleNode (
"pci-host-ecam-generic", Node, &Tmp); FdtClient,
"pci-host-ecam-generic",
Node,
&Tmp
);
ASSERT (Status == EFI_NOT_FOUND); ASSERT (Status == EFI_NOT_FOUND);
); );
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", &Prop, &Len); Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", &Prop, &Len);
if (EFI_ERROR (Status) || Len != 2 * sizeof (UINT64)) { if (EFI_ERROR (Status) || (Len != 2 * sizeof (UINT64))) {
DEBUG ((DEBUG_ERROR, "%a: 'reg' property not found or invalid\n", DEBUG ((
__FUNCTION__)); DEBUG_ERROR,
"%a: 'reg' property not found or invalid\n",
__FUNCTION__
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -155,13 +183,22 @@ ProcessPciHost (
// //
// Fetch the bus range (note: inclusive). // Fetch the bus range (note: inclusive).
// //
Status = FdtClient->GetNodeProperty (FdtClient, Node, "bus-range", &Prop, Status = FdtClient->GetNodeProperty (
&Len); FdtClient,
if (EFI_ERROR (Status) || Len != 2 * sizeof (UINT32)) { Node,
DEBUG ((DEBUG_ERROR, "%a: 'bus-range' not found or invalid\n", "bus-range",
__FUNCTION__)); &Prop,
&Len
);
if (EFI_ERROR (Status) || (Len != 2 * sizeof (UINT32))) {
DEBUG ((
DEBUG_ERROR,
"%a: 'bus-range' not found or invalid\n",
__FUNCTION__
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
*BusMin = SwapBytes32 (((CONST UINT32 *)Prop)[0]); *BusMin = SwapBytes32 (((CONST UINT32 *)Prop)[0]);
*BusMax = SwapBytes32 (((CONST UINT32 *)Prop)[1]); *BusMax = SwapBytes32 (((CONST UINT32 *)Prop)[1]);
@ -169,10 +206,14 @@ ProcessPciHost (
// Sanity check: the config space must accommodate all 4K register bytes of // Sanity check: the config space must accommodate all 4K register bytes of
// all 8 functions of all 32 devices of all buses. // all 8 functions of all 32 devices of all buses.
// //
if (*BusMax < *BusMin || *BusMax - *BusMin == MAX_UINT32 || if ((*BusMax < *BusMin) || (*BusMax - *BusMin == MAX_UINT32) ||
DivU64x32 (ConfigSize, SIZE_4KB * 8 * 32) < *BusMax - *BusMin + 1) { (DivU64x32 (ConfigSize, SIZE_4KB * 8 * 32) < *BusMax - *BusMin + 1))
DEBUG ((DEBUG_ERROR, "%a: invalid 'bus-range' and/or 'reg'\n", {
__FUNCTION__)); DEBUG ((
DEBUG_ERROR,
"%a: invalid 'bus-range' and/or 'reg'\n",
__FUNCTION__
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -180,14 +221,16 @@ ProcessPciHost (
// Iterate over "ranges". // Iterate over "ranges".
// //
Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len); Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len);
if (EFI_ERROR (Status) || Len == 0 || if (EFI_ERROR (Status) || (Len == 0) ||
Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) { (Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0))
{
DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD); for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);
++RecordIdx) { ++RecordIdx)
{
CONST DTB_PCI_HOST_RANGE_RECORD *Record; CONST DTB_PCI_HOST_RANGE_RECORD *Record;
Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx; Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx;
@ -205,8 +248,9 @@ ProcessPciHost (
*Mmio32Size = SwapBytes64 (Record->Size); *Mmio32Size = SwapBytes64 (Record->Size);
Mmio32Translation = SwapBytes64 (Record->CpuBase) - *Mmio32Base; Mmio32Translation = SwapBytes64 (Record->CpuBase) - *Mmio32Base;
if (*Mmio32Base > MAX_UINT32 || *Mmio32Size > MAX_UINT32 || if ((*Mmio32Base > MAX_UINT32) || (*Mmio32Size > MAX_UINT32) ||
*Mmio32Base + *Mmio32Size > SIZE_4GB) { (*Mmio32Base + *Mmio32Size > SIZE_4GB))
{
DEBUG ((DEBUG_ERROR, "%a: MMIO32 space invalid\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: MMIO32 space invalid\n", __FUNCTION__));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -214,8 +258,13 @@ ProcessPciHost (
ASSERT (PcdGet64 (PcdPciMmio32Translation) == Mmio32Translation); ASSERT (PcdGet64 (PcdPciMmio32Translation) == Mmio32Translation);
if (Mmio32Translation != 0) { if (Mmio32Translation != 0) {
DEBUG ((DEBUG_ERROR, "%a: unsupported nonzero MMIO32 translation " DEBUG ((
"0x%Lx\n", __FUNCTION__, Mmio32Translation)); DEBUG_ERROR,
"%a: unsupported nonzero MMIO32 translation "
"0x%Lx\n",
__FUNCTION__,
Mmio32Translation
));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
@ -229,17 +278,27 @@ ProcessPciHost (
ASSERT (PcdGet64 (PcdPciMmio64Translation) == Mmio64Translation); ASSERT (PcdGet64 (PcdPciMmio64Translation) == Mmio64Translation);
if (Mmio64Translation != 0) { if (Mmio64Translation != 0) {
DEBUG ((DEBUG_ERROR, "%a: unsupported nonzero MMIO64 translation " DEBUG ((
"0x%Lx\n", __FUNCTION__, Mmio64Translation)); DEBUG_ERROR,
"%a: unsupported nonzero MMIO64 translation "
"0x%Lx\n",
__FUNCTION__,
Mmio64Translation
));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
break; break;
} }
} }
if (*IoSize == 0 || *Mmio32Size == 0) {
DEBUG ((DEBUG_ERROR, "%a: %a space empty\n", __FUNCTION__, if ((*IoSize == 0) || (*Mmio32Size == 0)) {
(*IoSize == 0) ? "IO" : "MMIO32")); DEBUG ((
DEBUG_ERROR,
"%a: %a space empty\n",
__FUNCTION__,
(*IoSize == 0) ? "IO" : "MMIO32"
));
return EFI_PROTOCOL_ERROR; return EFI_PROTOCOL_ERROR;
} }
@ -249,10 +308,23 @@ ProcessPciHost (
// //
ASSERT (PcdGet64 (PcdPciExpressBaseAddress) == ConfigBase); ASSERT (PcdGet64 (PcdPciExpressBaseAddress) == ConfigBase);
DEBUG ((DEBUG_INFO, "%a: Config[0x%Lx+0x%Lx) Bus[0x%x..0x%x] " DEBUG ((
DEBUG_INFO,
"%a: Config[0x%Lx+0x%Lx) Bus[0x%x..0x%x] "
"Io[0x%Lx+0x%Lx)@0x%Lx Mem32[0x%Lx+0x%Lx)@0x0 Mem64[0x%Lx+0x%Lx)@0x0\n", "Io[0x%Lx+0x%Lx)@0x%Lx Mem32[0x%Lx+0x%Lx)@0x0 Mem64[0x%Lx+0x%Lx)@0x0\n",
__FUNCTION__, ConfigBase, ConfigSize, *BusMin, *BusMax, *IoBase, *IoSize, __FUNCTION__,
IoTranslation, *Mmio32Base, *Mmio32Size, *Mmio64Base, *Mmio64Size)); ConfigBase,
ConfigSize,
*BusMin,
*BusMax,
*IoBase,
*IoSize,
IoTranslation,
*Mmio32Base,
*Mmio32Size,
*Mmio64Base,
*Mmio64Size
));
// Map the ECAM space in the GCD memory map // Map the ECAM space in the GCD memory map
Status = MapGcdMmioSpace (ConfigBase, ConfigSize); Status = MapGcdMmioSpace (ConfigBase, ConfigSize);
@ -307,11 +379,23 @@ PciHostBridgeGetRootBridges (
return NULL; return NULL;
} }
Status = ProcessPciHost (&IoBase, &IoSize, &Mmio32Base, &Mmio32Size, Status = ProcessPciHost (
&Mmio64Base, &Mmio64Size, &BusMin, &BusMax); &IoBase,
&IoSize,
&Mmio32Base,
&Mmio32Size,
&Mmio64Base,
&Mmio64Size,
&BusMin,
&BusMax
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: failed to discover PCI host bridge: %r\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_ERROR,
"%a: failed to discover PCI host bridge: %r\n",
__FUNCTION__,
Status
));
*Count = 0; *Count = 0;
return NULL; return NULL;
} }

View File

@ -55,14 +55,16 @@ GetPciIoTranslation (
// Iterate over "ranges". // Iterate over "ranges".
// //
Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len); Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len);
if (EFI_ERROR (Status) || Len == 0 || if (EFI_ERROR (Status) || (Len == 0) ||
Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) { (Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0))
{
DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));
return RETURN_PROTOCOL_ERROR; return RETURN_PROTOCOL_ERROR;
} }
for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD); for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);
++RecordIdx) { ++RecordIdx)
{
CONST DTB_PCI_HOST_RANGE_RECORD *Record; CONST DTB_PCI_HOST_RANGE_RECORD *Record;
UINT32 Type; UINT32 Type;
@ -75,6 +77,7 @@ GetPciIoTranslation (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
} }
return RETURN_NOT_FOUND; return RETURN_NOT_FOUND;
} }
@ -106,19 +109,30 @@ FdtPciPcdProducerLibConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&FdtClient); &gFdtClientProtocolGuid,
NULL,
(VOID **)&FdtClient
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
PciExpressBaseAddress = 0; PciExpressBaseAddress = 0;
Status = FdtClient->FindCompatibleNode (FdtClient, "pci-host-ecam-generic", Status = FdtClient->FindCompatibleNode (
&Node); FdtClient,
"pci-host-ecam-generic",
&Node
);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", Status = FdtClient->GetNodeProperty (
(CONST VOID **)&Reg, &RegSize); FdtClient,
Node,
"reg",
(CONST VOID **)&Reg,
&RegSize
);
if (!EFI_ERROR (Status) && RegSize == 2 * sizeof (UINT64)) { if (!EFI_ERROR (Status) && (RegSize == 2 * sizeof (UINT64))) {
PciExpressBaseAddress = SwapBytes64 (*Reg); PciExpressBaseAddress = SwapBytes64 (*Reg);
PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE); PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE);
@ -135,9 +149,11 @@ FdtPciPcdProducerLibConstructor (
// to abort in the general case. So leave it up to the actual driver to // to abort in the general case. So leave it up to the actual driver to
// complain about this if it wants to, and just issue a warning here. // complain about this if it wants to, and just issue a warning here.
// //
DEBUG ((DEBUG_WARN, DEBUG ((
DEBUG_WARN,
"%a: 'pci-host-ecam-generic' device encountered with no I/O range\n", "%a: 'pci-host-ecam-generic' device encountered with no I/O range\n",
__FUNCTION__)); __FUNCTION__
));
} }
} }
} }

View File

@ -36,24 +36,42 @@ InitializeHighMemDxe (
UINT64 Attributes; UINT64 Attributes;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&FdtClient); &gFdtClientProtocolGuid,
NULL,
(VOID **)&FdtClient
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&Cpu); &gEfiCpuArchProtocolGuid,
NULL,
(VOID **)&Cpu
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
// Check for memory node and add the memory spaces except the lowest one // Check for memory node and add the memory spaces except the lowest one
// //
for (FindNodeStatus = FdtClient->FindMemoryNodeReg (FdtClient, &Node, for (FindNodeStatus = FdtClient->FindMemoryNodeReg (
(CONST VOID **) &Reg, &AddressCells, FdtClient,
&SizeCells, &RegSize); &Node,
(CONST VOID **)&Reg,
&AddressCells,
&SizeCells,
&RegSize
);
!EFI_ERROR (FindNodeStatus); !EFI_ERROR (FindNodeStatus);
FindNodeStatus = FdtClient->FindNextMemoryNodeReg (FdtClient, Node, FindNodeStatus = FdtClient->FindNextMemoryNodeReg (
&Node, (CONST VOID **) &Reg, &AddressCells, FdtClient,
&SizeCells, &RegSize)) { Node,
&Node,
(CONST VOID **)&Reg,
&AddressCells,
&SizeCells,
&RegSize
))
{
ASSERT (AddressCells <= 2); ASSERT (AddressCells <= 2);
ASSERT (SizeCells <= 2); ASSERT (SizeCells <= 2);
@ -62,36 +80,60 @@ InitializeHighMemDxe (
if (AddressCells > 1) { if (AddressCells > 1) {
CurBase = (CurBase << 32) | SwapBytes32 (*Reg++); CurBase = (CurBase << 32) | SwapBytes32 (*Reg++);
} }
CurSize = SwapBytes32 (*Reg++); CurSize = SwapBytes32 (*Reg++);
if (SizeCells > 1) { if (SizeCells > 1) {
CurSize = (CurSize << 32) | SwapBytes32 (*Reg++); CurSize = (CurSize << 32) | SwapBytes32 (*Reg++);
} }
RegSize -= (AddressCells + SizeCells) * sizeof (UINT32); RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);
Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor); Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, DEBUG ((
DEBUG_WARN,
"%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n", "%a: Region 0x%lx - 0x%lx not found in the GCD memory space map\n",
__FUNCTION__, CurBase, CurBase + CurSize - 1)); __FUNCTION__,
CurBase,
CurBase + CurSize - 1
));
continue; continue;
} }
if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) { if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase, Status = gDS->AddMemorySpace (
CurSize, EFI_MEMORY_WB); EfiGcdMemoryTypeSystemMemory,
CurBase,
CurSize,
EFI_MEMORY_WB
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n", "%a: Failed to add System RAM @ 0x%lx - 0x%lx (%r)\n",
__FUNCTION__, CurBase, CurBase + CurSize - 1, Status)); __FUNCTION__,
CurBase,
CurBase + CurSize - 1,
Status
));
continue; continue;
} }
Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize, Status = gDS->SetMemorySpaceAttributes (
EFI_MEMORY_WB); CurBase,
CurSize,
EFI_MEMORY_WB
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, DEBUG ((
DEBUG_WARN,
"%a: gDS->SetMemorySpaceAttributes() failed on region 0x%lx - 0x%lx (%r)\n", "%a: gDS->SetMemorySpaceAttributes() failed on region 0x%lx - 0x%lx (%r)\n",
__FUNCTION__, CurBase, CurBase + CurSize - 1, Status)); __FUNCTION__,
CurBase,
CurBase + CurSize - 1,
Status
));
} }
// //
@ -107,19 +149,30 @@ InitializeHighMemDxe (
// //
Attributes = EFI_MEMORY_WB; Attributes = EFI_MEMORY_WB;
if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) & if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) &
(1U << (UINT32)EfiConventionalMemory)) != 0) { (1U << (UINT32)EfiConventionalMemory)) != 0)
{
Attributes |= EFI_MEMORY_XP; Attributes |= EFI_MEMORY_XP;
} }
Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes); Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n", "%a: Failed to set System RAM @ 0x%lx - 0x%lx attribute (%r)\n",
__FUNCTION__, CurBase, CurBase + CurSize - 1, Status)); __FUNCTION__,
CurBase,
CurBase + CurSize - 1,
Status
));
} else { } else {
DEBUG ((DEBUG_INFO, "%a: Add System RAM @ 0x%lx - 0x%lx\n", DEBUG ((
__FUNCTION__, CurBase, CurBase + CurSize - 1)); DEBUG_INFO,
"%a: Add System RAM @ 0x%lx - 0x%lx\n",
__FUNCTION__,
CurBase,
CurBase + CurSize - 1
));
} }
} }
} }

View File

@ -44,21 +44,40 @@ InitializeVirtioFdtDxe (
EFI_HANDLE Handle; EFI_HANDLE Handle;
UINT64 RegBase; UINT64 RegBase;
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, Status = gBS->LocateProtocol (
(VOID **)&FdtClient); &gFdtClientProtocolGuid,
NULL,
(VOID **)&FdtClient
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
for (FindNodeStatus = FdtClient->FindCompatibleNode (FdtClient, for (FindNodeStatus = FdtClient->FindCompatibleNode (
"virtio,mmio", &Node); FdtClient,
"virtio,mmio",
&Node
);
!EFI_ERROR (FindNodeStatus); !EFI_ERROR (FindNodeStatus);
FindNodeStatus = FdtClient->FindNextCompatibleNode (FdtClient, FindNodeStatus = FdtClient->FindNextCompatibleNode (
"virtio,mmio", Node, &Node)) { FdtClient,
"virtio,mmio",
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", Node,
(CONST VOID **)&Reg, &RegSize); &Node
))
{
Status = FdtClient->GetNodeProperty (
FdtClient,
Node,
"reg",
(CONST VOID **)&Reg,
&RegSize
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: GetNodeProperty () failed (Status == %r)\n", DEBUG ((
__FUNCTION__, Status)); DEBUG_ERROR,
"%a: GetNodeProperty () failed (Status == %r)\n",
__FUNCTION__,
Status
));
continue; continue;
} }
@ -71,7 +90,8 @@ InitializeVirtioFdtDxe (
DevicePath = (VIRTIO_TRANSPORT_DEVICE_PATH *)CreateDeviceNode ( DevicePath = (VIRTIO_TRANSPORT_DEVICE_PATH *)CreateDeviceNode (
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
sizeof (VIRTIO_TRANSPORT_DEVICE_PATH)); sizeof (VIRTIO_TRANSPORT_DEVICE_PATH)
);
if (DevicePath == NULL) { if (DevicePath == NULL) {
DEBUG ((DEBUG_ERROR, "%a: Out of memory\n", __FUNCTION__)); DEBUG ((DEBUG_ERROR, "%a: Out of memory\n", __FUNCTION__));
continue; continue;
@ -79,39 +99,62 @@ InitializeVirtioFdtDxe (
CopyGuid (&DevicePath->Vendor.Guid, &gVirtioMmioTransportGuid); CopyGuid (&DevicePath->Vendor.Guid, &gVirtioMmioTransportGuid);
DevicePath->PhysBase = RegBase; DevicePath->PhysBase = RegBase;
SetDevicePathNodeLength (&DevicePath->Vendor, SetDevicePathNodeLength (
sizeof (*DevicePath) - sizeof (DevicePath->End)); &DevicePath->Vendor,
sizeof (*DevicePath) - sizeof (DevicePath->End)
);
SetDevicePathEndNode (&DevicePath->End); SetDevicePathEndNode (&DevicePath->End);
Handle = NULL; Handle = NULL;
Status = gBS->InstallProtocolInterface (&Handle, Status = gBS->InstallProtocolInterface (
&gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, &Handle,
DevicePath); &gEfiDevicePathProtocolGuid,
EFI_NATIVE_INTERFACE,
DevicePath
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH " DEBUG ((
DEBUG_ERROR,
"%a: Failed to install the EFI_DEVICE_PATH "
"protocol on a new handle (Status == %r)\n", "protocol on a new handle (Status == %r)\n",
__FUNCTION__, Status)); __FUNCTION__,
Status
));
FreePool (DevicePath); FreePool (DevicePath);
continue; continue;
} }
Status = VirtioMmioInstallDevice (RegBase, Handle); Status = VirtioMmioInstallDevice (RegBase, Handle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Failed to install VirtIO transport @ 0x%Lx " DEBUG ((
"on handle %p (Status == %r)\n", __FUNCTION__, RegBase, DEBUG_ERROR,
Handle, Status)); "%a: Failed to install VirtIO transport @ 0x%Lx "
"on handle %p (Status == %r)\n",
__FUNCTION__,
RegBase,
Handle,
Status
));
Status = gBS->UninstallProtocolInterface (Handle, Status = gBS->UninstallProtocolInterface (
&gEfiDevicePathProtocolGuid, DevicePath); Handle,
&gEfiDevicePathProtocolGuid,
DevicePath
);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
FreePool (DevicePath); FreePool (DevicePath);
continue; continue;
} }
} }
if (EFI_ERROR (FindNodeStatus) && FindNodeStatus != EFI_NOT_FOUND) { if (EFI_ERROR (FindNodeStatus) && (FindNodeStatus != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_ERROR, "%a: Error occurred while iterating DT nodes " DEBUG ((
"(FindNodeStatus == %r)\n", __FUNCTION__, FindNodeStatus)); DEBUG_ERROR,
"%a: Error occurred while iterating DT nodes "
"(FindNodeStatus == %r)\n",
__FUNCTION__,
FindNodeStatus
));
} }
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __E820_H__ #ifndef __E820_H__
#define __E820_H__ #define __E820_H__

View File

@ -153,6 +153,9 @@ typedef struct {
#pragma pack() #pragma pack()
extern EFI_STATUS setup_graphics(struct boot_params *buf); extern EFI_STATUS
setup_graphics (
struct boot_params *buf
);
#endif /* __LINUX_BZIMAGE_H__ */ #endif /* __LINUX_BZIMAGE_H__ */

View File

@ -4,6 +4,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __MICROVM_H__ #ifndef __MICROVM_H__
#define __MICROVM_H__ #define __MICROVM_H__

View File

@ -80,7 +80,6 @@ typedef enum {
QemuFwCfgItemX86Irq0Override = 0x8002, QemuFwCfgItemX86Irq0Override = 0x8002,
QemuFwCfgItemX86E820Table = 0x8003, QemuFwCfgItemX86E820Table = 0x8003,
QemuFwCfgItemX86HpetData = 0x8004, QemuFwCfgItemX86HpetData = 0x8004,
} FIRMWARE_CONFIG_ITEM; } FIRMWARE_CONFIG_ITEM;
// //

View File

@ -35,7 +35,6 @@
#define VIRTIO_VENDOR_ID 0x1AF4 #define VIRTIO_VENDOR_ID 0x1AF4
#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt" #define VIRTIO_MMIO_MAGIC 0x74726976 // "virt"
// //
// VirtIo Device Specific Configuration Offsets // VirtIo Device Specific Configuration Offsets
// //
@ -104,7 +103,6 @@ typedef struct {
volatile UINT16 *UsedEvent; // unused as per negotiation volatile UINT16 *UsedEvent; // unused as per negotiation
} VRING_AVAIL; } VRING_AVAIL;
// //
// virtio-0.9.5, 2.3.5 Used Ring // virtio-0.9.5, 2.3.5 Used Ring
// //
@ -124,7 +122,6 @@ typedef struct {
volatile UINT16 *AvailEvent; // unused as per negotiation volatile UINT16 *AvailEvent; // unused as per negotiation
} VRING_USED; } VRING_USED;
// //
// virtio-0.9.5, 2.3.2 Descriptor Table // virtio-0.9.5, 2.3.2 Descriptor Table
// //
@ -165,5 +162,4 @@ typedef struct {
#define VIRTIO_F_RING_INDIRECT_DESC BIT28 #define VIRTIO_F_RING_INDIRECT_DESC BIT28
#define VIRTIO_F_RING_EVENT_IDX BIT29 #define VIRTIO_F_RING_EVENT_IDX BIT29
#endif // _VIRTIO_0_9_5_H_ #endif // _VIRTIO_0_9_5_H_

View File

@ -14,7 +14,6 @@
#include <IndustryStandard/Virtio.h> #include <IndustryStandard/Virtio.h>
// //
// virtio-0.9.5, Appendix D: Block Device // virtio-0.9.5, Appendix D: Block Device
// //

View File

@ -14,7 +14,6 @@
#include <IndustryStandard/Virtio.h> #include <IndustryStandard/Virtio.h>
// //
// virtio-0.9.5, Appendix I: SCSI Host Device // virtio-0.9.5, Appendix I: SCSI Host Device
// //

View File

@ -200,8 +200,7 @@
#define __DECL_REG(n64, n32) UINT64 n64 #define __DECL_REG(n64, n32) UINT64 n64
#endif #endif
struct vcpu_guest_core_regs struct vcpu_guest_core_regs {
{
/* Aarch64 Aarch32 */ /* Aarch64 Aarch32 */
__DECL_REG (x0, r0_usr); __DECL_REG (x0, r0_usr);
__DECL_REG (x1, r1_usr); __DECL_REG (x1, r1_usr);
@ -259,6 +258,7 @@ struct vcpu_guest_core_regs
UINT64 sp_el0; UINT64 sp_el0;
UINT64 sp_el1, elr_el1; UINT64 sp_el1, elr_el1;
}; };
typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t; typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t;
DEFINE_XEN_GUEST_HANDLE (vcpu_guest_core_regs_t); DEFINE_XEN_GUEST_HANDLE (vcpu_guest_core_regs_t);
@ -285,16 +285,19 @@ struct vcpu_guest_context {
UINT32 sctlr; UINT32 sctlr;
UINT64 ttbcr, ttbr0, ttbr1; UINT64 ttbcr, ttbr0, ttbr1;
}; };
typedef struct vcpu_guest_context vcpu_guest_context_t; typedef struct vcpu_guest_context vcpu_guest_context_t;
DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t); DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t);
#endif #endif
struct arch_vcpu_info { struct arch_vcpu_info {
}; };
typedef struct arch_vcpu_info arch_vcpu_info_t; typedef struct arch_vcpu_info arch_vcpu_info_t;
struct arch_shared_info { struct arch_shared_info {
}; };
typedef struct arch_shared_info arch_shared_info_t; typedef struct arch_shared_info arch_shared_info_t;
typedef UINT64 xen_callback_t; typedef UINT64 xen_callback_t;

View File

@ -26,6 +26,7 @@ struct arch_vcpu_info {
UINTN cr2; UINTN cr2;
UINTN pad[5]; /* sizeof(vcpu_info_t) == 64 */ UINTN pad[5]; /* sizeof(vcpu_info_t) == 64 */
}; };
typedef struct arch_vcpu_info arch_vcpu_info_t; typedef struct arch_vcpu_info arch_vcpu_info_t;
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */

View File

@ -26,6 +26,7 @@ struct arch_vcpu_info {
UINTN cr2; UINTN cr2;
UINTN pad; /* sizeof(vcpu_info_t) == 64 */ UINTN pad; /* sizeof(vcpu_info_t) == 64 */
}; };
typedef struct arch_vcpu_info arch_vcpu_info_t; typedef struct arch_vcpu_info arch_vcpu_info_t;
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */

View File

@ -76,6 +76,7 @@ struct arch_shared_info {
UINTN nmi_reason; UINTN nmi_reason;
UINT64 pad[32]; UINT64 pad[32];
}; };
typedef struct arch_shared_info arch_shared_info_t; typedef struct arch_shared_info arch_shared_info_t;
#ifdef MDE_CPU_IA32 #ifdef MDE_CPU_IA32
#pragma pack() #pragma pack()

View File

@ -66,6 +66,7 @@ struct evtchn_alloc_unbound {
/* OUT parameters */ /* OUT parameters */
evtchn_port_t port; evtchn_port_t port;
}; };
typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t; typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
/* /*
@ -77,6 +78,7 @@ struct evtchn_close {
/* IN parameters. */ /* IN parameters. */
evtchn_port_t port; evtchn_port_t port;
}; };
typedef struct evtchn_close evtchn_close_t; typedef struct evtchn_close evtchn_close_t;
/* /*
@ -87,6 +89,7 @@ struct evtchn_send {
/* IN parameters. */ /* IN parameters. */
evtchn_port_t port; evtchn_port_t port;
}; };
typedef struct evtchn_send evtchn_send_t; typedef struct evtchn_send evtchn_send_t;
#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */ #endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */

View File

@ -117,12 +117,14 @@ struct grant_entry_v1 {
UINT16 flags; UINT16 flags;
/* The domain being granted foreign privileges. [GST] */ /* The domain being granted foreign privileges. [GST] */
domid_t domid; domid_t domid;
/* /*
* GTF_permit_access: Frame that @domid is allowed to map and access. [GST] * GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
* GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
*/ */
UINT32 frame; UINT32 frame;
}; };
typedef struct grant_entry_v1 grant_entry_v1_t; typedef struct grant_entry_v1 grant_entry_v1_t;
/* The first few grant table entries will be preserved across grant table /* The first few grant table entries will be preserved across grant table
@ -197,6 +199,7 @@ typedef struct grant_entry_v1 grant_entry_v1_t;
* on the grant table version in use by the other domain. * on the grant table version in use by the other domain.
*/ */
#if __XEN_INTERFACE_VERSION__ >= 0x0003020a #if __XEN_INTERFACE_VERSION__ >= 0x0003020a
/* /*
* Version 1 and version 2 grant entries share a common prefix. The * Version 1 and version 2 grant entries share a common prefix. The
* fields of the prefix are documented as part of struct * fields of the prefix are documented as part of struct
@ -206,6 +209,7 @@ struct grant_entry_header {
UINT16 flags; UINT16 flags;
domid_t domid; domid_t domid;
}; };
typedef struct grant_entry_header grant_entry_header_t; typedef struct grant_entry_header grant_entry_header_t;
/* /*
@ -259,6 +263,7 @@ union grant_entry_v2 {
UINT32 __spacer[4]; /* Pad to a power of two */ UINT32 __spacer[4]; /* Pad to a power of two */
}; };
typedef union grant_entry_v2 grant_entry_v2_t; typedef union grant_entry_v2 grant_entry_v2_t;
typedef UINT16 grant_status_t; typedef UINT16 grant_status_t;
@ -317,6 +322,7 @@ struct gnttab_map_grant_ref {
grant_handle_t handle; grant_handle_t handle;
UINT64 dev_bus_addr; UINT64 dev_bus_addr;
}; };
typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE (gnttab_map_grant_ref_t); DEFINE_XEN_GUEST_HANDLE (gnttab_map_grant_ref_t);
@ -339,6 +345,7 @@ struct gnttab_unmap_grant_ref {
/* OUT parameters. */ /* OUT parameters. */
INT16 status; /* => enum grant_status */ INT16 status; /* => enum grant_status */
}; };
typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
DEFINE_XEN_GUEST_HANDLE (gnttab_unmap_grant_ref_t); DEFINE_XEN_GUEST_HANDLE (gnttab_unmap_grant_ref_t);
@ -354,6 +361,7 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
/* Accesses to the granted frame will be restricted to read-only access. */ /* Accesses to the granted frame will be restricted to read-only access. */
#define _GNTMAP_readonly (2) #define _GNTMAP_readonly (2)
#define GNTMAP_readonly (1<<_GNTMAP_readonly) #define GNTMAP_readonly (1<<_GNTMAP_readonly)
/* /*
* GNTMAP_host_map subflag: * GNTMAP_host_map subflag:
* 0 => The host mapping is usable only by the guest OS. * 0 => The host mapping is usable only by the guest OS.

View File

@ -15,6 +15,7 @@ struct xen_hvm_param {
UINT32 index; /* IN */ UINT32 index; /* IN */
UINT64 value; /* IN/OUT */ UINT64 value; /* IN/OUT */
}; };
typedef struct xen_hvm_param xen_hvm_param_t; typedef struct xen_hvm_param xen_hvm_param_t;
DEFINE_XEN_GUEST_HANDLE (xen_hvm_param_t); DEFINE_XEN_GUEST_HANDLE (xen_hvm_param_t);

View File

@ -417,6 +417,7 @@
*/ */
#define BLKIF_OP_READ 0 #define BLKIF_OP_READ 0
#define BLKIF_OP_WRITE 1 #define BLKIF_OP_WRITE 1
/* /*
* All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER
* operation code ("barrier request") must be completed prior to the * operation code ("barrier request") must be completed prior to the
@ -426,6 +427,7 @@
* Optional. See "feature-barrier" XenBus node documentation above. * Optional. See "feature-barrier" XenBus node documentation above.
*/ */
#define BLKIF_OP_WRITE_BARRIER 2 #define BLKIF_OP_WRITE_BARRIER 2
/* /*
* Commit any uncommitted contents of the backing device's volatile cache * Commit any uncommitted contents of the backing device's volatile cache
* to stable storage. * to stable storage.
@ -433,11 +435,13 @@
* Optional. See "feature-flush-cache" XenBus node documentation above. * Optional. See "feature-flush-cache" XenBus node documentation above.
*/ */
#define BLKIF_OP_FLUSH_DISKCACHE 3 #define BLKIF_OP_FLUSH_DISKCACHE 3
/* /*
* Used in SLES sources for device specific command packet * Used in SLES sources for device specific command packet
* contained within the request. Reserved for that purpose. * contained within the request. Reserved for that purpose.
*/ */
#define BLKIF_OP_RESERVED_1 4 #define BLKIF_OP_RESERVED_1 4
/* /*
* Indicate to the backend device that a region of storage is no longer in * Indicate to the backend device that a region of storage is no longer in
* use, and may be discarded at any time without impact to the client. If * use, and may be discarded at any time without impact to the client. If
@ -530,6 +534,7 @@ struct blkif_request {
blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */ blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */
struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
}; };
typedef struct blkif_request blkif_request_t; typedef struct blkif_request blkif_request_t;
/* /*
@ -545,6 +550,7 @@ struct blkif_request_discard {
blkif_sector_t sector_number; /* start sector idx on disk */ blkif_sector_t sector_number; /* start sector idx on disk */
UINT64 nr_sectors; /* number of contiguous sectors to discard*/ UINT64 nr_sectors; /* number of contiguous sectors to discard*/
}; };
typedef struct blkif_request_discard blkif_request_discard_t; typedef struct blkif_request_discard blkif_request_discard_t;
struct blkif_request_indirect { struct blkif_request_indirect {
@ -559,6 +565,7 @@ struct blkif_request_indirect {
UINT64 pad; /* Make it 64 byte aligned on i386 */ UINT64 pad; /* Make it 64 byte aligned on i386 */
#endif #endif
}; };
typedef struct blkif_request_indirect blkif_request_indirect_t; typedef struct blkif_request_indirect blkif_request_indirect_t;
struct blkif_response { struct blkif_response {
@ -566,6 +573,7 @@ struct blkif_response {
UINT8 operation; /* copied from request */ UINT8 operation; /* copied from request */
INT16 status; /* BLKIF_RSP_??? */ INT16 status; /* BLKIF_RSP_??? */
}; };
typedef struct blkif_response blkif_response_t; typedef struct blkif_response blkif_response_t;
#if defined (MDE_CPU_IA32) #if defined (MDE_CPU_IA32)
#pragma pack() #pragma pack()

View File

@ -37,6 +37,7 @@ typedef UINT32 RING_IDX;
#define __CONST_RING_SIZE(_s, _sz) \ #define __CONST_RING_SIZE(_s, _sz) \
(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
sizeof(((struct _s##_sring *)0)->ring[0]))) sizeof(((struct _s##_sring *)0)->ring[0])))
/* /*
* The same for passing in an actual pointer instead of a name tag. * The same for passing in an actual pointer instead of a name tag.
*/ */

View File

@ -49,6 +49,7 @@ enum xenbus_state {
XenbusStateReconfigured = 8 XenbusStateReconfigured = 8
}; };
typedef enum xenbus_state XenbusState; typedef enum xenbus_state XenbusState;
#endif /* _XEN_PUBLIC_IO_XENBUS_H */ #endif /* _XEN_PUBLIC_IO_XENBUS_H */

View File

@ -10,8 +10,7 @@
#ifndef _XS_WIRE_H #ifndef _XS_WIRE_H
#define _XS_WIRE_H #define _XS_WIRE_H
enum xsd_sockmsg_type enum xsd_sockmsg_type {
{
XS_DEBUG, XS_DEBUG,
XS_DIRECTORY, XS_DIRECTORY,
XS_READ, XS_READ,
@ -43,11 +42,11 @@ enum xsd_sockmsg_type
#define XS_WRITE_CREATE_EXCL "CREATE|EXCL" #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
/* We hand errors as strings, for portability. */ /* We hand errors as strings, for portability. */
struct xsd_errors struct xsd_errors {
{
INT32 errnum; INT32 errnum;
const CHAR8 *errstring; const CHAR8 *errstring;
}; };
#ifdef EINVAL #ifdef EINVAL
#define XSD_ERROR(x) { x, #x } #define XSD_ERROR(x) { x, #x }
/* LINTED: static unused */ /* LINTED: static unused */
@ -74,8 +73,7 @@ __attribute__((unused))
}; };
#endif #endif
struct xsd_sockmsg struct xsd_sockmsg {
{
UINT32 type; /* XS_??? */ UINT32 type; /* XS_??? */
UINT32 req_id; /* Request identifier, echoed in daemon's response. */ UINT32 req_id; /* Request identifier, echoed in daemon's response. */
UINT32 tx_id; /* Transaction id (0 if not related to a transaction). */ UINT32 tx_id; /* Transaction id (0 if not related to a transaction). */
@ -84,8 +82,7 @@ struct xsd_sockmsg
/* Generally followed by nul-terminated string(s). */ /* Generally followed by nul-terminated string(s). */
}; };
enum xs_watch_type enum xs_watch_type {
{
XS_WATCH_PATH = 0, XS_WATCH_PATH = 0,
XS_WATCH_TOKEN XS_WATCH_TOKEN
}; };

View File

@ -46,6 +46,7 @@ struct xen_add_to_physmap {
/* GPFN in domid where the source mapping page should appear. */ /* GPFN in domid where the source mapping page should appear. */
xen_pfn_t gpfn; xen_pfn_t gpfn;
}; };
typedef struct xen_add_to_physmap xen_add_to_physmap_t; typedef struct xen_add_to_physmap xen_add_to_physmap_t;
DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_t); DEFINE_XEN_GUEST_HANDLE (xen_add_to_physmap_t);
@ -62,6 +63,7 @@ struct xen_remove_from_physmap {
/* GPFN of the current mapping of the page. */ /* GPFN of the current mapping of the page. */
xen_pfn_t gpfn; xen_pfn_t gpfn;
}; };
typedef struct xen_remove_from_physmap xen_remove_from_physmap_t; typedef struct xen_remove_from_physmap xen_remove_from_physmap_t;
DEFINE_XEN_GUEST_HANDLE (xen_remove_from_physmap_t); DEFINE_XEN_GUEST_HANDLE (xen_remove_from_physmap_t);
@ -85,6 +87,7 @@ struct xen_memory_map {
*/ */
XEN_GUEST_HANDLE (void) buffer; XEN_GUEST_HANDLE (void) buffer;
}; };
typedef struct xen_memory_map xen_memory_map_t; typedef struct xen_memory_map xen_memory_map_t;
DEFINE_XEN_GUEST_HANDLE (xen_memory_map_t); DEFINE_XEN_GUEST_HANDLE (xen_memory_map_t);

View File

@ -166,6 +166,7 @@ typedef UINT16 domid_t;
#define DOMID_IDLE (0x7FFFU) #define DOMID_IDLE (0x7FFFU)
#if __XEN_INTERFACE_VERSION__ < 0x00040400 #if __XEN_INTERFACE_VERSION__ < 0x00040400
/* /*
* Event channel endpoints per domain (when using the 2-level ABI): * Event channel endpoints per domain (when using the 2-level ABI):
* 1024 if a INTN is 32 bits; 4096 if a INTN is 64 bits. * 1024 if a INTN is 32 bits; 4096 if a INTN is 64 bits.
@ -187,6 +188,7 @@ struct vcpu_time_info {
UINT32 pad0; UINT32 pad0;
UINT64 TscTimestamp; /* TSC at last update of time vals. */ UINT64 TscTimestamp; /* TSC at last update of time vals. */
UINT64 SystemTime; /* Time, in nanosecs, since boot. */ UINT64 SystemTime; /* Time, in nanosecs, since boot. */
/* /*
* Current system time: * Current system time:
* system_time + * system_time +
@ -198,6 +200,7 @@ struct vcpu_time_info {
INT8 TscShift; INT8 TscShift;
INT8 pad1[3]; INT8 pad1[3];
}; /* 32 bytes */ }; /* 32 bytes */
typedef struct vcpu_time_info XEN_VCPU_TIME_INFO; typedef struct vcpu_time_info XEN_VCPU_TIME_INFO;
struct vcpu_info { struct vcpu_info {
@ -236,6 +239,7 @@ struct vcpu_info {
struct arch_vcpu_info arch; struct arch_vcpu_info arch;
struct vcpu_time_info Time; struct vcpu_time_info Time;
}; /* 64 bytes (x86) */ }; /* 64 bytes (x86) */
#ifndef __XEN__ #ifndef __XEN__
typedef struct vcpu_info vcpu_info_t; typedef struct vcpu_info vcpu_info_t;
#endif #endif
@ -295,8 +299,8 @@ struct shared_info {
UINT32 wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */ UINT32 wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
struct arch_shared_info arch; struct arch_shared_info arch;
}; };
#ifndef __XEN__ #ifndef __XEN__
typedef struct shared_info shared_info_t; typedef struct shared_info shared_info_t;
typedef struct shared_info XEN_SHARED_INFO; typedef struct shared_info XEN_SHARED_INFO;

View File

@ -9,7 +9,6 @@
#ifndef __LOAD_LINUX_LIB__ #ifndef __LOAD_LINUX_LIB__
#define __LOAD_LINUX_LIB__ #define __LOAD_LINUX_LIB__
/** /**
Verifies that the kernel setup image is valid and supported. Verifies that the kernel setup image is valid and supported.
The kernel setup image should be checked before using other library The kernel setup image should be checked before using other library
@ -30,7 +29,6 @@ LoadLinuxCheckKernelSetup (
IN UINTN KernelSetupSize IN UINTN KernelSetupSize
); );
/** /**
Gets the initial runtime size of the Linux kernel image by examining Gets the initial runtime size of the Linux kernel image by examining
the kernel setup image. the kernel setup image.
@ -50,7 +48,6 @@ LoadLinuxGetKernelSize (
IN UINTN KernelSize IN UINTN KernelSize
); );
/** /**
Loads and boots UEFI Linux. Loads and boots UEFI Linux.
@ -71,7 +68,6 @@ LoadLinux (
IN OUT VOID *KernelSetup IN OUT VOID *KernelSetup
); );
/** /**
Allocates pages for the kernel setup image. Allocates pages for the kernel setup image.
@ -87,7 +83,6 @@ LoadLinuxAllocateKernelSetupPages (
IN UINTN Pages IN UINTN Pages
); );
/** /**
Clears the uninitialised space before and after the struct setup_header Clears the uninitialised space before and after the struct setup_header
in the kernel setup image. The kernel requires that these be zeroed in the kernel setup image. The kernel requires that these be zeroed
@ -126,7 +121,6 @@ LoadLinuxAllocateKernelPages (
IN UINTN Pages IN UINTN Pages
); );
/** /**
Allocates pages for the kernel command line. Allocates pages for the kernel command line.
@ -142,7 +136,6 @@ LoadLinuxAllocateCommandLinePages (
IN UINTN Pages IN UINTN Pages
); );
/** /**
Allocates pages for the initrd image. Allocates pages for the initrd image.
@ -160,7 +153,6 @@ LoadLinuxAllocateInitrdPages (
IN UINTN Pages IN UINTN Pages
); );
/** /**
Sets the kernel command line parameter within the setup image. Sets the kernel command line parameter within the setup image.
@ -179,7 +171,6 @@ LoadLinuxSetCommandLine (
IN CHAR8 *CommandLine IN CHAR8 *CommandLine
); );
/** /**
Sets the kernel initial ram disk pointer within the setup image. Sets the kernel initial ram disk pointer within the setup image.
@ -200,6 +191,4 @@ LoadLinuxSetInitrd (
IN UINTN InitrdSize IN UINTN InitrdSize
); );
#endif #endif

View File

@ -121,7 +121,6 @@ MemEncryptSevSetPageEncMask (
IN UINTN NumPages IN UINTN NumPages
); );
/** /**
Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
Save State Map. Save State Map.

View File

@ -25,7 +25,6 @@ ConnectNvVarsToFileSystem (
IN EFI_HANDLE FsHandle IN EFI_HANDLE FsHandle
); );
/** /**
Update non-volatile variables stored on the file system. Update non-volatile variables stored on the file system.
@ -40,6 +39,4 @@ EFIAPI
UpdateNvVarsOnFileSystem ( UpdateNvVarsOnFileSystem (
); );
#endif #endif

View File

@ -162,7 +162,6 @@ typedef struct {
UINT8 Version; UINT8 Version;
} PCI_CAP_INFO; } PCI_CAP_INFO;
/** /**
Parse the capabilities lists (both normal and extended, as applicable) of a Parse the capabilities lists (both normal and extended, as applicable) of a
PCI device. PCI device.
@ -202,7 +201,6 @@ PciCapListInit (
OUT PCI_CAP_LIST **CapList OUT PCI_CAP_LIST **CapList
); );
/** /**
Free the resources used by CapList. Free the resources used by CapList.
@ -215,7 +213,6 @@ PciCapListUninit (
IN PCI_CAP_LIST *CapList IN PCI_CAP_LIST *CapList
); );
/** /**
Locate a capability instance in the parsed capabilities lists. Locate a capability instance in the parsed capabilities lists.
@ -259,7 +256,6 @@ PciCapListFindCap (
OUT PCI_CAP **Cap OPTIONAL OUT PCI_CAP **Cap OPTIONAL
); );
/** /**
Locate the first instance of the capability given by (Domain, CapId) such Locate the first instance of the capability given by (Domain, CapId) such
that the instance's Version is greater than or equal to MinVersion. that the instance's Version is greater than or equal to MinVersion.
@ -303,7 +299,6 @@ PciCapListFindCapVersion (
OUT PCI_CAP **Cap OPTIONAL OUT PCI_CAP **Cap OPTIONAL
); );
/** /**
Get information about a PCI Capability instance. Get information about a PCI Capability instance.
@ -325,7 +320,6 @@ PciCapGetInfo (
OUT PCI_CAP_INFO *Info OUT PCI_CAP_INFO *Info
); );
/** /**
Read a slice of a capability instance. Read a slice of a capability instance.
@ -372,7 +366,6 @@ PciCapRead (
IN UINT16 Size IN UINT16 Size
); );
/** /**
Write a slice of a capability instance. Write a slice of a capability instance.

View File

@ -14,7 +14,6 @@
#include <Library/PciCapLib.h> #include <Library/PciCapLib.h>
/** /**
Create a PCI_CAP_DEV object from an EFI_PCI_IO_PROTOCOL instance. The config Create a PCI_CAP_DEV object from an EFI_PCI_IO_PROTOCOL instance. The config
space accessors are based upon EFI_PCI_IO_PROTOCOL.Pci.Read() and space accessors are based upon EFI_PCI_IO_PROTOCOL.Pci.Read() and
@ -36,7 +35,6 @@ PciCapPciIoDeviceInit (
OUT PCI_CAP_DEV **PciDevice OUT PCI_CAP_DEV **PciDevice
); );
/** /**
Free the resources used by PciDevice. Free the resources used by PciDevice.

View File

@ -12,7 +12,6 @@
#include <Library/PciCapLib.h> #include <Library/PciCapLib.h>
/** /**
Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function
quadruplet. The config space accessors are based upon PciSegmentLib. quadruplet. The config space accessors are based upon PciSegmentLib.
@ -60,7 +59,6 @@ PciCapPciSegmentDeviceInit (
OUT PCI_CAP_DEV **PciDevice OUT PCI_CAP_DEV **PciDevice
); );
/** /**
Free the resources used by PciDevice. Free the resources used by PciDevice.

View File

@ -13,10 +13,8 @@
#ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__ #ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__
#define __PCI_HOST_BRIDGE_UTILITY_LIB_H__ #define __PCI_HOST_BRIDGE_UTILITY_LIB_H__
#include <Library/PciHostBridgeLib.h> #include <Library/PciHostBridgeLib.h>
/** /**
Utility function to initialize a PCI_ROOT_BRIDGE structure. Utility function to initialize a PCI_ROOT_BRIDGE structure.
@ -82,7 +80,6 @@ PciHostBridgeUtilityInitRootBridge (
OUT PCI_ROOT_BRIDGE *RootBus OUT PCI_ROOT_BRIDGE *RootBus
); );
/** /**
Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with
PciHostBridgeUtilityInitRootBridge(). PciHostBridgeUtilityInitRootBridge().
@ -98,7 +95,6 @@ PciHostBridgeUtilityUninitRootBridge (
IN PCI_ROOT_BRIDGE *RootBus IN PCI_ROOT_BRIDGE *RootBus
); );
/** /**
Utility function to return all the root bridge instances in an array. Utility function to return all the root bridge instances in an array.
@ -145,7 +141,6 @@ PciHostBridgeUtilityGetRootBridges (
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
); );
/** /**
Utility function to free root bridge instances array from Utility function to free root bridge instances array from
PciHostBridgeUtilityGetRootBridges(). PciHostBridgeUtilityGetRootBridges().
@ -160,7 +155,6 @@ PciHostBridgeUtilityFreeRootBridges (
IN UINTN Count IN UINTN Count
); );
/** /**
Utility function to inform the platform that the resource conflict happens. Utility function to inform the platform that the resource conflict happens.
@ -181,5 +175,4 @@ PciHostBridgeUtilityResourceConflict (
IN VOID *Configuration IN VOID *Configuration
); );
#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__ #endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__

Some files were not shown because too many files have changed in this diff Show More