diff options
Diffstat (limited to 'MdeModulePkg/Universal')
70 files changed, 1305 insertions, 1384 deletions
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h index 9cfef3d..3caa20d 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTable.h @@ -127,6 +127,12 @@ typedef struct { )
//
+// ACPI HOB produced by silicon initialization code will provide the RSDP structure.
+//
+typedef struct {
+ EFI_PHYSICAL_ADDRESS Rsdp;
+} ACPI_SILICON_HOB;
+//
// Protocol Constructor functions
//
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf index be498a5..8d147a3 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf @@ -57,6 +57,7 @@ gEfiAcpi10TableGuid ## PRODUCES ## SystemTable
gEfiAcpiTableGuid ## PRODUCES ## SystemTable
gUniversalPayloadAcpiTableGuid ## SOMETIMES_CONSUMES ## HOB
+ gAcpiTableHobGuid ## SOMETIMES_CONSUMES ## HOB
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol ## CONSUMES
diff --git a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c index 45c0ae6..56f3c8b 100644 --- a/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c +++ b/MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableProtocol.c @@ -1948,6 +1948,227 @@ InstallAcpiTableFromHob ( }
/**
+ This function is updating the instance with RSDP and RSDT, these are steps in the constructor that will be skipped if this HOB is available.
+
+ @param AcpiTableInstance Protocol instance private data.
+ @param GuidHob GUID HOB header.
+
+ @return EFI_SUCCESS The function completed successfully.
+ @return EFI_NOT_FOUND The function doesn't find the Rsdp from AcpiSiliconHob.
+ @return EFI_ABORTED The function could not complete successfully.
+
+**/
+EFI_STATUS
+InstallAcpiTableFromAcpiSiliconHob (
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance,
+ EFI_HOB_GUID_TYPE *GuidHob
+ )
+{
+ ACPI_SILICON_HOB *AcpiSiliconHob;
+ EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *SiAcpiHobRsdp;
+ EFI_ACPI_DESCRIPTION_HEADER *SiCommonAcpiTable;
+ EFI_STATUS Status;
+ UINTN NumOfTblEntries;
+ EFI_ACPI_TABLE_VERSION Version;
+ UINT64 SocTablePtr;
+ EFI_ACPI_DESCRIPTION_HEADER *SocEntryTable;
+ UINTN Index;
+ UINTN TableKey;
+ VOID *NeedToInstallTable;
+ UINT8 *Buffer;
+ EFI_PHYSICAL_ADDRESS PageAddress;
+ UINTN TotalSocTablesize;
+
+ DEBUG ((DEBUG_INFO, "InstallAcpiTableFromAcpiSiliconHob - Start\n"));
+ //
+ // Initial variable.
+ //
+ SiAcpiHobRsdp = NULL;
+ SiCommonAcpiTable = NULL;
+ AcpiSiliconHob = GET_GUID_HOB_DATA (GuidHob);
+ Status = EFI_SUCCESS;
+ Version = PcdGet32 (PcdAcpiExposedTableVersions);
+ TableKey = 0;
+ //
+ // Got RSDP table from ACPI Silicon Hob.
+ //
+ SiAcpiHobRsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)(AcpiSiliconHob->Rsdp);
+ if (SiAcpiHobRsdp == NULL) {
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromAcpiSiliconHob: Fail to locate RSDP Acpi table!!\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ DEBUG ((DEBUG_INFO, "Silicon ACPI RSDP address : 0x%016lx\n", SiAcpiHobRsdp));
+ AcpiTableInstance->Rsdp3 = SiAcpiHobRsdp;
+
+ //
+ // Got XSDT address from RSDP table.
+ //
+ Buffer = (UINT8 *)(UINTN)(SiAcpiHobRsdp->XsdtAddress);
+ SiCommonAcpiTable = (EFI_ACPI_DESCRIPTION_HEADER *)Buffer;
+
+ DEBUG ((DEBUG_INFO, "Silicon ACPI XSDT address : 0x%016lx\n", SiCommonAcpiTable));
+
+ if (SiCommonAcpiTable->Length <= sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
+ DEBUG ((DEBUG_ERROR, "XSDT length is incorrect\n"));
+ return EFI_ABORTED;
+ }
+
+ //
+ // Calcaue 64bit Acpi table number.
+ //
+ NumOfTblEntries = (SiCommonAcpiTable->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof (UINT64);
+ DEBUG ((DEBUG_ERROR, "64bit NumOfTblEntries : 0x%x\n", NumOfTblEntries));
+ //
+ // Reserved the ACPI reclaim memory for XSDT.
+ //
+ //
+ TotalSocTablesize = sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (UINT64);
+ PageAddress = 0xFFFFFFFF;
+ Status = gBS->AllocatePages (
+ mAcpiTableAllocType,
+ EfiACPIReclaimMemory,
+ EFI_SIZE_TO_PAGES (TotalSocTablesize),
+ &PageAddress
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Fail to allocate EfiACPIReclaimMemory for XSDT. Status : %r\n", Status));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ ZeroMem (&PageAddress, TotalSocTablesize);
+ AcpiTableInstance->Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)PageAddress;
+
+ //
+ // Initial XSDT table content.
+ //
+ AcpiTableInstance->Xsdt->Signature = SiCommonAcpiTable->Signature;
+ //
+ // Always reserve first one for FADT table.
+ //
+ AcpiTableInstance->Xsdt->Length = sizeof (EFI_ACPI_DESCRIPTION_HEADER) + sizeof (UINT64);
+ AcpiTableInstance->Xsdt->Revision = SiCommonAcpiTable->Revision;
+ CopyMem (
+ &AcpiTableInstance->Xsdt->OemId,
+ SiCommonAcpiTable->OemId,
+ sizeof (AcpiTableInstance->Xsdt->OemId)
+ );
+ CopyMem (
+ &AcpiTableInstance->Xsdt->OemTableId,
+ &SiCommonAcpiTable->OemTableId,
+ sizeof (UINT64)
+ );
+ AcpiTableInstance->Xsdt->OemRevision = SiCommonAcpiTable->OemRevision;
+ AcpiTableInstance->Xsdt->CreatorId = SiCommonAcpiTable->CreatorId;
+ AcpiTableInstance->Xsdt->CreatorRevision = SiCommonAcpiTable->CreatorRevision;
+ AcpiTableInstance->NumberOfTableEntries3 = 1;
+ //
+ // Extract ACPI table from AcpiSiliconHob XSDT.
+ //
+ for (Index = 0; Index < NumOfTblEntries; Index++) {
+ CopyMem (&SocTablePtr, (((UINT8 *)(SiCommonAcpiTable + 1)) + ((sizeof (UINT64)) * Index)), sizeof (UINT64));
+ SocEntryTable = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)SocTablePtr;
+ //
+ // Display table information.
+ //
+ DEBUG ((DEBUG_INFO, "[%x] Table address : 0x%016lx\n", Index, SocTablePtr));
+
+ Buffer = (UINT8 *)&SocEntryTable->Signature;
+ DEBUG ((DEBUG_INFO, "Table signature = %c%c%c%c\n", Buffer[0], Buffer[1], Buffer[2], Buffer[3]));
+
+ DEBUG ((DEBUG_INFO, "Table Length : 0x%x\n", SocEntryTable->Length));
+
+ Buffer = (UINT8 *)&SocEntryTable->OemId;
+ DEBUG (
+ (DEBUG_INFO, "Table OemId = %c%c%c%c%c%c\n",
+ Buffer[0],
+ Buffer[1],
+ Buffer[2],
+ Buffer[3],
+ Buffer[4],
+ Buffer[5]
+ )
+ );
+
+ Buffer = (UINT8 *)&SocEntryTable->OemTableId;
+ DEBUG (
+ (DEBUG_INFO, "Table OemTableId = %c%c%c%c%c%c%c%c\n",
+ Buffer[0],
+ Buffer[1],
+ Buffer[2],
+ Buffer[3],
+ Buffer[4],
+ Buffer[5],
+ Buffer[6],
+ Buffer[7]
+ )
+ );
+ DEBUG ((DEBUG_INFO, "\n"));
+ //
+ // Add ACPI table in the DXE AcpiTableInstance.
+ //
+ Status = AddTableToList (AcpiTableInstance, SocEntryTable, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "InstallAcpiTableFromAcpiSiliconHob: Fail to add ACPI table at 0x%p\n", SocEntryTable));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ }
+
+ if (SocEntryTable->Signature == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
+ //
+ // According ACPI spec, if XDsdt field contains a nonzero value which can be used by the OSPM, then the Dsdt field must be ignored by the OSPM.
+ //
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->XDsdt != 0) {
+ NeedToInstallTable = (VOID *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->XDsdt;
+ } else if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->Dsdt != 0) {
+ NeedToInstallTable = (VOID *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->Dsdt;
+ }
+
+ //
+ // if signature can not be found from the XDsdt / Dsdt field then skip it.
+ //
+ if (((EFI_ACPI_DESCRIPTION_HEADER *)NeedToInstallTable)->Signature == EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
+ Status = AddTableToList (AcpiTableInstance, NeedToInstallTable, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Fail to add DSDT in the DXE Table list!\n"));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Installed DSDT in the DXE Table list!\n"));
+ }
+ } else {
+ DEBUG ((DEBUG_ERROR, "The DSDT content is not correct, then skip it!\n"));
+ }
+
+ //
+ // According ACPI spec, if XFirmwareCtrl field contains a nonzero value which can be used by the OSPM, then the FirmwareCtrl field must be ignored by the OSPM.
+ //
+ if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->XFirmwareCtrl != 0) {
+ NeedToInstallTable = (VOID *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->XFirmwareCtrl;
+ } else if (((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->FirmwareCtrl != 0) {
+ NeedToInstallTable = (VOID *)(UINTN)((EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *)SocEntryTable)->FirmwareCtrl;
+ }
+
+ if (((EFI_ACPI_DESCRIPTION_HEADER *)NeedToInstallTable)->Signature == EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
+ Status = AddTableToList (AcpiTableInstance, NeedToInstallTable, TRUE, Version, TRUE, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Fail to add FACS in the DXE Table list!\n"));
+ ASSERT_EFI_ERROR (Status);
+ break;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Installed FACS in the DXE Table list!\n"));
+ }
+ } else {
+ DEBUG ((DEBUG_ERROR, "The FACS content is not correct, then skip it!\n"));
+ }
+ }
+ }
+
+ DEBUG ((DEBUG_INFO, "InstallAcpiTableFromAcpiSiliconHob - End\n"));
+ return Status;
+}
+
+/**
Constructor for the ACPI table protocol. Initializes instance
data.
@@ -1969,6 +2190,7 @@ AcpiTableAcpiTableConstructor ( UINT8 *Pointer;
EFI_PHYSICAL_ADDRESS PageAddress;
EFI_MEMORY_TYPE AcpiAllocateMemoryType;
+ EFI_HOB_GUID_TYPE *GuidHob;
//
// Check for invalid input parameters
@@ -1996,6 +2218,23 @@ AcpiTableAcpiTableConstructor ( }
//
+ // Check Silicon ACPI Hob.
+ //
+ GuidHob = GetFirstGuidHob (&gAcpiTableHobGuid);
+ if (GuidHob != NULL) {
+ Status = InstallAcpiTableFromAcpiSiliconHob (AcpiTableInstance, GuidHob);
+ if (Status == EFI_SUCCESS) {
+ DEBUG ((DEBUG_INFO, "Installed ACPI Table from AcpiSiliconHob.\n"));
+ return EFI_SUCCESS;
+ } else {
+ DEBUG ((DEBUG_ERROR, "Fail to Installed ACPI Table from AcpiSiliconHob!!\n"));
+ ASSERT (Status != EFI_SUCCESS);
+ }
+ } else {
+ DEBUG ((DEBUG_INFO, "Fail to locate AcpiSiliconHob!!\n"));
+ }
+
+ //
// Create RSDP table
//
RsdpTableSize = sizeof (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER);
diff --git a/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c b/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c index 0ea4fb3..c7be6c5 100644 --- a/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c +++ b/MdeModulePkg/Universal/CapsuleOnDiskLoadPei/CapsuleOnDiskLoadPei.c @@ -20,7 +20,7 @@ #include <PiPei.h>
//
-// The protocols, PPI and GUID defintions for this module
+// The protocols, PPI and GUID definitions for this module
//
#include <Ppi/MasterBootMode.h>
#include <Ppi/FirmwareVolumeInfo.h>
diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf index 35d2535..8457ac3 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf @@ -44,6 +44,9 @@ DebugLib
CpuExceptionHandlerLib
DebugAgentLib
+ # CapsuleX64 implements its own _ModuleEntryPoint() and does not link against the standard PEIM entrypoint. As a
+ # result, it must include StackCheckLib to resolve the compiler inserted references to stack cookie functionality
+ StackCheckLib
[Depex]
FALSE
diff --git a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c index 700ea9d..7d32d9a 100644 --- a/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c +++ b/MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatform.c @@ -27,6 +27,15 @@ EFI_DRIVER_BINDING_PROTOCOL gConPlatformTextOutDriverBinding = { NULL
};
+//
+// Values from Usb Inteface Association Descriptor Device
+// Class Code and Usage Model specification (iadclasscode_r10.pdf)
+// from Usb.org
+//
+#define USB_BASE_CLASS_MISCELLANEOUS 0xEF
+#define USB_MISCELLANEOUS_SUBCLASS_COMMON 0x02
+#define USB_MISCELLANEOUS_PROTOCOL_IAD 0x01
+
/**
Entrypoint of this module.
@@ -808,10 +817,16 @@ MatchUsbClass ( DeviceClass = DevDesc.DeviceClass;
DeviceSubClass = DevDesc.DeviceSubClass;
DeviceProtocol = DevDesc.DeviceProtocol;
- if (DeviceClass == 0) {
+
+ if ((DeviceClass == 0) ||
+ ((DeviceClass == USB_BASE_CLASS_MISCELLANEOUS) &&
+ (DeviceSubClass == USB_MISCELLANEOUS_SUBCLASS_COMMON) &&
+ (DeviceProtocol == USB_MISCELLANEOUS_PROTOCOL_IAD)))
+ {
//
- // If Class in Device Descriptor is set to 0, use the Class, SubClass and
- // Protocol in Interface Descriptor instead.
+ // If Class in Device Descriptor is set to 0 (Device), or
+ // Class/SubClass/Protocol is 0xEF/0x02/0x01 (IAD), use the Class, SubClass
+ // and Protocol in Interface Descriptor instead.
//
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IfDesc);
if (EFI_ERROR (Status)) {
@@ -1081,10 +1096,8 @@ ConPlatformMatchDevicePaths ( //
// If performing Delete operation, the NewDevicePath must not be NULL.
//
- if (Delete) {
- if (NewDevicePath == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ if (Delete && (NewDevicePath == NULL)) {
+ return EFI_INVALID_PARAMETER;
}
TempDevicePath1 = NULL;
@@ -1163,6 +1176,8 @@ ConPlatformUpdateDeviceVariable ( EFI_DEVICE_PATH_PROTOCOL *VariableDevicePath;
EFI_DEVICE_PATH_PROTOCOL *NewVariableDevicePath;
+ Status = EFI_SUCCESS;
+
VariableDevicePath = NULL;
NewVariableDevicePath = NULL;
@@ -1172,7 +1187,7 @@ ConPlatformUpdateDeviceVariable ( // it is the caller's responsibility to free the memory before return.
//
VariableDevicePath = ConPlatformGetVariable (VariableName);
-
+ // At this point, VariableDevicePath may be null. This is expected.
if (Operation != Delete) {
//
// Match specified DevicePath in Console Variable.
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index 0a776f3..2dbb7ea 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -108,15 +108,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_IN_SPLITTER_PRIVATE_DATA mConIn = { };
//
-// Uga Draw Protocol Private Data template
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UGA_DRAW_PROTOCOL mUgaDrawProtocolTemplate = {
- ConSplitterUgaDrawGetMode,
- ConSplitterUgaDrawSetMode,
- ConSplitterUgaDrawBlt
-};
-
-//
// Graphics Output Protocol Private Data template
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_GRAPHICS_OUTPUT_PROTOCOL mGraphicsOutputProtocolTemplate = {
@@ -156,22 +147,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mConOut = { {
NULL,
NULL,
- NULL
- },
- 0,
- 0,
- 0,
- 0,
-
- {
- NULL,
- NULL,
NULL,
NULL
},
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL,
0,
- 0,
0,
(TEXT_OUT_AND_GOP_DATA *)NULL,
@@ -212,22 +192,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED TEXT_OUT_SPLITTER_PRIVATE_DATA mStdErr = { {
NULL,
NULL,
- NULL
- },
- 0,
- 0,
- 0,
- 0,
-
- {
- NULL,
- NULL,
NULL,
NULL
},
(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *)NULL,
0,
- 0,
0,
(TEXT_OUT_AND_GOP_DATA *)NULL,
@@ -422,7 +391,7 @@ ToggleStateSyncReInitialization ( Installs driver module protocols and. Creates virtual device handles for ConIn,
ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
- Installs Graphics Output protocol and/or UGA Draw protocol if needed.
+ Installs Graphics Output protocol.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@@ -494,12 +463,9 @@ ConSplitterDriverEntry ( ASSERT_EFI_ERROR (Status);
//
- // Either Graphics Output protocol or UGA Draw protocol must be supported.
+ // Graphics Output protocol must be supported.
//
- ASSERT (
- FeaturePcdGet (PcdConOutGopSupport) ||
- FeaturePcdGet (PcdConOutUgaSupport)
- );
+ ASSERT (FeaturePcdGet (PcdConOutGopSupport));
//
// The driver creates virtual handles for ConIn, ConOut, StdErr.
@@ -757,10 +723,6 @@ ConSplitterTextOutConstructor ( //
// Copy protocols template
//
- if (FeaturePcdGet (PcdConOutUgaSupport)) {
- CopyMem (&ConOutPrivate->UgaDraw, &mUgaDrawProtocolTemplate, sizeof (EFI_UGA_DRAW_PROTOCOL));
- }
-
if (FeaturePcdGet (PcdConOutGopSupport)) {
CopyMem (&ConOutPrivate->GraphicsOutput, &mGraphicsOutputProtocolTemplate, sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL));
}
@@ -806,13 +768,6 @@ ConSplitterTextOutConstructor ( ConOutPrivate->TextOutQueryData[0].Rows = 25;
TextOutSetMode (ConOutPrivate, 0);
- if (FeaturePcdGet (PcdConOutUgaSupport)) {
- //
- // Setup the UgaDraw to 800 x 600 x 32 bits per pixel, 60Hz.
- //
- ConSplitterUgaDrawSetMode (&ConOutPrivate->UgaDraw, 800, 600, 32, 60);
- }
-
if (FeaturePcdGet (PcdConOutGopSupport)) {
//
// Setup resource for mode information in Graphics Output Protocol interface
@@ -1335,7 +1290,6 @@ ConSplitterConOutDriverBindingStart ( EFI_STATUS Status;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
@@ -1356,7 +1310,6 @@ ConSplitterConOutDriverBindingStart ( }
GraphicsOutput = NULL;
- UgaDraw = NULL;
//
// Try to Open Graphics Output protocol
//
@@ -1369,20 +1322,6 @@ ConSplitterConOutDriverBindingStart ( EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // Open UGA DRAW protocol
- //
- gBS->OpenProtocol (
- ControllerHandle,
- &gEfiUgaDrawProtocolGuid,
- (VOID **)&UgaDraw,
- This->DriverBindingHandle,
- mConOut.VirtualHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- }
-
//
// When new console device is added, the new mode will be set later,
// so put current mode back to init state.
@@ -1393,36 +1332,18 @@ ConSplitterConOutDriverBindingStart ( // If both ConOut and StdErr incorporate the same Text Out device,
// their MaxMode and QueryData should be the intersection of both.
//
- Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput, UgaDraw);
+ Status = ConSplitterTextOutAddDevice (&mConOut, TextOut, GraphicsOutput);
ConSplitterTextOutSetAttribute (&mConOut.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
- if (FeaturePcdGet (PcdConOutUgaSupport)) {
- //
- // Get the UGA mode data of ConOut from the current mode
- //
- if (GraphicsOutput != NULL) {
- Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
-
- mConOut.UgaHorizontalResolution = Info->HorizontalResolution;
- mConOut.UgaVerticalResolution = Info->VerticalResolution;
- mConOut.UgaColorDepth = 32;
- mConOut.UgaRefreshRate = 60;
-
- FreePool (Info);
- } else if (UgaDraw != NULL) {
- Status = UgaDraw->GetMode (
- UgaDraw,
- &mConOut.UgaHorizontalResolution,
- &mConOut.UgaVerticalResolution,
- &mConOut.UgaColorDepth,
- &mConOut.UgaRefreshRate
- );
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+
+ ASSERT (SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
+
+ FreePool (Info);
}
return Status;
@@ -1477,7 +1398,7 @@ ConSplitterStdErrDriverBindingStart ( // If both ConOut and StdErr incorporate the same Text Out device,
// their MaxMode and QueryData should be the intersection of both.
//
- Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL, NULL);
+ Status = ConSplitterTextOutAddDevice (&mStdErr, TextOut, NULL);
ConSplitterTextOutSetAttribute (&mStdErr.TextOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
return Status;
@@ -2737,7 +2658,6 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( @param Private Text Out Splitter pointer.
@param GraphicsOutput Graphics Output protocol pointer.
- @param UgaDraw UGA Draw protocol pointer.
@retval EFI_SUCCESS Output mode added successfully.
@retval other Failed to add output mode.
@@ -2746,8 +2666,7 @@ ConSplitterGetIntersectionBetweenConOutAndStrErr ( EFI_STATUS
ConSplitterAddGraphicsOutputMode (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput
)
{
EFI_STATUS Status;
@@ -2762,12 +2681,8 @@ ConSplitterAddGraphicsOutputMode ( UINTN NumberIndex;
BOOLEAN Match;
BOOLEAN AlreadyExist;
- UINT32 UgaHorizontalResolution;
- UINT32 UgaVerticalResolution;
- UINT32 UgaColorDepth;
- UINT32 UgaRefreshRate;
- ASSERT (GraphicsOutput != NULL || UgaDraw != NULL);
+ ASSERT (GraphicsOutput != NULL);
CurrentGraphicsOutputMode = Private->GraphicsOutput.Mode;
@@ -2775,15 +2690,6 @@ ConSplitterAddGraphicsOutputMode ( CurrentIndex = 0;
Status = EFI_SUCCESS;
- if (Private->CurrentNumberOfUgaDraw != 0) {
- //
- // If any UGA device has already been added, then there is no need to
- // calculate intersection of display mode of different GOP/UGA device,
- // since only one display mode will be exported (i.e. user-defined mode)
- //
- goto Done;
- }
-
if (GraphicsOutput != NULL) {
if (Private->CurrentNumberOfGraphicsOutput == 0) {
//
@@ -2937,51 +2843,12 @@ ConSplitterAddGraphicsOutputMode ( }
}
}
- } else if (UgaDraw != NULL) {
- //
- // Graphics console driver can ensure the same mode for all GOP devices
- // so we can get the current mode from this video device
- //
- UgaDraw->GetMode (
- UgaDraw,
- &UgaHorizontalResolution,
- &UgaVerticalResolution,
- &UgaColorDepth,
- &UgaRefreshRate
- );
-
- CurrentGraphicsOutputMode->MaxMode = 1;
- Info = CurrentGraphicsOutputMode->Info;
- Info->Version = 0;
- Info->HorizontalResolution = UgaHorizontalResolution;
- Info->VerticalResolution = UgaVerticalResolution;
- Info->PixelFormat = PixelBltOnly;
- Info->PixelsPerScanLine = UgaHorizontalResolution;
- CurrentGraphicsOutputMode->SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- CurrentGraphicsOutputMode->FrameBufferBase = (EFI_PHYSICAL_ADDRESS)(UINTN)NULL;
- CurrentGraphicsOutputMode->FrameBufferSize = 0;
-
- //
- // Update the private mode buffer
- //
- CopyMem (&Private->GraphicsOutputModeBuffer[0], Info, sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
-
- //
- // Only mode 0 is available to be set
- //
- CurrentIndex = 0;
}
-Done:
-
if (GraphicsOutput != NULL) {
Private->CurrentNumberOfGraphicsOutput++;
}
- if (UgaDraw != NULL) {
- Private->CurrentNumberOfUgaDraw++;
- }
-
//
// Force GraphicsOutput mode to be set,
//
@@ -3130,7 +2997,6 @@ ConsplitterSetConsoleOutMode ( @param Private Text Out Splitter pointer.
@param TextOut Simple Text Output protocol pointer.
@param GraphicsOutput Graphics Output protocol pointer.
- @param UgaDraw UGA Draw protocol pointer.
@retval EFI_SUCCESS Text Output Device added successfully.
@retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
@@ -3140,17 +3006,12 @@ EFI_STATUS ConSplitterTextOutAddDevice (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput
)
{
EFI_STATUS Status;
UINTN CurrentNumOfConsoles;
INT32 MaxMode;
- UINT32 UgaHorizontalResolution;
- UINT32 UgaVerticalResolution;
- UINT32 UgaColorDepth;
- UINT32 UgaRefreshRate;
TEXT_OUT_AND_GOP_DATA *TextAndGop;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
@@ -3186,7 +3047,6 @@ ConSplitterTextOutAddDevice ( TextAndGop->TextOut = TextOut;
TextAndGop->GraphicsOutput = GraphicsOutput;
- TextAndGop->UgaDraw = UgaDraw;
if (CurrentNumOfConsoles == 0) {
//
@@ -3215,101 +3075,33 @@ ConSplitterTextOutAddDevice ( //
// This device display mode will be added into Graphics Ouput modes.
//
- if ((GraphicsOutput != NULL) || (UgaDraw != NULL)) {
- DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput, UgaDraw);
+ if (GraphicsOutput != NULL) {
+ DeviceStatus = ConSplitterAddGraphicsOutputMode (Private, GraphicsOutput);
}
- if (FeaturePcdGet (PcdConOutUgaSupport)) {
- //
- // If UGA is produced by Consplitter
- //
- if (GraphicsOutput != NULL) {
- Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
-
- UgaHorizontalResolution = Info->HorizontalResolution;
- UgaVerticalResolution = Info->VerticalResolution;
-
- FreePool (Info);
- } else if (UgaDraw != NULL) {
- Status = UgaDraw->GetMode (
- UgaDraw,
- &UgaHorizontalResolution,
- &UgaVerticalResolution,
- &UgaColorDepth,
- &UgaRefreshRate
- );
- if (!EFI_ERROR (Status) && EFI_ERROR (DeviceStatus)) {
- //
- // if GetMode is successfully and UGA device hasn't been set, set it
- //
- Status = ConSplitterUgaDrawSetMode (
- &Private->UgaDraw,
- UgaHorizontalResolution,
- UgaVerticalResolution,
- UgaColorDepth,
- UgaRefreshRate
- );
- }
-
- //
- // If GetMode/SetMode is failed, set to 800x600 mode
- //
- if (EFI_ERROR (Status)) {
- Status = ConSplitterUgaDrawSetMode (
- &Private->UgaDraw,
- 800,
- 600,
- 32,
- 60
- );
- }
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->QueryMode (GraphicsOutput, GraphicsOutput->Mode->Mode, &SizeOfInfo, &Info);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+
+ ASSERT (SizeOfInfo <= sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
+ FreePool (Info);
}
if (((!EFI_ERROR (DeviceStatus)) || (!EFI_ERROR (Status))) &&
- ((Private->CurrentNumberOfGraphicsOutput + Private->CurrentNumberOfUgaDraw) == 1))
+ ((Private->CurrentNumberOfGraphicsOutput) == 1))
{
- if (!FeaturePcdGet (PcdConOutGopSupport)) {
- //
- // If Graphics Outpurt protocol not supported, UGA Draw protocol is installed
- // on the virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiUgaDrawProtocolGuid,
- &mConOut.UgaDraw,
- NULL
- );
- } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {
- //
- // If UGA Draw protocol not supported, Graphics Output Protocol is installed
- // on virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiGraphicsOutputProtocolGuid,
- &mConOut.GraphicsOutput,
- NULL
- );
- } else {
- //
- // Boot Graphics Output protocol and UGA Draw protocol are supported,
- // both they will be installed on virtual handle.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mConOut.VirtualHandle,
- &gEfiGraphicsOutputProtocolGuid,
- &mConOut.GraphicsOutput,
- &gEfiUgaDrawProtocolGuid,
- &mConOut.UgaDraw,
- NULL
- );
- }
+ //
+ // Graphics Output Protocol is installed
+ // on virtual handle.
+ //
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &mConOut.VirtualHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &mConOut.GraphicsOutput,
+ NULL
+ );
}
//
@@ -3353,10 +3145,6 @@ ConSplitterTextOutDeleteDevice ( TextOutList = Private->TextOutList;
while (Index >= 0) {
if (TextOutList->TextOut == TextOut) {
- if (TextOutList->UgaDraw != NULL) {
- Private->CurrentNumberOfUgaDraw--;
- }
-
if (TextOutList->GraphicsOutput != NULL) {
Private->CurrentNumberOfGraphicsOutput--;
}
@@ -3377,33 +3165,16 @@ ConSplitterTextOutDeleteDevice ( return EFI_NOT_FOUND;
}
- if ((Private->CurrentNumberOfGraphicsOutput == 0) && (Private->CurrentNumberOfUgaDraw == 0)) {
+ if ((Private->CurrentNumberOfGraphicsOutput == 0)) {
//
- // If there is not any physical GOP and UGA device in system,
- // Consplitter GOP or UGA protocol will be uninstalled
+ // If there is not any physical GOP in system,
+ // Consplitter GOP protocol will be uninstalled
//
- if (!FeaturePcdGet (PcdConOutGopSupport)) {
- Status = gBS->UninstallProtocolInterface (
- Private->VirtualHandle,
- &gEfiUgaDrawProtocolGuid,
- &Private->UgaDraw
- );
- } else if (!FeaturePcdGet (PcdConOutUgaSupport)) {
- Status = gBS->UninstallProtocolInterface (
- Private->VirtualHandle,
- &gEfiGraphicsOutputProtocolGuid,
- &Private->GraphicsOutput
- );
- } else {
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Private->VirtualHandle,
- &gEfiUgaDrawProtocolGuid,
- &Private->UgaDraw,
- &gEfiGraphicsOutputProtocolGuid,
- &Private->GraphicsOutput,
- NULL
- );
- }
+ Status = gBS->UninstallProtocolInterface (
+ Private->VirtualHandle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &Private->GraphicsOutput
+ );
}
if (CurrentNumOfConsoles == 0) {
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index 354107c..f6d90d5 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -21,7 +21,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/GraphicsOutput.h>
-#include <Protocol/UgaDraw.h>
#include <Guid/ConsoleInDevice.h>
#include <Guid/StandardErrorDevice.h>
@@ -182,7 +181,6 @@ typedef struct { typedef struct {
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
} TEXT_OUT_AND_GOP_DATA;
@@ -195,16 +193,9 @@ typedef struct { EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL TextOut;
EFI_SIMPLE_TEXT_OUTPUT_MODE TextOutMode;
- EFI_UGA_DRAW_PROTOCOL UgaDraw;
- UINT32 UgaHorizontalResolution;
- UINT32 UgaVerticalResolution;
- UINT32 UgaColorDepth;
- UINT32 UgaRefreshRate;
-
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *GraphicsOutputModeBuffer;
UINTN CurrentNumberOfGraphicsOutput;
- UINTN CurrentNumberOfUgaDraw;
UINTN CurrentNumberOfConsoles;
TEXT_OUT_AND_GOP_DATA *TextOutList;
@@ -230,13 +221,6 @@ typedef struct { TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \
)
-#define UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \
- CR ((a), \
- TEXT_OUT_SPLITTER_PRIVATE_DATA, \
- UgaDraw, \
- TEXT_OUT_SPLITTER_PRIVATE_DATA_SIGNATURE \
- )
-
#define CONSOLE_CONTROL_SPLITTER_PRIVATE_DATA_FROM_THIS(a) \
CR ((a), \
TEXT_OUT_SPLITTER_PRIVATE_DATA, \
@@ -254,7 +238,7 @@ typedef struct { Installs driver module protocols and. Creates virtual device handles for ConIn,
ConOut, and StdErr. Installs Simple Text In protocol, Simple Text In Ex protocol,
Simple Pointer protocol, Absolute Pointer protocol on those virtual handlers.
- Installs Graphics Output protocol and/or UGA Draw protocol if needed.
+ Installs Graphics Output protocol if needed.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@@ -1202,7 +1186,6 @@ ConSplitterSimplePointerDeleteDevice ( @param Private Text Out Splitter pointer.
@param TextOut Simple Text Output protocol pointer.
@param GraphicsOutput Graphics Output protocol pointer.
- @param UgaDraw UGA Draw protocol pointer.
@retval EFI_SUCCESS Text Output Device added successfully.
@retval EFI_OUT_OF_RESOURCES Could not grow the buffer size.
@@ -1212,8 +1195,7 @@ EFI_STATUS ConSplitterTextOutAddDevice (
IN TEXT_OUT_SPLITTER_PRIVATE_DATA *Private,
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut,
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN EFI_UGA_DRAW_PROTOCOL *UgaDraw
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput
);
/**
@@ -1858,118 +1840,6 @@ ConSplitterGraphicsOutputBlt ( );
/**
- Return the current video mode information.
-
- @param This The EFI_UGA_DRAW_PROTOCOL instance.
- @param HorizontalResolution The size of video screen in pixels in the X dimension.
- @param VerticalResolution The size of video screen in pixels in the Y dimension.
- @param ColorDepth Number of bits per pixel, currently defined to be 32.
- @param RefreshRate The refresh rate of the monitor in Hertz.
-
- @retval EFI_SUCCESS Mode information returned.
- @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
- @retval EFI_INVALID_PARAMETER One of the input args was NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawGetMode (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- OUT UINT32 *HorizontalResolution,
- OUT UINT32 *VerticalResolution,
- OUT UINT32 *ColorDepth,
- OUT UINT32 *RefreshRate
- );
-
-/**
- Set the current video mode information.
-
- @param This The EFI_UGA_DRAW_PROTOCOL instance.
- @param HorizontalResolution The size of video screen in pixels in the X dimension.
- @param VerticalResolution The size of video screen in pixels in the Y dimension.
- @param ColorDepth Number of bits per pixel, currently defined to be 32.
- @param RefreshRate The refresh rate of the monitor in Hertz.
-
- @retval EFI_SUCCESS Mode information returned.
- @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
- @retval EFI_OUT_OF_RESOURCES Out of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawSetMode (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- IN UINT32 ColorDepth,
- IN UINT32 RefreshRate
- );
-
-/**
- Blt a rectangle of pixels on the graphics screen.
-
- The following table defines actions for BltOperations.
-
- EfiUgaVideoFill:
- Write data from the BltBuffer pixel (SourceX, SourceY)
- directly to every pixel of the video display rectangle
- (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height).
- Only one pixel will be used from the BltBuffer. Delta is NOT used.
- EfiUgaVideoToBltBuffer:
- Read data from the video display rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
- the BltBuffer rectangle (DestinationX, DestinationY )
- (DestinationX + Width, DestinationY + Height). If DestinationX or
- DestinationY is not zero then Delta must be set to the length in bytes
- of a row in the BltBuffer.
- EfiUgaBltBufferToVideo:
- Write data from the BltBuffer rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
- video display rectangle (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
- not zero then Delta must be set to the length in bytes of a row in the
- BltBuffer.
- EfiUgaVideoToVideo:
- Copy from the video display rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) .
- to the video display rectangle (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height).
- The BltBuffer and Delta are not used in this mode.
-
- @param This Protocol instance pointer.
- @param BltBuffer Buffer containing data to blit into video buffer. This
- buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
- @param BltOperation Operation to perform on BlitBuffer and video memory
- @param SourceX X coordinate of source for the BltBuffer.
- @param SourceY Y coordinate of source for the BltBuffer.
- @param DestinationX X coordinate of destination for the BltBuffer.
- @param DestinationY Y coordinate of destination for the BltBuffer.
- @param Width Width of rectangle in BltBuffer in pixels.
- @param Height Hight of rectangle in BltBuffer in pixels.
- @param Delta OPTIONAL
-
- @retval EFI_SUCCESS The Blt operation completed.
- @retval EFI_INVALID_PARAMETER BltOperation is not valid.
- @retval EFI_DEVICE_ERROR A hardware error occurred writting to the video buffer.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawBlt (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
- IN EFI_UGA_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
- );
-
-/**
Sets the output device(s) to a specified mode.
@param Private Text Out Splitter pointer.
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf index 9aa1dad..156757a 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf @@ -3,12 +3,9 @@ #
# This driver acts as a virtual console, takes over the console I/O control from selected
# standard console devices, and transmits console I/O to related console device drivers.
-# Consplitter could install Graphics Output protocol and/or UGA Draw protocol in system
-# table according PCD settings(PcdConOutGopSupport, and PcdConOutUgaSupport). It always
-# consumes Graphics Output protocol which is produced by display device, and consumes UGA Draw
-# protocol which is produced by display device according to PcdUgaConsumeSupport value.
-# Note: If only UGA Draw protocol is installed in system, PcdUgaConsumeSupport should be
-# set to TRUE.
+# Consplitter could install Graphics Output protocol in system
+# table according PCD settings(PcdConOutGopSupport). It always
+# consumes Graphics Output protocol which is produced by display device
#
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
#
@@ -92,14 +89,9 @@ ## SOMETIMES_PRODUCES
## SOMETIMES_CONSUMES
gEfiGraphicsOutputProtocolGuid
- ## SOMETIMES_PRODUCES
- ## SOMETIMES_CONSUMES
- gEfiUgaDrawProtocolGuid
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES
[Pcd]
## SOMETIMES_PRODUCES
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.uni b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.uni index 13c25b2..903c505 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.uni +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.uni @@ -3,12 +3,9 @@ //
// This driver acts as a virtual console, takes over the console I/O control from selected
// standard console devices, and transmits console I/O to related console device drivers.
-// Consplitter could install Graphics Output protocol and/or UGA Draw protocol in system
-// table according PCD settings(PcdConOutGopSupport, and PcdConOutUgaSupport). It always
-// consumes Graphics Output protocol which is produced by display device, and consumes UGA Draw
-// protocol which is produced by display device according to PcdUgaConsumeSupport value.
-// Note: If only UGA Draw protocol is installed in system, PcdUgaConsumeSupport should be
-// set to TRUE.
+// Consplitter could install Graphics Output protocol in system
+// table according PCD settings(PcdConOutGopSupport). It always
+// consumes Graphics Output protocol which is produced by display device
//
// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
//
@@ -19,5 +16,5 @@ #string STR_MODULE_ABSTRACT #language en-US "Provides multi console support"
-#string STR_MODULE_DESCRIPTION #language en-US "This driver acts as a virtual console, takes over the console I/O control from selected standard console devices, and transmits console I/O to related console device drivers. Consplitter could install Graphics Output protocol and/or UGA Draw protocol in system table according PCD settings(PcdConOutGopSupport, and PcdConOutUgaSupport). It always consumes Graphics Output protocol, which is produced by display device, and consumes UGA Draw protocol, which is produced by display device according to PcdUgaConsumeSupport value. Note: If only UGA Draw protocol is installed in system, PcdUgaConsumeSupport should be set to TRUE."
+#string STR_MODULE_DESCRIPTION #language en-US "This driver acts as a virtual console, takes over the console I/O control from selected standard console devices, and transmits console I/O to related console device drivers. Consplitter could install Graphics Output protocol in system table according PCD settings(PcdConOutGopSupport). It always consumes Graphics Output protocol, which is produced by display device."
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c index 64ad567..8353f0b 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterGraphics.c @@ -117,7 +117,6 @@ ConSplitterGraphicsOutputSetMode ( UINTN NumberIndex;
UINTN SizeOfInfo;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
if (ModeNumber >= This->Mode->MaxMode) {
return EFI_UNSUPPORTED;
@@ -157,20 +156,6 @@ ConSplitterGraphicsOutputSetMode ( if (EFI_ERROR (Status)) {
ReturnStatus = Status;
}
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- UgaDraw = Private->TextOutList[Index].UgaDraw;
- if (UgaDraw != NULL) {
- Status = UgaDraw->SetMode (
- UgaDraw,
- Mode->HorizontalResolution,
- Mode->VerticalResolution,
- 32,
- 60
- );
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- }
- }
}
}
@@ -261,7 +246,6 @@ ConSplitterGraphicsOutputBlt ( TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
UINTN Index;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
if ((This == NULL) || (((UINTN)BltOperation) >= EfiGraphicsOutputBltOperationMax)) {
return EFI_INVALID_PARAMETER;
@@ -298,298 +282,6 @@ ConSplitterGraphicsOutputBlt ( return EFI_SUCCESS;
}
}
-
- UgaDraw = Private->TextOutList[Index].UgaDraw;
- if ((UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {
- Status = UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)BltBuffer,
- (EFI_UGA_BLT_OPERATION)BltOperation,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height,
- Delta
- );
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- } else if (BltOperation == EfiBltVideoToBltBuffer) {
- //
- // Only need to read the data into buffer one time
- //
- return EFI_SUCCESS;
- }
- }
- }
-
- return ReturnStatus;
-}
-
-/**
- Return the current video mode information.
-
- @param This The EFI_UGA_DRAW_PROTOCOL instance.
- @param HorizontalResolution The size of video screen in pixels in the X dimension.
- @param VerticalResolution The size of video screen in pixels in the Y dimension.
- @param ColorDepth Number of bits per pixel, currently defined to be 32.
- @param RefreshRate The refresh rate of the monitor in Hertz.
-
- @retval EFI_SUCCESS Mode information returned.
- @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
- @retval EFI_INVALID_PARAMETER One of the input args was NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawGetMode (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- OUT UINT32 *HorizontalResolution,
- OUT UINT32 *VerticalResolution,
- OUT UINT32 *ColorDepth,
- OUT UINT32 *RefreshRate
- )
-{
- TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
-
- if ((HorizontalResolution == NULL) ||
- (VerticalResolution == NULL) ||
- (RefreshRate == NULL) ||
- (ColorDepth == NULL))
- {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // retrieve private data
- //
- Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
-
- *HorizontalResolution = Private->UgaHorizontalResolution;
- *VerticalResolution = Private->UgaVerticalResolution;
- *ColorDepth = Private->UgaColorDepth;
- *RefreshRate = Private->UgaRefreshRate;
-
- return EFI_SUCCESS;
-}
-
-/**
- Set the current video mode information.
-
- @param This The EFI_UGA_DRAW_PROTOCOL instance.
- @param HorizontalResolution The size of video screen in pixels in the X dimension.
- @param VerticalResolution The size of video screen in pixels in the Y dimension.
- @param ColorDepth Number of bits per pixel, currently defined to be 32.
- @param RefreshRate The refresh rate of the monitor in Hertz.
-
- @retval EFI_SUCCESS Mode information returned.
- @retval EFI_NOT_STARTED Video display is not initialized. Call SetMode ()
- @retval EFI_OUT_OF_RESOURCES Out of resources.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawSetMode (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- IN UINT32 ColorDepth,
- IN UINT32 RefreshRate
- )
-{
- EFI_STATUS Status;
- TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
- UINTN Index;
- EFI_STATUS ReturnStatus;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- UINTN NumberIndex;
- UINTN SizeOfInfo;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
-
- Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
-
- ReturnStatus = EFI_SUCCESS;
-
- //
- // Update the Mode data
- //
- Private->UgaHorizontalResolution = HorizontalResolution;
- Private->UgaVerticalResolution = VerticalResolution;
- Private->UgaColorDepth = ColorDepth;
- Private->UgaRefreshRate = RefreshRate;
-
- //
- // return the worst status met
- //
- for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
- GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
- if (GraphicsOutput != NULL) {
- //
- // Find corresponding ModeNumber of this GraphicsOutput instance
- //
- for (NumberIndex = 0; NumberIndex < GraphicsOutput->Mode->MaxMode; NumberIndex++) {
- Status = GraphicsOutput->QueryMode (GraphicsOutput, (UINT32)NumberIndex, &SizeOfInfo, &Info);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution == VerticalResolution)) {
- FreePool (Info);
- break;
- }
-
- FreePool (Info);
- }
-
- Status = GraphicsOutput->SetMode (GraphicsOutput, (UINT32)NumberIndex);
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- }
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- UgaDraw = Private->TextOutList[Index].UgaDraw;
- if (UgaDraw != NULL) {
- Status = UgaDraw->SetMode (
- UgaDraw,
- HorizontalResolution,
- VerticalResolution,
- ColorDepth,
- RefreshRate
- );
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- }
- }
- }
- }
-
- return ReturnStatus;
-}
-
-/**
- Blt a rectangle of pixels on the graphics screen.
-
- The following table defines actions for BltOperations.
-
- EfiUgaVideoFill:
- Write data from the BltBuffer pixel (SourceX, SourceY)
- directly to every pixel of the video display rectangle
- (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height).
- Only one pixel will be used from the BltBuffer. Delta is NOT used.
- EfiUgaVideoToBltBuffer:
- Read data from the video display rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
- the BltBuffer rectangle (DestinationX, DestinationY )
- (DestinationX + Width, DestinationY + Height). If DestinationX or
- DestinationY is not zero then Delta must be set to the length in bytes
- of a row in the BltBuffer.
- EfiUgaBltBufferToVideo:
- Write data from the BltBuffer rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
- video display rectangle (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
- not zero then Delta must be set to the length in bytes of a row in the
- BltBuffer.
- EfiUgaVideoToVideo:
- Copy from the video display rectangle
- (SourceX, SourceY) (SourceX + Width, SourceY + Height) .
- to the video display rectangle (DestinationX, DestinationY)
- (DestinationX + Width, DestinationY + Height).
- The BltBuffer and Delta are not used in this mode.
-
- @param This Protocol instance pointer.
- @param BltBuffer Buffer containing data to blit into video buffer. This
- buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
- @param BltOperation Operation to perform on BlitBuffer and video memory
- @param SourceX X coordinate of source for the BltBuffer.
- @param SourceY Y coordinate of source for the BltBuffer.
- @param DestinationX X coordinate of destination for the BltBuffer.
- @param DestinationY Y coordinate of destination for the BltBuffer.
- @param Width Width of rectangle in BltBuffer in pixels.
- @param Height Hight of rectangle in BltBuffer in pixels.
- @param Delta OPTIONAL
-
- @retval EFI_SUCCESS The Blt operation completed.
- @retval EFI_INVALID_PARAMETER BltOperation is not valid.
- @retval EFI_DEVICE_ERROR A hardware error occurred writting to the video buffer.
-
-**/
-EFI_STATUS
-EFIAPI
-ConSplitterUgaDrawBlt (
- IN EFI_UGA_DRAW_PROTOCOL *This,
- IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
- IN EFI_UGA_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_STATUS Status;
- TEXT_OUT_SPLITTER_PRIVATE_DATA *Private;
- UINTN Index;
- EFI_STATUS ReturnStatus;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
-
- Private = UGA_DRAW_SPLITTER_PRIVATE_DATA_FROM_THIS (This);
-
- ReturnStatus = EFI_SUCCESS;
- //
- // return the worst status met
- //
- for (Index = 0; Index < Private->CurrentNumberOfConsoles; Index++) {
- GraphicsOutput = Private->TextOutList[Index].GraphicsOutput;
- if (GraphicsOutput != NULL) {
- Status = GraphicsOutput->Blt (
- GraphicsOutput,
- (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)BltBuffer,
- (EFI_GRAPHICS_OUTPUT_BLT_OPERATION)BltOperation,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height,
- Delta
- );
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- } else if (BltOperation == EfiUgaVideoToBltBuffer) {
- //
- // Only need to read the data into buffer one time
- //
- return EFI_SUCCESS;
- }
- }
-
- if ((Private->TextOutList[Index].UgaDraw != NULL) && FeaturePcdGet (PcdUgaConsumeSupport)) {
- Status = Private->TextOutList[Index].UgaDraw->Blt (
- Private->TextOutList[Index].UgaDraw,
- BltBuffer,
- BltOperation,
- SourceX,
- SourceY,
- DestinationX,
- DestinationY,
- Width,
- Height,
- Delta
- );
- if (EFI_ERROR (Status)) {
- ReturnStatus = Status;
- } else if (BltOperation == EfiUgaVideoToBltBuffer) {
- //
- // Only need to read the data into buffer one time
- //
- return EFI_SUCCESS;
- }
- }
}
return ReturnStatus;
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c index b895daf..50a88f5 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.c @@ -14,7 +14,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {
GRAPHICS_CONSOLE_DEV_SIGNATURE,
(EFI_GRAPHICS_OUTPUT_PROTOCOL *)NULL,
- (EFI_UGA_DRAW_PROTOCOL *)NULL,
{
GraphicsConsoleConOutReset,
GraphicsConsoleConOutOutputString,
@@ -104,9 +103,8 @@ EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = { /**
Test to see if Graphics Console could be supported on the Controller.
- Graphics Console could be supported if Graphics Output Protocol or UGA Draw
- Protocol exists on the Controller. (UGA Draw Protocol could be skipped
- if PcdUgaConsumeSupport is set to FALSE.)
+ Graphics Console could be supported if Graphics Output Protocol
+ exists on the Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to test.
@@ -127,11 +125,9 @@ GraphicsConsoleControllerDriverSupported ( {
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
GraphicsOutput = NULL;
- UgaDraw = NULL;
//
// Open the IO Abstraction(s) needed to perform the supported test
//
@@ -143,21 +139,6 @@ GraphicsConsoleControllerDriverSupported ( Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
-
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // Open Graphics Output Protocol failed, try to open UGA Draw Protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiUgaDrawProtocolGuid,
- (VOID **)&UgaDraw,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- }
-
if (EFI_ERROR (Status)) {
return Status;
}
@@ -202,13 +183,6 @@ Error: This->DriverBindingHandle,
Controller
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUgaDrawProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
}
return Status;
@@ -283,7 +257,10 @@ InitializeGraphicsConsoleTextMode ( // Reserve 2 modes for 80x25, 80x50 of graphics console.
//
NewModeBuffer = AllocateZeroPool (sizeof (GRAPHICS_CONSOLE_MODE_DATA) * (Count + 2));
- ASSERT (NewModeBuffer != NULL);
+ if (NewModeBuffer == NULL) {
+ ASSERT (NewModeBuffer != NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
//
// Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
@@ -369,9 +346,8 @@ InitializeGraphicsConsoleTextMode ( }
/**
- Start this driver on Controller by opening Graphics Output protocol or
- UGA Draw protocol, and installing Simple Text Out protocol on Controller.
- (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
+ Start this driver on Controller by opening Graphics Output protocol
+ and installing Simple Text Out protocol on Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to bind driver to
@@ -394,8 +370,6 @@ GraphicsConsoleControllerDriverStart ( GRAPHICS_CONSOLE_DEV *Private;
UINT32 HorizontalResolution;
UINT32 VerticalResolution;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
UINT32 ModeIndex;
UINTN MaxMode;
UINT32 ModeNumber;
@@ -432,18 +406,6 @@ GraphicsConsoleControllerDriverStart ( Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
-
- if (EFI_ERROR (Status) && FeaturePcdGet (PcdUgaConsumeSupport)) {
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiUgaDrawProtocolGuid,
- (VOID **)&Private->UgaDraw,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- }
-
if (EFI_ERROR (Status)) {
goto Error;
}
@@ -463,7 +425,7 @@ GraphicsConsoleControllerDriverStart ( //
MaxMode = Private->GraphicsOutput->Mode->MaxMode;
- for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) {
+ for (ModeIndex = 0; (UINTN)ModeIndex < MaxMode; ModeIndex++) {
Status = Private->GraphicsOutput->QueryMode (
Private->GraphicsOutput,
ModeIndex,
@@ -534,43 +496,6 @@ GraphicsConsoleControllerDriverStart ( goto Error;
}
}
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // At first try to set user-defined resolution
- //
- ColorDepth = 32;
- RefreshRate = 60;
- Status = Private->UgaDraw->SetMode (
- Private->UgaDraw,
- HorizontalResolution,
- VerticalResolution,
- ColorDepth,
- RefreshRate
- );
- if (EFI_ERROR (Status)) {
- //
- // Try to set 800*600 which is required by UEFI/EFI spec
- //
- Status = Private->UgaDraw->SetMode (
- Private->UgaDraw,
- 800,
- 600,
- ColorDepth,
- RefreshRate
- );
- if (EFI_ERROR (Status)) {
- Status = Private->UgaDraw->GetMode (
- Private->UgaDraw,
- &HorizontalResolution,
- &VerticalResolution,
- &ColorDepth,
- &RefreshRate
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
- }
- }
}
DEBUG ((DEBUG_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution));
@@ -638,7 +563,7 @@ GraphicsConsoleControllerDriverStart ( Error:
if (EFI_ERROR (Status)) {
//
- // Close the GOP and UGA Draw Protocol
+ // Close the GOP
//
if (Private->GraphicsOutput != NULL) {
gBS->CloseProtocol (
@@ -647,13 +572,6 @@ Error: This->DriverBindingHandle,
Controller
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUgaDrawProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
}
if (Private->LineBuffer != NULL) {
@@ -675,9 +593,7 @@ Error: /**
Stop this driver on Controller by removing Simple Text Out protocol
- and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
- (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
-
+ and closing the Graphics Output Protocol on Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to stop driver on
@@ -726,7 +642,7 @@ GraphicsConsoleControllerDriverStop ( if (!EFI_ERROR (Status)) {
//
- // Close the GOP or UGA IO Protocol
+ // Close the GOP Protocol
//
if (Private->GraphicsOutput != NULL) {
gBS->CloseProtocol (
@@ -735,13 +651,6 @@ GraphicsConsoleControllerDriverStop ( This->DriverBindingHandle,
Controller
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiUgaDrawProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
}
if (Private->LineBuffer != NULL) {
@@ -933,7 +842,6 @@ GraphicsConsoleConOutOutputString ( {
GRAPHICS_CONSOLE_DEV *Private;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
INTN Mode;
UINTN MaxColumn;
UINTN MaxRow;
@@ -967,7 +875,6 @@ GraphicsConsoleConOutOutputString ( Mode = This->Mode->Mode;
Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
GraphicsOutput = Private->GraphicsOutput;
- UgaDraw = Private->UgaDraw;
MaxColumn = Private->ModeData[Mode].Columns;
MaxRow = Private->ModeData[Mode].Rows;
@@ -1055,38 +962,6 @@ GraphicsConsoleConOutOutputString ( EFI_GLYPH_HEIGHT,
Delta
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // Scroll Screen Up One Row
- //
- UgaDraw->Blt (
- UgaDraw,
- NULL,
- EfiUgaVideoToVideo,
- DeltaX,
- DeltaY + EFI_GLYPH_HEIGHT,
- DeltaX,
- DeltaY,
- Width,
- Height,
- Delta
- );
-
- //
- // Print Blank Line at last line
- //
- UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)(UINTN)&Background,
- EfiUgaVideoFill,
- 0,
- 0,
- DeltaX,
- DeltaY + Height,
- Width,
- EFI_GLYPH_HEIGHT,
- Delta
- );
}
} else {
This->Mode->CursorRow++;
@@ -1320,19 +1195,13 @@ GraphicsConsoleConOutSetMode ( GRAPHICS_CONSOLE_DEV *Private;
GRAPHICS_CONSOLE_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
- UINT32 ColorDepth;
- UINT32 RefreshRate;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
GraphicsOutput = Private->GraphicsOutput;
- UgaDraw = Private->UgaDraw;
//
// Make sure the requested mode number is supported
@@ -1366,7 +1235,7 @@ GraphicsConsoleConOutSetMode ( }
//
- // Otherwise, the size of the text console and/or the GOP/UGA mode will be changed,
+ // Otherwise, the size of the text console and/or the GOP mode will be changed,
// so erase the cursor, and free the LineBuffer for the current mode
//
FlushCursor (This);
@@ -1422,51 +1291,6 @@ GraphicsConsoleConOutSetMode ( 0
);
}
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // Get the current UGA Draw mode information
- //
- Status = UgaDraw->GetMode (
- UgaDraw,
- &HorizontalResolution,
- &VerticalResolution,
- &ColorDepth,
- &RefreshRate
- );
- if (EFI_ERROR (Status) || (HorizontalResolution != ModeData->GopWidth) || (VerticalResolution != ModeData->GopHeight)) {
- //
- // Either no graphics mode is currently set, or it is set to the wrong resolution, so set the new graphics mode
- //
- Status = UgaDraw->SetMode (
- UgaDraw,
- ModeData->GopWidth,
- ModeData->GopHeight,
- 32,
- 60
- );
- if (EFI_ERROR (Status)) {
- //
- // The mode set operation failed
- //
- goto Done;
- }
- } else {
- //
- // The current graphics mode is correct, so simply clear the entire display
- //
- Status = UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)(UINTN)&mGraphicsEfiColors[0],
- EfiUgaVideoFill,
- 0,
- 0,
- 0,
- 0,
- ModeData->GopWidth,
- ModeData->GopHeight,
- 0
- );
- }
}
//
@@ -1558,7 +1382,6 @@ GraphicsConsoleConOutClearScreen ( GRAPHICS_CONSOLE_DEV *Private;
GRAPHICS_CONSOLE_MODE_DATA *ModeData;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
EFI_TPL OldTpl;
@@ -1574,7 +1397,6 @@ GraphicsConsoleConOutClearScreen ( Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
GraphicsOutput = Private->GraphicsOutput;
- UgaDraw = Private->UgaDraw;
ModeData = &(Private->ModeData[This->Mode->Mode]);
GetTextColors (This, &Foreground, &Background);
@@ -1591,19 +1413,6 @@ GraphicsConsoleConOutClearScreen ( ModeData->GopHeight,
0
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- Status = UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)(UINTN)&Background,
- EfiUgaVideoFill,
- 0,
- 0,
- 0,
- 0,
- ModeData->GopWidth,
- ModeData->GopHeight,
- 0
- );
} else {
Status = EFI_UNSUPPORTED;
}
@@ -1764,7 +1573,7 @@ GetTextColors ( @param Count The count of Unicode string.
@retval EFI_OUT_OF_RESOURCES If no memory resource to use.
- @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
+ @retval EFI_UNSUPPORTED If no Graphics Output protocol
protocol exist.
@retval EFI_SUCCESS Drawing Unicode string implemented successfully.
@@ -1781,9 +1590,6 @@ DrawUnicodeWeightAtCursorN ( EFI_IMAGE_OUTPUT *Blt;
EFI_STRING String;
EFI_FONT_DISPLAY_INFO *FontInfo;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
- EFI_HII_ROW_INFO *RowInfoArray;
- UINTN RowInfoArraySize;
Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
Blt = (EFI_IMAGE_OUTPUT *)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
@@ -1835,63 +1641,6 @@ DrawUnicodeWeightAtCursorN ( NULL,
NULL
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- //
- // If Graphics Output protocol cannot be found and PcdUgaConsumeSupport enabled,
- // using UGA Draw protocol to draw.
- //
- ASSERT (Private->UgaDraw != NULL);
-
- UgaDraw = Private->UgaDraw;
-
- Blt->Image.Bitmap = AllocateZeroPool (Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- if (Blt->Image.Bitmap == NULL) {
- FreePool (Blt);
- FreePool (String);
- return EFI_OUT_OF_RESOURCES;
- }
-
- RowInfoArray = NULL;
- //
- // StringToImage only support blt'ing image to device using GOP protocol. If GOP is not supported in this platform,
- // we ask StringToImage to print the string to blt buffer, then blt to device using UgaDraw.
- //
- Status = mHiiFont->StringToImage (
- mHiiFont,
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_IGNORE_LINE_BREAK,
- String,
- FontInfo,
- &Blt,
- This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
- This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
- &RowInfoArray,
- &RowInfoArraySize,
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Line breaks are handled by caller of DrawUnicodeWeightAtCursorN, so the updated parameter RowInfoArraySize by StringToImage will
- // always be 1 or 0 (if there is no valid Unicode Char can be printed). ASSERT here to make sure.
- //
- ASSERT (RowInfoArraySize <= 1);
-
- Status = UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)Blt->Image.Bitmap,
- EfiUgaBltBufferToVideo,
- This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
- (This->Mode->CursorRow) * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
- This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
- (This->Mode->CursorRow) * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
- RowInfoArray[0].LineWidth,
- RowInfoArray[0].LineHeight,
- Blt->Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
- }
-
- FreePool (RowInfoArray);
- FreePool (Blt->Image.Bitmap);
} else {
Status = EFI_UNSUPPORTED;
}
@@ -1934,7 +1683,6 @@ FlushCursor ( INTN GlyphX;
INTN GlyphY;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[EFI_GLYPH_HEIGHT][EFI_GLYPH_WIDTH];
@@ -1949,7 +1697,6 @@ FlushCursor ( Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
GraphicsOutput = Private->GraphicsOutput;
- UgaDraw = Private->UgaDraw;
//
// In this driver, only narrow character was supported.
@@ -1972,19 +1719,6 @@ FlushCursor ( EFI_GLYPH_HEIGHT,
EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)(UINTN)BltChar,
- EfiUgaVideoToBltBuffer,
- GlyphX,
- GlyphY,
- 0,
- 0,
- EFI_GLYPH_WIDTH,
- EFI_GLYPH_HEIGHT,
- EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
- );
}
GetTextColors (This, &Foreground.Pixel, &Background.Pixel);
@@ -2013,19 +1747,6 @@ FlushCursor ( EFI_GLYPH_HEIGHT,
EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
);
- } else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
- UgaDraw->Blt (
- UgaDraw,
- (EFI_UGA_PIXEL *)(UINTN)BltChar,
- EfiUgaBltBufferToVideo,
- 0,
- 0,
- GlyphX,
- GlyphY,
- EFI_GLYPH_WIDTH,
- EFI_GLYPH_HEIGHT,
- EFI_GLYPH_WIDTH * sizeof (EFI_UGA_PIXEL)
- );
}
return EFI_SUCCESS;
@@ -2084,7 +1805,10 @@ RegisterFontPackage ( PackageLength = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR) + mNarrowFontSize + 4;
Package = AllocateZeroPool (PackageLength);
- ASSERT (Package != NULL);
+ if (Package == NULL) {
+ ASSERT (Package != NULL);
+ return;
+ }
WriteUnaligned32 ((UINT32 *)Package, PackageLength);
SimplifiedFont = (EFI_HII_SIMPLE_FONT_PACKAGE_HDR *)(Package + 4);
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h index e4abad4..e1a6b37 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsole.h @@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Uefi.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/GraphicsOutput.h>
-#include <Protocol/UgaDraw.h>
#include <Protocol/DevicePath.h>
#include <Library/DebugLib.h>
#include <Library/UefiDriverEntryPoint.h>
@@ -59,7 +58,6 @@ typedef struct { typedef struct {
UINTN Signature;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_UGA_DRAW_PROTOCOL *UgaDraw;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
GRAPHICS_CONSOLE_MODE_DATA *ModeData;
@@ -417,9 +415,8 @@ GraphicsConsoleConOutEnableCursor ( /**
Test to see if Graphics Console could be supported on the Controller.
- Graphics Console could be supported if Graphics Output Protocol or UGADraw
- Protocol exists on the Controller. (UGA Draw Protocol could be skipped
- if PcdUgaConsumeSupport is set to FALSE.)
+ Graphics Console could be supported if Graphics Output Protocol
+ exists on the Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to test.
@@ -439,9 +436,8 @@ GraphicsConsoleControllerDriverSupported ( );
/**
- Start this driver on Controller by opening Graphics Output protocol or
- UGA Draw protocol, and installing Simple Text Out protocol on Controller.
- (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
+ Start this driver on Controller by opening Graphics Output protocol
+ and installing Simple Text Out protocol on Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to bind driver to
@@ -462,9 +458,7 @@ GraphicsConsoleControllerDriverStart ( /**
Stop this driver on Controller by removing Simple Text Out protocol
- and closing the Graphics Output Protocol or UGA Draw protocol on Controller.
- (UGA Draw protocol could be skipped if PcdUgaConsumeSupport is set to FALSE.)
-
+ and closing the Graphics Output Protocol on Controller.
@param This Protocol instance pointer.
@param Controller Handle of device to stop driver on
@@ -526,8 +520,7 @@ GetTextColors ( @param Count The count of Unicode string.
@retval EFI_OUT_OF_RESOURCES If no memory resource to use.
- @retval EFI_UNSUPPORTED If no Graphics Output protocol and UGA Draw
- protocol exist.
+ @retval EFI_UNSUPPORTED If no Graphics Output protocol exist.
@retval EFI_SUCCESS Drawing Unicode string implemented successfully.
**/
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf index bcfd306..975871b 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf @@ -2,7 +2,7 @@ # Console support on graphic devices.
#
# This driver will install Simple Text Output protocol by consuming Graphices Output
-# protocol or UGA Draw protocol on graphic devices.
+# protocol on graphic devices.
#
# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -53,15 +53,11 @@ gEfiDevicePathProtocolGuid ## TO_START
gEfiSimpleTextOutProtocolGuid ## BY_START
gEfiGraphicsOutputProtocolGuid ## TO_START
- gEfiUgaDrawProtocolGuid ## TO_START
gEfiHiiFontProtocolGuid ## TO_START
## TO_START
## NOTIFY
gEfiHiiDatabaseProtocolGuid
-[FeaturePcd]
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES
-
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.uni b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.uni index aec5d57..45dbb24 100644 --- a/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.uni +++ b/MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.uni @@ -2,7 +2,7 @@ // Console support on graphic devices.
//
// This driver will install Simple Text Output protocol by consuming Graphices Output
-// protocol or UGA Draw protocol on graphic devices.
+// protocol on graphic devices.
//
// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
//
@@ -14,5 +14,5 @@ #string STR_MODULE_ABSTRACT #language en-US "Console support on graphic devices"
#string STR_MODULE_DESCRIPTION #language en-US "This driver will install SimpleTextOutputProtocol by consuming GraphicesOutput\n"
- "Protocol or UgaDrawProtocol on graphics devices."
+ "Protocol on graphics devices."
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c index e2d779c..2f45571 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.c @@ -2,6 +2,7 @@ Produces Simple Text Input Protocol, Simple Text Input Extended Protocol and
Simple Text Output Protocol upon Serial IO Protocol.
+Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -114,7 +115,10 @@ TERMINAL_DEV mTerminalDevTemplate = { TERMINAL_CONSOLE_MODE_DATA mTerminalConsoleModeData[] = {
{ 80, 25 },
{ 80, 50 },
- { 100, 31 },
+ { 100, 31 }, // 800 x 600
+ { 128, 40 }, // 1024 x 768
+ { 160, 42 }, // 1280 x 800
+ { 240, 56 }, // 1920 x 1080
//
// New modes can be added here.
//
@@ -1261,19 +1265,21 @@ TerminalRemoveConsoleDevVariable ( FreePool (OriginalVariable);
if (FoundOne) {
- VariableSize = GetDevicePathSize (NewVariable);
-
- Status = gRT->SetVariable (
- VariableName,
- &gEfiGlobalVariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- VariableSize,
- NewVariable
- );
- //
- // Shrinking variable with existing variable driver implementation shouldn't fail.
- //
- ASSERT_EFI_ERROR (Status);
+ if (NewVariable != NULL) {
+ VariableSize = GetDevicePathSize (NewVariable);
+
+ Status = gRT->SetVariable (
+ VariableName,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ VariableSize,
+ NewVariable
+ );
+ //
+ // Shrinking variable with existing variable driver implementation shouldn't fail.
+ //
+ ASSERT_EFI_ERROR (Status);
+ }
}
if (NewVariable != NULL) {
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h index 7581cda..66438be 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h +++ b/MdeModulePkg/Universal/Console/TerminalDxe/Terminal.h @@ -1,6 +1,7 @@ /** @file
Header file for Terminal driver.
+Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -162,6 +163,8 @@ typedef union { #define ROW_OFFSET 2
#define COLUMN_OFFSET 5
#define FW_BACK_OFFSET 2
+#define RESIZE_ROW_OFFSET 4
+#define RESIZE_COLUMN_OFFSET 8
typedef struct {
UINT16 Unicode;
@@ -1216,8 +1219,8 @@ AnsiRawDataToUnicode ( Putty function key map:
+=========+======+===========+=============+=============+=============+=========+
| | EFI | | | | | |
- | | Scan | | | Normal | | |
- | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ | | Scan | VT100+ | | Normal | | |
+ | KEY | Code | VTUTF8 | Xterm R6 | VT400 | Linux | SCO |
+=========+======+===========+=============+=============+=============+=========+
| F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
| F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c index aafa65f..f1d0a34 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConIn.c @@ -95,6 +95,13 @@ TerminalConInReset ( );
}
+ if (!EFI_ERROR (Status)) {
+ Status = TerminalDevice->SerialIo->SetControl (TerminalDevice->SerialIo, EFI_SERIAL_DATA_TERMINAL_READY|EFI_SERIAL_REQUEST_TO_SEND);
+ if (Status == EFI_UNSUPPORTED) {
+ Status = EFI_SUCCESS;
+ }
+ }
+
return Status;
}
@@ -1313,8 +1320,8 @@ UnicodeToEfiKeyFlushState ( Putty function key map:
+=========+======+===========+=============+=============+=============+=========+
| | EFI | | | | | |
- | | Scan | | | Normal | | |
- | KEY | Code | VT100+ | Xterm R6 | VT400 | Linux | SCO |
+ | | Scan | VT100+ | | Normal | | |
+ | KEY | Code | VTUTF8 | Xterm R6 | VT400 | Linux | SCO |
+=========+======+===========+=============+=============+=============+=========+
| F1 | 0x0B | ESC O P | ESC O P | ESC [ 1 1 ~ | ESC [ [ A | ESC [ M |
| F2 | 0x0C | ESC O Q | ESC O Q | ESC [ 1 2 ~ | ESC [ [ B | ESC [ N |
@@ -1391,7 +1398,8 @@ UnicodeToEfiKey ( if ((UnicodeChar == 'O') && ((TerminalDevice->TerminalType == TerminalTypeVt100) ||
(TerminalDevice->TerminalType == TerminalTypeTtyTerm) ||
(TerminalDevice->TerminalType == TerminalTypeXtermR6) ||
- (TerminalDevice->TerminalType == TerminalTypeVt100Plus)))
+ (TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
+ (TerminalDevice->TerminalType == TerminalTypeVtUtf8)))
{
TerminalDevice->InputState |= INPUT_STATE_O;
TerminalDevice->ResetState = RESET_STATE_DEFAULT;
@@ -1565,7 +1573,9 @@ UnicodeToEfiKey ( Key.ScanCode = SCAN_END;
break;
}
- } else if (TerminalDevice->TerminalType == TerminalTypeVt100Plus) {
+ } else if ((TerminalDevice->TerminalType == TerminalTypeVt100Plus) ||
+ (TerminalDevice->TerminalType == TerminalTypeVtUtf8))
+ {
switch (UnicodeChar) {
case 'P':
Key.ScanCode = SCAN_F1;
diff --git a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c index 7809869..eb8658c 100644 --- a/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c +++ b/MdeModulePkg/Universal/Console/TerminalDxe/TerminalConOut.c @@ -1,6 +1,7 @@ /** @file
Implementation for EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL protocol.
+Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.<BR>
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (C) 2016 Silicon Graphics, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -74,6 +75,7 @@ UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = { };
CHAR16 mSetModeString[] = { ESC, '[', '=', '3', 'h', 0 };
+CHAR16 mSetModeStringResize[] = { ESC, '[', '8', ';', '0', '0', '0', ';', '0', '0', '0', 't', '0', 0 };
CHAR16 mSetAttributeString[] = { ESC, '[', '0', 'm', ESC, '[', '4', '0', 'm', ESC, '[', '4', '0', 'm', 0 };
CHAR16 mClearScreenString[] = { ESC, '[', '2', 'J', 0 };
CHAR16 mSetCursorPositionString[] = { ESC, '[', '0', '0', ';', '0', '0', 'H', 0 };
@@ -453,7 +455,6 @@ TerminalConOutQueryMode ( Implements EFI_SIMPLE_TEXT_OUT.SetMode().
Set the terminal to a specified display mode.
- In this driver, we only support mode 0.
@param This Indicates the calling context.
@param ModeNumber The text mode to set.
@@ -473,9 +474,12 @@ TerminalConOutSetMode ( {
EFI_STATUS Status;
TERMINAL_DEV *TerminalDevice;
+ CHAR16 *String;
+ UINTN Columns;
+ UINTN Rows;
//
- // get Terminal device data structure pointer.
+ // Get Terminal device data structure pointer.
//
TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (This);
@@ -484,6 +488,25 @@ TerminalConOutSetMode ( }
//
+ // Configure terminal string for the text mode to set.
+ //
+ if (ModeNumber == 0) {
+ String = mSetModeString;
+ } else {
+ Columns = TerminalDevice->TerminalConsoleModeData[ModeNumber].Columns;
+ Rows = TerminalDevice->TerminalConsoleModeData[ModeNumber].Rows;
+
+ mSetModeStringResize[RESIZE_ROW_OFFSET + 0] = (CHAR16)('0' + (Rows / 100));
+ mSetModeStringResize[RESIZE_ROW_OFFSET + 1] = (CHAR16)('0' + ((Rows - ((Rows / 100) * 100)) / 10));
+ mSetModeStringResize[RESIZE_ROW_OFFSET + 2] = (CHAR16)('0' + (Rows % 10));
+ mSetModeStringResize[RESIZE_COLUMN_OFFSET + 0] = (CHAR16)('0' + (Columns / 100));
+ mSetModeStringResize[RESIZE_COLUMN_OFFSET + 1] = (CHAR16)('0' + ((Columns - ((Columns / 100) * 100)) / 10));
+ mSetModeStringResize[RESIZE_COLUMN_OFFSET + 2] = (CHAR16)('0' + (Columns % 10));
+
+ String = mSetModeStringResize;
+ }
+
+ //
// Set the current mode
//
This->Mode->Mode = (INT32)ModeNumber;
@@ -491,7 +514,7 @@ TerminalConOutSetMode ( This->ClearScreen (This);
TerminalDevice->OutputEscChar = TRUE;
- Status = This->OutputString (This, mSetModeString);
+ Status = This->OutputString (This, String);
TerminalDevice->OutputEscChar = FALSE;
if (EFI_ERROR (Status)) {
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c index b340727..cc3257e 100644 --- a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c +++ b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c @@ -78,7 +78,7 @@ PeiDebugAssert ( @param FileHandle Handle of the file being invoked.
@param PeiServices Describes the list of possible PEI Services.
- @retval EFI_SUCESS The entry point of Debug Service PEIM executes successfully.
+ @retval EFI_SUCCESS The entry point of Debug Service PEIM executes successfully.
@retval Others Some error occurs during the execution of this function.
**/
diff --git a/MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.c b/MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.c index 40fe74d..2291985 100644 --- a/MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.c +++ b/MdeModulePkg/Universal/DebugSupportDxe/Ia32/PlDebugSupport.c @@ -262,17 +262,24 @@ InvalidateInstructionCache ( **/
VOID
InterruptDistrubutionHub (
- EFI_EXCEPTION_TYPE ExceptionType,
- EFI_SYSTEM_CONTEXT_IA32 *ContextRecord
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN EFI_SYSTEM_CONTEXT ContextRecord
)
{
- if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {
- if (ExceptionType != SYSTEM_TIMER_VECTOR) {
- IdtEntryTable[ExceptionType].RegisteredCallback (ExceptionType, ContextRecord);
- } else {
- OrigVector = IdtEntryTable[ExceptionType].OrigVector;
- IdtEntryTable[ExceptionType].RegisteredCallback (ContextRecord);
- }
+ EFI_EXCEPTION_CALLBACK ExceptionCallback;
+ EFI_PERIODIC_CALLBACK PeriodicCallback;
+
+ if (IdtEntryTable[ExceptionType].RegisteredCallback == NULL) {
+ return;
+ }
+
+ if (ExceptionType == SYSTEM_TIMER_VECTOR) {
+ OrigVector = IdtEntryTable[ExceptionType].OrigVector;
+ PeriodicCallback = (EFI_PERIODIC_CALLBACK)IdtEntryTable[ExceptionType].RegisteredCallback;
+ PeriodicCallback (ContextRecord);
+ } else {
+ ExceptionCallback = (EFI_EXCEPTION_CALLBACK)IdtEntryTable[ExceptionType].RegisteredCallback;
+ ExceptionCallback (ExceptionType, ContextRecord);
}
}
diff --git a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c index 38af39f..54b634a 100644 --- a/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c +++ b/MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIo.c @@ -846,7 +846,8 @@ DiskIo2ReadWriteDisk ( LIST_ENTRY Subtasks;
DISK_IO_SUBTASK *Subtask;
DISK_IO2_TASK *Task;
- EFI_TPL OldTpl;
+ EFI_TPL SubtaskPerformTpl;
+ EFI_TPL SubtaskLockTpl;
BOOLEAN Blocking;
BOOLEAN SubtaskBlocking;
LIST_ENTRY *SubtasksPtr;
@@ -896,7 +897,7 @@ DiskIo2ReadWriteDisk ( ASSERT (!IsListEmpty (SubtasksPtr));
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+ SubtaskPerformTpl = gBS->RaiseTPL (TPL_CALLBACK);
for ( Link = GetFirstNode (SubtasksPtr), NextLink = GetNextNode (SubtasksPtr, Link)
; !IsNull (SubtasksPtr, Link)
; Link = NextLink, NextLink = GetNextNode (SubtasksPtr, NextLink)
@@ -977,7 +978,7 @@ DiskIo2ReadWriteDisk ( }
}
- gBS->RaiseTPL (TPL_NOTIFY);
+ SubtaskLockTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
// Remove all the remaining subtasks when failure.
@@ -1012,7 +1013,8 @@ DiskIo2ReadWriteDisk ( FreePool (Task);
}
- gBS->RestoreTPL (OldTpl);
+ gBS->RestoreTPL (SubtaskLockTpl);
+ gBS->RestoreTPL (SubtaskPerformTpl);
return Status;
}
diff --git a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c index 60cf3c8..2dac121 100644 --- a/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c +++ b/MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskImpl.c @@ -404,7 +404,8 @@ HiiCreateRamDisk ( );
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- return EFI_DEVICE_ERROR;
+ Status = EFI_DEVICE_ERROR;
+ goto ErrorExit;
}
}
@@ -431,7 +432,7 @@ HiiCreateRamDisk ( );
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
- return Status;
+ goto ErrorExit;
}
//
@@ -442,6 +443,10 @@ HiiCreateRamDisk ( PrivateData->CreateMethod = RamDiskCreateHii;
return EFI_SUCCESS;
+
+ErrorExit:
+ gBS->FreePool (StartingAddr);
+ return Status;
}
/**
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c index a7b7dc7..81020b2 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c @@ -2014,8 +2014,8 @@ FindTopMenu ( /**
Record the highlight menu and top of screen menu info.
- @param Highlight The menu opton which is highlight.
- @param TopOfScreen The menu opton which is at the top of the form.
+ @param Highlight The menu option which is highlight.
+ @param TopOfScreen The menu option which is at the top of the form.
@param SkipValue The skip line info for the top of screen menu.
**/
@@ -2095,9 +2095,9 @@ UpdateHighlightMenuInfo ( }
/**
- Update attribut for this menu.
+ Update attribute for this menu.
- @param MenuOption The menu opton which this attribut used to.
+ @param MenuOption The menu option which this attribute used to.
@param Highlight Whether this menu will be highlight.
**/
@@ -2130,7 +2130,7 @@ SetDisplayAttribute ( /**
Print string for this menu option.
- @param MenuOption The menu opton which this attribut used to.
+ @param MenuOption The menu option which this attribute used to.
@param Col The column that this string will be print at.
@param Row The row that this string will be print at.
@param String The string which need to print.
@@ -2164,19 +2164,20 @@ DisplayMenuString ( // First print the highlight string.
//
SetDisplayAttribute (MenuOption, TRUE);
- Length = PrintStringAt (Col, Row, String);
+ PrintStringAt (Col, Row, String);
//
// Second, clean the empty after the string.
//
SetDisplayAttribute (MenuOption, FALSE);
+ Length = GetStringWidth (String) / 2 - 1;
PrintStringAtWithWidth (Col + Length, Row, L"", Width - Length);
}
/**
Check whether this menu can has option string.
- @param MenuOption The menu opton which this attribut used to.
+ @param MenuOption The menu option which this attribute used to.
@retval TRUE This menu option can have option string.
@retval FALSE This menu option can't have option string.
@@ -2371,7 +2372,7 @@ FxConfirmPopup ( /**
Print string for this menu option.
- @param MenuOption The menu opton which this attribut used to.
+ @param MenuOption The menu option which this attribute used to.
@param SkipWidth The skip width between the left to the start of the prompt.
@param BeginCol The begin column for one menu.
@param SkipLine The skip line for this menu.
@@ -2379,7 +2380,7 @@ FxConfirmPopup ( @param Highlight Whether this menu will be highlight.
@param UpdateCol Whether need to update the column info for Date/Time.
- @retval EFI_SUCESSS Process the user selection success.
+ @retval EFI_SUCCESS Process the user selection success.
**/
EFI_STATUS
@@ -2626,7 +2627,7 @@ DisplayOneMenu ( @param FormData The current form data info.
- @retval EFI_SUCESSS Process the user selection success.
+ @retval EFI_SUCCESS Process the user selection success.
@retval EFI_NOT_FOUND Process option string for orderedlist/Oneof fail.
**/
@@ -2904,9 +2905,9 @@ UiDisplayMenu ( case CfRefreshHighLight:
//
- // MenuOption: Last menu option that need to remove hilight
+ // MenuOption: Last menu option that need to remove highlight
// MenuOption is set to NULL in Repaint
- // NewPos: Current menu option that need to hilight
+ // NewPos: Current menu option that need to highlight
//
ControlFlag = CfUpdateHelpString;
@@ -2986,13 +2987,13 @@ UiDisplayMenu ( }
//
- // NewLine means only update highlight menu (remove old highlight and highlith
- // the new one), not need to full repain the form.
+ // NewLine means only update highlight menu (remove old highlight and highlight
+ // the new one), not need to full repaint the form.
//
if (Repaint || NewLine) {
if (IsListEmpty (&gMenuOption)) {
//
- // Don't print anything if no mwnu option.
+ // Don't print anything if no menu option.
//
StringPtr = GetToken (STRING_TOKEN (EMPTY_STRING), gHiiHandle);
} else {
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h index 6e26704..a7b15a8 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h +++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h @@ -696,8 +696,8 @@ RefreshTimeOutProcess ( /**
Record the highlight menu and top of screen menu info.
- @param Highlight The menu opton which is highlight.
- @param TopOfScreen The menu opton which is at the top of the form.
+ @param Highlight The menu option which is highlight.
+ @param TopOfScreen The menu option which is at the top of the form.
@param SkipValue The skip line info for the top of screen menu.
**/
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c index b6dc234..b2a3ef6 100644 --- a/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c +++ b/MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c @@ -229,8 +229,8 @@ ReadString ( case CHAR_BACKSPACE:
if ((StringPtr[0] != CHAR_NULL) && (CurrentCursor != 0)) {
- for (Index = 0; Index < CurrentCursor - 1; Index++) {
- TempString[Index] = StringPtr[Index];
+ if (CurrentCursor > 1) {
+ CopyMem (TempString, StringPtr, (CurrentCursor - 1) * sizeof (CHAR16));
}
Count = GetStringWidth (StringPtr) / 2 - 1;
@@ -261,9 +261,7 @@ ReadString ( KeyPad[1] = CHAR_NULL;
Count = GetStringWidth (StringPtr) / 2 - 1;
if (CurrentCursor < Count) {
- for (Index = 0; Index < CurrentCursor; Index++) {
- TempString[Index] = StringPtr[Index];
- }
+ CopyMem (TempString, StringPtr, CurrentCursor * sizeof (CHAR16));
TempString[Index] = CHAR_NULL;
StrCatS (TempString, MaxLen, KeyPad);
diff --git a/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c b/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c index 4794365..d629684 100644 --- a/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c +++ b/MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.c @@ -694,6 +694,7 @@ DriverHealthManagerUpdateForm ( UINTN Index;
EFI_STRING_ID Prompt;
EFI_STRING_ID Help;
+ EFI_STRING_ID TextTwo;
CHAR16 String[512];
UINTN StringCount;
EFI_STRING TmpString;
@@ -848,11 +849,12 @@ DriverHealthManagerUpdateForm ( mDriverHealthManagerHealthInfo[Index].HealthStatus == EfiDriverHealthStatusHealthy ||
mDriverHealthManagerHealthInfo[Index].HealthStatus == EfiDriverHealthStatusFailed
);
+ TextTwo = Help;
HiiCreateTextOpCode (
StartOpCodeHandle,
Prompt,
- Help,
- 0
+ 0,
+ TextTwo
);
break;
}
@@ -872,7 +874,7 @@ DriverHealthManagerUpdateForm ( }
/**
- Called when the form is closing to remove the dynamicly added string from the HII package list.
+ Called when the form is closing to remove the dynamically added string from the HII package list.
**/
VOID
DriverHealthManagerCleanDynamicString (
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index 003cb49..b8c903b 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -1746,7 +1746,7 @@ DriverCallback ( @param ImageHandle Image handle this driver.
@param SystemTable Pointer to SystemTable.
- @retval EFI_SUCESS This function always complete successfully.
+ @retval EFI_SUCCESS This function always complete successfully.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c index 834c90e..cc3b3e3 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbSymbol.c @@ -1773,7 +1773,7 @@ FindSymbolStr ( Get line number and offset from this line in code file.
@param Line - Line buffer in code file
- @param Offset - Offset to functin entry
+ @param Offset - Offset to function entry
@return Line number
@@ -1867,7 +1867,7 @@ typedef enum { Get line number from this code file.
@param Entry - Symbol entry
- @param FuncOffset - Offset to functin entry
+ @param FuncOffset - Offset to function entry
@param SearchType - Search type for the code
@return Line number
@@ -2045,7 +2045,7 @@ EdbGetSourceStrFromCodeByLine ( Get source string from this code file.
@param Entry - Symbol entry
- @param FuncOffset - Offset to functin entry
+ @param FuncOffset - Offset to function entry
@param FuncEnd - Function end
@retval Funtion start
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c index 508184f..5c168c8 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c @@ -810,12 +810,18 @@ FtwGetLastWriteHeader ( FtwHeader = (EFI_FAULT_TOLERANT_WRITE_HEADER *)(FtwWorkSpaceHeader + 1);
Offset = sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
+ if (!CompareGuid (&FtwWorkSpaceHeader->Signature, &gEdkiiWorkingBlockSignatureGuid)) {
+ *FtwWriteHeader = FtwHeader;
+ return EFI_ABORTED;
+ }
+
while (FtwHeader->Complete == FTW_VALID_STATE) {
Offset += FTW_WRITE_TOTAL_SIZE (FtwHeader->NumberOfWrites, FtwHeader->PrivateDataSize);
//
// If Offset exceed the FTW work space boudary, return error.
//
- if (Offset >= FtwWorkSpaceSize) {
+
+ if ((Offset + sizeof (EFI_FAULT_TOLERANT_WRITE_HEADER)) >= FtwWorkSpaceSize) {
*FtwWriteHeader = FtwHeader;
return EFI_ABORTED;
}
@@ -1294,7 +1300,10 @@ InitFtwProtocol ( // Refresh the working space data from working block
//
Status = WorkSpaceRefresh (FtwDevice);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Ftw: Init.. WorkSpaceRefresh failed: Status = %r\n", Status));
+ }
+
//
// If the working block workspace is not valid, try the spare block
//
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c index fd56364..caa87e9 100644 --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c @@ -286,6 +286,10 @@ WorkSpaceRefresh ( return EFI_ABORTED;
}
+ if (!IsValidWorkSpace (FtwDevice->FtwWorkSpaceHeader)) {
+ return EFI_ABORTED;
+ }
+
//
// Refresh the FtwLastWriteHeader
//
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c index 0252db1..42ab3f1 100644 --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c @@ -562,6 +562,10 @@ FvSimpleFileSystemOpen ( // NewFileNameLength = FileNameLength + 1 + 4 = (Number of non-null character) + (file extension) + (a null character)
NewFileNameLength = FileNameLength + 1 + 4;
FileNameWithExtension = AllocatePool (NewFileNameLength * 2);
+ if (FileNameWithExtension == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
StrCpyS (FileNameWithExtension, NewFileNameLength, FileName);
StrCatS (FileNameWithExtension, NewFileNameLength, L".EFI");
diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c index 3f96407..5d7fdaa 100644 --- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c +++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemEntryPoint.c @@ -450,7 +450,10 @@ FvSimpleFileSystemDriverStart ( // Create an instance
//
Instance = AllocateZeroPool (sizeof (FV_FILESYSTEM_INSTANCE));
- ASSERT (Instance != NULL);
+ if (Instance == NULL) {
+ ASSERT (Instance != NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
Instance->Root = NULL;
Instance->FvProtocol = FvProtocol;
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 5ae6189..c9aabaa 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -1372,6 +1372,149 @@ GetSupportedLanguages ( }
/**
+ This function create a new string in String Package or updates an existing
+ string in a String Package. If StringId is 0, then a new string is added to
+ a String Package. If StringId is not zero, then a string in String Package is
+ updated. If SupportedLanguages is NULL, then the string is added or updated
+ for all the languages that the String Package supports. If SupportedLanguages
+ is not NULL, then the string is added or updated for the set of languages
+ specified by SupportedLanguages.
+
+ If HiiHandle is NULL, then ASSERT().
+ If String is NULL, then ASSERT().
+
+ @param[in] HiiHandle A handle that was previously registered in the
+ HII Database.
+ @param[in] StringId If zero, then a new string is created in the
+ String Package associated with HiiHandle. If
+ non-zero, then the string specified by StringId
+ is updated in the String Package associated
+ with HiiHandle.
+ @param[in] String A pointer to the Null-terminated Unicode string
+ to add or update in the String Package associated
+ with HiiHandle.
+ @param[in] SupportedLanguages A pointer to a Null-terminated ASCII string of
+ language codes. If this parameter is NULL, then
+ String is added or updated in the String Package
+ associated with HiiHandle for all the languages
+ that the String Package supports. If this
+ parameter is not NULL, then then String is added
+ or updated in the String Package associated with
+ HiiHandle for the set oflanguages specified by
+ SupportedLanguages. The format of
+ SupportedLanguages must follow the language
+ format assumed the HII Database.
+
+ @retval 0 The string could not be added or updated in the String Package.
+ @retval Other The EFI_STRING_ID of the newly added or updated string.
+
+**/
+EFI_STRING_ID
+InternalHiiSetString (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_STRING_ID StringId OPTIONAL,
+ IN CONST EFI_STRING String,
+ IN CONST CHAR8 *SupportedLanguages OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ CHAR8 *AllocatedLanguages;
+ CHAR8 *Supported;
+ CHAR8 *Language;
+
+ ASSERT (HiiHandle != NULL);
+
+ if (SupportedLanguages == NULL) {
+ //
+ // Retrieve the languages that the package specified by HiiHandle supports
+ //
+ AllocatedLanguages = GetSupportedLanguages (HiiHandle);
+ } else {
+ //
+ // Allocate a copy of the SupportLanguages string that passed in
+ //
+ AllocatedLanguages = AllocateCopyPool (AsciiStrSize (SupportedLanguages), SupportedLanguages);
+ }
+
+ //
+ // If there are not enough resources for the supported languages string, then return a StringId of 0
+ //
+ if (AllocatedLanguages == NULL) {
+ return (EFI_STRING_ID)(0);
+ }
+
+ Status = EFI_INVALID_PARAMETER;
+ //
+ // Loop through each language that the string supports
+ //
+ for (Supported = AllocatedLanguages; *Supported != '\0'; ) {
+ //
+ // Cache a pointer to the beginning of the current language in the list of languages
+ //
+ Language = Supported;
+
+ //
+ // Search for the next language separator and replace it with a Null-terminator
+ //
+ for ( ; *Supported != 0 && *Supported != ';'; Supported++) {
+ }
+
+ if (*Supported != 0) {
+ *(Supported++) = '\0';
+ }
+
+ if ((SupportedLanguages == NULL) && (AsciiStrnCmp (Language, UEFI_CONFIG_LANG, AsciiStrLen (UEFI_CONFIG_LANG)) == 0)) {
+ //
+ // Skip string package used for keyword protocol.
+ //
+ continue;
+ }
+
+ //
+ // If StringId is 0, then call NewString(). Otherwise, call SetString()
+ //
+ if (StringId == (EFI_STRING_ID)(0)) {
+ Status = mPrivate.HiiString.NewString (
+ &mPrivate.HiiString,
+ HiiHandle,
+ &StringId,
+ Language,
+ NULL,
+ String,
+ NULL
+ );
+ } else {
+ Status = mPrivate.HiiString.SetString (
+ &mPrivate.HiiString,
+ HiiHandle,
+ StringId,
+ Language,
+ String,
+ NULL
+ );
+ }
+
+ //
+ // If there was an error, then break out of the loop and return a StringId of 0
+ //
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ //
+ // Free the buffer of supported languages
+ //
+ FreePool (AllocatedLanguages);
+
+ if (EFI_ERROR (Status)) {
+ return (EFI_STRING_ID)(0);
+ } else {
+ return StringId;
+ }
+}
+
+/**
Retrieves a string from a string package.
If HiiHandle is NULL, then ASSERT().
@@ -2202,6 +2345,7 @@ ParseIfrData ( BOOLEAN SmallestIdFromFlag;
BOOLEAN FromOtherDefaultOpcode;
BOOLEAN QuestionReferBitField;
+ UINT16 *StringData;
Status = EFI_SUCCESS;
BlockData = NULL;
@@ -2215,6 +2359,7 @@ ParseIfrData ( FromOtherDefaultOpcode = FALSE;
QuestionReferBitField = FALSE;
IfrEfiVarStoreTmp = NULL;
+ StringData = NULL;
//
// Go through the form package to parse OpCode one by one.
@@ -2871,6 +3016,33 @@ ParseIfrData ( goto Done;
}
+ if (IfrEfiVarStoreTmp == NULL) {
+ break;
+ }
+
+ //
+ // Set default value base on the DefaultId list get from IFR data.
+ //
+ NvDefaultStoreSize = PcdGetSize (PcdNvStoreDefaultValueBuffer);
+ for (LinkData = DefaultIdArray->Entry.ForwardLink; LinkData != &DefaultIdArray->Entry; LinkData = LinkData->ForwardLink) {
+ DefaultDataPtr = BASE_CR (LinkData, IFR_DEFAULT_DATA, Entry);
+ DefaultData.DefaultId = DefaultDataPtr->DefaultId;
+ if (NvDefaultStoreSize > sizeof (PCD_NV_STORE_DEFAULT_BUFFER_HEADER)) {
+ StringData = AllocateZeroPool (VarWidth*2);
+ if (StringData == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ FindQuestionDefaultSetting (DefaultData.DefaultId, IfrEfiVarStoreTmp, &(IfrString->Question), (VOID *)StringData, VarWidth, QuestionReferBitField);
+ if ((DefaultData.Value.string != 0) && (StringData != NULL)) {
+ DefaultData.Value.string = InternalHiiSetString (HiiHandle, 0, StringData, NULL);
+ InsertDefaultValue (BlockData, &DefaultData);
+ FreePool (StringData);
+ }
+ }
+ }
+
break;
case EFI_IFR_PASSWORD_OP:
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 0b09c24..314e408 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -574,6 +574,45 @@ IsEfiVarStoreQuestion ( @return Pointer to the matched variable header or NULL if not found.
**/
+AUTHENTICATED_VARIABLE_HEADER *
+AuthFindVariableData (
+ IN VARIABLE_STORE_HEADER *VariableStorage,
+ IN EFI_GUID *VarGuid,
+ IN UINT32 VarAttribute,
+ IN CHAR16 *VarName
+ )
+{
+ AUTHENTICATED_VARIABLE_HEADER *VariableHeader;
+ AUTHENTICATED_VARIABLE_HEADER *VariableEnd;
+
+ VariableEnd = (AUTHENTICATED_VARIABLE_HEADER *)((UINT8 *)VariableStorage + VariableStorage->Size);
+ VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)(VariableStorage + 1);
+ VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN (VariableHeader);
+ while (VariableHeader < VariableEnd) {
+ if (CompareGuid (&VariableHeader->VendorGuid, VarGuid) &&
+ (VariableHeader->Attributes == VarAttribute) &&
+ (StrCmp (VarName, (CHAR16 *)(VariableHeader + 1)) == 0))
+ {
+ return VariableHeader;
+ }
+
+ VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)((UINT8 *)VariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + VariableHeader->NameSize + VariableHeader->DataSize);
+ VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN (VariableHeader);
+ }
+
+ return NULL;
+}
+
+/**
+ Find the matched variable from the input variable storage.
+
+ @param[in] VariableStorage Point to the variable storage header.
+ @param[in] VarGuid A unique identifier for the variable.
+ @param[in] VarAttribute The attributes bitmask for the variable.
+ @param[in] VarName A Null-terminated ascii string that is the name of the variable.
+
+ @return Pointer to the matched variable header or NULL if not found.
+**/
VARIABLE_HEADER *
FindVariableData (
IN VARIABLE_STORE_HEADER *VariableStorage,
@@ -626,25 +665,32 @@ FindQuestionDefaultSetting ( IN BOOLEAN BitFieldQuestion
)
{
- VARIABLE_HEADER *VariableHeader;
- VARIABLE_STORE_HEADER *VariableStorage;
- LIST_ENTRY *Link;
- VARSTORAGE_DEFAULT_DATA *Entry;
- VARIABLE_STORE_HEADER *NvStoreBuffer;
- UINT8 *DataBuffer;
- UINT8 *BufferEnd;
- BOOLEAN IsFound;
- UINTN Index;
- UINT32 BufferValue;
- UINT32 BitFieldVal;
- UINTN BitOffset;
- UINTN ByteOffset;
- UINTN BitWidth;
- UINTN StartBit;
- UINTN EndBit;
- PCD_DEFAULT_DATA *DataHeader;
- PCD_DEFAULT_INFO *DefaultInfo;
- PCD_DATA_DELTA *DeltaData;
+ AUTHENTICATED_VARIABLE_HEADER *AuthVariableHeader;
+ VARIABLE_HEADER *VariableHeader;
+ VARIABLE_STORE_HEADER *VariableStorage;
+ LIST_ENTRY *Link;
+ VARSTORAGE_DEFAULT_DATA *Entry;
+ VARIABLE_STORE_HEADER *NvStoreBuffer;
+ UINT8 *DataBuffer;
+ UINT8 *BufferEnd;
+ BOOLEAN IsFound;
+ UINTN Index;
+ UINT32 BufferValue;
+ UINT32 BitFieldVal;
+ UINTN BitOffset;
+ UINTN ByteOffset;
+ UINTN BitWidth;
+ UINTN StartBit;
+ UINTN EndBit;
+ PCD_DEFAULT_DATA *DataHeader;
+ PCD_DEFAULT_INFO *DefaultInfo;
+ PCD_DATA_DELTA *DeltaData;
+ BOOLEAN VarCheck;
+
+ if (EfiVarStore == NULL) {
+ DEBUG ((DEBUG_ERROR, "EfiVarStore is null\n"));
+ return EFI_NOT_FOUND;
+ }
if (gSkuId == 0xFFFFFFFFFFFFFFFF) {
gSkuId = LibPcdGetSku ();
@@ -750,40 +796,81 @@ FindQuestionDefaultSetting ( return EFI_NOT_FOUND;
}
- //
- // Find the question default value from the variable storage
- //
- VariableHeader = FindVariableData (VariableStorage, &EfiVarStore->Guid, EfiVarStore->Attributes, (CHAR16 *)EfiVarStore->Name);
- if (VariableHeader == NULL) {
- return EFI_NOT_FOUND;
- }
+ VarCheck = (BOOLEAN)(CompareGuid (&VariableStorage->Signature, &gEfiAuthenticatedVariableGuid));
- StartBit = 0;
- EndBit = 0;
- ByteOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
- if (BitFieldQuestion) {
- BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
- ByteOffset = BitOffset / 8;
- BitWidth = Width;
- StartBit = BitOffset % 8;
- EndBit = StartBit + BitWidth - 1;
- Width = EndBit / 8 + 1;
- }
+ if (VarCheck) {
+ //
+ // Find the question default value from the variable storage
+ //
+ AuthVariableHeader = AuthFindVariableData (VariableStorage, &EfiVarStore->Guid, EfiVarStore->Attributes, (CHAR16 *)EfiVarStore->Name);
+ if (AuthVariableHeader == NULL) {
+ return EFI_NOT_FOUND;
+ }
- if (VariableHeader->DataSize < ByteOffset + Width) {
- return EFI_INVALID_PARAMETER;
- }
+ StartBit = 0;
+ EndBit = 0;
+ ByteOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ if (BitFieldQuestion) {
+ BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ ByteOffset = BitOffset / 8;
+ BitWidth = Width;
+ StartBit = BitOffset % 8;
+ EndBit = StartBit + BitWidth - 1;
+ Width = EndBit / 8 + 1;
+ }
- //
- // Copy the question value
- //
- if (ValueBuffer != NULL) {
+ if (AuthVariableHeader->DataSize < ByteOffset + Width) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Copy the question value
+ //
+ if (ValueBuffer != NULL) {
+ if (BitFieldQuestion) {
+ CopyMem (&BufferValue, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + ByteOffset, Width);
+ BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
+ CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32));
+ } else {
+ CopyMem (ValueBuffer, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
+ }
+ }
+ } else {
+ //
+ // Find the question default value from the variable storage
+ //
+ VariableHeader = FindVariableData (VariableStorage, &EfiVarStore->Guid, EfiVarStore->Attributes, (CHAR16 *)EfiVarStore->Name);
+ if (VariableHeader == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ StartBit = 0;
+ EndBit = 0;
+ ByteOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
if (BitFieldQuestion) {
- CopyMem (&BufferValue, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + ByteOffset, Width);
- BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
- CopyMem (ValueBuffer, &BitFieldVal, Width);
- } else {
- CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
+ BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
+ ByteOffset = BitOffset / 8;
+ BitWidth = Width;
+ StartBit = BitOffset % 8;
+ EndBit = StartBit + BitWidth - 1;
+ Width = EndBit / 8 + 1;
+ }
+
+ if (VariableHeader->DataSize < ByteOffset + Width) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Copy the question value
+ //
+ if (ValueBuffer != NULL) {
+ if (BitFieldQuestion) {
+ CopyMem (&BufferValue, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + ByteOffset, Width);
+ BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
+ CopyMem (ValueBuffer, &BitFieldVal, sizeof (UINT32));
+ } else {
+ CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
+ }
}
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf index 0116fb6..5123332 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -86,6 +86,7 @@ gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID
+ gEfiAuthenticatedVariableGuid ## CONSUMES ## GUID
[Depex]
TRUE
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c index ab8f056..ae5eff7 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -242,19 +242,19 @@ Output1bitPixel ( IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo
)
{
- UINT16 Xpos;
- UINT16 Ypos;
- UINTN OffsetY;
- UINT8 Index;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[2];
- EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINTN PaletteSize;
- UINT8 Byte;
+ UINT16 Xpos;
+ UINT16 Ypos;
+ UINTN OffsetY;
+ UINT8 Index;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *BitMapPtr;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue[2];
+ EFI_HII_IMAGE_PALETTE_INFO *Palette;
+ UINTN PaletteSize;
+ UINT8 Byte;
ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL);
- BitMapPtr = Image->Bitmap;
+ BitMapPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)Image->Bitmap;
//
// First entry corresponds to color 0 and second entry corresponds to color 1.
@@ -271,8 +271,8 @@ Output1bitPixel ( CopyMem (Palette, PaletteInfo, PaletteSize);
ZeroMem (PaletteValue, sizeof (PaletteValue));
- CopyRgbToGopPixel (&PaletteValue[0], &Palette->PaletteValue[0], 1);
- CopyRgbToGopPixel (&PaletteValue[1], &Palette->PaletteValue[1], 1);
+ CopyRgbToGopPixel (&PaletteValue[0].Pixel, &Palette->PaletteValue[0], 1);
+ CopyRgbToGopPixel (&PaletteValue[1].Pixel, &Palette->PaletteValue[1], 1);
FreePool (Palette);
//
@@ -287,9 +287,9 @@ Output1bitPixel ( Byte = *(Data + OffsetY + Xpos);
for (Index = 0; Index < 8; Index++) {
if ((Byte & (1 << Index)) != 0) {
- BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)] = PaletteValue[1];
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)].Raw = PaletteValue[1].Raw;
} else {
- BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)] = PaletteValue[0];
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + (8 - Index - 1)].Raw = PaletteValue[0].Raw;
}
}
}
@@ -301,9 +301,9 @@ Output1bitPixel ( Byte = *(Data + OffsetY + Xpos);
for (Index = 0; Index < Image->Width % 8; Index++) {
if ((Byte & (1 << (8 - Index - 1))) != 0) {
- BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index] = PaletteValue[1];
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index].Raw = PaletteValue[1].Raw;
} else {
- BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index] = PaletteValue[0];
+ BitMapPtr[Ypos * Image->Width + Xpos * 8 + Index].Raw = PaletteValue[0].Raw;
}
}
}
@@ -331,19 +331,19 @@ Output4bitPixel ( IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo
)
{
- UINT16 Xpos;
- UINT16 Ypos;
- UINTN OffsetY;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[16];
- EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINTN PaletteSize;
- UINT16 PaletteNum;
- UINT8 Byte;
+ UINT16 Xpos;
+ UINT16 Ypos;
+ UINTN OffsetY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *BitMapPtr;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue[16];
+ EFI_HII_IMAGE_PALETTE_INFO *Palette;
+ UINTN PaletteSize;
+ UINT16 PaletteNum;
+ UINT8 Byte;
ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL);
- BitMapPtr = Image->Bitmap;
+ BitMapPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)Image->Bitmap;
//
// The bitmap should allocate each color index starting from 0.
@@ -361,7 +361,7 @@ Output4bitPixel ( PaletteNum = (UINT16)(Palette->PaletteSize / sizeof (EFI_HII_RGB_PIXEL));
ZeroMem (PaletteValue, sizeof (PaletteValue));
- CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue)));
+ CopyRgbToGopPixel (&PaletteValue->Pixel, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue)));
FreePool (Palette);
//
@@ -373,17 +373,17 @@ Output4bitPixel ( // All bits in these bytes are meaningful
//
for (Xpos = 0; Xpos < Image->Width / 2; Xpos++) {
- Byte = *(Data + OffsetY + Xpos);
- BitMapPtr[Ypos * Image->Width + Xpos * 2] = PaletteValue[Byte >> 4];
- BitMapPtr[Ypos * Image->Width + Xpos * 2 + 1] = PaletteValue[Byte & 0x0F];
+ Byte = *(Data + OffsetY + Xpos);
+ BitMapPtr[Ypos * Image->Width + Xpos * 2].Raw = PaletteValue[Byte >> 4].Raw;
+ BitMapPtr[Ypos * Image->Width + Xpos * 2 + 1].Raw = PaletteValue[Byte & 0x0F].Raw;
}
if (Image->Width % 2 != 0) {
//
// Padding bits in this byte should be ignored.
//
- Byte = *(Data + OffsetY + Xpos);
- BitMapPtr[Ypos * Image->Width + Xpos * 2] = PaletteValue[Byte >> 4];
+ Byte = *(Data + OffsetY + Xpos);
+ BitMapPtr[Ypos * Image->Width + Xpos * 2].Raw = PaletteValue[Byte >> 4].Raw;
}
}
}
@@ -409,19 +409,19 @@ Output8bitPixel ( IN EFI_HII_IMAGE_PALETTE_INFO *PaletteInfo
)
{
- UINT16 Xpos;
- UINT16 Ypos;
- UINTN OffsetY;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BitMapPtr;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL PaletteValue[256];
- EFI_HII_IMAGE_PALETTE_INFO *Palette;
- UINTN PaletteSize;
- UINT16 PaletteNum;
- UINT8 Byte;
+ UINT16 Xpos;
+ UINT16 Ypos;
+ UINTN OffsetY;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *BitMapPtr;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION PaletteValue[256];
+ EFI_HII_IMAGE_PALETTE_INFO *Palette;
+ UINTN PaletteSize;
+ UINT16 PaletteNum;
+ UINT8 Byte;
ASSERT (Image != NULL && Data != NULL && PaletteInfo != NULL);
- BitMapPtr = Image->Bitmap;
+ BitMapPtr = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)Image->Bitmap;
//
// The bitmap should allocate each color index starting from 0.
@@ -438,7 +438,7 @@ Output8bitPixel ( CopyMem (Palette, PaletteInfo, PaletteSize);
PaletteNum = (UINT16)(Palette->PaletteSize / sizeof (EFI_HII_RGB_PIXEL));
ZeroMem (PaletteValue, sizeof (PaletteValue));
- CopyRgbToGopPixel (PaletteValue, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue)));
+ CopyRgbToGopPixel (&PaletteValue->Pixel, Palette->PaletteValue, MIN (PaletteNum, ARRAY_SIZE (PaletteValue)));
FreePool (Palette);
//
@@ -450,8 +450,8 @@ Output8bitPixel ( // All bits are meaningful since the bitmap is 8 bits per pixel.
//
for (Xpos = 0; Xpos < Image->Width; Xpos++) {
- Byte = *(Data + OffsetY + Xpos);
- BitMapPtr[OffsetY + Xpos] = PaletteValue[Byte];
+ Byte = *(Data + OffsetY + Xpos);
+ BitMapPtr[OffsetY + Xpos].Raw = PaletteValue[Byte].Raw;
}
}
}
@@ -521,13 +521,15 @@ ImageToBlt ( IN OUT EFI_IMAGE_OUTPUT **Blt
)
{
- EFI_IMAGE_OUTPUT *ImageOut;
- UINTN Xpos;
- UINTN Ypos;
- UINTN OffsetY1; // src buffer
- UINTN OffsetY2; // dest buffer
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL SrcPixel;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL ZeroPixel;
+ EFI_IMAGE_OUTPUT *ImageOut;
+ UINTN Xpos;
+ UINTN Ypos;
+ UINTN OffsetY1; // src buffer
+ UINTN OffsetY2; // dest buffer
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION SrcPixel;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ZeroPixel;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *BltBufferPixel;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *ImageBitmap;
if ((BltBuffer == NULL) || (Blt == NULL) || (*Blt == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -545,17 +547,20 @@ ImageToBlt ( ZeroMem (&ZeroPixel, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ BltBufferPixel = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)BltBuffer;
+ ImageBitmap = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION *)ImageOut->Image.Bitmap;
+
for (Ypos = 0; Ypos < Height; Ypos++) {
OffsetY1 = Width * Ypos;
OffsetY2 = ImageOut->Width * (BltY + Ypos);
for (Xpos = 0; Xpos < Width; Xpos++) {
- SrcPixel = BltBuffer[OffsetY1 + Xpos];
+ SrcPixel.Raw = BltBufferPixel[OffsetY1 + Xpos].Raw;
if (Transparent) {
if (CompareMem (&SrcPixel, &ZeroPixel, 3) != 0) {
- ImageOut->Image.Bitmap[OffsetY2 + BltX + Xpos] = SrcPixel;
+ ImageBitmap[OffsetY2 + BltX + Xpos].Raw = SrcPixel.Raw;
}
} else {
- ImageOut->Image.Bitmap[OffsetY2 + BltX + Xpos] = SrcPixel;
+ ImageBitmap[OffsetY2 + BltX + Xpos].Raw = SrcPixel.Raw;
}
}
}
@@ -1402,7 +1407,7 @@ HiiDrawImage ( //
if ((Flags & EFI_HII_DIRECT_TO_SCREEN) == EFI_HII_DIRECT_TO_SCREEN) {
//
- // Caller should make sure the current UGA console is grarphic mode.
+ // Caller should make sure the current console is grarphic mode.
//
//
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c index e3fceed..c70f308 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c @@ -1000,7 +1000,7 @@ SetStringWorker ( case EFI_HII_SIBT_STRING_SCSU_FONT:
case EFI_HII_SIBT_STRINGS_SCSU:
case EFI_HII_SIBT_STRINGS_SCSU_FONT:
- BlockSize = OldBlockSize + StrLen (String);
+ BlockSize = OldBlockSize + StrSize (String);
BlockSize -= AsciiStrSize ((CHAR8 *)StringTextPtr);
Block = AllocateZeroPool (BlockSize);
if (Block == NULL) {
diff --git a/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c b/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c index dd0ae50..cbcb7b2 100644 --- a/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c +++ b/MdeModulePkg/Universal/HiiResourcesSampleDxe/HiiResourcesSample.c @@ -57,7 +57,7 @@ HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = { @param[in] ImageHandle Image handle this driver.
@param[in] SystemTable Pointer to SystemTable.
- @retval EFI_SUCESS This function always complete successfully.
+ @retval EFI_SUCCESS This function always complete successfully.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c index 3aa7660..e30a55f 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c @@ -6,9 +6,9 @@ drivers to controllers.
The main flow:
- 1. It dynamicly locate all controller device path.
- 2. It dynamicly locate all drivers which support binding protocol.
- 3. It export and dynamicly update two menu to let user select the
+ 1. It dynamically locate all controller device path.
+ 2. It dynamically locate all drivers which support binding protocol.
+ 3. It export and dynamically update two menu to let user select the
mapping between drivers to controllers.
4. It save all the mapping info in NV variables which will be consumed
by platform override protocol driver to publish the platform override protocol.
@@ -421,6 +421,8 @@ UpdateDeviceSelectPage ( &mDevicePathHandleBuffer
);
if (EFI_ERROR (Status) || (DevicePathHandleCount == 0)) {
+ HiiFreeOpCodeHandle (StartOpCodeHandle);
+ HiiFreeOpCodeHandle (EndOpCodeHandle);
return EFI_SUCCESS;
}
@@ -708,6 +710,8 @@ UpdateBindingDriverSelectPage ( &mDriverImageHandleBuffer
);
if (EFI_ERROR (Status) || (DriverImageHandleCount == 0)) {
+ HiiFreeOpCodeHandle (StartOpCodeHandle);
+ HiiFreeOpCodeHandle (EndOpCodeHandle);
return EFI_NOT_FOUND;
}
diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.uni b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.uni index 9905a28..8f81593 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.uni +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.uni @@ -10,9 +10,9 @@ // drivers to controllers.
//
// The main flow:
-// 1. It dynamicly locate all controller device path.
-// 2. It dynamicly locate all drivers which support binding protocol.
-// 3. It export and dynamicly update two menu to let user select the
+// 1. It dynamically locate all controller device path.
+// 2. It dynamically locate all drivers which support binding protocol.
+// 3. It export and dynamically update two menu to let user select the
// mapping between drivers to controllers.
// 4. It save all the mapping info in NV variables for the following boot,
// which will be consumed by GetDriver API of the produced the platform override protocol.
@@ -32,6 +32,6 @@ "The main flow:<BR>\n"
"1. It dynamically locates all controller device path.<BR>\n"
"2. It dynamically locates all drivers which support binding protocol.<BR>\n"
- "3. It exports and dynamicly updates two menu to let user select the mapping between drivers to controllers.<BR>\n"
+ "3. It exports and dynamically updates two menu to let user select the mapping between drivers to controllers.<BR>\n"
"4. It saves all the mapping info in NV variables for the following boot, which will be consumed by GetDriver API of the produced the platform override protocol.<BR>"
diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatOverMngr.h b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatOverMngr.h index 0e200c0..fbc9c8f 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatOverMngr.h +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatOverMngr.h @@ -1,6 +1,6 @@ /** @file
- The defintions are required both by Source code and Vfr file.
+ The definitions are required both by Source code and Vfr file.
The PLAT_OVER_MNGR_DATA structure, form guid and Ifr question ID are defined.
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf index 97c8e3c..e12d784 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatformDriOverrideDxe.inf @@ -9,9 +9,9 @@ # drivers to controllers.
#
# The main flow:
-# 1. It dynamicly locate all controller device path.
-# 2. It dynamicly locate all drivers which support binding protocol.
-# 3. It export and dynamicly update two menu to let user select the
+# 1. It dynamically locate all controller device path.
+# 2. It dynamically locate all drivers which support binding protocol.
+# 3. It export and dynamically update two menu to let user select the
# mapping between drivers to controllers.
# 4. It save all the mapping info in NV variables for the following boot,
# which will be consumed by GetDriver API of the produced the platform override protocol.
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h index 8931f8e..ee173d5 100644 --- a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h +++ b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h @@ -32,6 +32,7 @@ typedef UINTN size_t;
typedef UINT32 uint32_t;
typedef INTN intptr_t;
+typedef INT64 ptrdiff_t;
#ifndef offsetof
#define offsetof OFFSET_OF
diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma b/MdeModulePkg/Universal/RegularExpressionDxe/oniguruma -Subproject abfc8ff81df4067f309032467785e06975678f0 +Subproject 4ef89209a239c1aea328cf13c05a2807e5c146d diff --git a/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c b/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c index b123983..e1b1021 100644 --- a/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c +++ b/MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.c @@ -275,7 +275,7 @@ ReportDispatcher ( @param FileHandle Handle of the file being invoked.
@param PeiServices Describes the list of possible PEI Services.
- @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully.
+ @retval EFI_SUCCESS The entry point of DXE IPL PEIM executes successfully.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Universal/SectionExtractionPei/SectionExtractionPei.c b/MdeModulePkg/Universal/SectionExtractionPei/SectionExtractionPei.c index 8a11643..5229fd8 100644 --- a/MdeModulePkg/Universal/SectionExtractionPei/SectionExtractionPei.c +++ b/MdeModulePkg/Universal/SectionExtractionPei/SectionExtractionPei.c @@ -251,12 +251,15 @@ SectionExtractionPeiEntry ( if (ExtractHandlerNumber > 0) {
GuidPpi = (EFI_PEI_PPI_DESCRIPTOR *)AllocatePool (ExtractHandlerNumber * sizeof (EFI_PEI_PPI_DESCRIPTOR));
ASSERT (GuidPpi != NULL);
- while (ExtractHandlerNumber-- > 0) {
- GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
- GuidPpi->Ppi = (VOID *)&mCustomGuidedSectionExtractionPpi;
- GuidPpi->Guid = &ExtractHandlerGuidTable[ExtractHandlerNumber];
- Status = PeiServicesInstallPpi (GuidPpi++);
- ASSERT_EFI_ERROR (Status);
+
+ if (GuidPpi != NULL) {
+ while (ExtractHandlerNumber-- > 0) {
+ GuidPpi->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+ GuidPpi->Ppi = (VOID *)&mCustomGuidedSectionExtractionPpi;
+ GuidPpi->Guid = &ExtractHandlerGuidTable[ExtractHandlerNumber];
+ Status = PeiServicesInstallPpi (GuidPpi++);
+ ASSERT_EFI_ERROR (Status);
+ }
}
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index de7e79e..e44a70c 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1004,7 +1004,7 @@ UpdateStatementStatus ( @param Action The user input action request info.
@param DefaultId The user input default Id info.
- @retval EFI_SUCESSS This function always return successfully for now.
+ @retval EFI_SUCCESS This function always return successfully for now.
**/
EFI_STATUS
@@ -1557,7 +1557,7 @@ ProcessQuestionConfig ( @param UserInput The user input data.
- @retval EFI_SUCESSS This function always return successfully for now.
+ @retval EFI_SUCCESS This function always return successfully for now.
**/
EFI_STATUS
@@ -1687,7 +1687,7 @@ ProcessUserInput ( Display form and wait for user to select one menu option, then return it.
- @retval EFI_SUCESSS This function always return successfully for now.
+ @retval EFI_SUCCESS This function always return successfully for now.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c index d61edc8..9c7d390 100644 --- a/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c +++ b/MdeModulePkg/Universal/SmbiosMeasurementDxe/SmbiosMeasurementDxe.c @@ -637,6 +637,10 @@ MeasureSmbiosTable ( if (!EFI_ERROR (Status)) {
gBS->CloseEvent (Event);
}
+
+ if (TableAddress != NULL) {
+ FreePool (TableAddress);
+ }
}
return;
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c index 663cfff..8121e0c 100644 --- a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.c @@ -19,7 +19,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
#include <Library/UefiLib.h>
+#include <Guid/MmCommBuffer.h>
#include <Guid/PiSmmCommunicationRegionTable.h>
#define DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES 4
@@ -44,8 +46,11 @@ SmmCommunicationBufferEntryPoint ( UINT32 DescriptorSize;
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
EFI_MEMORY_DESCRIPTOR *Entry;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ MM_COMM_BUFFER *MmCommBuffer;
DescriptorSize = sizeof (EFI_MEMORY_DESCRIPTOR);
+
//
// Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will
// prevent people from having pointer math bugs in their code.
@@ -58,6 +63,10 @@ SmmCommunicationBufferEntryPoint ( //
PiSmmCommunicationRegionTable = AllocateReservedPool (sizeof (EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize);
ASSERT (PiSmmCommunicationRegionTable != NULL);
+ if (PiSmmCommunicationRegionTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
ZeroMem (PiSmmCommunicationRegionTable, sizeof (EDKII_PI_SMM_COMMUNICATION_REGION_TABLE) + DescriptorSize);
PiSmmCommunicationRegionTable->Version = EDKII_PI_SMM_COMMUNICATION_REGION_TABLE_VERSION;
@@ -65,11 +74,21 @@ SmmCommunicationBufferEntryPoint ( PiSmmCommunicationRegionTable->DescriptorSize = DescriptorSize;
Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
Entry->Type = EfiConventionalMemory;
- Entry->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES);
+
+ GuidHob = GetFirstGuidHob (&gMmCommBufferHobGuid);
+
+ if (GuidHob == NULL) {
+ Entry->PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES);
+ Entry->NumberOfPages = DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES;
+ } else {
+ MmCommBuffer = GET_GUID_HOB_DATA (GuidHob);
+ Entry->PhysicalStart = MmCommBuffer->PhysicalStart;
+ Entry->NumberOfPages = MmCommBuffer->NumberOfPages;
+ }
+
ASSERT (Entry->PhysicalStart != 0);
- Entry->VirtualStart = 0;
- Entry->NumberOfPages = DEFAULT_COMMON_PI_SMM_COMMUNIATION_REGION_PAGES;
- Entry->Attribute = 0;
+ Entry->VirtualStart = 0;
+ Entry->Attribute = 0;
DEBUG ((DEBUG_INFO, "PiSmmCommunicationRegionTable:(0x%x)\n", PiSmmCommunicationRegionTable));
DEBUG ((DEBUG_INFO, " Version - 0x%x\n", PiSmmCommunicationRegionTable->Version));
diff --git a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf index 5c867ba..1c9bbdc 100644 --- a/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf +++ b/MdeModulePkg/Universal/SmmCommunicationBufferDxe/SmmCommunicationBufferDxe.inf @@ -47,6 +47,7 @@ [Guids]
gEdkiiPiSmmCommunicationRegionTableGuid ## PRODUCES ## SystemTable
+ gMmCommBufferHobGuid ## CONSUMES
[Depex]
TRUE
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c b/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c index d740a62..b29b78b 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.c @@ -19,7 +19,7 @@ @param FileHandle Handle of the file being invoked.
@param PeiServices Describes the list of possible PEI Services.
- @retval EFI_SUCESS The entry point of DXE IPL PEIM executes successfully.
+ @retval EFI_SUCCESS The entry point of DXE IPL PEIM executes successfully.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.c b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.c index 6286210..77f7052 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.c @@ -27,7 +27,7 @@ InitializationDispatcherWorker ( // If enable UseSerial, then initialize serial port.
// if enable UseRuntimeMemory, then initialize runtime memory status code worker.
//
- if (PcdGetBool (PcdStatusCodeUseSerial)) {
+ if (IsStatusCodeUsingSerialPort ()) {
//
// Call Serial Port Lib API to initialize serial port.
//
@@ -68,7 +68,7 @@ StatusCodeHandlerCommonEntry ( //
InitializationDispatcherWorker ();
- if (PcdGetBool (PcdStatusCodeUseSerial)) {
+ if (IsStatusCodeUsingSerialPort ()) {
mRscHandlerProtocol->Register (SerialStatusCodeReportWorker);
}
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.h b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.h index e416220..79ff005 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.h +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerMm.h @@ -126,4 +126,18 @@ StatusCodeHandlerCommonEntry ( VOID
);
+/**
+ Check if the status code is using serial port.
+
+ This function determines whether the status code reporting mechanism
+ is configured to use the serial port.
+
+ @retval TRUE Status code is using the serial port.
+ @retval FALSE Status code is not using the serial port.
+**/
+BOOLEAN
+IsStatusCodeUsingSerialPort (
+ VOID
+ );
+
#endif
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandalone.c b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandalone.c index 11a6170..67ff33f 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandalone.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandalone.c @@ -8,6 +8,33 @@ **/
#include "StatusCodeHandlerMm.h"
+#include <Guid/MmStatusCodeUseSerial.h>
+#include <Library/HobLib.h>
+
+/**
+ Check if the status code is using serial port.
+
+ This function determines whether the status code reporting mechanism
+ is configured to use the serial port.
+
+ @retval TRUE Status code is using the serial port.
+ @retval FALSE Status code is not using the serial port.
+**/
+BOOLEAN
+IsStatusCodeUsingSerialPort (
+ VOID
+ )
+{
+ VOID *Hob;
+ MM_STATUS_CODE_USE_SERIAL *StatusCodeUseSerialHob;
+
+ Hob = GetFirstGuidHob (&gMmStatusCodeUseSerialHobGuid);
+ ASSERT (Hob != NULL);
+
+ StatusCodeUseSerialHob = (MM_STATUS_CODE_USE_SERIAL *)GET_GUID_HOB_DATA (Hob);
+
+ return StatusCodeUseSerialHob->StatusCodeUseSerial;
+}
/**
Entry point of Standalone MM Status Code Driver.
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf index d7c863b..618b7f8 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf @@ -35,6 +35,7 @@ [Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ StandaloneMmPkg/StandaloneMmPkg.dec
[LibraryClasses]
SerialPortLib
@@ -46,16 +47,17 @@ DebugLib
MemoryAllocationLib
BaseMemoryLib
+ HobLib
[Guids]
gEfiStatusCodeDataTypeStringGuid ## SOMETIMES_CONSUMES ## UNDEFINED
gMemoryStatusCodeRecordGuid ## SOMETIMES_PRODUCES ## UNDEFINED # MmSystemTable
+ gMmStatusCodeUseSerialHobGuid ## CONSUMES
[Protocols]
gEfiMmRscHandlerProtocolGuid ## CONSUMES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerTraditional.c b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerTraditional.c index da49829..c30c02d 100644 --- a/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerTraditional.c +++ b/MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerTraditional.c @@ -10,6 +10,23 @@ #include "StatusCodeHandlerMm.h"
/**
+ Check if the status code is using serial port.
+
+ This function determines whether the status code reporting mechanism
+ is configured to use the serial port.
+
+ @retval TRUE Status code is using the serial port.
+ @retval FALSE Status code is not using the serial port.
+**/
+BOOLEAN
+IsStatusCodeUsingSerialPort (
+ VOID
+ )
+{
+ return PcdGetBool (PcdStatusCodeUseSerial);
+}
+
+/**
Entry point of Traditional MM Status Code Driver.
This function is the entry point of Traditional MM Status Code Driver.
diff --git a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.c b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.c index 4f937e2..eac1da5 100644 --- a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.c +++ b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.c @@ -66,7 +66,9 @@ PopulateHeaderAndCommunicate ( {
EFI_STATUS Status;
EFI_PEI_MM_COMMUNICATION_PPI *MmCommunicationPpi;
+ EFI_PEI_MM_COMMUNICATION3_PPI *MmCommunicationPpiV3;
EFI_MM_COMMUNICATE_HEADER *MmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *MmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *MmVarCommsHeader;
// Minimal sanity check
@@ -86,30 +88,67 @@ PopulateHeaderAndCommunicate ( goto Exit;
}
- Status = PeiServicesLocatePpi (&gEfiPeiMmCommunicationPpiGuid, 0, NULL, (VOID **)&MmCommunicationPpi);
+ MmCommunicationPpiV3 = NULL;
+ MmCommunicationPpi = NULL;
+
+ Status = PeiServicesLocatePpi (&gEfiPeiMmCommunication3PpiGuid, 0, NULL, (VOID **)&MmCommunicationPpiV3);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Failed to locate PEI MM Communication PPI: %r\n", __func__, Status));
- goto Exit;
+ DEBUG ((DEBUG_WARN, "%a: Unable to locate PEI MM Communication3 PPI: %r\n", __func__, Status));
+ // Try to locate the older version of the PPI
+ Status = PeiServicesLocatePpi (&gEfiPeiMmCommunicationPpiGuid, 0, NULL, (VOID **)&MmCommunicationPpi);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: Failed to locate PEI MM Communication PPI: %r\n", __func__, Status));
+ goto Exit;
+ }
}
- // Zero the entire Communication Buffer Header
- MmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommunicateBuffer;
+ if (MmCommunicationPpiV3 != NULL) {
+ // Zero the entire Communication Buffer Header
+ MmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)CommunicateBuffer;
- ZeroMem (MmCommunicateHeader, SMM_COMMUNICATE_HEADER_SIZE);
+ ZeroMem (MmCommunicateHeaderV3, SMM_COMMUNICATE_HEADER_SIZE_V3);
- // Use gEfiSmmVariableProtocolGuid to request the MM variable service in Standalone MM
- CopyMem ((VOID *)&MmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid, sizeof (GUID));
+ // Use gEfiSmmVariableProtocolGuid to request the MM variable service in Standalone MM
+ CopyMem ((VOID *)&MmCommunicateHeaderV3->HeaderGuid, &gEfiMmCommunicateHeaderV3Guid, sizeof (GUID));
+ MmCommunicateHeaderV3->BufferSize = CommunicateBufferSize;
- // Program the MM header size
- MmCommunicateHeader->MessageLength = CommunicateBufferSize - SMM_COMMUNICATE_HEADER_SIZE;
+ CopyMem ((VOID *)&MmCommunicateHeaderV3->MessageGuid, &gEfiSmmVariableProtocolGuid, sizeof (GUID));
- MmVarCommsHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)(CommunicateBuffer + SMM_COMMUNICATE_HEADER_SIZE);
+ // Program the MM header size
+ MmCommunicateHeaderV3->MessageSize = CommunicateBufferSize - SMM_COMMUNICATE_HEADER_SIZE_V3;
- // We are only supporting GetVariable and GetNextVariableName
- MmVarCommsHeader->Function = Function;
+ MmVarCommsHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)(MmCommunicateHeaderV3->MessageData);
+
+ // We are only supporting GetVariable and GetNextVariableName
+ MmVarCommsHeader->Function = Function;
+
+ // Send the MM request using MmCommunicationPei
+ Status = MmCommunicationPpiV3->Communicate (MmCommunicationPpiV3, CommunicateBuffer);
+ } else if (MmCommunicationPpi != NULL) {
+ // Zero the entire Communication Buffer Header
+ MmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommunicateBuffer;
+
+ ZeroMem (MmCommunicateHeader, SMM_COMMUNICATE_HEADER_SIZE);
+
+ // Use gEfiSmmVariableProtocolGuid to request the MM variable service in Standalone MM
+ CopyMem ((VOID *)&MmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid, sizeof (GUID));
+
+ // Program the MM header size
+ MmCommunicateHeader->MessageLength = CommunicateBufferSize - SMM_COMMUNICATE_HEADER_SIZE;
+
+ MmVarCommsHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)(CommunicateBuffer + SMM_COMMUNICATE_HEADER_SIZE);
+
+ // We are only supporting GetVariable and GetNextVariableName
+ MmVarCommsHeader->Function = Function;
+
+ // Send the MM request using MmCommunicationPei
+ Status = MmCommunicationPpi->Communicate (MmCommunicationPpi, CommunicateBuffer, &CommunicateBufferSize);
+ } else {
+ // We should never reach here, but just in case
+ Status = EFI_UNSUPPORTED;
+ DEBUG ((DEBUG_ERROR, "%a: No MM Communication PPI found!\n", __func__));
+ }
- // Send the MM request using MmCommunicationPei
- Status = MmCommunicationPpi->Communicate (MmCommunicationPpi, CommunicateBuffer, &CommunicateBufferSize);
if (EFI_ERROR (Status)) {
// Received an error from MM interface.
DEBUG ((DEBUG_ERROR, "%a - MM Interface Error: %r\n", __func__, Status));
diff --git a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.h b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.h index 0feed8c..0b38329 100644 --- a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.h +++ b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.h @@ -23,6 +23,7 @@ #include <Ppi/ReadOnlyVariable2.h>
#include <Ppi/MmCommunication.h>
+#include <Ppi/MmCommunication3.h>
#include <Protocol/SmmVariable.h>
#include <Protocol/MmCommunication.h>
diff --git a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.inf b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.inf index 13e8052..1f972db 100644 --- a/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.inf +++ b/MdeModulePkg/Universal/Variable/MmVariablePei/MmVariablePei.inf @@ -34,7 +34,11 @@ [Ppis]
gEfiPeiReadOnlyVariable2PpiGuid ## PRODUCES
- gEfiPeiMmCommunicationPpiGuid ## CONSUMES
+ gEfiPeiMmCommunication3PpiGuid ## CONSUMES
+ gEfiPeiMmCommunicationPpiGuid ## SOMETIMES_CONSUMES
+
+[Guids]
+ gEfiMmCommunicateHeaderV3Guid
[Depex]
- gEfiPeiMmCommunicationPpiGuid
+ gEfiPeiMmCommunicationPpiGuid OR gEfiPeiMmCommunication3PpiGuid
diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c index 26f95c6..9f3d434 100644 --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c @@ -1336,6 +1336,7 @@ CalculateHobVariableCacheSize ( VARIABLE_STORE_HEADER *VariableStoreHeader;
VariableStoreHeader = NULL;
+ ZeroMem (&StoreInfo, sizeof (VARIABLE_STORE_INFO));
GetHobVariableStore (&StoreInfo, &VariableStoreHeader);
if (VariableStoreHeader == NULL) {
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h index e7bd4c9..969a4f7 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h @@ -156,17 +156,13 @@ VariableSmmIsNonPrimaryBufferValid ( );
/**
- Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
- This information is used by the MorLock code to infer whether an existing
- MOR variable is legitimate or not.
-
- @retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
- protocol database
- @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
- protocol database
+ Whether the MOR variable is legitimate or not.
+
+ @retval TRUE MOR Variable is legitimate.
+ @retval FALSE MOR Variable in not legitimate.
**/
BOOLEAN
-VariableHaveTcgProtocols (
+VariableIsMorVariableLegitimate (
VOID
);
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c index 28e8cc5..7f8b2a7 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c @@ -475,7 +475,7 @@ MorLockInitAtEndOfDxe ( // can be deduced from the absence of the TCG / TCG2 protocols, as edk2's
// MOR implementation depends on (one of) those protocols.
//
- if (VariableHaveTcgProtocols ()) {
+ if (VariableIsMorVariableLegitimate ()) {
//
// The MOR variable originates from the platform firmware; set the MOR
// Control Lock variable to report the locking capability to the OS.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c index 0dd72dd..984cae1 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariablePolicySmmDxe.c @@ -805,7 +805,6 @@ VariablePolicyVirtualAddressCallback ( The driver's entry point.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point executed successfully.
@retval other Some error occured when executing this entry point.
@@ -814,8 +813,7 @@ VariablePolicyVirtualAddressCallback ( EFI_STATUS
EFIAPI
VariablePolicySmmDxeMain (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle
)
{
EFI_STATUS Status;
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf index f90ec70..b5e8bf6 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf @@ -84,7 +84,7 @@ gEfiVariableWriteArchProtocolGuid ## PRODUCES
gEfiVariableArchProtocolGuid ## PRODUCES
gEdkiiVariableLockProtocolGuid ## PRODUCES
- gEdkiiVariablePolicyProtocolGuid ## CONSUMES
+ gEdkiiVariablePolicyProtocolGuid ## PRODUCES
gEdkiiVarCheckProtocolGuid ## PRODUCES
[Guids]
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 5a03061..47f14c5 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include <Protocol/VariableWrite.h>
#include <Protocol/Variable.h>
#include <Protocol/MmCommunication2.h>
+#include <Protocol/MmCommunication3.h>
#include <Protocol/SmmVariable.h>
#include <Protocol/VariableLock.h>
#include <Protocol/VarCheck.h>
@@ -48,6 +49,7 @@ EFI_HANDLE mHandle = NULL; EFI_SMM_VARIABLE_PROTOCOL *mSmmVariable = NULL;
EFI_EVENT mVirtualAddressChangeEvent = NULL;
EFI_MM_COMMUNICATION2_PROTOCOL *mMmCommunication2 = NULL;
+EFI_MM_COMMUNICATION3_PROTOCOL *mMmCommunication3 = NULL;
UINT8 *mVariableBuffer = NULL;
UINT8 *mVariableBufferPhysical = NULL;
VARIABLE_INFO_ENTRY *mVariableInfo = NULL;
@@ -67,8 +69,7 @@ BOOLEAN mIsRuntimeCacheEnabled = FALSE; EFI_STATUS
EFIAPI
VariablePolicySmmDxeMain (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle
);
/**
@@ -164,17 +165,33 @@ InitCommunicateBuffer ( )
{
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *SmmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
- if (DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE > mVariableBufferSize) {
- return EFI_INVALID_PARAMETER;
- }
+ ZeroMem (mVariableBuffer, mVariableBufferSize);
+ if (mMmCommunication3 != NULL) {
+ if (DataSize + SMM_COMMUNICATE_HEADER_SIZE_V3 + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE > mVariableBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
- SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mVariableBuffer;
- CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
- SmmCommunicateHeader->MessageLength = DataSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ SmmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)mVariableBuffer;
+ CopyGuid (&SmmCommunicateHeaderV3->HeaderGuid, &gEfiMmCommunicateHeaderV3Guid);
+ SmmCommunicateHeaderV3->BufferSize = mVariableBufferSize;
+ CopyGuid (&SmmCommunicateHeaderV3->MessageGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeaderV3->MessageSize = DataSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeaderV3->MessageData;
+ } else {
+ // Use v1 communication header, if v3 protocol is not available.
+ if (DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE > mVariableBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mVariableBuffer;
+ CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeader->MessageLength = DataSize + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
+ }
- SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
SmmVariableFunctionHeader->Function = Function;
if (DataPtr != NULL) {
*DataPtr = SmmVariableFunctionHeader->Data;
@@ -188,7 +205,7 @@ InitCommunicateBuffer ( @param[in] DataSize This size of the function header and the data.
- @retval EFI_SUCCESS Success is returned from the functin in SMM.
+ @retval EFI_SUCCESS Success is returned from the function in SMM.
@retval Others Failure is returned from the function in SMM.
**/
@@ -200,20 +217,38 @@ SendCommunicateBuffer ( EFI_STATUS Status;
UINTN CommSize;
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *SmmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
- CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
- Status = mMmCommunication2->Communicate (
- mMmCommunication2,
+ if (mMmCommunication3 != NULL) {
+ Status = mMmCommunication3->Communicate (
+ mMmCommunication3,
mVariableBufferPhysical,
- mVariableBuffer,
- &CommSize
+ mVariableBuffer
);
- ASSERT_EFI_ERROR (Status);
+ ASSERT_EFI_ERROR (Status);
+
+ SmmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)mVariableBuffer;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeaderV3->MessageData;
+
+ Status = SmmVariableFunctionHeader->ReturnStatus;
+ } else {
+ CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
+ Status = mMmCommunication2->Communicate (
+ mMmCommunication2,
+ mVariableBufferPhysical,
+ mVariableBuffer,
+ &CommSize
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mVariableBuffer;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
- SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mVariableBuffer;
- SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
- return SmmVariableFunctionHeader->ReturnStatus;
+ Status = SmmVariableFunctionHeader->ReturnStatus;
+ }
+
+ return Status;
}
/**
@@ -1343,7 +1378,12 @@ VariableAddressChangeEvent ( )
{
EfiConvertPointer (0x0, (VOID **)&mVariableBuffer);
- EfiConvertPointer (0x0, (VOID **)&mMmCommunication2);
+ if (mMmCommunication3 != NULL) {
+ EfiConvertPointer (0x0, (VOID **)&mMmCommunication3);
+ } else {
+ EfiConvertPointer (0x0, (VOID **)&mMmCommunication2);
+ }
+
EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mVariableRtCacheInfo.CacheInfoFlagBuffer);
EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mVariableRtCacheInfo.RuntimeHobCacheBuffer);
EfiConvertPointer (EFI_OPTIONAL_PTR, (VOID **)&mVariableRtCacheInfo.RuntimeNvCacheBuffer);
@@ -1368,6 +1408,7 @@ GetVariablePayloadSize ( EFI_STATUS Status;
SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *SmmGetPayloadSize;
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *SmmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
UINTN CommSize;
UINT8 *CommBuffer;
@@ -1385,26 +1426,52 @@ GetVariablePayloadSize ( // Init the communicate buffer. The buffer data size is:
// SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
//
- CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
- CommBuffer = AllocateZeroPool (CommSize);
- if (CommBuffer == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
- SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
- CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
- SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
+ if (mMmCommunication3 != NULL) {
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE_V3 + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
+ CommBuffer = AllocateZeroPool (CommSize);
+ if (CommBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
- SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
- SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE;
- SmmGetPayloadSize = (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *)SmmVariableFunctionHeader->Data;
+ SmmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeaderV3->HeaderGuid, &gEfiMmCommunicateHeaderV3Guid);
+ SmmCommunicateHeaderV3->BufferSize = CommSize;
+ CopyGuid (&SmmCommunicateHeaderV3->MessageGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeaderV3->MessageSize = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeaderV3->MessageData;
- //
- // Send data to SMM.
- //
- Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
- ASSERT_EFI_ERROR (Status);
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE;
+ SmmGetPayloadSize = (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *)SmmVariableFunctionHeader->Data;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication3->Communicate (mMmCommunication3, CommBuffer, CommBuffer);
+ ASSERT_EFI_ERROR (Status);
+ } else {
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
+ CommBuffer = AllocateZeroPool (CommSize);
+ if (CommBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE);
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
+
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_PAYLOAD_SIZE;
+ SmmGetPayloadSize = (SMM_VARIABLE_COMMUNICATE_GET_PAYLOAD_SIZE *)SmmVariableFunctionHeader->Data;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR (Status);
+ }
Status = SmmVariableFunctionHeader->ReturnStatus;
if (EFI_ERROR (Status)) {
@@ -1450,6 +1517,7 @@ GetRuntimeCacheInfo ( EFI_STATUS Status;
SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *SmmGetRuntimeCacheInfo;
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *SmmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
UINTN CommSize;
UINT8 *CommBuffer;
@@ -1467,22 +1535,44 @@ GetRuntimeCacheInfo ( AcquireLockOnlyAtBootTime (&mVariableServicesLock);
- CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
- ZeroMem (CommBuffer, CommSize);
+ if (mMmCommunication3 != NULL) {
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE_V3 + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
+ ZeroMem (CommBuffer, CommSize);
- SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
- CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
- SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
+ SmmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeaderV3->HeaderGuid, &gEfiMmCommunicateHeaderV3Guid);
+ SmmCommunicateHeaderV3->BufferSize = mVariableBufferSize;
+ CopyGuid (&SmmCommunicateHeaderV3->MessageGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeaderV3->MessageSize = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
- SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
- SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO;
- SmmGetRuntimeCacheInfo = (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *)SmmVariableFunctionHeader->Data;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeaderV3->MessageData;
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO;
+ SmmGetRuntimeCacheInfo = (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *)SmmVariableFunctionHeader->Data;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication3->Communicate (mMmCommunication3, CommBuffer, CommBuffer);
+ ASSERT_EFI_ERROR (Status);
+ } else {
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
+ ZeroMem (CommBuffer, CommSize);
+
+ SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO);
+
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_RUNTIME_CACHE_INFO;
+ SmmGetRuntimeCacheInfo = (SMM_VARIABLE_COMMUNICATE_GET_RUNTIME_CACHE_INFO *)SmmVariableFunctionHeader->Data;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR (Status);
+ }
- //
- // Send data to SMM.
- //
- Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
- ASSERT_EFI_ERROR (Status);
if (CommSize <= SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
Status = EFI_BAD_BUFFER_SIZE;
goto Done;
@@ -1600,6 +1690,7 @@ SendRuntimeVariableCacheContextToSmm ( EFI_STATUS Status;
SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT *SmmRuntimeVarCacheContext;
EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER_V3 *SmmCommunicateHeaderV3;
SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
UINTN CommSize;
UINT8 *CommBuffer;
@@ -1613,33 +1704,66 @@ SendRuntimeVariableCacheContextToSmm ( AcquireLockOnlyAtBootTime (&mVariableServicesLock);
- //
- // Init the communicate buffer. The buffer data size is:
- // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
- //
- CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
- ZeroMem (CommBuffer, CommSize);
+ if (mMmCommunication3 != NULL) {
+ //
+ // Init the communicate buffer. The buffer data size is:
+ // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+ //
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE_V3 + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+ ZeroMem (CommBuffer, CommSize);
+
+ SmmCommunicateHeaderV3 = (EFI_MM_COMMUNICATE_HEADER_V3 *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeaderV3->HeaderGuid, &gEfiMmCommunicateHeaderV3Guid);
+ SmmCommunicateHeaderV3->BufferSize = mVariableBufferSize;
+ CopyGuid (&SmmCommunicateHeaderV3->MessageGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeaderV3->MessageSize = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeaderV3->MessageData;
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT;
+ SmmRuntimeVarCacheContext = (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT *)SmmVariableFunctionHeader->Data;
+
+ SmmRuntimeVarCacheContext->RuntimeHobCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeHobCacheBuffer;
+ SmmRuntimeVarCacheContext->RuntimeVolatileCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeVolatileCacheBuffer;
+ SmmRuntimeVarCacheContext->RuntimeNvCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeNvCacheBuffer;
+ SmmRuntimeVarCacheContext->PendingUpdate = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->PendingUpdate;
+ SmmRuntimeVarCacheContext->ReadLock = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->ReadLock;
+ SmmRuntimeVarCacheContext->HobFlushComplete = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->HobFlushComplete;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication3->Communicate (mMmCommunication3, CommBuffer, CommBuffer);
+ ASSERT_EFI_ERROR (Status);
+ } else {
+ //
+ // Init the communicate buffer. The buffer data size is:
+ // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+ //
+ CommSize = SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+ ZeroMem (CommBuffer, CommSize);
- SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
- CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
- SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
+ SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)CommBuffer;
+ CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmVariableProtocolGuid);
+ SmmCommunicateHeader->MessageLength = SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + sizeof (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT);
- SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
- SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT;
- SmmRuntimeVarCacheContext = (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT *)SmmVariableFunctionHeader->Data;
+ SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *)SmmCommunicateHeader->Data;
+ SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_INIT_RUNTIME_VARIABLE_CACHE_CONTEXT;
+ SmmRuntimeVarCacheContext = (SMM_VARIABLE_COMMUNICATE_RUNTIME_VARIABLE_CACHE_CONTEXT *)SmmVariableFunctionHeader->Data;
- SmmRuntimeVarCacheContext->RuntimeHobCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeHobCacheBuffer;
- SmmRuntimeVarCacheContext->RuntimeVolatileCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeVolatileCacheBuffer;
- SmmRuntimeVarCacheContext->RuntimeNvCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeNvCacheBuffer;
- SmmRuntimeVarCacheContext->PendingUpdate = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->PendingUpdate;
- SmmRuntimeVarCacheContext->ReadLock = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->ReadLock;
- SmmRuntimeVarCacheContext->HobFlushComplete = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->HobFlushComplete;
+ SmmRuntimeVarCacheContext->RuntimeHobCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeHobCacheBuffer;
+ SmmRuntimeVarCacheContext->RuntimeVolatileCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeVolatileCacheBuffer;
+ SmmRuntimeVarCacheContext->RuntimeNvCache = (VARIABLE_STORE_HEADER *)(UINTN)mVariableRtCacheInfo.RuntimeNvCacheBuffer;
+ SmmRuntimeVarCacheContext->PendingUpdate = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->PendingUpdate;
+ SmmRuntimeVarCacheContext->ReadLock = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->ReadLock;
+ SmmRuntimeVarCacheContext->HobFlushComplete = &((CACHE_INFO_FLAG *)(UINTN)mVariableRtCacheInfo.CacheInfoFlagBuffer)->HobFlushComplete;
+
+ //
+ // Send data to SMM.
+ //
+ Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
+ ASSERT_EFI_ERROR (Status);
+ }
- //
- // Send data to SMM.
- //
- Status = mMmCommunication2->Communicate (mMmCommunication2, CommBuffer, CommBuffer, &CommSize);
- ASSERT_EFI_ERROR (Status);
if (CommSize <= SMM_VARIABLE_COMMUNICATE_HEADER_SIZE) {
Status = EFI_BAD_BUFFER_SIZE;
goto Done;
@@ -1670,6 +1794,7 @@ SmmVariableReady ( )
{
EFI_STATUS Status;
+ EFI_HANDLE VariablePolicyHandle;
EFI_HOB_GUID_TYPE *GuidHob;
Status = gBS->LocateProtocol (&gEfiSmmVariableProtocolGuid, NULL, (VOID **)&mSmmVariable);
@@ -1677,7 +1802,12 @@ SmmVariableReady ( return;
}
- Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **)&mMmCommunication2);
+ Status = gBS->LocateProtocol (&gEfiMmCommunication3ProtocolGuid, NULL, (VOID **)&mMmCommunication3);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_WARN, "Unable to locate MM communication v3 (%r). Falling back to v2\n", Status));
+ Status = gBS->LocateProtocol (&gEfiMmCommunication2ProtocolGuid, NULL, (VOID **)&mMmCommunication2);
+ }
+
ASSERT_EFI_ERROR (Status);
//
@@ -1721,6 +1851,16 @@ SmmVariableReady ( gRT->SetVariable = RuntimeServiceSetVariable;
gRT->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
+ VariablePolicyHandle = (Context != NULL) ? Context : mHandle;
+ if (Context == NULL) {
+ DEBUG ((DEBUG_WARN, "Variable policy protocol was not installed on the variable image handle.\n"));
+ }
+
+ //
+ // Initialize the Variable Policy protocol and engine.
+ //
+ VariablePolicySmmDxeMain (VariablePolicyHandle);
+
//
// Install the Variable Architectural Protocol on a new handle.
//
@@ -1831,7 +1971,7 @@ VariableSmmRuntimeInitialize ( &gEfiSmmVariableProtocolGuid,
TPL_CALLBACK,
SmmVariableReady,
- NULL,
+ ImageHandle,
&SmmVariableRegistration
);
@@ -1891,8 +2031,5 @@ VariableSmmRuntimeInitialize ( &mVirtualAddressChangeEvent
);
- // Initialize the VariablePolicy protocol and engine.
- VariablePolicySmmDxeMain (ImageHandle, SystemTable);
-
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf index d984a36..af8a32a 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf @@ -66,6 +66,7 @@ gEfiVariableWriteArchProtocolGuid ## PRODUCES
gEfiVariableArchProtocolGuid ## PRODUCES
gEfiMmCommunication2ProtocolGuid ## CONSUMES
+ gEfiMmCommunication3ProtocolGuid ## CONSUMES
## CONSUMES
## NOTIFY
## UNDEFINED # Used to do smm communication
@@ -113,9 +114,10 @@ gEfiEndOfDxeEventGroupGuid
gEfiDeviceSignatureDatabaseGuid
gEdkiiVariableRuntimeCacheInfoHobGuid
+ gEfiMmCommunicateHeaderV3Guid
[Depex]
- gEfiMmCommunication2ProtocolGuid
+ gEfiMmCommunication2ProtocolGuid OR gEfiMmCommunication3ProtocolGuid
[UserExtensions.TianoCore."ExtraFiles"]
VariableSmmRuntimeDxeExtra.uni
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c index 1b9cf6d..1057822 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c @@ -7,6 +7,8 @@ Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR> SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
+#include <Library/MmServicesTableLib.h>
#include <Library/StandaloneMmMemLib.h>
#include "Variable.h"
@@ -67,6 +69,17 @@ VariableNotifySmmWriteReady ( VOID
)
{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ Status = gMmst->MmInstallProtocolInterface (
+ &Handle,
+ &gSmmVariableWriteGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
}
/**
@@ -89,19 +102,15 @@ VariableServiceInitialize ( }
/**
- Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
- This information is used by the MorLock code to infer whether an existing
- MOR variable is legitimate or not.
-
- @retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
- protocol database
- @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
- protocol database
+ Whether the MOR variable is legitimate or not.
+
+ @retval TRUE MOR Variable is legitimate.
+ @retval FALSE MOR Variable in not legitimate.
**/
BOOLEAN
-VariableHaveTcgProtocols (
+VariableIsMorVariableLegitimate (
VOID
)
{
- return FALSE;
+ return TRUE;
}
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf index c418571..2d651c3 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf @@ -115,6 +115,7 @@ gEfiMemoryOverwriteControlDataGuid ## SOMETIMES_CONSUMES ## Variable:L"MemoryOverwriteRequestControl"
gEfiMemoryOverwriteRequestControlLockGuid ## SOMETIMES_PRODUCES ## Variable:L"MemoryOverwriteRequestControlLock"
+ gSmmVariableWriteGuid ## PRODUCES ## GUID # Install protocol
gEfiSystemNvDataFvGuid ## CONSUMES ## GUID
gEdkiiFaultTolerantWriteGuid ## SOMETIMES_CONSUMES ## HOB
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c index 7247f75..cd82bb5 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c @@ -118,12 +118,12 @@ VariableServiceInitialize ( MOR variable is legitimate or not.
@retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI
- protocol database
+ protocol database. MOR variable is legitimate.
@retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
- protocol database
+ protocol database. MOR variable is not legitimate.
**/
BOOLEAN
-VariableHaveTcgProtocols (
+VariableIsMorVariableLegitimate (
VOID
)
{
|