/**@file\r
\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
Module Name:\r
\r
\r
#include "MiscSubclassDriver.h"\r
\r
-BOOLEAN mDone = FALSE;\r
-\r
-//\r
-//\r
-//\r
-MISC_SUBCLASS_TABLE_FUNCTION (\r
- MiscSystemManufacturer\r
- )\r
-/*++\r
-Description:\r
-\r
+/**\r
This function makes boot time changes to the contents of the\r
- MiscSystemManufacturer (Type 13).\r
+ MiscSystemManufacturer (Type 1).\r
\r
-Parameters:\r
+ @param RecordData Pointer to copy of RecordData from the Data Table. \r
\r
- RecordType\r
- Type of record to be processed from the Data Table.\r
- mMiscSubclassDataTable[].RecordType\r
+ @retval EFI_SUCCESS All parameters were valid.\r
+ @retval EFI_UNSUPPORTED Unexpected RecordType value.\r
+ @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r
\r
- RecordLen\r
- Size of static RecordData from the Data Table.\r
- mMiscSubclassDataTable[].RecordLen\r
+**/\r
+MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)\r
+{\r
+ CHAR8 *OptionalStrStart;\r
+ UINTN ManuStrLen;\r
+ UINTN VerStrLen;\r
+ UINTN PdNameStrLen;\r
+ UINTN SerialNumStrLen;\r
+ EFI_STATUS Status;\r
+ EFI_STRING Manufacturer;\r
+ EFI_STRING ProductName;\r
+ EFI_STRING Version;\r
+ EFI_STRING SerialNumber;\r
+ STRING_REF TokenToGet;\r
+ EFI_SMBIOS_HANDLE SmbiosHandle;\r
+ SMBIOS_TABLE_TYPE1 *SmbiosRecord;\r
+ EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;\r
+\r
+ ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;\r
\r
- RecordData\r
- Pointer to copy of RecordData from the Data Table. Changes made\r
- to this copy will be written to the Data Hub but will not alter\r
- the contents of the static Data Table.\r
+ //\r
+ // First check for invalid parameters.\r
+ //\r
+ if (RecordData == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
\r
- LogRecordData\r
- Set *LogRecordData to TRUE to log RecordData to Data Hub.\r
- Set *LogRecordData to FALSE when there is no more data to log.\r
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);\r
+ Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+ ManuStrLen = StrLen(Manufacturer);\r
+ if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
-Returns:\r
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);\r
+ ProductName = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+ PdNameStrLen = StrLen(ProductName);\r
+ if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
- EFI_SUCCESS\r
- All parameters were valid and *RecordData and *LogRecordData have\r
- been set.\r
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);\r
+ Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+ VerStrLen = StrLen(Version);\r
+ if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
\r
- EFI_UNSUPPORTED\r
- Unexpected RecordType value.\r
+ TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER);\r
+ SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+ SerialNumStrLen = StrLen(SerialNumber);\r
+ if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ //\r
+ // Two zeros following the last string.\r
+ //\r
+ SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
\r
- EFI_INVALID_PARAMETER\r
- One of the following parameter conditions was true:\r
- RecordLen was zero.\r
- RecordData was NULL.\r
- LogRecordData was NULL.\r
---*/\r
-{\r
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
//\r
- // First check for invalid parameters.\r
+ // Make handle chosen by smbios protocol.add automatically.\r
+ // \r
+ SmbiosRecord->Hdr.Handle = 0; \r
//\r
- if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ // Manu will be the 1st optional string following the formatted structure.\r
//\r
- // Then check for unsupported RecordType.\r
+ SmbiosRecord->Manufacturer = 1;\r
//\r
- if (RecordType != EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER) {\r
- return EFI_UNSUPPORTED;\r
- }\r
+ // ProductName will be the 2nd optional string following the formatted structure.\r
//\r
- // Is this the first time through this function?\r
+ SmbiosRecord->ProductName = 2; \r
//\r
- if (!mDone) {\r
- //\r
- // Yes, this is the first time. Inspect/Change the contents of the\r
- // RecordData structure.\r
- //\r
- //\r
- // Set system GUID.\r
- //\r
- // ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemUuid = %%TBD\r
- //\r
- // Set power-on type.\r
- //\r
- // ((EFI_MISC_SYSTEM_MANUFACTURER_DATA *)RecordData)->SystemWakeupType = %%TBD\r
- //\r
- // Set mDone flag to TRUE for next pass through this function.\r
- // Set *LogRecordData to TRUE so data will get logged to Data Hub.\r
- //\r
- mDone = TRUE;\r
- *LogRecordData = TRUE;\r
- } else {\r
- //\r
- // No, this is the second time. Reset the state of the mDone flag\r
- // to FALSE and tell the data logger that there is no more data\r
- // to be logged for this record type. If any memory allocations\r
- // were made by earlier passes, they must be released now.\r
- //\r
- mDone = FALSE;\r
- *LogRecordData = FALSE;\r
- }\r
+ // Version will be the 3rd optional string following the formatted structure. \r
+ //\r
+ SmbiosRecord->Version = 3; \r
+ //\r
+ // Version will be the 4th optional string following the formatted structure.\r
+ //\r
+ SmbiosRecord->SerialNumber = 4;\r
+ CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);\r
+ SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;\r
+\r
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+ UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
+ UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);\r
+ UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);\r
+ UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);\r
+\r
+ //\r
+ // Now we have got the full smbios record, call smbios protocol to add this record.\r
+ //\r
+ Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
\r
- return EFI_SUCCESS;\r
+ FreePool(SmbiosRecord);\r
+ return Status;\r
}\r
\r
/* eof - MiscSystemManufacturerFunction.c */\r