* [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue
@ 2016-12-09 8:43 Guo, Mang
2016-12-12 6:19 ` Wei, David
0 siblings, 1 reply; 2+ messages in thread
From: Guo, Mang @ 2016-12-09 8:43 UTC (permalink / raw)
To: edk2-devel@lists.01.org; +Cc: Wei, David
frontpage show blank on Turbot 2 due to some SMBIOS data missing.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Mang <mang.guo@intel.com>
---
.../MiscBaseBoardManufacturerFunction.c | 566 ++++++++-------
.../SmBiosMiscDxe/MiscSystemManufacturerFunction.c | 758 +++++++++++----------
Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf | 291 ++++----
3 files changed, 856 insertions(+), 759 deletions(-)
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
index 0102310..b2c12fd 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
@@ -1,244 +1,322 @@
-/*++
-
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available under
- the terms and conditions of the BSD License that accompanies this distribution.
- The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-
-Module Name:
-
- MiscBaseBoardManufacturerFunction.c
-
-Abstract:
-
- BaseBoard manufacturer information boot time changes.
- SMBIOS type 2.
-
---*/
-
-
-#include "CommonHeader.h"
-#include "MiscSubclassDriver.h"
-#include <Library/NetLib.h>
-#include "Library/DebugLib.h"
-#include <Uefi/UefiBaseType.h>
-#include <Guid/PlatformInfo.h>
-
-
-extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
-
-/**
- This function makes boot time changes to the contents of the
- MiscBaseBoardManufacturer (Type 2).
-
- @param RecordData Pointer to copy of RecordData from the Data Table.
-
- @retval EFI_SUCCESS All parameters were valid.
- @retval EFI_UNSUPPORTED Unexpected RecordType value.
- @retval EFI_INVALID_PARAMETER Invalid parameter was found.
-
-**/
-MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
-{
- CHAR8 *OptionalStrStart;
- UINTN ManuStrLen;
- UINTN ProductStrLen;
- UINTN VerStrLen;
- UINTN AssertTagStrLen;
- UINTN SerialNumStrLen;
- UINTN ChassisStrLen;
- EFI_STATUS Status;
- EFI_STRING Manufacturer;
- EFI_STRING Product;
- EFI_STRING Version;
- EFI_STRING SerialNumber;
- EFI_STRING AssertTag;
- EFI_STRING Chassis;
- STRING_REF TokenToGet;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_TABLE_TYPE2 *SmbiosRecord;
- EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;
-
- CHAR16 *MacStr;
- EFI_HANDLE *Handles;
- UINTN BufferSize;
- CHAR16 Buffer[40];
-
- ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;
-
- //
- // First check for invalid parameters.
- //
- if (RecordData == NULL || mPlatformInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);
- Manufacturer = SmbiosMiscGetString (TokenToGet);
- ManuStrLen = StrLen(Manufacturer);
- if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1);
- Product = SmbiosMiscGetString (TokenToGet);
- ProductStrLen = StrLen(Product);
- if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);
- Version = SmbiosMiscGetString (TokenToGet);
- VerStrLen = StrLen(Version);
- if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- //Get handle infomation
- //
- BufferSize = 0;
- Handles = NULL;
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Handles = AllocateZeroPool(BufferSize);
- if (Handles == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
- }
-
- //
- //Get the MAC string
- //
- Status = NetLibGetMacString (
- *Handles,
- NULL,
- &MacStr
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- SerialNumber = MacStr;
- SerialNumStrLen = StrLen(SerialNumber);
- if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr));
-
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);
- AssertTag = SmbiosMiscGetString (TokenToGet);
- AssertTagStrLen = StrLen(AssertTag);
- if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);
- Chassis = SmbiosMiscGetString (TokenToGet);
- ChassisStrLen = StrLen(Chassis);
- if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
-
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
- ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
-
- SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
-
- //
- // Make handle chosen by smbios protocol.add automatically.
- //
- SmbiosRecord->Hdr.Handle = 0;
-
- //
- // Manu will be the 1st optional string following the formatted structure.
- //
- SmbiosRecord->Manufacturer = 1;
-
- //
- // ProductName will be the 2st optional string following the formatted structure.
- //
- SmbiosRecord->ProductName = 2;
-
- //
- // Version will be the 3rd optional string following the formatted structure.
- //
- SmbiosRecord->Version = 3;
-
- //
- // SerialNumber will be the 4th optional string following the formatted structure.
- //
- SmbiosRecord->SerialNumber = 4;
-
- //
- // AssertTag will be the 5th optional string following the formatted structure.
- //
- SmbiosRecord->AssetTag = 5;
-
- //
- // LocationInChassis will be the 6th optional string following the formatted structure.
- //
- SmbiosRecord->LocationInChassis = 6;
- SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));
- SmbiosRecord->ChassisHandle = 0;
- SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType;
- SmbiosRecord->NumberOfContainedObjectHandles = 0;
-
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-
- //
- // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
- //
- UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
- UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
- UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
- UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
- UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
- UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
-
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios-> Add(
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
- );
-
- FreePool(SmbiosRecord);
- return Status;
-}
+/*++
+
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+
+Module Name:
+
+ MiscBaseBoardManufacturerFunction.c
+
+Abstract:
+
+ BaseBoard manufacturer information boot time changes.
+ SMBIOS type 2.
+
+--*/
+
+
+#include "CommonHeader.h"
+#include "MiscSubclassDriver.h"
+#include <Library/NetLib.h>
+#include "Library/DebugLib.h"
+#include <Uefi/UefiBaseType.h>
+#include <Guid/PlatformInfo.h>
+
+extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
+static EFI_SMBIOS_HANDLE mSmbiosHandleType2;
+
+EFI_STATUS
+EFIAPI
+UpdateBaseBoardManuCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN BufferSize;
+ CHAR16 *MacStr;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ UINTN SerialNumberOffset;
+ CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH];
+
+ gBS->CloseEvent (Event); // Unload this event.
+
+ DEBUG ((EFI_D_INFO, "Executing UpdateBaseBoardManuCallback.\n"));
+
+ //
+ //Get handle infomation
+ //
+ BufferSize = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Handles = AllocateZeroPool(BufferSize);
+ if (Handles == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ Status = gBS->LocateHandle(
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+ }
+
+ //
+ //Get the MAC string
+ //
+ Status = NetLibGetMacString (
+ *Handles,
+ NULL,
+ &MacStr
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);
+ UnicodeStrToAsciiStr (MacStr, AsciiData);
+
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID *) &Smbios
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ SerialNumberOffset = 4;
+ Status = Smbios->UpdateString (
+ Smbios,
+ &mSmbiosHandleType2,
+ &SerialNumberOffset,
+ AsciiData
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+
+/**
+ This function makes boot time changes to the contents of the
+ MiscBaseBoardManufacturer (Type 2).
+
+ @param RecordData Pointer to copy of RecordData from the Data Table.
+
+ @retval EFI_SUCCESS All parameters were valid.
+ @retval EFI_UNSUPPORTED Unexpected RecordType value.
+ @retval EFI_INVALID_PARAMETER Invalid parameter was found.
+
+**/
+MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
+{
+ CHAR8 *OptionalStrStart;
+ UINTN ManuStrLen;
+ UINTN ProductStrLen;
+ UINTN VerStrLen;
+ UINTN AssertTagStrLen;
+ UINTN SerialNumStrLen;
+ UINTN ChassisStrLen;
+ EFI_STATUS Status;
+ EFI_STRING Manufacturer;
+ EFI_STRING Product;
+ EFI_STRING Version;
+ EFI_STRING SerialNumber;
+ EFI_STRING AssertTag;
+ EFI_STRING Chassis;
+ STRING_REF TokenToGet;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_TABLE_TYPE2 *SmbiosRecord;
+ EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;
+ VOID *UpdateBaseBoardManuCallbackNotifyReg;
+ EFI_EVENT UpdateBaseBoardManuCallbackEvent;
+ CHAR16 *MacStr;
+ CHAR16 Buffer[40];
+ static BOOLEAN CallbackIsInstalledT2 = FALSE;
+
+ ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;
+
+ //
+ // First check for invalid parameters.
+ //
+ if (RecordData == NULL || mPlatformInfo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);
+ Manufacturer = SmbiosMiscGetString (TokenToGet);
+ ManuStrLen = StrLen(Manufacturer);
+ if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1);
+ Product = SmbiosMiscGetString (TokenToGet);
+ ProductStrLen = StrLen(Product);
+ if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);
+ Version = SmbiosMiscGetString (TokenToGet);
+ VerStrLen = StrLen(Version);
+ if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MacStr = L"00000000";
+ SerialNumber = MacStr;
+ SerialNumStrLen = StrLen(SerialNumber);
+ if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr));
+
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);
+ AssertTag = SmbiosMiscGetString (TokenToGet);
+ AssertTagStrLen = StrLen(AssertTag);
+ if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);
+ Chassis = SmbiosMiscGetString (TokenToGet);
+ ChassisStrLen = StrLen(Chassis);
+ if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
+
+ //
+ // Make handle chosen by smbios protocol.add automatically.
+ //
+ SmbiosRecord->Hdr.Handle = 0;
+
+ //
+ // Manu will be the 1st optional string following the formatted structure.
+ //
+ SmbiosRecord->Manufacturer = 1;
+
+ //
+ // ProductName will be the 2st optional string following the formatted structure.
+ //
+ SmbiosRecord->ProductName = 2;
+
+ //
+ // Version will be the 3rd optional string following the formatted structure.
+ //
+ SmbiosRecord->Version = 3;
+
+ //
+ // SerialNumber will be the 4th optional string following the formatted structure.
+ //
+ SmbiosRecord->SerialNumber = 4;
+
+ //
+ // AssertTag will be the 5th optional string following the formatted structure.
+ //
+ SmbiosRecord->AssetTag = 5;
+
+ //
+ // LocationInChassis will be the 6th optional string following the formatted structure.
+ //
+ SmbiosRecord->LocationInChassis = 6;
+ SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));
+ SmbiosRecord->ChassisHandle = 0;
+ SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType;
+ SmbiosRecord->NumberOfContainedObjectHandles = 0;
+
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+
+ //
+ // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
+ //
+ UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
+ UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
+ UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
+ UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
+ UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+ UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios-> Add(
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
+ );
+
+ FreePool(SmbiosRecord);
+
+ //
+ // gEfiSimpleNetworkProtocolGuid is ready
+ //
+ if (CallbackIsInstalledT2 == FALSE) {
+ CallbackIsInstalledT2 = TRUE; // Prevent more than 1 callback.
+ DEBUG ((EFI_D_INFO, "Create Smbios T2 callback.\n"));
+
+ mSmbiosHandleType2 = SmbiosHandle;
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)UpdateBaseBoardManuCallback,
+ RecordData,
+ &UpdateBaseBoardManuCallbackEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiSimpleNetworkProtocolGuid,
+ UpdateBaseBoardManuCallbackEvent,
+ &UpdateBaseBoardManuCallbackNotifyReg
+ );
+
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
index 420c8c3..1d47e4a 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
@@ -1,370 +1,388 @@
-/*++
-
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available under
- the terms and conditions of the BSD License that accompanies this distribution.
- The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-
-Module Name:
-
- MiscSystemManufacturerFunction.c
-
-Abstract:
-
- This driver parses the mMiscSubclassDataTable structure and reports
- any generated data.
-
---*/
-
-
-#include "CommonHeader.h"
-#include "MiscSubclassDriver.h"
-#include <Protocol/DxeSmmReadyToLock.h>
-#include <Library/NetLib.h>
-#include "Library/DebugLib.h"
-#include <Uefi/UefiBaseType.h>
-#include <Guid/PlatformInfo.h>
-
-
-extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
-
-
-/**
-
- Publish the smbios type 1.
-
- @param Event Event whose notification function is being invoked (gEfiDxeSmmReadyToLockProtocolGuid).
- @param Context Pointer to the notification functions context, which is implementation dependent.
-
- @retval None
-
-**/
-EFI_STATUS
-EFIAPI
-AddSmbiosManuCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-
- CHAR8 *OptionalStrStart;
- UINTN ManuStrLen;
- UINTN VerStrLen;
- UINTN PdNameStrLen;
- UINTN SerialNumStrLen;
- UINTN SkuNumberStrLen;
- UINTN FamilyNameStrLen;
- EFI_STATUS Status;
- EFI_STRING Manufacturer;
- EFI_STRING ProductName;
- EFI_STRING Version;
- EFI_STRING SerialNumber;
- EFI_STRING SkuNumber;
- EFI_STRING FamilyName;
- STRING_REF TokenToGet;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_TABLE_TYPE1 *SmbiosRecord;
- EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;
- EFI_SMBIOS_PROTOCOL *Smbios;
- CHAR16 Buffer[40];
-
- CHAR16 *MacStr;
- EFI_HANDLE *Handles;
- UINTN BufferSize;
- CHAR16 PlatformNameBuffer[40];
-
- ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)Context;
-
- //
- // First check for invalid parameters.
- //
- if (Context == NULL || mPlatformInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID *) &Smbios);
- ASSERT_EFI_ERROR (Status);
-
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- // Detect the board is Turbot board platform
- UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Turbot ");
- } else {
- UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Max ");
- }
-
- //
- // Silicon Steppings
- //
- switch (PchStepping()) {
- case PchA0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n"));
- break;
- case PchA1:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A1 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n"));
- break;
- case PchB0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n"));
- break;
- case PchB1:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B1 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n"));
- break;
- case PchB2:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B2 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n"));
- break;
- case PchB3:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B3 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n"));
- break;
- case PchC0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"C0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n"));
- break;
- case PchD0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"D0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n"));
- break;
- default:
- DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n"));
- break;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);
- Manufacturer = SmbiosMiscGetString (TokenToGet);
- ManuStrLen = StrLen(Manufacturer);
- if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);
- ProductName = SmbiosMiscGetString (TokenToGet);
- PdNameStrLen = StrLen(ProductName);
- if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);
- Version = SmbiosMiscGetString (TokenToGet);
- VerStrLen = StrLen(Version);
- if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- //Get handle infomation
- //
- BufferSize = 0;
- Handles = NULL;
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Handles = AllocateZeroPool(BufferSize);
- if (Handles == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
- }
-
- //
- //Get the MAC string
- //
- Status = NetLibGetMacString (
- *Handles,
- NULL,
- &MacStr
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- SerialNumber = MacStr;
- SerialNumStrLen = StrLen(SerialNumber);
- if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER);
- SkuNumber = SmbiosMiscGetString (TokenToGet);
- SkuNumberStrLen = StrLen(SkuNumber);
- if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1);
- FamilyName = SmbiosMiscGetString (TokenToGet);
- FamilyNameStrLen = StrLen(FamilyName);
- if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
- ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
-
- SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
-
- //
- // Make handle chosen by smbios protocol.add automatically.
- //
- SmbiosRecord->Hdr.Handle = 0;
-
- //
- // Manu will be the 1st optional string following the formatted structure.
- //
- SmbiosRecord->Manufacturer = 1;
-
- //
- // ProductName will be the 2nd optional string following the formatted structure.
- //
- SmbiosRecord->ProductName = 2;
-
- //
- // Version will be the 3rd optional string following the formatted structure.
- //
- SmbiosRecord->Version = 3;
-
- //
- // Version will be the 4th optional string following the formatted structure.
- //
- SmbiosRecord->SerialNumber = 4;
-
- SmbiosRecord->SKUNumber= 5;
- SmbiosRecord->Family= 6;
-
- //
- // Unique UUID
- //
- ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber);
- ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId);
-
- CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);
-
- SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;
-
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
- UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
- UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);
- UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);
- UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);
-
- UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
- UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1);
-
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios-> Add(
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
- );
- FreePool(SmbiosRecord);
- return Status;
-}
-
-/**
- This function makes boot time changes to the contents of the
- MiscSystemManufacturer (Type 1).
-
- @param RecordData Pointer to copy of RecordData from the Data Table.
-
- @retval EFI_SUCCESS All parameters were valid.
- @retval EFI_UNSUPPORTED Unexpected RecordType value.
- @retval EFI_INVALID_PARAMETER Invalid parameter was found.
-
-**/
-MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
-{
- EFI_STATUS Status;
- static BOOLEAN CallbackIsInstalledManu = FALSE;
- VOID *AddSmbiosManuCallbackNotifyReg;
- EFI_EVENT AddSmbiosManuCallbackEvent;
-
-
- if (CallbackIsInstalledManu == FALSE) {
- CallbackIsInstalledManu = TRUE; // Prevent more than 1 callback.
- DEBUG ((EFI_D_INFO, "Create Smbios Manu callback.\n"));
-
- //
- // gEfiDxeSmmReadyToLockProtocolGuid is ready
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- (EFI_EVENT_NOTIFY)AddSmbiosManuCallback,
- RecordData,
- &AddSmbiosManuCallbackEvent
- );
-
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
-
- }
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiDxeSmmReadyToLockProtocolGuid,
- AddSmbiosManuCallbackEvent,
- &AddSmbiosManuCallbackNotifyReg
- );
-
- return Status;
- }
-
- return EFI_SUCCESS;
-
-}
+/*++
+
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+
+Module Name:
+
+ MiscSystemManufacturerFunction.c
+
+Abstract:
+
+ This driver parses the mMiscSubclassDataTable structure and reports
+ any generated data.
+
+--*/
+
+
+#include "CommonHeader.h"
+#include "MiscSubclassDriver.h"
+#include <Protocol/DxeSmmReadyToLock.h>
+#include <Library/NetLib.h>
+#include "Library/DebugLib.h"
+#include <Uefi/UefiBaseType.h>
+#include <Guid/PlatformInfo.h>
+
+
+extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
+static EFI_SMBIOS_HANDLE mSmbiosHandleType1;
+
+
+EFI_STATUS
+EFIAPI
+UpdateSmbiosManuCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN BufferSize;
+ CHAR16 *MacStr;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ UINTN SerialNumberOffset;
+ CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH];
+
+ gBS->CloseEvent (Event); // Unload this event.
+
+ DEBUG ((EFI_D_INFO, "Executing UpdateSmbiosManuCallback.\n"));
+
+ //
+ //Get handle infomation
+ //
+ BufferSize = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Handles = AllocateZeroPool(BufferSize);
+ if (Handles == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ Status = gBS->LocateHandle(
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+ }
+
+ //
+ //Get the MAC string
+ //
+ Status = NetLibGetMacString (
+ *Handles,
+ NULL,
+ &MacStr
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);
+ UnicodeStrToAsciiStr (MacStr, AsciiData);
+
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID *) &Smbios
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ SerialNumberOffset = 4;
+ Status = Smbios->UpdateString (
+ Smbios,
+ &mSmbiosHandleType1,
+ &SerialNumberOffset,
+ AsciiData
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+
+/**
+
+ Publish the smbios type 1.
+
+ @param Event Event whose notification function is being invoked (gEfiDxeSmmReadyToLockProtocolGuid).
+ @param Context Pointer to the notification functions context, which is implementation dependent.
+
+ @retval None
+
+**/
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
+{
+
+ CHAR8 *OptionalStrStart;
+ UINTN ManuStrLen;
+ UINTN VerStrLen;
+ UINTN PdNameStrLen;
+ UINTN SerialNumStrLen;
+ UINTN SkuNumberStrLen;
+ UINTN FamilyNameStrLen;
+ EFI_STATUS Status;
+ EFI_STRING Manufacturer;
+ EFI_STRING ProductName;
+ EFI_STRING Version;
+ EFI_STRING SerialNumber;
+ EFI_STRING SkuNumber;
+ EFI_STRING FamilyName;
+ STRING_REF TokenToGet;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_TABLE_TYPE1 *SmbiosRecord;
+ EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;
+ CHAR16 Buffer[40];
+ CHAR16 *MacStr;
+ CHAR16 PlatformNameBuffer[40];
+ VOID *UpdateSmbiosManuCallbackNotifyReg;
+ EFI_EVENT UpdateSmbiosManuCallbackEvent;
+ static BOOLEAN CallbackIsInstalledT1 = FALSE;
+
+ ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;
+ //
+ // First check for invalid parameters.
+ //
+ if (RecordData == NULL || mPlatformInfo == NULL) {
+ DEBUG ((EFI_D_INFO, "MISC_SMBIOS_TABLE_FUNCTION error.\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ //
+ // Detect the board is Turbot board platform
+ //
+ UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Turbot ");
+ } else {
+ UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Max ");
+ }
+
+ //
+ // Silicon Steppings
+ //
+ switch (PchStepping()) {
+ case PchA0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n"));
+ break;
+ case PchA1:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A1 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n"));
+ break;
+ case PchB0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n"));
+ break;
+ case PchB1:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B1 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n"));
+ break;
+ case PchB2:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B2 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n"));
+ break;
+ case PchB3:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B3 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n"));
+ break;
+ case PchC0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"C0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n"));
+ break;
+ case PchD0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"D0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n"));
+ break;
+ default:
+ DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n"));
+ break;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);
+ Manufacturer = SmbiosMiscGetString (TokenToGet);
+ ManuStrLen = StrLen(Manufacturer);
+ if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);
+ ProductName = SmbiosMiscGetString (TokenToGet);
+ PdNameStrLen = StrLen(ProductName);
+ if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);
+ Version = SmbiosMiscGetString (TokenToGet);
+ VerStrLen = StrLen(Version);
+ if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MacStr = L"00000000";
+ SerialNumber = MacStr;
+ SerialNumStrLen = StrLen(SerialNumber);
+ if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER);
+ SkuNumber = SmbiosMiscGetString (TokenToGet);
+ SkuNumberStrLen = StrLen(SkuNumber);
+ if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1);
+ FamilyName = SmbiosMiscGetString (TokenToGet);
+ FamilyNameStrLen = StrLen(FamilyName);
+ if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
+
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
+
+ //
+ // Make handle chosen by smbios protocol.add automatically.
+ //
+ SmbiosRecord->Hdr.Handle = 0;
+
+ //
+ // Manu will be the 1st optional string following the formatted structure.
+ //
+ SmbiosRecord->Manufacturer = 1;
+
+ //
+ // ProductName will be the 2nd optional string following the formatted structure.
+ //
+ SmbiosRecord->ProductName = 2;
+
+ //
+ // Version will be the 3rd optional string following the formatted structure.
+ //
+ SmbiosRecord->Version = 3;
+
+ //
+ // Version will be the 4th optional string following the formatted structure.
+ //
+ SmbiosRecord->SerialNumber = 4;
+
+ SmbiosRecord->SKUNumber= 5;
+ SmbiosRecord->Family= 6;
+
+ //
+ // Unique UUID
+ //
+ ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber);
+ ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId);
+
+ CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);
+
+ SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;
+
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+ UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
+ UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);
+ UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);
+ UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);
+
+ UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+ UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1);
+
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios-> Add(
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
+ );
+ FreePool(SmbiosRecord);
+
+ //
+ // gEfiSimpleNetworkProtocolGuid is ready
+ //
+ if (CallbackIsInstalledT1 == FALSE) {
+ CallbackIsInstalledT1 = TRUE; // Prevent more than 1 callback.
+ DEBUG ((EFI_D_INFO, "Create Smbios Type1 callback.\n"));
+
+ mSmbiosHandleType1 = SmbiosHandle;
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)UpdateSmbiosManuCallback,
+ RecordData,
+ &UpdateSmbiosManuCallbackEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiSimpleNetworkProtocolGuid,
+ UpdateSmbiosManuCallbackEvent,
+ &UpdateSmbiosManuCallbackNotifyReg
+ );
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf b/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
index 332d237..f88dcbe 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
@@ -1,145 +1,146 @@
-## @file
-# Component name for module MiscSubclass
-#
-# FIX ME!
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available under
-# the terms and conditions of the BSD License that accompanies this distribution.
-# The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MiscSubclass
- FILE_GUID = 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = MiscSubclassDriverEntryPoint
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources]
- MiscBaseBoardManufacturer.uni
- MiscBaseBoardManufacturerData.c
- MiscBaseBoardManufacturerFunction.c
- MiscBiosVendor.uni
- MiscBiosVendorData.c
- MiscBiosVendorFunction.c
- MiscBootInformationData.c
- MiscBootInformationFunction.c
- MiscChassisManufacturer.uni
- MiscChassisManufacturerData.c
- MiscChassisManufacturerFunction.c
- MiscNumberOfInstallableLanguagesData.c
- MiscNumberOfInstallableLanguagesFunction.c
- MiscOemString.uni
- MiscOemStringData.c
- MiscOemStringFunction.c
- MiscOnboardDevice.uni
- MiscOnboardDeviceData.c
- MiscOnboardDeviceFunction.c
- MiscPortInternalConnectorDesignator.uni
- MiscPortInternalConnectorDesignatorData.c
- MiscPortInternalConnectorDesignatorFunction.c
- MiscResetCapabilitiesData.c
- MiscResetCapabilitiesFunction.c
- MiscSystemLanguageString.uni
- MiscSystemLanguageStringData.c
- MiscSystemLanguageStringFunction.c
- MiscSystemManufacturer.uni
- MiscSystemManufacturerData.c
- MiscSystemManufacturerFunction.c
- MiscSystemOptionString.uni
- MiscSystemOptionStringData.c
- MiscSystemOptionStringFunction.c
- MiscSystemSlotDesignation.uni
- MiscSystemSlotDesignationData.c
- MiscSystemSlotDesignationFunction.c
- MiscSubclassDriver.h
- MiscSubclassDriver.uni
- MiscSubclassDriverDataTable.c
- MiscSubclassDriverEntryPoint.c
- CommonHeader.h
- MiscOemType0x90Function.c
- MiscOemType0x90Data.c
- MiscOemType0x90.uni
- MiscProcessorInformation.uni
- MiscProcessorInformationData.c
- MiscProcessorInformationFunction.c
- MiscProcessorCache.uni
- MiscProcessorCacheData.c
- MiscProcessorCacheFunction.c
- MiscPhysicalArray.uni
- MiscPhysicalArrayData.c
- MiscPhysicalArrayFunction.c
- MiscMemoryDevice.uni
- MiscMemoryDeviceData.c
- MiscMemoryDeviceFunction.c
-
-[Packages]
- MdeModulePkg/MdeModulePkg.dec
- Vlv2TbltDevicePkg/PlatformPkg.dec
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
-
-[LibraryClasses]
- HiiLib
- DevicePathLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- DebugLib
- BaseLib
- MemoryAllocationLib
- PcdLib
- UefiLib
- BiosIdLib
- PrintLib
- CpuIA32Lib
- PchPlatformLib
- I2cLib
- NetLib
- HobLib
-
-[Guids]
- gEfiProcessorSubClassGuid
- gEfiCacheSubClassGuid
- gEfiNormalSetupGuid
- gEfiPlatformInfoGuid
- gEfiVlv2VariableGuid
-
-[Protocols]
- gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDataHubProtocolGuid
- gEfiMpServiceProtocolGuid
- gMemInfoProtocolGuid
- gEfiTdtOperationProtocolGuid
- gDxePchPlatformPolicyProtocolGuid
- gEfiSpiProtocolGuid
- gEfiSimpleNetworkProtocolGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
- gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
- gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId
- gEfiVLVTokenSpaceGuid.PcdProductSerialNumber
-
-[Depex]
- gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocolGuid AND gEfiSimpleNetworkProtocolGuid
+## @file
+# Component name for module MiscSubclass
+#
+# FIX ME!
+# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License that accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = MiscSubclass
+ FILE_GUID = 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = MiscSubclassDriverEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ MiscBaseBoardManufacturer.uni
+ MiscBaseBoardManufacturerData.c
+ MiscBaseBoardManufacturerFunction.c
+ MiscBiosVendor.uni
+ MiscBiosVendorData.c
+ MiscBiosVendorFunction.c
+ MiscBootInformationData.c
+ MiscBootInformationFunction.c
+ MiscChassisManufacturer.uni
+ MiscChassisManufacturerData.c
+ MiscChassisManufacturerFunction.c
+ MiscNumberOfInstallableLanguagesData.c
+ MiscNumberOfInstallableLanguagesFunction.c
+ MiscOemString.uni
+ MiscOemStringData.c
+ MiscOemStringFunction.c
+ MiscOnboardDevice.uni
+ MiscOnboardDeviceData.c
+ MiscOnboardDeviceFunction.c
+ MiscPortInternalConnectorDesignator.uni
+ MiscPortInternalConnectorDesignatorData.c
+ MiscPortInternalConnectorDesignatorFunction.c
+ MiscResetCapabilitiesData.c
+ MiscResetCapabilitiesFunction.c
+ MiscSystemLanguageString.uni
+ MiscSystemLanguageStringData.c
+ MiscSystemLanguageStringFunction.c
+ MiscSystemManufacturer.uni
+ MiscSystemManufacturerData.c
+ MiscSystemManufacturerFunction.c
+ MiscSystemOptionString.uni
+ MiscSystemOptionStringData.c
+ MiscSystemOptionStringFunction.c
+ MiscSystemSlotDesignation.uni
+ MiscSystemSlotDesignationData.c
+ MiscSystemSlotDesignationFunction.c
+ MiscSubclassDriver.h
+ MiscSubclassDriver.uni
+ MiscSubclassDriverDataTable.c
+ MiscSubclassDriverEntryPoint.c
+ CommonHeader.h
+ MiscOemType0x90Function.c
+ MiscOemType0x90Data.c
+ MiscOemType0x90.uni
+ MiscProcessorInformation.uni
+ MiscProcessorInformationData.c
+ MiscProcessorInformationFunction.c
+ MiscProcessorCache.uni
+ MiscProcessorCacheData.c
+ MiscProcessorCacheFunction.c
+ MiscPhysicalArray.uni
+ MiscPhysicalArrayData.c
+ MiscPhysicalArrayFunction.c
+ MiscMemoryDevice.uni
+ MiscMemoryDeviceData.c
+ MiscMemoryDeviceFunction.c
+
+[Packages]
+ MdeModulePkg/MdeModulePkg.dec
+ Vlv2TbltDevicePkg/PlatformPkg.dec
+ MdePkg/MdePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
+
+[LibraryClasses]
+ HiiLib
+ DevicePathLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ BaseMemoryLib
+ DebugLib
+ BaseLib
+ MemoryAllocationLib
+ PcdLib
+ UefiLib
+ BiosIdLib
+ PrintLib
+ CpuIA32Lib
+ PchPlatformLib
+ I2cLib
+ NetLib
+ HobLib
+
+[Guids]
+ gEfiProcessorSubClassGuid
+ gEfiCacheSubClassGuid
+ gEfiNormalSetupGuid
+ gEfiPlatformInfoGuid
+ gEfiVlv2VariableGuid
+
+[Protocols]
+ gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDataHubProtocolGuid
+ gEfiMpServiceProtocolGuid
+ gMemInfoProtocolGuid
+ gEfiTdtOperationProtocolGuid
+ gDxePchPlatformPolicyProtocolGuid
+ gEfiSpiProtocolGuid
+ gEfiSimpleNetworkProtocolGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+ gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
+ gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId
+ gEfiVLVTokenSpaceGuid.PcdProductSerialNumber
+
+[Depex]
+ gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocolGuid
+
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue
2016-12-09 8:43 [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue Guo, Mang
@ 2016-12-12 6:19 ` Wei, David
0 siblings, 0 replies; 2+ messages in thread
From: Wei, David @ 2016-12-12 6:19 UTC (permalink / raw)
To: Guo, Mang, edk2-devel@lists.01.org
Reviewed-by: David Wei <david.wei@intel.com>
Thanks,
David Wei
-----Original Message-----
From: Guo, Mang
Sent: Friday, December 09, 2016 4:44 PM
To: edk2-devel@lists.01.org
Cc: Wei, David <david.wei@intel.com>
Subject: [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue
frontpage show blank on Turbot 2 due to some SMBIOS data missing.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Mang <mang.guo@intel.com>
---
.../MiscBaseBoardManufacturerFunction.c | 566 ++++++++-------
.../SmBiosMiscDxe/MiscSystemManufacturerFunction.c | 758 +++++++++++----------
Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf | 291 ++++----
3 files changed, 856 insertions(+), 759 deletions(-)
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
index 0102310..b2c12fd 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufacturerFunction.c
@@ -1,244 +1,322 @@
-/*++
-
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available under
- the terms and conditions of the BSD License that accompanies this distribution.
- The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-
-Module Name:
-
- MiscBaseBoardManufacturerFunction.c
-
-Abstract:
-
- BaseBoard manufacturer information boot time changes.
- SMBIOS type 2.
-
---*/
-
-
-#include "CommonHeader.h"
-#include "MiscSubclassDriver.h"
-#include <Library/NetLib.h>
-#include "Library/DebugLib.h"
-#include <Uefi/UefiBaseType.h>
-#include <Guid/PlatformInfo.h>
-
-
-extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
-
-/**
- This function makes boot time changes to the contents of the
- MiscBaseBoardManufacturer (Type 2).
-
- @param RecordData Pointer to copy of RecordData from the Data Table.
-
- @retval EFI_SUCCESS All parameters were valid.
- @retval EFI_UNSUPPORTED Unexpected RecordType value.
- @retval EFI_INVALID_PARAMETER Invalid parameter was found.
-
-**/
-MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
-{
- CHAR8 *OptionalStrStart;
- UINTN ManuStrLen;
- UINTN ProductStrLen;
- UINTN VerStrLen;
- UINTN AssertTagStrLen;
- UINTN SerialNumStrLen;
- UINTN ChassisStrLen;
- EFI_STATUS Status;
- EFI_STRING Manufacturer;
- EFI_STRING Product;
- EFI_STRING Version;
- EFI_STRING SerialNumber;
- EFI_STRING AssertTag;
- EFI_STRING Chassis;
- STRING_REF TokenToGet;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_TABLE_TYPE2 *SmbiosRecord;
- EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;
-
- CHAR16 *MacStr;
- EFI_HANDLE *Handles;
- UINTN BufferSize;
- CHAR16 Buffer[40];
-
- ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;
-
- //
- // First check for invalid parameters.
- //
- if (RecordData == NULL || mPlatformInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);
- Manufacturer = SmbiosMiscGetString (TokenToGet);
- ManuStrLen = StrLen(Manufacturer);
- if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1);
- Product = SmbiosMiscGetString (TokenToGet);
- ProductStrLen = StrLen(Product);
- if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);
- Version = SmbiosMiscGetString (TokenToGet);
- VerStrLen = StrLen(Version);
- if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- //Get handle infomation
- //
- BufferSize = 0;
- Handles = NULL;
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Handles = AllocateZeroPool(BufferSize);
- if (Handles == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
- }
-
- //
- //Get the MAC string
- //
- Status = NetLibGetMacString (
- *Handles,
- NULL,
- &MacStr
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- SerialNumber = MacStr;
- SerialNumStrLen = StrLen(SerialNumber);
- if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr));
-
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);
- AssertTag = SmbiosMiscGetString (TokenToGet);
- AssertTagStrLen = StrLen(AssertTag);
- if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);
- Chassis = SmbiosMiscGetString (TokenToGet);
- ChassisStrLen = StrLen(Chassis);
- if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
-
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
- ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
-
- SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
-
- //
- // Make handle chosen by smbios protocol.add automatically.
- //
- SmbiosRecord->Hdr.Handle = 0;
-
- //
- // Manu will be the 1st optional string following the formatted structure.
- //
- SmbiosRecord->Manufacturer = 1;
-
- //
- // ProductName will be the 2st optional string following the formatted structure.
- //
- SmbiosRecord->ProductName = 2;
-
- //
- // Version will be the 3rd optional string following the formatted structure.
- //
- SmbiosRecord->Version = 3;
-
- //
- // SerialNumber will be the 4th optional string following the formatted structure.
- //
- SmbiosRecord->SerialNumber = 4;
-
- //
- // AssertTag will be the 5th optional string following the formatted structure.
- //
- SmbiosRecord->AssetTag = 5;
-
- //
- // LocationInChassis will be the 6th optional string following the formatted structure.
- //
- SmbiosRecord->LocationInChassis = 6;
- SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));
- SmbiosRecord->ChassisHandle = 0;
- SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType;
- SmbiosRecord->NumberOfContainedObjectHandles = 0;
-
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-
- //
- // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
- //
- UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
- UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
- UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
- UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
- UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
- UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
-
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios-> Add(
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
- );
-
- FreePool(SmbiosRecord);
- return Status;
-}
+/*++
+
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+
+Module Name:
+
+ MiscBaseBoardManufacturerFunction.c
+
+Abstract:
+
+ BaseBoard manufacturer information boot time changes.
+ SMBIOS type 2.
+
+--*/
+
+
+#include "CommonHeader.h"
+#include "MiscSubclassDriver.h"
+#include <Library/NetLib.h>
+#include "Library/DebugLib.h"
+#include <Uefi/UefiBaseType.h>
+#include <Guid/PlatformInfo.h>
+
+extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
+static EFI_SMBIOS_HANDLE mSmbiosHandleType2;
+
+EFI_STATUS
+EFIAPI
+UpdateBaseBoardManuCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN BufferSize;
+ CHAR16 *MacStr;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ UINTN SerialNumberOffset;
+ CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH];
+
+ gBS->CloseEvent (Event); // Unload this event.
+
+ DEBUG ((EFI_D_INFO, "Executing UpdateBaseBoardManuCallback.\n"));
+
+ //
+ //Get handle infomation
+ //
+ BufferSize = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Handles = AllocateZeroPool(BufferSize);
+ if (Handles == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ Status = gBS->LocateHandle(
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+ }
+
+ //
+ //Get the MAC string
+ //
+ Status = NetLibGetMacString (
+ *Handles,
+ NULL,
+ &MacStr
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);
+ UnicodeStrToAsciiStr (MacStr, AsciiData);
+
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID *) &Smbios
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ SerialNumberOffset = 4;
+ Status = Smbios->UpdateString (
+ Smbios,
+ &mSmbiosHandleType2,
+ &SerialNumberOffset,
+ AsciiData
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+
+/**
+ This function makes boot time changes to the contents of the
+ MiscBaseBoardManufacturer (Type 2).
+
+ @param RecordData Pointer to copy of RecordData from the Data Table.
+
+ @retval EFI_SUCCESS All parameters were valid.
+ @retval EFI_UNSUPPORTED Unexpected RecordType value.
+ @retval EFI_INVALID_PARAMETER Invalid parameter was found.
+
+**/
+MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
+{
+ CHAR8 *OptionalStrStart;
+ UINTN ManuStrLen;
+ UINTN ProductStrLen;
+ UINTN VerStrLen;
+ UINTN AssertTagStrLen;
+ UINTN SerialNumStrLen;
+ UINTN ChassisStrLen;
+ EFI_STATUS Status;
+ EFI_STRING Manufacturer;
+ EFI_STRING Product;
+ EFI_STRING Version;
+ EFI_STRING SerialNumber;
+ EFI_STRING AssertTag;
+ EFI_STRING Chassis;
+ STRING_REF TokenToGet;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_TABLE_TYPE2 *SmbiosRecord;
+ EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;
+ VOID *UpdateBaseBoardManuCallbackNotifyReg;
+ EFI_EVENT UpdateBaseBoardManuCallbackEvent;
+ CHAR16 *MacStr;
+ CHAR16 Buffer[40];
+ static BOOLEAN CallbackIsInstalledT2 = FALSE;
+
+ ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;
+
+ //
+ // First check for invalid parameters.
+ //
+ if (RecordData == NULL || mPlatformInfo == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_MANUFACTURER), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);
+ Manufacturer = SmbiosMiscGetString (TokenToGet);
+ ManuStrLen = StrLen(Manufacturer);
+ if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"MinnowBoard Turbot");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_BASE_BOARD_PRODUCT_NAME1), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME1);
+ Product = SmbiosMiscGetString (TokenToGet);
+ ProductStrLen = StrLen(Product);
+ if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);
+ Version = SmbiosMiscGetString (TokenToGet);
+ VerStrLen = StrLen(Version);
+ if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MacStr = L"00000000";
+ SerialNumber = MacStr;
+ SerialNumStrLen = StrLen(SerialNumber);
+ if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ DEBUG ((EFI_D_ERROR, "MAC Address: %S\n", MacStr));
+
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);
+ AssertTag = SmbiosMiscGetString (TokenToGet);
+ AssertTagStrLen = StrLen(AssertTag);
+ if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);
+ Chassis = SmbiosMiscGetString (TokenToGet);
+ ChassisStrLen = StrLen(Chassis);
+ if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
+
+ //
+ // Make handle chosen by smbios protocol.add automatically.
+ //
+ SmbiosRecord->Hdr.Handle = 0;
+
+ //
+ // Manu will be the 1st optional string following the formatted structure.
+ //
+ SmbiosRecord->Manufacturer = 1;
+
+ //
+ // ProductName will be the 2st optional string following the formatted structure.
+ //
+ SmbiosRecord->ProductName = 2;
+
+ //
+ // Version will be the 3rd optional string following the formatted structure.
+ //
+ SmbiosRecord->Version = 3;
+
+ //
+ // SerialNumber will be the 4th optional string following the formatted structure.
+ //
+ SmbiosRecord->SerialNumber = 4;
+
+ //
+ // AssertTag will be the 5th optional string following the formatted structure.
+ //
+ SmbiosRecord->AssetTag = 5;
+
+ //
+ // LocationInChassis will be the 6th optional string following the formatted structure.
+ //
+ SmbiosRecord->LocationInChassis = 6;
+ SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));
+ SmbiosRecord->ChassisHandle = 0;
+ SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType;
+ SmbiosRecord->NumberOfContainedObjectHandles = 0;
+
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+
+ //
+ // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
+ //
+ UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
+ UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
+ UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
+ UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
+ UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+ UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios-> Add(
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
+ );
+
+ FreePool(SmbiosRecord);
+
+ //
+ // gEfiSimpleNetworkProtocolGuid is ready
+ //
+ if (CallbackIsInstalledT2 == FALSE) {
+ CallbackIsInstalledT2 = TRUE; // Prevent more than 1 callback.
+ DEBUG ((EFI_D_INFO, "Create Smbios T2 callback.\n"));
+
+ mSmbiosHandleType2 = SmbiosHandle;
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)UpdateBaseBoardManuCallback,
+ RecordData,
+ &UpdateBaseBoardManuCallbackEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiSimpleNetworkProtocolGuid,
+ UpdateBaseBoardManuCallbackEvent,
+ &UpdateBaseBoardManuCallbackNotifyReg
+ );
+
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
index 420c8c3..1d47e4a 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturerFunction.c
@@ -1,370 +1,388 @@
-/*++
-
-Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
-
- This program and the accompanying materials are licensed and made available under
- the terms and conditions of the BSD License that accompanies this distribution.
- The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-
-
-Module Name:
-
- MiscSystemManufacturerFunction.c
-
-Abstract:
-
- This driver parses the mMiscSubclassDataTable structure and reports
- any generated data.
-
---*/
-
-
-#include "CommonHeader.h"
-#include "MiscSubclassDriver.h"
-#include <Protocol/DxeSmmReadyToLock.h>
-#include <Library/NetLib.h>
-#include "Library/DebugLib.h"
-#include <Uefi/UefiBaseType.h>
-#include <Guid/PlatformInfo.h>
-
-
-extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
-
-
-/**
-
- Publish the smbios type 1.
-
- @param Event Event whose notification function is being invoked (gEfiDxeSmmReadyToLockProtocolGuid).
- @param Context Pointer to the notification functions context, which is implementation dependent.
-
- @retval None
-
-**/
-EFI_STATUS
-EFIAPI
-AddSmbiosManuCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
-
- CHAR8 *OptionalStrStart;
- UINTN ManuStrLen;
- UINTN VerStrLen;
- UINTN PdNameStrLen;
- UINTN SerialNumStrLen;
- UINTN SkuNumberStrLen;
- UINTN FamilyNameStrLen;
- EFI_STATUS Status;
- EFI_STRING Manufacturer;
- EFI_STRING ProductName;
- EFI_STRING Version;
- EFI_STRING SerialNumber;
- EFI_STRING SkuNumber;
- EFI_STRING FamilyName;
- STRING_REF TokenToGet;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_TABLE_TYPE1 *SmbiosRecord;
- EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;
- EFI_SMBIOS_PROTOCOL *Smbios;
- CHAR16 Buffer[40];
-
- CHAR16 *MacStr;
- EFI_HANDLE *Handles;
- UINTN BufferSize;
- CHAR16 PlatformNameBuffer[40];
-
- ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)Context;
-
- //
- // First check for invalid parameters.
- //
- if (Context == NULL || mPlatformInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID *) &Smbios);
- ASSERT_EFI_ERROR (Status);
-
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- // Detect the board is Turbot board platform
- UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Turbot ");
- } else {
- UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Max ");
- }
-
- //
- // Silicon Steppings
- //
- switch (PchStepping()) {
- case PchA0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n"));
- break;
- case PchA1:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A1 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n"));
- break;
- case PchB0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n"));
- break;
- case PchB1:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B1 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n"));
- break;
- case PchB2:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B2 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n"));
- break;
- case PchB3:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B3 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n"));
- break;
- case PchC0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"C0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n"));
- break;
- case PchD0:
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"D0 PLATFORM");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
- UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
- DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n"));
- break;
- default:
- DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n"));
- break;
- }
-
- if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
- UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
- HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Buffer, NULL);
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);
- Manufacturer = SmbiosMiscGetString (TokenToGet);
- ManuStrLen = StrLen(Manufacturer);
- if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);
- ProductName = SmbiosMiscGetString (TokenToGet);
- PdNameStrLen = StrLen(ProductName);
- if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);
- Version = SmbiosMiscGetString (TokenToGet);
- VerStrLen = StrLen(Version);
- if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- //Get handle infomation
- //
- BufferSize = 0;
- Handles = NULL;
- Status = gBS->LocateHandle (
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
-
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Handles = AllocateZeroPool(BufferSize);
- if (Handles == NULL) {
- return (EFI_OUT_OF_RESOURCES);
- }
- Status = gBS->LocateHandle(
- ByProtocol,
- &gEfiSimpleNetworkProtocolGuid,
- NULL,
- &BufferSize,
- Handles
- );
- }
-
- //
- //Get the MAC string
- //
- Status = NetLibGetMacString (
- *Handles,
- NULL,
- &MacStr
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
- SerialNumber = MacStr;
- SerialNumStrLen = StrLen(SerialNumber);
- if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER);
- SkuNumber = SmbiosMiscGetString (TokenToGet);
- SkuNumberStrLen = StrLen(SkuNumber);
- if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
- TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1);
- FamilyName = SmbiosMiscGetString (TokenToGet);
- FamilyNameStrLen = StrLen(FamilyName);
- if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
- return EFI_UNSUPPORTED;
- }
-
- //
- // Two zeros following the last string.
- //
- SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
- ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
-
- SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;
- SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
-
- //
- // Make handle chosen by smbios protocol.add automatically.
- //
- SmbiosRecord->Hdr.Handle = 0;
-
- //
- // Manu will be the 1st optional string following the formatted structure.
- //
- SmbiosRecord->Manufacturer = 1;
-
- //
- // ProductName will be the 2nd optional string following the formatted structure.
- //
- SmbiosRecord->ProductName = 2;
-
- //
- // Version will be the 3rd optional string following the formatted structure.
- //
- SmbiosRecord->Version = 3;
-
- //
- // Version will be the 4th optional string following the formatted structure.
- //
- SmbiosRecord->SerialNumber = 4;
-
- SmbiosRecord->SKUNumber= 5;
- SmbiosRecord->Family= 6;
-
- //
- // Unique UUID
- //
- ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber);
- ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId);
-
- CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);
-
- SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;
-
- OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
- UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
- UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);
- UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);
- UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);
-
- UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
- UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1);
-
- //
- // Now we have got the full smbios record, call smbios protocol to add this record.
- //
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios-> Add(
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
- );
- FreePool(SmbiosRecord);
- return Status;
-}
-
-/**
- This function makes boot time changes to the contents of the
- MiscSystemManufacturer (Type 1).
-
- @param RecordData Pointer to copy of RecordData from the Data Table.
-
- @retval EFI_SUCCESS All parameters were valid.
- @retval EFI_UNSUPPORTED Unexpected RecordType value.
- @retval EFI_INVALID_PARAMETER Invalid parameter was found.
-
-**/
-MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
-{
- EFI_STATUS Status;
- static BOOLEAN CallbackIsInstalledManu = FALSE;
- VOID *AddSmbiosManuCallbackNotifyReg;
- EFI_EVENT AddSmbiosManuCallbackEvent;
-
-
- if (CallbackIsInstalledManu == FALSE) {
- CallbackIsInstalledManu = TRUE; // Prevent more than 1 callback.
- DEBUG ((EFI_D_INFO, "Create Smbios Manu callback.\n"));
-
- //
- // gEfiDxeSmmReadyToLockProtocolGuid is ready
- //
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- (EFI_EVENT_NOTIFY)AddSmbiosManuCallback,
- RecordData,
- &AddSmbiosManuCallbackEvent
- );
-
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
-
- }
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiDxeSmmReadyToLockProtocolGuid,
- AddSmbiosManuCallbackEvent,
- &AddSmbiosManuCallbackNotifyReg
- );
-
- return Status;
- }
-
- return EFI_SUCCESS;
-
-}
+/*++
+
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
+
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php.
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+
+Module Name:
+
+ MiscSystemManufacturerFunction.c
+
+Abstract:
+
+ This driver parses the mMiscSubclassDataTable structure and reports
+ any generated data.
+
+--*/
+
+
+#include "CommonHeader.h"
+#include "MiscSubclassDriver.h"
+#include <Protocol/DxeSmmReadyToLock.h>
+#include <Library/NetLib.h>
+#include "Library/DebugLib.h"
+#include <Uefi/UefiBaseType.h>
+#include <Guid/PlatformInfo.h>
+
+
+extern EFI_PLATFORM_INFO_HOB *mPlatformInfo;
+static EFI_SMBIOS_HANDLE mSmbiosHandleType1;
+
+
+EFI_STATUS
+EFIAPI
+UpdateSmbiosManuCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ UINTN BufferSize;
+ CHAR16 *MacStr;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ UINTN SerialNumberOffset;
+ CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH];
+
+ gBS->CloseEvent (Event); // Unload this event.
+
+ DEBUG ((EFI_D_INFO, "Executing UpdateSmbiosManuCallback.\n"));
+
+ //
+ //Get handle infomation
+ //
+ BufferSize = 0;
+ Handles = NULL;
+ Status = gBS->LocateHandle (
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Handles = AllocateZeroPool(BufferSize);
+ if (Handles == NULL) {
+ return (EFI_OUT_OF_RESOURCES);
+ }
+ Status = gBS->LocateHandle(
+ ByProtocol,
+ &gEfiSimpleNetworkProtocolGuid,
+ NULL,
+ &BufferSize,
+ Handles
+ );
+ }
+
+ //
+ //Get the MAC string
+ //
+ Status = NetLibGetMacString (
+ *Handles,
+ NULL,
+ &MacStr
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);
+ UnicodeStrToAsciiStr (MacStr, AsciiData);
+
+ Status = gBS->LocateProtocol (
+ &gEfiSmbiosProtocolGuid,
+ NULL,
+ (VOID *) &Smbios
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ SerialNumberOffset = 4;
+ Status = Smbios->UpdateString (
+ Smbios,
+ &mSmbiosHandleType1,
+ &SerialNumberOffset,
+ AsciiData
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+
+/**
+
+ Publish the smbios type 1.
+
+ @param Event Event whose notification function is being invoked (gEfiDxeSmmReadyToLockProtocolGuid).
+ @param Context Pointer to the notification functions context, which is implementation dependent.
+
+ @retval None
+
+**/
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
+{
+
+ CHAR8 *OptionalStrStart;
+ UINTN ManuStrLen;
+ UINTN VerStrLen;
+ UINTN PdNameStrLen;
+ UINTN SerialNumStrLen;
+ UINTN SkuNumberStrLen;
+ UINTN FamilyNameStrLen;
+ EFI_STATUS Status;
+ EFI_STRING Manufacturer;
+ EFI_STRING ProductName;
+ EFI_STRING Version;
+ EFI_STRING SerialNumber;
+ EFI_STRING SkuNumber;
+ EFI_STRING FamilyName;
+ STRING_REF TokenToGet;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_TABLE_TYPE1 *SmbiosRecord;
+ EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;
+ CHAR16 Buffer[40];
+ CHAR16 *MacStr;
+ CHAR16 PlatformNameBuffer[40];
+ VOID *UpdateSmbiosManuCallbackNotifyReg;
+ EFI_EVENT UpdateSmbiosManuCallbackEvent;
+ static BOOLEAN CallbackIsInstalledT1 = FALSE;
+
+ ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;
+ //
+ // First check for invalid parameters.
+ //
+ if (RecordData == NULL || mPlatformInfo == NULL) {
+ DEBUG ((EFI_D_INFO, "MISC_SMBIOS_TABLE_FUNCTION error.\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ //
+ // Detect the board is Turbot board platform
+ //
+ UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Turbot ");
+ } else {
+ UnicodeSPrint (PlatformNameBuffer, sizeof (PlatformNameBuffer),L"%s",L"Minnowboard Max ");
+ }
+
+ //
+ // Silicon Steppings
+ //
+ switch (PchStepping()) {
+ case PchA0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "A0 Stepping Detected\n"));
+ break;
+ case PchA1:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"A1 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"A1");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "A1 Stepping Detected\n"));
+ break;
+ case PchB0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B0 Stepping Detected\n"));
+ break;
+ case PchB1:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B1 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B1");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B1 Stepping Detected\n"));
+ break;
+ case PchB2:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B2 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B2");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B2 Stepping Detected\n"));
+ break;
+ case PchB3:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"B3 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"B3");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "B3 Stepping Detected\n"));
+ break;
+ case PchC0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"C0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"C0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "C0 Stepping Detected\n"));
+ break;
+ case PchD0:
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s%s", PlatformNameBuffer, L"D0 PLATFORM");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_PRODUCT_NAME), Buffer, NULL);
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"%s",L"D0");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_VERSION), Buffer, NULL);
+ DEBUG ((EFI_D_ERROR, "D0 Stepping Detected\n"));
+ break;
+ default:
+ DEBUG ((EFI_D_ERROR, "Unknow Stepping Detected\n"));
+ break;
+ }
+
+ if (BOARD_ID_MINNOW2_TURBOT == mPlatformInfo->BoardId) {
+ UnicodeSPrint (Buffer, sizeof (Buffer),L"ADI");
+ HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_SYSTEM_MANUFACTURER), Buffer, NULL);
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);
+ Manufacturer = SmbiosMiscGetString (TokenToGet);
+ ManuStrLen = StrLen(Manufacturer);
+ if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);
+ ProductName = SmbiosMiscGetString (TokenToGet);
+ PdNameStrLen = StrLen(ProductName);
+ if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);
+ Version = SmbiosMiscGetString (TokenToGet);
+ VerStrLen = StrLen(Version);
+ if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ MacStr = L"00000000";
+ SerialNumber = MacStr;
+ SerialNumStrLen = StrLen(SerialNumber);
+ if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER);
+ SkuNumber = SmbiosMiscGetString (TokenToGet);
+ SkuNumberStrLen = StrLen(SkuNumber);
+ if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY_NAME1);
+ FamilyName = SmbiosMiscGetString (TokenToGet);
+ FamilyNameStrLen = StrLen(FamilyName);
+ if (FamilyNameStrLen > SMBIOS_STRING_MAX_LENGTH) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Two zeros following the last string.
+ //
+ SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1);
+
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);
+
+ //
+ // Make handle chosen by smbios protocol.add automatically.
+ //
+ SmbiosRecord->Hdr.Handle = 0;
+
+ //
+ // Manu will be the 1st optional string following the formatted structure.
+ //
+ SmbiosRecord->Manufacturer = 1;
+
+ //
+ // ProductName will be the 2nd optional string following the formatted structure.
+ //
+ SmbiosRecord->ProductName = 2;
+
+ //
+ // Version will be the 3rd optional string following the formatted structure.
+ //
+ SmbiosRecord->Version = 3;
+
+ //
+ // Version will be the 4th optional string following the formatted structure.
+ //
+ SmbiosRecord->SerialNumber = 4;
+
+ SmbiosRecord->SKUNumber= 5;
+ SmbiosRecord->Family= 6;
+
+ //
+ // Unique UUID
+ //
+ ForType1InputData->SystemUuid.Data1 = PcdGet32 (PcdProductSerialNumber);
+ ForType1InputData->SystemUuid.Data4[0] = PcdGet8 (PcdEmmcManufacturerId);
+
+ CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);
+
+ SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;
+
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+ UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
+ UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);
+ UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);
+ UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);
+
+ UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+ UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1);
+
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios-> Add(
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
+ );
+ FreePool(SmbiosRecord);
+
+ //
+ // gEfiSimpleNetworkProtocolGuid is ready
+ //
+ if (CallbackIsInstalledT1 == FALSE) {
+ CallbackIsInstalledT1 = TRUE; // Prevent more than 1 callback.
+ DEBUG ((EFI_D_INFO, "Create Smbios Type1 callback.\n"));
+
+ mSmbiosHandleType1 = SmbiosHandle;
+ Status = gBS->CreateEvent (
+ EVT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ (EFI_EVENT_NOTIFY)UpdateSmbiosManuCallback,
+ RecordData,
+ &UpdateSmbiosManuCallbackEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ return Status;
+
+ }
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiSimpleNetworkProtocolGuid,
+ UpdateSmbiosManuCallbackEvent,
+ &UpdateSmbiosManuCallbackNotifyReg
+ );
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf b/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
index 332d237..f88dcbe 100644
--- a/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
+++ b/Vlv2TbltDevicePkg/SmBiosMiscDxe/SmBiosMiscDxe.inf
@@ -1,145 +1,146 @@
-## @file
-# Component name for module MiscSubclass
-#
-# FIX ME!
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
-#
-# This program and the accompanying materials are licensed and made available under
-# the terms and conditions of the BSD License that accompanies this distribution.
-# The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = MiscSubclass
- FILE_GUID = 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = MiscSubclassDriverEntryPoint
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC
-#
-
-[Sources]
- MiscBaseBoardManufacturer.uni
- MiscBaseBoardManufacturerData.c
- MiscBaseBoardManufacturerFunction.c
- MiscBiosVendor.uni
- MiscBiosVendorData.c
- MiscBiosVendorFunction.c
- MiscBootInformationData.c
- MiscBootInformationFunction.c
- MiscChassisManufacturer.uni
- MiscChassisManufacturerData.c
- MiscChassisManufacturerFunction.c
- MiscNumberOfInstallableLanguagesData.c
- MiscNumberOfInstallableLanguagesFunction.c
- MiscOemString.uni
- MiscOemStringData.c
- MiscOemStringFunction.c
- MiscOnboardDevice.uni
- MiscOnboardDeviceData.c
- MiscOnboardDeviceFunction.c
- MiscPortInternalConnectorDesignator.uni
- MiscPortInternalConnectorDesignatorData.c
- MiscPortInternalConnectorDesignatorFunction.c
- MiscResetCapabilitiesData.c
- MiscResetCapabilitiesFunction.c
- MiscSystemLanguageString.uni
- MiscSystemLanguageStringData.c
- MiscSystemLanguageStringFunction.c
- MiscSystemManufacturer.uni
- MiscSystemManufacturerData.c
- MiscSystemManufacturerFunction.c
- MiscSystemOptionString.uni
- MiscSystemOptionStringData.c
- MiscSystemOptionStringFunction.c
- MiscSystemSlotDesignation.uni
- MiscSystemSlotDesignationData.c
- MiscSystemSlotDesignationFunction.c
- MiscSubclassDriver.h
- MiscSubclassDriver.uni
- MiscSubclassDriverDataTable.c
- MiscSubclassDriverEntryPoint.c
- CommonHeader.h
- MiscOemType0x90Function.c
- MiscOemType0x90Data.c
- MiscOemType0x90.uni
- MiscProcessorInformation.uni
- MiscProcessorInformationData.c
- MiscProcessorInformationFunction.c
- MiscProcessorCache.uni
- MiscProcessorCacheData.c
- MiscProcessorCacheFunction.c
- MiscPhysicalArray.uni
- MiscPhysicalArrayData.c
- MiscPhysicalArrayFunction.c
- MiscMemoryDevice.uni
- MiscMemoryDeviceData.c
- MiscMemoryDeviceFunction.c
-
-[Packages]
- MdeModulePkg/MdeModulePkg.dec
- Vlv2TbltDevicePkg/PlatformPkg.dec
- MdePkg/MdePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
- Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
-
-[LibraryClasses]
- HiiLib
- DevicePathLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- DebugLib
- BaseLib
- MemoryAllocationLib
- PcdLib
- UefiLib
- BiosIdLib
- PrintLib
- CpuIA32Lib
- PchPlatformLib
- I2cLib
- NetLib
- HobLib
-
-[Guids]
- gEfiProcessorSubClassGuid
- gEfiCacheSubClassGuid
- gEfiNormalSetupGuid
- gEfiPlatformInfoGuid
- gEfiVlv2VariableGuid
-
-[Protocols]
- gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
- gEfiDataHubProtocolGuid
- gEfiMpServiceProtocolGuid
- gMemInfoProtocolGuid
- gEfiTdtOperationProtocolGuid
- gDxePchPlatformPolicyProtocolGuid
- gEfiSpiProtocolGuid
- gEfiSimpleNetworkProtocolGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
- gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
- gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId
- gEfiVLVTokenSpaceGuid.PcdProductSerialNumber
-
-[Depex]
- gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocolGuid AND gEfiSimpleNetworkProtocolGuid
+## @file
+# Component name for module MiscSubclass
+#
+# FIX ME!
+# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+#
+# This program and the accompanying materials are licensed and made available under
+# the terms and conditions of the BSD License that accompanies this distribution.
+# The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = MiscSubclass
+ FILE_GUID = 4EFFB560-B28B-4e57-9DAD-4344E32EA3BA
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = MiscSubclassDriverEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ MiscBaseBoardManufacturer.uni
+ MiscBaseBoardManufacturerData.c
+ MiscBaseBoardManufacturerFunction.c
+ MiscBiosVendor.uni
+ MiscBiosVendorData.c
+ MiscBiosVendorFunction.c
+ MiscBootInformationData.c
+ MiscBootInformationFunction.c
+ MiscChassisManufacturer.uni
+ MiscChassisManufacturerData.c
+ MiscChassisManufacturerFunction.c
+ MiscNumberOfInstallableLanguagesData.c
+ MiscNumberOfInstallableLanguagesFunction.c
+ MiscOemString.uni
+ MiscOemStringData.c
+ MiscOemStringFunction.c
+ MiscOnboardDevice.uni
+ MiscOnboardDeviceData.c
+ MiscOnboardDeviceFunction.c
+ MiscPortInternalConnectorDesignator.uni
+ MiscPortInternalConnectorDesignatorData.c
+ MiscPortInternalConnectorDesignatorFunction.c
+ MiscResetCapabilitiesData.c
+ MiscResetCapabilitiesFunction.c
+ MiscSystemLanguageString.uni
+ MiscSystemLanguageStringData.c
+ MiscSystemLanguageStringFunction.c
+ MiscSystemManufacturer.uni
+ MiscSystemManufacturerData.c
+ MiscSystemManufacturerFunction.c
+ MiscSystemOptionString.uni
+ MiscSystemOptionStringData.c
+ MiscSystemOptionStringFunction.c
+ MiscSystemSlotDesignation.uni
+ MiscSystemSlotDesignationData.c
+ MiscSystemSlotDesignationFunction.c
+ MiscSubclassDriver.h
+ MiscSubclassDriver.uni
+ MiscSubclassDriverDataTable.c
+ MiscSubclassDriverEntryPoint.c
+ CommonHeader.h
+ MiscOemType0x90Function.c
+ MiscOemType0x90Data.c
+ MiscOemType0x90.uni
+ MiscProcessorInformation.uni
+ MiscProcessorInformationData.c
+ MiscProcessorInformationFunction.c
+ MiscProcessorCache.uni
+ MiscProcessorCacheData.c
+ MiscProcessorCacheFunction.c
+ MiscPhysicalArray.uni
+ MiscPhysicalArrayData.c
+ MiscPhysicalArrayFunction.c
+ MiscMemoryDevice.uni
+ MiscMemoryDeviceData.c
+ MiscMemoryDeviceFunction.c
+
+[Packages]
+ MdeModulePkg/MdeModulePkg.dec
+ Vlv2TbltDevicePkg/PlatformPkg.dec
+ MdePkg/MdePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec
+
+[LibraryClasses]
+ HiiLib
+ DevicePathLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ BaseMemoryLib
+ DebugLib
+ BaseLib
+ MemoryAllocationLib
+ PcdLib
+ UefiLib
+ BiosIdLib
+ PrintLib
+ CpuIA32Lib
+ PchPlatformLib
+ I2cLib
+ NetLib
+ HobLib
+
+[Guids]
+ gEfiProcessorSubClassGuid
+ gEfiCacheSubClassGuid
+ gEfiNormalSetupGuid
+ gEfiPlatformInfoGuid
+ gEfiVlv2VariableGuid
+
+[Protocols]
+ gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL ALWAYS_CONSUMED
+ gEfiDataHubProtocolGuid
+ gEfiMpServiceProtocolGuid
+ gMemInfoProtocolGuid
+ gEfiTdtOperationProtocolGuid
+ gDxePchPlatformPolicyProtocolGuid
+ gEfiSpiProtocolGuid
+ gEfiSimpleNetworkProtocolGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareReleaseDateString
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+ gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang
+ gEfiVLVTokenSpaceGuid.PcdEmmcManufacturerId
+ gEfiVLVTokenSpaceGuid.PcdProductSerialNumber
+
+[Depex]
+ gEfiSmbiosProtocolGuid AND gMemInfoProtocolGuid AND gEfiMpServiceProtocolGuid
+
--
2.10.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-12 6:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-09 8:43 [PATCH][edk2-platforms/Minnowboard-max-udk2015] Vlv2TbltDevicePkg: Fixed Turbot 2 frontpage issue Guo, Mang
2016-12-12 6:19 ` Wei, David
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox