3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 MiscSystemManufacturerFunction.c
12 This driver parses the mMiscSubclassDataTable structure and reports
13 any generated data to the DataHub.
17 #include "MiscSubClassDriver.h"
20 This function makes boot time changes to the contents of the
21 MiscSystemManufacturer (Type 1).
23 @param RecordData Pointer to copy of RecordData from the Data Table.
25 @retval EFI_SUCCESS All parameters were valid.
26 @retval EFI_UNSUPPORTED Unexpected RecordType value.
27 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
30 MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer
)
32 CHAR8
*OptionalStrStart
;
36 UINTN SerialNumStrLen
;
38 EFI_STRING Manufacturer
;
39 EFI_STRING ProductName
;
41 EFI_STRING SerialNumber
;
42 STRING_REF TokenToGet
;
43 EFI_SMBIOS_HANDLE SmbiosHandle
;
44 SMBIOS_TABLE_TYPE1
*SmbiosRecord
;
45 EFI_MISC_SYSTEM_MANUFACTURER
*ForType1InputData
;
47 ForType1InputData
= (EFI_MISC_SYSTEM_MANUFACTURER
*)RecordData
;
50 // First check for invalid parameters.
52 if (RecordData
== NULL
) {
53 return EFI_INVALID_PARAMETER
;
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
;
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
;
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
;
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
;
84 // Two zeros following the last string.
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);
89 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_INFORMATION
;
90 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE1
);
92 // Make handle chosen by smbios protocol.add automatically.
94 SmbiosRecord
->Hdr
.Handle
= 0;
96 // Manu will be the 1st optional string following the formatted structure.
98 SmbiosRecord
->Manufacturer
= 1;
100 // ProductName will be the 2nd optional string following the formatted structure.
102 SmbiosRecord
->ProductName
= 2;
104 // Version will be the 3rd optional string following the formatted structure.
106 SmbiosRecord
->Version
= 3;
108 // Version will be the 4th optional string following the formatted structure.
110 SmbiosRecord
->SerialNumber
= 4;
111 CopyMem ((UINT8
*) (&SmbiosRecord
->Uuid
),&ForType1InputData
->SystemUuid
,16);
112 SmbiosRecord
->WakeUpType
= (UINT8
)ForType1InputData
->SystemWakeupType
;
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);
121 // Now we have got the full smbios record, call smbios protocol to add this record.
123 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
125 FreePool(SmbiosRecord
);
129 /* eof - MiscSystemManufacturerFunction.c */