]>
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 | MiscChassisManufacturerFunction.c\r | |
16 | \r | |
17 | Abstract: \r | |
18 | \r | |
19 | Chassis manufacturer information boot time changes.\r | |
20 | SMBIOS type 3.\r | |
21 | \r | |
22 | --*/\r | |
23 | \r | |
24 | #include "MiscSubclassDriver.h"\r | |
25 | \r | |
26 | /**\r | |
27 | This function makes boot time changes to the contents of the\r | |
28 | MiscChassisManufacturer (Type 3).\r | |
29 | \r | |
30 | @param RecordData Pointer to copy of RecordData from the Data Table. \r | |
31 | \r | |
32 | @retval EFI_SUCCESS All parameters were valid.\r | |
33 | @retval EFI_UNSUPPORTED Unexpected RecordType value.\r | |
34 | @retval EFI_INVALID_PARAMETER Invalid parameter was found.\r | |
35 | \r | |
36 | **/\r | |
37 | MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)\r | |
38 | {\r | |
39 | CHAR8 *OptionalStrStart;\r | |
40 | UINTN ManuStrLen;\r | |
41 | UINTN VerStrLen;\r | |
42 | UINTN AssertTagStrLen;\r | |
43 | UINTN SerialNumStrLen;\r | |
44 | EFI_STATUS Status;\r | |
45 | EFI_STRING Manufacturer;\r | |
46 | EFI_STRING Version;\r | |
47 | EFI_STRING SerialNumber;\r | |
48 | EFI_STRING AssertTag;\r | |
49 | STRING_REF TokenToGet;\r | |
50 | EFI_SMBIOS_HANDLE SmbiosHandle;\r | |
51 | SMBIOS_TABLE_TYPE3 *SmbiosRecord;\r | |
52 | EFI_MISC_CHASSIS_MANUFACTURER *ForType3InputData;\r | |
53 | \r | |
54 | ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData;\r | |
55 | \r | |
56 | //\r | |
57 | // First check for invalid parameters.\r | |
58 | //\r | |
59 | if (RecordData == NULL) {\r | |
60 | return EFI_INVALID_PARAMETER;\r | |
61 | }\r | |
62 | \r | |
63 | TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER);\r | |
64 | Manufacturer = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
65 | ManuStrLen = StrLen(Manufacturer);\r | |
66 | if (ManuStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
67 | return EFI_UNSUPPORTED;\r | |
68 | }\r | |
69 | \r | |
70 | TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_VERSION);\r | |
71 | Version = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
72 | VerStrLen = StrLen(Version);\r | |
73 | if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
74 | return EFI_UNSUPPORTED;\r | |
75 | }\r | |
76 | \r | |
77 | TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER);\r | |
78 | SerialNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
79 | SerialNumStrLen = StrLen(SerialNumber);\r | |
80 | if (SerialNumStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
81 | return EFI_UNSUPPORTED;\r | |
82 | }\r | |
83 | \r | |
84 | TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG);\r | |
85 | AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r | |
86 | AssertTagStrLen = StrLen(AssertTag);\r | |
87 | if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
88 | return EFI_UNSUPPORTED;\r | |
89 | }\r | |
90 | \r | |
91 | //\r | |
92 | // Two zeros following the last string.\r | |
93 | //\r | |
94 | SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r | |
95 | ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1);\r | |
96 | \r | |
97 | SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE;\r | |
98 | SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3);\r | |
99 | //\r | |
100 | // Make handle chosen by smbios protocol.add automatically.\r | |
101 | //\r | |
102 | SmbiosRecord->Hdr.Handle = 0; \r | |
103 | //\r | |
104 | // Manu will be the 1st optional string following the formatted structure.\r | |
105 | // \r | |
106 | SmbiosRecord->Manufacturer = 1; \r | |
107 | SmbiosRecord->Type = (UINT8)ForType3InputData->ChassisType.ChassisType;\r | |
108 | //\r | |
109 | // Version will be the 2nd optional string following the formatted structure.\r | |
110 | //\r | |
111 | SmbiosRecord->Version = 2; \r | |
112 | //\r | |
113 | // SerialNumber will be the 3rd optional string following the formatted structure.\r | |
114 | //\r | |
115 | SmbiosRecord->SerialNumber = 3; \r | |
116 | //\r | |
117 | // AssertTag will be the 4th optional string following the formatted structure.\r | |
118 | //\r | |
119 | SmbiosRecord->AssetTag = 4; \r | |
120 | SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState;\r | |
121 | SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState;\r | |
122 | SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState;\r | |
123 | SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState;\r | |
124 | CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4);\r | |
125 | \r | |
126 | OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r | |
127 | UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r | |
128 | UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1);\r | |
129 | UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1);\r | |
130 | UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r | |
131 | \r | |
132 | //\r | |
133 | // Now we have got the full smbios record, call smbios protocol to add this record.\r | |
134 | //\r | |
135 | SmbiosHandle = 0;\r | |
136 | Status = Smbios-> Add(\r | |
137 | Smbios, \r | |
138 | NULL,\r | |
139 | &SmbiosHandle, \r | |
140 | (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r | |
141 | );\r | |
142 | \r | |
143 | FreePool(SmbiosRecord);\r | |
144 | return Status;\r | |
145 | }\r |