]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c
Fix help command scroll issue. Also add FV space used, and free space to dir command.
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscSystemManufacturerFunction.c
CommitLineData
804405e7 1/*++\r
2\r
aaa2cc19 3Copyright (c) 2006 - 2009, Intel Corporation \r
804405e7 4All rights reserved. This 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
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
21--*/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
aaa2cc19 25/**\r
804405e7 26 This function makes boot time changes to the contents of the\r
aaa2cc19 27 MiscSystemManufacturer (Type 1).\r
804405e7 28\r
aaa2cc19 29 @param RecordData Pointer to copy of RecordData from the Data Table. \r
804405e7 30\r
aaa2cc19 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
804405e7 34\r
aaa2cc19 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
804405e7 54\r
aaa2cc19 55 //\r
56 // First check for invalid parameters.\r
57 //\r
58 if (RecordData == NULL) {\r
59 return EFI_INVALID_PARAMETER;\r
60 }\r
804405e7 61\r
aaa2cc19 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
804405e7 68\r
aaa2cc19 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
804405e7 75\r
aaa2cc19 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
804405e7 82\r
aaa2cc19 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
804405e7 94\r
aaa2cc19 95 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_INFORMATION;\r
96 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE1);\r
804405e7 97 //\r
aaa2cc19 98 // Make handle chosen by smbios protocol.add automatically.\r
99 // \r
100 SmbiosRecord->Hdr.Handle = 0; \r
804405e7 101 //\r
aaa2cc19 102 // Manu will be the 1st optional string following the formatted structure.\r
804405e7 103 //\r
aaa2cc19 104 SmbiosRecord->Manufacturer = 1;\r
804405e7 105 //\r
aaa2cc19 106 // ProductName will be the 2nd optional string following the formatted structure.\r
804405e7 107 //\r
aaa2cc19 108 SmbiosRecord->ProductName = 2; \r
804405e7 109 //\r
aaa2cc19 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
804405e7 125\r
aaa2cc19 126 //\r
127 // Now we have got the full smbios record, call smbios protocol to add this record.\r
128 //\r
129 SmbiosHandle = 0;\r
130 Status = Smbios-> Add(\r
131 Smbios, \r
132 NULL,\r
133 &SmbiosHandle, \r
134 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
135 );\r
136 FreePool(SmbiosRecord);\r
137 return Status;\r
804405e7 138}\r
139\r
140/* eof - MiscSystemManufacturerFunction.c */\r