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:
committed by
mergify[bot]
parent
d1050b9dff
commit
ac0a286f4d
@ -47,6 +47,7 @@ volatile UINT64 mTimerPeriod = 0;
|
||||
//
|
||||
// Worker Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Sets the counter value for Timer #0 in a legacy 8254 timer.
|
||||
|
||||
@ -133,11 +134,11 @@ TimerDriverRegisterHandler (
|
||||
//
|
||||
// Check for invalid parameters
|
||||
//
|
||||
if (NotifyFunction == NULL && mTimerNotifyFunction == NULL) {
|
||||
if ((NotifyFunction == NULL) && (mTimerNotifyFunction == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (NotifyFunction != NULL && mTimerNotifyFunction != NULL) {
|
||||
if ((NotifyFunction != NULL) && (mTimerNotifyFunction != NULL)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
@ -203,7 +204,6 @@ TimerDriverSetTimerPeriod (
|
||||
//
|
||||
mLegacy8259->DisableIrq (mLegacy8259, Efi8259Irq0);
|
||||
} else {
|
||||
|
||||
//
|
||||
// Convert TimerPeriod into 8254 counts
|
||||
//
|
||||
@ -216,6 +216,7 @@ TimerDriverSetTimerPeriod (
|
||||
TimerCount = 0;
|
||||
TimerPeriod = MAX_TIMER_TICK_DURATION;
|
||||
}
|
||||
|
||||
//
|
||||
// Program the 8254 timer with the new count value
|
||||
//
|
||||
@ -226,6 +227,7 @@ TimerDriverSetTimerPeriod (
|
||||
//
|
||||
mLegacy8259->EnableIrq (mLegacy8259, Efi8259Irq0, FALSE);
|
||||
}
|
||||
|
||||
//
|
||||
// Save the new timer period
|
||||
//
|
||||
@ -392,11 +394,11 @@ TimerDriverInitialize (
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&mTimerHandle,
|
||||
&gEfiTimerArchProtocolGuid, &mTimer,
|
||||
&gEfiTimerArchProtocolGuid,
|
||||
&mTimer,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
|
||||
/**
|
||||
Initialize the Timer Architectural Protocol driver
|
||||
|
||||
|
@ -69,4 +69,3 @@ TransferS3ContextToBootScript (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "AcpiPlatform.h"
|
||||
|
||||
|
||||
//
|
||||
// Condensed structure for capturing the fw_cfg operations -- select, skip,
|
||||
// write -- inherent in executing a QEMU_LOADER_WRITE_POINTER command.
|
||||
@ -27,7 +26,6 @@ typedef struct {
|
||||
// and QEMU_LOADER_WRITE_POINTER.PointeeOffset
|
||||
} CONDENSED_WRITE_POINTER;
|
||||
|
||||
|
||||
//
|
||||
// Context structure to accumulate CONDENSED_WRITE_POINTER objects from
|
||||
// QEMU_LOADER_WRITE_POINTER commands.
|
||||
@ -45,7 +43,6 @@ struct S3_CONTEXT {
|
||||
// WritePointers
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Scratch buffer, allocated in EfiReservedMemoryType type memory, for the ACPI
|
||||
// S3 Boot Script opcodes to work on.
|
||||
@ -56,7 +53,6 @@ typedef union {
|
||||
} SCRATCH_BUFFER;
|
||||
#pragma pack ()
|
||||
|
||||
|
||||
/**
|
||||
Allocate an S3_CONTEXT object.
|
||||
|
||||
@ -91,8 +87,10 @@ AllocateS3Context (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Context->WritePointers = AllocatePool (WritePointerCount *
|
||||
sizeof *Context->WritePointers);
|
||||
Context->WritePointers = AllocatePool (
|
||||
WritePointerCount *
|
||||
sizeof *Context->WritePointers
|
||||
);
|
||||
if (Context->WritePointers == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeContext;
|
||||
@ -108,7 +106,6 @@ FreeContext:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release an S3_CONTEXT object.
|
||||
|
||||
@ -123,7 +120,6 @@ ReleaseS3Context (
|
||||
FreePool (S3Context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Save the information necessary to replicate a QEMU_LOADER_WRITE_POINTER
|
||||
command during S3 resume, in condensed format.
|
||||
@ -170,19 +166,26 @@ SaveCondensedWritePointerToS3Context (
|
||||
if (S3Context->Used == S3Context->Allocated) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Condensed = S3Context->WritePointers + S3Context->Used;
|
||||
Condensed->PointerItem = PointerItem;
|
||||
Condensed->PointerSize = PointerSize;
|
||||
Condensed->PointerOffset = PointerOffset;
|
||||
Condensed->PointerValue = PointerValue;
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: 0x%04x/[0x%08x+%d] := 0x%Lx (%Lu)\n",
|
||||
__FUNCTION__, PointerItem, PointerOffset, PointerSize, PointerValue,
|
||||
(UINT64)S3Context->Used));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: 0x%04x/[0x%08x+%d] := 0x%Lx (%Lu)\n",
|
||||
__FUNCTION__,
|
||||
PointerItem,
|
||||
PointerOffset,
|
||||
PointerSize,
|
||||
PointerValue,
|
||||
(UINT64)S3Context->Used
|
||||
));
|
||||
++S3Context->Used;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION provided to QemuFwCfgS3Lib.
|
||||
**/
|
||||
@ -207,8 +210,10 @@ AppendFwCfgBootScript (
|
||||
|
||||
Condensed = &S3Context->WritePointers[Index];
|
||||
|
||||
Status = QemuFwCfgS3ScriptSkipBytes (Condensed->PointerItem,
|
||||
Condensed->PointerOffset);
|
||||
Status = QemuFwCfgS3ScriptSkipBytes (
|
||||
Condensed->PointerItem,
|
||||
Condensed->PointerOffset
|
||||
);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
goto FatalError;
|
||||
}
|
||||
@ -230,7 +235,6 @@ FatalError:
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Translate and append the information from an S3_CONTEXT object to the ACPI S3
|
||||
Boot Script.
|
||||
@ -263,7 +267,10 @@ TransferS3ContextToBootScript (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Status = QemuFwCfgS3CallWhenBootScriptReady (AppendFwCfgBootScript,
|
||||
S3Context, sizeof (SCRATCH_BUFFER));
|
||||
Status = QemuFwCfgS3CallWhenBootScriptReady (
|
||||
AppendFwCfgBootScript,
|
||||
S3Context,
|
||||
sizeof (SCRATCH_BUFFER)
|
||||
);
|
||||
return (EFI_STATUS)Status;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ FindAcpiTableProtocol (
|
||||
return AcpiTable;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
@ -44,17 +43,19 @@ OnRootBridgesConnected (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: root bridges have been connected, installing ACPI tables\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
Status = InstallAcpiTables (FindAcpiTableProtocol ());
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
|
||||
}
|
||||
|
||||
gBS->CloseEvent (Event);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AcpiPlatformEntryPoint (
|
||||
@ -71,8 +72,12 @@ AcpiPlatformEntryPoint (
|
||||
// the full functionality.
|
||||
//
|
||||
if (PcdGetBool (PcdPciDisableBusEnumeration)) {
|
||||
DEBUG ((DEBUG_INFO, "%a: PCI or its enumeration disabled, installing "
|
||||
"ACPI tables\n", __FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: PCI or its enumeration disabled, installing "
|
||||
"ACPI tables\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return InstallAcpiTables (FindAcpiTableProtocol ());
|
||||
}
|
||||
|
||||
@ -82,13 +87,20 @@ AcpiPlatformEntryPoint (
|
||||
// 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.)
|
||||
//
|
||||
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
|
||||
OnRootBridgesConnected, NULL /* Context */,
|
||||
&gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected);
|
||||
Status = gBS->CreateEventEx (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
OnRootBridgesConnected,
|
||||
NULL /* Context */,
|
||||
&gRootBridgesConnectedEventGroupGuid,
|
||||
&RootBridgesConnected
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: waiting for root bridges to be connected, registered callback\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "AcpiPlatform.h"
|
||||
|
||||
|
||||
/**
|
||||
Collect all PciIo protocol instances in the system. Save their original
|
||||
attributes, and enable IO and MMIO decoding for each.
|
||||
@ -61,8 +60,13 @@ EnablePciDecoding (
|
||||
return;
|
||||
}
|
||||
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid,
|
||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
NULL /* SearchKey */,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
//
|
||||
// No PCI devices were found on either of the root bridges. We're done.
|
||||
@ -71,15 +75,22 @@ EnablePciDecoding (
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: LocateHandleBuffer(): %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);
|
||||
if (OrigAttrs == NULL) {
|
||||
DEBUG ((DEBUG_WARN, "%a: AllocatePool(): out of resources\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: AllocatePool(): out of resources\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeHandles;
|
||||
}
|
||||
|
||||
@ -90,30 +101,49 @@ EnablePciDecoding (
|
||||
//
|
||||
// Look up PciIo on the handle and stash it
|
||||
//
|
||||
Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid,
|
||||
(VOID**)&PciIo);
|
||||
Status = gBS->HandleProtocol (
|
||||
Handles[Idx],
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
OrigAttrs[Idx].PciIo = PciIo;
|
||||
|
||||
//
|
||||
// Stash the current attributes
|
||||
//
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0,
|
||||
&OrigAttrs[Idx].PciAttributes);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationGet,
|
||||
0,
|
||||
&OrigAttrs[Idx].PciAttributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationGet: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve supported attributes
|
||||
//
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0,
|
||||
&Attributes);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSupported,
|
||||
0,
|
||||
&Attributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationSupported: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
|
||||
@ -121,11 +151,19 @@ EnablePciDecoding (
|
||||
// Enable IO and MMIO decoding
|
||||
//
|
||||
Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable,
|
||||
Attributes, NULL);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationEnable,
|
||||
Attributes,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationEnable: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
}
|
||||
@ -141,19 +179,20 @@ EnablePciDecoding (
|
||||
RestoreAttributes:
|
||||
while (Idx > 0) {
|
||||
--Idx;
|
||||
OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo,
|
||||
OrigAttrs[Idx].PciIo->Attributes (
|
||||
OrigAttrs[Idx].PciIo,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
OrigAttrs[Idx].PciAttributes,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (OrigAttrs);
|
||||
|
||||
FreeHandles:
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Restore the original PCI attributes saved with EnablePciDecoding().
|
||||
|
||||
@ -190,5 +229,6 @@ RestorePciDecoding (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (OriginalAttributes);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ typedef struct {
|
||||
// part of ACPI tables.
|
||||
} BLOB;
|
||||
|
||||
|
||||
/**
|
||||
Compare a standalone key against a user structure containing an embedded key.
|
||||
|
||||
@ -65,7 +64,6 @@ BlobKeyCompare (
|
||||
return AsciiStrCmp (StandaloneKey, (CONST CHAR8 *)Blob->File);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Comparator function for two user structures.
|
||||
|
||||
@ -93,7 +91,6 @@ BlobCompare (
|
||||
return BlobKeyCompare (Blob1->File, UserStruct2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Comparator function for two opaque pointers, ordering on (unsigned) pointer
|
||||
value itself.
|
||||
@ -120,13 +117,14 @@ PointerCompare (
|
||||
if (Pointer1 == Pointer2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((UINTN)Pointer1 < (UINTN)Pointer2) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Comparator function for two ASCII strings. Can be used as both Key and
|
||||
UserStruct comparator.
|
||||
@ -151,7 +149,6 @@ AsciiStringCompare (
|
||||
return AsciiStrCmp (AsciiString1, AsciiString2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release the ORDERED_COLLECTION structure populated by
|
||||
CollectAllocationsRestrictedTo32Bit() (below).
|
||||
@ -172,14 +169,15 @@ ReleaseAllocationsRestrictedTo32Bit (
|
||||
|
||||
for (Entry = OrderedCollectionMin (AllocationsRestrictedTo32Bit);
|
||||
Entry != NULL;
|
||||
Entry = Entry2) {
|
||||
Entry = Entry2)
|
||||
{
|
||||
Entry2 = OrderedCollectionNext (Entry);
|
||||
OrderedCollectionDelete (AllocationsRestrictedTo32Bit, Entry, NULL);
|
||||
}
|
||||
|
||||
OrderedCollectionUninit (AllocationsRestrictedTo32Bit);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -230,6 +228,7 @@ CollectAllocationsRestrictedTo32Bit (
|
||||
if (LoaderEntry->Type != QemuLoaderCmdAddPointer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AddPointer = &LoaderEntry->Command.AddPointer;
|
||||
|
||||
if (AddPointer->PointerSize >= 8) {
|
||||
@ -276,7 +275,6 @@ RollBack:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process a QEMU_LOADER_ALLOCATE command.
|
||||
|
||||
@ -335,15 +333,24 @@ ProcessCmdAllocate (
|
||||
}
|
||||
|
||||
if (Allocate->Alignment > EFI_PAGE_SIZE) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: unsupported alignment 0x%x\n", __FUNCTION__,
|
||||
Allocate->Alignment));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: unsupported alignment 0x%x\n",
|
||||
__FUNCTION__,
|
||||
Allocate->Alignment
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Status = QemuFwCfgFindFile ((CHAR8 *)Allocate->File, &FwCfgItem, &FwCfgSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: QemuFwCfgFindFile(\"%a\"): %r\n", __FUNCTION__,
|
||||
Allocate->File, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: QemuFwCfgFindFile(\"%a\"): %r\n",
|
||||
__FUNCTION__,
|
||||
Allocate->File,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -352,11 +359,17 @@ ProcessCmdAllocate (
|
||||
if (OrderedCollectionFind (
|
||||
AllocationsRestrictedTo32Bit,
|
||||
Allocate->File
|
||||
) != NULL) {
|
||||
) != NULL)
|
||||
{
|
||||
Address = MAX_UINT32;
|
||||
}
|
||||
Status = gBS->AllocatePages (AllocateMaxAddress, EfiACPIMemoryNVS, NumPages,
|
||||
&Address);
|
||||
|
||||
Status = gBS->AllocatePages (
|
||||
AllocateMaxAddress,
|
||||
EfiACPIMemoryNVS,
|
||||
NumPages,
|
||||
&Address
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -366,6 +379,7 @@ ProcessCmdAllocate (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreePages;
|
||||
}
|
||||
|
||||
CopyMem (Blob->File, Allocate->File, QEMU_LOADER_FNAME_SIZE);
|
||||
Blob->Size = FwCfgSize;
|
||||
Blob->Base = (VOID *)(UINTN)Address;
|
||||
@ -373,10 +387,15 @@ ProcessCmdAllocate (
|
||||
|
||||
Status = OrderedCollectionInsert (Tracker, NULL, Blob);
|
||||
if (Status == RETURN_ALREADY_STARTED) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: duplicated file \"%a\"\n", __FUNCTION__,
|
||||
Allocate->File));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: duplicated file \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
Allocate->File
|
||||
));
|
||||
Status = EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeBlob;
|
||||
}
|
||||
@ -385,9 +404,17 @@ ProcessCmdAllocate (
|
||||
QemuFwCfgReadBytes (FwCfgSize, Blob->Base);
|
||||
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 "
|
||||
"Address=0x%Lx\n", __FUNCTION__, Allocate->File, Allocate->Alignment,
|
||||
Allocate->Zone, (UINT64)Blob->Size, (UINT64)(UINTN)Blob->Base));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%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;
|
||||
|
||||
FreeBlob:
|
||||
@ -399,7 +426,6 @@ FreePages:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process a QEMU_LOADER_ADD_POINTER command.
|
||||
|
||||
@ -431,28 +457,39 @@ ProcessCmdAddPointer (
|
||||
UINT8 *PointerField;
|
||||
UINT64 PointerValue;
|
||||
|
||||
if (AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' ||
|
||||
AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {
|
||||
if ((AddPointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') ||
|
||||
(AddPointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0'))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
TrackerEntry = OrderedCollectionFind (Tracker, AddPointer->PointerFile);
|
||||
TrackerEntry2 = OrderedCollectionFind (Tracker, AddPointer->PointeeFile);
|
||||
if (TrackerEntry == NULL || TrackerEntry2 == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid blob reference(s) \"%a\" / \"%a\"\n",
|
||||
__FUNCTION__, AddPointer->PointerFile, AddPointer->PointeeFile));
|
||||
if ((TrackerEntry == NULL) || (TrackerEntry2 == NULL)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid blob reference(s) \"%a\" / \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointerFile,
|
||||
AddPointer->PointeeFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
Blob = OrderedCollectionUserStruct (TrackerEntry);
|
||||
Blob2 = OrderedCollectionUserStruct (TrackerEntry2);
|
||||
if ((AddPointer->PointerSize != 1 && AddPointer->PointerSize != 2 &&
|
||||
AddPointer->PointerSize != 4 && AddPointer->PointerSize != 8) ||
|
||||
Blob->Size < AddPointer->PointerSize ||
|
||||
Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n",
|
||||
__FUNCTION__, AddPointer->PointerFile));
|
||||
if (((AddPointer->PointerSize != 1) && (AddPointer->PointerSize != 2) &&
|
||||
(AddPointer->PointerSize != 4) && (AddPointer->PointerSize != 8)) ||
|
||||
(Blob->Size < AddPointer->PointerSize) ||
|
||||
(Blob->Size - AddPointer->PointerSize < AddPointer->PointerOffset))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid pointer location or size in \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointerFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -460,8 +497,12 @@ ProcessCmdAddPointer (
|
||||
PointerValue = 0;
|
||||
CopyMem (&PointerValue, PointerField, AddPointer->PointerSize);
|
||||
if (PointerValue >= Blob2->Size) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid pointer value in \"%a\"\n", __FUNCTION__,
|
||||
AddPointer->PointerFile));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid pointer value in \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointerFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -472,23 +513,34 @@ ProcessCmdAddPointer (
|
||||
ASSERT ((UINTN)Blob2->Base <= MAX_ADDRESS - Blob2->Size);
|
||||
|
||||
PointerValue += (UINT64)(UINTN)Blob2->Base;
|
||||
if (AddPointer->PointerSize < 8 &&
|
||||
RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: relocated pointer value unrepresentable in "
|
||||
"\"%a\"\n", __FUNCTION__, AddPointer->PointerFile));
|
||||
if ((AddPointer->PointerSize < 8) &&
|
||||
(RShiftU64 (PointerValue, AddPointer->PointerSize * 8) != 0))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: relocated pointer value unrepresentable in "
|
||||
"\"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointerFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
CopyMem (PointerField, &PointerValue, AddPointer->PointerSize);
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
|
||||
"PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__,
|
||||
AddPointer->PointerFile, AddPointer->PointeeFile,
|
||||
AddPointer->PointerOffset, AddPointer->PointerSize));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
|
||||
"PointerOffset=0x%x PointerSize=%d\n",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointerFile,
|
||||
AddPointer->PointeeFile,
|
||||
AddPointer->PointerOffset,
|
||||
AddPointer->PointerSize
|
||||
));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process a QEMU_LOADER_ADD_CHECKSUM command.
|
||||
|
||||
@ -522,17 +574,26 @@ ProcessCmdAddChecksum (
|
||||
|
||||
TrackerEntry = OrderedCollectionFind (Tracker, AddChecksum->File);
|
||||
if (TrackerEntry == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid blob reference \"%a\"\n", __FUNCTION__,
|
||||
AddChecksum->File));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid blob reference \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddChecksum->File
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
Blob = OrderedCollectionUserStruct (TrackerEntry);
|
||||
if (Blob->Size <= AddChecksum->ResultOffset ||
|
||||
Blob->Size < AddChecksum->Length ||
|
||||
Blob->Size - AddChecksum->Length < AddChecksum->Start) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid checksum range in \"%a\"\n",
|
||||
__FUNCTION__, AddChecksum->File));
|
||||
if ((Blob->Size <= AddChecksum->ResultOffset) ||
|
||||
(Blob->Size < AddChecksum->Length) ||
|
||||
(Blob->Size - AddChecksum->Length < AddChecksum->Start))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid checksum range in \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
AddChecksum->File
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -540,13 +601,19 @@ ProcessCmdAddChecksum (
|
||||
Blob->Base + AddChecksum->Start,
|
||||
AddChecksum->Length
|
||||
);
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: File=\"%a\" ResultOffset=0x%x Start=0x%x "
|
||||
"Length=0x%x\n", __FUNCTION__, AddChecksum->File,
|
||||
AddChecksum->ResultOffset, AddChecksum->Start, AddChecksum->Length));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Process a QEMU_LOADER_WRITE_POINTER command.
|
||||
|
||||
@ -593,29 +660,42 @@ ProcessCmdWritePointer (
|
||||
BLOB *PointeeBlob;
|
||||
UINT64 PointerValue;
|
||||
|
||||
if (WritePointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0' ||
|
||||
WritePointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') {
|
||||
if ((WritePointer->PointerFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0') ||
|
||||
(WritePointer->PointeeFile[QEMU_LOADER_FNAME_SIZE - 1] != '\0'))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: malformed file name\n", __FUNCTION__));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile,
|
||||
&PointerItem, &PointerItemSize);
|
||||
Status = QemuFwCfgFindFile (
|
||||
(CONST CHAR8 *)WritePointer->PointerFile,
|
||||
&PointerItem,
|
||||
&PointerItemSize
|
||||
);
|
||||
PointeeEntry = OrderedCollectionFind (Tracker, WritePointer->PointeeFile);
|
||||
if (RETURN_ERROR (Status) || PointeeEntry == NULL) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
if (RETURN_ERROR (Status) || (PointeeEntry == NULL)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%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;
|
||||
}
|
||||
|
||||
if ((WritePointer->PointerSize != 1 && WritePointer->PointerSize != 2 &&
|
||||
WritePointer->PointerSize != 4 && WritePointer->PointerSize != 8) ||
|
||||
if (((WritePointer->PointerSize != 1) && (WritePointer->PointerSize != 2) &&
|
||||
(WritePointer->PointerSize != 4) && (WritePointer->PointerSize != 8)) ||
|
||||
(PointerItemSize < WritePointer->PointerSize) ||
|
||||
(PointerItemSize - WritePointer->PointerSize <
|
||||
WritePointer->PointerOffset)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid pointer location or size in \"%a\"\n",
|
||||
__FUNCTION__, WritePointer->PointerFile));
|
||||
WritePointer->PointerOffset))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid pointer location or size in \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
WritePointer->PointerFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -633,10 +713,15 @@ ProcessCmdWritePointer (
|
||||
ASSERT ((UINTN)PointeeBlob->Base <= MAX_ADDRESS - PointeeBlob->Size);
|
||||
|
||||
PointerValue += (UINT64)(UINTN)PointeeBlob->Base;
|
||||
if (WritePointer->PointerSize < 8 &&
|
||||
RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: pointer value unrepresentable in \"%a\"\n",
|
||||
__FUNCTION__, WritePointer->PointerFile));
|
||||
if ((WritePointer->PointerSize < 8) &&
|
||||
(RShiftU64 (PointerValue, WritePointer->PointerSize * 8) != 0))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: pointer value unrepresentable in \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
WritePointer->PointerFile
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -670,15 +755,20 @@ ProcessCmdWritePointer (
|
||||
//
|
||||
PointeeBlob->HostsOnlyTableData = FALSE;
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
|
||||
"PointerOffset=0x%x PointeeOffset=0x%x PointerSize=%d\n", __FUNCTION__,
|
||||
WritePointer->PointerFile, WritePointer->PointeeFile,
|
||||
WritePointer->PointerOffset, WritePointer->PointeeOffset,
|
||||
WritePointer->PointerSize));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: PointerFile=\"%a\" PointeeFile=\"%a\" "
|
||||
"PointerOffset=0x%x PointeeOffset=0x%x PointerSize=%d\n",
|
||||
__FUNCTION__,
|
||||
WritePointer->PointerFile,
|
||||
WritePointer->PointeeFile,
|
||||
WritePointer->PointerOffset,
|
||||
WritePointer->PointeeOffset,
|
||||
WritePointer->PointerSize
|
||||
));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Undo a QEMU_LOADER_WRITE_POINTER command.
|
||||
|
||||
@ -700,8 +790,11 @@ UndoCmdWritePointer (
|
||||
UINTN PointerItemSize;
|
||||
UINT64 PointerValue;
|
||||
|
||||
Status = QemuFwCfgFindFile ((CONST CHAR8 *)WritePointer->PointerFile,
|
||||
&PointerItem, &PointerItemSize);
|
||||
Status = QemuFwCfgFindFile (
|
||||
(CONST CHAR8 *)WritePointer->PointerFile,
|
||||
&PointerItem,
|
||||
&PointerItemSize
|
||||
);
|
||||
ASSERT_RETURN_ERROR (Status);
|
||||
|
||||
PointerValue = 0;
|
||||
@ -709,13 +802,16 @@ UndoCmdWritePointer (
|
||||
QemuFwCfgSkipBytes (WritePointer->PointerOffset);
|
||||
QemuFwCfgWriteBytes (WritePointer->PointerSize, &PointerValue);
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE,
|
||||
"%a: PointerFile=\"%a\" PointerOffset=0x%x PointerSize=%d\n", __FUNCTION__,
|
||||
WritePointer->PointerFile, WritePointer->PointerOffset,
|
||||
WritePointer->PointerSize));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: PointerFile=\"%a\" PointerOffset=0x%x PointerSize=%d\n",
|
||||
__FUNCTION__,
|
||||
WritePointer->PointerFile,
|
||||
WritePointer->PointerOffset,
|
||||
WritePointer->PointerSize
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 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).
|
||||
@ -806,7 +902,7 @@ Process2ndPassCmdAddPointer (
|
||||
CONST EFI_ACPI_DESCRIPTION_HEADER *Header;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (*NumInstalled < 0 || *NumInstalled > INSTALLED_TABLES_MAX) {
|
||||
if ((*NumInstalled < 0) || (*NumInstalled > INSTALLED_TABLES_MAX)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -845,13 +941,20 @@ Process2ndPassCmdAddPointer (
|
||||
));
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
Blob2Remaining -= (UINTN)PointerValue;
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: checking for ACPI header in \"%a\" at 0x%Lx "
|
||||
"(remaining: 0x%Lx): ", __FUNCTION__, AddPointer->PointeeFile,
|
||||
PointerValue, (UINT64)Blob2Remaining));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: checking for ACPI header in \"%a\" at 0x%Lx "
|
||||
"(remaining: 0x%Lx): ",
|
||||
__FUNCTION__,
|
||||
AddPointer->PointeeFile,
|
||||
PointerValue,
|
||||
(UINT64)Blob2Remaining
|
||||
));
|
||||
|
||||
TableSize = 0;
|
||||
|
||||
@ -861,12 +964,17 @@ Process2ndPassCmdAddPointer (
|
||||
if (sizeof *Facs <= Blob2Remaining) {
|
||||
Facs = (EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)PointerValue;
|
||||
|
||||
if (Facs->Length >= sizeof *Facs &&
|
||||
Facs->Length <= Blob2Remaining &&
|
||||
Facs->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));
|
||||
if ((Facs->Length >= sizeof *Facs) &&
|
||||
(Facs->Length <= Blob2Remaining) &&
|
||||
(Facs->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
|
||||
));
|
||||
TableSize = Facs->Length;
|
||||
}
|
||||
}
|
||||
@ -874,28 +982,34 @@ Process2ndPassCmdAddPointer (
|
||||
//
|
||||
// check for the uniform tables
|
||||
//
|
||||
if (TableSize == 0 && sizeof *Header <= Blob2Remaining) {
|
||||
if ((TableSize == 0) && (sizeof *Header <= Blob2Remaining)) {
|
||||
Header = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)PointerValue;
|
||||
|
||||
if (Header->Length >= sizeof *Header &&
|
||||
Header->Length <= Blob2Remaining &&
|
||||
CalculateSum8 ((CONST UINT8 *)Header, Header->Length) == 0) {
|
||||
if ((Header->Length >= sizeof *Header) &&
|
||||
(Header->Length <= Blob2Remaining) &&
|
||||
(CalculateSum8 ((CONST UINT8 *)Header, Header->Length) == 0))
|
||||
{
|
||||
//
|
||||
// This looks very much like an ACPI table from QEMU:
|
||||
// - Length field consistent with both ACPI and containing blob size
|
||||
// - checksum is correct
|
||||
//
|
||||
DEBUG ((DEBUG_VERBOSE, "found \"%-4.4a\" size 0x%x\n",
|
||||
(CONST CHAR8 *)&Header->Signature, Header->Length));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"found \"%-4.4a\" size 0x%x\n",
|
||||
(CONST CHAR8 *)&Header->Signature,
|
||||
Header->Length
|
||||
));
|
||||
TableSize = Header->Length;
|
||||
|
||||
//
|
||||
// Skip RSDT and XSDT because those are handled by
|
||||
// EFI_ACPI_TABLE_PROTOCOL automatically.
|
||||
if (Header->Signature ==
|
||||
EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE ||
|
||||
Header->Signature ==
|
||||
EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
|
||||
if ((Header->Signature ==
|
||||
EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) ||
|
||||
(Header->Signature ==
|
||||
EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -908,20 +1022,32 @@ Process2ndPassCmdAddPointer (
|
||||
}
|
||||
|
||||
if (*NumInstalled == INSTALLED_TABLES_MAX) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: can't install more than %d tables\n",
|
||||
__FUNCTION__, INSTALLED_TABLES_MAX));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: can't install more than %d tables\n",
|
||||
__FUNCTION__,
|
||||
INSTALLED_TABLES_MAX
|
||||
));
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto RollbackSeenPointer;
|
||||
}
|
||||
|
||||
Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol,
|
||||
(VOID *)(UINTN)PointerValue, TableSize,
|
||||
&InstalledKey[*NumInstalled]);
|
||||
Status = AcpiProtocol->InstallAcpiTable (
|
||||
AcpiProtocol,
|
||||
(VOID *)(UINTN)PointerValue,
|
||||
TableSize,
|
||||
&InstalledKey[*NumInstalled]
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTable(): %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: InstallAcpiTable(): %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RollbackSeenPointer;
|
||||
}
|
||||
|
||||
++*NumInstalled;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@ -930,7 +1056,6 @@ RollbackSeenPointer:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Download, process, and install ACPI table data from the QEMU loader
|
||||
interface.
|
||||
@ -980,9 +1105,14 @@ InstallQemuFwCfgTables (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (FwCfgSize % sizeof *LoaderEntry != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: \"etc/table-loader\" has invalid size 0x%Lx\n",
|
||||
__FUNCTION__, (UINT64)FwCfgSize));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: \"etc/table-loader\" has invalid size 0x%Lx\n",
|
||||
__FUNCTION__,
|
||||
(UINT64)FwCfgSize
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -990,6 +1120,7 @@ InstallQemuFwCfgTables (
|
||||
if (LoaderStart == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
EnablePciDecoding (&OriginalPciAttributes, &OriginalPciAttributesCount);
|
||||
QemuFwCfgSelectItem (FwCfgItem);
|
||||
QemuFwCfgReadBytes (FwCfgSize, LoaderStart);
|
||||
@ -1043,26 +1174,38 @@ InstallQemuFwCfgTables (
|
||||
break;
|
||||
|
||||
case QemuLoaderCmdAddPointer:
|
||||
Status = ProcessCmdAddPointer (&LoaderEntry->Command.AddPointer,
|
||||
Tracker);
|
||||
Status = ProcessCmdAddPointer (
|
||||
&LoaderEntry->Command.AddPointer,
|
||||
Tracker
|
||||
);
|
||||
break;
|
||||
|
||||
case QemuLoaderCmdAddChecksum:
|
||||
Status = ProcessCmdAddChecksum (&LoaderEntry->Command.AddChecksum,
|
||||
Tracker);
|
||||
Status = ProcessCmdAddChecksum (
|
||||
&LoaderEntry->Command.AddChecksum,
|
||||
Tracker
|
||||
);
|
||||
break;
|
||||
|
||||
case QemuLoaderCmdWritePointer:
|
||||
Status = ProcessCmdWritePointer (&LoaderEntry->Command.WritePointer,
|
||||
Tracker, S3Context);
|
||||
Status = ProcessCmdWritePointer (
|
||||
&LoaderEntry->Command.WritePointer,
|
||||
Tracker,
|
||||
S3Context
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
WritePointerSubsetEnd = LoaderEntry + 1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: unknown loader command: 0x%x\n",
|
||||
__FUNCTION__, LoaderEntry->Type));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: unknown loader command: 0x%x\n",
|
||||
__FUNCTION__,
|
||||
LoaderEntry->Type
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1113,6 +1256,7 @@ InstallQemuFwCfgTables (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto UninstallAcpiTables;
|
||||
}
|
||||
|
||||
//
|
||||
// Ownership of S3Context has been transferred.
|
||||
//
|
||||
@ -1134,10 +1278,12 @@ UninstallAcpiTables:
|
||||
|
||||
for (SeenPointerEntry = OrderedCollectionMin (SeenPointers);
|
||||
SeenPointerEntry != NULL;
|
||||
SeenPointerEntry = SeenPointerEntry2) {
|
||||
SeenPointerEntry = SeenPointerEntry2)
|
||||
{
|
||||
SeenPointerEntry2 = OrderedCollectionNext (SeenPointerEntry);
|
||||
OrderedCollectionDelete (SeenPointers, SeenPointerEntry, NULL);
|
||||
}
|
||||
|
||||
OrderedCollectionUninit (SeenPointers);
|
||||
|
||||
FreeKeys:
|
||||
@ -1164,7 +1310,8 @@ RollbackWritePointersAndFreeTracker:
|
||||
// not directly part of some ACPI table.
|
||||
//
|
||||
for (TrackerEntry = OrderedCollectionMin (Tracker); TrackerEntry != NULL;
|
||||
TrackerEntry = TrackerEntry2) {
|
||||
TrackerEntry = TrackerEntry2)
|
||||
{
|
||||
VOID *UserStruct;
|
||||
BLOB *Blob;
|
||||
|
||||
@ -1173,12 +1320,18 @@ RollbackWritePointersAndFreeTracker:
|
||||
Blob = UserStruct;
|
||||
|
||||
if (EFI_ERROR (Status) || Blob->HostsOnlyTableData) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: freeing \"%a\"\n", __FUNCTION__,
|
||||
Blob->File));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: freeing \"%a\"\n",
|
||||
__FUNCTION__,
|
||||
Blob->File
|
||||
));
|
||||
gBS->FreePages ((UINTN)Blob->Base, EFI_SIZE_TO_PAGES (Blob->Size));
|
||||
}
|
||||
|
||||
FreePool (Blob);
|
||||
}
|
||||
|
||||
OrderedCollectionUninit (Tracker);
|
||||
|
||||
FreeS3Context:
|
||||
|
@ -97,17 +97,23 @@ VerifyBlob (
|
||||
INT32 Remaining;
|
||||
HASH_TABLE *Entry;
|
||||
|
||||
if (mHashesTable == NULL || mHashesTableSize == 0) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
if ((mHashesTable == NULL) || (mHashesTableSize == 0)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Verifier called but no hashes table discoverd in MEMFD\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
Guid = FindBlobEntryGuid (BlobName);
|
||||
if (Guid == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Unknown blob name \"%s\"\n", __FUNCTION__,
|
||||
BlobName));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Unknown blob name \"%s\"\n",
|
||||
__FUNCTION__,
|
||||
BlobName
|
||||
));
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -118,7 +124,8 @@ VerifyBlob (
|
||||
for (Entry = mHashesTable, Remaining = mHashesTableSize;
|
||||
Remaining >= sizeof *Entry && Remaining >= Entry->Len;
|
||||
Remaining -= Entry->Len,
|
||||
Entry = (HASH_TABLE *)((UINT8 *)Entry + Entry->Len)) {
|
||||
Entry = (HASH_TABLE *)((UINT8 *)Entry + Entry->Len))
|
||||
{
|
||||
UINTN EntrySize;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Hash[SHA256_DIGEST_SIZE];
|
||||
@ -131,8 +138,13 @@ VerifyBlob (
|
||||
|
||||
EntrySize = Entry->Len - sizeof Entry->Guid - sizeof Entry->Len;
|
||||
if (EntrySize != SHA256_DIGEST_SIZE) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Hash has the wrong size %d != %d\n",
|
||||
__FUNCTION__, EntrySize, SHA256_DIGEST_SIZE));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Hash has the wrong size %d != %d\n",
|
||||
__FUNCTION__,
|
||||
EntrySize,
|
||||
SHA256_DIGEST_SIZE
|
||||
));
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -144,18 +156,31 @@ VerifyBlob (
|
||||
|
||||
if (CompareMem (Entry->Data, Hash, EntrySize) == 0) {
|
||||
Status = EFI_SUCCESS;
|
||||
DEBUG ((DEBUG_INFO, "%a: Hash comparison succeeded for \"%s\"\n",
|
||||
__FUNCTION__, BlobName));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Hash comparison succeeded for \"%s\"\n",
|
||||
__FUNCTION__,
|
||||
BlobName
|
||||
));
|
||||
} else {
|
||||
Status = EFI_ACCESS_DENIED;
|
||||
DEBUG ((DEBUG_ERROR, "%a: Hash comparison failed for \"%s\"\n",
|
||||
__FUNCTION__, BlobName));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Hash comparison failed for \"%s\"\n",
|
||||
__FUNCTION__,
|
||||
BlobName
|
||||
));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_ERROR, "%a: Hash GUID %g not found in table\n", __FUNCTION__,
|
||||
Guid));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Hash GUID %g not found in table\n",
|
||||
__FUNCTION__,
|
||||
Guid
|
||||
));
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -183,20 +208,29 @@ BlobVerifierLibSevHashesConstructor (
|
||||
Ptr = (void *)(UINTN)FixedPcdGet64 (PcdQemuHashTableBase);
|
||||
Size = FixedPcdGet32 (PcdQemuHashTableSize);
|
||||
|
||||
if (Ptr == NULL || Size < sizeof *Ptr ||
|
||||
if ((Ptr == NULL) || (Size < sizeof *Ptr) ||
|
||||
!CompareGuid (&Ptr->Guid, &SEV_HASH_TABLE_GUID) ||
|
||||
Ptr->Len < sizeof *Ptr || Ptr->Len > Size) {
|
||||
(Ptr->Len < sizeof *Ptr) || (Ptr->Len > Size))
|
||||
{
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Found injected hashes table in secure location\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Found injected hashes table in secure location\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
|
||||
mHashesTable = (HASH_TABLE *)Ptr->Data;
|
||||
mHashesTableSize = Ptr->Len - sizeof Ptr->Guid - sizeof Ptr->Len;
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: mHashesTable=0x%p, Size=%u\n", __FUNCTION__,
|
||||
mHashesTable, mHashesTableSize));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: mHashesTable=0x%p, Size=%u\n",
|
||||
__FUNCTION__,
|
||||
mHashesTable,
|
||||
mHashesTableSize
|
||||
));
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
@ -51,8 +51,9 @@ AmdSevDxeEntryPoint (
|
||||
CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Desc;
|
||||
|
||||
Desc = &AllDescMap[Index];
|
||||
if (Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo ||
|
||||
Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
|
||||
if ((Desc->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) ||
|
||||
(Desc->GcdMemoryType == EfiGcdMemoryTypeNonExistent))
|
||||
{
|
||||
Status = MemEncryptSevClearMmioPageEncMask (
|
||||
0,
|
||||
Desc->BaseAddress,
|
||||
@ -123,8 +124,12 @@ AmdSevDxeEntryPoint (
|
||||
MapPagesCount // NumPages
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: MemEncryptSevClearPageEncMask(): %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: MemEncryptSevClearPageEncMask(): %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ InstallAcpiTable (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -124,7 +123,6 @@ LocateFvInstanceWithTables (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find ACPI tables in an FV and install them.
|
||||
|
||||
@ -171,13 +169,13 @@ InstallOvmfFvTables (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
ASSERT (FwVol != NULL);
|
||||
|
||||
//
|
||||
// Read tables from the storage file.
|
||||
//
|
||||
while (Status == EFI_SUCCESS) {
|
||||
|
||||
Status = FwVol->ReadSection (
|
||||
FwVol,
|
||||
(EFI_GUID *)PcdGetPtr (PcdAcpiTableStorageFile),
|
||||
@ -249,4 +247,3 @@ InstallAcpiTables (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ BhyveInstallAcpiMadtTable (
|
||||
LocalApic->Flags = 1; // enabled
|
||||
++LocalApic;
|
||||
}
|
||||
|
||||
Ptr = LocalApic;
|
||||
|
||||
IoApic = Ptr;
|
||||
|
@ -28,7 +28,6 @@ FindAcpiTableProtocol (
|
||||
return AcpiTable;
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
VOID
|
||||
EFIAPI
|
||||
@ -39,17 +38,19 @@ OnRootBridgesConnected (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: root bridges have been connected, installing ACPI tables\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
Status = InstallAcpiTables (FindAcpiTableProtocol ());
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: InstallAcpiTables: %r\n", __FUNCTION__, Status));
|
||||
}
|
||||
|
||||
gBS->CloseEvent (Event);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
AcpiPlatformEntryPoint (
|
||||
@ -66,8 +67,12 @@ AcpiPlatformEntryPoint (
|
||||
// the full functionality.
|
||||
//
|
||||
if (PcdGetBool (PcdPciDisableBusEnumeration)) {
|
||||
DEBUG ((DEBUG_INFO, "%a: PCI or its enumeration disabled, installing "
|
||||
"ACPI tables\n", __FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: PCI or its enumeration disabled, installing "
|
||||
"ACPI tables\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return InstallAcpiTables (FindAcpiTableProtocol ());
|
||||
}
|
||||
|
||||
@ -77,13 +82,20 @@ AcpiPlatformEntryPoint (
|
||||
// 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.)
|
||||
//
|
||||
Status = gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
|
||||
OnRootBridgesConnected, NULL /* Context */,
|
||||
&gRootBridgesConnectedEventGroupGuid, &RootBridgesConnected);
|
||||
Status = gBS->CreateEventEx (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
OnRootBridgesConnected,
|
||||
NULL /* Context */,
|
||||
&gRootBridgesConnectedEventGroupGuid,
|
||||
&RootBridgesConnected
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: waiting for root bridges to be connected, registered callback\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "AcpiPlatform.h"
|
||||
|
||||
|
||||
/**
|
||||
Collect all PciIo protocol instances in the system. Save their original
|
||||
attributes, and enable IO and MMIO decoding for each.
|
||||
@ -59,8 +58,13 @@ EnablePciDecoding (
|
||||
return;
|
||||
}
|
||||
|
||||
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid,
|
||||
NULL /* SearchKey */, &NoHandles, &Handles);
|
||||
Status = gBS->LocateHandleBuffer (
|
||||
ByProtocol,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
NULL /* SearchKey */,
|
||||
&NoHandles,
|
||||
&Handles
|
||||
);
|
||||
if (Status == EFI_NOT_FOUND) {
|
||||
//
|
||||
// No PCI devices were found on either of the root bridges. We're done.
|
||||
@ -69,15 +73,22 @@ EnablePciDecoding (
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: LocateHandleBuffer(): %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);
|
||||
if (OrigAttrs == NULL) {
|
||||
DEBUG ((DEBUG_WARN, "%a: AllocatePool(): out of resources\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: AllocatePool(): out of resources\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
goto FreeHandles;
|
||||
}
|
||||
|
||||
@ -88,30 +99,49 @@ EnablePciDecoding (
|
||||
//
|
||||
// Look up PciIo on the handle and stash it
|
||||
//
|
||||
Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid,
|
||||
(VOID**)&PciIo);
|
||||
Status = gBS->HandleProtocol (
|
||||
Handles[Idx],
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **)&PciIo
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
OrigAttrs[Idx].PciIo = PciIo;
|
||||
|
||||
//
|
||||
// Stash the current attributes
|
||||
//
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0,
|
||||
&OrigAttrs[Idx].PciAttributes);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationGet,
|
||||
0,
|
||||
&OrigAttrs[Idx].PciAttributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationGet: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve supported attributes
|
||||
//
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0,
|
||||
&Attributes);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationSupported,
|
||||
0,
|
||||
&Attributes
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationSupported: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
|
||||
@ -119,11 +149,19 @@ EnablePciDecoding (
|
||||
// Enable IO and MMIO decoding
|
||||
//
|
||||
Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;
|
||||
Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable,
|
||||
Attributes, NULL);
|
||||
Status = PciIo->Attributes (
|
||||
PciIo,
|
||||
EfiPciIoAttributeOperationEnable,
|
||||
Attributes,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: EfiPciIoAttributeOperationEnable: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto RestoreAttributes;
|
||||
}
|
||||
}
|
||||
@ -139,19 +177,20 @@ EnablePciDecoding (
|
||||
RestoreAttributes:
|
||||
while (Idx > 0) {
|
||||
--Idx;
|
||||
OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo,
|
||||
OrigAttrs[Idx].PciIo->Attributes (
|
||||
OrigAttrs[Idx].PciIo,
|
||||
EfiPciIoAttributeOperationSet,
|
||||
OrigAttrs[Idx].PciAttributes,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (OrigAttrs);
|
||||
|
||||
FreeHandles:
|
||||
FreePool (Handles);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Restore the original PCI attributes saved with EnablePciDecoding().
|
||||
|
||||
@ -188,5 +227,6 @@ RestorePciDecoding (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
FreePool (OriginalAttributes);
|
||||
}
|
||||
|
@ -55,13 +55,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
|
||||
{ "eng", L"Emulator GOP Driver" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
that is being managed by a driver.
|
||||
|
@ -87,7 +87,6 @@ typedef struct {
|
||||
UINT32 FbSize;
|
||||
} GOP_PRIVATE_DATA;
|
||||
|
||||
|
||||
#define GOP_PRIVATE_DATA_FROM_THIS(a) \
|
||||
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
|
||||
|
||||
|
@ -19,7 +19,6 @@ BhyveGetGraphicsMode (
|
||||
UINT16 *Depth
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -107,7 +106,7 @@ EmuGopDriverBindingSupported (
|
||||
}
|
||||
|
||||
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"));
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@ -130,7 +129,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Starts a device controller or a bus controller.
|
||||
|
||||
@ -224,17 +222,23 @@ EmuGopDriverBindingStart (
|
||||
(VOID **)&MmioDesc
|
||||
);
|
||||
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"));
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "BHYVE GOP: Using mmio bar @ 0x%lx\n",
|
||||
MmioDesc->AddrRangeMin));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"BHYVE GOP: Using mmio bar @ 0x%lx\n",
|
||||
MmioDesc->AddrRangeMin
|
||||
));
|
||||
BhyveGetMemregs (Private, &Memregs);
|
||||
Private->FbSize = Memregs.FbSize;
|
||||
}
|
||||
|
||||
if (MmioDesc != NULL) {
|
||||
FreePool (MmioDesc);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
@ -250,11 +254,15 @@ EmuGopDriverBindingStart (
|
||||
(VOID **)&MmioDesc
|
||||
);
|
||||
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"));
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "BHYVE GOP: Using frame-buffer bar @ 0x%lx\n",
|
||||
MmioDesc->AddrRangeMin));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"BHYVE GOP: Using frame-buffer bar @ 0x%lx\n",
|
||||
MmioDesc->AddrRangeMin
|
||||
));
|
||||
Private->FbAddr = MmioDesc->AddrRangeMin;
|
||||
// XXX assert BAR is >= size
|
||||
}
|
||||
@ -262,12 +270,17 @@ EmuGopDriverBindingStart (
|
||||
if (MmioDesc != NULL) {
|
||||
FreePool (MmioDesc);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "BHYVE GOP: Framebuf addr 0x%lx, size %x\n",
|
||||
Private->FbAddr, Private->FbSize));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"BHYVE GOP: Framebuf addr 0x%lx, size %x\n",
|
||||
Private->FbAddr,
|
||||
Private->FbSize
|
||||
));
|
||||
|
||||
Status = EmuGopConstructor (Private);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -279,7 +292,8 @@ EmuGopDriverBindingStart (
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Private->Handle,
|
||||
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
|
||||
@ -309,8 +323,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Stops a device controller or a bus controller.
|
||||
|
||||
@ -377,7 +389,8 @@ EmuGopDriverBindingStop (
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->Handle,
|
||||
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -402,13 +415,11 @@ EmuGopDriverBindingStop (
|
||||
FreeUnicodeStringTable (Private->ControllerNameTable);
|
||||
|
||||
gBS->FreePool (Private);
|
||||
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// 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.
|
||||
@ -422,8 +433,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
The user Entry Point for module EmuGop. The user code starts with this function.
|
||||
|
||||
@ -453,7 +462,6 @@ InitializeEmuGop (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -469,7 +477,6 @@ BhyveGetGraphicsMode (
|
||||
UINT64 Offset;
|
||||
EFI_STATUS Status;
|
||||
|
||||
|
||||
Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs;
|
||||
|
||||
Status = PciIo->Mem.Read (
|
||||
@ -538,6 +545,11 @@ BhyveGetMemregs (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "BHYVE Get Memregs, size %d width %d height %d\n",
|
||||
Memregs->FbSize, Memregs->Width, Memregs->Height));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"BHYVE Get Memregs, size %d width %d height %d\n",
|
||||
Memregs->FbSize,
|
||||
Memregs->Width,
|
||||
Memregs->Height
|
||||
));
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ Abstract:
|
||||
#include "Gop.h"
|
||||
#include <Library/FrameBufferBltLib.h>
|
||||
|
||||
|
||||
EFI_EVENT mGopScreenExitBootServicesEvent;
|
||||
|
||||
GOP_MODE_DATA mGopModeData[] = {
|
||||
@ -53,14 +52,18 @@ BhyveGopCompleteModeInfo (
|
||||
Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK;
|
||||
Info->PixelInformation.ReservedMask = 0;
|
||||
} else if (ModeData->ColorDepth == 32) {
|
||||
DEBUG ((DEBUG_INFO, "%dx%d PixelBlueGreenRedReserved8BitPerColor\n",
|
||||
ModeData->HorizontalResolution, ModeData->VerticalResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%dx%d PixelBlueGreenRedReserved8BitPerColor\n",
|
||||
ModeData->HorizontalResolution,
|
||||
ModeData->VerticalResolution
|
||||
));
|
||||
Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
|
||||
}
|
||||
|
||||
Info->PixelsPerScanLine = Info->HorizontalResolution;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns information for an available graphics mode that the graphics device
|
||||
and the set of active video output devices supports.
|
||||
@ -91,7 +94,7 @@ EmuGopQuerytMode (
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -112,8 +115,6 @@ EmuGopQuerytMode (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Set the video device into the specified mode and clears the visible portions of
|
||||
the output display to black.
|
||||
@ -142,6 +143,7 @@ EmuGopSetMode (
|
||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
|
||||
|
||||
UINTN confsize = 0;
|
||||
|
||||
fbconf = NULL;
|
||||
|
||||
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
|
||||
@ -179,13 +181,19 @@ EmuGopSetMode (
|
||||
|
||||
RETURN_STATUS ret = FrameBufferBltConfigure (
|
||||
(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);
|
||||
ret = FrameBufferBltConfigure (
|
||||
(VOID *)(UINTN)This->Mode->FrameBufferBase,
|
||||
This->Mode->Info, fbconf, &confsize);
|
||||
This->Mode->Info,
|
||||
fbconf,
|
||||
&confsize
|
||||
);
|
||||
ASSERT (ret == EFI_SUCCESS);
|
||||
}
|
||||
|
||||
@ -207,8 +215,6 @@ EmuGopSetMode (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
|
||||
|
||||
@ -251,7 +257,7 @@ EmuGopBlt (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Width == 0 || Height == 0) {
|
||||
if ((Width == 0) || (Height == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -291,7 +297,6 @@ EmuGopBlt (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Construction and Destruction functions
|
||||
//
|
||||
@ -318,12 +323,12 @@ EmuGopConstructor (
|
||||
if (Private->GraphicsOutput.Mode == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Private->GraphicsOutput.Mode->Info = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
|
||||
if (Private->GraphicsOutput.Mode->Info == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
DEBUG ((DEBUG_INFO, "BHYVE Gop Constructor\n"));
|
||||
|
||||
Private->GraphicsOutput.Mode->MaxMode = sizeof (mGopModeData) / sizeof (GOP_MODE_DATA);
|
||||
@ -342,8 +347,6 @@ EmuGopConstructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EmuGopDestructor (
|
||||
GOP_PRIVATE_DATA *Private
|
||||
@ -356,6 +359,7 @@ EmuGopDestructor (
|
||||
if (Private->GraphicsOutput.Mode->Info != NULL) {
|
||||
FreePool (Private->GraphicsOutput.Mode->Info);
|
||||
}
|
||||
|
||||
FreePool (Private->GraphicsOutput.Mode);
|
||||
Private->GraphicsOutput.Mode = NULL;
|
||||
}
|
||||
@ -363,13 +367,13 @@ EmuGopDestructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ShutdownGopEvent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
@ -52,7 +52,6 @@ STATIC CONST UINT16 vbeModeIds[] = {
|
||||
|
||||
STATIC VBE2_MODE_INFO vbeModes[] = {
|
||||
{ // 0x13f 640x480x32
|
||||
|
||||
// ModeAttr - BytesPerScanLine
|
||||
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
|
||||
// Width, Height..., Vbe3
|
||||
@ -63,7 +62,6 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
|
||||
0xdeadbeef, 0x0000, 0x0000
|
||||
},
|
||||
{ // 0x140 800x600x32
|
||||
|
||||
// ModeAttr - BytesPerScanLine
|
||||
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
|
||||
// Width, Height..., Vbe3
|
||||
@ -74,7 +72,6 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
|
||||
0xdeadbeef, 0x0000, 0x0000
|
||||
},
|
||||
{ // 0x141 1024x768x32
|
||||
|
||||
// ModeAttr - BytesPerScanLine
|
||||
VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
|
||||
// Width, Height..., Vbe3
|
||||
@ -130,8 +127,12 @@ InstallVbeShim (
|
||||
//
|
||||
Segment0Pages = 1;
|
||||
Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10;
|
||||
Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode,
|
||||
Segment0Pages, &Segment0);
|
||||
Status = gBS->AllocatePages (
|
||||
AllocateAddress,
|
||||
EfiBootServicesCode,
|
||||
Segment0Pages,
|
||||
&Segment0
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
EFI_PHYSICAL_ADDRESS Handler;
|
||||
@ -142,9 +143,14 @@ InstallVbeShim (
|
||||
// it's already present.
|
||||
//
|
||||
Handler = (Int0x10->Segment << 4) + Int0x10->Offset;
|
||||
if (Handler >= SegmentC && Handler < SegmentF) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n",
|
||||
__FUNCTION__, Int0x10->Segment, Int0x10->Offset));
|
||||
if ((Handler >= SegmentC) && (Handler < SegmentF)) {
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: Video BIOS handler found at %04x:%04x\n",
|
||||
__FUNCTION__,
|
||||
Int0x10->Segment,
|
||||
Int0x10->Offset
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,8 +158,12 @@ InstallVbeShim (
|
||||
// Otherwise we'll overwrite the Int10h vector, even though we may not own
|
||||
// the page at zero.
|
||||
//
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: failed to allocate page at zero: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: failed to allocate page at zero: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
} else {
|
||||
//
|
||||
// We managed to allocate the page at zero. SVN r14218 guarantees that it
|
||||
@ -207,6 +217,7 @@ InstallVbeShim (
|
||||
*(UINT16 *)Ptr = vbeModeIds[i]; // mode number
|
||||
Ptr += 2;
|
||||
}
|
||||
|
||||
*(UINT16 *)Ptr = 0xFFFF; // mode list terminator
|
||||
Ptr += 2;
|
||||
|
||||
@ -218,9 +229,12 @@ InstallVbeShim (
|
||||
Ptr += 5;
|
||||
|
||||
VbeInfo->ProductNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
|
||||
Printed = AsciiSPrint ((CHAR8 *)Ptr,
|
||||
sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer), "%s",
|
||||
CardName);
|
||||
Printed = AsciiSPrint (
|
||||
(CHAR8 *)Ptr,
|
||||
sizeof VbeInfoFull->Buffer - (Ptr - VbeInfoFull->Buffer),
|
||||
"%s",
|
||||
CardName
|
||||
);
|
||||
Ptr += Printed + 1;
|
||||
|
||||
VbeInfo->ProductRevAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
|
||||
@ -254,6 +268,11 @@ InstallVbeShim (
|
||||
Int0x10->Segment = (UINT16)((UINT32)SegmentC >> 4);
|
||||
Int0x10->Offset = (UINT16)((UINTN)(VbeModeInfo + 1) - SegmentC);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: VBE shim installed to %x:%x\n",
|
||||
__FUNCTION__, Int0x10->Segment, Int0x10->Offset));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: VBE shim installed to %x:%x\n",
|
||||
__FUNCTION__,
|
||||
Int0x10->Segment,
|
||||
Int0x10->Offset
|
||||
));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
//
|
||||
// THIS FILE WAS GENERATED BY "VbeShim.sh". DO NOT EDIT.
|
||||
//
|
||||
|
||||
#ifndef _VBE_SHIM_H_
|
||||
#define _VBE_SHIM_H_
|
||||
STATIC CONST UINT8 mVbeShim[] = {
|
||||
|
@ -73,7 +73,7 @@ ClearCacheOnMpServicesAvailable (
|
||||
0, // TimeoutInMicroSeconds: inf.
|
||||
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));
|
||||
return Status;
|
||||
}
|
||||
@ -105,7 +105,11 @@ InstallClearCacheCallback (
|
||||
|
||||
Status = PeiServicesNotifyPpi (&mMpServicesNotify);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to set up MP Services callback: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to set up MP Services callback: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "Cmos.h"
|
||||
#include "Library/IoLib.h"
|
||||
|
||||
@ -31,7 +30,6 @@ CmosRead8 (
|
||||
return IoRead8 (0x71);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Writes 8-bits of CMOS data.
|
||||
|
||||
@ -55,4 +53,3 @@ CmosWrite8 (
|
||||
IoWrite8 (0x71, Value);
|
||||
return Value;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,4 @@ CmosWrite8 (
|
||||
IN UINT8 Value
|
||||
);
|
||||
|
||||
|
||||
#endif /* _CMOS_H_ */
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PeiServicesLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Publish PEI & DXE (Decompressed) Memory based FVs to let PEI
|
||||
and DXE know about them.
|
||||
@ -91,4 +90,3 @@ PeiFvInitialization (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ Q35TsegMbytesInitialization (
|
||||
mQ35TsegMbytes = ExtendedTsegMbytes;
|
||||
}
|
||||
|
||||
|
||||
UINT32
|
||||
GetSystemMemorySizeBelow4gb (
|
||||
VOID
|
||||
@ -124,7 +123,6 @@ GetSystemMemorySizeBelow4gb (
|
||||
return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
|
||||
}
|
||||
|
||||
|
||||
STATIC
|
||||
UINT64
|
||||
GetSystemMemorySizeAbove4gb (
|
||||
@ -149,7 +147,6 @@ GetSystemMemorySizeAbove4gb (
|
||||
return LShiftU64 (Size, 16);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return the highest address that DXE could possibly use, plus one.
|
||||
**/
|
||||
@ -174,6 +171,7 @@ GetFirstNonAddress (
|
||||
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
|
||||
return FirstNonAddress;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -184,8 +182,11 @@ GetFirstNonAddress (
|
||||
|
||||
if (Pci64Size == 0) {
|
||||
if (mBootMode != BOOT_ON_S3_RESUME) {
|
||||
DEBUG ((DEBUG_INFO, "%a: disabling 64-bit PCI host aperture\n",
|
||||
__FUNCTION__));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: disabling 64-bit PCI host aperture\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
PcdStatus = PcdSet64S (PcdPciMmio64Size, 0);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
}
|
||||
@ -224,8 +225,13 @@ GetFirstNonAddress (
|
||||
PcdStatus = PcdSet64S (PcdPciMmio64Size, Pci64Size);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n",
|
||||
__FUNCTION__, Pci64Base, Pci64Size));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n",
|
||||
__FUNCTION__,
|
||||
Pci64Base,
|
||||
Pci64Size
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -235,7 +241,6 @@ GetFirstNonAddress (
|
||||
return FirstNonAddress;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the mPhysMemAddressWidth variable, based on guest RAM size.
|
||||
**/
|
||||
@ -272,10 +277,10 @@ AddressWidthInitialization (
|
||||
if (mPhysMemAddressWidth <= 36) {
|
||||
mPhysMemAddressWidth = 36;
|
||||
}
|
||||
|
||||
ASSERT (mPhysMemAddressWidth <= 48);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Calculate the cap for the permanent PEI memory.
|
||||
**/
|
||||
@ -299,6 +304,7 @@ GetPeiMemoryCap (
|
||||
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
|
||||
return SIZE_64MB;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -340,7 +346,6 @@ GetPeiMemoryCap (
|
||||
return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Publish PEI core memory
|
||||
|
||||
@ -384,8 +389,13 @@ PublishPeiMemory (
|
||||
MemorySize = mS3AcpiReservedMemorySize;
|
||||
} else {
|
||||
PeiMemoryCap = GetPeiMemoryCap ();
|
||||
DEBUG ((DEBUG_INFO, "%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
|
||||
__FUNCTION__, mPhysMemAddressWidth, PeiMemoryCap >> 10));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: mPhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
|
||||
__FUNCTION__,
|
||||
mPhysMemAddressWidth,
|
||||
PeiMemoryCap >> 10
|
||||
));
|
||||
|
||||
//
|
||||
// Determine the range of memory to use during PEI
|
||||
@ -416,7 +426,6 @@ PublishPeiMemory (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Peform Memory Detection for QEMU / KVM
|
||||
|
||||
@ -473,8 +482,11 @@ QemuInitializeRam (
|
||||
|
||||
TsegSize = mQ35TsegMbytes * SIZE_1MB;
|
||||
AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize);
|
||||
AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize,
|
||||
TRUE);
|
||||
AddReservedMemoryBaseSizeHob (
|
||||
LowerMemorySize - TsegSize,
|
||||
TsegSize,
|
||||
TRUE
|
||||
);
|
||||
} else {
|
||||
AddMemoryRangeHob (BASE_1MB, LowerMemorySize);
|
||||
}
|
||||
@ -516,16 +528,22 @@ QemuInitializeRam (
|
||||
//
|
||||
// Set memory range from 640KB to 1MB to uncacheable
|
||||
//
|
||||
Status = MtrrSetMemoryAttribute (BASE_512KB + BASE_128KB,
|
||||
BASE_1MB - (BASE_512KB + BASE_128KB), CacheUncacheable);
|
||||
Status = MtrrSetMemoryAttribute (
|
||||
BASE_512KB + BASE_128KB,
|
||||
BASE_1MB - (BASE_512KB + BASE_128KB),
|
||||
CacheUncacheable
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Set memory range from the "top of lower RAM" (RAM below 4GB) to 4GB as
|
||||
// uncacheable
|
||||
//
|
||||
Status = MtrrSetMemoryAttribute (LowerMemorySize,
|
||||
SIZE_4GB - LowerMemorySize, CacheUncacheable);
|
||||
Status = MtrrSetMemoryAttribute (
|
||||
LowerMemorySize,
|
||||
SIZE_4GB - LowerMemorySize,
|
||||
CacheUncacheable
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
}
|
||||
@ -541,7 +559,7 @@ InitializeRamRegions (
|
||||
{
|
||||
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
|
||||
//
|
||||
|
@ -47,7 +47,6 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
|
||||
{ EfiMaxMemoryType, 0x000 }
|
||||
};
|
||||
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
|
||||
{
|
||||
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
|
||||
@ -56,7 +55,6 @@ EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
UINT16 mHostBridgeDevId;
|
||||
|
||||
EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
|
||||
@ -115,7 +113,6 @@ AddIoMemoryRangeHob (
|
||||
AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
AddMemoryBaseSizeHob (
|
||||
EFI_PHYSICAL_ADDRESS MemoryBase,
|
||||
@ -136,7 +133,6 @@ AddMemoryBaseSizeHob (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
AddMemoryRangeHob (
|
||||
EFI_PHYSICAL_ADDRESS MemoryBase,
|
||||
@ -146,7 +142,6 @@ AddMemoryRangeHob (
|
||||
AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
MemMapInitialization (
|
||||
VOID
|
||||
@ -192,9 +187,10 @@ MemMapInitialization (
|
||||
PciBase = (UINT32)(PciExBarBase + SIZE_256MB);
|
||||
} else {
|
||||
PciBase = (UINT32)PcdGet64 (PcdPciMmio32Base);
|
||||
if (PciBase == 0)
|
||||
if (PciBase == 0) {
|
||||
PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// address purpose size
|
||||
@ -242,9 +238,13 @@ MemMapInitialization (
|
||||
// uncacheable reserved memory right here.
|
||||
//
|
||||
AddReservedMemoryBaseSizeHob (PciExBarBase, SIZE_256MB, FALSE);
|
||||
BuildMemoryAllocationHob (PciExBarBase, SIZE_256MB,
|
||||
EfiReservedMemoryType);
|
||||
BuildMemoryAllocationHob (
|
||||
PciExBarBase,
|
||||
SIZE_256MB,
|
||||
EfiReservedMemoryType
|
||||
);
|
||||
}
|
||||
|
||||
AddIoMemoryBaseSizeHob (PcdGet32 (PcdCpuLocalApicBaseAddress), SIZE_1MB);
|
||||
|
||||
//
|
||||
@ -370,11 +370,16 @@ MiscInitialization (
|
||||
AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN;
|
||||
break;
|
||||
default:
|
||||
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__, mHostBridgeDevId));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__,
|
||||
mHostBridgeDevId
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, mHostBridgeDevId);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
@ -417,7 +422,6 @@ MiscInitialization (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
BootModeInitialization (
|
||||
VOID
|
||||
@ -428,6 +432,7 @@ BootModeInitialization (
|
||||
if (CmosRead8 (0xF) == 0xFE) {
|
||||
mBootMode = BOOT_ON_S3_RESUME;
|
||||
}
|
||||
|
||||
CmosWrite8 (0xF, 0x00);
|
||||
|
||||
Status = PeiServicesSetBootMode (mBootMode);
|
||||
@ -437,7 +442,6 @@ BootModeInitialization (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
ReserveEmuVariableNvStore (
|
||||
)
|
||||
@ -456,7 +460,8 @@ ReserveEmuVariableNvStore (
|
||||
AllocateRuntimePages (
|
||||
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
|
||||
);
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Reserved variable store memory: 0x%lX; size: %dkb\n",
|
||||
VariableStore,
|
||||
(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
|
||||
@ -465,7 +470,6 @@ ReserveEmuVariableNvStore (
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
DebugDumpCmos (
|
||||
VOID
|
||||
@ -479,6 +483,7 @@ DebugDumpCmos (
|
||||
if ((Loop % 0x10) == 0) {
|
||||
DEBUG ((DEBUG_INFO, "%02x:", Loop));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, " %02x", CmosRead8 (Loop)));
|
||||
if ((Loop % 0x10) == 0xf) {
|
||||
DEBUG ((DEBUG_INFO, "\n"));
|
||||
@ -486,7 +491,6 @@ DebugDumpCmos (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
S3Verification (
|
||||
VOID
|
||||
@ -494,20 +498,28 @@ S3Verification (
|
||||
{
|
||||
#if defined (MDE_CPU_X64)
|
||||
if (FeaturePcdGet (PcdSmmSmramRequire) && mS3Supported) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
"%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n", __FUNCTION__));
|
||||
DEBUG ((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",
|
||||
__FUNCTION__));
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
"%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n", __FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: or build OVMF with \"OvmfPkgIa32X64.dsc\".\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modules.
|
||||
Set the mMaxCpuCount variable.
|
||||
@ -528,6 +540,7 @@ MaxCpuCountInitialization (
|
||||
mMaxCpuCount = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Otherwise, set mMaxCpuCount to the value reported by QEMU.
|
||||
//
|
||||
@ -542,11 +555,14 @@ MaxCpuCountInitialization (
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
PcdStatus = PcdSet32S (PcdCpuApInitTimeOutInMicroSeconds, MAX_UINT32);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processor(s)\n", __FUNCTION__,
|
||||
ProcessorCount));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: QEMU reports %d processor(s)\n",
|
||||
__FUNCTION__,
|
||||
ProcessorCount
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Perform Platform PEI initialization.
|
||||
|
||||
@ -596,6 +612,7 @@ InitializePlatform (
|
||||
if (!FeaturePcdGet (PcdSmmSmramRequire)) {
|
||||
ReserveEmuVariableNvStore ();
|
||||
}
|
||||
|
||||
PeiFvInitialization ();
|
||||
MemMapInitialization ();
|
||||
NoexecDxeInitialization ();
|
||||
|
@ -26,16 +26,15 @@ GetBhyveSmbiosTables (
|
||||
|
||||
for (BhyveSmbiosPtr = (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_ADDRESS;
|
||||
BhyveSmbiosPtr < (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_END;
|
||||
BhyveSmbiosPtr += 0x10) {
|
||||
|
||||
BhyveSmbiosPtr += 0x10)
|
||||
{
|
||||
BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)BhyveSmbiosPtr;
|
||||
|
||||
if (!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
|
||||
!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
|
||||
IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure)) {
|
||||
|
||||
IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure))
|
||||
{
|
||||
return BhyveSmbiosEntryPointStructure;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,6 @@ STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
|
||||
TYPE0_STRINGS
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Validates the SMBIOS entry point structure
|
||||
|
||||
@ -93,7 +92,6 @@ IsEntryPointStructureValid (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get SMBIOS record length.
|
||||
|
||||
@ -116,12 +114,12 @@ SmbiosTableLength (
|
||||
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
|
||||
AChar++;
|
||||
}
|
||||
|
||||
Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Install all structures from the given SMBIOS structures block
|
||||
|
||||
@ -187,7 +185,6 @@ InstallAllStructures (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Installs SMBIOS information for OVMF
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Locates the bhyve SMBIOS data if it exists
|
||||
|
||||
@ -33,7 +32,6 @@ GetBhyveSmbiosTables (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Validates the SMBIOS entry point structure
|
||||
|
||||
|
@ -74,18 +74,21 @@ GetCompatEntryPoint (
|
||||
PeCompatEnd = (UINTN)(VOID *)PeCompat + Section->Misc.VirtualSize;
|
||||
|
||||
while (PeCompat->Type != 0 && (UINTN)(VOID *)PeCompat < PeCompatEnd) {
|
||||
if (PeCompat->Type == 1 &&
|
||||
PeCompat->Size >= sizeof (PE_COMPAT_TYPE1) &&
|
||||
EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCompat->MachineType)) {
|
||||
|
||||
if ((PeCompat->Type == 1) &&
|
||||
(PeCompat->Size >= sizeof (PE_COMPAT_TYPE1)) &&
|
||||
EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCompat->MachineType))
|
||||
{
|
||||
return (EFI_IMAGE_ENTRY_POINT)((UINTN)ImageBase + PeCompat->EntryPoint);
|
||||
}
|
||||
|
||||
PeCompat = (PE_COMPAT_TYPE1 *)((UINTN)PeCompat + PeCompat->Size);
|
||||
ASSERT ((UINTN)(VOID *)PeCompat < PeCompatEnd);
|
||||
}
|
||||
}
|
||||
|
||||
Section++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -136,8 +139,10 @@ CompatImageLoaderDxeEntryPoint (
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
return gBS->InstallProtocolInterface (&ImageHandle,
|
||||
return gBS->InstallProtocolInterface (
|
||||
&ImageHandle,
|
||||
&gEdkiiPeCoffImageEmulatorProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
&mCompatLoaderPeCoffEmuProtocol);
|
||||
&mCompatLoaderPeCoffEmuProtocol
|
||||
);
|
||||
}
|
||||
|
@ -123,14 +123,21 @@ ProcessHotAddedCpus (
|
||||
//
|
||||
for (CheckSlot = 0;
|
||||
CheckSlot < mCpuHotPlugData->ArrayLength;
|
||||
CheckSlot++) {
|
||||
CheckSlot++)
|
||||
{
|
||||
if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckSlot < mCpuHotPlugData->ArrayLength) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged "
|
||||
"before; ignoring it\n", __FUNCTION__, NewApicId));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: APIC ID " FMT_APIC_ID " was hot-plugged "
|
||||
"before; ignoring it\n",
|
||||
__FUNCTION__,
|
||||
NewApicId
|
||||
));
|
||||
PluggedIdx++;
|
||||
continue;
|
||||
}
|
||||
@ -139,12 +146,18 @@ ProcessHotAddedCpus (
|
||||
// Find the first empty slot in CPU_HOT_PLUG_DATA.
|
||||
//
|
||||
while (NewSlot < mCpuHotPlugData->ArrayLength &&
|
||||
mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64) {
|
||||
mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64)
|
||||
{
|
||||
NewSlot++;
|
||||
}
|
||||
|
||||
if (NewSlot == mCpuHotPlugData->ArrayLength) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n",
|
||||
__FUNCTION__, NewApicId));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: no room for APIC ID " FMT_APIC_ID "\n",
|
||||
__FUNCTION__,
|
||||
NewApicId
|
||||
));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
@ -156,8 +169,11 @@ ProcessHotAddedCpus (
|
||||
//
|
||||
// Relocate the SMBASE of the new CPU.
|
||||
//
|
||||
Status = SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot],
|
||||
mPostSmmPenAddress);
|
||||
Status = SmbaseRelocate (
|
||||
NewApicId,
|
||||
mCpuHotPlugData->SmBase[NewSlot],
|
||||
mPostSmmPenAddress
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto RevokeNewSlot;
|
||||
}
|
||||
@ -165,18 +181,31 @@ ProcessHotAddedCpus (
|
||||
//
|
||||
// Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL.
|
||||
//
|
||||
Status = mMmCpuService->AddProcessor (mMmCpuService, NewApicId,
|
||||
&NewProcessorNumberByProtocol);
|
||||
Status = mMmCpuService->AddProcessor (
|
||||
mMmCpuService,
|
||||
NewApicId,
|
||||
&NewProcessorNumberByProtocol
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n",
|
||||
__FUNCTION__, NewApicId, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: AddProcessor(" FMT_APIC_ID "): %r\n",
|
||||
__FUNCTION__,
|
||||
NewApicId,
|
||||
Status
|
||||
));
|
||||
goto RevokeNewSlot;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, "
|
||||
"EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__,
|
||||
NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot],
|
||||
(UINT64)NewProcessorNumberByProtocol));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, "
|
||||
"EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n",
|
||||
__FUNCTION__,
|
||||
NewApicId,
|
||||
(UINT64)mCpuHotPlugData->SmBase[NewSlot],
|
||||
(UINT64)NewProcessorNumberByProtocol
|
||||
));
|
||||
|
||||
NewSlot++;
|
||||
PluggedIdx++;
|
||||
@ -277,8 +306,14 @@ EjectCpu (
|
||||
mCpuHotEjectData->QemuSelectorMap[Idx] =
|
||||
CPU_EJECT_QEMU_SELECTOR_INVALID;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Unplugged ProcessorNum %u, "
|
||||
"QemuSelector %Lu\n", __FUNCTION__, Idx, QemuSelector));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Unplugged ProcessorNum %u, "
|
||||
"QemuSelector %Lu\n",
|
||||
__FUNCTION__,
|
||||
Idx,
|
||||
QemuSelector
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,7 +439,8 @@ UnplugCpus (
|
||||
|
||||
for (ProcessorNum = 0;
|
||||
ProcessorNum < mCpuHotPlugData->ArrayLength;
|
||||
ProcessorNum++) {
|
||||
ProcessorNum++)
|
||||
{
|
||||
if (mCpuHotPlugData->ApicId[ProcessorNum] == RemoveApicId) {
|
||||
break;
|
||||
}
|
||||
@ -414,8 +450,13 @@ UnplugCpus (
|
||||
// Ignore the unplug if APIC ID not found
|
||||
//
|
||||
if (ProcessorNum == mCpuHotPlugData->ArrayLength) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: did not find APIC ID " FMT_APIC_ID
|
||||
" to unplug\n", __FUNCTION__, RemoveApicId));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: did not find APIC ID " FMT_APIC_ID
|
||||
" to unplug\n",
|
||||
__FUNCTION__,
|
||||
RemoveApicId
|
||||
));
|
||||
ToUnplugIdx++;
|
||||
continue;
|
||||
}
|
||||
@ -425,13 +466,19 @@ UnplugCpus (
|
||||
//
|
||||
Status = mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n",
|
||||
__FUNCTION__, RemoveApicId, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: RemoveProcessor(" FMT_APIC_ID "): %r\n",
|
||||
__FUNCTION__,
|
||||
RemoveApicId,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (mCpuHotEjectData->QemuSelectorMap[ProcessorNum] !=
|
||||
CPU_EJECT_QEMU_SELECTOR_INVALID) {
|
||||
CPU_EJECT_QEMU_SELECTOR_INVALID)
|
||||
{
|
||||
//
|
||||
// mCpuHotEjectData->QemuSelectorMap[ProcessorNum] is set to
|
||||
// CPU_EJECT_QEMU_SELECTOR_INVALID when mCpuHotEjectData->QemuSelectorMap
|
||||
@ -442,9 +489,15 @@ UnplugCpus (
|
||||
// never match more than one APIC ID -- nor, by transitivity, designate
|
||||
// more than one QemuSelector -- in a single invocation of UnplugCpus().
|
||||
//
|
||||
DEBUG ((DEBUG_ERROR, "%a: ProcessorNum %Lu maps to QemuSelector %Lu, "
|
||||
"cannot also map to %u\n", __FUNCTION__, (UINT64)ProcessorNum,
|
||||
mCpuHotEjectData->QemuSelectorMap[ProcessorNum], QemuSelector));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: ProcessorNum %Lu maps to QemuSelector %Lu, "
|
||||
"cannot also map to %u\n",
|
||||
__FUNCTION__,
|
||||
(UINT64)ProcessorNum,
|
||||
mCpuHotEjectData->QemuSelectorMap[ProcessorNum],
|
||||
QemuSelector
|
||||
));
|
||||
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
@ -454,9 +507,15 @@ UnplugCpus (
|
||||
//
|
||||
mCpuHotEjectData->QemuSelectorMap[ProcessorNum] = (UINT64)QemuSelector;
|
||||
|
||||
DEBUG ((DEBUG_INFO, "%a: Started hot-unplug on ProcessorNum %Lu, APIC ID "
|
||||
FMT_APIC_ID ", QemuSelector %u\n", __FUNCTION__, (UINT64)ProcessorNum,
|
||||
RemoveApicId, QemuSelector));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Started hot-unplug on ProcessorNum %Lu, APIC ID "
|
||||
FMT_APIC_ID ", QemuSelector %u\n",
|
||||
__FUNCTION__,
|
||||
(UINT64)ProcessorNum,
|
||||
RemoveApicId,
|
||||
QemuSelector
|
||||
));
|
||||
|
||||
EjectCount++;
|
||||
ToUnplugIdx++;
|
||||
@ -565,11 +624,20 @@ CpuHotplugMmi (
|
||||
// Read the MMI command value from the APM Control Port, to see if this is an
|
||||
// MMI we should care about.
|
||||
//
|
||||
Status = mMmCpuIo->Io.Read (mMmCpuIo, MM_IO_UINT8, ICH9_APM_CNT, 1,
|
||||
&ApmControl);
|
||||
Status = mMmCpuIo->Io.Read (
|
||||
mMmCpuIo,
|
||||
MM_IO_UINT8,
|
||||
ICH9_APM_CNT,
|
||||
1,
|
||||
&ApmControl
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to read ICH9_APM_CNT: %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
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.
|
||||
//
|
||||
@ -628,7 +696,6 @@ Fatal:
|
||||
return EFI_INTERRUPT_PENDING;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Entry point function of this driver.
|
||||
//
|
||||
@ -663,17 +730,28 @@ CpuHotplugEntry (
|
||||
// First, collect the protocols needed later. All of these protocols are
|
||||
// listed in our module DEPEX.
|
||||
//
|
||||
Status = gMmst->MmLocateProtocol (&gEfiMmCpuIoProtocolGuid,
|
||||
NULL /* Registration */, (VOID **)&mMmCpuIo);
|
||||
Status = gMmst->MmLocateProtocol (
|
||||
&gEfiMmCpuIoProtocolGuid,
|
||||
NULL /* Registration */,
|
||||
(VOID **)&mMmCpuIo
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: locate MmCpuIo: %r\n", __FUNCTION__, Status));
|
||||
goto Fatal;
|
||||
}
|
||||
Status = gMmst->MmLocateProtocol (&gEfiSmmCpuServiceProtocolGuid,
|
||||
NULL /* Registration */, (VOID **)&mMmCpuService);
|
||||
|
||||
Status = gMmst->MmLocateProtocol (
|
||||
&gEfiSmmCpuServiceProtocolGuid,
|
||||
NULL /* Registration */,
|
||||
(VOID **)&mMmCpuService
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: locate MmCpuService: %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: locate MmCpuService: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto Fatal;
|
||||
}
|
||||
|
||||
@ -692,6 +770,7 @@ CpuHotplugEntry (
|
||||
DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_PLUG_DATA: %r\n", __FUNCTION__, Status));
|
||||
goto Fatal;
|
||||
}
|
||||
|
||||
//
|
||||
// If the possible CPU count is 1, there's nothing for this driver to do.
|
||||
//
|
||||
@ -706,6 +785,7 @@ CpuHotplugEntry (
|
||||
} else {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_EJECT_DATA: %r\n", __FUNCTION__, Status));
|
||||
goto Fatal;
|
||||
@ -716,25 +796,38 @@ CpuHotplugEntry (
|
||||
//
|
||||
if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Len)) ||
|
||||
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;
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_PLUG_DATA\n", __FUNCTION__));
|
||||
goto Fatal;
|
||||
}
|
||||
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, Size,
|
||||
(VOID **)&mPluggedApicIds);
|
||||
|
||||
Status = gMmst->MmAllocatePool (
|
||||
EfiRuntimeServicesData,
|
||||
Size,
|
||||
(VOID **)&mPluggedApicIds
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
|
||||
goto Fatal;
|
||||
}
|
||||
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, Size,
|
||||
(VOID **)&mToUnplugApicIds);
|
||||
|
||||
Status = gMmst->MmAllocatePool (
|
||||
EfiRuntimeServicesData,
|
||||
Size,
|
||||
(VOID **)&mToUnplugApicIds
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
|
||||
goto ReleasePluggedApicIds;
|
||||
}
|
||||
Status = gMmst->MmAllocatePool (EfiRuntimeServicesData, SizeSel,
|
||||
(VOID **)&mToUnplugSelectors);
|
||||
|
||||
Status = gMmst->MmAllocatePool (
|
||||
EfiRuntimeServicesData,
|
||||
SizeSel,
|
||||
(VOID **)&mToUnplugSelectors
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Status));
|
||||
goto ReleaseToUnplugApicIds;
|
||||
@ -743,8 +836,10 @@ CpuHotplugEntry (
|
||||
//
|
||||
// Allocate the Post-SMM Pen for hot-added CPUs.
|
||||
//
|
||||
Status = SmbaseAllocatePostSmmPen (&mPostSmmPenAddress,
|
||||
SystemTable->BootServices);
|
||||
Status = SmbaseAllocatePostSmmPen (
|
||||
&mPostSmmPenAddress,
|
||||
SystemTable->BootServices
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ReleaseToUnplugSelectors;
|
||||
}
|
||||
@ -776,8 +871,12 @@ CpuHotplugEntry (
|
||||
QemuCpuhpWriteCommand (mMmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);
|
||||
if (QemuCpuhpReadCommandData2 (mMmCpuIo) != 0) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
DEBUG ((DEBUG_ERROR, "%a: modern CPU hotplug interface: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: modern CPU hotplug interface: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto ReleasePostSmmPen;
|
||||
}
|
||||
|
||||
@ -790,8 +889,12 @@ CpuHotplugEntry (
|
||||
&mDispatchHandle
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: MmiHandlerRegister(): %r\n", __FUNCTION__,
|
||||
Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: MmiHandlerRegister(): %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
goto ReleasePostSmmPen;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ QemuCpuhpReadCommandData2 (
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
return CommandData2;
|
||||
}
|
||||
|
||||
@ -64,6 +65,7 @@ QemuCpuhpReadCpuStatus (
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
return CpuStatus;
|
||||
}
|
||||
|
||||
@ -88,6 +90,7 @@ QemuCpuhpReadCommandData (
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
return CommandData;
|
||||
}
|
||||
|
||||
@ -218,7 +221,7 @@ QemuCpuhpCollectApicIds (
|
||||
{
|
||||
UINT32 CurrentSelector;
|
||||
|
||||
if (PossibleCpuCount == 0 || ApicIdCount == 0) {
|
||||
if ((PossibleCpuCount == 0) || (ApicIdCount == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -259,10 +262,17 @@ QemuCpuhpCollectApicIds (
|
||||
QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_PENDING);
|
||||
PendingSelector = QemuCpuhpReadCommandData (MmCpuIo);
|
||||
if (PendingSelector < CurrentSelector) {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u PendingSelector=%u: "
|
||||
"wrap-around\n", __FUNCTION__, CurrentSelector, PendingSelector));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: CurrentSelector=%u PendingSelector=%u: "
|
||||
"wrap-around\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector,
|
||||
PendingSelector
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentSelector = PendingSelector;
|
||||
|
||||
//
|
||||
@ -274,16 +284,26 @@ QemuCpuhpCollectApicIds (
|
||||
// The "insert" event guarantees the "enabled" status; plus it excludes
|
||||
// the "fw_remove" event.
|
||||
//
|
||||
if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0 ||
|
||||
(CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=%u CpuStatus=0x%x: "
|
||||
"inconsistent CPU status\n", __FUNCTION__, CurrentSelector,
|
||||
CpuStatus));
|
||||
if (((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0) ||
|
||||
((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) != 0))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: CurrentSelector=%u CpuStatus=0x%x: "
|
||||
"inconsistent CPU status\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector,
|
||||
CpuStatus
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: insert\n", __FUNCTION__,
|
||||
CurrentSelector));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: CurrentSelector=%u: insert\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector
|
||||
));
|
||||
|
||||
ExtendIds = PluggedApicIds;
|
||||
ExtendSels = NULL;
|
||||
@ -293,14 +313,23 @@ QemuCpuhpCollectApicIds (
|
||||
// "fw_remove" event guarantees "enabled".
|
||||
//
|
||||
if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) == 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=%u CpuStatus=0x%x: "
|
||||
"inconsistent CPU status\n", __FUNCTION__, CurrentSelector,
|
||||
CpuStatus));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: CurrentSelector=%u CpuStatus=0x%x: "
|
||||
"inconsistent CPU status\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector,
|
||||
CpuStatus
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: fw_remove\n",
|
||||
__FUNCTION__, CurrentSelector));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: CurrentSelector=%u: fw_remove\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector
|
||||
));
|
||||
|
||||
ExtendIds = ToUnplugApicIds;
|
||||
ExtendSels = ToUnplugSelectors;
|
||||
@ -309,15 +338,23 @@ QemuCpuhpCollectApicIds (
|
||||
//
|
||||
// Let the OSPM deal with the "remove" event.
|
||||
//
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: remove (ignored)\n",
|
||||
__FUNCTION__, CurrentSelector));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: CurrentSelector=%u: remove (ignored)\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector
|
||||
));
|
||||
|
||||
ExtendIds = NULL;
|
||||
ExtendSels = NULL;
|
||||
ExtendCount = NULL;
|
||||
} else {
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=%u: no event\n",
|
||||
__FUNCTION__, CurrentSelector));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: CurrentSelector=%u: no event\n",
|
||||
__FUNCTION__,
|
||||
CurrentSelector
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -334,15 +371,22 @@ QemuCpuhpCollectApicIds (
|
||||
DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__));
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID);
|
||||
NewApicId = QemuCpuhpReadCommandData (MmCpuIo);
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: ApicId=" FMT_APIC_ID "\n", __FUNCTION__,
|
||||
NewApicId));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: ApicId=" FMT_APIC_ID "\n",
|
||||
__FUNCTION__,
|
||||
NewApicId
|
||||
));
|
||||
if (ExtendSels != NULL) {
|
||||
ExtendSels[(*ExtendCount)] = CurrentSelector;
|
||||
}
|
||||
|
||||
ExtendIds[(*ExtendCount)++] = NewApicId;
|
||||
}
|
||||
|
||||
//
|
||||
// We've processed the CPU with (known) pending events, but we must never
|
||||
// clear events. Therefore we need to advance past this CPU manually;
|
||||
@ -352,7 +396,12 @@ QemuCpuhpCollectApicIds (
|
||||
CurrentSelector++;
|
||||
} while (CurrentSelector < PossibleCpuCount);
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "%a: PluggedCount=%u ToUnplugCount=%u\n",
|
||||
__FUNCTION__, *PluggedCount, *ToUnplugCount));
|
||||
DEBUG ((
|
||||
DEBUG_VERBOSE,
|
||||
"%a: PluggedCount=%u ToUnplugCount=%u\n",
|
||||
__FUNCTION__,
|
||||
*PluggedCount,
|
||||
*ToUnplugCount
|
||||
));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -59,14 +59,23 @@ SmbaseAllocatePostSmmPen (
|
||||
//
|
||||
if (mPostSmmPenSize >= EFI_PAGE_SIZE) {
|
||||
Status = EFI_BAD_BUFFER_SIZE;
|
||||
DEBUG ((DEBUG_ERROR, "%a: mPostSmmPenSize=%u: %r\n", __FUNCTION__,
|
||||
mPostSmmPenSize, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: mPostSmmPenSize=%u: %r\n",
|
||||
__FUNCTION__,
|
||||
mPostSmmPenSize,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Address = BASE_1MB - 1;
|
||||
Status = BootServices->AllocatePages (AllocateMaxAddress,
|
||||
EfiReservedMemoryType, 1, &Address);
|
||||
Status = BootServices->AllocatePages (
|
||||
AllocateMaxAddress,
|
||||
EfiReservedMemoryType,
|
||||
1,
|
||||
&Address
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: AllocatePages(): %r\n", __FUNCTION__, Status));
|
||||
return Status;
|
||||
@ -135,8 +144,11 @@ SmbaseInstallFirstSmiHandler (
|
||||
{
|
||||
FIRST_SMI_HANDLER_CONTEXT *Context;
|
||||
|
||||
CopyMem ((VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
|
||||
mFirstSmiHandler, mFirstSmiHandlerSize);
|
||||
CopyMem (
|
||||
(VOID *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET),
|
||||
mFirstSmiHandler,
|
||||
mFirstSmiHandlerSize
|
||||
);
|
||||
|
||||
Context = (VOID *)(UINTN)SMM_DEFAULT_SMBASE;
|
||||
Context->ApicIdGate = MAX_UINT64;
|
||||
@ -196,8 +208,14 @@ SmbaseRelocate (
|
||||
|
||||
if (Smbase > MAX_UINT32) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n",
|
||||
__FUNCTION__, ApicId, (UINT64)Smbase, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: ApicId=" FMT_APIC_ID " Smbase=0x%Lx: %r\n",
|
||||
__FUNCTION__,
|
||||
ApicId,
|
||||
(UINT64)Smbase,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -261,12 +279,21 @@ SmbaseRelocate (
|
||||
//
|
||||
// Un-gate SMBASE relocation for the hot-added CPU whose APIC ID is ApicId.
|
||||
//
|
||||
ExchangeResult = InterlockedCompareExchange64 (&Context->ApicIdGate,
|
||||
MAX_UINT64, ApicId);
|
||||
ExchangeResult = InterlockedCompareExchange64 (
|
||||
&Context->ApicIdGate,
|
||||
MAX_UINT64,
|
||||
ApicId
|
||||
);
|
||||
if (ExchangeResult != MAX_UINT64) {
|
||||
Status = EFI_PROTOCOL_ERROR;
|
||||
DEBUG ((DEBUG_ERROR, "%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n",
|
||||
__FUNCTION__, ApicId, ExchangeResult, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: ApicId=" FMT_APIC_ID " ApicIdGate=0x%Lx: %r\n",
|
||||
__FUNCTION__,
|
||||
ApicId,
|
||||
ExchangeResult,
|
||||
Status
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ AllocateZeroPages (
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
Callback function executed when the EndOfDxe event group is signaled.
|
||||
|
||||
@ -209,6 +210,7 @@ CpuS3DataInitialize (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus;
|
||||
|
||||
//
|
||||
|
@ -154,6 +154,7 @@ BiosVideoDriverBindingSupported (
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is a PCI Graphics Controller by looking at the Command register and
|
||||
// Class Code Register
|
||||
@ -171,8 +172,7 @@ BiosVideoDriverBindingSupported (
|
||||
}
|
||||
|
||||
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;
|
||||
//
|
||||
// If this is a graphics controller,
|
||||
@ -189,9 +189,10 @@ BiosVideoDriverBindingSupported (
|
||||
// If RemainingDevicePath isn't the End of Device Path Node,
|
||||
// check its validation
|
||||
//
|
||||
if (Node->DevPath.Type != ACPI_DEVICE_PATH ||
|
||||
Node->DevPath.SubType != ACPI_ADR_DP ||
|
||||
DevicePathNodeLength(&Node->DevPath) < sizeof(ACPI_ADR_DEVICE_PATH)) {
|
||||
if ((Node->DevPath.Type != ACPI_DEVICE_PATH) ||
|
||||
(Node->DevPath.SubType != ACPI_ADR_DP) ||
|
||||
(DevicePathNodeLength (&Node->DevPath) < sizeof (ACPI_ADR_DEVICE_PATH)))
|
||||
{
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
@ -209,7 +210,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Install Graphics Output Protocol onto VGA device handles.
|
||||
|
||||
@ -292,6 +292,7 @@ BiosVideoDriverBindingStart (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
mPciAttributesSaved = TRUE;
|
||||
}
|
||||
|
||||
@ -309,7 +310,7 @@ BiosVideoDriverBindingStart (
|
||||
}
|
||||
|
||||
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;
|
||||
goto Done;
|
||||
}
|
||||
@ -336,6 +337,7 @@ BiosVideoDriverBindingStart (
|
||||
);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// 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)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
//
|
||||
// Post the legacy option ROM if it is available.
|
||||
//
|
||||
@ -378,7 +381,8 @@ BiosVideoDriverBindingStart (
|
||||
|
||||
if (RemainingDevicePath != NULL) {
|
||||
if (IsDevicePathEnd (RemainingDevicePath) &&
|
||||
(FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdBiosVideoCheckVgaEnable))) {
|
||||
(FeaturePcdGet (PcdBiosVideoCheckVbeEnable) || FeaturePcdGet (PcdBiosVideoCheckVgaEnable)))
|
||||
{
|
||||
//
|
||||
// If RemainingDevicePath is the End of Device Path Node,
|
||||
// don't create any child device and return EFI_SUCCESS
|
||||
@ -425,6 +429,7 @@ Done:
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Release PCI I/O Protocols on the controller handle.
|
||||
//
|
||||
@ -439,7 +444,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop.
|
||||
|
||||
@ -516,11 +520,9 @@ BiosVideoDriverBindingStop (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Install child handles if the Handle supports MBR format.
|
||||
|
||||
@ -580,12 +582,13 @@ BiosVideoChildHandleInstall (
|
||||
);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -626,7 +629,6 @@ BiosVideoChildHandleInstall (
|
||||
BiosVideoPrivate->GraphicsOutput.QueryMode = BiosVideoGraphicsOutputQueryMode;
|
||||
BiosVideoPrivate->GraphicsOutput.SetMode = BiosVideoGraphicsOutputSetMode;
|
||||
|
||||
|
||||
//
|
||||
// Allocate buffer for Graphics Output Protocol mode information
|
||||
//
|
||||
@ -715,6 +717,7 @@ BiosVideoChildHandleInstall (
|
||||
} else {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// The VESA BIOS Extensions are not compatible with Graphics Output, so check for support
|
||||
@ -740,6 +743,7 @@ BiosVideoChildHandleInstall (
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
|
||||
}
|
||||
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode = NULL;
|
||||
}
|
||||
@ -789,6 +793,7 @@ BiosVideoChildHandleInstall (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
ProtocolInstalled = TRUE;
|
||||
}
|
||||
}
|
||||
@ -810,6 +815,7 @@ Done:
|
||||
if ((BiosVideoPrivate != NULL) && (BiosVideoPrivate->ExitBootServicesEvent != NULL)) {
|
||||
gBS->CloseEvent (BiosVideoPrivate->ExitBootServicesEvent);
|
||||
}
|
||||
|
||||
//
|
||||
// Free private data structure
|
||||
//
|
||||
@ -819,7 +825,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deregister an video child handle and free resources.
|
||||
|
||||
@ -918,6 +923,7 @@ BiosVideoChildHandleUninstall (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (!BiosVideoPrivate->ProduceGraphicsOutput) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Controller,
|
||||
@ -954,7 +960,6 @@ BiosVideoChildHandleUninstall (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Release resource for biso video instance.
|
||||
|
||||
@ -980,24 +985,28 @@ BiosVideoDeviceReleaseResource (
|
||||
if (BiosVideoPrivate->VgaFrameBuffer != NULL) {
|
||||
FreePool (BiosVideoPrivate->VgaFrameBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Free VBE Frame Buffer
|
||||
//
|
||||
if (BiosVideoPrivate->VbeFrameBuffer != NULL) {
|
||||
FreePool (BiosVideoPrivate->VbeFrameBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Free line buffer
|
||||
//
|
||||
if (BiosVideoPrivate->LineBuffer != NULL) {
|
||||
FreePool (BiosVideoPrivate->LineBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// Free mode data
|
||||
//
|
||||
if (BiosVideoPrivate->ModeData != NULL) {
|
||||
FreePool (BiosVideoPrivate->ModeData);
|
||||
}
|
||||
|
||||
//
|
||||
// Free memory allocated below 1MB
|
||||
//
|
||||
@ -1017,15 +1026,18 @@ BiosVideoDeviceReleaseResource (
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
|
||||
}
|
||||
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Free EDID discovered protocol occupied resource
|
||||
//
|
||||
if (BiosVideoPrivate->EdidDiscovered.Edid != NULL) {
|
||||
FreePool (BiosVideoPrivate->EdidDiscovered.Edid);
|
||||
}
|
||||
|
||||
//
|
||||
// Free EDID active protocol occupied resource
|
||||
//
|
||||
@ -1042,7 +1054,6 @@ BiosVideoDeviceReleaseResource (
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Generate a search key for a specified timing data.
|
||||
|
||||
@ -1065,7 +1076,6 @@ CalculateEdidKey (
|
||||
return Key;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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++) {
|
||||
CheckSum = (UINT8)(CheckSum + EdidBuffer[Index]);
|
||||
}
|
||||
|
||||
if (CheckSum != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -1113,7 +1124,8 @@ ParseEdidData (
|
||||
if ((EdidDataBlock->EstablishedTimings[0] != 0) ||
|
||||
(EdidDataBlock->EstablishedTimings[1] != 0) ||
|
||||
(EdidDataBlock->EstablishedTimings[2] != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Established timing data
|
||||
//
|
||||
@ -1122,11 +1134,16 @@ ParseEdidData (
|
||||
((EdidDataBlock->EstablishedTimings[2] & 0x80) << 9);
|
||||
for (Index = 0; Index < VESA_BIOS_EXTENSIONS_EDID_ESTABLISHED_TIMING_MAX_NUMBER; Index++) {
|
||||
if ((TimingBits & 0x1) != 0) {
|
||||
DEBUG ((DEBUG_INFO, "Established Timing: %d x %d\n",
|
||||
mEstablishedEdidTiming[Index].HorizontalResolution, mEstablishedEdidTiming[Index].VerticalResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Established Timing: %d x %d\n",
|
||||
mEstablishedEdidTiming[Index].HorizontalResolution,
|
||||
mEstablishedEdidTiming[Index].VerticalResolution
|
||||
));
|
||||
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&mEstablishedEdidTiming[Index]);
|
||||
ValidNumber++;
|
||||
}
|
||||
|
||||
TimingBits = TimingBits >> 1;
|
||||
}
|
||||
}
|
||||
@ -1163,6 +1180,7 @@ ParseEdidData (
|
||||
VerticalResolution = (UINT16)(HorizontalResolution / 4 * 3);
|
||||
break;
|
||||
}
|
||||
|
||||
RefreshRate = (UINT8)((BufferIndex[1] & 0x1f) + 60);
|
||||
DEBUG ((DEBUG_INFO, "Standard Timing: %d x %d\n", HorizontalResolution, VerticalResolution));
|
||||
TempTiming.HorizontalResolution = HorizontalResolution;
|
||||
@ -1171,6 +1189,7 @@ ParseEdidData (
|
||||
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);
|
||||
ValidNumber++;
|
||||
}
|
||||
|
||||
BufferIndex += 2;
|
||||
}
|
||||
|
||||
@ -1186,13 +1205,19 @@ ParseEdidData (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Horizontal and Vertical resolution
|
||||
//
|
||||
TempTiming.HorizontalResolution = ((UINT16)(BufferIndex[4] & 0xF0) << 4) | (BufferIndex[2]);
|
||||
TempTiming.VerticalResolution = ((UINT16)(BufferIndex[7] & 0xF0) << 4) | (BufferIndex[5]);
|
||||
DEBUG ((DEBUG_INFO, "Detailed Timing %d: %d x %d\n",
|
||||
Index, TempTiming.HorizontalResolution, TempTiming.VerticalResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Detailed Timing %d: %d x %d\n",
|
||||
Index,
|
||||
TempTiming.HorizontalResolution,
|
||||
TempTiming.VerticalResolution
|
||||
));
|
||||
ValidEdidTiming->Key[ValidNumber] = CalculateEdidKey (&TempTiming);
|
||||
ValidNumber++;
|
||||
}
|
||||
@ -1201,7 +1226,6 @@ ParseEdidData (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Search a specified Timing in all the valid EDID timings.
|
||||
|
||||
@ -1367,12 +1391,14 @@ BiosVideoCheckForVbe (
|
||||
if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for 'VESA' signature
|
||||
//
|
||||
if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if this is VBE 2.0 or higher
|
||||
//
|
||||
@ -1410,8 +1436,9 @@ BiosVideoCheckForVbe (
|
||||
(UINT8 **)&EdidOverrideDataBlock
|
||||
);
|
||||
if (!EFI_ERROR (Status) &&
|
||||
EdidAttributes == 0 &&
|
||||
EdidOverrideDataSize != 0) {
|
||||
(EdidAttributes == 0) &&
|
||||
(EdidOverrideDataSize != 0))
|
||||
{
|
||||
//
|
||||
// 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,
|
||||
// read EDID information through INT10 call
|
||||
@ -1506,13 +1533,15 @@ BiosVideoCheckForVbe (
|
||||
//
|
||||
for (VbeModeNumber = ReadUnaligned16 (ModeNumberPtr);
|
||||
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.
|
||||
//
|
||||
if ((VbeModeNumber & VESA_BIOS_EXTENSIONS_MODE_NUMBER_VESA) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the information about the mode
|
||||
//
|
||||
@ -1531,24 +1560,28 @@ BiosVideoCheckForVbe (
|
||||
if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -1565,6 +1598,7 @@ BiosVideoCheckForVbe (
|
||||
if ((BiosVideoPrivate->VbeModeInformationBlock->BitsPerPixel % 8) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Video Controller Mode 0x%x: %d x %d\n",
|
||||
VbeModeNumber, BiosVideoPrivate->VbeModeInformationBlock->XResolution, BiosVideoPrivate->VbeModeInformationBlock->YResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Video Controller Mode 0x%x: %d x %d\n",
|
||||
VbeModeNumber,
|
||||
BiosVideoPrivate->VbeModeInformationBlock->XResolution,
|
||||
BiosVideoPrivate->VbeModeInformationBlock->YResolution
|
||||
));
|
||||
|
||||
if (EdidFound && (ValidEdidTiming.ValidNumber > 0)) {
|
||||
//
|
||||
@ -1587,9 +1626,10 @@ BiosVideoCheckForVbe (
|
||||
// but INT10 can support these modes, we add them into GOP mode.
|
||||
//
|
||||
if ((BiosVideoPrivate->EdidDiscovered.SizeOfEdid != 0) &&
|
||||
!((Timing.HorizontalResolution) == 1024 && (Timing.VerticalResolution == 768)) &&
|
||||
!((Timing.HorizontalResolution) == 800 && (Timing.VerticalResolution == 600)) &&
|
||||
!((Timing.HorizontalResolution) == 640 && (Timing.VerticalResolution == 480))) {
|
||||
!(((Timing.HorizontalResolution) == 1024) && (Timing.VerticalResolution == 768)) &&
|
||||
!(((Timing.HorizontalResolution) == 800) && (Timing.VerticalResolution == 600)) &&
|
||||
!(((Timing.HorizontalResolution) == 640) && (Timing.VerticalResolution == 480)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1600,20 +1640,25 @@ BiosVideoCheckForVbe (
|
||||
//
|
||||
ModeFound = FALSE;
|
||||
|
||||
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024 &&
|
||||
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768
|
||||
) {
|
||||
if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 1024) &&
|
||||
(BiosVideoPrivate->VbeModeInformationBlock->YResolution == 768)
|
||||
)
|
||||
{
|
||||
ModeFound = TRUE;
|
||||
}
|
||||
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800 &&
|
||||
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600
|
||||
) {
|
||||
|
||||
if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 800) &&
|
||||
(BiosVideoPrivate->VbeModeInformationBlock->YResolution == 600)
|
||||
)
|
||||
{
|
||||
ModeFound = TRUE;
|
||||
PreferMode = ModeNumber;
|
||||
}
|
||||
if (BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640 &&
|
||||
BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480
|
||||
) {
|
||||
|
||||
if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution == 640) &&
|
||||
(BiosVideoPrivate->VbeModeInformationBlock->YResolution == 480)
|
||||
)
|
||||
{
|
||||
ModeFound = TRUE;
|
||||
}
|
||||
|
||||
@ -1629,7 +1674,8 @@ BiosVideoCheckForVbe (
|
||||
//
|
||||
if ((BiosVideoPrivate->VbeModeInformationBlock->XResolution > HighestHorizontalResolution) ||
|
||||
((BiosVideoPrivate->VbeModeInformationBlock->XResolution == HighestHorizontalResolution) &&
|
||||
(BiosVideoPrivate->VbeModeInformationBlock->YResolution > HighestVerticalResolution))) {
|
||||
(BiosVideoPrivate->VbeModeInformationBlock->YResolution > HighestVerticalResolution)))
|
||||
{
|
||||
HighestHorizontalResolution = BiosVideoPrivate->VbeModeInformationBlock->XResolution;
|
||||
HighestVerticalResolution = BiosVideoPrivate->VbeModeInformationBlock->YResolution;
|
||||
HighestResolutionMode = ModeNumber;
|
||||
@ -1685,7 +1731,8 @@ BiosVideoCheckForVbe (
|
||||
|
||||
CurrentModeData->PixelFormat = PixelBitMask;
|
||||
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)) {
|
||||
CurrentModeData->PixelFormat = PixelRedGreenBlueReserved8BitPerColor;
|
||||
} else if ((CurrentModeData->Blue.Position == 0) && (CurrentModeData->Green.Position == 8) && (CurrentModeData->Red.Position == 16)) {
|
||||
@ -1711,6 +1758,7 @@ BiosVideoCheckForVbe (
|
||||
|
||||
BiosVideoPrivate->ModeData = ModeBuffer;
|
||||
}
|
||||
|
||||
//
|
||||
// Check to see if we found any modes that are compatible with GRAPHICS OUTPUT
|
||||
//
|
||||
@ -1737,11 +1785,16 @@ BiosVideoCheckForVbe (
|
||||
DEBUG_CODE (
|
||||
BIOS_VIDEO_MODE_DATA *ModeData;
|
||||
ModeData = &BiosVideoPrivate->ModeData[HighestResolutionMode];
|
||||
DEBUG ((DEBUG_INFO, "BiosVideo set highest resolution %d x %d\n",
|
||||
ModeData->HorizontalResolution, ModeData->VerticalResolution));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"BiosVideo set highest resolution %d x %d\n",
|
||||
ModeData->HorizontalResolution,
|
||||
ModeData->VerticalResolution
|
||||
));
|
||||
);
|
||||
PreferMode = HighestResolutionMode;
|
||||
}
|
||||
|
||||
Status = BiosVideoGraphicsOutputSetMode (&BiosVideoPrivate->GraphicsOutput, (UINT32)PreferMode);
|
||||
if (EFI_ERROR (Status)) {
|
||||
for (PreferMode = 0; PreferMode < ModeNumber; PreferMode++) {
|
||||
@ -1753,6 +1806,7 @@ BiosVideoCheckForVbe (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (PreferMode == ModeNumber) {
|
||||
//
|
||||
// None mode is set successfully.
|
||||
@ -1771,6 +1825,7 @@ Done:
|
||||
BiosVideoPrivate->ModeData = NULL;
|
||||
BiosVideoPrivate->MaxMode = 0;
|
||||
}
|
||||
|
||||
if (EdidOverrideDataBlock != NULL) {
|
||||
FreePool (EdidOverrideDataBlock);
|
||||
}
|
||||
@ -1779,7 +1834,6 @@ Done:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check for VGA device.
|
||||
|
||||
@ -1845,15 +1899,18 @@ Done:
|
||||
FreePool (BiosVideoPrivate->ModeData);
|
||||
BiosVideoPrivate->ModeData = NULL;
|
||||
}
|
||||
|
||||
if (BiosVideoPrivate->GraphicsOutput.Mode != NULL) {
|
||||
if (BiosVideoPrivate->GraphicsOutput.Mode->Info != NULL) {
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode->Info);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode->Info = NULL;
|
||||
}
|
||||
|
||||
FreePool (BiosVideoPrivate->GraphicsOutput.Mode);
|
||||
BiosVideoPrivate->GraphicsOutput.Mode = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -1901,7 +1958,7 @@ BiosVideoGraphicsOutputQueryMode (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1967,6 +2024,7 @@ BiosVideoSetModeWorker (
|
||||
if (NULL == BiosVideoPrivate->LineBuffer) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Clear all registers
|
||||
//
|
||||
@ -1980,12 +2038,12 @@ BiosVideoSetModeWorker (
|
||||
if (NULL == BiosVideoPrivate->VgaFrameBuffer) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Set VGA Mode
|
||||
//
|
||||
Regs.X.AX = ModeData->VbeModeNumber;
|
||||
BiosVideoPrivate->LegacyBios->Int86 (BiosVideoPrivate->LegacyBios, 0x10, &Regs);
|
||||
|
||||
} else {
|
||||
//
|
||||
// Allocate a working buffer for BLT operations to the VBE frame buffer
|
||||
@ -1997,6 +2055,7 @@ BiosVideoSetModeWorker (
|
||||
if (NULL == BiosVideoPrivate->VbeFrameBuffer) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Set VBE mode
|
||||
//
|
||||
@ -2018,6 +2077,7 @@ BiosVideoSetModeWorker (
|
||||
);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the state of the VbeFrameBuffer
|
||||
//
|
||||
@ -2291,9 +2351,10 @@ BiosVideoVbeBltWorker (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Width == 0 || Height == 0) {
|
||||
if ((Width == 0) || (Height == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -2322,6 +2383,7 @@ BiosVideoVbeBltWorker (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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,
|
||||
@ -2330,6 +2392,7 @@ BiosVideoVbeBltWorker (
|
||||
if (Delta == 0) {
|
||||
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 would not want a timer based event (Cursor, ...) to come in while we are
|
||||
@ -2354,8 +2417,8 @@ BiosVideoVbeBltWorker (
|
||||
Blt++;
|
||||
VbeBuffer += VbePixelWidth;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EfiBltVideoToVideo:
|
||||
@ -2391,6 +2454,7 @@ BiosVideoVbeBltWorker (
|
||||
BytesPerScanLine
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EfiBltVideoFill:
|
||||
@ -2439,6 +2503,7 @@ BiosVideoVbeBltWorker (
|
||||
BytesPerScanLine
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EfiBltBufferToVideo:
|
||||
@ -2477,6 +2542,7 @@ BiosVideoVbeBltWorker (
|
||||
BytesPerScanLine
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:;
|
||||
@ -2583,7 +2649,6 @@ WriteGraphicsController (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read the four bit plane of VGA frame buffer.
|
||||
|
||||
@ -2624,7 +2689,8 @@ VgaReadBitPlanes (
|
||||
for (BitPlane = 0, FrameBufferOffset = 0;
|
||||
BitPlane < VGA_NUMBER_OF_BIT_PLANES;
|
||||
BitPlane++, FrameBufferOffset += VGA_BYTES_PER_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.
|
||||
|
||||
@ -2708,7 +2773,6 @@ VgaConvertColor (
|
||||
return Color;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Grahpics Output protocol instance to block transfer for VGA device.
|
||||
|
||||
@ -2780,7 +2844,7 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
UINTN CoordinateY;
|
||||
UINTN CurrentMode;
|
||||
|
||||
if (This == NULL || ((UINTN) BltOperation) >= EfiGraphicsOutputBltOperationMax) {
|
||||
if ((This == NULL) || (((UINTN)BltOperation) >= EfiGraphicsOutputBltOperationMax)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -2792,10 +2856,10 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
BytesPerScanLine = BiosVideoPrivate->ModeData[CurrentMode].BytesPerScanLine >> 3;
|
||||
VgaFrameBuffer = BiosVideoPrivate->VgaFrameBuffer;
|
||||
|
||||
|
||||
if (Width == 0 || Height == 0) {
|
||||
if ((Width == 0) || (Height == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -2824,6 +2888,7 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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,
|
||||
@ -2832,6 +2897,7 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
if (Delta == 0) {
|
||||
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 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
|
||||
//
|
||||
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
|
||||
//
|
||||
@ -3053,6 +3119,7 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case EfiBltBufferToVideo:
|
||||
@ -3081,6 +3148,7 @@ BiosVideoGraphicsOutputVgaBlt (
|
||||
for (Index1 = 0; Index1 < Width; Index1++) {
|
||||
BiosVideoPrivate->LineBuffer[Index1] = VgaConvertColor (&BltBuffer[(SourceY + Index) * (Delta >> 2) + SourceX + Index1]);
|
||||
}
|
||||
|
||||
AddressFix = Address;
|
||||
|
||||
for (Bit = 0; Bit < 8; Bit++) {
|
||||
@ -3168,6 +3236,7 @@ BiosVideoVgaMiniPortSetMode (
|
||||
if (ModeNumber >= This->MaxMode) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the device structure for this device
|
||||
//
|
||||
|
@ -164,7 +164,6 @@ BiosVideoDriverBindingSupported (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Install Graphics Output Protocol onto VGA device handles.
|
||||
|
||||
@ -184,7 +183,6 @@ BiosVideoDriverBindingStart (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Stop.
|
||||
|
||||
@ -223,7 +221,6 @@ BiosVideoCheckForVbe (
|
||||
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Check for VGA device.
|
||||
|
||||
@ -237,9 +234,6 @@ BiosVideoCheckForVga (
|
||||
IN OUT BIOS_VIDEO_DEV *BiosVideoPrivate
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Release resource for BIOS video instance.
|
||||
|
||||
@ -282,7 +276,6 @@ BiosVideoGraphicsOutputQueryMode (
|
||||
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Graphics Output protocol interface to set video mode.
|
||||
|
||||
@ -302,7 +295,6 @@ BiosVideoGraphicsOutputSetMode (
|
||||
IN UINT32 ModeNumber
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Graphics Output protocol instance to block transfer for VBE device.
|
||||
|
||||
@ -345,7 +337,6 @@ BiosVideoGraphicsOutputVbeBlt (
|
||||
IN UINTN Delta
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Graphics Output protocol instance to block transfer for VGA device.
|
||||
|
||||
@ -529,4 +520,5 @@ BOOLEAN
|
||||
HasChildHandle (
|
||||
IN EFI_HANDLE Controller
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
// EFI Component Name Functions
|
||||
//
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the driver.
|
||||
|
||||
@ -58,7 +59,6 @@ BiosVideoComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@ -137,7 +137,6 @@ BiosVideoComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
@ -156,7 +155,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gBiosVideoComponentNa
|
||||
"en"
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mBiosVideoDriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
|
@ -29,4 +29,3 @@ CsmSupportLibConstructor (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -46,4 +46,3 @@ LegacyBiosPlatformInstall (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -31,7 +31,6 @@ STATIC EFI_LEGACY_INTERRUPT_PROTOCOL mLegacyInterrupt = {
|
||||
|
||||
STATIC UINT8 PirqReg[MAX_PIRQ_NUMBER] = { PIRQA, PIRQB, PIRQC, PIRQD, PIRQE, PIRQF, PIRQG, PIRQH };
|
||||
|
||||
|
||||
/**
|
||||
Return the number of PIRQs supported by this chipset.
|
||||
|
||||
@ -53,7 +52,6 @@ GetNumberPirqs (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return PCI location of this device.
|
||||
$PIR table requires this info.
|
||||
@ -82,7 +80,6 @@ GetLocation (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builds the PCI configuration address for the register specified by PirqNumber
|
||||
|
||||
@ -132,7 +129,6 @@ ReadPirq (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write the given PIRQ register
|
||||
|
||||
@ -160,7 +156,6 @@ WritePirq (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize Legacy Interrupt support
|
||||
|
||||
@ -192,8 +187,12 @@ LegacyInterruptInstall (
|
||||
mLegacyInterruptDevice = LEGACY_INT_DEV_Q35;
|
||||
break;
|
||||
default:
|
||||
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__, HostBridgeDevId));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__,
|
||||
HostBridgeDevId
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -211,4 +210,3 @@ LegacyInterruptInstall (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <OvmfPlatforms.h>
|
||||
|
||||
|
||||
#define LEGACY_INT_BUS 0
|
||||
#define LEGACY_INT_DEV_PIIX4 0x01
|
||||
#define LEGACY_INT_DEV_Q35 0x1f
|
||||
@ -114,4 +113,3 @@ WritePirq (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -76,12 +76,24 @@ EFI_LEGACY_PIRQ_TABLE PirqTableHead = {
|
||||
// -- Pin 1 -- -- Pin 2 -- -- Pin 3 -- -- Pin 4 --
|
||||
// Bus Dev Reg Map Reg Map Reg Map Reg Map
|
||||
//
|
||||
{0x00,0x08,{{0x60,0xDEB8},{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8}},0x00,0x00},
|
||||
{0x00,0x10,{{0x61,0xDEB8},{0x62,0xDEB8},{0x63,0xDEB8},{0x60,0xDEB8}},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},
|
||||
{ 0x00, 0x08, {
|
||||
{ 0x60, 0xDEB8 }, { 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }
|
||||
}, 0x00, 0x00 },
|
||||
{ 0x00, 0x10, {
|
||||
{ 0x61, 0xDEB8 }, { 0x62, 0xDEB8 }, { 0x63, 0xDEB8 }, { 0x60, 0xDEB8 }
|
||||
}, 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++) {
|
||||
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,
|
||||
HandleBuffer[Index],
|
||||
@ -173,7 +186,8 @@ FindAllDeviceTypes (
|
||||
if (
|
||||
((DeviceFlags != 0) && (Flags == NO_ROM)) ||
|
||||
((Flags & (ROM_FOUND | VALID_LEGACY_ROM)) == (ROM_FOUND | VALID_LEGACY_ROM))
|
||||
) {
|
||||
)
|
||||
{
|
||||
DeviceTable->Handle = HandleBuffer[Index];
|
||||
DeviceTable->Vid = PciConfigHeader.Hdr.VendorId;
|
||||
DeviceTable->Did = PciConfigHeader.Hdr.DeviceId;
|
||||
@ -285,7 +299,7 @@ GetSelectedVgaDeviceInfo (
|
||||
// Determine if this is in the correct bus range.
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
@ -309,7 +323,9 @@ GetSelectedVgaDeviceInfo (
|
||||
if (!IS_PCI_VGA (&Pci)) {
|
||||
continue;
|
||||
}
|
||||
DEBUG ((DEBUG_INFO,
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"PCI VGA: 0x%04x:0x%04x\n",
|
||||
Pci.Hdr.VendorId,
|
||||
Pci.Hdr.DeviceId
|
||||
@ -330,7 +346,6 @@ GetSelectedVgaDeviceInfo (
|
||||
FreePool (HandleBuffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns a buffer of handles for the requested subfunction.
|
||||
|
||||
@ -449,7 +464,7 @@ GetPlatformHandle (
|
||||
//
|
||||
PriorityIndex = 0;
|
||||
for (Index = 0; Index < LocalIndex; Index++) {
|
||||
if (LocalDevice[Index].Handle == IdeHandle && PriorityIndex == 0) {
|
||||
if ((LocalDevice[Index].Handle == IdeHandle) && (PriorityIndex == 0)) {
|
||||
TempDevice = LocalDevice[PriorityIndex];
|
||||
LocalDevice[PriorityIndex] = LocalDevice[Index];
|
||||
LocalDevice[Index] = TempDevice;
|
||||
@ -464,6 +479,7 @@ GetPlatformHandle (
|
||||
for (Index = 0; Index < LocalIndex; Index++) {
|
||||
mDiskHandles[Index] = LocalDevice[Index].Handle;
|
||||
}
|
||||
|
||||
*HandleBuffer = &mDiskHandles[0];
|
||||
*HandleCount = LocalIndex;
|
||||
|
||||
@ -477,7 +493,8 @@ GetPlatformHandle (
|
||||
//
|
||||
for (Index = 0; (Index < LocalIndex) && (AdditionalData != NULL); Index++) {
|
||||
if ((LocalDevice[Index].Handle != NULL) &&
|
||||
(LocalDevice[Index].Handle == IdeHandle)) {
|
||||
(LocalDevice[Index].Handle == IdeHandle))
|
||||
{
|
||||
Status = gBS->HandleProtocol (
|
||||
LocalDevice[Index].Handle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@ -529,6 +546,7 @@ GetPlatformHandle (
|
||||
HddInfo[HddIndex].ControlBaseAddress = 0x3f6;
|
||||
HddInfo[HddIndex].BusMasterAddress = 0;
|
||||
}
|
||||
|
||||
HddIndex++;
|
||||
|
||||
//
|
||||
@ -548,10 +566,12 @@ GetPlatformHandle (
|
||||
HddInfo[HddIndex].ControlBaseAddress = 0x376;
|
||||
HddInfo[HddIndex].BusMasterAddress = 0;
|
||||
}
|
||||
|
||||
HddIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
case EfiGetPlatformIsaBusHandle:
|
||||
ClassLists[0].Class = (UINT8)PCI_CLASS_BRIDGE;
|
||||
@ -585,13 +605,14 @@ GetPlatformHandle (
|
||||
for (Index = 0; Index < LocalIndex; Index++) {
|
||||
mIsaHandles[Index] = LocalDevice[Index].Handle;
|
||||
}
|
||||
|
||||
*HandleBuffer = &mIsaHandles[0];
|
||||
*HandleCount = LocalIndex;
|
||||
return EFI_SUCCESS;
|
||||
case EfiGetPlatformUsbHandle:
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -646,7 +667,7 @@ PlatformHooks (
|
||||
case EfiPlatformHookAfterRomInit:
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -724,6 +745,7 @@ GetRoutingTable (
|
||||
Checksum = (UINT8)(Checksum + (UINT8)*Ptr);
|
||||
Ptr += 1;
|
||||
}
|
||||
|
||||
Checksum = (UINT8)(0x00 - Checksum);
|
||||
PirqTableHead.PirqTable.Checksum = Checksum;
|
||||
|
||||
@ -796,6 +818,7 @@ GetPlatformInfo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -808,7 +831,7 @@ GetPlatformInfo (
|
||||
case EfiGetPlatformPciExpressBase:
|
||||
default:
|
||||
return EFI_UNSUPPORTED;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -856,7 +879,8 @@ TranslatePirq (
|
||||
|
||||
for (Index = 0; Index < MAX_IRQ_ROUTING_ENTRIES; Index++) {
|
||||
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);
|
||||
if (LocalPirq > 4) {
|
||||
LocalPirq -= 4;
|
||||
@ -867,7 +891,8 @@ TranslatePirq (
|
||||
while (PirqData == 0) {
|
||||
for (Index1 = 0; Index1 < MAX_IRQ_PRIORITY_ENTRIES; Index1++) {
|
||||
if ((IrqPriorityTable[Index1].Used == MatchData) &&
|
||||
(IrqPriorityTable[Index1].Irq != 0)) {
|
||||
(IrqPriorityTable[Index1].Irq != 0))
|
||||
{
|
||||
PirqData = IrqPriorityTable[Index1].Irq;
|
||||
IrqPriorityTable[Index1].Used = 0xff;
|
||||
LegacyInterrupt->WritePirq (
|
||||
@ -880,7 +905,6 @@ TranslatePirq (
|
||||
}
|
||||
|
||||
if (PirqData == 0) {
|
||||
|
||||
//
|
||||
// No unused interrupts, so start reusing them.
|
||||
//
|
||||
@ -896,7 +920,6 @@ TranslatePirq (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Attempt to legacy boot the BootOption. If the EFI contexted has been
|
||||
compromised this function will not return.
|
||||
@ -966,7 +989,8 @@ PrepareToBoot (
|
||||
if ((LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&
|
||||
(LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY) &&
|
||||
(LocalBbsTable[Index].BootPriority != BBS_LOWEST_PRIORITY) &&
|
||||
(Priority <= LocalBbsTable[Index].BootPriority)) {
|
||||
(Priority <= LocalBbsTable[Index].BootPriority))
|
||||
{
|
||||
Priority = (UINT16)(LocalBbsTable[Index].BootPriority + 1);
|
||||
}
|
||||
}
|
||||
@ -978,28 +1002,32 @@ PrepareToBoot (
|
||||
case BBS_EMBED_NETWORK:
|
||||
for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) {
|
||||
if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) &&
|
||||
(LocalBbsTable[Index].DeviceType == DevicePathType)) {
|
||||
(LocalBbsTable[Index].DeviceType == DevicePathType))
|
||||
{
|
||||
LocalBbsTable[Index].BootPriority = Priority;
|
||||
++Priority;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case BBS_BEV_DEVICE:
|
||||
for (Index = 0; Index < Legacy16BootTable->NumberBbsEntries; Index++) {
|
||||
if ((LocalBbsTable[Index].BootPriority == BBS_UNPRIORITIZED_ENTRY) &&
|
||||
(LocalBbsTable[Index].Class == 01) &&
|
||||
(LocalBbsTable[Index].SubClass == 01)) {
|
||||
(LocalBbsTable[Index].SubClass == 01))
|
||||
{
|
||||
LocalBbsTable[Index].BootPriority = Priority;
|
||||
++Priority;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case BBS_USB:
|
||||
case BBS_PCMCIA:
|
||||
case BBS_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// Set priority for rest of devices
|
||||
@ -1014,7 +1042,6 @@ PrepareToBoot (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize Legacy Platform support
|
||||
|
||||
|
@ -95,4 +95,3 @@ typedef struct {
|
||||
)
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -112,11 +112,12 @@ LegacyRegionManipulationInternal (
|
||||
//
|
||||
// Validate input parameters.
|
||||
//
|
||||
if (Length == 0 || Granularity == NULL) {
|
||||
if ((Length == 0) || (Granularity == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -130,6 +131,7 @@ LegacyRegionManipulationInternal (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (Index < ARRAY_SIZE (mSectionArray));
|
||||
|
||||
//
|
||||
@ -149,6 +151,7 @@ LegacyRegionManipulationInternal (
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (WriteEnable != NULL) {
|
||||
if (*WriteEnable) {
|
||||
PciOr8 (
|
||||
@ -171,6 +174,7 @@ LegacyRegionManipulationInternal (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (Index < ARRAY_SIZE (mSectionArray));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -189,7 +193,7 @@ LegacyRegionGetInfoInternal (
|
||||
//
|
||||
// Check input parameters
|
||||
//
|
||||
if (DescriptorCount == NULL || Descriptor == NULL) {
|
||||
if ((DescriptorCount == NULL) || (Descriptor == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -203,6 +207,7 @@ LegacyRegionGetInfoInternal (
|
||||
if ((PamValue & mRegisterValues[Index].ReadEnableData) != 0) {
|
||||
mSectionArray[Index].ReadEnabled = TRUE;
|
||||
}
|
||||
|
||||
mSectionArray[Index].WriteEnabled = FALSE;
|
||||
if ((PamValue & mRegisterValues[Index].WriteEnableData) != 0) {
|
||||
mSectionArray[Index].WriteEnabled = TRUE;
|
||||
@ -250,7 +255,6 @@ LegacyRegion2Decode (
|
||||
return LegacyRegionManipulationInternal (Start, Length, On, NULL, Granularity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Modify the hardware to disallow memory attribute changes in a region.
|
||||
|
||||
@ -292,7 +296,6 @@ LegacyRegion2BootLock (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Modify the hardware to disallow memory writes in a region.
|
||||
|
||||
@ -328,7 +331,6 @@ LegacyRegion2Lock (
|
||||
return LegacyRegionManipulationInternal (Start, Length, NULL, &WriteEnable, Granularity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Modify the hardware to allow memory writes in a region.
|
||||
|
||||
@ -420,6 +422,7 @@ LegacyRegionGetInfo (
|
||||
} else {
|
||||
DescriptorArray[DescriptorIndex].Attribute = LegacyRegionNotDecoded;
|
||||
}
|
||||
|
||||
DescriptorIndex++;
|
||||
|
||||
//
|
||||
@ -433,6 +436,7 @@ LegacyRegionGetInfo (
|
||||
} else {
|
||||
DescriptorArray[DescriptorIndex].Attribute = LegacyRegionWriteDisabled;
|
||||
}
|
||||
|
||||
DescriptorIndex++;
|
||||
|
||||
//
|
||||
@ -477,8 +481,12 @@ LegacyRegionInit (
|
||||
mRegisterValues = mRegisterValuesQ35;
|
||||
break;
|
||||
default:
|
||||
DEBUG ((DEBUG_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__, HostBridgeDevId));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Unknown Host Bridge Device ID: 0x%04x\n",
|
||||
__FUNCTION__,
|
||||
HostBridgeDevId
|
||||
));
|
||||
ASSERT (FALSE);
|
||||
return RETURN_UNSUPPORTED;
|
||||
}
|
||||
@ -488,11 +496,11 @@ LegacyRegionInit (
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&mHandle,
|
||||
&gEfiLegacyRegion2ProtocolGuid, &mLegacyRegion2,
|
||||
&gEfiLegacyRegion2ProtocolGuid,
|
||||
&mLegacyRegion2,
|
||||
NULL
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -200,4 +200,3 @@ LegacyRegionGetInfo (
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -37,5 +37,4 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
///
|
||||
#define FRAMEWORK_EFI_BOOT_SCRIPT_TERMINATE_OPCODE 0xFF
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -167,4 +167,3 @@ typedef struct {
|
||||
#define EFI_EVENT_SIGNAL_LEGACY_BOOT 0x00000204
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -96,7 +96,6 @@ typedef UINT16 STRING_REF;
|
||||
///
|
||||
#define EFI_IFR_FLAG_CREATED 128
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
//
|
||||
// IFR Structure definitions
|
||||
|
@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _FIRMWARE_VOLUME_H_
|
||||
#define _FIRMWARE_VOLUME_H_
|
||||
|
||||
|
||||
//
|
||||
// Firmware Volume Protocol GUID definition
|
||||
//
|
||||
|
@ -363,7 +363,6 @@ typedef enum {
|
||||
Legacy16InstallPciHandler = 0x0008
|
||||
} EFI_COMPATIBILITY_FUNCTIONS;
|
||||
|
||||
|
||||
///
|
||||
/// EFI_DISPATCH_OPROM_TABLE
|
||||
///
|
||||
@ -382,7 +381,6 @@ typedef struct {
|
||||
///< Inconsistent with specification here:
|
||||
///< 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.
|
||||
|
||||
} EFI_DISPATCH_OPROM_TABLE;
|
||||
|
||||
///
|
||||
|
@ -496,7 +496,6 @@ typedef struct {
|
||||
UINT8 Checksum;
|
||||
} EFI_LEGACY_PIRQ_TABLE_HEADER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
///
|
||||
/// If nonzero, a value assigned by the IBV.
|
||||
@ -533,7 +532,6 @@ typedef struct {
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
/**
|
||||
Finds the binary data or other platform information.
|
||||
|
||||
|
@ -13,7 +13,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _EFI_LEGACY_INTERRUPT_H_
|
||||
#define _EFI_LEGACY_INTERRUPT_H_
|
||||
|
||||
|
||||
#define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \
|
||||
{ \
|
||||
0x31ce593d, 0x108a, 0x485d, {0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe } \
|
||||
|
@ -85,6 +85,7 @@ HasMediaInFloppy (
|
||||
if (IsaIo->ResourceList->Device.HID != EISA_PNP_ID (0x604)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Update blockio in case the floppy is inserted in during BdsTimeout
|
||||
//
|
||||
@ -121,10 +122,8 @@ HasMediaInFloppy (
|
||||
FreePool (HandleBuffer);
|
||||
|
||||
return FLOPPY_NOT_PRESENT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Complete build of BBS TABLE.
|
||||
|
||||
@ -196,10 +195,8 @@ LegacyBiosBuildBbs (
|
||||
LegacyBiosBuildIdeData (Private, &HddInfo, 0);
|
||||
|
||||
for (HddIndex = 0; HddIndex < MAX_IDE_CONTROLLER; HddIndex++) {
|
||||
|
||||
BbsIndex = HddIndex * 2 + 1;
|
||||
for (Index = 0; Index < 2; ++Index) {
|
||||
|
||||
BbsTable[BbsIndex + Index].Bus = HddInfo[HddIndex].Bus;
|
||||
BbsTable[BbsIndex + Index].Device = HddInfo[HddIndex].Device;
|
||||
BbsTable[BbsIndex + Index].Function = HddInfo[HddIndex].Function;
|
||||
@ -324,12 +321,15 @@ LegacyBiosBuildBbs (
|
||||
//
|
||||
DevicePathNode = DevicePath;
|
||||
while (!IsDevicePathEnd (DevicePathNode)) {
|
||||
if (DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH &&
|
||||
DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP) {
|
||||
if ((DevicePathType (DevicePathNode) == MESSAGING_DEVICE_PATH) &&
|
||||
(DevicePathSubType (DevicePathNode) == MSG_ATAPI_DP))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
DevicePathNode = NextDevicePathNode (DevicePathNode);
|
||||
}
|
||||
|
||||
if (!IsDevicePathEnd (DevicePathNode)) {
|
||||
continue;
|
||||
}
|
||||
@ -367,13 +367,21 @@ LegacyBiosBuildBbs (
|
||||
}
|
||||
|
||||
if (SegNum != 0) {
|
||||
DEBUG ((DEBUG_WARN, "CSM cannot use PCI devices in segment %Lu\n",
|
||||
(UINT64) SegNum));
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"CSM cannot use PCI devices in segment %Lu\n",
|
||||
(UINT64)SegNum
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Add Legacy Bbs entry for PCI %d/%d/%d\n",
|
||||
BusNum, DevNum, FuncNum));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Add Legacy Bbs entry for PCI %d/%d/%d\n",
|
||||
BusNum,
|
||||
DevNum,
|
||||
FuncNum
|
||||
));
|
||||
|
||||
BbsTable[BbsIndex].Bus = BusNum;
|
||||
BbsTable[BbsIndex].Device = DevNum;
|
||||
@ -403,7 +411,6 @@ LegacyBiosBuildBbs (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get all BBS info
|
||||
|
||||
@ -475,7 +482,6 @@ LegacyBiosGetBbsInfo (
|
||||
// PCI bus driver enumerate all subsequent handles
|
||||
//
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
|
||||
|
||||
}
|
||||
|
||||
LegacyBiosBuildBbs (Private, mBbsTable);
|
||||
|
@ -81,13 +81,14 @@ AllocateLegacyMemory (
|
||||
// Make sure that the buffer can be used to store code.
|
||||
//
|
||||
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 (
|
||||
MemPage,
|
||||
EFI_PAGES_TO_SIZE (Pages),
|
||||
MemDesc.Attributes & (~EFI_MEMORY_XP)
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePages (MemPage, Pages);
|
||||
}
|
||||
@ -101,7 +102,6 @@ AllocateLegacyMemory (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is called when EFI needs to reserve an area in the 0xE0000 or 0xF0000
|
||||
64 KB blocks.
|
||||
@ -133,7 +133,6 @@ LegacyBiosGetLegacyRegion (
|
||||
OUT VOID **LegacyMemoryAddress
|
||||
)
|
||||
{
|
||||
|
||||
LEGACY_BIOS_INSTANCE *Private;
|
||||
EFI_IA32_REGISTER_SET Regs;
|
||||
EFI_STATUS Status;
|
||||
@ -169,7 +168,6 @@ LegacyBiosGetLegacyRegion (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is called when copying data to the region assigned by
|
||||
EFI_LEGACY_BIOS_PROTOCOL.GetLegacyRegion().
|
||||
@ -193,15 +191,16 @@ LegacyBiosCopyLegacyRegion (
|
||||
IN VOID *LegacyMemorySourceAddress
|
||||
)
|
||||
{
|
||||
|
||||
LEGACY_BIOS_INSTANCE *Private;
|
||||
UINT32 Granularity;
|
||||
|
||||
if ((LegacyMemoryAddress < (VOID *)(UINTN)0xE0000) ||
|
||||
((UINTN)LegacyMemoryAddress + LegacyMemorySize > (UINTN)0x100000)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
//
|
||||
// There is no protection from writes over lapping if this function is
|
||||
// called multiple times.
|
||||
@ -216,7 +215,6 @@ LegacyBiosCopyLegacyRegion (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -488,6 +486,7 @@ ShadowAndStartLegacy16 (
|
||||
TempData = Table->E820Pointer;
|
||||
CopyMem ((VOID *)TempData, Private->E820Table, E820Size);
|
||||
}
|
||||
|
||||
//
|
||||
// Get PnPInstallationCheck Info.
|
||||
//
|
||||
@ -511,6 +510,7 @@ ShadowAndStartLegacy16 (
|
||||
Private->Legacy16Table->PciExpressBase = (UINT32)Location;
|
||||
Location = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -527,7 +527,6 @@ ShadowAndStartLegacy16 (
|
||||
0
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
|
||||
Regs.X.AX = Legacy16GetTableAddress;
|
||||
Regs.X.CX = (UINT16)TpmBinaryImageSize;
|
||||
@ -548,9 +547,9 @@ ShadowAndStartLegacy16 (
|
||||
CopyMem ((VOID *)(UINTN)TpmPointer, TpmBinaryImage, TpmBinaryImageSize);
|
||||
Table->TpmSegment = Regs.X.DS;
|
||||
Table->TpmOffset = Regs.X.BX;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//
|
||||
// Lock the Legacy BIOS region
|
||||
//
|
||||
@ -574,6 +573,7 @@ ShadowAndStartLegacy16 (
|
||||
for (Index = 0; Index < MAX_BBS_ENTRIES; Index++) {
|
||||
BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate space for Legacy HDD table
|
||||
//
|
||||
@ -684,6 +684,7 @@ GetPciInterfaceVersion (
|
||||
PciInterfaceVersion = Reg.X.BX;
|
||||
}
|
||||
}
|
||||
|
||||
return PciInterfaceVersion;
|
||||
}
|
||||
|
||||
@ -738,11 +739,13 @@ InstallSmbiosEventCallback (
|
||||
mReserveSmbiosEntryPoint = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Entry Point Structure\n"));
|
||||
}
|
||||
|
||||
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
|
||||
//
|
||||
@ -775,6 +778,7 @@ InstallSmbiosEventCallback (
|
||||
mStructureTablePages = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Allocate memory for Smbios Structure Table\n"));
|
||||
}
|
||||
}
|
||||
@ -904,6 +908,7 @@ LegacyBiosInstall (
|
||||
StartAddress = Descriptor.BaseAddress + Descriptor.Length;
|
||||
continue;
|
||||
}
|
||||
|
||||
Length = MIN (Descriptor.Length, 0xa0000 - StartAddress);
|
||||
Private->GenericMemoryTest->CompatibleRangeTest (
|
||||
Private->GenericMemoryTest,
|
||||
@ -912,6 +917,7 @@ LegacyBiosInstall (
|
||||
);
|
||||
StartAddress = StartAddress + Length;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
continue;
|
||||
}
|
||||
|
||||
Length = MIN (Descriptor.Length, BASE_16MB - StartAddress);
|
||||
Private->GenericMemoryTest->CompatibleRangeTest (
|
||||
Private->GenericMemoryTest,
|
||||
@ -1121,6 +1128,7 @@ LegacyBiosInstall (
|
||||
&MemoryAddress
|
||||
);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
EfiToLegacy16InitTable->HiPmmMemory = (UINT32)(EFI_PHYSICAL_ADDRESS)(UINTN)MemoryAddress;
|
||||
EfiToLegacy16InitTable->HiPmmMemorySizeInBytes = MemorySize;
|
||||
@ -1135,6 +1143,7 @@ LegacyBiosInstall (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize interrupt redirection code and entries;
|
||||
// IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f.
|
||||
@ -1155,6 +1164,7 @@ LegacyBiosInstall (
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
BaseVectorMaster[Index] = (EFI_SEGMENT (IntRedirCode + Index * 4) << 16) | EFI_OFFSET (IntRedirCode + Index * 4);
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
//
|
||||
@ -1206,7 +1216,9 @@ LegacyBiosInstall (
|
||||
);
|
||||
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
|
||||
));
|
||||
|
@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _LEGACY_BIOS_INTERFACE_
|
||||
#define _LEGACY_BIOS_INTERFACE_
|
||||
|
||||
|
||||
#include <FrameworkDxe.h>
|
||||
#include <IndustryStandard/Pci.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
@ -591,10 +590,8 @@ typedef struct {
|
||||
// CSM16 PCI Interface Version
|
||||
//
|
||||
UINT16 Csm16PciInterfaceVersion;
|
||||
|
||||
} LEGACY_BIOS_INSTANCE;
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/*
|
||||
@ -699,7 +696,6 @@ LegacyBiosInt86 (
|
||||
IN EFI_IA32_REGISTER_SET *Regs
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -729,7 +725,6 @@ LegacyBiosFarCall86 (
|
||||
IN UINTN StackSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Test to see if a legacy PCI ROM exists for this device. Optionally return
|
||||
the Legacy ROM instance for this PCI device.
|
||||
@ -755,7 +750,6 @@ LegacyBiosCheckPciRom (
|
||||
OUT UINTN *Flags
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Assign drive number to legacy HDD drives prior to booting an EFI
|
||||
aware OS so the OS can access drives without an EFI driver.
|
||||
@ -777,7 +771,6 @@ LegacyBiosPrepareToBootEfi (
|
||||
OUT BBS_TABLE **BbsTable
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
To boot from an unconventional device like parties and/or execute
|
||||
HDD diagnostics.
|
||||
@ -803,7 +796,6 @@ LegacyBiosBootUnconventionalDevice (
|
||||
IN VOID *ServiceAreaData
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -844,7 +836,6 @@ LegacyBiosInstallPciRom (
|
||||
OUT UINT32 *RomShadowedSize OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard BDA for Keyboard LEDs
|
||||
|
||||
@ -861,7 +852,6 @@ LegacyBiosUpdateKeyboardLedStatus (
|
||||
IN UINT8 Leds
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get all BBS info
|
||||
|
||||
@ -886,7 +876,6 @@ LegacyBiosGetBbsInfo (
|
||||
OUT BBS_TABLE **BbsTable
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Shadow all legacy16 OPROMs that haven't been shadowed.
|
||||
Warning: Use this with caution. This routine disconnects all EFI
|
||||
@ -904,7 +893,6 @@ LegacyBiosShadowAllLegacyOproms (
|
||||
IN EFI_LEGACY_BIOS_PROTOCOL *This
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Attempt to legacy boot the BootOption. If the EFI contexted has been
|
||||
compromised this function will not return.
|
||||
@ -926,7 +914,6 @@ LegacyBiosLegacyBoot (
|
||||
IN VOID *LoadOptions
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocate memory < 1 MB and copy the thunker code into low memory. Se up
|
||||
all the descriptors.
|
||||
@ -941,7 +928,6 @@ LegacyBiosInitializeThunk (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard BDA and EBDA stuff before Legacy16 load
|
||||
|
||||
@ -955,7 +941,6 @@ LegacyBiosInitBda (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Collect IDE Inquiry data from the IDE disks
|
||||
|
||||
@ -973,7 +958,6 @@ LegacyBiosBuildIdeData (
|
||||
IN UINT16 Flag
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Enable ide controller. This gets disabled when LegacyBoot.c is about
|
||||
to run the Option ROMs.
|
||||
@ -987,7 +971,6 @@ EnableIdeController (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
If the IDE channel is in compatibility (legacy) mode, remove all
|
||||
PCI I/O BAR addresses from the controller.
|
||||
@ -1001,7 +984,6 @@ InitLegacyIdeController (
|
||||
IN EFI_HANDLE IdeController
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -1017,7 +999,6 @@ PciProgramAllInterruptLineRegisters (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Collect EFI Info about legacy devices.
|
||||
|
||||
@ -1031,7 +1012,6 @@ LegacyBiosBuildSioData (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -1048,7 +1028,6 @@ PciShadowRoms (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard BDA and EBDA stuff prior to legacy Boot
|
||||
|
||||
@ -1062,7 +1041,6 @@ LegacyBiosCompleteBdaBeforeBoot (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard CMOS stuff before Legacy16 load
|
||||
|
||||
@ -1076,7 +1054,6 @@ LegacyBiosInitCmos (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard CMOS stuff prior to legacy Boot
|
||||
|
||||
@ -1090,7 +1067,6 @@ LegacyBiosCompleteStandardCmosBeforeBoot (
|
||||
IN LEGACY_BIOS_INSTANCE *Private
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Contains the code that is copied into low memory (below 640K).
|
||||
This code reflects interrupts 0x68-0x6f to interrupts 0x08-0x0f.
|
||||
@ -1105,7 +1081,6 @@ InterruptRedirectionTemplate (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Build the E820 table.
|
||||
|
||||
|
@ -90,8 +90,10 @@ PrintBbsTable (
|
||||
for (SubIndex = 0; String[SubIndex] != 0; SubIndex++) {
|
||||
DEBUG ((DEBUG_INFO, "%c", String[SubIndex]));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, ")"));
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "\n"));
|
||||
}
|
||||
|
||||
@ -177,6 +179,7 @@ PrintPciInterruptRegister (
|
||||
Interrupt
|
||||
);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = PciIo->GetLocation (
|
||||
PciIo,
|
||||
@ -186,11 +189,20 @@ PrintPciInterruptRegister (
|
||||
&Function
|
||||
);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO, " %02x/%02x/%02x 0x%02x 0x%02x\n",
|
||||
Bus, Device, Function, Interrupt[0], Interrupt[1]));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
" %02x/%02x/%02x 0x%02x 0x%02x\n",
|
||||
Bus,
|
||||
Device,
|
||||
Function,
|
||||
Interrupt[0],
|
||||
Interrupt[1]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "\n"));
|
||||
|
||||
if (Handles != NULL) {
|
||||
@ -336,7 +348,6 @@ UpdateSioData (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
IsaIo->Io.Write (IsaIo, EfiIsaIoWidthUint8, 0x64, 1, &Register);
|
||||
|
||||
}
|
||||
|
||||
if (HandleBuffer != NULL) {
|
||||
@ -344,7 +355,6 @@ UpdateSioData (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,6 +376,7 @@ CalculateIdentifyDriveChecksum (
|
||||
{
|
||||
UINTN Index;
|
||||
UINT8 LocalChecksum;
|
||||
|
||||
LocalChecksum = 0;
|
||||
*Checksum = 0;
|
||||
if (IdentifyDriveData[510] != 0xA5) {
|
||||
@ -380,7 +391,6 @@ CalculateIdentifyDriveChecksum (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Identify drive data must be updated to actual parameters before boot.
|
||||
|
||||
@ -411,6 +421,7 @@ UpdateIdentifyDriveData (
|
||||
if (OriginalChecksum != 0) {
|
||||
Status = EFI_SECURITY_VIOLATION;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
to run the Option ROMs.
|
||||
@ -600,8 +610,8 @@ EnableAllControllers (
|
||||
IS_PCI_IDE (&PciConfigHeader) ||
|
||||
IS_PCI_P2P (&PciConfigHeader) ||
|
||||
IS_PCI_P2P_SUB (&PciConfigHeader) ||
|
||||
IS_PCI_LPC (&PciConfigHeader) )) {
|
||||
|
||||
IS_PCI_LPC (&PciConfigHeader)))
|
||||
{
|
||||
PciConfigHeader.Hdr.Command |= 0x1f;
|
||||
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 4, 1, &PciConfigHeader.Hdr.Command);
|
||||
@ -703,6 +713,7 @@ LegacyGetDataOrTable (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Phase 2 Call routine second time with address to allow address adjustment
|
||||
//
|
||||
@ -727,7 +738,6 @@ LegacyGetDataOrTable (
|
||||
|
||||
case EfiGetPlatformBinaryOemIntData:
|
||||
{
|
||||
|
||||
Legacy16Table->OemIntSegment = Regs.X.DS;
|
||||
Legacy16Table->OemIntOffset = Regs.X.BX;
|
||||
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)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Phase 3 Copy table to final location
|
||||
//
|
||||
@ -787,7 +798,8 @@ CreateSmbiosTableInReservedMemory (
|
||||
|
||||
if ((mRuntimeSmbiosEntryPoint == NULL) ||
|
||||
(mReserveSmbiosEntryPoint == 0) ||
|
||||
(mStructureTableAddress == 0)) {
|
||||
(mStructureTableAddress == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -911,6 +923,7 @@ GenericLegacyBoot (
|
||||
IdeController = HandleBuffer[0];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Unlock the Legacy BIOS region
|
||||
//
|
||||
@ -967,6 +980,7 @@ GenericLegacyBoot (
|
||||
if (mReserveSmbiosEntryPoint == 0) {
|
||||
DEBUG ((DEBUG_INFO, "Smbios table is not found!\n"));
|
||||
}
|
||||
|
||||
CreateSmbiosTableInReservedMemory ();
|
||||
EfiToLegacy16BootTable->SmbiosTable = (UINT32)(UINTN)mReserveSmbiosEntryPoint;
|
||||
|
||||
@ -981,12 +995,14 @@ GenericLegacyBoot (
|
||||
&AcpiTable
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// We do not ASSERT if AcpiTable not found. It is possible that a platform does not produce AcpiTable.
|
||||
//
|
||||
if (AcpiTable == NULL) {
|
||||
DEBUG ((DEBUG_INFO, "ACPI table is not found!\n"));
|
||||
}
|
||||
|
||||
EfiToLegacy16BootTable->AcpiTable = (UINT32)(UINTN)AcpiTable;
|
||||
|
||||
//
|
||||
@ -995,7 +1011,6 @@ GenericLegacyBoot (
|
||||
// Rev != 0 Length is UINT32 at offset 20 decimal
|
||||
//
|
||||
if (AcpiTable != NULL) {
|
||||
|
||||
AcpiPtr = AcpiTable;
|
||||
if (*((UINT8 *)AcpiPtr + 15) == 0) {
|
||||
CopySize = 20;
|
||||
@ -1010,6 +1025,7 @@ GenericLegacyBoot (
|
||||
CopySize
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// 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)) {
|
||||
UpdateSioData (Private);
|
||||
}
|
||||
|
||||
//
|
||||
// Setup BDA and EBDA standard areas before Legacy Boot
|
||||
//
|
||||
@ -1130,13 +1147,15 @@ GenericLegacyBoot (
|
||||
for (Index = 0; Index < MAX_IDE_CONTROLLER; Index++) {
|
||||
if ((LocalHddInfo[Index].IdentifyDrive[0].Raw[0] != 0) &&
|
||||
(LocalBbsTable[2 * Index + 1].BootPriority == BBS_IGNORE_ENTRY)
|
||||
) {
|
||||
)
|
||||
{
|
||||
LocalBbsTable[2 * Index + 1].BootPriority = BBS_UNPRIORITIZED_ENTRY;
|
||||
}
|
||||
|
||||
if ((LocalHddInfo[Index].IdentifyDrive[1].Raw[0] != 0) &&
|
||||
(LocalBbsTable[2 * Index + 2].BootPriority == BBS_IGNORE_ENTRY)
|
||||
) {
|
||||
)
|
||||
{
|
||||
LocalBbsTable[2 * Index + 2].BootPriority = BBS_UNPRIORITIZED_ENTRY;
|
||||
}
|
||||
}
|
||||
@ -1164,14 +1183,17 @@ GenericLegacyBoot (
|
||||
for (Index = 0; Index < BbsCount; Index++) {
|
||||
if ((LocalBbsTable[Index].BootPriority != BBS_DO_NOT_BOOT_FROM) &&
|
||||
(LocalBbsTable[Index].BootPriority != BBS_UNPRIORITIZED_ENTRY) &&
|
||||
(LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY)) {
|
||||
(LocalBbsTable[Index].BootPriority != BBS_IGNORE_ENTRY))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == BbsCount) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Let the Legacy16 code know the device path type for legacy boot
|
||||
//
|
||||
@ -1229,6 +1251,7 @@ GenericLegacyBoot (
|
||||
if (Regs.X.AX != 0) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Lock the Legacy BIOS region
|
||||
//
|
||||
@ -1240,13 +1263,18 @@ GenericLegacyBoot (
|
||||
);
|
||||
|
||||
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
|
||||
// account the granularity of the access control.
|
||||
//
|
||||
DEBUG((DEBUG_INFO, "Unlocking UMB RAM region 0x%x-0x%x\n", Private->Legacy16Table->UmaAddress,
|
||||
Private->Legacy16Table->UmaAddress + Private->Legacy16Table->UmaSize));
|
||||
DEBUG ((
|
||||
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,
|
||||
@ -1271,7 +1299,6 @@ GenericLegacyBoot (
|
||||
//
|
||||
EnableAllControllers (Private);
|
||||
if ((mBootMode == BOOT_LEGACY_OS) || (mBootMode == BOOT_UNCONVENTIONAL_DEVICE)) {
|
||||
|
||||
//
|
||||
// Signal all the events that are waiting on EVT_SIGNAL_LEGACY_BOOT
|
||||
//
|
||||
@ -1297,7 +1324,6 @@ GenericLegacyBoot (
|
||||
//
|
||||
SaveAndSetDebugTimerInterrupt (FALSE);
|
||||
|
||||
|
||||
//
|
||||
// Put the 8259 into its legacy mode by reprogramming the vector bases
|
||||
//
|
||||
@ -1328,6 +1354,7 @@ GenericLegacyBoot (
|
||||
BaseVectorMaster[Index] = (UINT32)(Private->BiosUnexpectedInt);
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
ZeroMem (&Regs, sizeof (EFI_IA32_REGISTER_SET));
|
||||
@ -1347,8 +1374,10 @@ GenericLegacyBoot (
|
||||
for (Index = 0; Index < 8; Index++) {
|
||||
BaseVectorMaster[Index] = Private->ThunkSavedInt[Index];
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
Private->LegacyBootEntered = TRUE;
|
||||
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
|
||||
aware OS so the OS can access drives without an EFI driver.
|
||||
@ -1449,13 +1477,15 @@ LegacyBiosBootUnconventionalDevice (
|
||||
if ((Attributes.DirectoryServiceValidity == 0) &&
|
||||
(Attributes.RabcaUsedFlag == 0) &&
|
||||
(Attributes.ExecuteHddDiagnosticsFlag == 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (((Attributes.DirectoryServiceValidity != 0) && (ServiceAreaData == NULL)) ||
|
||||
(((Attributes.DirectoryServiceValidity | Attributes.RabcaUsedFlag) != 0) && (BeerData == NULL))
|
||||
) {
|
||||
)
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -1478,6 +1508,7 @@ LegacyBiosBootUnconventionalDevice (
|
||||
for (Index = 0; Index < EfiToLegacy16BootTable->NumberBbsEntries; Index++) {
|
||||
BbsTable[Index].BootPriority = BBS_DO_NOT_BOOT_FROM;
|
||||
}
|
||||
|
||||
//
|
||||
// If parent is onboard IDE then assign controller & device number
|
||||
// else they are 0.
|
||||
@ -1501,6 +1532,7 @@ LegacyBiosBootUnconventionalDevice (
|
||||
(UINTN)64
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// For each new entry do the following:
|
||||
// 1. Increment current number of BBS entries
|
||||
@ -1553,6 +1585,7 @@ LegacyBiosBootUnconventionalDevice (
|
||||
//
|
||||
mBbsDevicePathNode.DeviceType = BBS_TYPE_FLOPPY;
|
||||
}
|
||||
|
||||
//
|
||||
// Build the BBS Device Path for this boot selection
|
||||
//
|
||||
@ -1828,6 +1861,7 @@ LegacyBiosBuildE820 (
|
||||
E820Table[Index].Type = TempType;
|
||||
}
|
||||
}
|
||||
|
||||
EfiEntry = NEXT_MEMORY_DESCRIPTOR (EfiEntry, EfiDescriptorSize);
|
||||
}
|
||||
|
||||
@ -1837,13 +1871,14 @@ LegacyBiosBuildE820 (
|
||||
// Process the reserved memory map to produce E820 map ;
|
||||
//
|
||||
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;
|
||||
if (((ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_MAPPED_IO) ||
|
||||
(ResourceHob->ResourceType == EFI_RESOURCE_FIRMWARE_DEVICE) ||
|
||||
(ResourceHob->ResourceType == EFI_RESOURCE_MEMORY_RESERVED)) &&
|
||||
(ResourceHob->PhysicalStart > 0x100000) &&
|
||||
(Index < EFI_MAX_E820_ENTRY - 1)) {
|
||||
(Index < EFI_MAX_E820_ENTRY - 1))
|
||||
{
|
||||
++Index;
|
||||
E820Table[Index].BaseAddr = ResourceHob->PhysicalStart;
|
||||
E820Table[Index].Length = ResourceHob->ResourceLength;
|
||||
@ -1889,9 +1924,10 @@ LegacyBiosBuildE820 (
|
||||
// Remove the overlap range
|
||||
//
|
||||
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].BaseAddr +E820Table[TempIndex].Length))) {
|
||||
(E820Table[TempIndex].BaseAddr +E820Table[TempIndex].Length)))
|
||||
{
|
||||
//
|
||||
// Overlap range is found
|
||||
//
|
||||
@ -1909,13 +1945,12 @@ LegacyBiosBuildE820 (
|
||||
E820Table[IndexSort].Length = E820Table[IndexSort + 1].Length;
|
||||
E820Table[IndexSort].Type = E820Table[IndexSort + 1].Type;
|
||||
}
|
||||
|
||||
Index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Private->IntThunk->EfiToLegacy16InitTable.NumberE820Entries = (UINT32)Index;
|
||||
Private->IntThunk->EfiToLegacy16BootTable.NumberE820Entries = (UINT32)Index;
|
||||
Private->NumberE820Entries = (UINT32)Index;
|
||||
@ -1926,7 +1961,8 @@ LegacyBiosBuildE820 (
|
||||
//
|
||||
Private->IntThunk->EfiToLegacy16BootTable.OsMemoryAbove1Mb = 0x0000;
|
||||
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.
|
||||
//
|
||||
@ -1944,7 +1980,9 @@ LegacyBiosBuildE820 (
|
||||
// Print DEBUG information
|
||||
//
|
||||
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,
|
||||
E820Table[TempIndex].BaseAddr,
|
||||
(E820Table[TempIndex].BaseAddr + E820Table[TempIndex].Length),
|
||||
@ -1955,7 +1993,6 @@ LegacyBiosBuildE820 (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard BDA and EBDA stuff prior to legacy Boot
|
||||
|
||||
@ -2086,7 +2123,6 @@ LegacyBiosUpdateKeyboardLedStatus (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard CMOS stuff prior to legacy Boot
|
||||
|
||||
|
@ -66,12 +66,12 @@ LegacyCalculateWriteStandardCmosChecksum (
|
||||
for (Checksum = 0, Register = 0x10; Register < 0x2e; Register++) {
|
||||
Checksum = (UINT16)(Checksum + LegacyReadStandardCmos (Register));
|
||||
}
|
||||
|
||||
LegacyWriteStandardCmos (CMOS_2E, (UINT8)(Checksum >> 8));
|
||||
LegacyWriteStandardCmos (CMOS_2F, (UINT8)(Checksum & 0xff));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fill in the standard CMOS stuff before Legacy16 load
|
||||
|
||||
|
@ -136,10 +136,12 @@ LegacyBiosBuildIdeData (
|
||||
if ((DevicePathType (DevicePathNode) == HARDWARE_DEVICE_PATH) &&
|
||||
(DevicePathSubType (DevicePathNode) == HW_PCI_DP) &&
|
||||
(DevicePathType (TempDevicePathNode) == MESSAGING_DEVICE_PATH) &&
|
||||
( DevicePathSubType(TempDevicePathNode) == MSG_ATAPI_DP) ) {
|
||||
(DevicePathSubType (TempDevicePathNode) == MSG_ATAPI_DP))
|
||||
{
|
||||
PciDevicePath = (PCI_DEVICE_PATH *)DevicePathNode;
|
||||
break;
|
||||
}
|
||||
|
||||
DevicePathNode = NextDevicePathNode (DevicePathNode);
|
||||
}
|
||||
|
||||
@ -161,7 +163,8 @@ LegacyBiosBuildIdeData (
|
||||
for (PciIndex = 0; PciIndex < 8; PciIndex++) {
|
||||
if ((PciDevicePath->Device == LocalHddInfo[PciIndex].Device) &&
|
||||
(PciDevicePath->Function == LocalHddInfo[PciIndex].Function)
|
||||
) {
|
||||
)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -227,6 +230,7 @@ LegacyBiosBuildIdeData (
|
||||
LocalHddInfo[PciIndex + IdeChannel].Status |= HDD_SLAVE_ATAPI_ZIPDISK;
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (InquiryData);
|
||||
} else {
|
||||
if (IdeDevice == 0) {
|
||||
@ -246,7 +250,6 @@ LegacyBiosBuildIdeData (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
If the IDE channel is in compatibility (legacy) mode, remove all
|
||||
PCI I/O BAR addresses from the controller.
|
||||
@ -289,7 +292,8 @@ InitLegacyIdeController (
|
||||
// Check whether this is IDE
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
@ -301,6 +305,7 @@ InitLegacyIdeController (
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x10, 1, &IOBarClear);
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x14, 1, &IOBarClear);
|
||||
}
|
||||
|
||||
if ((PciData.Hdr.ClassCode[0] & IDE_PI_REGISTER_SNE) == 0) {
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x18, 1, &IOBarClear);
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint32, 0x1C, 1, &IOBarClear);
|
||||
|
@ -93,7 +93,8 @@ GetShadowedRomParameters (
|
||||
if ((mRomEntry[Index].PciSegment == PciSegment) &&
|
||||
(mRomEntry[Index].PciBus == PciBus) &&
|
||||
(mRomEntry[Index].PciDevice == PciDevice) &&
|
||||
(mRomEntry[Index].PciFunction == PciFunction)) {
|
||||
(mRomEntry[Index].PciFunction == PciFunction))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -157,6 +158,7 @@ RomShadow (
|
||||
if (mRomCount >= ROM_MAX_ENTRIES) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the PCI I/O Protocol on PciHandle
|
||||
//
|
||||
@ -168,6 +170,7 @@ RomShadow (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the location of the PCI device
|
||||
//
|
||||
@ -188,7 +191,6 @@ RomShadow (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return EFI_SUCCESS if PciHandle has had a legacy BIOS ROM shadowed. This
|
||||
information represents every call to RomShadow ()
|
||||
@ -223,6 +225,7 @@ IsLegacyRom (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the location of the PCI device
|
||||
//
|
||||
@ -238,11 +241,12 @@ IsLegacyRom (
|
||||
// See if the option ROM from PciHandle has been previously posted
|
||||
//
|
||||
for (Index = 0; Index < mRomCount; Index++) {
|
||||
if (mRomEntry[Index].PciSegment == Segment &&
|
||||
mRomEntry[Index].PciBus == Bus &&
|
||||
mRomEntry[Index].PciDevice == Device &&
|
||||
mRomEntry[Index].PciFunction == Function
|
||||
) {
|
||||
if ((mRomEntry[Index].PciSegment == Segment) &&
|
||||
(mRomEntry[Index].PciBus == Bus) &&
|
||||
(mRomEntry[Index].PciDevice == Device) &&
|
||||
(mRomEntry[Index].PciFunction == Function)
|
||||
)
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -288,7 +292,6 @@ GetPciLegacyRom (
|
||||
VOID *BackupImage;
|
||||
VOID *BestImage;
|
||||
|
||||
|
||||
if (*ImageSize < sizeof (EFI_PCI_ROM_HEADER)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -297,9 +300,10 @@ GetPciLegacyRom (
|
||||
BackupImage = NULL;
|
||||
RomHeader.Raw = *Rom;
|
||||
while (RomHeader.Generic->Signature == PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
|
||||
if (RomHeader.Generic->PcirOffset == 0 ||
|
||||
(RomHeader.Generic->PcirOffset & 3) !=0 ||
|
||||
*ImageSize < RomHeader.Raw - (UINT8 *) *Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)) {
|
||||
if ((RomHeader.Generic->PcirOffset == 0) ||
|
||||
((RomHeader.Generic->PcirOffset & 3) != 0) ||
|
||||
(*ImageSize < RomHeader.Raw - (UINT8 *)*Rom + RomHeader.Generic->PcirOffset + sizeof (PCI_DATA_STRUCTURE)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -330,6 +334,7 @@ GetPciLegacyRom (
|
||||
Match = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
DeviceIdList++;
|
||||
}
|
||||
}
|
||||
@ -389,11 +394,13 @@ GetPciLegacyRom (
|
||||
if (BackupImage == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// The versions of CSM16 and OpRom don't match exactly
|
||||
//
|
||||
BestImage = BackupImage;
|
||||
}
|
||||
|
||||
RomHeader.Raw = BestImage;
|
||||
Pcir = (PCI_3_0_DATA_STRUCTURE *)(RomHeader.Raw + RomHeader.Generic->PcirOffset);
|
||||
*Rom = BestImage;
|
||||
@ -475,6 +482,7 @@ CreateBridgeTable (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
@ -514,7 +522,8 @@ CreateBridgeTable (
|
||||
// Once we find one, store it in the SlotBridges[]
|
||||
//
|
||||
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));
|
||||
SlotBridgeIndex++;
|
||||
|
||||
@ -532,7 +541,8 @@ CreateBridgeTable (
|
||||
for (Index = 0; Index < BridgeIndex;) {
|
||||
for (Index1 = 0; Index1 < SlotBridgeIndex; Index1++) {
|
||||
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
|
||||
//
|
||||
@ -574,18 +584,19 @@ CreateBridgeTable (
|
||||
|
||||
if ((Bridges[Index].SecondaryBus == Bridges[Index1].SecondaryBus) &&
|
||||
(Bridges[Index].SubordinateBus > Bridges[Index1].SubordinateBus)
|
||||
) {
|
||||
)
|
||||
{
|
||||
SortedBridgeIndex[Index] = Index1;
|
||||
SortedBridgeIndex[Index1] = Index;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find base Bridge for device.
|
||||
|
||||
@ -609,6 +620,7 @@ GetBaseBus (
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; Index < RoutingTableEntries; Index++) {
|
||||
if ((RoutingTable[Index].Bus == PciBus) && (RoutingTable[Index].Device == (PciDevice << 3))) {
|
||||
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;
|
||||
UINTN BridgeIndex;
|
||||
UINTN SBridgeIndex;
|
||||
|
||||
BaseIndexFlag = FALSE;
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy the $PIR table as required.
|
||||
|
||||
@ -964,6 +976,7 @@ InstallLegacyIrqHandler (
|
||||
Private->IntThunk->PciHandler.PrimaryBase = 0x1f0;
|
||||
Private->IntThunk->PciHandler.PrimaryControl = 0x3f6;
|
||||
}
|
||||
|
||||
//
|
||||
// Secondary controller data
|
||||
//
|
||||
@ -977,7 +990,6 @@ InstallLegacyIrqHandler (
|
||||
//
|
||||
IoWrite16 (PrimaryMaster, 0x04);
|
||||
IoWrite16 (SecondaryMaster, 0x04);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@ -991,7 +1003,6 @@ InstallLegacyIrqHandler (
|
||||
Private->IntThunk->PciHandler.SecondaryBase = (UINT16)(PciConfigHeader->Device.Bar[2] & 0xfffc);
|
||||
Private->IntThunk->PciHandler.SecondaryControl = (UINT16)((PciConfigHeader->Device.Bar[3] & 0xfffc) + 2);
|
||||
} else {
|
||||
|
||||
Private->IntThunk->PciHandler.SecondaryIrq = 15;
|
||||
Private->IntThunk->PciHandler.SecondaryBase = 0x170;
|
||||
Private->IntThunk->PciHandler.SecondaryControl = 0x376;
|
||||
@ -1043,10 +1054,8 @@ InstallLegacyIrqHandler (
|
||||
0x20000,
|
||||
&Granularity
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
@ -1136,6 +1145,7 @@ PciProgramAllInterruptLineRegisters (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (HandleCount == mHandleCount) {
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_ALREADY_STARTED;
|
||||
@ -1199,6 +1209,7 @@ PciProgramAllInterruptLineRegisters (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
PciIo->Pci.Write (PciIo, EfiPciIoWidthUint16, 0x04, 1, &Command);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@ -1238,6 +1249,7 @@ PciProgramAllInterruptLineRegisters (
|
||||
&InterruptPin
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Translate InterruptPin(0-3) into PIRQ
|
||||
//
|
||||
@ -1327,6 +1339,7 @@ PciProgramAllInterruptLineRegisters (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Write InterruptPin and enable 8259.
|
||||
//
|
||||
@ -1358,11 +1371,11 @@ PciProgramAllInterruptLineRegisters (
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find & verify PnP Expansion header in ROM image
|
||||
|
||||
@ -1385,6 +1398,7 @@ FindNextPnpExpansionHeader (
|
||||
{
|
||||
UINTN TempData;
|
||||
LEGACY_PNP_EXPANSION_HEADER *LocalPnpPtr;
|
||||
|
||||
LocalPnpPtr = *PnpPtr;
|
||||
if (FirstHeader == FIRST_INSTANCE) {
|
||||
mBasePnpPtr = LocalPnpPtr;
|
||||
@ -1413,7 +1427,6 @@ FindNextPnpExpansionHeader (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update list of Bev or BCV table entries.
|
||||
|
||||
@ -1445,6 +1458,7 @@ UpdateBevBcvTable (
|
||||
UINTN Function;
|
||||
UINT8 Class;
|
||||
UINT16 DeviceType;
|
||||
|
||||
Segment = 0;
|
||||
Bus = 0;
|
||||
Device = 0;
|
||||
@ -1499,6 +1513,7 @@ UpdateBevBcvTable (
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// There can be additional $PnP headers within the OPROM.
|
||||
// Example: SCSI can have one per drive.
|
||||
@ -1547,7 +1562,6 @@ UpdateBevBcvTable (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -1606,6 +1620,7 @@ PciShadowRoms (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Place the VGA handle as first.
|
||||
//
|
||||
@ -1617,6 +1632,7 @@ PciShadowRoms (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate memory to save Command WORD from each device. We do this
|
||||
// to restore devices to same state as EFI after switching to legacy.
|
||||
@ -1628,12 +1644,12 @@ PciShadowRoms (
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Disconnect all EFI devices first. This covers cases where alegacy BIOS
|
||||
// may control multiple PCI devices.
|
||||
//
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@ -1659,6 +1675,7 @@ PciShadowRoms (
|
||||
if (!EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Stop EFI Drivers with oprom.
|
||||
//
|
||||
@ -1668,11 +1685,11 @@ PciShadowRoms (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// For every device that has not had a legacy ROM started. Start a legacy ROM.
|
||||
//
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
HandleBuffer[Index],
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@ -1698,9 +1715,10 @@ PciShadowRoms (
|
||||
// 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).
|
||||
//
|
||||
if (IS_PCI_DISPLAY (&Pci) && Index != 0) {
|
||||
if (IS_PCI_DISPLAY (&Pci) && (Index != 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 (IS_PCI_DISPLAY (&Pci) && Index == 0) {
|
||||
if (IS_PCI_DISPLAY (&Pci) && (Index == 0)) {
|
||||
Status = LegacyBiosInstallVgaRom (Private);
|
||||
//
|
||||
// A return status of EFI_NOT_FOUND is considered valid (No EFI
|
||||
@ -1740,6 +1758,7 @@ PciShadowRoms (
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Restore Command register so legacy has same devices enabled or disabled
|
||||
// as EFI.
|
||||
@ -1773,6 +1792,7 @@ PciShadowRoms (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Command[Index] = 0x1f;
|
||||
}
|
||||
@ -1793,7 +1813,6 @@ PciShadowRoms (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test to see if a legacy PCI ROM exists for this device. Optionally return
|
||||
the Legacy ROM instance for this PCI device.
|
||||
@ -1829,7 +1848,6 @@ LegacyBiosCheckPciRom (
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1891,6 +1909,7 @@ LegacyBiosCheckPciRomEx (
|
||||
*Flags |= (UINTN)(ROM_FOUND | VALID_LEGACY_ROM);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Check for PCI ROM Bar
|
||||
//
|
||||
@ -1983,6 +2002,7 @@ EnablePs2Keyboard (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
//
|
||||
// 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
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -2017,11 +2037,11 @@ EnablePs2Keyboard (
|
||||
gBS->ConnectController (HandleBuffer[Index], NULL, NULL, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Load a legacy PC-AT OpROM for VGA controller.
|
||||
|
||||
@ -2132,6 +2152,7 @@ LegacyBiosInstallVgaRom (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Find all the Thunk Driver
|
||||
//
|
||||
@ -2208,7 +2229,6 @@ LegacyBiosInstallVgaRom (
|
||||
FreePool (ConnectHandleBuffer);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
Private->VgaInstalled = FALSE;
|
||||
|
||||
//
|
||||
@ -2221,7 +2241,6 @@ LegacyBiosInstallVgaRom (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Load a legacy PC-AT OpROM.
|
||||
|
||||
@ -2300,11 +2319,11 @@ LegacyBiosInstallRom (
|
||||
if ((Private->Legacy16Table->TableLength >= OFFSET_OF (EFI_COMPATIBILITY16_TABLE, HiPermanentMemoryAddress)) &&
|
||||
(Private->Legacy16Table->UmaAddress != 0) &&
|
||||
(Private->Legacy16Table->UmaSize != 0) &&
|
||||
(MaxRomAddr > (Private->Legacy16Table->UmaAddress))) {
|
||||
(MaxRomAddr > (Private->Legacy16Table->UmaAddress)))
|
||||
{
|
||||
MaxRomAddr = Private->Legacy16Table->UmaAddress;
|
||||
}
|
||||
|
||||
|
||||
PciProgramAllInterruptLineRegisters (Private);
|
||||
|
||||
if ((OpromRevision >= 3) && (Private->Csm16PciInterfaceVersion >= 0x0300)) {
|
||||
@ -2331,6 +2350,7 @@ LegacyBiosInstallRom (
|
||||
);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
InitAddress = (UINTN)PhysicalAddress;
|
||||
//
|
||||
// then test if there is enough space for its RT code
|
||||
@ -2414,7 +2434,6 @@ LegacyBiosInstallRom (
|
||||
}
|
||||
|
||||
if (PciHandle != mVgaHandle) {
|
||||
|
||||
EnablePs2Keyboard ();
|
||||
|
||||
//
|
||||
@ -2422,6 +2441,7 @@ LegacyBiosInstallRom (
|
||||
//
|
||||
VideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
//
|
||||
@ -2476,7 +2496,6 @@ LegacyBiosInstallRom (
|
||||
PciEnableStatus = EFI_UNSUPPORTED;
|
||||
ZeroMem (&Regs, sizeof (Regs));
|
||||
if (PciHandle != NULL) {
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
PciHandle,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@ -2543,6 +2562,7 @@ LegacyBiosInstallRom (
|
||||
Private->IntThunk->EfiToLegacy16BootTable.NumberBbsEntries = (UINT8)Private->IntThunk->DispatchOpromTable.NumberBbsEntries;
|
||||
mIgnoreBbsUpdateFlag = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if non-BBS compliant drives found
|
||||
//
|
||||
@ -2557,6 +2577,7 @@ LegacyBiosInstallRom (
|
||||
Private->LegacyEfiHddTable[Private->LegacyEfiHddTableIndex].EndDriveNumber = Private->DiskEnd;
|
||||
Private->LegacyEfiHddTableIndex += 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip video mode set, if installing VGA
|
||||
//
|
||||
@ -2564,9 +2585,11 @@ LegacyBiosInstallRom (
|
||||
//
|
||||
// Set mode settings since PrepareToScanRom may change mode
|
||||
//
|
||||
ACCESS_PAGE0_CODE ({
|
||||
ACCESS_PAGE0_CODE (
|
||||
{
|
||||
OldVideoMode = *(UINT8 *)((UINTN)(0x400 + BDA_VIDEO_MODE));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (VideoMode != OldVideoMode) {
|
||||
//
|
||||
@ -2577,6 +2600,7 @@ LegacyBiosInstallRom (
|
||||
Private->LegacyBios.Int86 (&Private->LegacyBios, 0x10, &Regs);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Regs.X.AX from the adapter initializion is ignored since some adapters
|
||||
// do not follow the standard of setting AX = 0 on success.
|
||||
@ -2650,6 +2674,7 @@ LegacyBiosInstallRom (
|
||||
Private->LegacyEfiHddTableIndex += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Mark PCI device as having a legacy BIOS ROM loaded.
|
||||
//
|
||||
@ -2730,6 +2755,7 @@ IoMmuGrantAccess (
|
||||
if (mIoMmu == NULL) {
|
||||
gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmu);
|
||||
}
|
||||
|
||||
if (mIoMmu != NULL) {
|
||||
Status = mIoMmu->Map (
|
||||
mIoMmu,
|
||||
@ -2754,6 +2780,7 @@ IoMmuGrantAccess (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -2903,7 +2930,8 @@ LegacyBiosInstallPciRom (
|
||||
)
|
||||
&&
|
||||
(!Private->VgaInstalled)
|
||||
) {
|
||||
)
|
||||
{
|
||||
mVgaInstallationInProgress = TRUE;
|
||||
|
||||
//
|
||||
@ -2911,6 +2939,7 @@ LegacyBiosInstallPciRom (
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 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.
|
||||
@ -2943,6 +2972,7 @@ LegacyBiosInstallPciRom (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if the option ROM for PciHandle has already been executed
|
||||
//
|
||||
@ -3012,9 +3042,10 @@ LegacyBiosInstallPciRom (
|
||||
}
|
||||
|
||||
LocalRomImage = *RomImage;
|
||||
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 & 3 ) != 0) {
|
||||
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 & 3) != 0))
|
||||
{
|
||||
mVgaInstallationInProgress = FALSE;
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@ -3033,6 +3064,7 @@ LegacyBiosInstallPciRom (
|
||||
} else {
|
||||
OpromRevision = 0;
|
||||
}
|
||||
|
||||
if (Pcir->Revision < 3) {
|
||||
RuntimeImageLength = 0;
|
||||
} else {
|
||||
|
@ -61,6 +61,7 @@ LegacyBiosBuildSioDataFromSio (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// 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) ||
|
||||
((DevicePathSubType (Acpi) != ACPI_DP) && (DevicePathSubType (Acpi) != ACPI_EXTENDED_DP))
|
||||
) {
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -141,9 +143,8 @@ LegacyBiosBuildSioDataFromSio (
|
||||
//
|
||||
// Ignore DMA resource since it is always returned NULL
|
||||
//
|
||||
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->HID == EISA_PNP_ID (0x500)) || (Acpi->HID == EISA_PNP_ID (0x501))) {
|
||||
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
|
||||
//
|
||||
@ -156,6 +157,7 @@ LegacyBiosBuildSioDataFromSio (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ChildIndex = 0; ChildIndex < EntryCount; ChildIndex++) {
|
||||
if ((OpenInfoBuffer[ChildIndex].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
|
||||
Status = gBS->HandleProtocol (OpenInfoBuffer[ChildIndex].ControllerHandle, &gEfiSerialIoProtocolGuid, (VOID **)&SerialIo);
|
||||
@ -172,14 +174,15 @@ LegacyBiosBuildSioDataFromSio (
|
||||
FreePool (OpenInfoBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is an ISA parallel port
|
||||
//
|
||||
// Ignore DMA resource since it is always returned NULL, port
|
||||
// only used in output mode.
|
||||
//
|
||||
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->HID == EISA_PNP_ID (0x400)) || (Acpi->HID == EISA_PNP_ID (0x401))) {
|
||||
if ((Acpi->UID < 3) && (Address != MAX_UINT16) && (Irq != MAX_UINT8) && (Dma != MAX_UINT8)) {
|
||||
SioParallel = &SioPtr->Parallel[Acpi->UID];
|
||||
SioParallel->Address = Address;
|
||||
SioParallel->Irq = Irq;
|
||||
@ -187,11 +190,12 @@ LegacyBiosBuildSioDataFromSio (
|
||||
SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is an ISA floppy controller
|
||||
//
|
||||
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);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SioFloppy = &SioPtr->Floppy;
|
||||
@ -202,6 +206,7 @@ LegacyBiosBuildSioDataFromSio (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is a mouse
|
||||
// Always set mouse found so USB hot plug will work
|
||||
@ -225,7 +230,6 @@ LegacyBiosBuildSioDataFromSio (
|
||||
|
||||
FreePool (HandleBuffer);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -274,11 +278,11 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Collect legacy information from each of the ISA controllers in the system
|
||||
//
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
|
||||
Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiIsaIoProtocolGuid, (VOID **)&IsaIo);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
@ -289,6 +293,7 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
if (ResourceList == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Collect the resource types neededto fill in the SIO data structure
|
||||
//
|
||||
@ -298,7 +303,8 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
for (ResourceIndex = 0;
|
||||
ResourceList->ResourceItem[ResourceIndex].Type != EfiIsaAcpiResourceEndOfList;
|
||||
ResourceIndex++
|
||||
) {
|
||||
)
|
||||
{
|
||||
switch (ResourceList->ResourceItem[ResourceIndex].Type) {
|
||||
case EfiIsaAcpiResourceIo:
|
||||
IoResource = &ResourceList->ResourceItem[ResourceIndex];
|
||||
@ -319,17 +325,18 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is an ISA serial port
|
||||
//
|
||||
// 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.UID <= 3 &&
|
||||
IoResource != NULL &&
|
||||
InterruptResource != NULL
|
||||
) {
|
||||
if ((ResourceList->Device.HID == EISA_PNP_ID (0x500)) || (ResourceList->Device.HID == EISA_PNP_ID (0x501))) {
|
||||
if ((ResourceList->Device.UID <= 3) &&
|
||||
(IoResource != NULL) &&
|
||||
(InterruptResource != NULL)
|
||||
)
|
||||
{
|
||||
//
|
||||
// Get the handle of the child device that has opened the ISA I/O Protocol
|
||||
//
|
||||
@ -342,6 +349,7 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// We want resource for legacy even if no 32-bit driver installed
|
||||
//
|
||||
@ -361,18 +369,20 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
FreePool (OpenInfoBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is an ISA parallel port
|
||||
//
|
||||
// Ignore DMA resource since it is always returned NULL, port
|
||||
// only used in output mode.
|
||||
//
|
||||
if (ResourceList->Device.HID == EISA_PNP_ID (0x400) || ResourceList->Device.HID == EISA_PNP_ID (0x401)) {
|
||||
if (ResourceList->Device.UID <= 2 &&
|
||||
IoResource != NULL &&
|
||||
InterruptResource != NULL &&
|
||||
DmaResource != NULL
|
||||
) {
|
||||
if ((ResourceList->Device.HID == EISA_PNP_ID (0x400)) || (ResourceList->Device.HID == EISA_PNP_ID (0x401))) {
|
||||
if ((ResourceList->Device.UID <= 2) &&
|
||||
(IoResource != NULL) &&
|
||||
(InterruptResource != NULL) &&
|
||||
(DmaResource != NULL)
|
||||
)
|
||||
{
|
||||
SioParallel = &SioPtr->Parallel[ResourceList->Device.UID];
|
||||
SioParallel->Address = (UINT16)IoResource->StartRange;
|
||||
SioParallel->Irq = (UINT8)InterruptResource->StartRange;
|
||||
@ -380,11 +390,12 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
SioParallel->Mode = DEVICE_PARALLEL_MODE_MODE_OUTPUT_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is an ISA floppy controller
|
||||
//
|
||||
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);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
SioFloppy = &SioPtr->Floppy;
|
||||
@ -395,6 +406,7 @@ LegacyBiosBuildSioDataFromIsaIo (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// See if this is a mouse
|
||||
// Always set mouse found so USB hot plug will work
|
||||
|
@ -237,13 +237,16 @@ InternalLegacyBiosFarCall (
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
Count++;
|
||||
}
|
||||
|
||||
if (Status == EFI_SUCCESS) {
|
||||
Private->Cpu->RegisterInterruptHandler (Private->Cpu, Vector, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (Count >= 2) {
|
||||
DEBUG ((DEBUG_ERROR, "ERROR: More than one HW interrupt active with CSM enabled\n"));
|
||||
}
|
||||
|
||||
ASSERT (Count < 2);
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
@ -252,11 +255,11 @@ InternalLegacyBiosFarCall (
|
||||
// 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
|
||||
//
|
||||
if (Private->TimerUses8254 && TimerPeriod < 549254) {
|
||||
if (Private->TimerUses8254 && (TimerPeriod < 549254)) {
|
||||
SetPitCount (0);
|
||||
}
|
||||
|
||||
if (Stack != NULL && StackSize != 0) {
|
||||
if ((Stack != NULL) && (StackSize != 0)) {
|
||||
//
|
||||
// Copy Stack to low memory stack
|
||||
//
|
||||
@ -279,7 +282,7 @@ InternalLegacyBiosFarCall (
|
||||
|
||||
AsmThunk16 (&mThunkContext);
|
||||
|
||||
if (Stack != NULL && StackSize != 0) {
|
||||
if ((Stack != NULL) && (StackSize != 0)) {
|
||||
//
|
||||
// Copy low memory stack to Stack
|
||||
//
|
||||
|
@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include "LegacyBootMaintUi.h"
|
||||
|
||||
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 };
|
||||
BOOLEAN mFirstEnterLegacyForm = FALSE;
|
||||
|
||||
|
||||
///
|
||||
/// Legacy FD Info from LegacyBios.GetBbsInfo()
|
||||
///
|
||||
@ -62,13 +60,11 @@ LEGACY_MENU_OPTION LegacyBEVMenu = {
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
VOID *mLegacyStartOpCodeHandle = NULL;
|
||||
VOID *mLegacyEndOpCodeHandle = NULL;
|
||||
EFI_IFR_GUID_LABEL *mLegacyStartLabel = NULL;
|
||||
EFI_IFR_GUID_LABEL *mLegacyEndLabel = NULL;
|
||||
|
||||
|
||||
HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = {
|
||||
{
|
||||
{
|
||||
@ -79,7 +75,8 @@ HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = {
|
||||
(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,
|
||||
@ -101,7 +98,6 @@ GetLegacyOptions (
|
||||
VOID
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Base on the L"LegacyDevOrder" variable to build the current order data.
|
||||
@ -170,13 +166,13 @@ OrderLegacyBootOption4SameType (
|
||||
ASSERT (*DisBootOption != NULL);
|
||||
|
||||
for (Index = 0; Index < BootOrderSize / sizeof (UINT16); Index++) {
|
||||
|
||||
UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", BootOrder[Index]);
|
||||
Status = EfiBootManagerVariableToLoadOption (OptionName, &BootOption);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if ((DevicePathType (BootOption.FilePath) == BBS_DEVICE_PATH) &&
|
||||
(DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP)) {
|
||||
(DevicePathSubType (BootOption.FilePath) == BBS_BBS_DP))
|
||||
{
|
||||
//
|
||||
// Legacy Boot Option
|
||||
//
|
||||
@ -188,6 +184,7 @@ OrderLegacyBootOption4SameType (
|
||||
DeviceTypeArray[Index] = BBS_TYPE_UNKNOWN;
|
||||
BbsIndexArray[Index] = 0xFFFF;
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&BootOption);
|
||||
}
|
||||
|
||||
@ -211,6 +208,7 @@ OrderLegacyBootOption4SameType (
|
||||
(*EnBootOption)[*EnBootOptionCount] = BootOrder[Index];
|
||||
(*EnBootOptionCount)++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -278,14 +276,12 @@ UpdateBBSOption (
|
||||
UINTN DisBootOptionCount;
|
||||
UINTN BufferSize;
|
||||
|
||||
|
||||
DisMap = NULL;
|
||||
NewOrder = NULL;
|
||||
CurrentType = 0;
|
||||
EnBootOption = NULL;
|
||||
DisBootOption = NULL;
|
||||
|
||||
|
||||
DisMap = mLegacyBootOptionPrivate->MaintainMapData->DisableMap;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
@ -296,6 +292,7 @@ UpdateBBSOption (
|
||||
if (VarData == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
OriginalPtr = VarData;
|
||||
|
||||
while (mBbsType[CurrentType] != BBS_UNKNOWN) {
|
||||
@ -458,7 +455,6 @@ UpdateBBSOption (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FreePool (EnBootOption);
|
||||
FreePool (DisBootOption);
|
||||
|
||||
@ -517,9 +513,10 @@ LegacyBootOptionExtractConfig (
|
||||
OUT EFI_STRING *Results
|
||||
)
|
||||
{
|
||||
if (Progress == NULL || Results == NULL) {
|
||||
if ((Progress == NULL) || (Results == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*Progress = Request;
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -553,8 +550,7 @@ LegacyBootOptionRouteConfig (
|
||||
LEGACY_BOOT_NV_DATA *CurrentNVMapData;
|
||||
UINTN BufferSize;
|
||||
|
||||
|
||||
if (Configuration == NULL || Progress == NULL) {
|
||||
if ((Configuration == NULL) || (Progress == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -610,6 +606,7 @@ RefreshLegacyUpdateData (
|
||||
if (mLegacyStartOpCodeHandle != NULL) {
|
||||
HiiFreeOpCodeHandle (mLegacyStartOpCodeHandle);
|
||||
}
|
||||
|
||||
if (mLegacyEndOpCodeHandle != NULL) {
|
||||
HiiFreeOpCodeHandle (mLegacyEndOpCodeHandle);
|
||||
}
|
||||
@ -645,7 +642,6 @@ RefreshLegacyUpdateData (
|
||||
mLegacyEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
|
||||
|
||||
mLegacyEndLabel->Number = FORM_BOOT_LEGACY_LABEL_END;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -819,7 +815,6 @@ UpdateLegacyDeviceOrderPage (
|
||||
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
|
||||
ASSERT (OptionsOpCodeHandle != NULL);
|
||||
|
||||
|
||||
for (Index = 0; Index < OptionMenu->MenuNumber; Index++) {
|
||||
NewMenuEntry = GetMenuEntry (OptionMenu, Index);
|
||||
//
|
||||
@ -895,7 +890,6 @@ UpdateLegacyDeviceOrderPage (
|
||||
HiiFreeOpCodeHandle (OptionsOpCodeHandle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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);
|
||||
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;
|
||||
CurrentVal = CurrentNVMap->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;
|
||||
CurrentVal = CurrentNVMap->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;
|
||||
CurrentVal = CurrentNVMap->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;
|
||||
CurrentVal = CurrentNVMap->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;
|
||||
CurrentVal = CurrentNVMap->LegacyBEV;
|
||||
Default = mLegacyBootOptionPrivate->MaintainMapData->LastTimeNvData.LegacyBEV;
|
||||
@ -1040,6 +1034,7 @@ AdjustOptionValue (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// To prevent DISABLE appears in the middle of the list
|
||||
// we should perform a re-ordering
|
||||
@ -1112,7 +1107,7 @@ LegacyBootOptionCallback (
|
||||
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.
|
||||
//
|
||||
@ -1160,10 +1155,10 @@ LegacyBootOptionCallback (
|
||||
AdjustOptionValue (QuestionId, Value);
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a menu entry by given menu type.
|
||||
|
||||
@ -1343,9 +1338,11 @@ GetLegacyOptions (
|
||||
for (Index = 0; Index < BootOptionCount; Index++) {
|
||||
if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||
|
||||
(DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)
|
||||
) {
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ASSERT (BootOption[Index].OptionalDataSize == sizeof (LEGACY_BOOT_OPTION_BBS_DATA));
|
||||
NewMenuEntry = CreateMenuEntry ();
|
||||
ASSERT (NewMenuEntry != NULL);
|
||||
@ -1395,7 +1392,6 @@ GetLegacyOptions (
|
||||
LegacyBEVMenu.MenuNumber = BEVNum;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Install Boot Manager Menu driver.
|
||||
@ -1483,7 +1479,7 @@ LegacyBootMaintUiLibDestructor (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (mLegacyBootOptionPrivate != NULL && mLegacyBootOptionPrivate->DriverHandle != NULL) {
|
||||
if ((mLegacyBootOptionPrivate != NULL) && (mLegacyBootOptionPrivate->DriverHandle != NULL)) {
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
mLegacyBootOptionPrivate->DriverHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
@ -1502,4 +1498,3 @@ LegacyBootMaintUiLibDestructor (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _EFI_LEGACY_BOOT_OPTION_H_
|
||||
#define _EFI_LEGACY_BOOT_OPTION_H_
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/LegacyDevOrder.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 LEGACY_FD_QUESTION_ID QUESTION_ID (LegacyFD)
|
||||
#define LEGACY_HD_QUESTION_ID QUESTION_ID (LegacyHD)
|
||||
#define LEGACY_CD_QUESTION_ID QUESTION_ID (LegacyCD)
|
||||
#define LEGACY_NET_QUESTION_ID QUESTION_ID (LegacyNET)
|
||||
#define LEGACY_BEV_QUESTION_ID QUESTION_ID (LegacyBEV)
|
||||
|
||||
|
||||
//
|
||||
// String Constant
|
||||
//
|
||||
@ -96,14 +92,11 @@ typedef struct {
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} HII_VENDOR_DEVICE_PATH;
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Variable created with this flag will be "Efi:...."
|
||||
//
|
||||
#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')
|
||||
|
||||
typedef struct {
|
||||
|
@ -6,7 +6,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _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 LEGACY_BOOT_FORM_ID 0x1000
|
||||
#define LEGACY_ORDER_CHANGE_FORM_ID 0x1001
|
||||
|
||||
|
||||
#define FORM_FLOPPY_BOOT_ID 0x2000
|
||||
#define FORM_HARDDISK_BOOT_ID 0x2001
|
||||
#define FORM_CDROM_BOOT_ID 0x2002
|
||||
#define FORM_NET_BOOT_ID 0x2003
|
||||
#define FORM_BEV_BOOT_ID 0x2004
|
||||
|
||||
|
||||
|
||||
#define FORM_BOOT_LEGACY_DEVICE_ID 0x9000
|
||||
#define FORM_BOOT_LEGACY_LABEL_END 0x9001
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
///
|
||||
|
@ -48,8 +48,10 @@ LegacyBmDeviceType (
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||
)
|
||||
{
|
||||
ASSERT ((DevicePathType (DevicePath) == BBS_DEVICE_PATH) &&
|
||||
(DevicePathSubType (DevicePath) == BBS_BBS_DP));
|
||||
ASSERT (
|
||||
(DevicePathType (DevicePath) == BBS_DEVICE_PATH) &&
|
||||
(DevicePathSubType (DevicePath) == BBS_BBS_DP)
|
||||
);
|
||||
return ((BBS_BBS_DEVICE_PATH *)DevicePath)->DeviceType;
|
||||
}
|
||||
|
||||
@ -167,6 +169,7 @@ LegacyBmBuildLegacyDevNameString (
|
||||
Type = L"Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// If current BBS entry has its description then use it.
|
||||
//
|
||||
@ -186,7 +189,7 @@ LegacyBmBuildLegacyDevNameString (
|
||||
// BbsTable 16 entries are for onboard IDE.
|
||||
// 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";
|
||||
UnicodeSPrint (BootString, BufSize, Fmt, Type, Index - 5);
|
||||
} else {
|
||||
@ -222,7 +225,8 @@ LegacyBmFuzzyMatch (
|
||||
// Directly check the BBS index stored in BootOption
|
||||
//
|
||||
if ((BbsData->BbsIndex < BbsCount) &&
|
||||
(LegacyBmDeviceType (BootOption->FilePath) == BbsTable[BbsData->BbsIndex].DeviceType)) {
|
||||
(LegacyBmDeviceType (BootOption->FilePath) == BbsTable[BbsData->BbsIndex].DeviceType))
|
||||
{
|
||||
LegacyBmBuildLegacyDevNameString (
|
||||
&BbsTable[BbsData->BbsIndex],
|
||||
BbsData->BbsIndex,
|
||||
@ -246,7 +250,8 @@ LegacyBmFuzzyMatch (
|
||||
//
|
||||
for (Index = 0; Index < BbsCount; Index++) {
|
||||
if (!LegacyBmValidBbsEntry (&BbsTable[Index]) ||
|
||||
(BbsTable[Index].DeviceType != LegacyBmDeviceType (BootOption->FilePath))) {
|
||||
(BbsTable[Index].DeviceType != LegacyBmDeviceType (BootOption->FilePath)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -299,14 +304,16 @@ LegacyBmUpdateBbsIndex (
|
||||
LEGACY_DEV_ORDER_ENTRY *Entry;
|
||||
UINTN Index;
|
||||
|
||||
ASSERT (((LegacyDevOrder == NULL) && (*LegacyDevOrderSize == 0)) ||
|
||||
ASSERT (
|
||||
((LegacyDevOrder == NULL) && (*LegacyDevOrderSize == 0)) ||
|
||||
((LegacyDevOrder != NULL) && (*LegacyDevOrderSize != 0))
|
||||
);
|
||||
|
||||
for (Entry = LegacyDevOrder;
|
||||
Entry < (LEGACY_DEV_ORDER_ENTRY *)((UINT8 *)LegacyDevOrder + *LegacyDevOrderSize);
|
||||
Entry = (LEGACY_DEV_ORDER_ENTRY *)((UINTN)Entry + sizeof (BBS_TYPE) + Entry->Length)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (Entry->BbsType == DeviceType) {
|
||||
for (Index = 0; Index < Entry->Length / sizeof (UINT16) - 1; Index++) {
|
||||
if (Entry->Data[Index] == OldBbsIndex) {
|
||||
@ -324,9 +331,11 @@ LegacyBmUpdateBbsIndex (
|
||||
} else {
|
||||
Entry->Data[Index] = NewBbsIndex;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -350,7 +359,8 @@ LegacyBmDeleteAllBootOptions (
|
||||
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
|
||||
for (Index = 0; Index < BootOptionCount; Index++) {
|
||||
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);
|
||||
//
|
||||
// Deleting variable with current variable implementation shouldn't fail.
|
||||
@ -374,7 +384,6 @@ LegacyBmDeleteAllBootOptions (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete all the invalid legacy boot options.
|
||||
|
||||
@ -434,7 +443,8 @@ LegacyBmDeleteAllInvalidBootOptions (
|
||||
// Skip non legacy boot option
|
||||
//
|
||||
if ((DevicePathType (BootOption[Index].FilePath) != BBS_DEVICE_PATH) ||
|
||||
(DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP)) {
|
||||
(DevicePathSubType (BootOption[Index].FilePath) != BBS_BBS_DP))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -454,8 +464,14 @@ LegacyBmDeleteAllInvalidBootOptions (
|
||||
EfiBootManagerDeleteLoadOptionVariable (BootOption[Index].OptionNumber, BootOption[Index].OptionType);
|
||||
} else {
|
||||
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,
|
||||
(UINTN) ((LEGACY_BM_BOOT_OPTION_BBS_DATA *) BootOption[Index].OptionalData)->BbsIndex, (UINTN) BbsIndex));
|
||||
DEBUG ((
|
||||
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
|
||||
//
|
||||
@ -475,6 +491,7 @@ LegacyBmDeleteAllInvalidBootOptions (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
|
||||
|
||||
if (LegacyDevOrder != NULL) {
|
||||
@ -492,6 +509,7 @@ LegacyBmDeleteAllInvalidBootOptions (
|
||||
|
||||
FreePool (LegacyDevOrder);
|
||||
}
|
||||
|
||||
FreePool (BbsIndexUsed);
|
||||
return Status;
|
||||
}
|
||||
@ -697,6 +715,7 @@ LegacyBmCreateDevOrder (
|
||||
if (NULL == DevOrder) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DevOrderPtr = DevOrder;
|
||||
|
||||
DevOrderPtr->BbsType = BBS_FLOPPY;
|
||||
@ -818,6 +837,7 @@ LegacyBmUpdateDevOrder (
|
||||
if (NULL == DevOrder) {
|
||||
return LegacyBmCreateDevOrder (LocalBbsTable, BbsCount);
|
||||
}
|
||||
|
||||
//
|
||||
// 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));
|
||||
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
|
||||
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
|
||||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY
|
||||
) {
|
||||
(LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_FLOPPY)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NewPtr->Data[FDIndex] = Ptr->Data[Index];
|
||||
FDIndex++;
|
||||
}
|
||||
|
||||
NewFDPtr = NewPtr->Data;
|
||||
|
||||
//
|
||||
@ -891,14 +913,16 @@ LegacyBmUpdateDevOrder (
|
||||
NewPtr->Length = (UINT16)(sizeof (UINT16) + HDCount * sizeof (UINT16));
|
||||
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
|
||||
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
|
||||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK
|
||||
) {
|
||||
(LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_HARDDISK)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NewPtr->Data[HDIndex] = Ptr->Data[Index];
|
||||
HDIndex++;
|
||||
}
|
||||
|
||||
NewHDPtr = NewPtr->Data;
|
||||
|
||||
//
|
||||
@ -910,14 +934,16 @@ LegacyBmUpdateDevOrder (
|
||||
NewPtr->Length = (UINT16)(sizeof (UINT16) + CDCount * sizeof (UINT16));
|
||||
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
|
||||
if (!LegacyBmValidBbsEntry (&LocalBbsTable[Ptr->Data[Index] & 0xFF]) ||
|
||||
LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM
|
||||
) {
|
||||
(LocalBbsTable[Ptr->Data[Index] & 0xFF].DeviceType != BBS_CDROM)
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
NewPtr->Data[CDIndex] = Ptr->Data[Index];
|
||||
CDIndex++;
|
||||
}
|
||||
|
||||
NewCDPtr = NewPtr->Data;
|
||||
|
||||
//
|
||||
@ -929,14 +955,16 @@ LegacyBmUpdateDevOrder (
|
||||
NewPtr->Length = (UINT16)(sizeof (UINT16) + NETCount * sizeof (UINT16));
|
||||
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
|
||||
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;
|
||||
}
|
||||
|
||||
NewPtr->Data[NETIndex] = Ptr->Data[Index];
|
||||
NETIndex++;
|
||||
}
|
||||
|
||||
NewNETPtr = NewPtr->Data;
|
||||
|
||||
//
|
||||
@ -948,14 +976,16 @@ LegacyBmUpdateDevOrder (
|
||||
NewPtr->Length = (UINT16)(sizeof (UINT16) + BEVCount * sizeof (UINT16));
|
||||
for (Index = 0; Index < Ptr->Length / sizeof (UINT16) - 1; Index++) {
|
||||
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;
|
||||
}
|
||||
|
||||
NewPtr->Data[BEVIndex] = Ptr->Data[Index];
|
||||
BEVIndex++;
|
||||
}
|
||||
|
||||
NewBEVPtr = NewPtr->Data;
|
||||
|
||||
for (Index = 0; Index < BbsCount; Index++) {
|
||||
@ -993,6 +1023,7 @@ LegacyBmUpdateDevOrder (
|
||||
Idx = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// at this point we have copied those valid indexes to new buffer
|
||||
// and we should check if there is any new appeared boot device
|
||||
@ -1015,6 +1046,7 @@ LegacyBmUpdateDevOrder (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CopyMem (&NewDevPtr[Index2 + 1], &NewDevPtr[Index2], (*Idx - Index2) * sizeof (UINT16));
|
||||
NewDevPtr[Index2] = (UINT16)(Index & 0xFF);
|
||||
(*Idx)++;
|
||||
@ -1089,9 +1121,11 @@ LegacyBmSetPriorityForSameTypeDev (
|
||||
FreePool (DevOrder);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
LocalBbsTable[BbsIndex].BootPriority = *Priority;
|
||||
(*Priority)++;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// boot priority always starts at 0
|
||||
//
|
||||
Priority = 0;
|
||||
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.
|
||||
//
|
||||
@ -1236,6 +1272,7 @@ LegacyBmRefreshBbsTableForBoot (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// we have to set the boot priority for other BBS entries with different device types
|
||||
//
|
||||
@ -1246,7 +1283,8 @@ LegacyBmRefreshBbsTableForBoot (
|
||||
DeviceTypeCount = 1;
|
||||
for (Index = 0; Index < OptionCount; Index++) {
|
||||
if ((DevicePathType (Option[Index].FilePath) != BBS_DEVICE_PATH) ||
|
||||
(DevicePathSubType (Option[Index].FilePath) != BBS_BBS_DP)) {
|
||||
(DevicePathSubType (Option[Index].FilePath) != BBS_BBS_DP))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1256,6 +1294,7 @@ LegacyBmRefreshBbsTableForBoot (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (DeviceTypeIndex < DeviceTypeCount) {
|
||||
//
|
||||
// We don't want to process twice for a device type
|
||||
@ -1273,6 +1312,7 @@ LegacyBmRefreshBbsTableForBoot (
|
||||
&Priority
|
||||
);
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOptions (Option, OptionCount);
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
@ -1282,7 +1322,6 @@ LegacyBmRefreshBbsTableForBoot (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Boot the legacy system with the boot option.
|
||||
|
||||
@ -1309,6 +1348,7 @@ LegacyBmBoot (
|
||||
BootOption->Status = EFI_UNSUPPORTED;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// 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) &&
|
||||
(CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
|
||||
(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;
|
||||
}
|
||||
}
|
||||
@ -1450,6 +1491,7 @@ LegacyBmRefreshAllBootOption (
|
||||
LegacyBmDeleteAllBootOptions ();
|
||||
return;
|
||||
}
|
||||
|
||||
PERF_START (NULL, "LegacyBootOptionEnum", "BDS", 0);
|
||||
|
||||
//
|
||||
@ -1506,7 +1548,8 @@ LegacyBmRefreshAllBootOption (
|
||||
if (LegacyBmFindBootOption (&BootOptions[Index], ExistingBootOptions, ExistingBootOptionCount) == -1) {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&BootOptions[Index], (UINTN)-1);
|
||||
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)((LEGACY_BM_BOOT_OPTION_BBS_DATA *)BootOptions[Index].OptionalData)->BbsIndex,
|
||||
BootOptions[Index].Description,
|
||||
|
@ -82,7 +82,6 @@ EFI_FW_VOL_BLOCK_DEVICE mEmuVarsFvb = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
|
||||
|
||||
@ -103,7 +102,6 @@ FvbVirtualAddressChangeEvent (
|
||||
EfiConvertPointer (0x0, &mEmuVarsFvb.BufferPtr);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FVB protocol APIs
|
||||
//
|
||||
@ -141,7 +139,6 @@ FvbProtocolGetPhysicalAddress (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The GetBlockSize() function retrieves the size of the requested
|
||||
block. It also returns the number of additional blocks with
|
||||
@ -191,7 +188,6 @@ FvbProtocolGetBlockSize (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The GetAttributes() function retrieves the attributes and
|
||||
current settings of the block. Status Codes Returned
|
||||
@ -226,7 +222,6 @@ FvbProtocolGetAttributes (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The SetAttributes() function sets configurable firmware volume
|
||||
attributes and returns the new settings of the firmware volume.
|
||||
@ -259,7 +254,6 @@ FvbProtocolSetAttributes (
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Erases and initializes a firmware volume block.
|
||||
|
||||
@ -333,14 +327,17 @@ FvbProtocolEraseBlocks (
|
||||
if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
|
||||
break;
|
||||
}
|
||||
|
||||
NumOfLba = VA_ARG (Args, UINTN);
|
||||
|
||||
if (StartingLba > EMU_FVB_NUM_TOTAL_BLOCKS ||
|
||||
NumOfLba > EMU_FVB_NUM_TOTAL_BLOCKS - StartingLba) {
|
||||
if ((StartingLba > EMU_FVB_NUM_TOTAL_BLOCKS) ||
|
||||
(NumOfLba > EMU_FVB_NUM_TOTAL_BLOCKS - StartingLba))
|
||||
{
|
||||
VA_END (Args);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
VA_END (Args);
|
||||
|
||||
//
|
||||
@ -352,6 +349,7 @@ FvbProtocolEraseBlocks (
|
||||
if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
|
||||
break;
|
||||
}
|
||||
|
||||
NumOfLba = VA_ARG (Args, UINTN);
|
||||
|
||||
ErasePtr = FvbDevice->BufferPtr;
|
||||
@ -360,6 +358,7 @@ FvbProtocolEraseBlocks (
|
||||
|
||||
SetMem (ErasePtr, EraseSize, ERASED_UINT8);
|
||||
} while (1);
|
||||
|
||||
VA_END (Args);
|
||||
|
||||
//
|
||||
@ -372,7 +371,6 @@ FvbProtocolEraseBlocks (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Writes the specified number of bytes from the input buffer to the block.
|
||||
|
||||
@ -448,8 +446,9 @@ FvbProtocolWrite (
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
if (Lba >= EMU_FVB_NUM_TOTAL_BLOCKS ||
|
||||
Offset > FvbDevice->BlockSize) {
|
||||
if ((Lba >= EMU_FVB_NUM_TOTAL_BLOCKS) ||
|
||||
(Offset > FvbDevice->BlockSize))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -468,7 +467,6 @@ FvbProtocolWrite (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reads the specified number of bytes into a buffer from the specified block.
|
||||
|
||||
@ -532,8 +530,9 @@ FvbProtocolRead (
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
|
||||
if (Lba >= EMU_FVB_NUM_TOTAL_BLOCKS ||
|
||||
Offset > FvbDevice->BlockSize) {
|
||||
if ((Lba >= EMU_FVB_NUM_TOTAL_BLOCKS) ||
|
||||
(Offset > FvbDevice->BlockSize))
|
||||
{
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -552,7 +551,6 @@ FvbProtocolRead (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the integrity of firmware volume header.
|
||||
|
||||
@ -578,10 +576,12 @@ ValidateFvHeader (
|
||||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
|
||||
(FwVolHeader->FvLength != EMU_FVB_SIZE) ||
|
||||
(FwVolHeader->HeaderLength != EMU_FV_HEADER_LENGTH)
|
||||
) {
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Verify the header checksum
|
||||
//
|
||||
@ -595,7 +595,6 @@ ValidateFvHeader (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initializes the FV Header and Variable Store Header
|
||||
to support variable operations.
|
||||
@ -724,21 +723,27 @@ FvbInitialize (
|
||||
//
|
||||
// Verify that the PCD's are set correctly.
|
||||
//
|
||||
ASSERT (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) %
|
||||
EMU_FVB_BLOCK_SIZE == 0);
|
||||
ASSERT (
|
||||
FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) %
|
||||
EMU_FVB_BLOCK_SIZE == 0
|
||||
);
|
||||
if (
|
||||
(PcdGet32 (PcdFlashNvStorageVariableSize) +
|
||||
PcdGet32 (PcdFlashNvStorageFtwWorkingSize)
|
||||
) >
|
||||
EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE
|
||||
) {
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "EMU Variable invalid PCD sizes\n"));
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0) {
|
||||
DEBUG ((DEBUG_INFO, "Disabling EMU Variable FVB since "
|
||||
"flash variables appear to be supported.\n"));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Disabling EMU Variable FVB since "
|
||||
"flash variables appear to be supported.\n"
|
||||
));
|
||||
return EFI_ABORTED;
|
||||
}
|
||||
|
||||
@ -776,6 +781,7 @@ FvbInitialize (
|
||||
SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8);
|
||||
InitializeFvAndVariableStoreHeaders (Ptr);
|
||||
}
|
||||
|
||||
PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN)Ptr);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
@ -783,8 +789,10 @@ FvbInitialize (
|
||||
// Initialize the Fault Tolerant Write data area
|
||||
//
|
||||
SubPtr = (VOID *)((UINT8 *)Ptr + PcdGet32 (PcdFlashNvStorageVariableSize));
|
||||
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase,
|
||||
(UINT32)(UINTN) SubPtr);
|
||||
PcdStatus = PcdSet32S (
|
||||
PcdFlashNvStorageFtwWorkingBase,
|
||||
(UINT32)(UINTN)SubPtr
|
||||
);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
//
|
||||
@ -792,8 +800,10 @@ FvbInitialize (
|
||||
//
|
||||
SubPtr = (VOID *)((UINT8 *)Ptr +
|
||||
EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE);
|
||||
PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase,
|
||||
(UINT32)(UINTN) SubPtr);
|
||||
PcdStatus = PcdSet32S (
|
||||
PcdFlashNvStorageFtwSpareBase,
|
||||
(UINT32)(UINTN)SubPtr
|
||||
);
|
||||
ASSERT_RETURN_ERROR (PcdStatus);
|
||||
|
||||
//
|
||||
@ -833,5 +843,3 @@ FvbInitialize (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,11 +25,9 @@ Abstract:
|
||||
#pragma pack (1)
|
||||
|
||||
typedef struct {
|
||||
|
||||
EFI_FIRMWARE_VOLUME_HEADER FvHdr;
|
||||
EFI_FV_BLOCK_MAP_ENTRY EndBlockMap;
|
||||
VARIABLE_STORE_HEADER VarHdr;
|
||||
|
||||
} FVB_FV_HDR_AND_VARS_TEMPLATE;
|
||||
|
||||
typedef struct {
|
||||
@ -48,7 +46,6 @@ typedef struct {
|
||||
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
|
||||
} EFI_FW_VOL_BLOCK_DEVICE;
|
||||
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "EnrollDefaultKeys.h"
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -137,7 +136,6 @@ CONST UINT8 mMicrosoftKek[] = {
|
||||
|
||||
CONST UINTN mSizeOfMicrosoftKek = sizeof mMicrosoftKek;
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -266,7 +264,6 @@ CONST UINT8 mMicrosoftPca[] = {
|
||||
|
||||
CONST UINTN mSizeOfMicrosoftPca = sizeof mMicrosoftPca;
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -398,7 +395,6 @@ CONST UINT8 mMicrosoftUefiCa[] = {
|
||||
|
||||
CONST UINTN mSizeOfMicrosoftUefiCa = sizeof mMicrosoftUefiCa;
|
||||
|
||||
|
||||
//
|
||||
// The Microsoft.UefiSecureBootLogo.Tests.OutOfBoxConfirmDBXisPresent test case
|
||||
// of the Secure Boot Logo Test in the Microsoft Hardware Certification Kit
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "EnrollDefaultKeys.h"
|
||||
|
||||
|
||||
/**
|
||||
Fetch the X509 certificate (to be used as Platform Key and first Key Exchange
|
||||
Key) from SMBIOS.
|
||||
@ -75,14 +74,21 @@ GetPkKek1 (
|
||||
//
|
||||
// Format the application prefix, for OEM String matching.
|
||||
//
|
||||
AsciiSPrint (OvmfPkKek1AppPrefix, sizeof OvmfPkKek1AppPrefix, "%g:",
|
||||
&gOvmfPkKek1AppPrefixGuid);
|
||||
AsciiSPrint (
|
||||
OvmfPkKek1AppPrefix,
|
||||
sizeof OvmfPkKek1AppPrefix,
|
||||
"%g:",
|
||||
&gOvmfPkKek1AppPrefixGuid
|
||||
);
|
||||
|
||||
//
|
||||
// Scan all "OEM Strings" tables.
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL,
|
||||
(VOID **)&Smbios);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiSmbiosProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&Smbios
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AsciiPrint ("error: failed to locate EFI_SMBIOS_PROTOCOL: %r\n", Status);
|
||||
return Status;
|
||||
@ -92,7 +98,8 @@ GetPkKek1 (
|
||||
Type = SMBIOS_TYPE_OEM_STRINGS;
|
||||
for (Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL);
|
||||
!EFI_ERROR (Status);
|
||||
Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL)) {
|
||||
Status = Smbios->GetNext (Smbios, &Handle, &Type, &Header, NULL))
|
||||
{
|
||||
CONST CHAR8 *OemString;
|
||||
UINTN Idx;
|
||||
|
||||
@ -102,6 +109,7 @@ GetPkKek1 (
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
OemStringsTable = (SMBIOS_TABLE_TYPE11 *)Header;
|
||||
|
||||
//
|
||||
@ -115,8 +123,12 @@ GetPkKek1 (
|
||||
//
|
||||
// NUL-terminate the candidate prefix for case-insensitive comparison.
|
||||
//
|
||||
AsciiStrnCpyS (CandidatePrefix, sizeof CandidatePrefix, OemString,
|
||||
GUID_STRING_LENGTH + 1);
|
||||
AsciiStrnCpyS (
|
||||
CandidatePrefix,
|
||||
sizeof CandidatePrefix,
|
||||
OemString,
|
||||
GUID_STRING_LENGTH + 1
|
||||
);
|
||||
if (AsciiStriCmp (OvmfPkKek1AppPrefix, CandidatePrefix) == 0) {
|
||||
//
|
||||
// The current string matches the prefix.
|
||||
@ -124,6 +136,7 @@ GetPkKek1 (
|
||||
Base64Cert = OemString + GUID_STRING_LENGTH + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
OemString += AsciiStrSize (OemString);
|
||||
}
|
||||
|
||||
@ -139,8 +152,11 @@ GetPkKek1 (
|
||||
//
|
||||
// No table with a matching string has been found.
|
||||
//
|
||||
AsciiPrint ("error: OEM String with app prefix %g not found: %r\n",
|
||||
&gOvmfPkKek1AppPrefixGuid, Status);
|
||||
AsciiPrint (
|
||||
"error: OEM String with app prefix %g not found: %r\n",
|
||||
&gOvmfPkKek1AppPrefixGuid,
|
||||
Status
|
||||
);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -157,12 +173,16 @@ GetPkKek1 (
|
||||
ASSERT (DecodedCertSize > 0);
|
||||
break;
|
||||
case EFI_SUCCESS:
|
||||
AsciiPrint ("error: empty certificate after app prefix %g\n",
|
||||
&gOvmfPkKek1AppPrefixGuid);
|
||||
AsciiPrint (
|
||||
"error: empty certificate after app prefix %g\n",
|
||||
&gOvmfPkKek1AppPrefixGuid
|
||||
);
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
default:
|
||||
AsciiPrint ("error: invalid base64 string after app prefix %g\n",
|
||||
&gOvmfPkKek1AppPrefixGuid);
|
||||
AsciiPrint (
|
||||
"error: invalid base64 string after app prefix %g\n",
|
||||
&gOvmfPkKek1AppPrefixGuid
|
||||
);
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -178,8 +198,12 @@ GetPkKek1 (
|
||||
//
|
||||
// Decoding will succeed at this point.
|
||||
//
|
||||
Status = Base64Decode (Base64Cert, Base64CertLen, DecodedCert,
|
||||
&DecodedCertSize);
|
||||
Status = Base64Decode (
|
||||
Base64Cert,
|
||||
Base64CertLen,
|
||||
DecodedCert,
|
||||
&DecodedCertSize
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
*PkKek1 = DecodedCert;
|
||||
@ -187,7 +211,6 @@ GetPkKek1 (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enroll a set of certificates in a global variable, overwriting it.
|
||||
|
||||
@ -259,25 +282,30 @@ EnrollListOfCerts (
|
||||
VA_START (Marker, CertType);
|
||||
for (Cert = VA_ARG (Marker, CONST UINT8 *);
|
||||
Cert != NULL;
|
||||
Cert = VA_ARG (Marker, CONST UINT8 *)) {
|
||||
Cert = VA_ARG (Marker, CONST UINT8 *))
|
||||
{
|
||||
UINTN CertSize;
|
||||
|
||||
CertSize = VA_ARG (Marker, UINTN);
|
||||
(VOID)VA_ARG (Marker, CONST EFI_GUID *);
|
||||
|
||||
if (CertSize == 0 ||
|
||||
CertSize > MAX_UINT32 - sizeof *RepeatingHeader ||
|
||||
DataSize > MAX_UINT32 - sizeof *RepeatingHeader - CertSize) {
|
||||
if ((CertSize == 0) ||
|
||||
(CertSize > MAX_UINT32 - sizeof *RepeatingHeader) ||
|
||||
(DataSize > MAX_UINT32 - sizeof *RepeatingHeader - CertSize))
|
||||
{
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
DataSize += sizeof *RepeatingHeader + CertSize;
|
||||
}
|
||||
|
||||
VA_END (Marker);
|
||||
|
||||
if (DataSize == sizeof *SingleHeader) {
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Out;
|
||||
}
|
||||
@ -295,6 +323,7 @@ EnrollListOfCerts (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeData;
|
||||
}
|
||||
|
||||
SingleHeader->TimeStamp.Pad1 = 0;
|
||||
SingleHeader->TimeStamp.Nanosecond = 0;
|
||||
SingleHeader->TimeStamp.TimeZone = 0;
|
||||
@ -320,7 +349,8 @@ EnrollListOfCerts (
|
||||
VA_START (Marker, CertType);
|
||||
for (Cert = VA_ARG (Marker, CONST UINT8 *);
|
||||
Cert != NULL;
|
||||
Cert = VA_ARG (Marker, CONST UINT8 *)) {
|
||||
Cert = VA_ARG (Marker, CONST UINT8 *))
|
||||
{
|
||||
UINTN CertSize;
|
||||
CONST EFI_GUID *OwnerGuid;
|
||||
|
||||
@ -340,28 +370,38 @@ EnrollListOfCerts (
|
||||
CopyMem (Position, Cert, CertSize);
|
||||
Position += CertSize;
|
||||
}
|
||||
|
||||
VA_END (Marker);
|
||||
|
||||
ASSERT (Data + DataSize == Position);
|
||||
|
||||
Status = gRT->SetVariable (VariableName, VendorGuid,
|
||||
Status = gRT->SetVariable (
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
(EFI_VARIABLE_NON_VOLATILE |
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS |
|
||||
EFI_VARIABLE_RUNTIME_ACCESS |
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS),
|
||||
DataSize, Data);
|
||||
DataSize,
|
||||
Data
|
||||
);
|
||||
|
||||
FreeData:
|
||||
FreePool (Data);
|
||||
|
||||
Out:
|
||||
if (EFI_ERROR (Status)) {
|
||||
AsciiPrint ("error: %a(\"%s\", %g): %r\n", __FUNCTION__, VariableName,
|
||||
VendorGuid, Status);
|
||||
}
|
||||
return Status;
|
||||
AsciiPrint (
|
||||
"error: %a(\"%s\", %g): %r\n",
|
||||
__FUNCTION__,
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
Status
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Read a UEFI variable into a caller-allocated buffer, enforcing an exact size.
|
||||
@ -417,26 +457,35 @@ GetExact (
|
||||
Size = DataSize;
|
||||
Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &Size, Data);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (Status == EFI_NOT_FOUND && AllowMissing) {
|
||||
if ((Status == EFI_NOT_FOUND) && AllowMissing) {
|
||||
ZeroMem (Data, DataSize);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
AsciiPrint ("error: GetVariable(\"%s\", %g): %r\n", VariableName,
|
||||
VendorGuid, Status);
|
||||
AsciiPrint (
|
||||
"error: GetVariable(\"%s\", %g): %r\n",
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
Status
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
if (Size != DataSize) {
|
||||
AsciiPrint ("error: GetVariable(\"%s\", %g): expected size 0x%Lx, "
|
||||
"got 0x%Lx\n", VariableName, VendorGuid, (UINT64)DataSize, (UINT64)Size);
|
||||
AsciiPrint (
|
||||
"error: GetVariable(\"%s\", %g): expected size 0x%Lx, "
|
||||
"got 0x%Lx\n",
|
||||
VariableName,
|
||||
VendorGuid,
|
||||
(UINT64)DataSize,
|
||||
(UINT64)Size
|
||||
);
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Populate a SETTINGS structure from the underlying UEFI variables.
|
||||
|
||||
@ -469,37 +518,60 @@ GetSettings (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = GetExact (EFI_SETUP_MODE_NAME, &gEfiGlobalVariableGuid,
|
||||
&Settings->SetupMode, sizeof Settings->SetupMode, FALSE);
|
||||
Status = GetExact (
|
||||
EFI_SETUP_MODE_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&Settings->SetupMode,
|
||||
sizeof Settings->SetupMode,
|
||||
FALSE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = GetExact (EFI_SECURE_BOOT_MODE_NAME, &gEfiGlobalVariableGuid,
|
||||
&Settings->SecureBoot, sizeof Settings->SecureBoot, FALSE);
|
||||
Status = GetExact (
|
||||
EFI_SECURE_BOOT_MODE_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&Settings->SecureBoot,
|
||||
sizeof Settings->SecureBoot,
|
||||
FALSE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = GetExact (EFI_SECURE_BOOT_ENABLE_NAME,
|
||||
&gEfiSecureBootEnableDisableGuid, &Settings->SecureBootEnable,
|
||||
sizeof Settings->SecureBootEnable, TRUE);
|
||||
Status = GetExact (
|
||||
EFI_SECURE_BOOT_ENABLE_NAME,
|
||||
&gEfiSecureBootEnableDisableGuid,
|
||||
&Settings->SecureBootEnable,
|
||||
sizeof Settings->SecureBootEnable,
|
||||
TRUE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = GetExact (EFI_CUSTOM_MODE_NAME, &gEfiCustomModeEnableGuid,
|
||||
&Settings->CustomMode, sizeof Settings->CustomMode, FALSE);
|
||||
Status = GetExact (
|
||||
EFI_CUSTOM_MODE_NAME,
|
||||
&gEfiCustomModeEnableGuid,
|
||||
&Settings->CustomMode,
|
||||
sizeof Settings->CustomMode,
|
||||
FALSE
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = GetExact (EFI_VENDOR_KEYS_VARIABLE_NAME, &gEfiGlobalVariableGuid,
|
||||
&Settings->VendorKeys, sizeof Settings->VendorKeys, FALSE);
|
||||
Status = GetExact (
|
||||
EFI_VENDOR_KEYS_VARIABLE_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&Settings->VendorKeys,
|
||||
sizeof Settings->VendorKeys,
|
||||
FALSE
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Print the contents of a SETTINGS structure to the UEFI console.
|
||||
|
||||
@ -511,12 +583,17 @@ PrintSettings (
|
||||
IN CONST SETTINGS *Settings
|
||||
)
|
||||
{
|
||||
AsciiPrint ("info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d "
|
||||
"CustomMode=%d VendorKeys=%d\n", Settings->SetupMode, Settings->SecureBoot,
|
||||
Settings->SecureBootEnable, Settings->CustomMode, Settings->VendorKeys);
|
||||
AsciiPrint (
|
||||
"info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d "
|
||||
"CustomMode=%d VendorKeys=%d\n",
|
||||
Settings->SetupMode,
|
||||
Settings->SecureBoot,
|
||||
Settings->SecureBootEnable,
|
||||
Settings->CustomMode,
|
||||
Settings->VendorKeys
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Entry point function of this shell application.
|
||||
**/
|
||||
@ -534,7 +611,7 @@ ShellAppMain (
|
||||
UINTN SizeOfPkKek1;
|
||||
BOOLEAN NoDefault;
|
||||
|
||||
if (Argc == 2 && StrCmp (Argv[1], L"--no-default") == 0) {
|
||||
if ((Argc == 2) && (StrCmp (Argv[1], L"--no-default") == 0)) {
|
||||
NoDefault = TRUE;
|
||||
} else {
|
||||
NoDefault = FALSE;
|
||||
@ -552,6 +629,7 @@ ShellAppMain (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return RetVal;
|
||||
}
|
||||
|
||||
PrintSettings (&Settings);
|
||||
|
||||
if (Settings.SetupMode != 1) {
|
||||
@ -581,13 +659,21 @@ ShellAppMain (
|
||||
//
|
||||
if (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_BOOTSERVICE_ACCESS),
|
||||
sizeof Settings.CustomMode, &Settings.CustomMode);
|
||||
sizeof Settings.CustomMode,
|
||||
&Settings.CustomMode
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AsciiPrint ("error: SetVariable(\"%s\", %g): %r\n", EFI_CUSTOM_MODE_NAME,
|
||||
&gEfiCustomModeEnableGuid, Status);
|
||||
AsciiPrint (
|
||||
"error: SetVariable(\"%s\", %g): %r\n",
|
||||
EFI_CUSTOM_MODE_NAME,
|
||||
&gEfiCustomModeEnableGuid,
|
||||
Status
|
||||
);
|
||||
goto FreePkKek1;
|
||||
}
|
||||
}
|
||||
@ -600,17 +686,26 @@ ShellAppMain (
|
||||
EFI_IMAGE_SECURITY_DATABASE,
|
||||
&gEfiImageSecurityDatabaseGuid,
|
||||
&gEfiCertX509Guid,
|
||||
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid,
|
||||
NULL);
|
||||
PkKek1,
|
||||
SizeOfPkKek1,
|
||||
&gEfiCallerIdGuid,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
Status = EnrollListOfCerts (
|
||||
EFI_IMAGE_SECURITY_DATABASE,
|
||||
&gEfiImageSecurityDatabaseGuid,
|
||||
&gEfiCertX509Guid,
|
||||
mMicrosoftPca, mSizeOfMicrosoftPca, &gMicrosoftVendorGuid,
|
||||
mMicrosoftUefiCa, mSizeOfMicrosoftUefiCa, &gMicrosoftVendorGuid,
|
||||
NULL);
|
||||
mMicrosoftPca,
|
||||
mSizeOfMicrosoftPca,
|
||||
&gMicrosoftVendorGuid,
|
||||
mMicrosoftUefiCa,
|
||||
mSizeOfMicrosoftUefiCa,
|
||||
&gMicrosoftVendorGuid,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreePkKek1;
|
||||
}
|
||||
@ -622,8 +717,11 @@ ShellAppMain (
|
||||
EFI_IMAGE_SECURITY_DATABASE1,
|
||||
&gEfiImageSecurityDatabaseGuid,
|
||||
&gEfiCertSha256Guid,
|
||||
mSha256OfDevNull, mSizeOfSha256OfDevNull, &gEfiCallerIdGuid,
|
||||
NULL);
|
||||
mSha256OfDevNull,
|
||||
mSizeOfSha256OfDevNull,
|
||||
&gEfiCallerIdGuid,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreePkKek1;
|
||||
}
|
||||
@ -636,17 +734,26 @@ ShellAppMain (
|
||||
EFI_KEY_EXCHANGE_KEY_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&gEfiCertX509Guid,
|
||||
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid,
|
||||
NULL);
|
||||
PkKek1,
|
||||
SizeOfPkKek1,
|
||||
&gEfiCallerIdGuid,
|
||||
NULL
|
||||
);
|
||||
} else {
|
||||
Status = EnrollListOfCerts (
|
||||
EFI_KEY_EXCHANGE_KEY_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&gEfiCertX509Guid,
|
||||
PkKek1, SizeOfPkKek1, &gEfiCallerIdGuid,
|
||||
mMicrosoftKek, mSizeOfMicrosoftKek, &gMicrosoftVendorGuid,
|
||||
NULL);
|
||||
PkKek1,
|
||||
SizeOfPkKek1,
|
||||
&gEfiCallerIdGuid,
|
||||
mMicrosoftKek,
|
||||
mSizeOfMicrosoftKek,
|
||||
&gMicrosoftVendorGuid,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreePkKek1;
|
||||
}
|
||||
@ -658,8 +765,11 @@ ShellAppMain (
|
||||
EFI_PLATFORM_KEY_NAME,
|
||||
&gEfiGlobalVariableGuid,
|
||||
&gEfiCertX509Guid,
|
||||
PkKek1, SizeOfPkKek1, &gEfiGlobalVariableGuid,
|
||||
NULL);
|
||||
PkKek1,
|
||||
SizeOfPkKek1,
|
||||
&gEfiGlobalVariableGuid,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreePkKek1;
|
||||
}
|
||||
@ -669,12 +779,20 @@ ShellAppMain (
|
||||
// signatures.
|
||||
//
|
||||
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,
|
||||
sizeof Settings.CustomMode, &Settings.CustomMode);
|
||||
sizeof Settings.CustomMode,
|
||||
&Settings.CustomMode
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
AsciiPrint ("error: SetVariable(\"%s\", %g): %r\n", EFI_CUSTOM_MODE_NAME,
|
||||
&gEfiCustomModeEnableGuid, Status);
|
||||
AsciiPrint (
|
||||
"error: SetVariable(\"%s\", %g): %r\n",
|
||||
EFI_CUSTOM_MODE_NAME,
|
||||
&gEfiCustomModeEnableGuid,
|
||||
Status
|
||||
);
|
||||
goto FreePkKek1;
|
||||
}
|
||||
|
||||
@ -713,11 +831,13 @@ ShellAppMain (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreePkKek1;
|
||||
}
|
||||
|
||||
PrintSettings (&Settings);
|
||||
|
||||
if (Settings.SetupMode != 0 || Settings.SecureBoot != 1 ||
|
||||
Settings.SecureBootEnable != 1 || Settings.CustomMode != 0 ||
|
||||
Settings.VendorKeys != 0) {
|
||||
if ((Settings.SetupMode != 0) || (Settings.SecureBoot != 1) ||
|
||||
(Settings.SecureBootEnable != 1) || (Settings.CustomMode != 0) ||
|
||||
(Settings.VendorKeys != 0))
|
||||
{
|
||||
AsciiPrint ("error: unexpected\n");
|
||||
goto FreePkKek1;
|
||||
}
|
||||
|
@ -106,7 +106,6 @@ typedef struct {
|
||||
} REPEATING_HEADER;
|
||||
#pragma pack ()
|
||||
|
||||
|
||||
//
|
||||
// A structure that collects the values of UEFI variables related to Secure
|
||||
// Boot.
|
||||
@ -119,7 +118,6 @@ typedef struct {
|
||||
UINT8 VendorKeys;
|
||||
} SETTINGS;
|
||||
|
||||
|
||||
//
|
||||
// Refer to "AuthData.c" for details on the following objects.
|
||||
//
|
||||
|
@ -51,21 +51,34 @@ MapGcdMmioSpace (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gDS->AddMemorySpace (EfiGcdMemoryTypeMemoryMappedIo, Base, Size,
|
||||
EFI_MEMORY_UC);
|
||||
Status = gDS->AddMemorySpace (
|
||||
EfiGcdMemoryTypeMemoryMappedIo,
|
||||
Base,
|
||||
Size,
|
||||
EFI_MEMORY_UC
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to add GCD memory space for region [0x%Lx+0x%Lx)\n",
|
||||
__FUNCTION__, Base, Size));
|
||||
__FUNCTION__,
|
||||
Base,
|
||||
Size
|
||||
));
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = gDS->SetMemorySpaceAttributes (Base, Size, EFI_MEMORY_UC);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to set memory space attributes for region [0x%Lx+0x%Lx)\n",
|
||||
__FUNCTION__, Base, Size));
|
||||
__FUNCTION__,
|
||||
Base,
|
||||
Size
|
||||
));
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -114,16 +127,24 @@ ProcessPciHost (
|
||||
*Mmio64Size = 0;
|
||||
IoTranslation = 0;
|
||||
|
||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
||||
(VOID **)&FdtClient);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gFdtClientProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&FdtClient
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = FdtClient->FindCompatibleNode (FdtClient, "pci-host-ecam-generic",
|
||||
&Node);
|
||||
Status = FdtClient->FindCompatibleNode (
|
||||
FdtClient,
|
||||
"pci-host-ecam-generic",
|
||||
&Node
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO,
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: No 'pci-host-ecam-generic' compatible DT node found\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -134,15 +155,22 @@ ProcessPciHost (
|
||||
// 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.
|
||||
//
|
||||
Status = FdtClient->FindNextCompatibleNode (FdtClient,
|
||||
"pci-host-ecam-generic", Node, &Tmp);
|
||||
Status = FdtClient->FindNextCompatibleNode (
|
||||
FdtClient,
|
||||
"pci-host-ecam-generic",
|
||||
Node,
|
||||
&Tmp
|
||||
);
|
||||
ASSERT (Status == EFI_NOT_FOUND);
|
||||
);
|
||||
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg", &Prop, &Len);
|
||||
if (EFI_ERROR (Status) || Len != 2 * sizeof (UINT64)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: 'reg' property not found or invalid\n",
|
||||
__FUNCTION__));
|
||||
if (EFI_ERROR (Status) || (Len != 2 * sizeof (UINT64))) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: 'reg' property not found or invalid\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -155,13 +183,22 @@ ProcessPciHost (
|
||||
//
|
||||
// Fetch the bus range (note: inclusive).
|
||||
//
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "bus-range", &Prop,
|
||||
&Len);
|
||||
if (EFI_ERROR (Status) || Len != 2 * sizeof (UINT32)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: 'bus-range' not found or invalid\n",
|
||||
__FUNCTION__));
|
||||
Status = FdtClient->GetNodeProperty (
|
||||
FdtClient,
|
||||
Node,
|
||||
"bus-range",
|
||||
&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;
|
||||
}
|
||||
|
||||
*BusMin = SwapBytes32 (((CONST UINT32 *)Prop)[0]);
|
||||
*BusMax = SwapBytes32 (((CONST UINT32 *)Prop)[1]);
|
||||
|
||||
@ -169,10 +206,14 @@ ProcessPciHost (
|
||||
// Sanity check: the config space must accommodate all 4K register bytes of
|
||||
// all 8 functions of all 32 devices of all buses.
|
||||
//
|
||||
if (*BusMax < *BusMin || *BusMax - *BusMin == MAX_UINT32 ||
|
||||
DivU64x32 (ConfigSize, SIZE_4KB * 8 * 32) < *BusMax - *BusMin + 1) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: invalid 'bus-range' and/or 'reg'\n",
|
||||
__FUNCTION__));
|
||||
if ((*BusMax < *BusMin) || (*BusMax - *BusMin == MAX_UINT32) ||
|
||||
(DivU64x32 (ConfigSize, SIZE_4KB * 8 * 32) < *BusMax - *BusMin + 1))
|
||||
{
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: invalid 'bus-range' and/or 'reg'\n",
|
||||
__FUNCTION__
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -180,14 +221,16 @@ ProcessPciHost (
|
||||
// Iterate over "ranges".
|
||||
//
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len);
|
||||
if (EFI_ERROR (Status) || Len == 0 ||
|
||||
Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) {
|
||||
if (EFI_ERROR (Status) || (Len == 0) ||
|
||||
(Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);
|
||||
++RecordIdx) {
|
||||
++RecordIdx)
|
||||
{
|
||||
CONST DTB_PCI_HOST_RANGE_RECORD *Record;
|
||||
|
||||
Record = (CONST DTB_PCI_HOST_RANGE_RECORD *)Prop + RecordIdx;
|
||||
@ -205,8 +248,9 @@ ProcessPciHost (
|
||||
*Mmio32Size = SwapBytes64 (Record->Size);
|
||||
Mmio32Translation = SwapBytes64 (Record->CpuBase) - *Mmio32Base;
|
||||
|
||||
if (*Mmio32Base > MAX_UINT32 || *Mmio32Size > MAX_UINT32 ||
|
||||
*Mmio32Base + *Mmio32Size > SIZE_4GB) {
|
||||
if ((*Mmio32Base > MAX_UINT32) || (*Mmio32Size > MAX_UINT32) ||
|
||||
(*Mmio32Base + *Mmio32Size > SIZE_4GB))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: MMIO32 space invalid\n", __FUNCTION__));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
@ -214,8 +258,13 @@ ProcessPciHost (
|
||||
ASSERT (PcdGet64 (PcdPciMmio32Translation) == Mmio32Translation);
|
||||
|
||||
if (Mmio32Translation != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: unsupported nonzero MMIO32 translation "
|
||||
"0x%Lx\n", __FUNCTION__, Mmio32Translation));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: unsupported nonzero MMIO32 translation "
|
||||
"0x%Lx\n",
|
||||
__FUNCTION__,
|
||||
Mmio32Translation
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@ -229,17 +278,27 @@ ProcessPciHost (
|
||||
ASSERT (PcdGet64 (PcdPciMmio64Translation) == Mmio64Translation);
|
||||
|
||||
if (Mmio64Translation != 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: unsupported nonzero MMIO64 translation "
|
||||
"0x%Lx\n", __FUNCTION__, Mmio64Translation));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: unsupported nonzero MMIO64 translation "
|
||||
"0x%Lx\n",
|
||||
__FUNCTION__,
|
||||
Mmio64Translation
|
||||
));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*IoSize == 0 || *Mmio32Size == 0) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %a space empty\n", __FUNCTION__,
|
||||
(*IoSize == 0) ? "IO" : "MMIO32"));
|
||||
|
||||
if ((*IoSize == 0) || (*Mmio32Size == 0)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: %a space empty\n",
|
||||
__FUNCTION__,
|
||||
(*IoSize == 0) ? "IO" : "MMIO32"
|
||||
));
|
||||
return EFI_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
@ -249,10 +308,23 @@ ProcessPciHost (
|
||||
//
|
||||
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",
|
||||
__FUNCTION__, ConfigBase, ConfigSize, *BusMin, *BusMax, *IoBase, *IoSize,
|
||||
IoTranslation, *Mmio32Base, *Mmio32Size, *Mmio64Base, *Mmio64Size));
|
||||
__FUNCTION__,
|
||||
ConfigBase,
|
||||
ConfigSize,
|
||||
*BusMin,
|
||||
*BusMax,
|
||||
*IoBase,
|
||||
*IoSize,
|
||||
IoTranslation,
|
||||
*Mmio32Base,
|
||||
*Mmio32Size,
|
||||
*Mmio64Base,
|
||||
*Mmio64Size
|
||||
));
|
||||
|
||||
// Map the ECAM space in the GCD memory map
|
||||
Status = MapGcdMmioSpace (ConfigBase, ConfigSize);
|
||||
@ -307,11 +379,23 @@ PciHostBridgeGetRootBridges (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Status = ProcessPciHost (&IoBase, &IoSize, &Mmio32Base, &Mmio32Size,
|
||||
&Mmio64Base, &Mmio64Size, &BusMin, &BusMax);
|
||||
Status = ProcessPciHost (
|
||||
&IoBase,
|
||||
&IoSize,
|
||||
&Mmio32Base,
|
||||
&Mmio32Size,
|
||||
&Mmio64Base,
|
||||
&Mmio64Size,
|
||||
&BusMin,
|
||||
&BusMax
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: failed to discover PCI host bridge: %r\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: failed to discover PCI host bridge: %r\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
*Count = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -55,14 +55,16 @@ GetPciIoTranslation (
|
||||
// Iterate over "ranges".
|
||||
//
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "ranges", &Prop, &Len);
|
||||
if (EFI_ERROR (Status) || Len == 0 ||
|
||||
Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0) {
|
||||
if (EFI_ERROR (Status) || (Len == 0) ||
|
||||
(Len % sizeof (DTB_PCI_HOST_RANGE_RECORD) != 0))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "%a: 'ranges' not found or invalid\n", __FUNCTION__));
|
||||
return RETURN_PROTOCOL_ERROR;
|
||||
}
|
||||
|
||||
for (RecordIdx = 0; RecordIdx < Len / sizeof (DTB_PCI_HOST_RANGE_RECORD);
|
||||
++RecordIdx) {
|
||||
++RecordIdx)
|
||||
{
|
||||
CONST DTB_PCI_HOST_RANGE_RECORD *Record;
|
||||
UINT32 Type;
|
||||
|
||||
@ -75,6 +77,7 @@ GetPciIoTranslation (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return RETURN_NOT_FOUND;
|
||||
}
|
||||
|
||||
@ -106,19 +109,30 @@ FdtPciPcdProducerLibConstructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
||||
(VOID **)&FdtClient);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gFdtClientProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&FdtClient
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
PciExpressBaseAddress = 0;
|
||||
Status = FdtClient->FindCompatibleNode (FdtClient, "pci-host-ecam-generic",
|
||||
&Node);
|
||||
Status = FdtClient->FindCompatibleNode (
|
||||
FdtClient,
|
||||
"pci-host-ecam-generic",
|
||||
&Node
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg",
|
||||
(CONST VOID **)&Reg, &RegSize);
|
||||
Status = FdtClient->GetNodeProperty (
|
||||
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);
|
||||
|
||||
PcdStatus = PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE);
|
||||
@ -135,9 +149,11 @@ FdtPciPcdProducerLibConstructor (
|
||||
// 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.
|
||||
//
|
||||
DEBUG ((DEBUG_WARN,
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%a: 'pci-host-ecam-generic' device encountered with no I/O range\n",
|
||||
__FUNCTION__));
|
||||
__FUNCTION__
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,24 +36,42 @@ InitializeHighMemDxe (
|
||||
UINT64 Attributes;
|
||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
|
||||
|
||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
||||
(VOID **)&FdtClient);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gFdtClientProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&FdtClient
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL,
|
||||
(VOID **)&Cpu);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiCpuArchProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&Cpu
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Check for memory node and add the memory spaces except the lowest one
|
||||
//
|
||||
for (FindNodeStatus = FdtClient->FindMemoryNodeReg (FdtClient, &Node,
|
||||
(CONST VOID **) &Reg, &AddressCells,
|
||||
&SizeCells, &RegSize);
|
||||
for (FindNodeStatus = FdtClient->FindMemoryNodeReg (
|
||||
FdtClient,
|
||||
&Node,
|
||||
(CONST VOID **)&Reg,
|
||||
&AddressCells,
|
||||
&SizeCells,
|
||||
&RegSize
|
||||
);
|
||||
!EFI_ERROR (FindNodeStatus);
|
||||
FindNodeStatus = FdtClient->FindNextMemoryNodeReg (FdtClient, Node,
|
||||
&Node, (CONST VOID **) &Reg, &AddressCells,
|
||||
&SizeCells, &RegSize)) {
|
||||
FindNodeStatus = FdtClient->FindNextMemoryNodeReg (
|
||||
FdtClient,
|
||||
Node,
|
||||
&Node,
|
||||
(CONST VOID **)&Reg,
|
||||
&AddressCells,
|
||||
&SizeCells,
|
||||
&RegSize
|
||||
))
|
||||
{
|
||||
ASSERT (AddressCells <= 2);
|
||||
ASSERT (SizeCells <= 2);
|
||||
|
||||
@ -62,36 +80,60 @@ InitializeHighMemDxe (
|
||||
if (AddressCells > 1) {
|
||||
CurBase = (CurBase << 32) | SwapBytes32 (*Reg++);
|
||||
}
|
||||
|
||||
CurSize = SwapBytes32 (*Reg++);
|
||||
if (SizeCells > 1) {
|
||||
CurSize = (CurSize << 32) | SwapBytes32 (*Reg++);
|
||||
}
|
||||
|
||||
RegSize -= (AddressCells + SizeCells) * sizeof (UINT32);
|
||||
|
||||
Status = gDS->GetMemorySpaceDescriptor (CurBase, &GcdDescriptor);
|
||||
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",
|
||||
__FUNCTION__, CurBase, CurBase + CurSize - 1));
|
||||
__FUNCTION__,
|
||||
CurBase,
|
||||
CurBase + CurSize - 1
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (GcdDescriptor.GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
|
||||
Status = gDS->AddMemorySpace (EfiGcdMemoryTypeSystemMemory, CurBase,
|
||||
CurSize, EFI_MEMORY_WB);
|
||||
Status = gDS->AddMemorySpace (
|
||||
EfiGcdMemoryTypeSystemMemory,
|
||||
CurBase,
|
||||
CurSize,
|
||||
EFI_MEMORY_WB
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%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;
|
||||
}
|
||||
|
||||
Status = gDS->SetMemorySpaceAttributes (CurBase, CurSize,
|
||||
EFI_MEMORY_WB);
|
||||
Status = gDS->SetMemorySpaceAttributes (
|
||||
CurBase,
|
||||
CurSize,
|
||||
EFI_MEMORY_WB
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_WARN,
|
||||
DEBUG ((
|
||||
DEBUG_WARN,
|
||||
"%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;
|
||||
if ((PcdGet64 (PcdDxeNxMemoryProtectionPolicy) &
|
||||
(1U << (UINT32)EfiConventionalMemory)) != 0) {
|
||||
(1U << (UINT32)EfiConventionalMemory)) != 0)
|
||||
{
|
||||
Attributes |= EFI_MEMORY_XP;
|
||||
}
|
||||
|
||||
Status = Cpu->SetMemoryAttributes (Cpu, CurBase, CurSize, Attributes);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%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 {
|
||||
DEBUG ((DEBUG_INFO, "%a: Add System RAM @ 0x%lx - 0x%lx\n",
|
||||
__FUNCTION__, CurBase, CurBase + CurSize - 1));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%a: Add System RAM @ 0x%lx - 0x%lx\n",
|
||||
__FUNCTION__,
|
||||
CurBase,
|
||||
CurBase + CurSize - 1
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,21 +44,40 @@ InitializeVirtioFdtDxe (
|
||||
EFI_HANDLE Handle;
|
||||
UINT64 RegBase;
|
||||
|
||||
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
|
||||
(VOID **)&FdtClient);
|
||||
Status = gBS->LocateProtocol (
|
||||
&gFdtClientProtocolGuid,
|
||||
NULL,
|
||||
(VOID **)&FdtClient
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
for (FindNodeStatus = FdtClient->FindCompatibleNode (FdtClient,
|
||||
"virtio,mmio", &Node);
|
||||
for (FindNodeStatus = FdtClient->FindCompatibleNode (
|
||||
FdtClient,
|
||||
"virtio,mmio",
|
||||
&Node
|
||||
);
|
||||
!EFI_ERROR (FindNodeStatus);
|
||||
FindNodeStatus = FdtClient->FindNextCompatibleNode (FdtClient,
|
||||
"virtio,mmio", Node, &Node)) {
|
||||
|
||||
Status = FdtClient->GetNodeProperty (FdtClient, Node, "reg",
|
||||
(CONST VOID **)&Reg, &RegSize);
|
||||
FindNodeStatus = FdtClient->FindNextCompatibleNode (
|
||||
FdtClient,
|
||||
"virtio,mmio",
|
||||
Node,
|
||||
&Node
|
||||
))
|
||||
{
|
||||
Status = FdtClient->GetNodeProperty (
|
||||
FdtClient,
|
||||
Node,
|
||||
"reg",
|
||||
(CONST VOID **)&Reg,
|
||||
&RegSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: GetNodeProperty () failed (Status == %r)\n",
|
||||
__FUNCTION__, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: GetNodeProperty () failed (Status == %r)\n",
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -71,7 +90,8 @@ InitializeVirtioFdtDxe (
|
||||
DevicePath = (VIRTIO_TRANSPORT_DEVICE_PATH *)CreateDeviceNode (
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
sizeof (VIRTIO_TRANSPORT_DEVICE_PATH));
|
||||
sizeof (VIRTIO_TRANSPORT_DEVICE_PATH)
|
||||
);
|
||||
if (DevicePath == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Out of memory\n", __FUNCTION__));
|
||||
continue;
|
||||
@ -79,39 +99,62 @@ InitializeVirtioFdtDxe (
|
||||
|
||||
CopyGuid (&DevicePath->Vendor.Guid, &gVirtioMmioTransportGuid);
|
||||
DevicePath->PhysBase = RegBase;
|
||||
SetDevicePathNodeLength (&DevicePath->Vendor,
|
||||
sizeof (*DevicePath) - sizeof (DevicePath->End));
|
||||
SetDevicePathNodeLength (
|
||||
&DevicePath->Vendor,
|
||||
sizeof (*DevicePath) - sizeof (DevicePath->End)
|
||||
);
|
||||
SetDevicePathEndNode (&DevicePath->End);
|
||||
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallProtocolInterface (&Handle,
|
||||
&gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
|
||||
DevicePath);
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
&Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
EFI_NATIVE_INTERFACE,
|
||||
DevicePath
|
||||
);
|
||||
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",
|
||||
__FUNCTION__, Status));
|
||||
__FUNCTION__,
|
||||
Status
|
||||
));
|
||||
FreePool (DevicePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = VirtioMmioInstallDevice (RegBase, Handle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Failed to install VirtIO transport @ 0x%Lx "
|
||||
"on handle %p (Status == %r)\n", __FUNCTION__, RegBase,
|
||||
Handle, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Failed to install VirtIO transport @ 0x%Lx "
|
||||
"on handle %p (Status == %r)\n",
|
||||
__FUNCTION__,
|
||||
RegBase,
|
||||
Handle,
|
||||
Status
|
||||
));
|
||||
|
||||
Status = gBS->UninstallProtocolInterface (Handle,
|
||||
&gEfiDevicePathProtocolGuid, DevicePath);
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
Handle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
DevicePath
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (DevicePath);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (FindNodeStatus) && FindNodeStatus != EFI_NOT_FOUND) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: Error occurred while iterating DT nodes "
|
||||
"(FindNodeStatus == %r)\n", __FUNCTION__, FindNodeStatus));
|
||||
if (EFI_ERROR (FindNodeStatus) && (FindNodeStatus != EFI_NOT_FOUND)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"%a: Error occurred while iterating DT nodes "
|
||||
"(FindNodeStatus == %r)\n",
|
||||
__FUNCTION__,
|
||||
FindNodeStatus
|
||||
));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -7,7 +7,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef __E820_H__
|
||||
#define __E820_H__
|
||||
|
||||
|
@ -153,6 +153,9 @@ typedef struct {
|
||||
|
||||
#pragma pack()
|
||||
|
||||
extern EFI_STATUS setup_graphics(struct boot_params *buf);
|
||||
extern EFI_STATUS
|
||||
setup_graphics (
|
||||
struct boot_params *buf
|
||||
);
|
||||
|
||||
#endif /* __LINUX_BZIMAGE_H__ */
|
||||
|
@ -4,6 +4,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __MICROVM_H__
|
||||
#define __MICROVM_H__
|
||||
|
||||
|
@ -80,7 +80,6 @@ typedef enum {
|
||||
QemuFwCfgItemX86Irq0Override = 0x8002,
|
||||
QemuFwCfgItemX86E820Table = 0x8003,
|
||||
QemuFwCfgItemX86HpetData = 0x8004,
|
||||
|
||||
} FIRMWARE_CONFIG_ITEM;
|
||||
|
||||
//
|
||||
|
@ -35,7 +35,6 @@
|
||||
#define VIRTIO_VENDOR_ID 0x1AF4
|
||||
#define VIRTIO_MMIO_MAGIC 0x74726976 // "virt"
|
||||
|
||||
|
||||
//
|
||||
// VirtIo Device Specific Configuration Offsets
|
||||
//
|
||||
@ -104,7 +103,6 @@ typedef struct {
|
||||
volatile UINT16 *UsedEvent; // unused as per negotiation
|
||||
} VRING_AVAIL;
|
||||
|
||||
|
||||
//
|
||||
// virtio-0.9.5, 2.3.5 Used Ring
|
||||
//
|
||||
@ -124,7 +122,6 @@ typedef struct {
|
||||
volatile UINT16 *AvailEvent; // unused as per negotiation
|
||||
} VRING_USED;
|
||||
|
||||
|
||||
//
|
||||
// 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_EVENT_IDX BIT29
|
||||
|
||||
|
||||
#endif // _VIRTIO_0_9_5_H_
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <IndustryStandard/Virtio.h>
|
||||
|
||||
|
||||
//
|
||||
// virtio-0.9.5, Appendix D: Block Device
|
||||
//
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <IndustryStandard/Virtio.h>
|
||||
|
||||
|
||||
//
|
||||
// virtio-0.9.5, Appendix I: SCSI Host Device
|
||||
//
|
||||
|
@ -200,8 +200,7 @@
|
||||
#define __DECL_REG(n64, n32) UINT64 n64
|
||||
#endif
|
||||
|
||||
struct vcpu_guest_core_regs
|
||||
{
|
||||
struct vcpu_guest_core_regs {
|
||||
/* Aarch64 Aarch32 */
|
||||
__DECL_REG (x0, r0_usr);
|
||||
__DECL_REG (x1, r1_usr);
|
||||
@ -259,6 +258,7 @@ struct vcpu_guest_core_regs
|
||||
UINT64 sp_el0;
|
||||
UINT64 sp_el1, elr_el1;
|
||||
};
|
||||
|
||||
typedef struct vcpu_guest_core_regs vcpu_guest_core_regs_t;
|
||||
DEFINE_XEN_GUEST_HANDLE (vcpu_guest_core_regs_t);
|
||||
|
||||
@ -285,16 +285,19 @@ struct vcpu_guest_context {
|
||||
UINT32 sctlr;
|
||||
UINT64 ttbcr, ttbr0, ttbr1;
|
||||
};
|
||||
|
||||
typedef struct vcpu_guest_context vcpu_guest_context_t;
|
||||
DEFINE_XEN_GUEST_HANDLE (vcpu_guest_context_t);
|
||||
#endif
|
||||
|
||||
struct arch_vcpu_info {
|
||||
};
|
||||
|
||||
typedef struct arch_vcpu_info arch_vcpu_info_t;
|
||||
|
||||
struct arch_shared_info {
|
||||
};
|
||||
|
||||
typedef struct arch_shared_info arch_shared_info_t;
|
||||
typedef UINT64 xen_callback_t;
|
||||
|
||||
|
@ -26,6 +26,7 @@ struct arch_vcpu_info {
|
||||
UINTN cr2;
|
||||
UINTN pad[5]; /* sizeof(vcpu_info_t) == 64 */
|
||||
};
|
||||
|
||||
typedef struct arch_vcpu_info arch_vcpu_info_t;
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
|
@ -26,6 +26,7 @@ struct arch_vcpu_info {
|
||||
UINTN cr2;
|
||||
UINTN pad; /* sizeof(vcpu_info_t) == 64 */
|
||||
};
|
||||
|
||||
typedef struct arch_vcpu_info arch_vcpu_info_t;
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
|
@ -76,6 +76,7 @@ struct arch_shared_info {
|
||||
UINTN nmi_reason;
|
||||
UINT64 pad[32];
|
||||
};
|
||||
|
||||
typedef struct arch_shared_info arch_shared_info_t;
|
||||
#ifdef MDE_CPU_IA32
|
||||
#pragma pack()
|
||||
|
@ -66,6 +66,7 @@ struct evtchn_alloc_unbound {
|
||||
/* OUT parameters */
|
||||
evtchn_port_t port;
|
||||
};
|
||||
|
||||
typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t;
|
||||
|
||||
/*
|
||||
@ -77,6 +78,7 @@ struct evtchn_close {
|
||||
/* IN parameters. */
|
||||
evtchn_port_t port;
|
||||
};
|
||||
|
||||
typedef struct evtchn_close evtchn_close_t;
|
||||
|
||||
/*
|
||||
@ -87,6 +89,7 @@ struct evtchn_send {
|
||||
/* IN parameters. */
|
||||
evtchn_port_t port;
|
||||
};
|
||||
|
||||
typedef struct evtchn_send evtchn_send_t;
|
||||
|
||||
#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */
|
||||
|
@ -117,12 +117,14 @@ struct grant_entry_v1 {
|
||||
UINT16 flags;
|
||||
/* The domain being granted foreign privileges. [GST] */
|
||||
domid_t domid;
|
||||
|
||||
/*
|
||||
* GTF_permit_access: Frame that @domid is allowed to map and access. [GST]
|
||||
* GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN]
|
||||
*/
|
||||
UINT32 frame;
|
||||
};
|
||||
|
||||
typedef struct grant_entry_v1 grant_entry_v1_t;
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
#if __XEN_INTERFACE_VERSION__ >= 0x0003020a
|
||||
|
||||
/*
|
||||
* Version 1 and version 2 grant entries share a common prefix. The
|
||||
* fields of the prefix are documented as part of struct
|
||||
@ -206,6 +209,7 @@ struct grant_entry_header {
|
||||
UINT16 flags;
|
||||
domid_t domid;
|
||||
};
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
typedef union grant_entry_v2 grant_entry_v2_t;
|
||||
|
||||
typedef UINT16 grant_status_t;
|
||||
@ -317,6 +322,7 @@ struct gnttab_map_grant_ref {
|
||||
grant_handle_t handle;
|
||||
UINT64 dev_bus_addr;
|
||||
};
|
||||
|
||||
typedef struct gnttab_map_grant_ref 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. */
|
||||
INT16 status; /* => enum grant_status */
|
||||
};
|
||||
|
||||
typedef struct gnttab_unmap_grant_ref 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. */
|
||||
#define _GNTMAP_readonly (2)
|
||||
#define GNTMAP_readonly (1<<_GNTMAP_readonly)
|
||||
|
||||
/*
|
||||
* GNTMAP_host_map subflag:
|
||||
* 0 => The host mapping is usable only by the guest OS.
|
||||
|
@ -15,6 +15,7 @@ struct xen_hvm_param {
|
||||
UINT32 index; /* IN */
|
||||
UINT64 value; /* IN/OUT */
|
||||
};
|
||||
|
||||
typedef struct xen_hvm_param xen_hvm_param_t;
|
||||
DEFINE_XEN_GUEST_HANDLE (xen_hvm_param_t);
|
||||
|
||||
|
@ -417,6 +417,7 @@
|
||||
*/
|
||||
#define BLKIF_OP_READ 0
|
||||
#define BLKIF_OP_WRITE 1
|
||||
|
||||
/*
|
||||
* All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER
|
||||
* operation code ("barrier request") must be completed prior to the
|
||||
@ -426,6 +427,7 @@
|
||||
* Optional. See "feature-barrier" XenBus node documentation above.
|
||||
*/
|
||||
#define BLKIF_OP_WRITE_BARRIER 2
|
||||
|
||||
/*
|
||||
* Commit any uncommitted contents of the backing device's volatile cache
|
||||
* to stable storage.
|
||||
@ -433,11 +435,13 @@
|
||||
* Optional. See "feature-flush-cache" XenBus node documentation above.
|
||||
*/
|
||||
#define BLKIF_OP_FLUSH_DISKCACHE 3
|
||||
|
||||
/*
|
||||
* Used in SLES sources for device specific command packet
|
||||
* contained within the request. Reserved for that purpose.
|
||||
*/
|
||||
#define BLKIF_OP_RESERVED_1 4
|
||||
|
||||
/*
|
||||
* 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
|
||||
@ -530,6 +534,7 @@ struct blkif_request {
|
||||
blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */
|
||||
struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
|
||||
};
|
||||
|
||||
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 */
|
||||
UINT64 nr_sectors; /* number of contiguous sectors to discard*/
|
||||
};
|
||||
|
||||
typedef struct blkif_request_discard blkif_request_discard_t;
|
||||
|
||||
struct blkif_request_indirect {
|
||||
@ -559,6 +565,7 @@ struct blkif_request_indirect {
|
||||
UINT64 pad; /* Make it 64 byte aligned on i386 */
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct blkif_request_indirect blkif_request_indirect_t;
|
||||
|
||||
struct blkif_response {
|
||||
@ -566,6 +573,7 @@ struct blkif_response {
|
||||
UINT8 operation; /* copied from request */
|
||||
INT16 status; /* BLKIF_RSP_??? */
|
||||
};
|
||||
|
||||
typedef struct blkif_response blkif_response_t;
|
||||
#if defined (MDE_CPU_IA32)
|
||||
#pragma pack()
|
||||
|
@ -37,6 +37,7 @@ typedef UINT32 RING_IDX;
|
||||
#define __CONST_RING_SIZE(_s, _sz) \
|
||||
(__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \
|
||||
sizeof(((struct _s##_sring *)0)->ring[0])))
|
||||
|
||||
/*
|
||||
* The same for passing in an actual pointer instead of a name tag.
|
||||
*/
|
||||
|
@ -49,6 +49,7 @@ enum xenbus_state {
|
||||
|
||||
XenbusStateReconfigured = 8
|
||||
};
|
||||
|
||||
typedef enum xenbus_state XenbusState;
|
||||
|
||||
#endif /* _XEN_PUBLIC_IO_XENBUS_H */
|
||||
|
@ -10,8 +10,7 @@
|
||||
#ifndef _XS_WIRE_H
|
||||
#define _XS_WIRE_H
|
||||
|
||||
enum xsd_sockmsg_type
|
||||
{
|
||||
enum xsd_sockmsg_type {
|
||||
XS_DEBUG,
|
||||
XS_DIRECTORY,
|
||||
XS_READ,
|
||||
@ -43,11 +42,11 @@ enum xsd_sockmsg_type
|
||||
#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
|
||||
|
||||
/* We hand errors as strings, for portability. */
|
||||
struct xsd_errors
|
||||
{
|
||||
struct xsd_errors {
|
||||
INT32 errnum;
|
||||
const CHAR8 *errstring;
|
||||
};
|
||||
|
||||
#ifdef EINVAL
|
||||
#define XSD_ERROR(x) { x, #x }
|
||||
/* LINTED: static unused */
|
||||
@ -74,8 +73,7 @@ __attribute__((unused))
|
||||
};
|
||||
#endif
|
||||
|
||||
struct xsd_sockmsg
|
||||
{
|
||||
struct xsd_sockmsg {
|
||||
UINT32 type; /* XS_??? */
|
||||
UINT32 req_id; /* Request identifier, echoed in daemon's response. */
|
||||
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). */
|
||||
};
|
||||
|
||||
enum xs_watch_type
|
||||
{
|
||||
enum xs_watch_type {
|
||||
XS_WATCH_PATH = 0,
|
||||
XS_WATCH_TOKEN
|
||||
};
|
||||
|
@ -46,6 +46,7 @@ struct xen_add_to_physmap {
|
||||
/* GPFN in domid where the source mapping page should appear. */
|
||||
xen_pfn_t gpfn;
|
||||
};
|
||||
|
||||
typedef struct xen_add_to_physmap 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. */
|
||||
xen_pfn_t gpfn;
|
||||
};
|
||||
|
||||
typedef struct xen_remove_from_physmap 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;
|
||||
};
|
||||
|
||||
typedef struct xen_memory_map xen_memory_map_t;
|
||||
DEFINE_XEN_GUEST_HANDLE (xen_memory_map_t);
|
||||
|
||||
|
@ -166,6 +166,7 @@ typedef UINT16 domid_t;
|
||||
#define DOMID_IDLE (0x7FFFU)
|
||||
|
||||
#if __XEN_INTERFACE_VERSION__ < 0x00040400
|
||||
|
||||
/*
|
||||
* 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.
|
||||
@ -187,6 +188,7 @@ struct vcpu_time_info {
|
||||
UINT32 pad0;
|
||||
UINT64 TscTimestamp; /* TSC at last update of time vals. */
|
||||
UINT64 SystemTime; /* Time, in nanosecs, since boot. */
|
||||
|
||||
/*
|
||||
* Current system time:
|
||||
* system_time +
|
||||
@ -198,6 +200,7 @@ struct vcpu_time_info {
|
||||
INT8 TscShift;
|
||||
INT8 pad1[3];
|
||||
}; /* 32 bytes */
|
||||
|
||||
typedef struct vcpu_time_info XEN_VCPU_TIME_INFO;
|
||||
|
||||
struct vcpu_info {
|
||||
@ -236,6 +239,7 @@ struct vcpu_info {
|
||||
struct arch_vcpu_info arch;
|
||||
struct vcpu_time_info Time;
|
||||
}; /* 64 bytes (x86) */
|
||||
|
||||
#ifndef __XEN__
|
||||
typedef struct vcpu_info vcpu_info_t;
|
||||
#endif
|
||||
@ -295,8 +299,8 @@ struct shared_info {
|
||||
UINT32 wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */
|
||||
|
||||
struct arch_shared_info arch;
|
||||
|
||||
};
|
||||
|
||||
#ifndef __XEN__
|
||||
typedef struct shared_info shared_info_t;
|
||||
typedef struct shared_info XEN_SHARED_INFO;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#ifndef __LOAD_LINUX_LIB__
|
||||
#define __LOAD_LINUX_LIB__
|
||||
|
||||
|
||||
/**
|
||||
Verifies that the kernel setup image is valid and supported.
|
||||
The kernel setup image should be checked before using other library
|
||||
@ -30,7 +29,6 @@ LoadLinuxCheckKernelSetup (
|
||||
IN UINTN KernelSetupSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Gets the initial runtime size of the Linux kernel image by examining
|
||||
the kernel setup image.
|
||||
@ -50,7 +48,6 @@ LoadLinuxGetKernelSize (
|
||||
IN UINTN KernelSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Loads and boots UEFI Linux.
|
||||
|
||||
@ -71,7 +68,6 @@ LoadLinux (
|
||||
IN OUT VOID *KernelSetup
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocates pages for the kernel setup image.
|
||||
|
||||
@ -87,7 +83,6 @@ LoadLinuxAllocateKernelSetupPages (
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Clears the uninitialised space before and after the struct setup_header
|
||||
in the kernel setup image. The kernel requires that these be zeroed
|
||||
@ -126,7 +121,6 @@ LoadLinuxAllocateKernelPages (
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocates pages for the kernel command line.
|
||||
|
||||
@ -142,7 +136,6 @@ LoadLinuxAllocateCommandLinePages (
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Allocates pages for the initrd image.
|
||||
|
||||
@ -160,7 +153,6 @@ LoadLinuxAllocateInitrdPages (
|
||||
IN UINTN Pages
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Sets the kernel command line parameter within the setup image.
|
||||
|
||||
@ -179,7 +171,6 @@ LoadLinuxSetCommandLine (
|
||||
IN CHAR8 *CommandLine
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Sets the kernel initial ram disk pointer within the setup image.
|
||||
|
||||
@ -200,6 +191,4 @@ LoadLinuxSetInitrd (
|
||||
IN UINTN InitrdSize
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -121,7 +121,6 @@ MemEncryptSevSetPageEncMask (
|
||||
IN UINTN NumPages
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
|
||||
Save State Map.
|
||||
|
@ -25,7 +25,6 @@ ConnectNvVarsToFileSystem (
|
||||
IN EFI_HANDLE FsHandle
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Update non-volatile variables stored on the file system.
|
||||
|
||||
@ -40,6 +39,4 @@ EFIAPI
|
||||
UpdateNvVarsOnFileSystem (
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -162,7 +162,6 @@ typedef struct {
|
||||
UINT8 Version;
|
||||
} PCI_CAP_INFO;
|
||||
|
||||
|
||||
/**
|
||||
Parse the capabilities lists (both normal and extended, as applicable) of a
|
||||
PCI device.
|
||||
@ -202,7 +201,6 @@ PciCapListInit (
|
||||
OUT PCI_CAP_LIST **CapList
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free the resources used by CapList.
|
||||
|
||||
@ -215,7 +213,6 @@ PciCapListUninit (
|
||||
IN PCI_CAP_LIST *CapList
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Locate a capability instance in the parsed capabilities lists.
|
||||
|
||||
@ -259,7 +256,6 @@ PciCapListFindCap (
|
||||
OUT PCI_CAP **Cap OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Locate the first instance of the capability given by (Domain, CapId) such
|
||||
that the instance's Version is greater than or equal to MinVersion.
|
||||
@ -303,7 +299,6 @@ PciCapListFindCapVersion (
|
||||
OUT PCI_CAP **Cap OPTIONAL
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Get information about a PCI Capability instance.
|
||||
|
||||
@ -325,7 +320,6 @@ PciCapGetInfo (
|
||||
OUT PCI_CAP_INFO *Info
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Read a slice of a capability instance.
|
||||
|
||||
@ -372,7 +366,6 @@ PciCapRead (
|
||||
IN UINT16 Size
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Write a slice of a capability instance.
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <Library/PciCapLib.h>
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -36,7 +35,6 @@ PciCapPciIoDeviceInit (
|
||||
OUT PCI_CAP_DEV **PciDevice
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free the resources used by PciDevice.
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
#include <Library/PciCapLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function
|
||||
quadruplet. The config space accessors are based upon PciSegmentLib.
|
||||
@ -60,7 +59,6 @@ PciCapPciSegmentDeviceInit (
|
||||
OUT PCI_CAP_DEV **PciDevice
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Free the resources used by PciDevice.
|
||||
|
||||
|
@ -13,10 +13,8 @@
|
||||
#ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__
|
||||
#define __PCI_HOST_BRIDGE_UTILITY_LIB_H__
|
||||
|
||||
|
||||
#include <Library/PciHostBridgeLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Utility function to initialize a PCI_ROOT_BRIDGE structure.
|
||||
|
||||
@ -82,7 +80,6 @@ PciHostBridgeUtilityInitRootBridge (
|
||||
OUT PCI_ROOT_BRIDGE *RootBus
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with
|
||||
PciHostBridgeUtilityInitRootBridge().
|
||||
@ -98,7 +95,6 @@ PciHostBridgeUtilityUninitRootBridge (
|
||||
IN PCI_ROOT_BRIDGE *RootBus
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Utility function to return all the root bridge instances in an array.
|
||||
|
||||
@ -145,7 +141,6 @@ PciHostBridgeUtilityGetRootBridges (
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Utility function to free root bridge instances array from
|
||||
PciHostBridgeUtilityGetRootBridges().
|
||||
@ -160,7 +155,6 @@ PciHostBridgeUtilityFreeRootBridges (
|
||||
IN UINTN Count
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Utility function to inform the platform that the resource conflict happens.
|
||||
|
||||
@ -181,5 +175,4 @@ PciHostBridgeUtilityResourceConflict (
|
||||
IN VOID *Configuration
|
||||
);
|
||||
|
||||
|
||||
#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user