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