]>
Commit | Line | Data |
---|---|---|
1fdd39d3 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2009, Intel Corporation. All rights reserved. <BR> \r | |
4 | This software and associated documentation (if any) is furnished\r | |
5 | under a license and may only be used or copied in accordance\r | |
6 | with the terms of the license. Except as permitted by such\r | |
7 | license, no part of this software or documentation may be\r | |
8 | reproduced, stored in a retrieval system, or transmitted in any\r | |
9 | form or by any means without the express written consent of\r | |
10 | Intel Corporation.\r | |
11 | \r | |
12 | \r | |
13 | Module Name:\r | |
14 | \r | |
15 | MiscBaseBoardManufacturerFunction.c\r | |
16 | \r | |
17 | Abstract: \r | |
18 | \r | |
19 | BaseBoard manufacturer information boot time changes.\r | |
20 | SMBIOS type 2.\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
24 | #include "MiscSubclassDriver.h"\r | |
25 | /**\r | |
26 | This function makes boot time changes to the contents of the\r | |
27 | MiscBaseBoardManufacturer (Type 2).\r | |
28 | \r | |
29 | @param RecordData Pointer to copy of RecordData from the Data Table. \r | |
30 | \r | |
31 | @retval EFI_SUCCESS All parameters were valid.\r | |
32 | @retval EFI_UNSUPPORTED Unexpected RecordType value.\r | |
33 | @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r | |
34 | \r | |
35 | **/\r | |
36 | MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)\r | |
37 | {\r | |
38 | CHAR8 *OptionalStrStart;\r | |
39 | UINTN ManuStrLen;\r | |
40 | UINTN ProductStrLen;\r | |
41 | UINTN VerStrLen;\r | |
42 | UINTN AssertTagStrLen;\r | |
43 | UINTN SerialNumStrLen;\r | |
44 | UINTN ChassisStrLen;\r | |
45 | EFI_STATUS Status;\r | |
46 | EFI_STRING Manufacturer;\r | |
47 | EFI_STRING Product;\r | |
48 | EFI_STRING Version;\r | |
49 | EFI_STRING SerialNumber;\r | |
50 | EFI_STRING AssertTag;\r | |
51 | EFI_STRING Chassis;\r | |
52 | STRING_REF TokenToGet;\r | |
53 | EFI_SMBIOS_HANDLE SmbiosHandle;\r | |
54 | SMBIOS_TABLE_TYPE2 *SmbiosRecord;\r | |
55 | EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;\r | |
56 | \r | |
57 | ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;\r | |
58 | \r | |
59 | //\r | |
60 | // First check for invalid parameters.\r | |
61 | //\r | |
62 | if (RecordData == NULL) {\r | |
63 | return EFI_INVALID_PARAMETER;\r | |
64 | }\r | |
65 | \r | |
66 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER);\r | |
67 | Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
68 | ManuStrLen = StrLen(Manufacturer);\r | |
69 | if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
70 | return EFI_UNSUPPORTED;\r | |
71 | }\r | |
72 | \r | |
73 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME);\r | |
74 | Product = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
75 | ProductStrLen = StrLen(Product);\r | |
76 | if (ProductStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
77 | return EFI_UNSUPPORTED;\r | |
78 | }\r | |
79 | \r | |
80 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION);\r | |
81 | Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
82 | VerStrLen = StrLen(Version);\r | |
83 | if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
84 | return EFI_UNSUPPORTED;\r | |
85 | }\r | |
86 | \r | |
87 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER);\r | |
88 | SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
89 | SerialNumStrLen = StrLen(SerialNumber);\r | |
90 | if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
91 | return EFI_UNSUPPORTED;\r | |
92 | }\r | |
93 | \r | |
94 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);\r | |
95 | AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
96 | AssertTagStrLen = StrLen(AssertTag);\r | |
97 | if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
98 | return EFI_UNSUPPORTED;\r | |
99 | }\r | |
100 | \r | |
101 | TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION);\r | |
102 | Chassis = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
103 | ChassisStrLen = StrLen(Chassis);\r | |
104 | if (ChassisStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
105 | return EFI_UNSUPPORTED;\r | |
106 | }\r | |
107 | \r | |
108 | \r | |
109 | //\r | |
110 | // Two zeros following the last string.\r | |
111 | //\r | |
112 | SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r | |
113 | ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r | |
114 | \r | |
115 | SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;\r | |
116 | SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);\r | |
117 | //\r | |
118 | // Make handle chosen by smbios protocol.add automatically.\r | |
119 | //\r | |
120 | SmbiosRecord->Hdr.Handle = 0; \r | |
121 | //\r | |
122 | // Manu will be the 1st optional string following the formatted structure.\r | |
123 | // \r | |
124 | SmbiosRecord->Manufacturer = 1; \r | |
125 | //\r | |
126 | // ProductName will be the 2st optional string following the formatted structure.\r | |
127 | // \r | |
128 | SmbiosRecord->ProductName = 2; \r | |
129 | //\r | |
130 | // Version will be the 3rd optional string following the formatted structure.\r | |
131 | //\r | |
132 | SmbiosRecord->Version = 3; \r | |
133 | //\r | |
134 | // SerialNumber will be the 4th optional string following the formatted structure.\r | |
135 | //\r | |
136 | SmbiosRecord->SerialNumber = 4; \r | |
137 | //\r | |
138 | // AssertTag will be the 5th optional string following the formatted structure.\r | |
139 | //\r | |
140 | SmbiosRecord->AssetTag = 5; \r | |
141 | \r | |
142 | //\r | |
143 | // LocationInChassis will be the 6th optional string following the formatted structure.\r | |
144 | //\r | |
145 | SmbiosRecord->LocationInChassis = 6; \r | |
146 | SmbiosRecord->FeatureFlag = (*(BASE_BOARD_FEATURE_FLAGS*)&(ForType2InputData->BaseBoardFeatureFlags));\r | |
147 | SmbiosRecord->ChassisHandle = 0;\r | |
148 | SmbiosRecord->BoardType = (UINT8)ForType2InputData->BaseBoardType;\r | |
149 | SmbiosRecord->NumberOfContainedObjectHandles = 0;\r | |
150 | \r | |
151 | OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r | |
152 | //\r | |
153 | // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string\r | |
154 | //\r | |
155 | OptionalStrStart -= 2;\r | |
156 | UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r | |
157 | UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);\r | |
158 | UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);\r | |
159 | UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);\r | |
160 | UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r | |
161 | UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);\r | |
162 | //\r | |
163 | // Now we have got the full smbios record, call smbios protocol to add this record.\r | |
164 | //\r | |
165 | SmbiosHandle = 0;\r | |
166 | Status = Smbios-> Add(\r | |
167 | Smbios, \r | |
168 | NULL,\r | |
169 | &SmbiosHandle, \r | |
170 | (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r | |
171 | );\r | |
172 | \r | |
173 | FreePool(SmbiosRecord);\r | |
174 | return Status;\r | |
175 | }\r |