2 BaseBoard manufacturer information boot time changes.
5 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "MiscSubclassDriver.h"
18 This function makes boot time changes to the contents of the
19 MiscBaseBoardManufacturer (Type 2).
21 @param RecordData Pointer to copy of RecordData from the Data Table.
23 @retval EFI_SUCCESS All parameters were valid.
24 @retval EFI_UNSUPPORTED Unexpected RecordType value.
25 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
28 MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer
)
30 CHAR8
*OptionalStrStart
;
34 UINTN AssertTagStrLen
;
35 UINTN SerialNumStrLen
;
38 EFI_STRING Manufacturer
;
41 EFI_STRING SerialNumber
;
44 STRING_REF TokenToGet
;
45 EFI_SMBIOS_HANDLE SmbiosHandle
;
46 SMBIOS_TABLE_TYPE2
*SmbiosRecord
;
47 EFI_MISC_BASE_BOARD_MANUFACTURER
*ForType2InputData
;
49 ForType2InputData
= (EFI_MISC_BASE_BOARD_MANUFACTURER
*)RecordData
;
52 // First check for invalid parameters.
54 if (RecordData
== NULL
) {
55 return EFI_INVALID_PARAMETER
;
58 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER
);
59 Manufacturer
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
60 ManuStrLen
= StrLen(Manufacturer
);
61 if (ManuStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
62 return EFI_UNSUPPORTED
;
65 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME
);
66 Product
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
67 ProductStrLen
= StrLen(Product
);
68 if (ProductStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
69 return EFI_UNSUPPORTED
;
72 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION
);
73 Version
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
74 VerStrLen
= StrLen(Version
);
75 if (VerStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
76 return EFI_UNSUPPORTED
;
79 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER
);
80 SerialNumber
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
81 SerialNumStrLen
= StrLen(SerialNumber
);
82 if (SerialNumStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
83 return EFI_UNSUPPORTED
;
86 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG
);
87 AssertTag
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
88 AssertTagStrLen
= StrLen(AssertTag
);
89 if (AssertTagStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
90 return EFI_UNSUPPORTED
;
93 TokenToGet
= STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION
);
94 Chassis
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenToGet
, NULL
);
95 ChassisStrLen
= StrLen(Chassis
);
96 if (ChassisStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
97 return EFI_UNSUPPORTED
;
102 // Two zeros following the last string.
104 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
105 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE3
) + ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1 + ChassisStrLen
+1 + 1);
107 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION
;
108 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE2
);
110 // Make handle chosen by smbios protocol.add automatically.
112 SmbiosRecord
->Hdr
.Handle
= 0;
114 // Manu will be the 1st optional string following the formatted structure.
116 SmbiosRecord
->Manufacturer
= 1;
118 // ProductName will be the 2st optional string following the formatted structure.
120 SmbiosRecord
->ProductName
= 2;
122 // Version will be the 3rd optional string following the formatted structure.
124 SmbiosRecord
->Version
= 3;
126 // SerialNumber will be the 4th optional string following the formatted structure.
128 SmbiosRecord
->SerialNumber
= 4;
130 // AssertTag will be the 5th optional string following the formatted structure.
132 SmbiosRecord
->AssetTag
= 5;
135 // LocationInChassis will be the 6th optional string following the formatted structure.
137 SmbiosRecord
->LocationInChassis
= 6;
138 SmbiosRecord
->FeatureFlag
= (*(BASE_BOARD_FEATURE_FLAGS
*)&(ForType2InputData
->BaseBoardFeatureFlags
));
139 SmbiosRecord
->ChassisHandle
= 0;
140 SmbiosRecord
->BoardType
= (UINT8
)ForType2InputData
->BaseBoardType
;
141 SmbiosRecord
->NumberOfContainedObjectHandles
= 0;
143 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
145 // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
147 OptionalStrStart
-= 2;
148 UnicodeStrToAsciiStr(Manufacturer
, OptionalStrStart
);
149 UnicodeStrToAsciiStr(Product
, OptionalStrStart
+ ManuStrLen
+ 1);
150 UnicodeStrToAsciiStr(Version
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1);
151 UnicodeStrToAsciiStr(SerialNumber
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1);
152 UnicodeStrToAsciiStr(AssertTag
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1);
153 UnicodeStrToAsciiStr(Chassis
, OptionalStrStart
+ ManuStrLen
+ 1 + ProductStrLen
+ 1 + VerStrLen
+ 1 + SerialNumStrLen
+ 1 + AssertTagStrLen
+ 1);
155 // Now we have got the full smbios record, call smbios protocol to add this record.
158 Status
= Smbios
-> Add(
162 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
165 FreePool(SmbiosRecord
);