]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscSystemManufacturerFunction.c
CommitLineData
6ae81428 1/**@file\r
8879d432 2\r
7ee85aa2 3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
8f2a5f80 4This program and the accompanying materials \r
8879d432 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 MiscSystemManufacturerFunction.c\r
15 \r
16Abstract: \r
17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
6ae81428 21**/\r
8879d432 22\r
8879d432 23#include "MiscSubclassDriver.h"\r
24\r
1fdd39d3 25/**\r
8879d432 26 This function makes boot time changes to the contents of the\r
1fdd39d3 27 MiscSystemManufacturer (Type 1).\r
8879d432 28\r
1fdd39d3 29 @param RecordData Pointer to copy of RecordData from the Data Table. \r
8879d432 30\r
1fdd39d3 31 @retval EFI_SUCCESS All parameters were valid.\r
32 @retval EFI_UNSUPPORTED Unexpected RecordType value.\r
33 @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r
8879d432 34\r
1fdd39d3 35**/\r
36MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)\r
37{\r
38 CHAR8 *OptionalStrStart;\r
39 UINTN ManuStrLen;\r
40 UINTN VerStrLen;\r
41 UINTN PdNameStrLen;\r
42 UINTN SerialNumStrLen;\r
43 EFI_STATUS Status;\r
44 EFI_STRING Manufacturer;\r
45 EFI_STRING ProductName;\r
46 EFI_STRING Version;\r
47 EFI_STRING SerialNumber;\r
48 STRING_REF TokenToGet;\r
49 EFI_SMBIOS_HANDLE SmbiosHandle;\r
50 SMBIOS_TABLE_TYPE1 *SmbiosRecord;\r
51 EFI_MISC_SYSTEM_MANUFACTURER *ForType1InputData;\r
52\r
53 ForType1InputData = (EFI_MISC_SYSTEM_MANUFACTURER *)RecordData;\r
8879d432 54\r
1fdd39d3 55 //\r
56 // First check for invalid parameters.\r
57 //\r
58 if (RecordData == NULL) {\r
59 return EFI_INVALID_PARAMETER;\r
60 }\r
8879d432 61\r
1fdd39d3 62 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);\r
63 Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
64 ManuStrLen = StrLen(Manufacturer);\r
65 if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
66 return EFI_UNSUPPORTED;\r
67 }\r
8879d432 68\r
1fdd39d3 69 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);\r
70 ProductName = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
71 PdNameStrLen = StrLen(ProductName);\r
72 if (PdNameStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
73 return EFI_UNSUPPORTED;\r
74 }\r
8879d432 75\r
1fdd39d3 76 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);\r
77 Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
78 VerStrLen = StrLen(Version);\r
79 if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
80 return EFI_UNSUPPORTED;\r
81 }\r
8879d432 82\r
1fdd39d3 83 TokenToGet = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER);\r
84 SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
85 SerialNumStrLen = StrLen(SerialNumber);\r
86 if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
87 return EFI_UNSUPPORTED;\r
88 }\r
89 //\r
90 // Two zeros following the last string.\r
91 //\r
92 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
93 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 1);\r
8879d432 94\r
1fdd39d3 95 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
96 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
8879d432 97 //\r
1fdd39d3 98 // Make handle chosen by smbios protocol.add automatically.\r
99 // \r
100 SmbiosRecord->Hdr.Handle = 0; \r
8879d432 101 //\r
1fdd39d3 102 // Manu will be the 1st optional string following the formatted structure.\r
8879d432 103 //\r
1fdd39d3 104 SmbiosRecord->Manufacturer = 1;\r
8879d432 105 //\r
1fdd39d3 106 // ProductName will be the 2nd optional string following the formatted structure.\r
8879d432 107 //\r
1fdd39d3 108 SmbiosRecord->ProductName = 2; \r
8879d432 109 //\r
1fdd39d3 110 // Version will be the 3rd optional string following the formatted structure. \r
111 //\r
112 SmbiosRecord->Version = 3; \r
113 //\r
114 // Version will be the 4th optional string following the formatted structure.\r
115 //\r
116 SmbiosRecord->SerialNumber = 4;\r
117 CopyMem ((UINT8 *) (&SmbiosRecord->Uuid),&ForType1InputData->SystemUuid,16);\r
118 SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;\r
119\r
120 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
121 UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
122 UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1);\r
123 UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);\r
124 UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);\r
8879d432 125\r
1fdd39d3 126 //\r
127 // Now we have got the full smbios record, call smbios protocol to add this record.\r
128 //\r
7ee85aa2
SZ
129 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
130\r
1fdd39d3 131 FreePool(SmbiosRecord);\r
132 return Status;\r
8879d432 133}\r
134\r
135/* eof - MiscSystemManufacturerFunction.c */\r