mirror of https://github.com/acidanthera/audk.git
Add a thunk driver to translate framework DataHub's smbios related record to PI SMBIOS's record via EFI_SMBIOS_PROTOCOL defined in PI 1.2 specification.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9619 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
1d7dfebf38
commit
024b10295d
|
@ -0,0 +1,786 @@
|
|||
/**@file
|
||||
Common filling functions used in translating Datahub's record
|
||||
to PI SMBIOS's record.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Thunk.h"
|
||||
|
||||
/**
|
||||
Field Filling Function for Cache SubClass record type 5&6 -- Cache SRAM type.
|
||||
Offset is mandatory
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldCacheType5 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_CACHE_SRAM_TYPE_DATA SramData;
|
||||
UINT32 Temp;
|
||||
|
||||
SramData = *(EFI_CACHE_SRAM_TYPE_DATA*)RecordData;
|
||||
|
||||
//
|
||||
// Swap two fields because of inconsistency between smbios and datahub specs
|
||||
//
|
||||
Temp = SramData.Asynchronous;
|
||||
SramData.Asynchronous = SramData.Synchronous;
|
||||
SramData.Synchronous = Temp;
|
||||
|
||||
//
|
||||
// Truncate the data to word
|
||||
//
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
(EFI_CACHE_SRAM_TYPE_DATA *) &SramData,
|
||||
2
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function for Cache SubClass record type 10 -- Cache Config.
|
||||
Offset is mandatory
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldCacheType10 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
|
||||
UINT16 CacheConfig;
|
||||
|
||||
CopyMem (&CacheConfig, RecordData, 2);
|
||||
|
||||
if ((CacheConfig & 0x07) == 0) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// Truncate the data to 2 bytes and make cache level zero-based.
|
||||
//
|
||||
CacheConfig--;
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
&CacheConfig,
|
||||
2
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Enlarge the structure buffer of a structure node in SMBIOS database.
|
||||
The function maybe lead the structure pointer for SMBIOS record changed.
|
||||
|
||||
@param StructureNode The structure node whose structure buffer is to be enlarged.
|
||||
@param NewLength The new length of SMBIOS record which does not include unformat area.
|
||||
@param OldBufferSize The old size of SMBIOS record buffer.
|
||||
@param NewSize The new size is targeted for enlarged.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No more memory to allocate new record
|
||||
@retval EFI_SUCCESS Success to enlarge the record buffer size.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosEnlargeStructureBuffer (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
UINT8 NewLength,
|
||||
UINTN OldBufferSize,
|
||||
UINTN NewBufferSize
|
||||
)
|
||||
{
|
||||
EFI_SMBIOS_TABLE_HEADER *NewRecord;
|
||||
EFI_SMBIOS_PROTOCOL *Smbios;
|
||||
EFI_STATUS Status;
|
||||
UINT8 CountOfString;
|
||||
|
||||
NewRecord = NULL;
|
||||
Smbios = GetSmbiosProtocol();
|
||||
ASSERT (Smbios != NULL);
|
||||
|
||||
NewRecord = (EFI_SMBIOS_TABLE_HEADER*) AllocateZeroPool (NewBufferSize);
|
||||
if (NewRecord == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem (NewRecord, StructureNode->Structure, OldBufferSize);
|
||||
|
||||
|
||||
Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// try to use original handle to enlarge the buffer.
|
||||
//
|
||||
NewRecord->Length = NewLength;
|
||||
Status = Smbios->Add (Smbios, NULL, &StructureNode->SmbiosHandle, NewRecord);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
FreePool (NewRecord);
|
||||
|
||||
StructureNode->Structure = GetSmbiosBufferFromHandle (
|
||||
StructureNode->SmbiosHandle,
|
||||
StructureNode->SmbiosType,
|
||||
NULL
|
||||
);
|
||||
GetSmbiosStructureSize (
|
||||
StructureNode->Structure,
|
||||
&StructureNode->StructureSize,
|
||||
&CountOfString
|
||||
);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Fill a standard Smbios string field.
|
||||
|
||||
This function will convert the unicode string to single byte chars, and only
|
||||
English language is supported.
|
||||
This function changes the Structure pointer value of the structure node,
|
||||
which should be noted by Caller.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is too larger
|
||||
@retval EFI_OUT_OF_RESOURCES No memory to allocate new buffer for string
|
||||
@retval EFI_SUCCESS Sucess append string for a SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldString (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT16 *Data;
|
||||
CHAR8 AsciiData[SMBIOS_STRING_MAX_LENGTH];
|
||||
UINT8 CountOfStrings;
|
||||
UINTN OrigStringNumber;
|
||||
EFI_SMBIOS_PROTOCOL *Smbios;
|
||||
EFI_SMBIOS_HANDLE SmbiosHandle;
|
||||
UINT32 OrigStructureSize;
|
||||
UINTN NewStructureSize;
|
||||
EFI_SMBIOS_TABLE_HEADER *NewRecord;
|
||||
UINT32 StringLength;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
OrigStringNumber = 0;
|
||||
OrigStructureSize = 0;
|
||||
|
||||
//
|
||||
// if we have a NULL token,
|
||||
//
|
||||
if (0 == *((STRING_REF *) RecordData)) {
|
||||
*(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the String from the Hii Database
|
||||
//
|
||||
Data = HiiGetPackageString (
|
||||
&(StructureNode->ProducerName),
|
||||
*((EFI_STRING_ID *) RecordData),
|
||||
NULL
|
||||
);
|
||||
if (Data == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
StringLength = (UINT32)StrLen (Data);
|
||||
//
|
||||
// Count the string size including the terminating 0.
|
||||
//
|
||||
if (StringLength == 0) {
|
||||
*(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = 0;
|
||||
FreePool (Data);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (StringLength > SMBIOS_STRING_MAX_LENGTH) {
|
||||
//
|
||||
// Too long a string
|
||||
//
|
||||
FreePool (Data);
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Smbios = GetSmbiosProtocol();
|
||||
ASSERT (Smbios != NULL);
|
||||
|
||||
//
|
||||
// Convert Unicode string to Ascii string which only supported by SMBIOS.
|
||||
//
|
||||
ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);
|
||||
UnicodeStrToAsciiStr (Data, AsciiData);
|
||||
|
||||
//
|
||||
// if the field at offset is already filled with some value,
|
||||
// find out the string it points to
|
||||
//
|
||||
OrigStringNumber = *(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset);
|
||||
if (OrigStringNumber != 0) {
|
||||
DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Update %dth string for type[%d],offset[0x%x],handle[0x%x] to [%s]\n",
|
||||
OrigStringNumber, StructureNode->SmbiosType, Offset, StructureNode->SmbiosHandle, AsciiData));
|
||||
|
||||
//
|
||||
// If original string number is not zero, just update string
|
||||
//
|
||||
Status = Smbios->UpdateString (Smbios, &StructureNode->SmbiosHandle, &OrigStringNumber, AsciiData);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Fail to update %dth string in offset 0x%x for handle:0x%x type:0x%x\n",
|
||||
OrigStringNumber, Offset, StructureNode->SmbiosHandle, StructureNode->SmbiosType));
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
return Status;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// If the string has not been filled in SMBIOS database, remove it and add again
|
||||
// with string appended.
|
||||
//
|
||||
Status = GetSmbiosStructureSize (StructureNode->Structure, &OrigStructureSize, &CountOfStrings);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
if (CountOfStrings == 0) {
|
||||
NewStructureSize = OrigStructureSize + StringLength;
|
||||
} else {
|
||||
NewStructureSize = OrigStructureSize + StringLength + 1;
|
||||
}
|
||||
|
||||
NewRecord = AllocateZeroPool (NewStructureSize);
|
||||
if (NewRecord == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem (NewRecord, StructureNode->Structure, OrigStructureSize);
|
||||
|
||||
//
|
||||
// Copy new string into tail of original SMBIOS record buffer.
|
||||
//
|
||||
if (CountOfStrings == 0) {
|
||||
AsciiStrCpy ((CHAR8 *)NewRecord + OrigStructureSize - 2, AsciiData);
|
||||
} else {
|
||||
AsciiStrCpy ((CHAR8 *)NewRecord + OrigStructureSize - 1, AsciiData);
|
||||
}
|
||||
DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Type(%d) offset(0x%x) StringNumber:%d\n",
|
||||
StructureNode->SmbiosType, Offset, CountOfStrings + 1));
|
||||
//
|
||||
// Update string reference number
|
||||
//
|
||||
*(UINT8 *) ((UINT8 *) NewRecord + Offset) = (UINT8) (CountOfStrings + 1);
|
||||
SmbiosHandle = StructureNode->SmbiosHandle;
|
||||
|
||||
//
|
||||
// Remove original SMBIOS record and add new one
|
||||
//
|
||||
Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Add new SMBIOS record
|
||||
//
|
||||
Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, NewRecord);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
StructureNode->SmbiosHandle = SmbiosHandle;
|
||||
|
||||
FreePool (NewRecord);
|
||||
}
|
||||
|
||||
//
|
||||
// The SMBIOS record buffer maybe re-allocated in SMBIOS database,
|
||||
// so update cached buffer pointer in DataHub structure list.
|
||||
//
|
||||
StructureNode->Structure = GetSmbiosBufferFromHandle (
|
||||
StructureNode->SmbiosHandle,
|
||||
StructureNode->SmbiosType,
|
||||
NULL
|
||||
);
|
||||
ASSERT (StructureNode->Structure != NULL);
|
||||
|
||||
//
|
||||
// The string update action maybe lead the record is re-allocated in SMBIOS database
|
||||
// so update cached record pointer
|
||||
//
|
||||
Status = GetSmbiosStructureSize (StructureNode->Structure, &StructureNode->StructureSize, &CountOfStrings);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Find a handle that matches the Link Data and the target Smbios type.
|
||||
|
||||
@param TargetType the Smbios type
|
||||
@param SubClass the SubClass
|
||||
@param LinkData Specifies Instance, SubInstance and ProducerName
|
||||
@param Handle the HandleNum found
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the record according to handle
|
||||
@retval EFI_SUCCESS Success to find the handle
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFindHandle (
|
||||
IN UINT8 TargetType,
|
||||
IN EFI_GUID *SubClass,
|
||||
IN EFI_INTER_LINK_DATA *LinkData,
|
||||
IN OUT UINT16 *HandleNum
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Link;
|
||||
SMBIOS_STRUCTURE_NODE *StructureNode;
|
||||
|
||||
StructureNode = NULL;
|
||||
|
||||
//
|
||||
// Find out the matching handle
|
||||
//
|
||||
for (Link = mStructureList.ForwardLink; Link != &mStructureList; Link = Link->ForwardLink) {
|
||||
StructureNode = CR (Link, SMBIOS_STRUCTURE_NODE, Link, SMBIOS_STRUCTURE_NODE_SIGNATURE);
|
||||
if (StructureNode->Structure->Type == TargetType &&
|
||||
CompareGuid (&(StructureNode->SubClass), SubClass) &&
|
||||
StructureNode->Instance == LinkData->Instance &&
|
||||
StructureNode->SubInstance == LinkData->SubInstance
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Link == &mStructureList) {
|
||||
return EFI_NOT_FOUND;
|
||||
} else {
|
||||
*HandleNum = StructureNode->Structure->Handle;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Fill the inter link field for a SMBIOS recorder.
|
||||
|
||||
Some SMBIOS recorder need to reference the handle of another SMBIOS record. But
|
||||
maybe another SMBIOS record has not been added, so put the InterLink request into
|
||||
a linked list and the interlink will be fixedup when a new SMBIOS record is added.
|
||||
|
||||
@param StructureNode Point to SMBIOS_STRUCTURE_NODE which reference another record's handle
|
||||
@param LinkSmbiosNodeOffset The offset in this record for holding the handle of another SMBIOS record
|
||||
@param LinkSmbiosType The type of SMBIOS record want to be linked.
|
||||
@param InterLink Point to EFI_INTER_LINK_DATA will be put linked list.
|
||||
@param SubClassGuid The guid of subclass for linked SMBIOS record.
|
||||
|
||||
@retval EFI_SUCESS The linked record is found and no need fixup in future.
|
||||
@retval !EFI_SUCESS The linked record can not be found and InterLink is put a fixing-p linked list.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldInterLink (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT16 LinkSmbiosNodeOffset,
|
||||
IN UINT8 LinkSmbiosType,
|
||||
IN EFI_INTER_LINK_DATA *InterLink,
|
||||
IN EFI_GUID *SubClassGuid
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SMBIOS_LINK_DATA_FIXUP_NODE *LinkDataFixupNode;
|
||||
UINT16 StructureHandle;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
LinkDataFixupNode = NULL;
|
||||
|
||||
Status = SmbiosFindHandle (
|
||||
LinkSmbiosType, // Smbios type
|
||||
SubClassGuid,
|
||||
InterLink,
|
||||
&StructureHandle
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
//
|
||||
// Set the handle
|
||||
//
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + LinkSmbiosNodeOffset,
|
||||
&StructureHandle,
|
||||
sizeof (EFI_SMBIOS_HANDLE)
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// Hang this in the link data fixup node
|
||||
//
|
||||
LinkDataFixupNode = AllocateZeroPool (sizeof (SMBIOS_LINK_DATA_FIXUP_NODE));
|
||||
if (!LinkDataFixupNode) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
LinkDataFixupNode->Signature = SMBIOS_LINK_DATA_FIXUP_NODE_SIGNATURE;
|
||||
LinkDataFixupNode->Offset = LinkSmbiosNodeOffset;
|
||||
LinkDataFixupNode->TargetType = LinkSmbiosType;
|
||||
CopyMem (
|
||||
&LinkDataFixupNode->SubClass,
|
||||
SubClassGuid,
|
||||
sizeof (EFI_GUID)
|
||||
);
|
||||
CopyMem (
|
||||
&LinkDataFixupNode->LinkData,
|
||||
InterLink,
|
||||
sizeof (EFI_INTER_LINK_DATA)
|
||||
);
|
||||
InsertTailList (
|
||||
&StructureNode->LinkDataFixup,
|
||||
&(LinkDataFixupNode->Link)
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function. Transform an EFI_EXP_BASE10_DATA to a word, with 'Mega'
|
||||
as the unit.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldBase10ToWordWithMega (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_EXP_BASE10_DATA *Base10Data;
|
||||
INT16 Value;
|
||||
INT16 Exponent;
|
||||
|
||||
if (RecordDataSize != sizeof (EFI_EXP_BASE10_DATA)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Base10Data = RecordData;
|
||||
Value = Base10Data->Value;
|
||||
Exponent = Base10Data->Exponent;
|
||||
|
||||
Exponent -= 6;
|
||||
while (Exponent != 0) {
|
||||
if (Exponent > 0) {
|
||||
Value = (INT16) (Value * 10);
|
||||
Exponent--;
|
||||
} else {
|
||||
Value = (INT16) (Value / 10);
|
||||
Exponent++;
|
||||
}
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
&Value,
|
||||
2
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a word, with 'Kilo'
|
||||
as the unit. Granularity implemented for Cache Size.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldBase2ToWordWithKilo (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_EXP_BASE2_DATA *Base2Data;
|
||||
UINT32 Value;
|
||||
UINT16 Exponent;
|
||||
|
||||
if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Base2Data = RecordData;
|
||||
Value = Base2Data->Value;
|
||||
Exponent = Base2Data->Exponent;
|
||||
|
||||
Exponent -= 10;
|
||||
Value <<= Exponent;
|
||||
|
||||
//
|
||||
// Implement cache size granularity
|
||||
//
|
||||
if(Value >= 0x8000) {
|
||||
Value >>= 6;
|
||||
Value |= 0x8000;
|
||||
}
|
||||
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
&Value,
|
||||
2
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'
|
||||
as the unit.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldBase2ToByteWith64K (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_EXP_BASE2_DATA *Base2Data;
|
||||
UINT16 Value;
|
||||
UINT16 Exponent;
|
||||
|
||||
if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Base2Data = RecordData;
|
||||
Value = Base2Data->Value;
|
||||
Exponent = Base2Data->Exponent;
|
||||
Exponent -= 16;
|
||||
Value <<= Exponent;
|
||||
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
&Value,
|
||||
1
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a word, with 10exp-9
|
||||
as the unit.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldBase10ToByteWithNano (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_EXP_BASE10_DATA *Base10Data;
|
||||
INT16 Value;
|
||||
INT16 Exponent;
|
||||
|
||||
if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Base10Data = RecordData;
|
||||
Value = Base10Data->Value;
|
||||
Exponent = Base10Data->Exponent;
|
||||
|
||||
Exponent += 9;
|
||||
while (Exponent != 0) {
|
||||
if (Exponent > 0) {
|
||||
Value = (INT16) (Value * 10);
|
||||
Exponent--;
|
||||
} else {
|
||||
Value = (INT16) (Value / 10);
|
||||
Exponent++;
|
||||
}
|
||||
}
|
||||
|
||||
* (UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) Value;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function: truncate record data to byte and fill in the
|
||||
field as indicated by Offset.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldTruncateToByte (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Truncate the data to 8 bits
|
||||
//
|
||||
*(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) (*(UINT8 *) RecordData);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function: truncate record data to byte and fill in the
|
||||
field as indicated by Offset.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is invalid.
|
||||
@retval EFI_SUCCESS RecordData is successed to be filled into given SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldTruncateToWord (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
//
|
||||
// Truncate the data to 8 bits
|
||||
//
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
RecordData,
|
||||
2
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if OEM structure has included 2 trailing 0s in data record.
|
||||
|
||||
@param RecordData Point to record data will be checked.
|
||||
@param RecordDataSize The size of record data.
|
||||
|
||||
@retval 0 2 trailing 0s exist in unformatted section
|
||||
@retval 1 1 trailing 0 exists at the end of unformatted section
|
||||
@retval -1 There is no 0 at the end of unformatted section
|
||||
**/
|
||||
INT8
|
||||
SmbiosCheckTrailingZero (
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
SMBIOS_STRUCTURE *Smbios;
|
||||
CHAR8 *Start;
|
||||
CHAR8 *End;
|
||||
|
||||
Smbios = (SMBIOS_STRUCTURE *) RecordData;
|
||||
|
||||
//
|
||||
// Skip over formatted section
|
||||
//
|
||||
Start = (CHAR8 *) ((UINT8 *) Smbios + Smbios->Length);
|
||||
End = (CHAR8 *) RecordData + RecordDataSize;
|
||||
|
||||
//
|
||||
// Unformatted section exists
|
||||
//
|
||||
while (Start < End - 1) {
|
||||
//
|
||||
// Avoid unaligned issue on IPF
|
||||
//
|
||||
if ((*Start == 0) && (*(Start + 1) == 0)) {
|
||||
//
|
||||
// 2 trailing 0s exist in unformatted section
|
||||
//
|
||||
return 0;
|
||||
}
|
||||
Start++;
|
||||
}
|
||||
|
||||
if (Start == End - 1) {
|
||||
//
|
||||
// Check if there has been already 1 trailing 0
|
||||
//
|
||||
if (*Start == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// There is no 0 at the end of unformatted section
|
||||
//
|
||||
return -1;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,75 @@
|
|||
#/** @file
|
||||
# This thunk driver register a filter for DataHub protocol, once a data hub record
|
||||
# is added via EFI_DATA_HUB_PROTOCOL->LogData(), this filter will be invoked to
|
||||
# translate the datahub's record to SMBIOS record.
|
||||
#
|
||||
# Copyright (c) 2009, Intel Corporation
|
||||
#
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
#
|
||||
#**/
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = Datahub2SmbiosThunk
|
||||
FILE_GUID = 9F8B12CF-E796-408f-9D59-3ACDDC0AFBE3
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
EDK_RELEASE_VERSION = 0x00020000
|
||||
EFI_SPECIFICATION_VERSION = 0x00020000
|
||||
|
||||
ENTRY_POINT = ThunkEntry
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
Thunk.c
|
||||
Thunk.h
|
||||
Translate.c
|
||||
ConvLib.c
|
||||
ConvTable.c
|
||||
ProcessorConv.c
|
||||
MemoryConv.c
|
||||
MiscConv.c
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
IntelFrameworkPkg/IntelFrameworkPkg.dec
|
||||
EdkCompatibilityPkg/EdkCompatibilityPkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
UefiBootServicesTableLib
|
||||
MemoryAllocationLib
|
||||
UefiDriverEntryPoint
|
||||
BaseMemoryLib
|
||||
HiiLib
|
||||
DebugLib
|
||||
BaseLib
|
||||
PcdLib
|
||||
|
||||
[Protocols]
|
||||
gEfiDataHubProtocolGuid ## CONSUMES
|
||||
gEfiSmbiosProtocolGuid ## CONSUMES
|
||||
|
||||
[Guids]
|
||||
gEfiMemorySubClassGuid ## CONSUMES
|
||||
gEfiMiscSubClassGuid ## CONSUMES
|
||||
gEfiCacheSubClassGuid ## CONSUMES
|
||||
|
||||
[FeaturePcd]
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFrameworkCompatibilitySupport
|
||||
|
||||
[Depex]
|
||||
gEfiDataHubProtocolGuid AND gEfiSmbiosProtocolGuid
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,164 @@
|
|||
/** @file
|
||||
Routines that support Processor SubClass data records translation.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Thunk.h"
|
||||
|
||||
/**
|
||||
Field Filling Function for Processor SubClass record type 17 -- Cache association.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType17 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
|
||||
EFI_INTER_LINK_DATA *LinkData;
|
||||
UINT16 FieldOffset;
|
||||
UINT8 *Pointer;
|
||||
|
||||
DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) RecordData;
|
||||
LinkData = (EFI_INTER_LINK_DATA *) (DataHeader + 1);
|
||||
if (RecordDataSize != sizeof (EFI_INTER_LINK_DATA) + sizeof (EFI_SUBCLASS_TYPE1_HEADER)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// Determine the cache level
|
||||
//
|
||||
Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);
|
||||
if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
|
||||
SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle), 2, 0xFF);
|
||||
}
|
||||
|
||||
Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);
|
||||
if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
|
||||
SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle), 2, 0xFF);
|
||||
}
|
||||
|
||||
Pointer = (UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);
|
||||
if ((*Pointer == 0) && (*(Pointer + 1) == 0)) {
|
||||
SetMem ((UINT8 *) (StructureNode->Structure) + OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle), 2, 0xFF);
|
||||
}
|
||||
|
||||
if (LinkData->SubInstance == 1) {
|
||||
FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L1CacheHandle);
|
||||
} else if (LinkData->SubInstance == 2) {
|
||||
FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L2CacheHandle);
|
||||
} else if (LinkData->SubInstance == 3) {
|
||||
FieldOffset = (UINT16) OFFSET_OF (SMBIOS_TABLE_TYPE4, L3CacheHandle);
|
||||
} else {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
return SmbiosFldInterLink (
|
||||
StructureNode,
|
||||
FieldOffset,
|
||||
7, // Smbios type 7 -- Cache Information
|
||||
LinkData,
|
||||
&gEfiCacheSubClassGuid // gProcessorSubClassName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function for Processor SubClass record type 6 -- ProcessorID.
|
||||
Offset is mandatory.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType6 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_PROCESSOR_ID_DATA *ProcessorIdData;
|
||||
|
||||
ProcessorIdData = RecordData;
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset,
|
||||
&(ProcessorIdData->Signature),
|
||||
4
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
(UINT8 *) (StructureNode->Structure) + Offset + 4,
|
||||
&(ProcessorIdData->FeatureFlags),
|
||||
4
|
||||
);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
Field Filling Function for Processor SubClass record type 9 -- Voltage.
|
||||
Offset is mandatory.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_SUCCESS Success fill RecordData into SMBIOS's record buffer.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType9 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
{
|
||||
EFI_EXP_BASE10_DATA *Base10Data;
|
||||
INT16 Value;
|
||||
INT16 Exponent;
|
||||
|
||||
if (RecordDataSize != sizeof (EFI_EXP_BASE10_DATA)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Base10Data = RecordData;
|
||||
Value = Base10Data->Value;
|
||||
Exponent = Base10Data->Exponent;
|
||||
|
||||
Exponent += 1;
|
||||
while (Exponent != 0) {
|
||||
if (Exponent > 0) {
|
||||
Value = (INT16) (Value * 10);
|
||||
Exponent--;
|
||||
} else {
|
||||
Value = (INT16) (Value / 10);
|
||||
Exponent++;
|
||||
}
|
||||
}
|
||||
|
||||
* (UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) (Value | BIT7);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/** @file
|
||||
Thunk driver's entry that install filter for DataRecord.
|
||||
|
||||
Copyright (c) 2009 Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Thunk.h"
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
LIST_ENTRY mStructureList;
|
||||
|
||||
/**
|
||||
Entry Point of thunk driver.
|
||||
|
||||
@param[in] ImageHandle Image handle of this driver.
|
||||
@param[in] SystemTable Pointer to EFI system table.
|
||||
|
||||
@retval EFI_SUCCESS The event handlers were registered.
|
||||
@retval EFI_DEVICE_ERROR Failed to register the event handlers
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ThunkEntry (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DATA_HUB_PROTOCOL *DataHub;
|
||||
EFI_EVENT FilterEvent;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID**) &DataHub);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ASSERT (DataHub != NULL);
|
||||
|
||||
InitializeListHead (&mStructureList);
|
||||
|
||||
//
|
||||
// Register SmBios Data Filter Function.
|
||||
// This function is notified at TPL_CALLBACK.
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
SmbiosDataFilter,
|
||||
NULL,
|
||||
&FilterEvent
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = DataHub->RegisterFilterDriver (
|
||||
DataHub,
|
||||
FilterEvent,
|
||||
TPL_APPLICATION,
|
||||
EFI_DATA_RECORD_CLASS_DATA,
|
||||
NULL
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->CloseEvent (FilterEvent);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Smbios data filter function. This function is invoked when there is data records
|
||||
available in the Data Hub.
|
||||
|
||||
@param Event The event that is signaled.
|
||||
@param Context not used here.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SmbiosDataFilter (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DATA_HUB_PROTOCOL *DataHub;
|
||||
EFI_HANDLE DataHubHandle;
|
||||
UINTN HandleSize;
|
||||
UINT64 MonotonicCount;
|
||||
EFI_DATA_RECORD_HEADER *Record;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
DataHub = NULL;
|
||||
|
||||
//
|
||||
// Get the Data Hub Protocol. Assume only one instance
|
||||
// of Data Hub Protocol is availabe in the system.
|
||||
//
|
||||
HandleSize = sizeof (EFI_HANDLE);
|
||||
|
||||
Status = gBS->LocateHandle (
|
||||
ByProtocol,
|
||||
&gEfiDataHubProtocolGuid,
|
||||
NULL,
|
||||
&HandleSize,
|
||||
&DataHubHandle
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = gBS->HandleProtocol (
|
||||
DataHubHandle,
|
||||
&gEfiDataHubProtocolGuid,
|
||||
(VOID **) &DataHub
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Get all available data records from data hub
|
||||
//
|
||||
MonotonicCount = 0;
|
||||
Record = NULL;
|
||||
|
||||
do {
|
||||
|
||||
Status = DataHub->GetNextRecord (
|
||||
DataHub,
|
||||
&MonotonicCount,
|
||||
&Event,
|
||||
&Record
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
|
||||
|
||||
//
|
||||
// It's of expected Data Type. Process it.
|
||||
//
|
||||
SmbiosProcessDataRecord (Record);
|
||||
}
|
||||
}
|
||||
} while (!EFI_ERROR (Status) && (MonotonicCount != 0));
|
||||
|
||||
Done:
|
||||
|
||||
return ;
|
||||
|
||||
}
|
|
@ -0,0 +1,842 @@
|
|||
/** @file
|
||||
The common header file for the thunk driver.
|
||||
|
||||
Copyright (c) 2009 Intel Corporation. <BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _DATAHUB_TO_SMBIOS_THUNK_
|
||||
#define _DATAHUB_TO_SMBIOS_THUNK_
|
||||
|
||||
#include <FrameworkDxe.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/SmBios.h>
|
||||
#include <Protocol/DataHub.h>
|
||||
#include <Guid/DataHubRecords.h>
|
||||
#include <Protocol/HiiDatabase.h>
|
||||
#include <Protocol/Smbios.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/ReportStatusCodeLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
|
||||
//
|
||||
// Conversion Table that describes the translation method for
|
||||
// Data Hub Data Records of certain SubClass and RecordNumber
|
||||
//
|
||||
typedef enum {
|
||||
BY_SUBCLASS_INSTANCE_SUBINSTANCE_PRODUCER,
|
||||
BY_SUBCLASS_INSTANCE_PRODUCER,
|
||||
MAX_LOCATING_METHOD
|
||||
} SMBIOS_STRUCTURE_LOCATING_METHOD;
|
||||
|
||||
typedef enum {
|
||||
RECORD_DATA_UNCHANGED_OFFSET_SPECIFIED,
|
||||
BY_FUNCTION_WITH_OFFSET_SPECIFIED,
|
||||
BY_FUNCTION,
|
||||
BY_FUNCTION_WITH_WHOLE_DATA_RECORD,
|
||||
MAX_FIELD_FILLING_METHOD
|
||||
} SMBIOS_FIELD_FILLING_METHOD;
|
||||
|
||||
typedef struct _SMBIOS_STRUCTURE_NODE SMBIOS_STRUCTURE_NODE;
|
||||
|
||||
typedef struct {
|
||||
UINT8 Type;
|
||||
UINT8 Length;
|
||||
UINT16 Handle;
|
||||
UINT8 Tailing[2];
|
||||
} EFI_SMBIOS_TABLE_TYPE127;
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(*SMBIOS_FIELD_FILLING_FUNCTION) (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE * StructureNode,
|
||||
IN UINT32 Offset OPTIONAL,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
//
|
||||
// Data Hub Data Record's SubClass and RecordNumber
|
||||
//
|
||||
EFI_GUID SubClass;
|
||||
UINT32 RecordType;
|
||||
|
||||
//
|
||||
// Translation method applied
|
||||
//
|
||||
UINT8 SmbiosType;
|
||||
SMBIOS_STRUCTURE_LOCATING_METHOD StructureLocatingMethod;
|
||||
SMBIOS_FIELD_FILLING_METHOD FieldFillingMethod;
|
||||
UINT32 FieldOffset;
|
||||
SMBIOS_FIELD_FILLING_FUNCTION FieldFillingFunction;
|
||||
|
||||
} SMBIOS_CONVERSION_TABLE_ENTRY;
|
||||
|
||||
//
|
||||
// SMBIOS_LINK_DATA_FIXUP nodes indicate the Link fields that
|
||||
// need to be fixed up when creating the resulting Smbios image.
|
||||
//
|
||||
#define SMBIOS_LINK_DATA_FIXUP_NODE_SIGNATURE SIGNATURE_32 ('S', 'm', 'l', 'n')
|
||||
|
||||
typedef struct {
|
||||
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
UINT32 Offset;
|
||||
UINT8 TargetType;
|
||||
EFI_GUID SubClass;
|
||||
EFI_INTER_LINK_DATA LinkData;
|
||||
|
||||
} SMBIOS_LINK_DATA_FIXUP_NODE;
|
||||
|
||||
//
|
||||
// The global Structure List node.
|
||||
// The Structure List is populated as more and more
|
||||
// Structures (of various types) are discovered and inserted.
|
||||
// The nodes in the Structure List will be concatenated
|
||||
// to form the ultimate SMBIOS table.
|
||||
//
|
||||
#define SMBIOS_STRUCTURE_NODE_SIGNATURE SIGNATURE_32 ('S', 'm', 'b', 's')
|
||||
|
||||
struct _SMBIOS_STRUCTURE_NODE {
|
||||
|
||||
UINT32 Signature;
|
||||
LIST_ENTRY Link;
|
||||
|
||||
//
|
||||
// Tags
|
||||
//
|
||||
EFI_GUID SubClass;
|
||||
UINT16 Instance;
|
||||
UINT16 SubInstance;
|
||||
EFI_GUID ProducerName;
|
||||
|
||||
//
|
||||
// the Smbios structure
|
||||
//
|
||||
UINT32 StructureSize; // Actual structure size including strings
|
||||
|
||||
EFI_SMBIOS_TABLE_HEADER *Structure;
|
||||
|
||||
|
||||
EFI_SMBIOS_HANDLE SmbiosHandle; // Smbios Handle in SMBIOS database.
|
||||
|
||||
EFI_SMBIOS_TYPE SmbiosType;
|
||||
|
||||
LIST_ENTRY LinkDataFixup;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// Smbios type info table. Indicates minimum length
|
||||
// for each Smbios type as the indicator of the initial size of buffer
|
||||
// allocated for the structure instance of a specific type.
|
||||
//
|
||||
typedef struct {
|
||||
|
||||
UINT8 Type;
|
||||
UINT8 MinLength; // Minimal structure size including
|
||||
// TWO trailing bytes of 0x00
|
||||
//
|
||||
BOOLEAN IsRequired; // Required structure type defined by Smbios Spec
|
||||
BOOLEAN IsCreated; // Created in this run
|
||||
} SMBIOS_TYPE_INFO_TABLE_ENTRY;
|
||||
|
||||
//
|
||||
// EDK framwork Memory Data hub definition to support EDK/Framework driver.
|
||||
//
|
||||
typedef struct {
|
||||
STRING_REF MemoryDeviceLocator;
|
||||
STRING_REF MemoryBankLocator;
|
||||
STRING_REF MemoryManufacturer;
|
||||
STRING_REF MemorySerialNumber;
|
||||
STRING_REF MemoryAssetTag;
|
||||
STRING_REF MemoryPartNumber;
|
||||
EFI_INTER_LINK_DATA MemoryArrayLink;
|
||||
EFI_INTER_LINK_DATA MemorySubArrayLink;
|
||||
UINT16 MemoryTotalWidth;
|
||||
UINT16 MemoryDataWidth;
|
||||
UINT64 MemoryDeviceSize;
|
||||
EFI_MEMORY_FORM_FACTOR MemoryFormFactor;
|
||||
UINT8 MemoryDeviceSet;
|
||||
EFI_MEMORY_ARRAY_TYPE MemoryType;
|
||||
EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail;
|
||||
UINT16 MemorySpeed;
|
||||
EFI_MEMORY_STATE MemoryState;
|
||||
UINT8 MemoryAttributes;
|
||||
} FRAMEWORK_MEMORY_ARRAY_LINK_DATA;
|
||||
|
||||
typedef struct {
|
||||
EFI_MEMORY_ARRAY_LOCATION MemoryArrayLocation;
|
||||
EFI_MEMORY_ARRAY_USE MemoryArrayUse;
|
||||
EFI_MEMORY_ERROR_CORRECTION MemoryErrorCorrection;
|
||||
UINT32 MaximumMemoryCapacity;
|
||||
UINT16 NumberMemoryDevices;
|
||||
} FRAMEWORK_MEMORY_ARRAY_LOCATION_DATA;
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
extern SMBIOS_CONVERSION_TABLE_ENTRY mConversionTable[];
|
||||
extern SMBIOS_TYPE_INFO_TABLE_ENTRY mTypeInfoTable[];
|
||||
extern LIST_ENTRY mStructureList;
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
/**
|
||||
Smbios data filter function. This function is invoked when there is data records
|
||||
available in the Data Hub.
|
||||
|
||||
@param Event The event that is signaled.
|
||||
@param Context not used here.
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
SmbiosDataFilter (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
//
|
||||
// Function prototypes
|
||||
//
|
||||
/**
|
||||
Process a datahub's record and find corresponding translation way to translate
|
||||
to SMBIOS record.
|
||||
|
||||
@param Record Point to datahub record.
|
||||
**/
|
||||
VOID
|
||||
SmbiosProcessDataRecord (
|
||||
IN EFI_DATA_RECORD_HEADER *Record
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Calculate the minimal length for a SMBIOS type. This length maybe not equal
|
||||
to sizeof (SMBIOS_RECORD_STRUCTURE), but defined in conformance chapter in SMBIOS specification.
|
||||
|
||||
@param Type SMBIOS's type.
|
||||
|
||||
@return the minimal length of a smbios record.
|
||||
**/
|
||||
UINT32
|
||||
SmbiosGetTypeMinimalLength (
|
||||
IN UINT8 Type
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Enlarge the structure buffer of a structure node in SMBIOS database.
|
||||
The function maybe lead the structure pointer for SMBIOS record changed.
|
||||
|
||||
@param StructureNode The structure node whose structure buffer is to be enlarged.
|
||||
@param NewLength The new length of SMBIOS record which does not include unformat area.
|
||||
@param OldBufferSize The old size of SMBIOS record buffer.
|
||||
@param NewSize The new size is targeted for enlarged.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES No more memory to allocate new record
|
||||
@retval EFI_SUCCESS Success to enlarge the record buffer size.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosEnlargeStructureBuffer (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
UINT8 NewLength,
|
||||
UINTN OldBufferSize,
|
||||
UINTN NewBufferSize
|
||||
);
|
||||
|
||||
/**
|
||||
Field Filling Function. Fill a standard Smbios string field.
|
||||
Convert the unicode string to single byte chars.
|
||||
Only English language is supported.
|
||||
|
||||
This function changes the Structure pointer value of the structure node,
|
||||
which should be noted by Caller.
|
||||
|
||||
@param StructureNode Pointer to SMBIOS_STRUCTURE_NODE which is current processed.
|
||||
@param Offset Offset of SMBIOS record which RecordData will be filled.
|
||||
@param RecordData RecordData buffer will be filled.
|
||||
@param RecordDataSize The size of RecordData buffer.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER RecordDataSize is too larger
|
||||
@retval EFI_OUT_OF_RESOURCES No memory to allocate new buffer for string
|
||||
@retval EFI_SUCCESS Sucess append string for a SMBIOS record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldString (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Fill the inter link field for a SMBIOS recorder.
|
||||
|
||||
Some SMBIOS recorder need to reference the handle of another SMBIOS record. But
|
||||
maybe another SMBIOS record has not been added, so put the InterLink request into
|
||||
a linked list and the interlink will be fixedup when a new SMBIOS record is added.
|
||||
|
||||
@param StructureNode Point to SMBIOS_STRUCTURE_NODE which reference another record's handle
|
||||
@param LinkSmbiosNodeOffset The offset in this record for holding the handle of another SMBIOS record
|
||||
@param LinkSmbiosType The type of SMBIOS record want to be linked.
|
||||
@param InterLink Point to EFI_INTER_LINK_DATA will be put linked list.
|
||||
@param SubClassGuid The guid of subclass for linked SMBIOS record.
|
||||
|
||||
@retval EFI_SUCESS The linked record is found and no need fixup in future.
|
||||
@retval !EFI_SUCESS The linked record can not be found and InterLink is put a fixing-p linked list.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFldInterLink (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT16 LinkSmbiosNodeOffset,
|
||||
IN UINT8 LinkSmbiosType,
|
||||
IN EFI_INTER_LINK_DATA *InterLink,
|
||||
IN EFI_GUID *SubClassGuid
|
||||
)
|
||||
;
|
||||
|
||||
/**
|
||||
Find a handle that matches the Link Data and the target Smbios type.
|
||||
|
||||
@param TargetType the Smbios type
|
||||
@param SubClass the SubClass
|
||||
@param LinkData Specifies Instance, SubInstance and ProducerName
|
||||
@param Handle the HandleNum found
|
||||
|
||||
@retval EFI_NOT_FOUND Can not find the record according to handle
|
||||
@retval EFI_SUCCESS Success to find the handle
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosFindHandle (
|
||||
IN UINT8 TargetType,
|
||||
IN EFI_GUID *SubClass,
|
||||
IN EFI_INTER_LINK_DATA *LinkData,
|
||||
IN OUT UINT16 *HandleNum
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldBase10ToWordWithMega (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldBase2ToWordWithKilo (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldTruncateToByte (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType6 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType9 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldProcessorType17 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldBase10ToByteWithNano (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldTruncateToWord (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldCacheType10 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
INT8
|
||||
SmbiosCheckTrailingZero (
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldCacheType5 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType2 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType3 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType4 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType5 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType6 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType7 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType8 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType9 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMemoryType10 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType0 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldBase2ToByteWith64K (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType1 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType2 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType3 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType8 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType9 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType10 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType11 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType12 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType13 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType14 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType15 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType21 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType32 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType38 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscTypeOEM (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldSMBIOSType6 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType22 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType22 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType23 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType24 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType25 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType26 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType27 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType28 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType29 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType30 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType34 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType36 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType38 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType39 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosFldMiscType127 (
|
||||
IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
|
||||
IN UINT32 Offset,
|
||||
IN VOID *RecordData,
|
||||
IN UINT32 RecordDataSize
|
||||
)
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
SmbiosProtocolCreateRecord (
|
||||
IN EFI_HANDLE ProducerHandle, OPTIONAL
|
||||
IN SMBIOS_STRUCTURE_NODE *StructureNode
|
||||
);
|
||||
|
||||
EFI_SMBIOS_PROTOCOL*
|
||||
GetSmbiosProtocol (
|
||||
VOID
|
||||
);
|
||||
|
||||
EFI_SMBIOS_TABLE_HEADER*
|
||||
GetSmbiosBufferFromHandle (
|
||||
IN EFI_SMBIOS_HANDLE Handle,
|
||||
IN EFI_SMBIOS_TYPE Type,
|
||||
IN EFI_HANDLE ProducerHandle OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetSmbiosStructureSize (
|
||||
IN EFI_SMBIOS_TABLE_HEADER *Head,
|
||||
OUT UINT32 *Size,
|
||||
OUT UINT8 *NumberOfStrings
|
||||
);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,591 @@
|
|||
/**@file
|
||||
Translate the DataHub records via EFI_DATA_HUB_PROTOCOL to Smbios recorders
|
||||
via EFI_SMBIOS_PROTOCOL.
|
||||
|
||||
Copyright (c) 2009, Intel Corporation
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#include "Thunk.h"
|
||||
|
||||
EFI_GUID ZeroGuid = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } };
|
||||
EFI_SMBIOS_PROTOCOL *mSmbiosProtocol = NULL;
|
||||
|
||||
/**
|
||||
Release the structure Node.
|
||||
|
||||
@param StructureNode Point to SMBIOS_STRUCTURE_NODE which will be removed.
|
||||
**/
|
||||
VOID
|
||||
ReleaseStructureNode (
|
||||
SMBIOS_STRUCTURE_NODE *StructureNode
|
||||
)
|
||||
{
|
||||
EFI_SMBIOS_PROTOCOL *Smbios;
|
||||
|
||||
RemoveEntryList (&(StructureNode->Link));
|
||||
Smbios = GetSmbiosProtocol();
|
||||
ASSERT (Smbios != NULL);
|
||||
Smbios->Remove (Smbios, StructureNode->SmbiosHandle);
|
||||
gBS->FreePool (StructureNode);
|
||||
}
|
||||
|
||||
/**
|
||||
Process a datahub's record and find corresponding translation way to translate
|
||||
to SMBIOS record.
|
||||
|
||||
@param Record Point to datahub record.
|
||||
**/
|
||||
VOID
|
||||
SmbiosProcessDataRecord (
|
||||
IN EFI_DATA_RECORD_HEADER *Record
|
||||
)
|
||||
{
|
||||
EFI_DATA_RECORD_HEADER *RecordHeader;
|
||||
EFI_SUBCLASS_TYPE1_HEADER *DataHeader;
|
||||
UINTN Index;
|
||||
SMBIOS_CONVERSION_TABLE_ENTRY *Conversion;
|
||||
UINT8 *SrcData;
|
||||
UINTN SrcDataSize;
|
||||
LIST_ENTRY *Link;
|
||||
SMBIOS_STRUCTURE_NODE *StructureNode;
|
||||
BOOLEAN StructureCreated;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Conversion = NULL;
|
||||
StructureNode = NULL;
|
||||
StructureCreated = FALSE;
|
||||
RecordHeader = Record;
|
||||
DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
|
||||
SrcData = (UINT8 *) (DataHeader + 1);
|
||||
SrcDataSize = RecordHeader->RecordSize - RecordHeader->HeaderSize - sizeof (EFI_SUBCLASS_TYPE1_HEADER);
|
||||
|
||||
if (DataHeader->HeaderSize != sizeof (EFI_SUBCLASS_TYPE1_HEADER) ||
|
||||
DataHeader->Instance == EFI_SUBCLASS_INSTANCE_RESERVED ||
|
||||
DataHeader->SubInstance == EFI_SUBCLASS_INSTANCE_RESERVED
|
||||
) {
|
||||
//
|
||||
// Invalid Data Record
|
||||
//
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Index = 0;
|
||||
while(TRUE) {
|
||||
//
|
||||
// Find a matching entry in the conversion table for this
|
||||
// (SubClass, RecordNumber) pair
|
||||
//
|
||||
for (; !CompareGuid (&(mConversionTable[Index].SubClass), &ZeroGuid); Index++) {
|
||||
if (CompareGuid (
|
||||
&(mConversionTable[Index].SubClass),
|
||||
&(RecordHeader->DataRecordGuid)
|
||||
)) {
|
||||
if (mConversionTable[Index].RecordType == DataHeader->RecordType) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CompareGuid (&(mConversionTable[Index].SubClass), &ZeroGuid)) {
|
||||
//
|
||||
// We cannot find a matching entry in conversion table,
|
||||
// this means this data record cannot be used for SMBIOS.
|
||||
// Just skip it.
|
||||
//
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Conversion = &mConversionTable[Index++];
|
||||
|
||||
//
|
||||
// Find corresponding structure in the Structure List
|
||||
//
|
||||
for (Link = mStructureList.ForwardLink; Link != &mStructureList; Link = Link->ForwardLink) {
|
||||
|
||||
StructureNode = CR (
|
||||
Link,
|
||||
SMBIOS_STRUCTURE_NODE,
|
||||
Link,
|
||||
SMBIOS_STRUCTURE_NODE_SIGNATURE
|
||||
);
|
||||
|
||||
if (Conversion->StructureLocatingMethod == BY_SUBCLASS_INSTANCE_SUBINSTANCE_PRODUCER) {
|
||||
//
|
||||
// Look at SubClass, Instance, SubInstance and ProducerName for a matching
|
||||
// node
|
||||
//
|
||||
if (CompareGuid (&(StructureNode->SubClass), &(RecordHeader->DataRecordGuid)) &&
|
||||
StructureNode->Instance == DataHeader->Instance &&
|
||||
StructureNode->SubInstance == DataHeader->SubInstance &&
|
||||
CompareGuid (&(StructureNode->ProducerName), &(RecordHeader->ProducerName))
|
||||
) {
|
||||
if (Conversion->SmbiosType >= 0X80) {
|
||||
if (StructureNode->SmbiosType == ((SMBIOS_STRUCTURE_HDR *) SrcData)->Type) {
|
||||
break;
|
||||
}
|
||||
} else if (StructureNode->SmbiosType == Conversion->SmbiosType) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (Conversion->StructureLocatingMethod == BY_SUBCLASS_INSTANCE_PRODUCER) {
|
||||
//
|
||||
// Look at SubClass, Instance and ProducerName for a matching node
|
||||
//
|
||||
if (CompareGuid (&(StructureNode->SubClass), &(RecordHeader->DataRecordGuid)) &&
|
||||
StructureNode->Instance == DataHeader->Instance &&
|
||||
CompareGuid (&(StructureNode->ProducerName), &(RecordHeader->ProducerName))
|
||||
) {
|
||||
if (Conversion->SmbiosType >= 0X80) {
|
||||
if (StructureNode->SmbiosType == ((SMBIOS_STRUCTURE_HDR *) SrcData)->Type) {
|
||||
break;
|
||||
}
|
||||
} else if (StructureNode->SmbiosType == Conversion->SmbiosType) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//
|
||||
// Invalid conversion table entry
|
||||
//
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
if (Link == &mStructureList) {
|
||||
|
||||
//
|
||||
// Not found, create a new structure
|
||||
//
|
||||
StructureNode = AllocateZeroPool (sizeof (SMBIOS_STRUCTURE_NODE));
|
||||
|
||||
if (!StructureNode) {
|
||||
goto Done;
|
||||
}
|
||||
|
||||
if (Conversion->StructureLocatingMethod == BY_SUBCLASS_INSTANCE_SUBINSTANCE_PRODUCER) {
|
||||
//
|
||||
// Fill in SubClass, Instance, SubInstance and ProducerName
|
||||
//
|
||||
CopyMem (&(StructureNode->SubClass), &(RecordHeader->DataRecordGuid), sizeof (EFI_GUID));
|
||||
StructureNode->Instance = DataHeader->Instance;
|
||||
StructureNode->SubInstance = DataHeader->SubInstance;
|
||||
CopyMem (&(StructureNode->ProducerName), &(RecordHeader->ProducerName), sizeof (EFI_GUID));
|
||||
|
||||
} else if (Conversion->StructureLocatingMethod == BY_SUBCLASS_INSTANCE_PRODUCER) {
|
||||
//
|
||||
// Fill in at SubClass, Instance and ProducerName, mark SubInstance as Non
|
||||
// Applicable
|
||||
//
|
||||
CopyMem (&(StructureNode->SubClass), &(RecordHeader->DataRecordGuid), sizeof (EFI_GUID));
|
||||
StructureNode->Instance = DataHeader->Instance;
|
||||
StructureNode->SubInstance = EFI_SUBCLASS_INSTANCE_NON_APPLICABLE;
|
||||
CopyMem (&(StructureNode->ProducerName), &(RecordHeader->ProducerName), sizeof (EFI_GUID));
|
||||
|
||||
}
|
||||
//
|
||||
// Allocate the structure instance
|
||||
//
|
||||
StructureNode->StructureSize = SmbiosGetTypeMinimalLength (Conversion->SmbiosType);
|
||||
StructureNode->SmbiosType = Conversion->SmbiosType;
|
||||
|
||||
//
|
||||
// StructureSize include the TWO trailing zero byte.
|
||||
//
|
||||
if (StructureNode->StructureSize < (sizeof(SMBIOS_STRUCTURE) + 2)) {
|
||||
//
|
||||
// Invalid Type
|
||||
//
|
||||
gBS->FreePool (StructureNode);
|
||||
goto Done;
|
||||
}
|
||||
|
||||
StructureNode->SmbiosType = Conversion->SmbiosType;
|
||||
StructureNode->SmbiosHandle = 0;
|
||||
Status = SmbiosProtocolCreateRecord (
|
||||
NULL,
|
||||
StructureNode
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Done;
|
||||
}
|
||||
//
|
||||
// Temporary cache the structrue pointer to Smbios database.
|
||||
//
|
||||
StructureNode->Structure = GetSmbiosBufferFromHandle (StructureNode->SmbiosHandle, StructureNode->SmbiosType, NULL);
|
||||
|
||||
InitializeListHead (&StructureNode->LinkDataFixup);
|
||||
|
||||
//
|
||||
// Insert the Structure Node into the Strucutre List
|
||||
//
|
||||
StructureNode->Signature = SMBIOS_STRUCTURE_NODE_SIGNATURE;
|
||||
InsertTailList (&mStructureList, &(StructureNode->Link));
|
||||
|
||||
StructureCreated = TRUE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Re-calculate the structure pointer to Smbios database.
|
||||
//
|
||||
StructureNode->Structure = GetSmbiosBufferFromHandle (StructureNode->SmbiosHandle, StructureNode->SmbiosType, NULL);
|
||||
|
||||
//
|
||||
// Fill the Structure's field corresponding to this data record
|
||||
//
|
||||
if (Conversion->FieldFillingMethod == RECORD_DATA_UNCHANGED_OFFSET_SPECIFIED) {
|
||||
//
|
||||
// Field data is just the record data without transforming and
|
||||
// offset is specified directly in the conversion table entry
|
||||
//
|
||||
if (Conversion->FieldOffset + SrcDataSize > StructureNode->Structure->Length) {
|
||||
//
|
||||
// Invalid Conversion Table Entry
|
||||
//
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
|
||||
CopyMem ((UINT8 *) (StructureNode->Structure) + Conversion->FieldOffset, SrcData, SrcDataSize);
|
||||
|
||||
} else if (Conversion->FieldFillingMethod == BY_FUNCTION_WITH_OFFSET_SPECIFIED) {
|
||||
//
|
||||
// Field offfset is specified in the conversion table entry, but
|
||||
// record data needs to be transformed to be filled into the field,
|
||||
// so let the FieldFillingFunction do it.
|
||||
//
|
||||
if (!(Conversion->FieldFillingFunction)) {
|
||||
//
|
||||
// Invalid Conversion Table Entry
|
||||
//
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = Conversion->FieldFillingFunction (
|
||||
StructureNode,
|
||||
Conversion->FieldOffset,
|
||||
SrcData,
|
||||
(UINT32) SrcDataSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
} else if (Conversion->FieldFillingMethod == BY_FUNCTION) {
|
||||
//
|
||||
// Both field offset and field content are determined by
|
||||
// FieldFillingFunction
|
||||
//
|
||||
if (!(Conversion->FieldFillingFunction)) {
|
||||
//
|
||||
// Invalid Conversion Table Entry
|
||||
//
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = Conversion->FieldFillingFunction (
|
||||
StructureNode,
|
||||
0,
|
||||
SrcData,
|
||||
(UINT32) SrcDataSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
} else if (Conversion->FieldFillingMethod == BY_FUNCTION_WITH_WHOLE_DATA_RECORD) {
|
||||
//
|
||||
// Both field offset and field content are determined by
|
||||
// FieldFillingFunction and the function accepts the whole data record
|
||||
// including the data header
|
||||
//
|
||||
if (!(Conversion->FieldFillingFunction)) {
|
||||
//
|
||||
// Invalid Conversion Table Entry
|
||||
//
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
|
||||
Status = Conversion->FieldFillingFunction (
|
||||
StructureNode,
|
||||
0,
|
||||
DataHeader,
|
||||
RecordHeader->RecordSize - RecordHeader->HeaderSize
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Invalid Conversion Table Entry
|
||||
//
|
||||
if (StructureCreated) {
|
||||
ReleaseStructureNode (StructureNode);
|
||||
}
|
||||
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
Done:
|
||||
return ;
|
||||
}
|
||||
|
||||
/**
|
||||
Calculate the minimal length for a SMBIOS type. This length maybe not equal
|
||||
to sizeof (SMBIOS_RECORD_STRUCTURE), but defined in conformance chapter in SMBIOS specification.
|
||||
|
||||
@param Type SMBIOS's type.
|
||||
|
||||
@return the minimal length of a smbios record.
|
||||
**/
|
||||
UINT32
|
||||
SmbiosGetTypeMinimalLength (
|
||||
IN UINT8 Type
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; mTypeInfoTable[Index].MinLength != 0; Index++) {
|
||||
if (mTypeInfoTable[Index].Type == Type) {
|
||||
return mTypeInfoTable[Index].MinLength;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
Get pointer of EFI_SMBIOS_PROTOCOL.
|
||||
|
||||
@return pointer of EFI_SMBIOS_PROTOCOL.
|
||||
**/
|
||||
EFI_SMBIOS_PROTOCOL*
|
||||
GetSmbiosProtocol(
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
if (mSmbiosProtocol == NULL) {
|
||||
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID*) &mSmbiosProtocol);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
ASSERT (mSmbiosProtocol != NULL);
|
||||
return mSmbiosProtocol;
|
||||
}
|
||||
|
||||
/**
|
||||
Create a blank smbios record. The datahub record is only a field of smbios record.
|
||||
So before fill any field from datahub's record. A blank smbios record need to be
|
||||
created.
|
||||
|
||||
@param ProducerHandle The produce handle for a datahub record
|
||||
@param StructureNode Point to SMBIOS_STRUCTURE_NODE
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Fail to allocate memory for new blank SMBIOS record.
|
||||
@retval EFI_SUCCESS Success to create blank smbios record.
|
||||
**/
|
||||
EFI_STATUS
|
||||
SmbiosProtocolCreateRecord (
|
||||
IN EFI_HANDLE ProducerHandle, OPTIONAL
|
||||
IN SMBIOS_STRUCTURE_NODE *StructureNode
|
||||
)
|
||||
{
|
||||
EFI_SMBIOS_PROTOCOL *Smbios;
|
||||
EFI_SMBIOS_TABLE_HEADER *BlankRecord;
|
||||
EFI_STATUS Status;
|
||||
SMBIOS_STRUCTURE_NODE *RefStructureNode;
|
||||
LIST_ENTRY *Link;
|
||||
LIST_ENTRY *Link1;
|
||||
LIST_ENTRY *Link2;
|
||||
SMBIOS_LINK_DATA_FIXUP_NODE *LinkDataFixupNode;
|
||||
UINT8 *BufferPointer;
|
||||
|
||||
Smbios = GetSmbiosProtocol();
|
||||
ASSERT (Smbios != NULL);
|
||||
|
||||
//
|
||||
// Prepare a blank smbios record.
|
||||
//
|
||||
BlankRecord = (EFI_SMBIOS_TABLE_HEADER*) AllocateZeroPool (StructureNode->StructureSize);
|
||||
if (BlankRecord == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
BlankRecord->Type = StructureNode->SmbiosType;
|
||||
BlankRecord->Length = (UINT8) (StructureNode->StructureSize - 2);
|
||||
|
||||
//
|
||||
// Add blank record into SMBIOS database.
|
||||
//
|
||||
Status = Smbios->Add (Smbios, NULL, &StructureNode->SmbiosHandle, BlankRecord);
|
||||
FreePool (BlankRecord);
|
||||
|
||||
//
|
||||
// Fix up the InterLink node for new added smbios record if some other
|
||||
// existing smbios record want to link this new record's handle.
|
||||
//
|
||||
for (Link = mStructureList.ForwardLink; Link != &mStructureList; Link = Link->ForwardLink) {
|
||||
RefStructureNode = CR (Link, SMBIOS_STRUCTURE_NODE, Link, SMBIOS_STRUCTURE_NODE_SIGNATURE);
|
||||
for (Link1 = RefStructureNode->LinkDataFixup.ForwardLink; Link1 != &RefStructureNode->LinkDataFixup;) {
|
||||
LinkDataFixupNode = CR (Link1, SMBIOS_LINK_DATA_FIXUP_NODE, Link, SMBIOS_LINK_DATA_FIXUP_NODE_SIGNATURE);
|
||||
Link2 = Link1;
|
||||
Link1 = Link1->ForwardLink;
|
||||
|
||||
if ((StructureNode->SmbiosType != LinkDataFixupNode->TargetType) ||
|
||||
!(CompareGuid (&StructureNode->SubClass, &LinkDataFixupNode->SubClass)) ||
|
||||
(StructureNode->Instance != LinkDataFixupNode->LinkData.Instance) ||
|
||||
(StructureNode->SubInstance != LinkDataFixupNode->LinkData.SubInstance)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Fill the field with the handle found
|
||||
//
|
||||
BufferPointer = (UINT8 *) (RefStructureNode->Structure) + LinkDataFixupNode->Offset;
|
||||
*BufferPointer = (UINT8) (StructureNode->SmbiosHandle & 0xFF);
|
||||
*(BufferPointer + 1) = (UINT8) ((StructureNode->SmbiosHandle >> 8) & 0xFF);
|
||||
BufferPointer = NULL;
|
||||
|
||||
RemoveEntryList (Link2);
|
||||
FreePool (LinkDataFixupNode);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Get pointer of a SMBIOS record's buffer according to its handle.
|
||||
|
||||
@param Handle The handle of SMBIOS record want to be searched.
|
||||
@param Type The type of SMBIOS record want to be searched.
|
||||
@param ProducerHandle The producer handle of SMBIOS record.
|
||||
|
||||
@return EFI_SMBIOS_TABLE_HEADER Point to a SMBIOS record's buffer.
|
||||
**/
|
||||
EFI_SMBIOS_TABLE_HEADER*
|
||||
GetSmbiosBufferFromHandle (
|
||||
IN EFI_SMBIOS_HANDLE Handle,
|
||||
IN EFI_SMBIOS_TYPE Type,
|
||||
IN EFI_HANDLE ProducerHandle OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_SMBIOS_PROTOCOL* Smbios;
|
||||
EFI_SMBIOS_HANDLE SearchingHandle;
|
||||
EFI_SMBIOS_TABLE_HEADER *RecordInSmbiosDatabase;
|
||||
EFI_STATUS Status;
|
||||
|
||||
SearchingHandle = 0;
|
||||
Smbios = GetSmbiosProtocol();
|
||||
ASSERT (Smbios != NULL);
|
||||
|
||||
do {
|
||||
Status = Smbios->GetNext (Smbios, &SearchingHandle, &Type, &RecordInSmbiosDatabase, NULL);
|
||||
} while ((SearchingHandle != Handle) && (Status != EFI_NOT_FOUND));
|
||||
|
||||
return RecordInSmbiosDatabase;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Get the full size of smbios structure including optional strings that follow the formatted structure.
|
||||
|
||||
@param Head Pointer to the beginning of smbios structure.
|
||||
@param Size The returned size.
|
||||
@param NumberOfStrings The returned number of optional strings that follow the formatted structure.
|
||||
|
||||
@retval EFI_SUCCESS Size retured in Size.
|
||||
@retval EFI_INVALID_PARAMETER Input smbios structure mal-formed or Size is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
GetSmbiosStructureSize (
|
||||
IN EFI_SMBIOS_TABLE_HEADER *Head,
|
||||
OUT UINT32 *Size,
|
||||
OUT UINT8 *NumberOfStrings
|
||||
)
|
||||
{
|
||||
UINT32 FullSize;
|
||||
UINT8 StrLen;
|
||||
INT8* CharInStr;
|
||||
|
||||
if (Size == NULL || NumberOfStrings == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
FullSize = Head->Length;
|
||||
CharInStr = (INT8*)Head + Head->Length;
|
||||
*Size = FullSize;
|
||||
*NumberOfStrings = 0;
|
||||
StrLen = 0;
|
||||
//
|
||||
// look for the two consecutive zeros, check the string limit by the way.
|
||||
//
|
||||
while (*CharInStr != 0 || *(CharInStr+1) != 0) {
|
||||
if (*CharInStr == 0) {
|
||||
*Size += 1;
|
||||
CharInStr++;
|
||||
}
|
||||
|
||||
for (StrLen = 0 ; StrLen < SMBIOS_STRING_MAX_LENGTH; StrLen++) {
|
||||
if (*(CharInStr+StrLen) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrLen == SMBIOS_STRING_MAX_LENGTH) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// forward the pointer
|
||||
//
|
||||
CharInStr += StrLen;
|
||||
*Size += StrLen;
|
||||
*NumberOfStrings += 1;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// count ending two zeros.
|
||||
//
|
||||
*Size += 2;
|
||||
return EFI_SUCCESS;
|
||||
}
|
|
@ -243,6 +243,7 @@ define GCC_MACRO = -DEFI_SPECIFICATION_VERSION=0x00020000 -DPI_S
|
|||
EdkCompatibilityPkg/Compatibility/UcOnUc2Thunk/UcOnUc2Thunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/PrintThunk/PrintThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/LegacyRegion2OnLegacyRegionThunk/LegacyRegion2OnLegacyRegionThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/DataHubSmBiosRecordsOnPiSmBiosThunk/DataHubSmBiosRecordsOnPiSmBiosThunk.inf
|
||||
EdkCompatibilityPkg/Compatibility/CpuIo2OnCpuIoThunk/CpuIo2OnCpuIoThunk.inf
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue