3 Copyright (c) 2009, Intel Corporation. All rights reserved. <BR>
4 This software and associated documentation (if any) is furnished
5 under a license and may only be used or copied in accordance
6 with the terms of the license. Except as permitted by such
7 license, no part of this software or documentation may be
8 reproduced, stored in a retrieval system, or transmitted in any
9 form or by any means without the express written consent of
15 MiscBaseBoardManufacturerFunction.c
19 BaseBoard manufacturer information boot time changes.
24 #include "MiscSubclassDriver.h"
26 This function makes boot time changes to the contents of the
27 MiscBaseBoardManufacturer (Type 2).
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(MiscBaseBoardManufacturer
)
38 CHAR8
*OptionalStrStart
;
42 UINTN AssertTagStrLen
;
43 UINTN SerialNumStrLen
;
46 EFI_STRING Manufacturer
;
49 EFI_STRING SerialNumber
;
52 STRING_REF TokenToGet
;
53 EFI_SMBIOS_HANDLE SmbiosHandle
;
54 SMBIOS_TABLE_TYPE2
*SmbiosRecord
;
55 EFI_MISC_BASE_BOARD_MANUFACTURER
*ForType2InputData
;
57 ForType2InputData
= (EFI_MISC_BASE_BOARD_MANUFACTURER
*)RecordData
;
60 // First check for invalid parameters.
62 if (RecordData
== NULL
) {
63 return EFI_INVALID_PARAMETER
;
66 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER
);
67 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
68 ManuStrLen
= StrLen(Manufacturer
);
69 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
70 return EFI_UNSUPPORTED
;
73 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME
);
74 Product
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
75 ProductStrLen
= StrLen(Product
);
76 if (ProductStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
77 return EFI_UNSUPPORTED
;
80 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION
);
81 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
82 VerStrLen
= StrLen(Version
);
83 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
84 return EFI_UNSUPPORTED
;
87 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER
);
88 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
89 SerialNumStrLen
= StrLen(SerialNumber
);
90 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
91 return EFI_UNSUPPORTED
;
94 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG
);
95 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
96 AssertTagStrLen
= StrLen(AssertTag
);
97 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
98 return EFI_UNSUPPORTED
;
101 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION
);
102 Chassis
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
103 ChassisStrLen
= StrLen(Chassis
);
104 if (ChassisStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
105 return EFI_UNSUPPORTED
;
110 // Two zeros following the last string.
112 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
113 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
115 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION
;
116 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE2
);
118 // Make handle chosen by smbios protocol.add automatically.
120 SmbiosRecord
->Hdr
.Handle
= 0;
122 // Manu will be the 1st optional string following the formatted structure.
124 SmbiosRecord
->Manufacturer
= 1;
126 // ProductName will be the 2st optional string following the formatted structure.
128 SmbiosRecord
->ProductName
= 2;
130 // Version will be the 3rd optional string following the formatted structure.
132 SmbiosRecord
->Version
= 3;
134 // SerialNumber will be the 4th optional string following the formatted structure.
136 SmbiosRecord
->SerialNumber
= 4;
138 // AssertTag will be the 5th optional string following the formatted structure.
140 SmbiosRecord
->AssetTag
= 5;
143 // LocationInChassis will be the 6th optional string following the formatted structure.
145 SmbiosRecord
->LocationInChassis
= 6;
146 SmbiosRecord
->FeatureFlag
= (*(BASE_BOARD_FEATURE_FLAGS
*)&(ForType2InputData
->BaseBoardFeatureFlags
));
147 SmbiosRecord
->ChassisHandle
= 0;
148 SmbiosRecord
->BoardType
= (UINT8
)ForType2InputData
->BaseBoardType
;
149 SmbiosRecord
->NumberOfContainedObjectHandles
= 0;
151 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
153 // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
155 OptionalStrStart
-= 2;
156 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
157 UnicodeStrToAsciiStr(Product
, OptionalStrStart
+ ManuStrLen
+ 1);
158 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1);
159 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1);
160 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
161 UnicodeStrToAsciiStr(Chassis
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1);
163 // Now we have got the full smbios record, call smbios protocol to add this record.
166 Status
= Smbios
-> Add(
170 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
173 FreePool(SmbiosRecord
);