OvmfPkg: Apply uncrustify changes

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

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

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

View File

@@ -13,10 +13,10 @@
EFI_STATUS
EFIAPI
InstallAcpiTable (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
)
{
return AcpiProtocol->InstallAcpiTable (
@@ -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
@@ -42,18 +41,18 @@ InstallAcpiTable (
**/
EFI_STATUS
LocateFvInstanceWithTables (
OUT EFI_FIRMWARE_VOLUME2_PROTOCOL **Instance
OUT EFI_FIRMWARE_VOLUME2_PROTOCOL **Instance
)
{
EFI_STATUS Status;
EFI_HANDLE *HandleBuffer;
UINTN NumberOfHandles;
EFI_FV_FILETYPE FileType;
UINT32 FvStatus;
EFI_FV_FILE_ATTRIBUTES Attributes;
UINTN Size;
UINTN Index;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
EFI_STATUS Status;
EFI_HANDLE *HandleBuffer;
UINTN NumberOfHandles;
EFI_FV_FILETYPE FileType;
UINT32 FvStatus;
EFI_FV_FILE_ATTRIBUTES Attributes;
UINTN Size;
UINTN Index;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FvInstance;
FvStatus = 0;
@@ -61,12 +60,12 @@ LocateFvInstanceWithTables (
// Locate protocol.
//
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&NumberOfHandles,
&HandleBuffer
);
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&NumberOfHandles,
&HandleBuffer
);
if (EFI_ERROR (Status)) {
//
// Defined errors at this time are not found and out of resources.
@@ -83,10 +82,10 @@ LocateFvInstanceWithTables (
// This should not fail because of LocateHandleBuffer
//
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID**) &FvInstance
);
HandleBuffer[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **)&FvInstance
);
ASSERT_EFI_ERROR (Status);
//
@@ -94,7 +93,7 @@ LocateFvInstanceWithTables (
//
Status = FvInstance->ReadFile (
FvInstance,
(EFI_GUID*)PcdGetPtr (PcdAcpiTableStorageFile),
(EFI_GUID *)PcdGetPtr (PcdAcpiTableStorageFile),
NULL,
&Size,
&FileType,
@@ -124,7 +123,6 @@ LocateFvInstanceWithTables (
return Status;
}
/**
Find ACPI tables in an FV and install them.
@@ -140,18 +138,18 @@ LocateFvInstanceWithTables (
EFI_STATUS
EFIAPI
InstallOvmfFvTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
)
{
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
INTN Instance;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINTN TableHandle;
UINT32 FvStatus;
UINTN TableSize;
UINTN Size;
EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction;
EFI_STATUS Status;
EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
INTN Instance;
EFI_ACPI_COMMON_HEADER *CurrentTable;
UINTN TableHandle;
UINT32 FvStatus;
UINTN TableSize;
UINTN Size;
EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction;
Instance = 0;
CurrentTable = NULL;
@@ -171,19 +169,19 @@ 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),
(EFI_GUID *)PcdGetPtr (PcdAcpiTableStorageFile),
EFI_SECTION_RAW,
Instance,
(VOID**) &CurrentTable,
(VOID **)&CurrentTable,
&Size,
&FvStatus
);
@@ -193,7 +191,7 @@ InstallOvmfFvTables (
//
TableHandle = 0;
TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *) CurrentTable)->Length;
TableSize = ((EFI_ACPI_DESCRIPTION_HEADER *)CurrentTable)->Length;
ASSERT (Size >= TableSize);
//
@@ -240,13 +238,12 @@ InstallOvmfFvTables (
EFI_STATUS
EFIAPI
InstallAcpiTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = InstallOvmfFvTables (AcpiTable);
return Status;
}

View File

@@ -22,8 +22,8 @@
#include <IndustryStandard/Acpi.h>
typedef struct {
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 PciAttributes;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 PciAttributes;
} ORIGINAL_ATTRIBUTES;
typedef struct S3_CONTEXT S3_CONTEXT;
@@ -31,43 +31,43 @@ typedef struct S3_CONTEXT S3_CONTEXT;
EFI_STATUS
EFIAPI
InstallAcpiTable (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
);
EFI_STATUS
EFIAPI
BhyveInstallAcpiTable(
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
BhyveInstallAcpiTable (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
);
EFI_STATUS
EFIAPI
InstallXenTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol
);
EFI_STATUS
EFIAPI
InstallAcpiTables (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable
);
VOID
EnablePciDecoding (
OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,
OUT UINTN *Count
OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,
OUT UINTN *Count
);
VOID
RestorePciDecoding (
IN ORIGINAL_ATTRIBUTES *OriginalAttributes,
IN UINTN Count
IN ORIGINAL_ATTRIBUTES *OriginalAttributes,
IN UINTN Count
);
#endif /* _ACPI_PLATFORM_H_INCLUDED_ */

View File

@@ -16,28 +16,28 @@ STATIC
EFI_STATUS
EFIAPI
BhyveInstallAcpiMadtTable (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
)
{
UINT32 CpuCount;
UINTN cSize;
UINTN NewBufferSize;
EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt;
EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE *LocalApic;
EFI_ACPI_1_0_IO_APIC_STRUCTURE *IoApic;
EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *Iso;
VOID *Ptr;
UINTN Loop;
EFI_STATUS Status;
UINT32 CpuCount;
UINTN cSize;
UINTN NewBufferSize;
EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt;
EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE *LocalApic;
EFI_ACPI_1_0_IO_APIC_STRUCTURE *IoApic;
EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE *Iso;
VOID *Ptr;
UINTN Loop;
EFI_STATUS Status;
ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
// Query the host for the number of vCPUs
CpuCount = 0;
cSize = sizeof(CpuCount);
cSize = sizeof (CpuCount);
if (BhyveFwCtlGet ("hw.ncpu", &CpuCount, &cSize) == RETURN_SUCCESS) {
DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
ASSERT (CpuCount >= 1);
@@ -57,44 +57,45 @@ BhyveInstallAcpiMadtTable (
}
CopyMem (&(Madt->Header), AcpiTableBuffer, sizeof (EFI_ACPI_DESCRIPTION_HEADER));
Madt->Header.Length = (UINT32) NewBufferSize;
Madt->Header.Length = (UINT32)NewBufferSize;
Madt->LocalApicAddress = 0xFEE00000;
Madt->Flags = EFI_ACPI_1_0_PCAT_COMPAT;
Ptr = Madt + 1;
Ptr = Madt + 1;
LocalApic = Ptr;
for (Loop = 0; Loop < CpuCount; ++Loop) {
LocalApic->Type = EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC;
LocalApic->Length = sizeof (*LocalApic);
LocalApic->AcpiProcessorId = (UINT8) Loop;
LocalApic->ApicId = (UINT8) Loop;
LocalApic->AcpiProcessorId = (UINT8)Loop;
LocalApic->ApicId = (UINT8)Loop;
LocalApic->Flags = 1; // enabled
++LocalApic;
}
Ptr = LocalApic;
IoApic = Ptr;
IoApic = Ptr;
IoApic->Type = EFI_ACPI_1_0_IO_APIC;
IoApic->Length = sizeof (*IoApic);
IoApic->IoApicId = (UINT8) CpuCount;
IoApic->IoApicId = (UINT8)CpuCount;
IoApic->Reserved = EFI_ACPI_RESERVED_BYTE;
IoApic->IoApicAddress = 0xFEC00000;
IoApic->SystemVectorBase = 0x00000000;
Ptr = IoApic + 1;
Ptr = IoApic + 1;
//
// IRQ0 (8254 Timer) => IRQ2 (PIC) Interrupt Source Override Structure
//
Iso = Ptr;
Iso = Ptr;
Iso->Type = EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE;
Iso->Length = sizeof (*Iso);
Iso->Bus = 0x00; // ISA
Iso->Source = 0x00; // IRQ0
Iso->GlobalSystemInterruptVector = 0x00000002;
Iso->Flags = 0x0000; // Conforms to specs of the bus
Ptr = Iso + 1;
Ptr = Iso + 1;
ASSERT ((UINTN) ((UINT8 *)Ptr - (UINT8 *)Madt) == NewBufferSize);
ASSERT ((UINTN)((UINT8 *)Ptr - (UINT8 *)Madt) == NewBufferSize);
Status = InstallAcpiTable (AcpiProtocol, Madt, NewBufferSize, TableKey);
FreePool (Madt);
@@ -105,22 +106,22 @@ BhyveInstallAcpiMadtTable (
EFI_STATUS
EFIAPI
BhyveInstallAcpiTable (
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol,
IN VOID *AcpiTableBuffer,
IN UINTN AcpiTableBufferSize,
OUT UINTN *TableKey
)
{
EFI_ACPI_DESCRIPTION_HEADER *Hdr;
EFI_ACPI_TABLE_INSTALL_ACPI_TABLE TableInstallFunction;
Hdr = (EFI_ACPI_DESCRIPTION_HEADER*) AcpiTableBuffer;
Hdr = (EFI_ACPI_DESCRIPTION_HEADER *)AcpiTableBuffer;
switch (Hdr->Signature) {
case EFI_ACPI_1_0_APIC_SIGNATURE:
TableInstallFunction = BhyveInstallAcpiMadtTable;
break;
default:
TableInstallFunction = InstallAcpiTable;
case EFI_ACPI_1_0_APIC_SIGNATURE:
TableInstallFunction = BhyveInstallAcpiMadtTable;
break;
default:
TableInstallFunction = InstallAcpiTable;
}
return TableInstallFunction (

View File

@@ -16,49 +16,50 @@ FindAcpiTableProtocol (
VOID
)
{
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
EFI_STATUS Status;
EFI_ACPI_TABLE_PROTOCOL *AcpiTable;
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
(VOID**)&AcpiTable
(VOID **)&AcpiTable
);
ASSERT_EFI_ERROR (Status);
return AcpiTable;
}
STATIC
VOID
EFIAPI
OnRootBridgesConnected (
IN EFI_EVENT Event,
IN VOID *Context
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
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 (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_EVENT RootBridgesConnected;
EFI_STATUS Status;
EFI_EVENT RootBridgesConnected;
//
// If the platform doesn't support PCI, or PCI enumeration has been disabled,
@@ -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;

View File

@@ -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.
@@ -38,15 +37,15 @@
**/
VOID
EnablePciDecoding (
OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,
OUT UINTN *Count
OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,
OUT UINTN *Count
)
{
EFI_STATUS Status;
UINTN NoHandles;
EFI_HANDLE *Handles;
ORIGINAL_ATTRIBUTES *OrigAttrs;
UINTN Idx;
EFI_STATUS Status;
UINTN NoHandles;
EFI_HANDLE *Handles;
ORIGINAL_ATTRIBUTES *OrigAttrs;
UINTN Idx;
*OriginalAttributes = NULL;
*Count = 0;
@@ -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,49 +73,75 @@ 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;
}
for (Idx = 0; Idx < NoHandles; ++Idx) {
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 Attributes;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT64 Attributes;
//
// 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().
@@ -169,11 +208,11 @@ FreeHandles:
**/
VOID
RestorePciDecoding (
IN ORIGINAL_ATTRIBUTES *OriginalAttributes,
IN UINTN Count
IN ORIGINAL_ATTRIBUTES *OriginalAttributes,
IN UINTN Count
)
{
UINTN Idx;
UINTN Idx;
ASSERT ((OriginalAttributes == NULL) == (Count == 0));
if (OriginalAttributes == NULL) {
@@ -188,5 +227,6 @@ RestorePciDecoding (
NULL
);
}
FreePool (OriginalAttributes);
}

View File

@@ -20,53 +20,53 @@
//
// ACPI table information used to initialize tables.
//
#define EFI_ACPI_OEM_ID 'B','H','Y','V','E',' ' // OEMID 6 bytes long
#define EFI_ACPI_OEM_REVISION 0x1
#define EFI_ACPI_CREATOR_ID SIGNATURE_32('B','H','Y','V')
#define EFI_ACPI_CREATOR_REVISION 0x00000001
#define EFI_ACPI_OEM_ID 'B','H','Y','V','E',' ' // OEMID 6 bytes long
#define EFI_ACPI_OEM_REVISION 0x1
#define EFI_ACPI_CREATOR_ID SIGNATURE_32('B','H','Y','V')
#define EFI_ACPI_CREATOR_REVISION 0x00000001
#define INT_MODEL 0x01
#define SCI_INT_VECTOR 0x0009
#define SMI_CMD_IO_PORT 0xB2
#define ACPI_ENABLE 0xA0
#define ACPI_DISABLE 0xA1
#define S4BIOS_REQ 0x00
#define PM1a_EVT_BLK 0x00000400 /* TNXXX */
#define PM1b_EVT_BLK 0x00000000
#define PM1a_CNT_BLK 0x00000404 /* TNXXX */
#define PM1b_CNT_BLK 0x00000000
#define PM2_CNT_BLK 0x00000000
#define PM_TMR_BLK 0x00000408
#define GPE0_BLK 0x00000000
#define GPE1_BLK 0x00000000
#define PM1_EVT_LEN 0x04
#define PM1_CNT_LEN 0x02
#define PM2_CNT_LEN 0x00
#define PM_TM_LEN 0x04
#define GPE0_BLK_LEN 0x00
#define GPE1_BLK_LEN 0x00
#define GPE1_BASE 0x00
#define RESERVED 0x00
#define P_LVL2_LAT 0x0000
#define P_LVL3_LAT 0x0000
#define FLUSH_SIZE 0x0000
#define FLUSH_STRIDE 0x0000
#define DUTY_OFFSET 0x00
#define DUTY_WIDTH 0x00
#define DAY_ALRM 0x00
#define MON_ALRM 0x00
#define CENTURY 0x32
#define IAPC_BOOT_ARCH 0x12 /* 8042 present, disable PCIe ASPM */
#define FACP_FLAGS (EFI_ACPI_1_0_WBINVD | EFI_ACPI_1_0_PROC_C1 | \
#define INT_MODEL 0x01
#define SCI_INT_VECTOR 0x0009
#define SMI_CMD_IO_PORT 0xB2
#define ACPI_ENABLE 0xA0
#define ACPI_DISABLE 0xA1
#define S4BIOS_REQ 0x00
#define PM1a_EVT_BLK 0x00000400 /* TNXXX */
#define PM1b_EVT_BLK 0x00000000
#define PM1a_CNT_BLK 0x00000404 /* TNXXX */
#define PM1b_CNT_BLK 0x00000000
#define PM2_CNT_BLK 0x00000000
#define PM_TMR_BLK 0x00000408
#define GPE0_BLK 0x00000000
#define GPE1_BLK 0x00000000
#define PM1_EVT_LEN 0x04
#define PM1_CNT_LEN 0x02
#define PM2_CNT_LEN 0x00
#define PM_TM_LEN 0x04
#define GPE0_BLK_LEN 0x00
#define GPE1_BLK_LEN 0x00
#define GPE1_BASE 0x00
#define RESERVED 0x00
#define P_LVL2_LAT 0x0000
#define P_LVL3_LAT 0x0000
#define FLUSH_SIZE 0x0000
#define FLUSH_STRIDE 0x0000
#define DUTY_OFFSET 0x00
#define DUTY_WIDTH 0x00
#define DAY_ALRM 0x00
#define MON_ALRM 0x00
#define CENTURY 0x32
#define IAPC_BOOT_ARCH 0x12 /* 8042 present, disable PCIe ASPM */
#define FACP_FLAGS (EFI_ACPI_1_0_WBINVD | EFI_ACPI_1_0_PROC_C1 | \
EFI_ACPI_1_0_SLP_BUTTON | EFI_ACPI_1_0_TMR_VAL_EXT | \
EFI_ACPI_2_0_RESET_REG_SUP | \
EFI_ACPI_3_0_FORCE_APIC_PHYSICAL_DESTINATION_MODE)
#define FACP_RESET_REG { \
#define FACP_RESET_REG { \
EFI_ACPI_3_0_SYSTEM_IO, /* Address Space ID */ \
8, /* Bit Width */ \
0, /* Bit Offset */ \
EFI_ACPI_3_0_BYTE, /* Byte Access */ \
0xCF9 /* I/O Port */ \
}
#define FACP_RESET_VAL 0x6
#define FACP_RESET_VAL 0x6
#endif

View File

@@ -30,17 +30,17 @@ EmuGopComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuGopComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
EmuGopComponentNameGetDriverName,
EmuGopComponentNameGetControllerName,
"eng"
@@ -49,19 +49,17 @@ EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName = {
//
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EmuGopComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EmuGopComponentNameGetControllerName,
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)EmuGopComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)EmuGopComponentNameGetControllerName,
"en"
};
EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
EFI_UNICODE_STRING_TABLE mEmuGopDriverNameTable[] = {
{ "eng", L"Emulator GOP Driver" },
{ NULL , NULL }
{ 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.
@@ -190,11 +187,11 @@ EmuGopComponentNameGetDriverName (
EFI_STATUS
EFIAPI
EmuGopComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;

View File

@@ -31,27 +31,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <IndustryStandard/Pci.h>
#define GRAPHICS_OUTPUT_INVALID_MODE_NUMBER 0xffff
#define GRAPHICS_OUTPUT_INVALID_MODE_NUMBER 0xffff
typedef struct {
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
UINT32 ColorDepth;
UINT32 RefreshRate;
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
UINT32 ColorDepth;
UINT32 RefreshRate;
} GOP_MODE_DATA;
#define PIXEL_RED_SHIFT 0
#define PIXEL_GREEN_SHIFT 3
#define PIXEL_BLUE_SHIFT 6
#define PIXEL_RED_SHIFT 0
#define PIXEL_GREEN_SHIFT 3
#define PIXEL_BLUE_SHIFT 6
#define PIXEL_RED_MASK (BIT7 | BIT6 | BIT5)
#define PIXEL_GREEN_MASK (BIT4 | BIT3 | BIT2)
#define PIXEL_BLUE_MASK (BIT1 | BIT0)
#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift))
#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT)
#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT)
#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT)
#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift))
#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT)
#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT)
#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT)
#define RGB_BYTES_TO_PIXEL(Red, Green, Blue) \
(UINT8) ( (((Red) >> PIXEL_RED_SHIFT) & PIXEL_RED_MASK) | \
@@ -62,61 +62,60 @@ typedef struct {
#define PIXEL24_GREEN_MASK 0x0000ff00
#define PIXEL24_BLUE_MASK 0x000000ff
extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
#define EMU_UGA_CLASS_NAME L"EmuGopWindow"
#define EMU_UGA_CLASS_NAME L"EmuGopWindow"
#define GOP_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('G', 'o', 'p', 'N')
typedef struct {
UINT64 Signature;
UINT64 Signature;
EFI_HANDLE Handle;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
EFI_HANDLE Handle;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
EFI_UNICODE_STRING_TABLE *ControllerNameTable;
//
// GOP Private Data for QueryMode ()
//
GOP_MODE_DATA *ModeData;
GOP_MODE_DATA *ModeData;
UINT64 FbAddr;
UINT32 FbSize;
UINT64 FbAddr;
UINT32 FbSize;
} GOP_PRIVATE_DATA;
#define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)
typedef struct {
UINT32 FbSize;
UINT16 Width;
UINT16 Height;
UINT16 Depth;
UINT16 RefreshRate;
UINT32 FbSize;
UINT16 Width;
UINT16 Height;
UINT16 Depth;
UINT16 RefreshRate;
} BHYVE_FBUF_MEMREGS;
//
// Global Protocol Variables
//
extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
//
// Gop Hardware abstraction internal worker functions
//
EFI_STATUS
EmuGopConstructor (
IN GOP_PRIVATE_DATA *Private
IN GOP_PRIVATE_DATA *Private
);
EFI_STATUS
EmuGopDestructor (
IN GOP_PRIVATE_DATA *Private
IN GOP_PRIVATE_DATA *Private
);
VOID
@@ -129,21 +128,21 @@ ShutdownGopEvent (
VOID
BhyveSetGraphicsMode (
GOP_PRIVATE_DATA *Private,
UINT16 Width,
UINT16 Height,
UINT16 Depth
UINT16 Width,
UINT16 Height,
UINT16 Depth
);
VOID
BhyveGetMemregs (
GOP_PRIVATE_DATA *Private,
BHYVE_FBUF_MEMREGS *Memregs
GOP_PRIVATE_DATA *Private,
BHYVE_FBUF_MEMREGS *Memregs
);
VOID
InstallVbeShim (
IN CONST CHAR16 *CardName,
IN EFI_PHYSICAL_ADDRESS FrameBufferBase
IN CONST CHAR16 *CardName,
IN EFI_PHYSICAL_ADDRESS FrameBufferBase
);
#endif /* _GOP_H_ */

View File

@@ -13,13 +13,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
STATIC VOID
BhyveGetGraphicsMode (
EFI_PCI_IO_PROTOCOL *PciIo,
UINT16 *Width,
UINT16 *Height,
UINT16 *Depth
EFI_PCI_IO_PROTOCOL *PciIo,
UINT16 *Width,
UINT16 *Height,
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.
@@ -65,15 +64,15 @@ BhyveGetGraphicsMode (
EFI_STATUS
EFIAPI
EmuGopDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 Pci;
UINT16 Width, Height, Depth;
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 Pci;
UINT16 Width, Height, Depth;
//
// Open the IO Abstraction(s) needed to perform the supported test
@@ -81,7 +80,7 @@ EmuGopDriverBindingSupported (
Status = gBS->OpenProtocol (
Handle,
&gEfiPciIoProtocolGuid,
(VOID **) &PciIo,
(VOID **)&PciIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -107,11 +106,11 @@ EmuGopDriverBindingSupported (
}
Status = EFI_UNSUPPORTED;
if (Pci.Hdr.VendorId == 0xFB5D && Pci.Hdr.DeviceId == 0x40FB) {
DEBUG((DEBUG_INFO, "BHYVE framebuffer device detected\n"));
if ((Pci.Hdr.VendorId == 0xFB5D) && (Pci.Hdr.DeviceId == 0x40FB)) {
DEBUG ((DEBUG_INFO, "BHYVE framebuffer device detected\n"));
Status = EFI_SUCCESS;
BhyveGetGraphicsMode(PciIo, &Width, &Height, &Depth);
BhyveGetGraphicsMode (PciIo, &Width, &Height, &Depth);
PcdSet32S (PcdVideoHorizontalResolution, Width);
PcdSet32S (PcdVideoVerticalResolution, Height);
}
@@ -121,16 +120,15 @@ Done:
// Close the PCI I/O Protocol
//
gBS->CloseProtocol (
Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Handle
);
return Status;
}
/**
Starts a device controller or a bus controller.
@@ -169,25 +167,25 @@ Done:
EFI_STATUS
EFIAPI
EmuGopDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Handle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
BHYVE_FBUF_MEMREGS Memregs;
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *MmioDesc;
BHYVE_FBUF_MEMREGS Memregs;
GOP_PRIVATE_DATA *Private;
EFI_STATUS Status;
EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *MmioDesc;
//
// Allocate Private context data for SGO inteface.
//
Private = NULL;
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (GOP_PRIVATE_DATA),
(VOID **)&Private
);
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (GOP_PRIVATE_DATA),
(VOID **)&Private
);
if (EFI_ERROR (Status)) {
goto Done;
}
@@ -204,7 +202,7 @@ EmuGopDriverBindingStart (
Status = gBS->OpenProtocol (
Handle,
&gEfiPciIoProtocolGuid,
(VOID **) &Private->PciIo,
(VOID **)&Private->PciIo,
This->DriverBindingHandle,
Handle,
EFI_OPEN_PROTOCOL_BY_DRIVER
@@ -217,24 +215,30 @@ EmuGopDriverBindingStart (
// Check if fbuf mmio BAR is present
//
MmioDesc = NULL;
Status = Private->PciIo->GetBarAttributes (
Private->PciIo,
PCI_BAR_IDX0,
NULL,
(VOID**) &MmioDesc
);
Status = Private->PciIo->GetBarAttributes (
Private->PciIo,
PCI_BAR_IDX0,
NULL,
(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));
BhyveGetMemregs(Private, &Memregs);
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;
}
@@ -243,18 +247,22 @@ EmuGopDriverBindingStart (
// Check if fbuf frame-buffer BAR is present
//
MmioDesc = NULL;
Status = Private->PciIo->GetBarAttributes (
Private->PciIo,
PCI_BAR_IDX1,
NULL,
(VOID**) &MmioDesc
);
Status = Private->PciIo->GetBarAttributes (
Private->PciIo,
PCI_BAR_IDX1,
NULL,
(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,18 +292,19 @@ EmuGopDriverBindingStart (
//
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
&gEfiGraphicsOutputProtocolGuid,
&Private->GraphicsOutput,
NULL
);
DEBUG((DEBUG_INFO, "BHYVE framebuffer device started\n"));
DEBUG ((DEBUG_INFO, "BHYVE framebuffer device started\n"));
//
// Install int10 handler
//
#ifndef CSM_ENABLE
#ifndef CSM_ENABLE
InstallVbeShim (L"Framebuffer", Private->FbAddr);
#endif
#endif
Done:
if (EFI_ERROR (Status)) {
@@ -309,8 +323,6 @@ Done:
return Status;
}
/**
Stops a device controller or a bus controller.
@@ -346,11 +358,11 @@ EmuGopDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_STATUS Status;
GOP_PRIVATE_DATA *Private;
DEBUG((DEBUG_INFO, "BHYVE framebuffer device stopping\n"));
DEBUG ((DEBUG_INFO, "BHYVE framebuffer device stopping\n"));
Status = gBS->OpenProtocol (
Handle,
@@ -377,7 +389,8 @@ EmuGopDriverBindingStop (
//
Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
&gEfiGraphicsOutputProtocolGuid,
&Private->GraphicsOutput,
NULL
);
if (!EFI_ERROR (Status)) {
@@ -390,11 +403,11 @@ EmuGopDriverBindingStop (
}
gBS->CloseProtocol (
Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Private->Handle
);
Handle,
&gEfiPciIoProtocolGuid,
This->DriverBindingHandle,
Private->Handle
);
//
// Free our instance data
@@ -402,18 +415,16 @@ 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.
///
EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
EmuGopDriverBindingSupported,
EmuGopDriverBindingStart,
EmuGopDriverBindingStop,
@@ -422,8 +433,6 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
NULL
};
/**
The user Entry Point for module EmuGop. The user code starts with this function.
@@ -437,11 +446,11 @@ EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding = {
EFI_STATUS
EFIAPI
InitializeEmuGop (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -453,33 +462,31 @@ InitializeEmuGop (
);
ASSERT_EFI_ERROR (Status);
return Status;
}
STATIC VOID
BhyveGetGraphicsMode (
EFI_PCI_IO_PROTOCOL *PciIo,
UINT16 *Width,
UINT16 *Height,
UINT16 *Depth
EFI_PCI_IO_PROTOCOL *PciIo,
UINT16 *Width,
UINT16 *Height,
UINT16 *Depth
)
{
BHYVE_FBUF_MEMREGS BhyveRegs;
UINT64 Offset;
EFI_STATUS Status;
BHYVE_FBUF_MEMREGS BhyveRegs;
UINT64 Offset;
EFI_STATUS Status;
Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs;
Status = PciIo->Mem.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_BAR_IDX0,
Offset,
3,
&BhyveRegs.Width
);
PciIo,
EfiPciIoWidthUint16,
PCI_BAR_IDX0,
Offset,
3,
&BhyveRegs.Width
);
*Width = BhyveRegs.Width;
*Height = BhyveRegs.Height;
@@ -493,51 +500,56 @@ BhyveGetGraphicsMode (
VOID
BhyveSetGraphicsMode (
GOP_PRIVATE_DATA *Private,
UINT16 Width,
UINT16 Height,
UINT16 Depth
UINT16 Width,
UINT16 Height,
UINT16 Depth
)
{
BHYVE_FBUF_MEMREGS BhyveRegs;
UINT64 Offset;
EFI_STATUS Status;
BHYVE_FBUF_MEMREGS BhyveRegs;
UINT64 Offset;
EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "BHYVE Set Graphics Mode: w %d, h %d\n", Width, Height));
BhyveRegs.Width = Width;
BhyveRegs.Height = Height;
BhyveRegs.Depth = Depth;
Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs;
Offset = (UINT64)&BhyveRegs.Width - (UINT64)&BhyveRegs;
Status = Private->PciIo->Mem.Write (
Private->PciIo,
EfiPciIoWidthUint16,
PCI_BAR_IDX0,
Offset,
3,
&BhyveRegs.Width
);
Private->PciIo,
EfiPciIoWidthUint16,
PCI_BAR_IDX0,
Offset,
3,
&BhyveRegs.Width
);
ASSERT_EFI_ERROR (Status);
}
VOID
BhyveGetMemregs (
GOP_PRIVATE_DATA *Private,
BHYVE_FBUF_MEMREGS *Memregs
GOP_PRIVATE_DATA *Private,
BHYVE_FBUF_MEMREGS *Memregs
)
{
EFI_STATUS Status;
EFI_STATUS Status;
Status = Private->PciIo->Mem.Read (
Private->PciIo,
EfiPciIoWidthUint32,
PCI_BAR_IDX0,
0,
3,
Memregs
);
Private->PciIo,
EfiPciIoWidthUint32,
PCI_BAR_IDX0,
0,
3,
Memregs
);
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
));
}

View File

@@ -22,45 +22,48 @@ Abstract:
#include "Gop.h"
#include <Library/FrameBufferBltLib.h>
EFI_EVENT mGopScreenExitBootServicesEvent;
EFI_EVENT mGopScreenExitBootServicesEvent;
GOP_MODE_DATA mGopModeData[] = {
{ 0, 0, 32, 0 }, // Filled in with user-spec'd resolution
{ 1024, 768, 32, 0 },
{ 800, 600, 32, 0 },
{ 640, 480, 32, 0 }
};
GOP_MODE_DATA mGopModeData[] = {
{ 0, 0, 32, 0 }, // Filled in with user-spec'd resolution
{ 1024, 768, 32, 0 },
{ 800, 600, 32, 0 },
{ 640, 480, 32, 0 }
};
STATIC
VOID
BhyveGopCompleteModeInfo (
IN GOP_MODE_DATA *ModeData,
IN GOP_MODE_DATA *ModeData,
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info
)
{
Info->Version = 0;
if (ModeData->ColorDepth == 8) {
Info->PixelFormat = PixelBitMask;
Info->PixelInformation.RedMask = PIXEL_RED_MASK;
Info->PixelInformation.GreenMask = PIXEL_GREEN_MASK;
Info->PixelInformation.BlueMask = PIXEL_BLUE_MASK;
Info->PixelFormat = PixelBitMask;
Info->PixelInformation.RedMask = PIXEL_RED_MASK;
Info->PixelInformation.GreenMask = PIXEL_GREEN_MASK;
Info->PixelInformation.BlueMask = PIXEL_BLUE_MASK;
Info->PixelInformation.ReservedMask = 0;
} else if (ModeData->ColorDepth == 24) {
Info->PixelFormat = PixelBitMask;
Info->PixelInformation.RedMask = PIXEL24_RED_MASK;
Info->PixelInformation.GreenMask = PIXEL24_GREEN_MASK;
Info->PixelInformation.BlueMask = PIXEL24_BLUE_MASK;
Info->PixelFormat = PixelBitMask;
Info->PixelInformation.RedMask = PIXEL24_RED_MASK;
Info->PixelInformation.GreenMask = PIXEL24_GREEN_MASK;
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;
}
@@ -102,18 +105,16 @@ EmuGopQuerytMode (
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
ModeData = &Private->ModeData[ModeNumber];
(*Info)->Version = 0;
ModeData = &Private->ModeData[ModeNumber];
(*Info)->Version = 0;
(*Info)->HorizontalResolution = ModeData->HorizontalResolution;
(*Info)->VerticalResolution = ModeData->VerticalResolution;
(*Info)->PixelFormat = PixelBitMask;
(*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
BhyveGopCompleteModeInfo(ModeData, *Info);
(*Info)->PixelFormat = PixelBitMask;
(*Info)->PixelsPerScanLine = (*Info)->HorizontalResolution;
BhyveGopCompleteModeInfo (ModeData, *Info);
return EFI_SUCCESS;
}
/**
Set the video device into the specified mode and clears the visible portions of
the output display to black.
@@ -127,7 +128,7 @@ EmuGopQuerytMode (
**/
FRAME_BUFFER_CONFIGURE *fbconf;
FRAME_BUFFER_CONFIGURE *fbconf;
EFI_STATUS
EFIAPI
@@ -136,37 +137,38 @@ EmuGopSetMode (
IN UINT32 ModeNumber
)
{
GOP_PRIVATE_DATA *Private;
GOP_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
GOP_PRIVATE_DATA *Private;
GOP_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
UINTN confsize = 0;
UINTN confsize = 0;
fbconf = NULL;
Private = GOP_PRIVATE_DATA_FROM_THIS (This);
if (ModeNumber >= This->Mode->MaxMode) {
// Tell bhyve that we are switching out of vesa
BhyveSetGraphicsMode(Private, 0, 0, 0);
BhyveSetGraphicsMode (Private, 0, 0, 0);
return EFI_UNSUPPORTED;
}
DEBUG ((DEBUG_INFO, "BHYVE GopSetMode %d\n", ModeNumber));
ModeData = &Private->ModeData[ModeNumber];
This->Mode->Mode = ModeNumber;
ModeData = &Private->ModeData[ModeNumber];
This->Mode->Mode = ModeNumber;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
Private->GraphicsOutput.Mode->Info->VerticalResolution = ModeData->VerticalResolution;
Private->GraphicsOutput.Mode->Info->PixelsPerScanLine = ModeData->HorizontalResolution;
Info = This->Mode->Info;
BhyveGopCompleteModeInfo(ModeData, Info);
BhyveGopCompleteModeInfo (ModeData, Info);
This->Mode->Info->HorizontalResolution = ModeData->HorizontalResolution;
This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;
This->Mode->SizeOfInfo = sizeof(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
This->Mode->FrameBufferBase = Private->GraphicsOutput.Mode->FrameBufferBase;
This->Mode->Info->VerticalResolution = ModeData->VerticalResolution;
This->Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
This->Mode->FrameBufferBase = Private->GraphicsOutput.Mode->FrameBufferBase;
/*
This->Mode->FrameBufferSize = Info->HorizontalResolution * Info->VerticalResolution
@@ -175,18 +177,24 @@ EmuGopSetMode (
This->Mode->FrameBufferSize = Private->FbSize;
DEBUG ((DEBUG_INFO, "BHYVE GOP FrameBufferBase: 0x%x, FrameBufferSize: 0x%x\n", This->Mode->FrameBufferBase, This->Mode->FrameBufferSize));
BhyveSetGraphicsMode(Private, (UINT16)ModeData->HorizontalResolution, (UINT16)ModeData->VerticalResolution, (UINT16)ModeData->ColorDepth);
BhyveSetGraphicsMode (Private, (UINT16)ModeData->HorizontalResolution, (UINT16)ModeData->VerticalResolution, (UINT16)ModeData->ColorDepth);
RETURN_STATUS ret = FrameBufferBltConfigure (
(VOID*)(UINTN) This->Mode->FrameBufferBase,
This->Mode->Info, fbconf, &confsize
);
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);
ASSERT(ret == EFI_SUCCESS);
RETURN_STATUS ret = FrameBufferBltConfigure (
(VOID *)(UINTN)This->Mode->FrameBufferBase,
This->Mode->Info,
fbconf,
&confsize
);
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
);
ASSERT (ret == EFI_SUCCESS);
}
Fill.Red = 0;
@@ -207,8 +215,6 @@ EmuGopSetMode (
return EFI_SUCCESS;
}
/**
Blt a rectangle of pixels on the graphics screen. Blt stands for BLock Transfer.
@@ -232,26 +238,26 @@ EmuGopSetMode (
EFI_STATUS
EFIAPI
EmuGopBlt (
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
)
{
EFI_TPL OriginalTPL;
EFI_STATUS Status;
EFI_TPL OriginalTPL;
EFI_STATUS Status;
if ((UINT32)BltOperation >= EfiGraphicsOutputBltOperationMax) {
return EFI_INVALID_PARAMETER;
}
if (Width == 0 || Height == 0) {
if ((Width == 0) || (Height == 0)) {
return EFI_INVALID_PARAMETER;
}
@@ -263,27 +269,27 @@ EmuGopBlt (
OriginalTPL = gBS->RaiseTPL (TPL_NOTIFY);
switch (BltOperation) {
case EfiBltVideoToBltBuffer:
case EfiBltBufferToVideo:
case EfiBltVideoFill:
case EfiBltVideoToVideo:
Status = FrameBufferBlt (
fbconf,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
break;
case EfiBltVideoToBltBuffer:
case EfiBltBufferToVideo:
case EfiBltVideoFill:
case EfiBltVideoToVideo:
Status = FrameBufferBlt (
fbconf,
BltBuffer,
BltOperation,
SourceX,
SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta
);
break;
default:
Status = EFI_INVALID_PARAMETER;
ASSERT (FALSE);
default:
Status = EFI_INVALID_PARAMETER;
ASSERT (FALSE);
}
gBS->RestoreTPL (OriginalTPL);
@@ -291,25 +297,24 @@ EmuGopBlt (
return Status;
}
//
// Construction and Destruction functions
//
EFI_STATUS
EmuGopConstructor (
GOP_PRIVATE_DATA *Private
GOP_PRIVATE_DATA *Private
)
{
// Set mode 0 to be the requested resolution
mGopModeData[0].HorizontalResolution = PcdGet32 ( PcdVideoHorizontalResolution);
mGopModeData[0].VerticalResolution = PcdGet32 ( PcdVideoVerticalResolution );
mGopModeData[0].HorizontalResolution = PcdGet32 (PcdVideoHorizontalResolution);
mGopModeData[0].VerticalResolution = PcdGet32 (PcdVideoVerticalResolution);
Private->ModeData = mGopModeData;
Private->GraphicsOutput.QueryMode = EmuGopQuerytMode;
Private->GraphicsOutput.SetMode = EmuGopSetMode;
Private->GraphicsOutput.Blt = EmuGopBlt;
Private->GraphicsOutput.QueryMode = EmuGopQuerytMode;
Private->GraphicsOutput.SetMode = EmuGopSetMode;
Private->GraphicsOutput.Blt = EmuGopBlt;
//
// Allocate buffer for Graphics Output Protocol mode information
@@ -318,35 +323,33 @@ 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);
Private->GraphicsOutput.Mode->MaxMode = sizeof (mGopModeData) / sizeof (GOP_MODE_DATA);
//
// Till now, we have no idea about the window size.
//
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALID_MODE_NUMBER;
Private->GraphicsOutput.Mode->Info->Version = 0;
Private->GraphicsOutput.Mode->Mode = GRAPHICS_OUTPUT_INVALID_MODE_NUMBER;
Private->GraphicsOutput.Mode->Info->Version = 0;
Private->GraphicsOutput.Mode->Info->HorizontalResolution = 0;
Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBitMask;
Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS) Private->FbAddr;
Private->GraphicsOutput.Mode->FrameBufferSize = Private->FbSize;
Private->GraphicsOutput.Mode->Info->VerticalResolution = 0;
Private->GraphicsOutput.Mode->Info->PixelFormat = PixelBitMask;
Private->GraphicsOutput.Mode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
Private->GraphicsOutput.Mode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)Private->FbAddr;
Private->GraphicsOutput.Mode->FrameBufferSize = Private->FbSize;
return EFI_SUCCESS;
}
EFI_STATUS
EmuGopDestructor (
GOP_PRIVATE_DATA *Private
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:

View File

@@ -28,8 +28,8 @@
#pragma pack (1)
typedef struct {
UINT16 Offset;
UINT16 Segment;
UINT16 Offset;
UINT16 Segment;
} IVT_ENTRY;
#pragma pack ()
@@ -37,52 +37,49 @@ typedef struct {
// This string is displayed by Windows 2008 R2 SP1 in the Screen Resolution,
// Advanced Settings dialog. It should be short.
//
STATIC CONST CHAR8 mProductRevision[] = "2.0";
STATIC CONST CHAR8 mProductRevision[] = "2.0";
#define NUM_VBE_MODES 3
STATIC CONST UINT16 vbeModeIds[] = {
#define NUM_VBE_MODES 3
STATIC CONST UINT16 vbeModeIds[] = {
0x13f, // 640x480x32
0x140, // 800x600x32
0x141 // 1024x768x32
};
// Modes can be toggled with bit-0
#define VBE_MODE_ENABLED 0x00BB
#define VBE_MODE_DISABLED 0x00BA
#define VBE_MODE_ENABLED 0x00BB
#define VBE_MODE_DISABLED 0x00BA
STATIC VBE2_MODE_INFO vbeModes[] = {
STATIC VBE2_MODE_INFO vbeModes[] = {
{ // 0x13f 640x480x32
// ModeAttr - BytesPerScanLine
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 640*4,
// Width, Height..., Vbe3
640, 480, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
640, 480, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
0xdeadbeef, 0x0000, 0x0000
0xdeadbeef, 0x0000, 0x0000
},
{ // 0x140 800x600x32
// ModeAttr - BytesPerScanLine
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
VBE_MODE_DISABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 800*4,
// Width, Height..., Vbe3
800, 600, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
800, 600, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
0xdeadbeef, 0x0000, 0x0000
0xdeadbeef, 0x0000, 0x0000
},
{ // 0x141 1024x768x32
// ModeAttr - BytesPerScanLine
VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
VBE_MODE_ENABLED, 0x07, 0x00, 0x40, 0x40, 0xA000, 0x00, 0x0000, 1024*4,
// Width, Height..., Vbe3
1024, 768, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
1024, 768, 16, 8, 1, 32, 1, 0x06, 0, 0, 1,
// Masks
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
0x08, 0x10, 0x08, 0x08, 0x08, 0x00, 0x08, 0x18, 0x00,
// Framebuffer
0xdeadbeef, 0x0000, 0x0000
0xdeadbeef, 0x0000, 0x0000
}
};
@@ -98,23 +95,23 @@ STATIC VBE2_MODE_INFO vbeModes[] = {
**/
VOID
InstallVbeShim (
IN CONST CHAR16 *CardName,
IN EFI_PHYSICAL_ADDRESS FrameBufferBase
IN CONST CHAR16 *CardName,
IN EFI_PHYSICAL_ADDRESS FrameBufferBase
)
{
EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF;
UINTN Segment0Pages;
IVT_ENTRY *Int0x10;
EFI_STATUS Status;
UINTN Pam1Address;
UINT8 Pam1;
UINTN SegmentCPages;
VBE_INFO *VbeInfoFull;
VBE_INFO_BASE *VbeInfo;
UINT8 *Ptr;
UINTN Printed;
VBE_MODE_INFO *VbeModeInfo;
UINTN i;
EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF;
UINTN Segment0Pages;
IVT_ENTRY *Int0x10;
EFI_STATUS Status;
UINTN Pam1Address;
UINT8 Pam1;
UINTN SegmentCPages;
VBE_INFO *VbeInfoFull;
VBE_INFO_BASE *VbeInfo;
UINT8 *Ptr;
UINTN Printed;
VBE_MODE_INFO *VbeModeInfo;
UINTN i;
Segment0 = 0x00000;
SegmentC = 0xC0000;
@@ -130,11 +127,15 @@ 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;
EFI_PHYSICAL_ADDRESS Handler;
//
// Check if a video BIOS handler has been installed previously -- we
@@ -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
@@ -203,14 +213,15 @@ InstallVbeShim (
VbeInfo->Capabilities = BIT1 | BIT0; // DAC can be switched into 8-bit mode
VbeInfo->ModeListAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
for (i = 0; i < NUM_VBE_MODES; i ++) {
*(UINT16*)Ptr = vbeModeIds[i]; // mode number
Ptr += 2;
for (i = 0; i < NUM_VBE_MODES; i++) {
*(UINT16 *)Ptr = vbeModeIds[i]; // mode number
Ptr += 2;
}
*(UINT16*)Ptr = 0xFFFF; // mode list terminator
Ptr += 2;
VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);
*(UINT16 *)Ptr = 0xFFFF; // mode list terminator
Ptr += 2;
VbeInfo->VideoMem64K = (UINT16)((1024 * 768 * 4 + 65535) / 65536);
VbeInfo->OemSoftwareVersion = 0x0200;
VbeInfo->VendorNameAddress = (UINT32)SegmentC << 12 | (UINT16)((UINTN)Ptr-SegmentC);
@@ -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);
@@ -234,7 +248,7 @@ InstallVbeShim (
// Fill in the VBE MODE INFO structure list
//
VbeModeInfo = (VBE_MODE_INFO *)(VbeInfoFull + 1);
Ptr = (UINT8 *)VbeModeInfo;
Ptr = (UINT8 *)VbeModeInfo;
for (i = 0; i < NUM_VBE_MODES; i++) {
vbeModes[i].LfbAddress = (UINT32)FrameBufferBase;
CopyMem (Ptr, &vbeModes[i], 0x32);
@@ -251,9 +265,14 @@ InstallVbeShim (
//
// Second, point the Int10h vector at the shim.
//
Int0x10->Segment = (UINT16) ((UINT32)SegmentC >> 4);
Int0x10->Offset = (UINT16) ((UINTN) (VbeModeInfo + 1) - SegmentC);
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
));
}

File diff suppressed because it is too large Load Diff

View File

@@ -30,8 +30,8 @@ AmdSevInitialize (
VOID
)
{
UINT64 EncryptionMask;
RETURN_STATUS PcdStatus;
UINT64 EncryptionMask;
RETURN_STATUS PcdStatus;
//
// Check if SEV is enabled
@@ -44,7 +44,7 @@ AmdSevInitialize (
// Set Memory Encryption Mask PCD
//
EncryptionMask = MemEncryptSevGetEncryptionMask ();
PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);
PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);
ASSERT_RETURN_ERROR (PcdStatus);
DEBUG ((DEBUG_INFO, "SEV is enabled (mask 0x%lx)\n", EncryptionMask));
@@ -67,9 +67,9 @@ AmdSevInitialize (
// hypervisor.
//
if (FeaturePcdGet (PcdSmmSmramRequire) && (mBootMode != BOOT_ON_S3_RESUME)) {
RETURN_STATUS LocateMapStatus;
UINTN MapPagesBase;
UINTN MapPagesCount;
RETURN_STATUS LocateMapStatus;
UINTN MapPagesBase;
UINTN MapPagesCount;
LocateMapStatus = MemEncryptSevLocateInitialSmramSaveStateMapPages (
&MapPagesBase,

View File

@@ -29,7 +29,7 @@ STATIC
VOID
EFIAPI
ClearCache (
IN OUT VOID *WorkSpace
IN OUT VOID *WorkSpace
)
{
WriteBackInvalidateDataCache ();
@@ -56,8 +56,8 @@ ClearCacheOnMpServicesAvailable (
IN VOID *Ppi
)
{
EFI_PEI_MP_SERVICES_PPI *MpServices;
EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *MpServices;
EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__));
@@ -65,15 +65,15 @@ ClearCacheOnMpServicesAvailable (
// Clear cache on all the APs in parallel.
//
MpServices = Ppi;
Status = MpServices->StartupAllAPs (
(CONST EFI_PEI_SERVICES **)PeiServices,
MpServices,
ClearCache, // Procedure
FALSE, // SingleThread
0, // TimeoutInMicroSeconds: inf.
NULL // ProcedureArgument
);
if (EFI_ERROR (Status) && Status != EFI_NOT_STARTED) {
Status = MpServices->StartupAllAPs (
(CONST EFI_PEI_SERVICES **)PeiServices,
MpServices,
ClearCache, // Procedure
FALSE, // SingleThread
0, // TimeoutInMicroSeconds: inf.
NULL // ProcedureArgument
);
if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status));
return Status;
}
@@ -89,7 +89,7 @@ ClearCacheOnMpServicesAvailable (
// Notification object for registering the callback, for when
// EFI_PEI_MP_SERVICES_PPI becomes available.
//
STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNotify = {
STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNotify = {
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | // Flags
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiPeiMpServicesPpiGuid, // Guid
@@ -101,11 +101,15 @@ InstallClearCacheCallback (
VOID
)
{
EFI_STATUS Status;
EFI_STATUS Status;
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
));
}
}

View File

@@ -6,7 +6,6 @@
**/
#include "Cmos.h"
#include "Library/IoLib.h"
@@ -24,14 +23,13 @@
UINT8
EFIAPI
CmosRead8 (
IN UINTN Index
IN UINTN Index
)
{
IoWrite8 (0x70, (UINT8) Index);
IoWrite8 (0x70, (UINT8)Index);
return IoRead8 (0x71);
}
/**
Writes 8-bits of CMOS data.
@@ -47,12 +45,11 @@ CmosRead8 (
UINT8
EFIAPI
CmosWrite8 (
IN UINTN Index,
IN UINT8 Value
IN UINTN Index,
IN UINT8 Value
)
{
IoWrite8 (0x70, (UINT8) Index);
IoWrite8 (0x70, (UINT8)Index);
IoWrite8 (0x71, Value);
return Value;
}

View File

@@ -23,7 +23,7 @@
UINT8
EFIAPI
CmosRead8 (
IN UINTN Index
IN UINTN Index
);
/**
@@ -41,10 +41,8 @@ CmosRead8 (
UINT8
EFIAPI
CmosWrite8 (
IN UINTN Index,
IN UINT8 Value
IN UINTN Index,
IN UINT8 Value
);
#endif /* _CMOS_H_ */

View File

@@ -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.
@@ -26,7 +25,7 @@ PeiFvInitialization (
VOID
)
{
BOOLEAN SecureS3Needed;
BOOLEAN SecureS3Needed;
DEBUG ((DEBUG_INFO, "Platform PEI Firmware Volume Initialization\n"));
@@ -67,7 +66,7 @@ PeiFvInitialization (
// of DXEFV, so let's keep away the OS from there too.
//
if (SecureS3Needed) {
UINT32 DxeMemFvEnd;
UINT32 DxeMemFvEnd;
DxeMemFvEnd = PcdGet32 (PcdOvmfDxeMemFvBase) +
PcdGet32 (PcdOvmfDxeMemFvSize);
@@ -83,7 +82,7 @@ PeiFvInitialization (
//
PeiServicesInstallFvInfoPpi (
NULL,
(VOID *)(UINTN) PcdGet32 (PcdOvmfDxeMemFvBase),
(VOID *)(UINTN)PcdGet32 (PcdOvmfDxeMemFvBase),
PcdGet32 (PcdOvmfDxeMemFvSize),
NULL,
NULL
@@ -91,4 +90,3 @@ PeiFvInitialization (
return EFI_SUCCESS;
}

View File

@@ -36,22 +36,22 @@ Module Name:
#include "Platform.h"
#include "Cmos.h"
UINT8 mPhysMemAddressWidth;
UINT8 mPhysMemAddressWidth;
STATIC UINT32 mS3AcpiReservedMemoryBase;
STATIC UINT32 mS3AcpiReservedMemorySize;
STATIC UINT32 mS3AcpiReservedMemoryBase;
STATIC UINT32 mS3AcpiReservedMemorySize;
STATIC UINT16 mQ35TsegMbytes;
STATIC UINT16 mQ35TsegMbytes;
BOOLEAN mQ35SmramAtDefaultSmbase = FALSE;
BOOLEAN mQ35SmramAtDefaultSmbase = FALSE;
VOID
Q35TsegMbytesInitialization (
VOID
)
{
UINT16 ExtendedTsegMbytes;
RETURN_STATUS PcdStatus;
UINT16 ExtendedTsegMbytes;
RETURN_STATUS PcdStatus;
if (mHostBridgeDevId != INTEL_Q35_MCH_DEVICE_ID) {
DEBUG ((
@@ -100,14 +100,13 @@ Q35TsegMbytesInitialization (
mQ35TsegMbytes = ExtendedTsegMbytes;
}
UINT32
GetSystemMemorySizeBelow4gb (
VOID
)
{
UINT8 Cmos0x34;
UINT8 Cmos0x35;
UINT8 Cmos0x34;
UINT8 Cmos0x35;
//
// CMOS 0x34/0x35 specifies the system memory above 16 MB.
@@ -118,20 +117,19 @@ GetSystemMemorySizeBelow4gb (
// into the calculation to get the total memory size.
//
Cmos0x34 = (UINT8) CmosRead8 (0x34);
Cmos0x35 = (UINT8) CmosRead8 (0x35);
Cmos0x34 = (UINT8)CmosRead8 (0x34);
Cmos0x35 = (UINT8)CmosRead8 (0x35);
return (UINT32) (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
}
STATIC
UINT64
GetSystemMemorySizeAbove4gb (
)
{
UINT32 Size;
UINTN CmosIndex;
UINT32 Size;
UINTN CmosIndex;
//
// CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
@@ -143,13 +141,12 @@ GetSystemMemorySizeAbove4gb (
Size = 0;
for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {
Size = (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex);
Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex);
}
return LShiftU64 (Size, 16);
}
/**
Return the highest address that DXE could possibly use, plus one.
**/
@@ -159,9 +156,9 @@ GetFirstNonAddress (
VOID
)
{
UINT64 FirstNonAddress;
UINT64 Pci64Base, Pci64Size;
RETURN_STATUS PcdStatus;
UINT64 FirstNonAddress;
UINT64 Pci64Base, Pci64Size;
RETURN_STATUS PcdStatus;
FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
@@ -170,11 +167,12 @@ GetFirstNonAddress (
// resources to 32-bit anyway. See DegradeResource() in
// "PciResourceSupport.c".
//
#ifdef MDE_CPU_IA32
#ifdef MDE_CPU_IA32
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
return FirstNonAddress;
}
#endif
#endif
//
// Otherwise, in order to calculate the highest address plus one, we must
@@ -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.
**/
@@ -244,7 +249,7 @@ AddressWidthInitialization (
VOID
)
{
UINT64 FirstNonAddress;
UINT64 FirstNonAddress;
//
// As guest-physical memory size grows, the permanent PEI RAM requirements
@@ -272,10 +277,10 @@ AddressWidthInitialization (
if (mPhysMemAddressWidth <= 36) {
mPhysMemAddressWidth = 36;
}
ASSERT (mPhysMemAddressWidth <= 48);
}
/**
Calculate the cap for the permanent PEI memory.
**/
@@ -285,21 +290,22 @@ GetPeiMemoryCap (
VOID
)
{
BOOLEAN Page1GSupport;
UINT32 RegEax;
UINT32 RegEdx;
UINT32 Pml4Entries;
UINT32 PdpEntries;
UINTN TotalPages;
BOOLEAN Page1GSupport;
UINT32 RegEax;
UINT32 RegEdx;
UINT32 Pml4Entries;
UINT32 PdpEntries;
UINTN TotalPages;
//
// If DXE is 32-bit, then just return the traditional 64 MB cap.
//
#ifdef MDE_CPU_IA32
#ifdef MDE_CPU_IA32
if (!FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
return SIZE_64MB;
}
#endif
#endif
//
// Dependent on physical address width, PEI memory allocations can be
@@ -320,7 +326,7 @@ GetPeiMemoryCap (
if (mPhysMemAddressWidth <= 39) {
Pml4Entries = 1;
PdpEntries = 1 << (mPhysMemAddressWidth - 30);
PdpEntries = 1 << (mPhysMemAddressWidth - 30);
ASSERT (PdpEntries <= 0x200);
} else {
Pml4Entries = 1 << (mPhysMemAddressWidth - 39);
@@ -329,7 +335,7 @@ GetPeiMemoryCap (
}
TotalPages = Page1GSupport ? Pml4Entries + 1 :
(PdpEntries + 1) * Pml4Entries + 1;
(PdpEntries + 1) * Pml4Entries + 1;
ASSERT (TotalPages <= 0x40201);
//
@@ -340,7 +346,6 @@ GetPeiMemoryCap (
return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB);
}
/**
Publish PEI core memory
@@ -352,11 +357,11 @@ PublishPeiMemory (
VOID
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS MemoryBase;
UINT64 MemorySize;
UINT32 LowerMemorySize;
UINT32 PeiMemoryCap;
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS MemoryBase;
UINT64 MemorySize;
UINT32 LowerMemorySize;
UINT32 PeiMemoryCap;
LowerMemorySize = GetSystemMemorySizeBelow4gb ();
if (FeaturePcdGet (PcdSmmSmramRequire)) {
@@ -373,10 +378,10 @@ PublishPeiMemory (
//
if (mS3Supported) {
mS3AcpiReservedMemorySize = SIZE_512KB +
mMaxCpuCount *
PcdGet32 (PcdCpuApStackSize);
mMaxCpuCount *
PcdGet32 (PcdCpuApStackSize);
mS3AcpiReservedMemoryBase = LowerMemorySize - mS3AcpiReservedMemorySize;
LowerMemorySize = mS3AcpiReservedMemoryBase;
LowerMemorySize = mS3AcpiReservedMemoryBase;
}
if (mBootMode == BOOT_ON_S3_RESUME) {
@@ -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
@@ -398,8 +408,8 @@ PublishPeiMemory (
// shouldn't overlap with that HOB.
//
MemoryBase = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire) ?
PcdGet32 (PcdOvmfDecompressionScratchEnd) :
PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
PcdGet32 (PcdOvmfDecompressionScratchEnd) :
PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
MemorySize = LowerMemorySize - MemoryBase;
if (MemorySize > PeiMemoryCap) {
MemoryBase = LowerMemorySize - PeiMemoryCap;
@@ -410,13 +420,12 @@ PublishPeiMemory (
//
// Publish this memory to the PEI Core
//
Status = PublishSystemMemory(MemoryBase, MemorySize);
Status = PublishSystemMemory (MemoryBase, MemorySize);
ASSERT_EFI_ERROR (Status);
return Status;
}
/**
Peform Memory Detection for QEMU / KVM
@@ -427,10 +436,10 @@ QemuInitializeRam (
VOID
)
{
UINT64 LowerMemorySize;
UINT64 UpperMemorySize;
MTRR_SETTINGS MtrrSettings;
EFI_STATUS Status;
UINT64 LowerMemorySize;
UINT64 UpperMemorySize;
MTRR_SETTINGS MtrrSettings;
EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "%a called\n", __FUNCTION__));
@@ -469,12 +478,15 @@ QemuInitializeRam (
AddMemoryRangeHob (0, BASE_512KB + BASE_128KB);
if (FeaturePcdGet (PcdSmmSmramRequire)) {
UINT32 TsegSize;
UINT32 TsegSize;
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
//
@@ -571,7 +589,7 @@ InitializeRamRegions (
EfiACPIMemoryNVS
);
#ifdef MDE_CPU_X64
#ifdef MDE_CPU_X64
//
// Reserve the initial page tables built by the reset vector code.
//
@@ -579,11 +597,11 @@ InitializeRamRegions (
// resume, it must be reserved as ACPI NVS.
//
BuildMemoryAllocationHob (
(EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfSecPageTablesBase),
(UINT64)(UINTN) PcdGet32 (PcdOvmfSecPageTablesSize),
(EFI_PHYSICAL_ADDRESS)(UINTN)PcdGet32 (PcdOvmfSecPageTablesBase),
(UINT64)(UINTN)PcdGet32 (PcdOvmfSecPageTablesSize),
EfiACPIMemoryNVS
);
#endif
#endif
}
if (mBootMode != BOOT_ON_S3_RESUME) {
@@ -599,18 +617,18 @@ InitializeRamRegions (
// such that they would overlap the LockBox storage.
//
ZeroMem (
(VOID*)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize)
(VOID *)(UINTN)PcdGet32 (PcdOvmfLockBoxStorageBase),
(UINTN)PcdGet32 (PcdOvmfLockBoxStorageSize)
);
BuildMemoryAllocationHob (
(EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageBase),
(UINT64)(UINTN) PcdGet32 (PcdOvmfLockBoxStorageSize),
(EFI_PHYSICAL_ADDRESS)(UINTN)PcdGet32 (PcdOvmfLockBoxStorageBase),
(UINT64)(UINTN)PcdGet32 (PcdOvmfLockBoxStorageSize),
mS3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
);
}
if (FeaturePcdGet (PcdSmmSmramRequire)) {
UINT32 TsegSize;
UINT32 TsegSize;
//
// Make sure the TSEG area that we reported as a reserved memory resource
@@ -618,7 +636,7 @@ InitializeRamRegions (
//
TsegSize = mQ35TsegMbytes * SIZE_1MB;
BuildMemoryAllocationHob (
GetSystemMemorySizeBelow4gb() - TsegSize,
GetSystemMemorySizeBelow4gb () - TsegSize,
TsegSize,
EfiReservedMemoryType
);

View File

@@ -36,7 +36,7 @@
#include "Platform.h"
#include "Cmos.h"
EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
{ EfiACPIMemoryNVS, 0x004 },
{ EfiACPIReclaimMemory, 0x008 },
{ EfiReservedMemoryType, 0x004 },
@@ -47,8 +47,7 @@ EFI_MEMORY_TYPE_INFORMATION mDefaultMemoryTypeInformation[] = {
{ EfiMaxMemoryType, 0x000 }
};
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiPeiMasterBootModePpiGuid,
@@ -56,27 +55,26 @@ EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
}
};
UINT16 mHostBridgeDevId;
UINT16 mHostBridgeDevId;
EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
EFI_BOOT_MODE mBootMode = BOOT_WITH_FULL_CONFIGURATION;
BOOLEAN mS3Supported = FALSE;
BOOLEAN mS3Supported = FALSE;
UINT32 mMaxCpuCount;
UINT32 mMaxCpuCount;
VOID
AddIoMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
)
{
BuildResourceDescriptorHob (
EFI_RESOURCE_MEMORY_MAPPED_IO,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
EFI_RESOURCE_ATTRIBUTE_TESTED,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
EFI_RESOURCE_ATTRIBUTE_TESTED,
MemoryBase,
MemorySize
);
@@ -84,23 +82,23 @@ AddIoMemoryBaseSizeHob (
VOID
AddReservedMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize,
BOOLEAN Cacheable
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize,
BOOLEAN Cacheable
)
{
BuildResourceDescriptorHob (
EFI_RESOURCE_MEMORY_RESERVED,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
(Cacheable ?
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE :
0
) |
EFI_RESOURCE_ATTRIBUTE_TESTED,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
(Cacheable ?
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE :
0
) |
EFI_RESOURCE_ATTRIBUTE_TESTED,
MemoryBase,
MemorySize
);
@@ -108,53 +106,50 @@ AddReservedMemoryBaseSizeHob (
VOID
AddIoMemoryRangeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
)
{
AddIoMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
}
VOID
AddMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
)
{
BuildResourceDescriptorHob (
EFI_RESOURCE_SYSTEM_MEMORY,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_TESTED,
EFI_RESOURCE_ATTRIBUTE_PRESENT |
EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
EFI_RESOURCE_ATTRIBUTE_TESTED,
MemoryBase,
MemorySize
);
}
VOID
AddMemoryRangeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
)
{
AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase));
}
VOID
MemMapInitialization (
VOID
)
{
UINT64 PciIoBase;
UINT64 PciIoSize;
RETURN_STATUS PcdStatus;
UINT64 PciIoBase;
UINT64 PciIoSize;
RETURN_STATUS PcdStatus;
PciIoBase = 0xC000;
PciIoSize = 0x4000;
@@ -165,7 +160,7 @@ MemMapInitialization (
BuildGuidDataHob (
&gEfiMemoryTypeInformationGuid,
mDefaultMemoryTypeInformation,
sizeof(mDefaultMemoryTypeInformation)
sizeof (mDefaultMemoryTypeInformation)
);
//
@@ -179,7 +174,7 @@ MemMapInitialization (
UINT32 PciBase;
UINT32 PciSize;
TopOfLowRam = GetSystemMemorySizeBelow4gb ();
TopOfLowRam = GetSystemMemorySizeBelow4gb ();
PciExBarBase = 0;
if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
//
@@ -192,8 +187,9 @@ MemMapInitialization (
PciBase = (UINT32)(PciExBarBase + SIZE_256MB);
} else {
PciBase = (UINT32)PcdGet64 (PcdPciMmio32Base);
if (PciBase == 0)
if (PciBase == 0) {
PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;
}
}
//
@@ -242,10 +238,14 @@ 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);
AddIoMemoryBaseSizeHob (PcdGet32 (PcdCpuLocalApicBaseAddress), SIZE_1MB);
//
// On Q35, the IO Port space is available for PCI resource allocations from
@@ -287,8 +287,8 @@ PciExBarInitialization (
)
{
union {
UINT64 Uint64;
UINT32 Uint32[2];
UINT64 Uint64;
UINT32 Uint32[2];
} PciExBarBase;
//
@@ -327,13 +327,13 @@ MiscInitialization (
VOID
)
{
UINTN PmCmd;
UINTN Pmba;
UINT32 PmbaAndVal;
UINT32 PmbaOrVal;
UINTN AcpiCtlReg;
UINT8 AcpiEnBit;
RETURN_STATUS PcdStatus;
UINTN PmCmd;
UINTN Pmba;
UINT32 PmbaAndVal;
UINT32 PmbaOrVal;
UINTN AcpiCtlReg;
UINT8 AcpiEnBit;
RETURN_STATUS PcdStatus;
//
// Disable A20 Mask
@@ -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,17 +422,17 @@ MiscInitialization (
}
}
VOID
BootModeInitialization (
VOID
)
{
EFI_STATUS Status;
EFI_STATUS Status;
if (CmosRead8 (0xF) == 0xFE) {
mBootMode = BOOT_ON_S3_RESUME;
}
CmosWrite8 (0xF, 0x00);
Status = PeiServicesSetBootMode (mBootMode);
@@ -437,13 +442,12 @@ BootModeInitialization (
ASSERT_EFI_ERROR (Status);
}
VOID
ReserveEmuVariableNvStore (
)
{
EFI_PHYSICAL_ADDRESS VariableStore;
RETURN_STATUS PcdStatus;
EFI_PHYSICAL_ADDRESS VariableStore;
RETURN_STATUS PcdStatus;
//
// Allocate storage for NV variables early on so it will be
@@ -453,25 +457,25 @@ ReserveEmuVariableNvStore (
//
VariableStore =
(EFI_PHYSICAL_ADDRESS)(UINTN)
AllocateRuntimePages (
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
);
DEBUG ((DEBUG_INFO,
"Reserved variable store memory: 0x%lX; size: %dkb\n",
VariableStore,
(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
));
AllocateRuntimePages (
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
);
DEBUG ((
DEBUG_INFO,
"Reserved variable store memory: 0x%lX; size: %dkb\n",
VariableStore,
(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
));
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
ASSERT_RETURN_ERROR (PcdStatus);
}
VOID
DebugDumpCmos (
VOID
)
{
UINT32 Loop;
UINT32 Loop;
DEBUG ((DEBUG_INFO, "CMOS:\n"));
@@ -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,27 +491,34 @@ DebugDumpCmos (
}
}
VOID
S3Verification (
VOID
)
{
#if defined (MDE_CPU_X64)
#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
}
#endif
}
/**
Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modules.
@@ -517,8 +529,8 @@ MaxCpuCountInitialization (
VOID
)
{
UINT16 ProcessorCount = 0;
RETURN_STATUS PcdStatus;
UINT16 ProcessorCount = 0;
RETURN_STATUS PcdStatus;
//
// If the fw_cfg key or fw_cfg entirely is unavailable, load mMaxCpuCount
@@ -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 ();

View File

@@ -14,33 +14,33 @@
VOID
AddIoMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
);
VOID
AddIoMemoryRangeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
);
VOID
AddMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize
);
VOID
AddMemoryRangeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
EFI_PHYSICAL_ADDRESS MemoryBase,
EFI_PHYSICAL_ADDRESS MemoryLimit
);
VOID
AddReservedMemoryBaseSizeHob (
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize,
BOOLEAN Cacheable
EFI_PHYSICAL_ADDRESS MemoryBase,
UINT64 MemorySize,
BOOLEAN Cacheable
);
VOID
@@ -113,25 +113,25 @@ AmdSevInitialize (
VOID
);
extern BOOLEAN mXen;
extern BOOLEAN mXen;
VOID
XenPublishRamRegions (
VOID
);
extern EFI_BOOT_MODE mBootMode;
extern EFI_BOOT_MODE mBootMode;
extern BOOLEAN mS3Supported;
extern BOOLEAN mS3Supported;
extern UINT8 mPhysMemAddressWidth;
extern UINT8 mPhysMemAddressWidth;
extern UINT32 mMaxCpuCount;
extern UINT32 mMaxCpuCount;
extern UINT16 mHostBridgeDevId;
extern UINT16 mHostBridgeDevId;
extern BOOLEAN mQ35SmramAtDefaultSmbase;
extern BOOLEAN mQ35SmramAtDefaultSmbase;
extern UINT32 mQemuUc32Base;
extern UINT32 mQemuUc32Base;
#endif // _PLATFORM_PEI_H_INCLUDED_

View File

@@ -7,8 +7,8 @@
#include "SmbiosPlatformDxe.h"
#define BHYVE_SMBIOS_PHYSICAL_ADDRESS 0x000F0000
#define BHYVE_SMBIOS_PHYSICAL_END 0x000FFFFF
#define BHYVE_SMBIOS_PHYSICAL_ADDRESS 0x000F0000
#define BHYVE_SMBIOS_PHYSICAL_END 0x000FFFFF
/**
Locates the bhyve SMBIOS data if it exists
@@ -24,18 +24,17 @@ GetBhyveSmbiosTables (
UINT8 *BhyveSmbiosPtr;
SMBIOS_TABLE_ENTRY_POINT *BhyveSmbiosEntryPointStructure;
for (BhyveSmbiosPtr = (UINT8*)(UINTN) BHYVE_SMBIOS_PHYSICAL_ADDRESS;
BhyveSmbiosPtr < (UINT8*)(UINTN) BHYVE_SMBIOS_PHYSICAL_END;
BhyveSmbiosPtr += 0x10) {
BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) BhyveSmbiosPtr;
if (!AsciiStrnCmp ((CHAR8 *) BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
!AsciiStrnCmp ((CHAR8 *) BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure)) {
for (BhyveSmbiosPtr = (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_ADDRESS;
BhyveSmbiosPtr < (UINT8 *)(UINTN)BHYVE_SMBIOS_PHYSICAL_END;
BhyveSmbiosPtr += 0x10)
{
BhyveSmbiosEntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)BhyveSmbiosPtr;
if (!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->AnchorString, "_SM_", 4) &&
!AsciiStrnCmp ((CHAR8 *)BhyveSmbiosEntryPointStructure->IntermediateAnchorString, "_DMI_", 5) &&
IsEntryPointStructureValid (BhyveSmbiosEntryPointStructure))
{
return BhyveSmbiosEntryPointStructure;
}
}

View File

@@ -20,34 +20,34 @@
//
#pragma pack(1)
typedef struct {
SMBIOS_TABLE_TYPE0 Base;
UINT8 Strings[sizeof(TYPE0_STRINGS)];
SMBIOS_TABLE_TYPE0 Base;
UINT8 Strings[sizeof (TYPE0_STRINGS)];
} OVMF_TYPE0;
#pragma pack()
STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
{
// SMBIOS_STRUCTURE Hdr
{
EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length
},
1, // SMBIOS_TABLE_STRING Vendor
2, // SMBIOS_TABLE_STRING BiosVersion
0xE800,// UINT16 BiosSegment
3, // SMBIOS_TABLE_STRING BiosReleaseDate
0, // UINT8 BiosSize
1, // SMBIOS_TABLE_STRING Vendor
2, // SMBIOS_TABLE_STRING BiosVersion
0xE800, // UINT16 BiosSegment
3, // SMBIOS_TABLE_STRING BiosReleaseDate
0, // UINT8 BiosSize
{ // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
0, // Reserved :2
0, // Unknown :1
1, // BiosCharacteristicsNotSupported :1
// Remaining BiosCharacteristics bits left unset :60
0, // Reserved :2
0, // Unknown :1
1, // BiosCharacteristicsNotSupported :1
// Remaining BiosCharacteristics bits left unset :60
},
{ // BIOSCharacteristicsExtensionBytes[2]
0, // BiosReserved
0x1C // SystemReserved = VirtualMachineSupported |
// UefiSpecificationSupported |
// TargetContentDistributionEnabled
0, // BiosReserved
0x1C // SystemReserved = VirtualMachineSupported |
// UefiSpecificationSupported |
// TargetContentDistributionEnabled
},
0, // UINT8 SystemBiosMajorRelease
0, // UINT8 SystemBiosMinorRelease
@@ -58,7 +58,6 @@ STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
TYPE0_STRINGS
};
/**
Validates the SMBIOS entry point structure
@@ -73,17 +72,17 @@ IsEntryPointStructureValid (
IN SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure
)
{
UINTN Index;
UINT8 Length;
UINT8 Checksum;
UINT8 *BytePtr;
UINTN Index;
UINT8 Length;
UINT8 Checksum;
UINT8 *BytePtr;
BytePtr = (UINT8*) EntryPointStructure;
Length = EntryPointStructure->EntryPointLength;
BytePtr = (UINT8 *)EntryPointStructure;
Length = EntryPointStructure->EntryPointLength;
Checksum = 0;
for (Index = 0; Index < Length; Index++) {
Checksum = Checksum + (UINT8) BytePtr[Index];
Checksum = Checksum + (UINT8)BytePtr[Index];
}
if (Checksum != 0) {
@@ -93,7 +92,6 @@ IsEntryPointStructureValid (
}
}
/**
Get SMBIOS record length.
@@ -102,7 +100,7 @@ IsEntryPointStructureValid (
**/
UINTN
SmbiosTableLength (
IN SMBIOS_STRUCTURE_POINTER SmbiosTable
IN SMBIOS_STRUCTURE_POINTER SmbiosTable
)
{
CHAR8 *AChar;
@@ -114,14 +112,14 @@ SmbiosTableLength (
// Each structure shall be terminated by a double-null (SMBIOS spec.7.1)
//
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
AChar ++;
AChar++;
}
Length = ((UINTN)AChar - (UINTN)SmbiosTable.Raw + 2);
return Length;
}
/**
Install all structures from the given SMBIOS structures block
@@ -131,8 +129,8 @@ SmbiosTableLength (
**/
EFI_STATUS
InstallAllStructures (
IN EFI_SMBIOS_PROTOCOL *Smbios,
IN UINT8 *TableAddress
IN EFI_SMBIOS_PROTOCOL *Smbios,
IN UINT8 *TableAddress
)
{
EFI_STATUS Status;
@@ -152,12 +150,12 @@ InstallAllStructures (
// Log the SMBIOS data for this structure
//
SmbiosHandle = SmbiosTable.Hdr->Handle;
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER*) SmbiosTable.Raw
);
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER *)SmbiosTable.Raw
);
ASSERT_EFI_ERROR (Status);
if (SmbiosTable.Hdr->Type == 0) {
@@ -175,19 +173,18 @@ InstallAllStructures (
// Add OVMF default Type 0 (BIOS Information) table
//
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER*) &mOvmfDefaultType0
);
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
(EFI_SMBIOS_TABLE_HEADER *)&mOvmfDefaultType0
);
ASSERT_EFI_ERROR (Status);
}
return EFI_SUCCESS;
}
/**
Installs SMBIOS information for OVMF
@@ -201,8 +198,8 @@ InstallAllStructures (
EFI_STATUS
EFIAPI
SmbiosTablePublishEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -216,7 +213,7 @@ SmbiosTablePublishEntry (
Status = gBS->LocateProtocol (
&gEfiSmbiosProtocolGuid,
NULL,
(VOID**)&Smbios
(VOID **)&Smbios
);
if (EFI_ERROR (Status)) {
return Status;
@@ -227,7 +224,7 @@ SmbiosTablePublishEntry (
//
EntryPointStructure = GetBhyveSmbiosTables ();
if (EntryPointStructure != NULL) {
SmbiosTables = (UINT8*)(UINTN)EntryPointStructure->TableAddress;
SmbiosTables = (UINT8 *)(UINTN)EntryPointStructure->TableAddress;
}
if (SmbiosTables != NULL) {

View File

@@ -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