]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c
According to PI errata 0000654 and 000811, we need use 0xFFFE to instead of 0 for...
[mirror_edk2.git] / EmulatorPkg / MiscSubClassPlatformDxe / MiscSystemManufacturerFunction.c
CommitLineData
949f388f 1/*++\r
2\r
2bfd90f9 3Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
d18d8a1d 4This program and the accompanying materials\r
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
949f388f 11\r
12Module Name:\r
13\r
14 MiscSystemManufacturerFunction.c\r
d18d8a1d 15\r
16Abstract:\r
949f388f 17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
21**/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
25/**\r
26 This function makes boot time changes to the contents of the\r
27 MiscSystemManufacturer (Type 1).\r
28\r
d18d8a1d 29 @param RecordData Pointer to copy of RecordData from the Data Table.\r
949f388f 30\r
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
34\r
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
54\r
55 //\r
56 // First check for invalid parameters.\r
57 //\r
58 if (RecordData == NULL) {\r
59 return EFI_INVALID_PARAMETER;\r
60 }\r
61\r
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
68\r
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
75\r
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
82\r
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
94\r
95 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
96 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
97 //\r
98 // Make handle chosen by smbios protocol.add automatically.\r
d18d8a1d 99 //\r
100 SmbiosRecord->Hdr.Handle = 0;\r
949f388f 101 //\r
102 // Manu will be the 1st optional string following the formatted structure.\r
103 //\r
104 SmbiosRecord->Manufacturer = 1;\r
105 //\r
106 // ProductName will be the 2nd optional string following the formatted structure.\r
107 //\r
d18d8a1d 108 SmbiosRecord->ProductName = 2;\r
949f388f 109 //\r
d18d8a1d 110 // Version will be the 3rd optional string following the formatted structure.\r
949f388f 111 //\r
d18d8a1d 112 SmbiosRecord->Version = 3;\r
949f388f 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
125\r
126 //\r
127 // Now we have got the full smbios record, call smbios protocol to add this record.\r
128 //\r
2bfd90f9
SZ
129 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
130\r
949f388f 131 FreePool(SmbiosRecord);\r
132 return Status;\r
133}\r
134\r
135/* eof - MiscSystemManufacturerFunction.c */\r