3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #include "DataHubGen.h"
21 EFI_HII_DATABASE_PROTOCOL
*gHiiDatabase
;
23 extern UINT8 DataHubGenDxeStrings
[];
25 EFI_DATA_HUB_PROTOCOL
*gDataHub
;
26 EFI_HII_HANDLE gStringHandle
;
29 GetSmbiosTablesFromHob (
33 EFI_PHYSICAL_ADDRESS
*Table
;
34 EFI_PEI_HOB_POINTERS GuidHob
;
38 GuidHob
.Raw
= GetHobList ();
39 GuidHob
.Raw
= GetNextGuidHob (&gEfiSmbiosTableGuid
, GuidHob
.Raw
);
40 if (GuidHob
.Raw
!= NULL
) {
41 Table
= GET_GUID_HOB_DATA (GuidHob
.Guid
);
43 return (VOID
*)(UINTN
)*Table
;
50 EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader
= {
51 EFI_PROCESSOR_SUBCLASS_VERSION
, // Version
52 sizeof (EFI_SUBCLASS_TYPE1_HEADER
), // Header Size
53 0, // Instance, Initialize later
54 EFI_SUBCLASS_INSTANCE_NON_APPLICABLE
, // SubInstance
55 0 // RecordType, Initialize later
59 InstallProcessorDataHub (
64 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
65 EFI_CPU_DATA_RECORD DataRecord
;
71 // Processor info (TYPE 4)
73 SmbiosTable
= GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT
*)Smbios
, 4, 0);
74 if (SmbiosTable
.Raw
== NULL
) {
75 DEBUG ((EFI_D_ERROR
, "SmbiosTable: Type 4 (Processor Info) not found!\n"));
82 CopyMem (&DataRecord
, &mCpuDataRecordHeader
, sizeof (DataRecord
.DataRecordHeader
));
87 DataRecord
.DataRecordHeader
.RecordType
= ProcessorCoreFrequencyRecordType
;
88 DataRecord
.VariableRecord
.ProcessorCoreFrequency
.Value
= SmbiosTable
.Type4
->CurrentSpeed
;
89 DataRecord
.VariableRecord
.ProcessorCoreFrequency
.Exponent
= 6;
91 Status
= gDataHub
->LogData (
93 &gEfiProcessorSubClassGuid
,
94 &gEfiMiscProducerGuid
,
95 EFI_DATA_RECORD_CLASS_DATA
,
97 sizeof (DataRecord
.DataRecordHeader
) + sizeof (DataRecord
.VariableRecord
.ProcessorCoreFrequency
)
102 AString
= GetSmbiosString (SmbiosTable
, SmbiosTable
.Type4
->ProcessorVersion
);
103 UString
= AllocateZeroPool ((AsciiStrLen(AString
) + 1) * sizeof(CHAR16
));
104 ASSERT (UString
!= NULL
);
105 AsciiStrToUnicodeStr (AString
, UString
);
107 Status
= HiiLibNewString (gStringHandle
, &Token
, UString
);
109 if (EFI_ERROR (Status
)) {
110 gBS
->FreePool (UString
);
113 gBS
->FreePool (UString
);
115 DataRecord
.DataRecordHeader
.RecordType
= ProcessorVersionRecordType
;
116 DataRecord
.VariableRecord
.ProcessorVersion
= Token
;
118 Status
= gDataHub
->LogData (
120 &gEfiProcessorSubClassGuid
,
121 &gEfiMiscProducerGuid
,
122 EFI_DATA_RECORD_CLASS_DATA
,
124 sizeof (DataRecord
.DataRecordHeader
) + sizeof (DataRecord
.VariableRecord
.ProcessorVersion
)
131 InstallCacheDataHub (
138 EFI_SUBCLASS_TYPE1_HEADER mMemorySubclassDriverDataHeader
= {
139 EFI_MEMORY_SUBCLASS_VERSION
, // Version
140 sizeof (EFI_SUBCLASS_TYPE1_HEADER
), // Header Size
141 0, // Instance, Initialize later
142 EFI_SUBCLASS_INSTANCE_NON_APPLICABLE
, // SubInstance
143 0 // RecordType, Initialize later
147 InstallMemoryDataHub (
151 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
152 EFI_MEMORY_SUBCLASS_DRIVER_DATA DataRecord
;
155 // Generate Memory Array Mapped Address info (TYPE 19)
157 SmbiosTable
= GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT
*)Smbios
, 19, 0);
158 if (SmbiosTable
.Raw
== NULL
) {
159 DEBUG ((EFI_D_ERROR
, "SmbiosTable: Type 19 (Memory Array Mapped Address Info) not found!\n"));
166 CopyMem (&DataRecord
, &mMemorySubclassDriverDataHeader
, sizeof (DataRecord
.Header
));
171 DataRecord
.Header
.RecordType
= EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER
;
172 DataRecord
.Record
.ArrayStartAddress
.MemoryArrayStartAddress
= LShiftU64(SmbiosTable
.Type19
->StartingAddress
, 10);
173 DataRecord
.Record
.ArrayStartAddress
.MemoryArrayEndAddress
= LShiftU64((UINT64
) SmbiosTable
.Type19
->EndingAddress
+ 1, 10) - 1;
175 DataRecord
.Record
.ArrayStartAddress
.PhysicalMemoryArrayLink
.ProducerName
= gEfiMemoryProducerGuid
;
176 DataRecord
.Record
.ArrayStartAddress
.PhysicalMemoryArrayLink
.Instance
= 0;
177 DataRecord
.Record
.ArrayStartAddress
.PhysicalMemoryArrayLink
.SubInstance
= EFI_SUBCLASS_INSTANCE_NON_APPLICABLE
;
178 DataRecord
.Record
.ArrayStartAddress
.MemoryArrayPartitionWidth
= (UINT16
)(SmbiosTable
.Type19
->PartitionWidth
);
182 &gEfiMemorySubClassGuid
,
183 &gEfiMiscProducerGuid
,
184 EFI_DATA_RECORD_CLASS_DATA
,
186 sizeof (DataRecord
.Header
) + sizeof (DataRecord
.Record
.ArrayStartAddress
)
192 EFI_SUBCLASS_TYPE1_HEADER mMiscSubclassDriverDataHeader
= {
193 EFI_MISC_SUBCLASS_VERSION
, // Version
194 sizeof (EFI_SUBCLASS_TYPE1_HEADER
), // Header Size
195 0, // Instance, Initialize later
196 EFI_SUBCLASS_INSTANCE_NON_APPLICABLE
, // SubInstance
197 0 // RecordType, Initialize later
206 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
207 EFI_MISC_SUBCLASS_DRIVER_DATA DataRecord
;
213 // BIOS information (TYPE 0)
215 SmbiosTable
= GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT
*)Smbios
, 0, 0);
216 if (SmbiosTable
.Raw
== NULL
) {
217 DEBUG ((EFI_D_ERROR
, "SmbiosTable: Type 0 (BIOS Information) not found!\n"));
224 CopyMem (&DataRecord
, &mMiscSubclassDriverDataHeader
, sizeof (DataRecord
.Header
));
229 AString
= GetSmbiosString (SmbiosTable
, SmbiosTable
.Type0
->BiosVersion
);
230 UString
= AllocateZeroPool ((AsciiStrLen(AString
) + 1) * sizeof(CHAR16
) + sizeof(FIRMWARE_BIOS_VERSIONE
));
231 ASSERT (UString
!= NULL
);
232 CopyMem (UString
, FIRMWARE_BIOS_VERSIONE
, sizeof(FIRMWARE_BIOS_VERSIONE
));
233 AsciiStrToUnicodeStr (AString
, UString
+ sizeof(FIRMWARE_BIOS_VERSIONE
) / sizeof(CHAR16
) - 1);
235 Status
= HiiLibNewString (gStringHandle
, &Token
, UString
);
237 if (EFI_ERROR (Status
)) {
238 gBS
->FreePool (UString
);
241 gBS
->FreePool (UString
);
243 DataRecord
.Header
.RecordType
= EFI_MISC_BIOS_VENDOR_RECORD_NUMBER
;
244 DataRecord
.Record
.MiscBiosVendor
.BiosVendor
= 0;
245 DataRecord
.Record
.MiscBiosVendor
.BiosVersion
= Token
;
246 DataRecord
.Record
.MiscBiosVendor
.BiosReleaseDate
= 0;
247 DataRecord
.Record
.MiscBiosVendor
.BiosStartingAddress
= 0;
248 DataRecord
.Record
.MiscBiosVendor
.BiosPhysicalDeviceSize
.Value
= 0;
249 DataRecord
.Record
.MiscBiosVendor
.BiosPhysicalDeviceSize
.Exponent
= 0;
250 // DataRecord.Record.MiscBiosVendor.BiosCharacteristics1 = {0};
251 // DataRecord.Record.MiscBiosVendor.BiosCharacteristics2 = {0};
252 DataRecord
.Record
.MiscBiosVendor
.BiosMajorRelease
= 0;
253 DataRecord
.Record
.MiscBiosVendor
.BiosMinorRelease
= 0;
254 DataRecord
.Record
.MiscBiosVendor
.BiosEmbeddedFirmwareMajorRelease
= 0;
255 DataRecord
.Record
.MiscBiosVendor
.BiosEmbeddedFirmwareMinorRelease
= 0;
257 Status
= gDataHub
->LogData (
259 &gEfiMiscSubClassGuid
,
260 &gEfiMiscProducerGuid
,
261 EFI_DATA_RECORD_CLASS_DATA
,
263 sizeof (DataRecord
.Header
) + sizeof (DataRecord
.Record
.MiscBiosVendor
)
267 // System information (TYPE 1)
269 SmbiosTable
= GetSmbiosTableFromType ((SMBIOS_TABLE_ENTRY_POINT
*)Smbios
, 1, 0);
270 if (SmbiosTable
.Raw
== NULL
) {
271 DEBUG ((EFI_D_ERROR
, "SmbiosTable: Type 1 (System Information) not found!\n"));
278 AString
= GetSmbiosString (SmbiosTable
, SmbiosTable
.Type1
->ProductName
);
279 UString
= AllocateZeroPool ((AsciiStrLen(AString
) + 1) * sizeof(CHAR16
) + sizeof(FIRMWARE_PRODUCT_NAME
));
280 ASSERT (UString
!= NULL
);
281 CopyMem (UString
, FIRMWARE_PRODUCT_NAME
, sizeof(FIRMWARE_PRODUCT_NAME
));
282 AsciiStrToUnicodeStr (AString
, UString
+ sizeof(FIRMWARE_PRODUCT_NAME
) / sizeof(CHAR16
) - 1);
284 Status
= HiiLibNewString (gStringHandle
, &Token
, UString
);
286 if (EFI_ERROR (Status
)) {
287 gBS
->FreePool (UString
);
290 gBS
->FreePool (UString
);
292 DataRecord
.Header
.RecordType
= EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER
;
293 DataRecord
.Record
.MiscSystemManufacturer
.SystemManufacturer
= 0;
294 DataRecord
.Record
.MiscSystemManufacturer
.SystemProductName
= Token
;
295 DataRecord
.Record
.MiscSystemManufacturer
.SystemVersion
= 0;
296 DataRecord
.Record
.MiscSystemManufacturer
.SystemSerialNumber
= 0;
297 // DataRecord.Record.MiscSystemManufacturer.SystemUuid = {0};
298 DataRecord
.Record
.MiscSystemManufacturer
.SystemWakeupType
= EfiSystemWakeupTypeReserved
;
299 DataRecord
.Record
.MiscSystemManufacturer
.SystemSKUNumber
= 0;
300 DataRecord
.Record
.MiscSystemManufacturer
.SystemFamily
= 0;
302 Status
= gDataHub
->LogData (
304 &gEfiMiscSubClassGuid
,
305 &gEfiMiscProducerGuid
,
306 EFI_DATA_RECORD_CLASS_DATA
,
308 sizeof (DataRecord
.Header
) + sizeof (DataRecord
.Record
.MiscSystemManufacturer
)
316 DataHubGenEntrypoint (
317 IN EFI_HANDLE ImageHandle
,
318 IN EFI_SYSTEM_TABLE
*SystemTable
324 Smbios
= GetSmbiosTablesFromHob ();
325 if (Smbios
== NULL
) {
326 return EFI_NOT_FOUND
;
329 Status
= gBS
->LocateProtocol (
330 &gEfiDataHubProtocolGuid
,
334 if (EFI_ERROR (Status
)) {
338 Status
= gBS
->LocateProtocol (
339 &gEfiHiiDatabaseProtocolGuid
,
341 (VOID
**)&gHiiDatabase
344 if (EFI_ERROR (Status
)) {
348 HiiLibAddPackages (1, &gEfiMiscProducerGuid
, NULL
, &gStringHandle
, DataHubGenDxeStrings
);
350 InstallProcessorDataHub (Smbios
);
351 InstallCacheDataHub (Smbios
);
352 InstallMemoryDataHub (Smbios
);
353 InstallMiscDataHub (Smbios
);
364 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
370 AChar
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
371 while ((*AChar
!= 0) || (*(AChar
+ 1) != 0)) {
374 Length
= ((UINTN
)AChar
- (UINTN
)SmbiosTable
.Raw
+ 2);
379 SMBIOS_STRUCTURE_POINTER
380 GetSmbiosTableFromType (
381 IN SMBIOS_TABLE_ENTRY_POINT
*Smbios
,
386 SMBIOS_STRUCTURE_POINTER SmbiosTable
;
387 UINTN SmbiosTypeIndex
;
390 SmbiosTable
.Raw
= (UINT8
*)(UINTN
)Smbios
->TableAddress
;
391 if (SmbiosTable
.Raw
== NULL
) {
394 while ((SmbiosTypeIndex
!= Index
) || (SmbiosTable
.Hdr
->Type
!= Type
)) {
395 if (SmbiosTable
.Hdr
->Type
== 127) {
396 SmbiosTable
.Raw
= NULL
;
399 if (SmbiosTable
.Hdr
->Type
== Type
) {
402 SmbiosTable
.Raw
= (UINT8
*)(SmbiosTable
.Raw
+ SmbiosTableLength (SmbiosTable
));
410 IN SMBIOS_STRUCTURE_POINTER SmbiosTable
,
411 IN SMBIOS_TABLE_STRING String
418 AString
= (CHAR8
*)(SmbiosTable
.Raw
+ SmbiosTable
.Hdr
->Length
);
419 while (Index
!= String
) {
420 while (*AString
!= 0) {