From ba4eda9ae517a37cd1e5defdc3a117c8dc7c2cc4 Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sun, 19 May 2019 08:46:18 +0300 Subject: [PATCH] OcSmbiosLib: Support setting SMBIOS SMC table --- Include/Library/OcSmbiosLib.h | 14 +++++------ Library/OcSmbiosLib/SmbiosPatch.c | 40 +++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Include/Library/OcSmbiosLib.h b/Include/Library/OcSmbiosLib.h index 4f6b8746..8b493c38 100644 --- a/Include/Library/OcSmbiosLib.h +++ b/Include/Library/OcSmbiosLib.h @@ -41,12 +41,6 @@ extern EFI_GUID gOcCustomSmbiosTableGuid; // #define OC_SMBIOS_VENDOR_NAME "Acidanthera" -// -// Some Macs do not support Type 133 table. -// This is the reserved value used to disable its creation. -// -#define PLATFORM_FEATURE_MISSING 0xFFFFFFFFU - typedef struct OC_SMBIOS_DATA_ { // // Type 0 @@ -97,11 +91,15 @@ typedef struct OC_SMBIOS_DATA_ { // // Type 131 // - UINT16 *ProcessorType; + CONST UINT16 *ProcessorType; // // Type 133 // - UINT32 PlatformFeature; + CONST UINT32 *PlatformFeature; + // + // Type 134 + // + CONST CHAR8 *SmcVersion; } OC_SMBIOS_DATA; typedef enum OC_SMBIOS_UPDATE_MODE_ { diff --git a/Library/OcSmbiosLib/SmbiosPatch.c b/Library/OcSmbiosLib/SmbiosPatch.c index 2b89a0cb..b06270c4 100755 --- a/Library/OcSmbiosLib/SmbiosPatch.c +++ b/Library/OcSmbiosLib/SmbiosPatch.c @@ -1021,7 +1021,7 @@ CreateApplePlatformFeature ( // // Older Macs do not support PlatformFeature table. // - if (Data->PlatformFeature == PLATFORM_FEATURE_MISSING) { + if (Data->PlatformFeature == NULL) { return; } @@ -1031,11 +1031,46 @@ CreateApplePlatformFeature ( return; } - Table->CurrentPtr.Type133->PlatformFeature = Data->PlatformFeature; + Table->CurrentPtr.Type133->PlatformFeature = *Data->PlatformFeature; SmbiosFinaliseStruct (Table); } +/** Type 134 + + @param[in] Table Pointer to location containing the current address within the buffer. + @param[in] Data Pointer to tocation containing SMBIOS data. +**/ +STATIC +VOID +CreateAppleSmcInformation ( + IN OUT OC_SMBIOS_TABLE *Table, + IN OC_SMBIOS_DATA *Data + ) +{ + UINT8 MinLength; + + // + // Newer Macs do not support SmcVersion table. + // + if (Data->SmcVersion == NULL) { + return; + } + + MinLength = sizeof (*Table->CurrentPtr.Type134); + + if (EFI_ERROR (SmbiosInitialiseStruct (Table, APPLE_SMBIOS_TYPE_SMC_INFORMATION, MinLength, 1))) { + return; + } + + CopyMem ( + Table->CurrentPtr.Type134->SmcVersion, + Data->SmcVersion, + sizeof (Table->CurrentPtr.Type134->SmcVersion) + ); + + SmbiosFinaliseStruct (Table); +} /** Type 127 @@ -1628,6 +1663,7 @@ CreateSmbios ( CreateAppleProcessorSpeed (&SmbiosTable, Data, CpuInfo); CreateAppleFirmwareVolume (&SmbiosTable, Data); CreateApplePlatformFeature (&SmbiosTable, Data); + CreateAppleSmcInformation (&SmbiosTable, Data); CreateSmBiosEndOfTable (&SmbiosTable, Data); FreePool (Mapping);