actually 'git add' patches

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2022-12-12 10:16:57 +01:00
parent f5ce58ba6d
commit d6c30b34bd
2 changed files with 440 additions and 0 deletions

View File

@ -0,0 +1,211 @@
From e151560ee60af405429ca7dd7d0a914aa20213a3 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 12 Dec 2022 10:05:27 +0100
Subject: [PATCH 18/20] Revert "OvmfPkg/PlatformDxe: Handle all requests in
ExtractConfig and RouteConfig"
This reverts commit aefcc91805fd69e4aad4bc08a9f708db11cae5f0.
---
OvmfPkg/PlatformDxe/PlatformConfig.h | 2 -
OvmfPkg/PlatformDxe/Platform.c | 115 +--------------------------
OvmfPkg/PlatformDxe/PlatformConfig.c | 2 +-
3 files changed, 3 insertions(+), 116 deletions(-)
diff --git a/OvmfPkg/PlatformDxe/PlatformConfig.h b/OvmfPkg/PlatformDxe/PlatformConfig.h
index 5d9b457b1b4b..902c9b2ce043 100644
--- a/OvmfPkg/PlatformDxe/PlatformConfig.h
+++ b/OvmfPkg/PlatformDxe/PlatformConfig.h
@@ -50,6 +50,4 @@ PlatformConfigLoad (
#define PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION BIT0
#define PLATFORM_CONFIG_F_DOWNGRADE BIT63
-extern CHAR16 mVariableName[];
-
#endif // _PLATFORM_CONFIG_H_
diff --git a/OvmfPkg/PlatformDxe/Platform.c b/OvmfPkg/PlatformDxe/Platform.c
index ac31fafbdce3..4d432f18df37 100644
--- a/OvmfPkg/PlatformDxe/Platform.c
+++ b/OvmfPkg/PlatformDxe/Platform.c
@@ -108,11 +108,6 @@ STATIC EFI_EVENT mGopEvent;
//
STATIC VOID *mGopTracker;
-//
-// The driver image handle, used to obtain the device path for <ConfigHdr>.
-//
-STATIC EFI_HANDLE mImageHandle;
-
//
// Cache the resolutions we get from the GOP.
//
@@ -234,10 +229,6 @@ ExtractConfig (
{
MAIN_FORM_STATE MainFormState;
EFI_STATUS Status;
- EFI_STRING ConfigRequestHdr;
- EFI_STRING ConfigRequest;
- UINTN Size;
- BOOLEAN AllocatedRequest;
DEBUG ((DEBUG_VERBOSE, "%a: Request=\"%s\"\n", __FUNCTION__, Request));
@@ -245,73 +236,18 @@ ExtractConfig (
return EFI_INVALID_PARAMETER;
}
- ConfigRequestHdr = NULL;
- ConfigRequest = NULL;
- Size = 0;
- AllocatedRequest = FALSE;
-
- //
- // Check if <ConfigHdr> matches the GUID and name
- //
- *Progress = Request;
- if ((Request != NULL) &&
- !HiiIsConfigHdrMatch (
- Request,
- &gOvmfPlatformConfigGuid,
- mVariableName
- )
- )
- {
- return EFI_NOT_FOUND;
- }
-
Status = PlatformConfigToFormState (&MainFormState);
if (EFI_ERROR (Status)) {
+ *Progress = Request;
return Status;
}
- if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {
- //
- // Request has no <RequestElement>, so construct full request string.
- // Allocate and fill a buffer large enough to hold <ConfigHdr>
- // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a
- // null terminator.
- //
- ConfigRequestHdr = HiiConstructConfigHdr (
- &gOvmfPlatformConfigGuid,
- mVariableName,
- mImageHandle
- );
- if (ConfigRequestHdr == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
- ConfigRequest = AllocateZeroPool (Size);
- AllocatedRequest = TRUE;
- if (ConfigRequest == NULL) {
- FreePool (ConfigRequestHdr);
- return EFI_OUT_OF_RESOURCES;
- }
-
- UnicodeSPrint (
- ConfigRequest,
- Size,
- L"%s&OFFSET=0&WIDTH=%016LX",
- ConfigRequestHdr,
- sizeof MainFormState
- );
- FreePool (ConfigRequestHdr);
- } else {
- ConfigRequest = Request;
- }
-
//
// Answer the textual request keying off the binary form state.
//
Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
- ConfigRequest,
+ Request,
(VOID *)&MainFormState,
sizeof MainFormState,
Results,
@@ -329,33 +265,6 @@ ExtractConfig (
DEBUG ((DEBUG_VERBOSE, "%a: Results=\"%s\"\n", __FUNCTION__, *Results));
}
- //
- // If we used a newly allocated ConfigRequest, update Progress to point to
- // original Request instead of ConfigRequest.
- //
- if (Request == NULL) {
- *Progress = NULL;
- } else if (StrStr (Request, L"OFFSET") == NULL) {
- if (EFI_ERROR (Status)) {
- //
- // Since we constructed ConfigRequest, failure can only occur if there
- // is not enough memory. In this case, we point Progress to the first
- // character of Request.
- //
- *Progress = Request;
- } else {
- //
- // In case of success, we point Progress to the null terminator of
- // Request.
- //
- *Progress = Request + StrLen (Request);
- }
- }
-
- if (AllocatedRequest) {
- FreePool (ConfigRequest);
- }
-
return Status;
}
@@ -439,21 +348,6 @@ RouteConfig (
return EFI_INVALID_PARAMETER;
}
- //
- // Check if <ConfigHdr> matches the GUID and name
- //
- *Progress = Configuration;
- if ((Configuration != NULL) &&
- !HiiIsConfigHdrMatch (
- Configuration,
- &gOvmfPlatformConfigGuid,
- mVariableName
- )
- )
- {
- return EFI_NOT_FOUND;
- }
-
//
// the "read" step in RMW
//
@@ -972,11 +866,6 @@ PlatformInit (
return Status;
}
- //
- // Save the driver image handle.
- //
- mImageHandle = ImageHandle;
-
//
// Publish the HII package list to HII Database.
//
diff --git a/OvmfPkg/PlatformDxe/PlatformConfig.c b/OvmfPkg/PlatformDxe/PlatformConfig.c
index f5ac2d0609ff..e202ac5b4798 100644
--- a/OvmfPkg/PlatformDxe/PlatformConfig.c
+++ b/OvmfPkg/PlatformDxe/PlatformConfig.c
@@ -21,7 +21,7 @@
//
// Name of the UEFI variable that we use for persistent storage.
//
-CHAR16 mVariableName[] = L"PlatformConfig";
+STATIC CHAR16 mVariableName[] = L"PlatformConfig";
/**
Serialize and persistently save platform configuration.
--
2.38.1

View File

@ -0,0 +1,229 @@
From 29842668ef9c1b3d553279954c18743acdb3036c Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Mon, 28 Nov 2022 13:40:20 +0800
Subject: [PATCH 19/20] OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*
Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
which is mostly useless read the PCDs (PcdFirmwareVendor,
PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
build the string table dynamuically at runtime.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 4cb94f20b002c99dd2b4b75f07c5495b81a34ffd)
---
.../SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 6 +
.../XenSmbiosPlatformDxe.inf | 9 +-
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 115 +++++++++++-------
3 files changed, 85 insertions(+), 45 deletions(-)
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 0066bbc9229c..52689c96e5af 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -32,9 +32,12 @@ [Sources]
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
DebugLib
MemoryAllocationLib
PcdLib
@@ -45,6 +48,9 @@ [LibraryClasses]
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
index 7f4588e33d1e..e646c88741b6 100644
--- a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
@@ -38,19 +38,26 @@ [Sources.ARM, Sources.AARCH64]
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
[Packages.IA32, Packages.X64]
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
DebugLib
UefiBootServicesTableLib
UefiDriverEntryPoint
[LibraryClasses.IA32, LibraryClasses.X64]
- BaseLib
HobLib
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
+
[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 94249d3ff1b0..dc1e6aed634f 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -9,57 +9,43 @@
**/
#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_TYPE0
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h> // gBS
#include <Protocol/Smbios.h> // EFI_SMBIOS_PROTOCOL
#include "SmbiosPlatformDxe.h"
-#define TYPE0_STRINGS \
- "EFI Development Kit II / OVMF\0" /* Vendor */ \
- "0.0.0\0" /* BiosVersion */ \
- "02/06/2015\0" /* BiosReleaseDate */
-//
-// Type definition and contents of the default Type 0 SMBIOS table.
-//
-#pragma pack(1)
-typedef struct {
- SMBIOS_TABLE_TYPE0 Base;
- UINT8 Strings[sizeof (TYPE0_STRINGS)];
-} OVMF_TYPE0;
-#pragma pack()
-
-STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
+STATIC CONST SMBIOS_TABLE_TYPE0 mOvmfDefaultType0 = {
+ // SMBIOS_STRUCTURE Hdr
{
- // SMBIOS_STRUCTURE Hdr
- {
- EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
- sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length
- },
- 1, // SMBIOS_TABLE_STRING Vendor
- 2, // SMBIOS_TABLE_STRING BiosVersion
- 0xE800, // UINT16 BiosSegment
- 3, // SMBIOS_TABLE_STRING BiosReleaseDate
- 0, // UINT8 BiosSize
- { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
- 0, // Reserved :2
- 0, // Unknown :1
- 1, // BiosCharacteristicsNotSupported :1
- // Remaining BiosCharacteristics bits left unset :60
- },
- { // BIOSCharacteristicsExtensionBytes[2]
- 0, // BiosReserved
- 0x1C // SystemReserved = VirtualMachineSupported |
- // UefiSpecificationSupported |
- // TargetContentDistributionEnabled
- },
- 0, // UINT8 SystemBiosMajorRelease
- 0, // UINT8 SystemBiosMinorRelease
- 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
- 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
+ EFI_SMBIOS_TYPE_BIOS_INFORMATION, // UINT8 Type
+ sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length
},
- // Text strings (unformatted area)
- TYPE0_STRINGS
+ 1, // SMBIOS_TABLE_STRING Vendor
+ 2, // SMBIOS_TABLE_STRING BiosVersion
+ 0xE800, // UINT16 BiosSegment
+ 3, // SMBIOS_TABLE_STRING BiosReleaseDate
+ 0, // UINT8 BiosSize
+ { // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
+ 0, // Reserved :2
+ 0, // Unknown :1
+ 1, // BiosCharacteristicsNotSupported :1
+ // Remaining BiosCharacteristics bits left unset :60
+ },
+ { // BIOSCharacteristicsExtensionBytes[2]
+ 0, // BiosReserved
+ 0x1C // SystemReserved = VirtualMachineSupported |
+ // UefiSpecificationSupported |
+ // TargetContentDistributionEnabled
+ },
+ 0, // UINT8 SystemBiosMajorRelease
+ 0, // UINT8 SystemBiosMinorRelease
+ 0xFF, // UINT8 EmbeddedControllerFirmwareMajorRelease
+ 0xFF // UINT8 EmbeddedControllerFirmwareMinorRelease
};
/**
@@ -153,14 +139,55 @@ InstallAllStructures (
//
// Add OVMF default Type 0 (BIOS Information) table
//
+ CHAR16 *VendStr, *VersStr, *DateStr;
+ UINTN VendLen, VersLen, DateLen;
+ CHAR8 *Type0;
+
+ VendStr = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVendor);
+ VendLen = StrLen (VendStr);
+ if (VendLen < 3) {
+ VendStr = L"unknown";
+ VendLen = StrLen (VendStr);
+ }
+
+ VersStr = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
+ VersLen = StrLen (VersStr);
+ if (VersLen < 3) {
+ VersStr = L"unknown";
+ VersLen = StrLen (VersStr);
+ }
+
+ DateStr = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareReleaseDateString);
+ DateLen = StrLen (DateStr);
+ if (DateLen < 3) {
+ DateStr = L"unknown";
+ DateLen = StrLen (DateStr);
+ }
+
+ DEBUG ((DEBUG_INFO, "FirmwareVendor: \"%s\" (%d chars)\n", VendStr, VendLen));
+ DEBUG ((DEBUG_INFO, "FirmwareVersionString: \"%s\" (%d chars)\n", VersStr, VersLen));
+ DEBUG ((DEBUG_INFO, "FirmwareReleaseDateString: \"%s\" (%d chars)\n", DateStr, DateLen));
+
+ Type0 = AllocateZeroPool (sizeof (mOvmfDefaultType0) + VendLen + VersLen + DateLen + 4);
+ if (Type0 == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (Type0, &mOvmfDefaultType0, sizeof (mOvmfDefaultType0));
+ UnicodeStrToAsciiStrS (VendStr, Type0 + sizeof (mOvmfDefaultType0), VendLen + 1);
+ UnicodeStrToAsciiStrS (VersStr, Type0 + sizeof (mOvmfDefaultType0) + VendLen + 1, VersLen + 1);
+ UnicodeStrToAsciiStrS (DateStr, Type0 + sizeof (mOvmfDefaultType0) + VendLen + VersLen + 2, DateLen + 1);
+
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *)&mOvmfDefaultType0
+ (EFI_SMBIOS_TABLE_HEADER *)Type0
);
ASSERT_EFI_ERROR (Status);
+
+ FreePool (Type0);
}
return EFI_SUCCESS;
--
2.38.1