]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
a66f6fe7af82d969b6ac2eae33a092f9234d123f
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscBaseBoardManufacturerFunction.c
1 /*++
2
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
10 Intel Corporation.
11
12
13 Module Name:
14
15 MiscBaseBoardManufacturerFunction.c
16
17 Abstract:
18
19 BaseBoard manufacturer information boot time changes.
20 SMBIOS type 2.
21
22 --*/
23
24 #include "MiscSubclassDriver.h"
25 /**
26 This function makes boot time changes to the contents of the
27 MiscBaseBoardManufacturer (Type 2).
28
29 @param RecordData Pointer to copy of RecordData from the Data Table.
30
31 @retval EFI_SUCCESS All parameters were valid.
32 @retval EFI_UNSUPPORTED Unexpected RecordType value.
33 @retval EFI_INVALID_PARAMETER Invalid parameter was found.
34
35 **/
36 MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
37 {
38 CHAR8 *OptionalStrStart;
39 UINTN ManuStrLen;
40 UINTN ProductStrLen;
41 UINTN VerStrLen;
42 UINTN AssertTagStrLen;
43 UINTN SerialNumStrLen;
44 UINTN ChassisStrLen;
45 EFI_STATUS Status;
46 EFI_STRING Manufacturer;
47 EFI_STRING Product;
48 EFI_STRING Version;
49 EFI_STRING SerialNumber;
50 EFI_STRING AssertTag;
51 EFI_STRING Chassis;
52 STRING_REF TokenToGet;
53 EFI_SMBIOS_HANDLE SmbiosHandle;
54 SMBIOS_TABLE_TYPE2 *SmbiosRecord;
55 EFI_MISC_BASE_BOARD_MANUFACTURER *ForType2InputData;
56
57 ForType2InputData = (EFI_MISC_BASE_BOARD_MANUFACTURER *)RecordData;
58
59 //
60 // First check for invalid parameters.
61 //
62 if (RecordData == NULL) {
63 return EFI_INVALID_PARAMETER;
64 }
65
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;
71 }
72
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;
78 }
79
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;
85 }
86
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;
92 }
93
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;
99 }
100
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;
106 }
107
108
109 //
110 // Two zeros following the last string.
111 //
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);
114
115 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
116 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
117 //
118 // Make handle chosen by smbios protocol.add automatically.
119 //
120 SmbiosRecord->Hdr.Handle = 0;
121 //
122 // Manu will be the 1st optional string following the formatted structure.
123 //
124 SmbiosRecord->Manufacturer = 1;
125 //
126 // ProductName will be the 2st optional string following the formatted structure.
127 //
128 SmbiosRecord->ProductName = 2;
129 //
130 // Version will be the 3rd optional string following the formatted structure.
131 //
132 SmbiosRecord->Version = 3;
133 //
134 // SerialNumber will be the 4th optional string following the formatted structure.
135 //
136 SmbiosRecord->SerialNumber = 4;
137 //
138 // AssertTag will be the 5th optional string following the formatted structure.
139 //
140 SmbiosRecord->AssetTag = 5;
141
142 //
143 // LocationInChassis will be the 6th optional string following the formatted structure.
144 //
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;
150
151 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
152 //
153 // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
154 //
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);
162 //
163 // Now we have got the full smbios record, call smbios protocol to add this record.
164 //
165 SmbiosHandle = 0;
166 Status = Smbios-> Add(
167 Smbios,
168 NULL,
169 &SmbiosHandle,
170 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
171 );
172
173 FreePool(SmbiosRecord);
174 return Status;
175 }