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