2 The common header file for the thunk driver.
4 Copyright (c) 2009 Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _DATAHUB_TO_SMBIOS_THUNK_
16 #define _DATAHUB_TO_SMBIOS_THUNK_
18 #include <FrameworkDxe.h>
19 #include <IndustryStandard/SmBios.h>
21 #include <Guid/EventGroup.h>
22 #include <Guid/SmBios.h>
23 #include <Protocol/DataHub.h>
24 #include <Guid/DataHubRecords.h>
25 #include <Protocol/HiiDatabase.h>
26 #include <Protocol/Smbios.h>
28 #include <Library/BaseLib.h>
29 #include <Library/PcdLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/HiiLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/ReportStatusCodeLib.h>
35 #include <Library/UefiDriverEntryPoint.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
40 // Conversion Table that describes the translation method for
41 // Data Hub Data Records of certain SubClass and RecordNumber
44 BY_SUBCLASS_INSTANCE_SUBINSTANCE_PRODUCER
,
45 BY_SUBCLASS_INSTANCE_PRODUCER
,
47 } SMBIOS_STRUCTURE_LOCATING_METHOD
;
50 RECORD_DATA_UNCHANGED_OFFSET_SPECIFIED
,
51 BY_FUNCTION_WITH_OFFSET_SPECIFIED
,
53 BY_FUNCTION_WITH_WHOLE_DATA_RECORD
,
54 MAX_FIELD_FILLING_METHOD
55 } SMBIOS_FIELD_FILLING_METHOD
;
57 typedef struct _SMBIOS_STRUCTURE_NODE SMBIOS_STRUCTURE_NODE
;
64 } EFI_SMBIOS_TABLE_TYPE127
;
68 (*SMBIOS_FIELD_FILLING_FUNCTION
) (
69 IN OUT SMBIOS_STRUCTURE_NODE
* StructureNode
,
70 IN UINT32 Offset OPTIONAL
,
72 IN UINT32 RecordDataSize
77 // Data Hub Data Record's SubClass and RecordNumber
83 // Translation method applied
86 SMBIOS_STRUCTURE_LOCATING_METHOD StructureLocatingMethod
;
87 SMBIOS_FIELD_FILLING_METHOD FieldFillingMethod
;
89 SMBIOS_FIELD_FILLING_FUNCTION FieldFillingFunction
;
91 } SMBIOS_CONVERSION_TABLE_ENTRY
;
94 // SMBIOS_LINK_DATA_FIXUP nodes indicate the Link fields that
95 // need to be fixed up when creating the resulting Smbios image.
97 #define SMBIOS_LINK_DATA_FIXUP_NODE_SIGNATURE SIGNATURE_32 ('S', 'm', 'l', 'n')
107 EFI_INTER_LINK_DATA LinkData
;
109 } SMBIOS_LINK_DATA_FIXUP_NODE
;
112 // The global Structure List node.
113 // The Structure List is populated as more and more
114 // Structures (of various types) are discovered and inserted.
115 // The nodes in the Structure List will be concatenated
116 // to form the ultimate SMBIOS table.
118 #define SMBIOS_STRUCTURE_NODE_SIGNATURE SIGNATURE_32 ('S', 'm', 'b', 's')
120 struct _SMBIOS_STRUCTURE_NODE
{
131 EFI_GUID ProducerName
;
134 // the Smbios structure
136 UINT32 StructureSize
; // Actual structure size including strings
138 EFI_SMBIOS_TABLE_HEADER
*Structure
;
141 EFI_SMBIOS_HANDLE SmbiosHandle
; // Smbios Handle in SMBIOS database.
143 EFI_SMBIOS_TYPE SmbiosType
;
145 LIST_ENTRY LinkDataFixup
;
150 // Smbios type info table. Indicates minimum length
151 // for each Smbios type as the indicator of the initial size of buffer
152 // allocated for the structure instance of a specific type.
157 UINT8 MinLength
; // Minimal structure size including
158 // TWO trailing bytes of 0x00
160 BOOLEAN IsRequired
; // Required structure type defined by Smbios Spec
161 BOOLEAN IsCreated
; // Created in this run
162 } SMBIOS_TYPE_INFO_TABLE_ENTRY
;
165 // EDK framwork Memory Data hub definition to support EDK/Framework driver.
168 STRING_REF MemoryDeviceLocator
;
169 STRING_REF MemoryBankLocator
;
170 STRING_REF MemoryManufacturer
;
171 STRING_REF MemorySerialNumber
;
172 STRING_REF MemoryAssetTag
;
173 STRING_REF MemoryPartNumber
;
174 EFI_INTER_LINK_DATA MemoryArrayLink
;
175 EFI_INTER_LINK_DATA MemorySubArrayLink
;
176 UINT16 MemoryTotalWidth
;
177 UINT16 MemoryDataWidth
;
178 UINT64 MemoryDeviceSize
;
179 EFI_MEMORY_FORM_FACTOR MemoryFormFactor
;
180 UINT8 MemoryDeviceSet
;
181 EFI_MEMORY_ARRAY_TYPE MemoryType
;
182 EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail
;
184 EFI_MEMORY_STATE MemoryState
;
185 UINT8 MemoryAttributes
;
186 } FRAMEWORK_MEMORY_ARRAY_LINK_DATA
;
189 EFI_MEMORY_ARRAY_LOCATION MemoryArrayLocation
;
190 EFI_MEMORY_ARRAY_USE MemoryArrayUse
;
191 EFI_MEMORY_ERROR_CORRECTION MemoryErrorCorrection
;
192 UINT32 MaximumMemoryCapacity
;
193 UINT16 NumberMemoryDevices
;
194 } FRAMEWORK_MEMORY_ARRAY_LOCATION_DATA
;
199 extern SMBIOS_CONVERSION_TABLE_ENTRY mConversionTable
[];
200 extern SMBIOS_TYPE_INFO_TABLE_ENTRY mTypeInfoTable
[];
201 extern LIST_ENTRY mStructureList
;
204 // Function Prototypes
207 Smbios data filter function. This function is invoked when there is data records
208 available in the Data Hub.
210 @param Event The event that is signaled.
211 @param Context not used here.
221 // Function prototypes
224 Process a datahub's record and find corresponding translation way to translate
227 @param Record Point to datahub record.
230 SmbiosProcessDataRecord (
231 IN EFI_DATA_RECORD_HEADER
*Record
236 Calculate the minimal length for a SMBIOS type. This length maybe not equal
237 to sizeof (SMBIOS_RECORD_STRUCTURE), but defined in conformance chapter in SMBIOS specification.
239 @param Type SMBIOS's type.
241 @return the minimal length of a smbios record.
244 SmbiosGetTypeMinimalLength (
250 Enlarge the structure buffer of a structure node in SMBIOS database.
251 The function maybe lead the structure pointer for SMBIOS record changed.
253 @param StructureNode The structure node whose structure buffer is to be enlarged.
254 @param NewLength The new length of SMBIOS record which does not include unformat area.
255 @param OldBufferSize The old size of SMBIOS record buffer.
256 @param NewSize The new size is targeted for enlarged.
258 @retval EFI_OUT_OF_RESOURCES No more memory to allocate new record
259 @retval EFI_SUCCESS Success to enlarge the record buffer size.
262 SmbiosEnlargeStructureBuffer (
263 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
270 Field Filling Function. Fill a standard Smbios string field.
271 Convert the unicode string to single byte chars.
272 Only English language is supported.
274 This function changes the Structure pointer value of the structure node,
275 which should be noted by Caller.
277 @param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
278 @param Offset Offset of SMBIOS record which RecordData will be filled.
279 @param RecordData RecordData buffer will be filled.
280 @param RecordDataSize The size of RecordData buffer.
282 @retval EFI_INVALID_PARAMETER RecordDataSize is too larger
283 @retval EFI_OUT_OF_RESOURCES No memory to allocate new buffer for string
284 @retval EFI_SUCCESS Sucess append string for a SMBIOS record.
288 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
291 IN UINT32 RecordDataSize
296 Fill the inter link field for a SMBIOS recorder.
298 Some SMBIOS recorder need to reference the handle of another SMBIOS record. But
299 maybe another SMBIOS record has not been added, so put the InterLink request into
300 a linked list and the interlink will be fixedup when a new SMBIOS record is added.
302 @param StructureNode Point to SMBIOS_STRUCTURE_NODE which reference another record's handle
303 @param LinkSmbiosNodeOffset The offset in this record for holding the handle of another SMBIOS record
304 @param LinkSmbiosType The type of SMBIOS record want to be linked.
305 @param InterLink Point to EFI_INTER_LINK_DATA will be put linked list.
306 @param SubClassGuid The guid of subclass for linked SMBIOS record.
308 @retval EFI_SUCESS The linked record is found and no need fixup in future.
309 @retval !EFI_SUCESS The linked record can not be found and InterLink is put a fixing-p linked list.
313 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
314 IN UINT16 LinkSmbiosNodeOffset
,
315 IN UINT8 LinkSmbiosType
,
316 IN EFI_INTER_LINK_DATA
*InterLink
,
317 IN EFI_GUID
*SubClassGuid
322 Find a handle that matches the Link Data and the target Smbios type.
324 @param TargetType the Smbios type
325 @param SubClass the SubClass
326 @param LinkData Specifies Instance, SubInstance and ProducerName
327 @param Handle the HandleNum found
329 @retval EFI_NOT_FOUND Can not find the record according to handle
330 @retval EFI_SUCCESS Success to find the handle
335 IN EFI_GUID
*SubClass
,
336 IN EFI_INTER_LINK_DATA
*LinkData
,
337 IN OUT UINT16
*HandleNum
342 SmbiosFldBase10ToWordWithMega (
343 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
346 IN UINT32 RecordDataSize
351 SmbiosFldBase2ToWordWithKilo (
352 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
355 IN UINT32 RecordDataSize
360 SmbiosFldTruncateToByte (
361 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
364 IN UINT32 RecordDataSize
369 SmbiosFldProcessorType6 (
370 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
373 IN UINT32 RecordDataSize
378 SmbiosFldProcessorType9 (
379 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
382 IN UINT32 RecordDataSize
387 SmbiosFldProcessorType17 (
388 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
391 IN UINT32 RecordDataSize
396 SmbiosFldBase10ToByteWithNano (
397 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
400 IN UINT32 RecordDataSize
405 SmbiosFldTruncateToWord (
406 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
409 IN UINT32 RecordDataSize
414 SmbiosFldCacheType10 (
415 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
418 IN UINT32 RecordDataSize
423 SmbiosCheckTrailingZero (
425 IN UINT32 RecordDataSize
430 SmbiosFldCacheType5 (
431 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
434 IN UINT32 RecordDataSize
439 SmbiosFldMemoryType2 (
440 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
443 IN UINT32 RecordDataSize
448 SmbiosFldMemoryType3 (
449 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
452 IN UINT32 RecordDataSize
457 SmbiosFldMemoryType4 (
458 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
461 IN UINT32 RecordDataSize
466 SmbiosFldMemoryType5 (
467 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
470 IN UINT32 RecordDataSize
475 SmbiosFldMemoryType6 (
476 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
479 IN UINT32 RecordDataSize
484 SmbiosFldMemoryType7 (
485 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
488 IN UINT32 RecordDataSize
493 SmbiosFldMemoryType8 (
494 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
497 IN UINT32 RecordDataSize
502 SmbiosFldMemoryType9 (
503 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
506 IN UINT32 RecordDataSize
511 SmbiosFldMemoryType10 (
512 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
515 IN UINT32 RecordDataSize
521 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
524 IN UINT32 RecordDataSize
529 SmbiosFldBase2ToByteWith64K (
530 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
533 IN UINT32 RecordDataSize
539 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
542 IN UINT32 RecordDataSize
548 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
551 IN UINT32 RecordDataSize
557 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
560 IN UINT32 RecordDataSize
566 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
569 IN UINT32 RecordDataSize
575 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
578 IN UINT32 RecordDataSize
583 SmbiosFldMiscType10 (
584 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
587 IN UINT32 RecordDataSize
592 SmbiosFldMiscType11 (
593 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
596 IN UINT32 RecordDataSize
601 SmbiosFldMiscType12 (
602 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
605 IN UINT32 RecordDataSize
610 SmbiosFldMiscType13 (
611 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
614 IN UINT32 RecordDataSize
619 SmbiosFldMiscType14 (
620 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
623 IN UINT32 RecordDataSize
628 SmbiosFldMiscType15 (
629 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
632 IN UINT32 RecordDataSize
637 SmbiosFldMiscType21 (
638 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
641 IN UINT32 RecordDataSize
647 SmbiosFldMiscType32 (
648 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
651 IN UINT32 RecordDataSize
656 SmbiosFldMiscType38 (
657 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
660 IN UINT32 RecordDataSize
664 SmbiosFldMiscTypeOEM (
665 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
668 IN UINT32 RecordDataSize
673 SmbiosFldSMBIOSType6 (
674 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
677 IN UINT32 RecordDataSize
682 SmbiosFldMiscType22 (
683 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
686 IN UINT32 RecordDataSize
691 SmbiosFldMiscType22 (
692 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
695 IN UINT32 RecordDataSize
700 SmbiosFldMiscType23 (
701 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
704 IN UINT32 RecordDataSize
709 SmbiosFldMiscType24 (
710 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
713 IN UINT32 RecordDataSize
718 SmbiosFldMiscType25 (
719 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
722 IN UINT32 RecordDataSize
727 SmbiosFldMiscType26 (
728 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
731 IN UINT32 RecordDataSize
736 SmbiosFldMiscType27 (
737 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
740 IN UINT32 RecordDataSize
745 SmbiosFldMiscType28 (
746 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
749 IN UINT32 RecordDataSize
754 SmbiosFldMiscType29 (
755 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
758 IN UINT32 RecordDataSize
763 SmbiosFldMiscType30 (
764 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
767 IN UINT32 RecordDataSize
772 SmbiosFldMiscType34 (
773 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
776 IN UINT32 RecordDataSize
781 SmbiosFldMiscType36 (
782 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
785 IN UINT32 RecordDataSize
790 SmbiosFldMiscType38 (
791 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
794 IN UINT32 RecordDataSize
799 SmbiosFldMiscType39 (
800 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
803 IN UINT32 RecordDataSize
808 SmbiosFldMiscType127 (
809 IN OUT SMBIOS_STRUCTURE_NODE
*StructureNode
,
812 IN UINT32 RecordDataSize
817 SmbiosProtocolCreateRecord (
818 IN EFI_HANDLE ProducerHandle
, OPTIONAL
819 IN SMBIOS_STRUCTURE_NODE
*StructureNode
827 EFI_SMBIOS_TABLE_HEADER
*
828 GetSmbiosBufferFromHandle (
829 IN EFI_SMBIOS_HANDLE Handle
,
830 IN EFI_SMBIOS_TYPE Type
,
831 IN EFI_HANDLE ProducerHandle OPTIONAL
836 GetSmbiosStructureSize (
837 IN EFI_SMBIOS_TABLE_HEADER
*Head
,
839 OUT UINT8
*NumberOfStrings