3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 MiscSystemManufacturerFunction.c
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
23 #include "MiscSubClassDriver.h"
26 This function makes boot time changes to the contents of the
27 MiscSystemManufacturer (Type 1).
29 @param RecordData Pointer to copy of RecordData from the Data Table.
31 @retval EFI_SUCCESS All parameters were valid.
32 @retval EFI_UNSUPPORTED Unexpected RecordType value.
33 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
36 MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer
)
38 CHAR8
*OptionalStrStart
;
42 UINTN SerialNumStrLen
;
44 EFI_STRING Manufacturer
;
45 EFI_STRING ProductName
;
47 EFI_STRING SerialNumber
;
48 STRING_REF TokenToGet
;
49 EFI_SMBIOS_HANDLE SmbiosHandle
;
50 SMBIOS_TABLE_TYPE1
*SmbiosRecord
;
51 EFI_MISC_SYSTEM_MANUFACTURER
*ForType1InputData
;
53 ForType1InputData
= (EFI_MISC_SYSTEM_MANUFACTURER
*)RecordData
;
56 // First check for invalid parameters.
58 if (RecordData
== NULL
) {
59 return EFI_INVALID_PARAMETER
;
62 TokenToGet
= STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER
);
63 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
64 ManuStrLen
= StrLen(Manufacturer
);
65 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
66 return EFI_UNSUPPORTED
;
69 TokenToGet
= STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME
);
70 ProductName
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
71 PdNameStrLen
= StrLen(ProductName
);
72 if (PdNameStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
73 return EFI_UNSUPPORTED
;
76 TokenToGet
= STRING_TOKEN (STR_MISC_SYSTEM_VERSION
);
77 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
78 VerStrLen
= StrLen(Version
);
79 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
80 return EFI_UNSUPPORTED
;
83 TokenToGet
= STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER
);
84 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
85 SerialNumStrLen
= StrLen(SerialNumber
);
86 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
87 return EFI_UNSUPPORTED
;
90 // Two zeros following the last string.
92 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE1
) + ManuStrLen
+ 1 + PdNameStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + 1);
93 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE1
) + ManuStrLen
+ 1 + PdNameStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + 1);
95 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_SYSTEM_INFORMATION
;
96 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE1
);
98 // Make handle chosen by smbios protocol.add automatically.
100 SmbiosRecord
->Hdr
.Handle
= 0;
102 // Manu will be the 1st optional string following the formatted structure.
104 SmbiosRecord
->Manufacturer
= 1;
106 // ProductName will be the 2nd optional string following the formatted structure.
108 SmbiosRecord
->ProductName
= 2;
110 // Version will be the 3rd optional string following the formatted structure.
112 SmbiosRecord
->Version
= 3;
114 // Version will be the 4th optional string following the formatted structure.
116 SmbiosRecord
->SerialNumber
= 4;
117 CopyMem ((UINT8
*) (&SmbiosRecord
->Uuid
),&ForType1InputData
->SystemUuid
,16);
118 SmbiosRecord
->WakeUpType
= (UINT8
)ForType1InputData
->SystemWakeupType
;
120 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
121 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
122 UnicodeStrToAsciiStr(ProductName
, OptionalStrStart
+ ManuStrLen
+ 1);
123 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + PdNameStrLen
+ 1);
124 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + PdNameStrLen
+ 1 + VerStrLen
+ 1);
127 // Now we have got the full smbios record, call smbios protocol to add this record.
129 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
131 FreePool(SmbiosRecord
);
135 /* eof - MiscSystemManufacturerFunction.c */