summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c')
-rw-r--r--MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c641
1 files changed, 335 insertions, 306 deletions
diff --git a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
index 804eedbf92..81df59cd0f 100644
--- a/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
+++ b/MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
@@ -14,16 +14,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Since this driver will only ever produce one instance of the
// protocol you are not required to dynamically allocate the PrivateData.
//
-SMBIOS_INSTANCE mPrivateData;
+SMBIOS_INSTANCE mPrivateData;
-UINTN mPreAllocatedPages = 0;
-UINTN mPre64BitAllocatedPages = 0;
+UINTN mPreAllocatedPages = 0;
+UINTN mPre64BitAllocatedPages = 0;
//
// Chassis for SMBIOS entry point structure that is to be installed into EFI system config table.
//
-SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure = NULL;
-SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = {
+SMBIOS_TABLE_ENTRY_POINT *EntryPointStructure = NULL;
+SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = {
//
// AnchorString
//
@@ -99,8 +99,8 @@ SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = {
0
};
-SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30EntryPointStructure = NULL;
-SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructureData = {
+SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30EntryPointStructure = NULL;
+SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructureData = {
//
// AnchorString _SM3_
//
@@ -149,9 +149,9 @@ SMBIOS_TABLE_3_0_ENTRY_POINT Smbios30EntryPointStructureData = {
0
};
-IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
- {&gUniversalPayloadSmbios3TableGuid, IsValidSmbios30Table },
- {&gUniversalPayloadSmbiosTableGuid, IsValidSmbios20Table }
+IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
+ { &gUniversalPayloadSmbios3TableGuid, IsValidSmbios30Table },
+ { &gUniversalPayloadSmbiosTableGuid, IsValidSmbios20Table }
};
/**
@@ -170,26 +170,26 @@ IS_SMBIOS_TABLE_VALID_ENTRY mIsSmbiosTableValid[] = {
EFI_STATUS
EFIAPI
GetSmbiosStructureSize (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN EFI_SMBIOS_TABLE_HEADER *Head,
- OUT UINTN *Size,
- OUT UINTN *NumberOfStrings
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN EFI_SMBIOS_TABLE_HEADER *Head,
+ OUT UINTN *Size,
+ OUT UINTN *NumberOfStrings
)
{
UINTN FullSize;
UINTN StrLen;
UINTN MaxLen;
- INT8* CharInStr;
+ INT8 *CharInStr;
- if (Size == NULL || NumberOfStrings == NULL) {
+ if ((Size == NULL) || (NumberOfStrings == NULL)) {
return EFI_INVALID_PARAMETER;
}
- FullSize = Head->Length;
- CharInStr = (INT8*)Head + Head->Length;
- *Size = FullSize;
+ FullSize = Head->Length;
+ CharInStr = (INT8 *)Head + Head->Length;
+ *Size = FullSize;
*NumberOfStrings = 0;
- StrLen = 0;
+ StrLen = 0;
//
// look for the two consecutive zeros, check the string limit by the way.
//
@@ -199,7 +199,7 @@ GetSmbiosStructureSize (
CharInStr++;
}
- if (This->MajorVersion < 2 || (This->MajorVersion == 2 && This->MinorVersion < 7)){
+ if ((This->MajorVersion < 2) || ((This->MajorVersion == 2) && (This->MinorVersion < 7))) {
MaxLen = SMBIOS_STRING_MAX_LENGTH;
} else if (This->MajorVersion < 3) {
//
@@ -217,7 +217,7 @@ GetSmbiosStructureSize (
MaxLen = SMBIOS_3_0_TABLE_MAX_LENGTH;
}
- for (StrLen = 0 ; StrLen < MaxLen; StrLen++) {
+ for (StrLen = 0; StrLen < MaxLen; StrLen++) {
if (*(CharInStr+StrLen) == 0) {
break;
}
@@ -230,8 +230,8 @@ GetSmbiosStructureSize (
//
// forward the pointer
//
- CharInStr += StrLen;
- *Size += StrLen;
+ CharInStr += StrLen;
+ *Size += StrLen;
*NumberOfStrings += 1;
}
@@ -256,15 +256,15 @@ GetSmbiosStructureSize (
BOOLEAN
EFIAPI
CheckSmbiosHandleExistance (
- IN LIST_ENTRY *Head,
- IN EFI_SMBIOS_HANDLE Handle
+ IN LIST_ENTRY *Head,
+ IN EFI_SMBIOS_HANDLE Handle
)
{
- LIST_ENTRY *Link;
- SMBIOS_HANDLE_ENTRY *HandleEntry;
+ LIST_ENTRY *Link;
+ SMBIOS_HANDLE_ENTRY *HandleEntry;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
- HandleEntry = SMBIOS_HANDLE_ENTRY_FROM_LINK(Link);
+ HandleEntry = SMBIOS_HANDLE_ENTRY_FROM_LINK (Link);
if (HandleEntry->SmbiosHandle == Handle) {
return TRUE;
}
@@ -284,11 +284,11 @@ CheckSmbiosHandleExistance (
VOID
EFIAPI
GetMaxSmbiosHandle (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN OUT EFI_SMBIOS_HANDLE *MaxHandle
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN OUT EFI_SMBIOS_HANDLE *MaxHandle
)
{
- if (This->MajorVersion == 2 && This->MinorVersion == 0) {
+ if ((This->MajorVersion == 2) && (This->MinorVersion == 0)) {
*MaxHandle = 0xFFFE;
} else {
*MaxHandle = 0xFEFF;
@@ -309,21 +309,21 @@ GetMaxSmbiosHandle (
EFI_STATUS
EFIAPI
GetAvailableSmbiosHandle (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN OUT EFI_SMBIOS_HANDLE *Handle
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN OUT EFI_SMBIOS_HANDLE *Handle
)
{
- LIST_ENTRY *Head;
- SMBIOS_INSTANCE *Private;
- EFI_SMBIOS_HANDLE MaxSmbiosHandle;
- EFI_SMBIOS_HANDLE AvailableHandle;
+ LIST_ENTRY *Head;
+ SMBIOS_INSTANCE *Private;
+ EFI_SMBIOS_HANDLE MaxSmbiosHandle;
+ EFI_SMBIOS_HANDLE AvailableHandle;
- GetMaxSmbiosHandle(This, &MaxSmbiosHandle);
+ GetMaxSmbiosHandle (This, &MaxSmbiosHandle);
Private = SMBIOS_INSTANCE_FROM_THIS (This);
- Head = &Private->AllocatedHandleListHead;
+ Head = &Private->AllocatedHandleListHead;
for (AvailableHandle = 0; AvailableHandle < MaxSmbiosHandle; AvailableHandle++) {
- if (!CheckSmbiosHandleExistance(Head, AvailableHandle)) {
+ if (!CheckSmbiosHandleExistance (Head, AvailableHandle)) {
*Handle = AvailableHandle;
return EFI_SUCCESS;
}
@@ -332,7 +332,6 @@ GetAvailableSmbiosHandle (
return EFI_OUT_OF_RESOURCES;
}
-
/**
Add an SMBIOS record.
@@ -361,20 +360,20 @@ SmbiosAdd (
IN EFI_SMBIOS_TABLE_HEADER *Record
)
{
- VOID *Raw;
- UINTN TotalSize;
- UINTN RecordSize;
- UINTN StructureSize;
- UINTN NumberOfStrings;
- EFI_STATUS Status;
- LIST_ENTRY *Head;
- SMBIOS_INSTANCE *Private;
- EFI_SMBIOS_ENTRY *SmbiosEntry;
- EFI_SMBIOS_HANDLE MaxSmbiosHandle;
- SMBIOS_HANDLE_ENTRY *HandleEntry;
- EFI_SMBIOS_RECORD_HEADER *InternalRecord;
- BOOLEAN Smbios32BitTable;
- BOOLEAN Smbios64BitTable;
+ VOID *Raw;
+ UINTN TotalSize;
+ UINTN RecordSize;
+ UINTN StructureSize;
+ UINTN NumberOfStrings;
+ EFI_STATUS Status;
+ LIST_ENTRY *Head;
+ SMBIOS_INSTANCE *Private;
+ EFI_SMBIOS_ENTRY *SmbiosEntry;
+ EFI_SMBIOS_HANDLE MaxSmbiosHandle;
+ SMBIOS_HANDLE_ENTRY *HandleEntry;
+ EFI_SMBIOS_RECORD_HEADER *InternalRecord;
+ BOOLEAN Smbios32BitTable;
+ BOOLEAN Smbios64BitTable;
if (SmbiosHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -385,7 +384,7 @@ SmbiosAdd (
// Check whether SmbiosHandle is already in use
//
Head = &Private->AllocatedHandleListHead;
- if (*SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED && CheckSmbiosHandleExistance(Head, *SmbiosHandle)) {
+ if ((*SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) && CheckSmbiosHandleExistance (Head, *SmbiosHandle)) {
return EFI_ALREADY_STARTED;
}
@@ -393,15 +392,15 @@ SmbiosAdd (
// when SmbiosHandle is 0xFFFE, an available handle will be assigned
//
if (*SmbiosHandle == SMBIOS_HANDLE_PI_RESERVED) {
- Status = GetAvailableSmbiosHandle(This, SmbiosHandle);
- if (EFI_ERROR(Status)) {
+ Status = GetAvailableSmbiosHandle (This, SmbiosHandle);
+ if (EFI_ERROR (Status)) {
return Status;
}
} else {
//
// Check this handle validity
//
- GetMaxSmbiosHandle(This, &MaxSmbiosHandle);
+ GetMaxSmbiosHandle (This, &MaxSmbiosHandle);
if (*SmbiosHandle > MaxSmbiosHandle) {
return EFI_INVALID_PARAMETER;
}
@@ -410,22 +409,24 @@ SmbiosAdd (
//
// Calculate record size and string number
//
- Status = GetSmbiosStructureSize(This, Record, &StructureSize, &NumberOfStrings);
- if (EFI_ERROR(Status)) {
+ Status = GetSmbiosStructureSize (This, Record, &StructureSize, &NumberOfStrings);
+ if (EFI_ERROR (Status)) {
return Status;
}
Smbios32BitTable = FALSE;
Smbios64BitTable = FALSE;
if ((This->MajorVersion < 0x3) ||
- ((This->MajorVersion >= 0x3) && ((PcdGet32 (PcdSmbiosEntryPointProvideMethod) & BIT0) == BIT0))) {
+ ((This->MajorVersion >= 0x3) && ((PcdGet32 (PcdSmbiosEntryPointProvideMethod) & BIT0) == BIT0)))
+ {
//
// For SMBIOS 32-bit table, the length of the entire structure table (including all strings) must be reported
// in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
// which is a WORD field limited to 65,535 bytes. So the max size of 32-bit table should not exceed 65,535 bytes.
//
if ((EntryPointStructure != NULL) &&
- (EntryPointStructure->TableLength + StructureSize > SMBIOS_TABLE_MAX_LENGTH)) {
+ (EntryPointStructure->TableLength + StructureSize > SMBIOS_TABLE_MAX_LENGTH))
+ {
DEBUG ((DEBUG_INFO, "SmbiosAdd: Total length exceeds max 32-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize));
} else {
Smbios32BitTable = TRUE;
@@ -442,7 +443,8 @@ SmbiosAdd (
// is a DWORD field limited to 0xFFFFFFFF bytes. So the max size of 64-bit table should not exceed 0xFFFFFFFF bytes.
//
if ((Smbios30EntryPointStructure != NULL) &&
- (Smbios30EntryPointStructure->TableMaximumSize + StructureSize > SMBIOS_3_0_TABLE_MAX_LENGTH)) {
+ (Smbios30EntryPointStructure->TableMaximumSize + StructureSize > SMBIOS_3_0_TABLE_MAX_LENGTH))
+ {
DEBUG ((DEBUG_INFO, "SmbiosAdd: Total length exceeds max 64-bit table length with type = %d size = 0x%x\n", Record->Type, StructureSize));
} else {
DEBUG ((DEBUG_INFO, "SmbiosAdd: Smbios type %d with size 0x%x is added to 64-bit table\n", Record->Type, StructureSize));
@@ -465,8 +467,8 @@ SmbiosAdd (
return Status;
}
- RecordSize = sizeof (EFI_SMBIOS_RECORD_HEADER) + StructureSize;
- TotalSize = sizeof (EFI_SMBIOS_ENTRY) + RecordSize;
+ RecordSize = sizeof (EFI_SMBIOS_RECORD_HEADER) + StructureSize;
+ TotalSize = sizeof (EFI_SMBIOS_ENTRY) + RecordSize;
//
// Allocate internal buffer
@@ -476,7 +478,8 @@ SmbiosAdd (
EfiReleaseLock (&Private->DataLock);
return EFI_OUT_OF_RESOURCES;
}
- HandleEntry = AllocateZeroPool (sizeof(SMBIOS_HANDLE_ENTRY));
+
+ HandleEntry = AllocateZeroPool (sizeof (SMBIOS_HANDLE_ENTRY));
if (HandleEntry == NULL) {
EfiReleaseLock (&Private->DataLock);
return EFI_OUT_OF_RESOURCES;
@@ -485,33 +488,33 @@ SmbiosAdd (
//
// Build Handle Entry and insert into linked list
//
- HandleEntry->Signature = SMBIOS_HANDLE_ENTRY_SIGNATURE;
- HandleEntry->SmbiosHandle = *SmbiosHandle;
- InsertTailList(&Private->AllocatedHandleListHead, &HandleEntry->Link);
+ HandleEntry->Signature = SMBIOS_HANDLE_ENTRY_SIGNATURE;
+ HandleEntry->SmbiosHandle = *SmbiosHandle;
+ InsertTailList (&Private->AllocatedHandleListHead, &HandleEntry->Link);
- InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (SmbiosEntry + 1);
- Raw = (VOID *) (InternalRecord + 1);
+ InternalRecord = (EFI_SMBIOS_RECORD_HEADER *)(SmbiosEntry + 1);
+ Raw = (VOID *)(InternalRecord + 1);
//
// Build internal record Header
//
- InternalRecord->Version = EFI_SMBIOS_RECORD_HEADER_VERSION;
- InternalRecord->HeaderSize = (UINT16) sizeof (EFI_SMBIOS_RECORD_HEADER);
- InternalRecord->RecordSize = RecordSize;
- InternalRecord->ProducerHandle = ProducerHandle;
+ InternalRecord->Version = EFI_SMBIOS_RECORD_HEADER_VERSION;
+ InternalRecord->HeaderSize = (UINT16)sizeof (EFI_SMBIOS_RECORD_HEADER);
+ InternalRecord->RecordSize = RecordSize;
+ InternalRecord->ProducerHandle = ProducerHandle;
InternalRecord->NumberOfStrings = NumberOfStrings;
//
// Insert record into the internal linked list
//
- SmbiosEntry->Signature = EFI_SMBIOS_ENTRY_SIGNATURE;
- SmbiosEntry->RecordHeader = InternalRecord;
- SmbiosEntry->RecordSize = TotalSize;
+ SmbiosEntry->Signature = EFI_SMBIOS_ENTRY_SIGNATURE;
+ SmbiosEntry->RecordHeader = InternalRecord;
+ SmbiosEntry->RecordSize = TotalSize;
SmbiosEntry->Smbios32BitTable = Smbios32BitTable;
SmbiosEntry->Smbios64BitTable = Smbios64BitTable;
InsertTailList (&Private->DataListHead, &SmbiosEntry->Link);
CopyMem (Raw, Record, StructureSize);
- ((EFI_SMBIOS_TABLE_HEADER*)Raw)->Handle = *SmbiosHandle;
+ ((EFI_SMBIOS_TABLE_HEADER *)Raw)->Handle = *SmbiosHandle;
//
// Some UEFI drivers (such as network) need some information in SMBIOS table.
@@ -545,10 +548,10 @@ SmbiosAdd (
EFI_STATUS
EFIAPI
SmbiosUpdateString (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN EFI_SMBIOS_HANDLE *SmbiosHandle,
- IN UINTN *StringNumber,
- IN CHAR8 *String
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN EFI_SMBIOS_HANDLE *SmbiosHandle,
+ IN UINTN *StringNumber,
+ IN CHAR8 *String
)
{
UINTN InputStrLen;
@@ -571,7 +574,7 @@ SmbiosUpdateString (
//
// Check args validity
//
- GetMaxSmbiosHandle(This, &MaxSmbiosHandle);
+ GetMaxSmbiosHandle (This, &MaxSmbiosHandle);
if (*SmbiosHandle > MaxSmbiosHandle) {
return EFI_INVALID_PARAMETER;
@@ -585,9 +588,9 @@ SmbiosUpdateString (
return EFI_NOT_FOUND;
}
- InputStrLen = AsciiStrLen(String);
+ InputStrLen = AsciiStrLen (String);
- if (This->MajorVersion < 2 || (This->MajorVersion == 2 && This->MinorVersion < 7)) {
+ if ((This->MajorVersion < 2) || ((This->MajorVersion == 2) && (This->MinorVersion < 7))) {
if (InputStrLen > SMBIOS_STRING_MAX_LENGTH) {
return EFI_UNSUPPORTED;
}
@@ -622,8 +625,8 @@ SmbiosUpdateString (
Head = &Private->DataListHead;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
- SmbiosEntry = SMBIOS_ENTRY_FROM_LINK(Link);
- Record = (EFI_SMBIOS_TABLE_HEADER*)(SmbiosEntry->RecordHeader + 1);
+ SmbiosEntry = SMBIOS_ENTRY_FROM_LINK (Link);
+ Record = (EFI_SMBIOS_TABLE_HEADER *)(SmbiosEntry->RecordHeader + 1);
if (Record->Handle == *SmbiosHandle) {
//
@@ -633,10 +636,11 @@ SmbiosUpdateString (
EfiReleaseLock (&Private->DataLock);
return EFI_NOT_FOUND;
}
+
//
// Point to unformed string section
//
- StrStart = (CHAR8 *) Record + Record->Length;
+ StrStart = (CHAR8 *)Record + Record->Length;
for (StrIndex = 1, TargetStrOffset = 0; StrIndex < *StringNumber; StrStart++, TargetStrOffset++) {
//
@@ -649,7 +653,7 @@ SmbiosUpdateString (
//
// String section ends in double-null (0000h)
//
- if (*StrStart == 0 && *(StrStart + 1) == 0) {
+ if ((*StrStart == 0) && (*(StrStart + 1) == 0)) {
EfiReleaseLock (&Private->DataLock);
return EFI_NOT_FOUND;
}
@@ -663,9 +667,9 @@ SmbiosUpdateString (
//
// Now we get the string target
//
- TargetStrLen = AsciiStrLen(StrStart);
+ TargetStrLen = AsciiStrLen (StrStart);
if (InputStrLen == TargetStrLen) {
- AsciiStrCpyS(StrStart, TargetStrLen + 1, String);
+ AsciiStrCpyS (StrStart, TargetStrLen + 1, String);
//
// Some UEFI drivers (such as network) need some information in SMBIOS table.
// Here we create SMBIOS table and publish it in
@@ -680,12 +684,14 @@ SmbiosUpdateString (
SmbiosEntry->Smbios32BitTable = FALSE;
SmbiosEntry->Smbios64BitTable = FALSE;
if ((This->MajorVersion < 0x3) ||
- ((This->MajorVersion >= 0x3) && ((PcdGet32 (PcdSmbiosEntryPointProvideMethod) & BIT0) == BIT0))) {
+ ((This->MajorVersion >= 0x3) && ((PcdGet32 (PcdSmbiosEntryPointProvideMethod) & BIT0) == BIT0)))
+ {
//
// 32-bit table is produced, check the valid length.
//
if ((EntryPointStructure != NULL) &&
- (EntryPointStructure->TableLength + InputStrLen - TargetStrLen > SMBIOS_TABLE_MAX_LENGTH)) {
+ (EntryPointStructure->TableLength + InputStrLen - TargetStrLen > SMBIOS_TABLE_MAX_LENGTH))
+ {
//
// The length of the entire structure table (including all strings) must be reported
// in the Structure Table Length field of the SMBIOS Structure Table Entry Point,
@@ -703,7 +709,8 @@ SmbiosUpdateString (
// 64-bit table is produced, check the valid length.
//
if ((Smbios30EntryPointStructure != NULL) &&
- (Smbios30EntryPointStructure->TableMaximumSize + InputStrLen - TargetStrLen > SMBIOS_3_0_TABLE_MAX_LENGTH)) {
+ (Smbios30EntryPointStructure->TableMaximumSize + InputStrLen - TargetStrLen > SMBIOS_3_0_TABLE_MAX_LENGTH))
+ {
DEBUG ((DEBUG_INFO, "SmbiosUpdateString: Total length exceeds max 64-bit table length\n"));
} else {
DEBUG ((DEBUG_INFO, "SmbiosUpdateString: New smbios record add to 64-bit table\n"));
@@ -720,7 +727,7 @@ SmbiosUpdateString (
// Original string buffer size is not exactly match input string length.
// Re-allocate buffer is needed.
//
- NewEntrySize = SmbiosEntry->RecordSize + InputStrLen - TargetStrLen;
+ NewEntrySize = SmbiosEntry->RecordSize + InputStrLen - TargetStrLen;
ResizedSmbiosEntry = AllocateZeroPool (NewEntrySize);
if (ResizedSmbiosEntry == NULL) {
@@ -728,33 +735,35 @@ SmbiosUpdateString (
return EFI_OUT_OF_RESOURCES;
}
- InternalRecord = (EFI_SMBIOS_RECORD_HEADER *) (ResizedSmbiosEntry + 1);
- Raw = (VOID *) (InternalRecord + 1);
+ InternalRecord = (EFI_SMBIOS_RECORD_HEADER *)(ResizedSmbiosEntry + 1);
+ Raw = (VOID *)(InternalRecord + 1);
//
// Build internal record Header
//
- InternalRecord->Version = EFI_SMBIOS_RECORD_HEADER_VERSION;
- InternalRecord->HeaderSize = (UINT16) sizeof (EFI_SMBIOS_RECORD_HEADER);
- InternalRecord->RecordSize = SmbiosEntry->RecordHeader->RecordSize + InputStrLen - TargetStrLen;
- InternalRecord->ProducerHandle = SmbiosEntry->RecordHeader->ProducerHandle;
+ InternalRecord->Version = EFI_SMBIOS_RECORD_HEADER_VERSION;
+ InternalRecord->HeaderSize = (UINT16)sizeof (EFI_SMBIOS_RECORD_HEADER);
+ InternalRecord->RecordSize = SmbiosEntry->RecordHeader->RecordSize + InputStrLen - TargetStrLen;
+ InternalRecord->ProducerHandle = SmbiosEntry->RecordHeader->ProducerHandle;
InternalRecord->NumberOfStrings = SmbiosEntry->RecordHeader->NumberOfStrings;
//
// Copy SMBIOS structure and optional strings.
//
CopyMem (Raw, SmbiosEntry->RecordHeader + 1, Record->Length + TargetStrOffset);
- CopyMem ((VOID*)((UINTN)Raw + Record->Length + TargetStrOffset), String, InputStrLen + 1);
- CopyMem ((CHAR8*)((UINTN)Raw + Record->Length + TargetStrOffset + InputStrLen + 1),
- (CHAR8*)Record + Record->Length + TargetStrOffset + TargetStrLen + 1,
- SmbiosEntry->RecordHeader->RecordSize - sizeof (EFI_SMBIOS_RECORD_HEADER) - Record->Length - TargetStrOffset - TargetStrLen - 1);
+ CopyMem ((VOID *)((UINTN)Raw + Record->Length + TargetStrOffset), String, InputStrLen + 1);
+ CopyMem (
+ (CHAR8 *)((UINTN)Raw + Record->Length + TargetStrOffset + InputStrLen + 1),
+ (CHAR8 *)Record + Record->Length + TargetStrOffset + TargetStrLen + 1,
+ SmbiosEntry->RecordHeader->RecordSize - sizeof (EFI_SMBIOS_RECORD_HEADER) - Record->Length - TargetStrOffset - TargetStrLen - 1
+ );
//
// Insert new record
//
- ResizedSmbiosEntry->Signature = EFI_SMBIOS_ENTRY_SIGNATURE;
- ResizedSmbiosEntry->RecordHeader = InternalRecord;
- ResizedSmbiosEntry->RecordSize = NewEntrySize;
+ ResizedSmbiosEntry->Signature = EFI_SMBIOS_ENTRY_SIGNATURE;
+ ResizedSmbiosEntry->RecordHeader = InternalRecord;
+ ResizedSmbiosEntry->RecordSize = NewEntrySize;
ResizedSmbiosEntry->Smbios32BitTable = SmbiosEntry->Smbios32BitTable;
ResizedSmbiosEntry->Smbios64BitTable = SmbiosEntry->Smbios64BitTable;
InsertTailList (Link->ForwardLink, &ResizedSmbiosEntry->Link);
@@ -762,8 +771,8 @@ SmbiosUpdateString (
//
// Remove old record
//
- RemoveEntryList(Link);
- FreePool(SmbiosEntry);
+ RemoveEntryList (Link);
+ FreePool (SmbiosEntry);
//
// Some UEFI drivers (such as network) need some information in SMBIOS table.
// Here we create SMBIOS table and publish it in
@@ -793,23 +802,23 @@ SmbiosUpdateString (
EFI_STATUS
EFIAPI
SmbiosRemove (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN EFI_SMBIOS_HANDLE SmbiosHandle
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN EFI_SMBIOS_HANDLE SmbiosHandle
)
{
- LIST_ENTRY *Link;
- LIST_ENTRY *Head;
- EFI_STATUS Status;
- EFI_SMBIOS_HANDLE MaxSmbiosHandle;
- SMBIOS_INSTANCE *Private;
- EFI_SMBIOS_ENTRY *SmbiosEntry;
- SMBIOS_HANDLE_ENTRY *HandleEntry;
- EFI_SMBIOS_TABLE_HEADER *Record;
+ LIST_ENTRY *Link;
+ LIST_ENTRY *Head;
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE MaxSmbiosHandle;
+ SMBIOS_INSTANCE *Private;
+ EFI_SMBIOS_ENTRY *SmbiosEntry;
+ SMBIOS_HANDLE_ENTRY *HandleEntry;
+ EFI_SMBIOS_TABLE_HEADER *Record;
//
// Check args validity
//
- GetMaxSmbiosHandle(This, &MaxSmbiosHandle);
+ GetMaxSmbiosHandle (This, &MaxSmbiosHandle);
if (SmbiosHandle > MaxSmbiosHandle) {
return EFI_INVALID_PARAMETER;
@@ -826,25 +835,26 @@ SmbiosRemove (
Head = &Private->DataListHead;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
- SmbiosEntry = SMBIOS_ENTRY_FROM_LINK(Link);
- Record = (EFI_SMBIOS_TABLE_HEADER*)(SmbiosEntry->RecordHeader + 1);
+ SmbiosEntry = SMBIOS_ENTRY_FROM_LINK (Link);
+ Record = (EFI_SMBIOS_TABLE_HEADER *)(SmbiosEntry->RecordHeader + 1);
if (Record->Handle == SmbiosHandle) {
//
// Remove specified smobios record from DataList
//
- RemoveEntryList(Link);
+ RemoveEntryList (Link);
//
// Remove this handle from AllocatedHandleList
//
Head = &Private->AllocatedHandleListHead;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
- HandleEntry = SMBIOS_HANDLE_ENTRY_FROM_LINK(Link);
+ HandleEntry = SMBIOS_HANDLE_ENTRY_FROM_LINK (Link);
if (HandleEntry->SmbiosHandle == SmbiosHandle) {
- RemoveEntryList(Link);
- FreePool(HandleEntry);
+ RemoveEntryList (Link);
+ FreePool (HandleEntry);
break;
}
}
+
//
// Some UEFI drivers (such as network) need some information in SMBIOS table.
// Here we create SMBIOS table and publish it in
@@ -854,14 +864,16 @@ SmbiosRemove (
if (SmbiosEntry->Smbios32BitTable) {
DEBUG ((DEBUG_INFO, "SmbiosRemove: remove from 32-bit table\n"));
}
+
if (SmbiosEntry->Smbios64BitTable) {
DEBUG ((DEBUG_INFO, "SmbiosRemove: remove from 64-bit table\n"));
}
+
//
// Update the whole SMBIOS table again based on which table the removed SMBIOS record is in.
//
SmbiosTableConstruction (SmbiosEntry->Smbios32BitTable, SmbiosEntry->Smbios64BitTable);
- FreePool(SmbiosEntry);
+ FreePool (SmbiosEntry);
EfiReleaseLock (&Private->DataLock);
return EFI_SUCCESS;
}
@@ -872,7 +884,6 @@ SmbiosRemove (
//
EfiReleaseLock (&Private->DataLock);
return EFI_INVALID_PARAMETER;
-
}
/**
@@ -896,11 +907,11 @@ SmbiosRemove (
EFI_STATUS
EFIAPI
SmbiosGetNext (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN OUT EFI_SMBIOS_HANDLE *SmbiosHandle,
- IN EFI_SMBIOS_TYPE *Type OPTIONAL,
- OUT EFI_SMBIOS_TABLE_HEADER **Record,
- OUT EFI_HANDLE *ProducerHandle OPTIONAL
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN OUT EFI_SMBIOS_HANDLE *SmbiosHandle,
+ IN EFI_SMBIOS_TYPE *Type OPTIONAL,
+ OUT EFI_SMBIOS_TABLE_HEADER **Record,
+ OUT EFI_HANDLE *ProducerHandle OPTIONAL
)
{
BOOLEAN StartPointFound;
@@ -915,11 +926,11 @@ SmbiosGetNext (
}
StartPointFound = FALSE;
- Private = SMBIOS_INSTANCE_FROM_THIS (This);
- Head = &Private->DataListHead;
+ Private = SMBIOS_INSTANCE_FROM_THIS (This);
+ Head = &Private->DataListHead;
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
- SmbiosEntry = SMBIOS_ENTRY_FROM_LINK(Link);
- SmbiosTableHeader = (EFI_SMBIOS_TABLE_HEADER*)(SmbiosEntry->RecordHeader + 1);
+ SmbiosEntry = SMBIOS_ENTRY_FROM_LINK (Link);
+ SmbiosTableHeader = (EFI_SMBIOS_TABLE_HEADER *)(SmbiosEntry->RecordHeader + 1);
//
// If SmbiosHandle is 0xFFFE, the first matched SMBIOS record handle will be returned
@@ -930,10 +941,11 @@ SmbiosGetNext (
}
*SmbiosHandle = SmbiosTableHeader->Handle;
- *Record =SmbiosTableHeader;
+ *Record = SmbiosTableHeader;
if (ProducerHandle != NULL) {
*ProducerHandle = SmbiosEntry->RecordHeader->ProducerHandle;
}
+
return EFI_SUCCESS;
}
@@ -951,7 +963,7 @@ SmbiosGetNext (
}
*SmbiosHandle = SmbiosTableHeader->Handle;
- *Record = SmbiosTableHeader;
+ *Record = SmbiosTableHeader;
if (ProducerHandle != NULL) {
*ProducerHandle = SmbiosEntry->RecordHeader->ProducerHandle;
}
@@ -962,7 +974,6 @@ SmbiosGetNext (
*SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
return EFI_NOT_FOUND;
-
}
/**
@@ -982,9 +993,9 @@ SmbiosGetNext (
EFI_STATUS
EFIAPI
GetNextSmbiosRecord (
- IN CONST EFI_SMBIOS_PROTOCOL *This,
- IN OUT EFI_SMBIOS_ENTRY **CurrentSmbiosEntry,
- OUT EFI_SMBIOS_TABLE_HEADER **Record
+ IN CONST EFI_SMBIOS_PROTOCOL *This,
+ IN OUT EFI_SMBIOS_ENTRY **CurrentSmbiosEntry,
+ OUT EFI_SMBIOS_TABLE_HEADER **Record
)
{
LIST_ENTRY *Link;
@@ -1006,7 +1017,7 @@ GetNextSmbiosRecord (
Head = &(*CurrentSmbiosEntry)->Link;
}
- Link = Head->ForwardLink;
+ Link = Head->ForwardLink;
if (Link == &Private->DataListHead) {
//
@@ -1015,9 +1026,9 @@ GetNextSmbiosRecord (
return EFI_NOT_FOUND;
}
- SmbiosEntry = SMBIOS_ENTRY_FROM_LINK(Link);
- SmbiosTableHeader = (EFI_SMBIOS_TABLE_HEADER*)(SmbiosEntry->RecordHeader + 1);
- *Record = SmbiosTableHeader;
+ SmbiosEntry = SMBIOS_ENTRY_FROM_LINK (Link);
+ SmbiosTableHeader = (EFI_SMBIOS_TABLE_HEADER *)(SmbiosEntry->RecordHeader + 1);
+ *Record = SmbiosTableHeader;
*CurrentSmbiosEntry = SmbiosEntry;
return EFI_SUCCESS;
}
@@ -1035,7 +1046,7 @@ GetNextSmbiosRecord (
EFI_STATUS
EFIAPI
SmbiosCreateTable (
- OUT VOID **TableEntryPointStructure
+ OUT VOID **TableEntryPointStructure
)
{
UINT8 *BufferPointer;
@@ -1049,8 +1060,8 @@ SmbiosCreateTable (
EFI_SMBIOS_TABLE_END_STRUCTURE EndStructure;
EFI_SMBIOS_ENTRY *CurrentSmbiosEntry;
- Status = EFI_SUCCESS;
- BufferPointer = NULL;
+ Status = EFI_SUCCESS;
+ BufferPointer = NULL;
if (EntryPointStructure == NULL) {
//
@@ -1059,16 +1070,16 @@ SmbiosCreateTable (
// Allocate memory (below 4GB).
//
DEBUG ((DEBUG_INFO, "SmbiosCreateTable: Initialize 32-bit entry point structure\n"));
- EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion;
- EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion;
- EntryPointStructureData.SmbiosBcdRevision = (UINT8) ((PcdGet16 (PcdSmbiosVersion) >> 4) & 0xf0) | (UINT8) (PcdGet16 (PcdSmbiosVersion) & 0x0f);
- PhysicalAddress = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiRuntimeServicesData,
- EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
- &PhysicalAddress
- );
+ EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion;
+ EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion;
+ EntryPointStructureData.SmbiosBcdRevision = (UINT8)((PcdGet16 (PcdSmbiosVersion) >> 4) & 0xf0) | (UINT8)(PcdGet16 (PcdSmbiosVersion) & 0x0f);
+ PhysicalAddress = 0xffffffff;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiRuntimeServicesData,
+ EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
+ &PhysicalAddress
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SmbiosCreateTable () could not allocate EntryPointStructure < 4GB\n"));
Status = gBS->AllocatePages (
@@ -1077,12 +1088,12 @@ SmbiosCreateTable (
EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
&PhysicalAddress
);
- if (EFI_ERROR (Status)) {
+ if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
}
- EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) PhysicalAddress;
+ EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)PhysicalAddress;
CopyMem (
EntryPointStructure,
@@ -1111,66 +1122,69 @@ SmbiosCreateTable (
Status = GetNextSmbiosRecord (SmbiosProtocol, &CurrentSmbiosEntry, &SmbiosRecord);
if ((Status == EFI_SUCCESS) && (CurrentSmbiosEntry->Smbios32BitTable)) {
- GetSmbiosStructureSize(SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
+ GetSmbiosStructureSize (SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
//
// Record NumberOfSmbiosStructures, TableLength and MaxStructureSize
//
EntryPointStructure->NumberOfSmbiosStructures++;
- EntryPointStructure->TableLength = (UINT16) (EntryPointStructure->TableLength + RecordSize);
+ EntryPointStructure->TableLength = (UINT16)(EntryPointStructure->TableLength + RecordSize);
if (RecordSize > EntryPointStructure->MaxStructureSize) {
- EntryPointStructure->MaxStructureSize = (UINT16) RecordSize;
+ EntryPointStructure->MaxStructureSize = (UINT16)RecordSize;
}
}
- } while (!EFI_ERROR(Status));
+ } while (!EFI_ERROR (Status));
//
// Create End-Of-Table structure
//
- GetMaxSmbiosHandle(SmbiosProtocol, &SmbiosHandle);
- EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
- EndStructure.Header.Length = (UINT8) sizeof (EFI_SMBIOS_TABLE_HEADER);
+ GetMaxSmbiosHandle (SmbiosProtocol, &SmbiosHandle);
+ EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
+ EndStructure.Header.Length = (UINT8)sizeof (EFI_SMBIOS_TABLE_HEADER);
EndStructure.Header.Handle = SmbiosHandle;
- EndStructure.Tailing[0] = 0;
- EndStructure.Tailing[1] = 0;
+ EndStructure.Tailing[0] = 0;
+ EndStructure.Tailing[1] = 0;
EntryPointStructure->NumberOfSmbiosStructures++;
- EntryPointStructure->TableLength = (UINT16) (EntryPointStructure->TableLength + sizeof (EndStructure));
+ EntryPointStructure->TableLength = (UINT16)(EntryPointStructure->TableLength + sizeof (EndStructure));
if (sizeof (EndStructure) > EntryPointStructure->MaxStructureSize) {
- EntryPointStructure->MaxStructureSize = (UINT16) sizeof (EndStructure);
+ EntryPointStructure->MaxStructureSize = (UINT16)sizeof (EndStructure);
}
- if (EFI_SIZE_TO_PAGES ((UINT32) EntryPointStructure->TableLength) > mPreAllocatedPages) {
+ if (EFI_SIZE_TO_PAGES ((UINT32)EntryPointStructure->TableLength) > mPreAllocatedPages) {
//
// If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory (below 4GB).
//
- DEBUG ((DEBUG_INFO, "%a() re-allocate SMBIOS 32-bit table\n",
- __FUNCTION__));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a() re-allocate SMBIOS 32-bit table\n",
+ __FUNCTION__
+ ));
if (EntryPointStructure->TableAddress != 0) {
//
// Free the previous allocated page
//
FreePages (
- (VOID*)(UINTN)EntryPointStructure->TableAddress,
- mPreAllocatedPages
- );
+ (VOID *)(UINTN)EntryPointStructure->TableAddress,
+ mPreAllocatedPages
+ );
EntryPointStructure->TableAddress = 0;
- mPreAllocatedPages = 0;
+ mPreAllocatedPages = 0;
}
PhysicalAddress = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiRuntimeServicesData,
- EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength),
- &PhysicalAddress
- );
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiRuntimeServicesData,
+ EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength),
+ &PhysicalAddress
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n"));
EntryPointStructure->TableAddress = 0;
return EFI_OUT_OF_RESOURCES;
} else {
- EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;
- mPreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);
+ EntryPointStructure->TableAddress = (UINT32)PhysicalAddress;
+ mPreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);
}
}
@@ -1178,17 +1192,17 @@ SmbiosCreateTable (
// Assemble the tables
//
ASSERT (EntryPointStructure->TableAddress != 0);
- BufferPointer = (UINT8 *) (UINTN) EntryPointStructure->TableAddress;
+ BufferPointer = (UINT8 *)(UINTN)EntryPointStructure->TableAddress;
CurrentSmbiosEntry = NULL;
do {
Status = GetNextSmbiosRecord (SmbiosProtocol, &CurrentSmbiosEntry, &SmbiosRecord);
if ((Status == EFI_SUCCESS) && (CurrentSmbiosEntry->Smbios32BitTable)) {
- GetSmbiosStructureSize(SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
+ GetSmbiosStructureSize (SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
CopyMem (BufferPointer, SmbiosRecord, RecordSize);
BufferPointer = BufferPointer + RecordSize;
}
- } while (!EFI_ERROR(Status));
+ } while (!EFI_ERROR (Status));
//
// Assemble End-Of-Table structure
@@ -1198,13 +1212,13 @@ SmbiosCreateTable (
//
// Fixup checksums in the Entry Point Structure
//
- EntryPointStructure->IntermediateChecksum = 0;
+ EntryPointStructure->IntermediateChecksum = 0;
EntryPointStructure->EntryPointStructureChecksum = 0;
EntryPointStructure->IntermediateChecksum =
- CalculateCheckSum8 ((UINT8 *) EntryPointStructure + 0x10, EntryPointStructure->EntryPointLength - 0x10);
+ CalculateCheckSum8 ((UINT8 *)EntryPointStructure + 0x10, EntryPointStructure->EntryPointLength - 0x10);
EntryPointStructure->EntryPointStructureChecksum =
- CalculateCheckSum8 ((UINT8 *) EntryPointStructure, EntryPointStructure->EntryPointLength);
+ CalculateCheckSum8 ((UINT8 *)EntryPointStructure, EntryPointStructure->EntryPointLength);
//
// Returns the pointer
@@ -1227,7 +1241,7 @@ SmbiosCreateTable (
EFI_STATUS
EFIAPI
SmbiosCreate64BitTable (
- OUT VOID **TableEntryPointStructure
+ OUT VOID **TableEntryPointStructure
)
{
UINT8 *BufferPointer;
@@ -1241,8 +1255,8 @@ SmbiosCreate64BitTable (
EFI_SMBIOS_TABLE_END_STRUCTURE EndStructure;
EFI_SMBIOS_ENTRY *CurrentSmbiosEntry;
- Status = EFI_SUCCESS;
- BufferPointer = NULL;
+ Status = EFI_SUCCESS;
+ BufferPointer = NULL;
if (Smbios30EntryPointStructure == NULL) {
//
@@ -1251,21 +1265,21 @@ SmbiosCreate64BitTable (
// Allocate memory at any address.
//
DEBUG ((DEBUG_INFO, "SmbiosCreateTable: Initialize 64-bit entry point structure\n"));
- Smbios30EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion;
- Smbios30EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion;
- Smbios30EntryPointStructureData.DocRev = PcdGet8 (PcdSmbiosDocRev);
- Status = gBS->AllocatePages (
- AllocateAnyPages,
- EfiRuntimeServicesData,
- EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT)),
- &PhysicalAddress
- );
+ Smbios30EntryPointStructureData.MajorVersion = mPrivateData.Smbios.MajorVersion;
+ Smbios30EntryPointStructureData.MinorVersion = mPrivateData.Smbios.MinorVersion;
+ Smbios30EntryPointStructureData.DocRev = PcdGet8 (PcdSmbiosDocRev);
+ Status = gBS->AllocatePages (
+ AllocateAnyPages,
+ EfiRuntimeServicesData,
+ EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT)),
+ &PhysicalAddress
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SmbiosCreate64BitTable() could not allocate Smbios30EntryPointStructure\n"));
return EFI_OUT_OF_RESOURCES;
}
- Smbios30EntryPointStructure = (SMBIOS_TABLE_3_0_ENTRY_POINT *) (UINTN) PhysicalAddress;
+ Smbios30EntryPointStructure = (SMBIOS_TABLE_3_0_ENTRY_POINT *)(UINTN)PhysicalAddress;
CopyMem (
Smbios30EntryPointStructure,
@@ -1277,7 +1291,7 @@ SmbiosCreate64BitTable (
//
// Get Smbios protocol to traverse SMBIOS records.
//
- SmbiosProtocol = &mPrivateData.Smbios;
+ SmbiosProtocol = &mPrivateData.Smbios;
Smbios30EntryPointStructure->TableMaximumSize = 0;
//
@@ -1288,42 +1302,45 @@ SmbiosCreate64BitTable (
Status = GetNextSmbiosRecord (SmbiosProtocol, &CurrentSmbiosEntry, &SmbiosRecord);
if ((Status == EFI_SUCCESS) && (CurrentSmbiosEntry->Smbios64BitTable)) {
- GetSmbiosStructureSize(SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
+ GetSmbiosStructureSize (SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
//
// Record TableMaximumSize
//
- Smbios30EntryPointStructure->TableMaximumSize = (UINT32) (Smbios30EntryPointStructure->TableMaximumSize + RecordSize);
+ Smbios30EntryPointStructure->TableMaximumSize = (UINT32)(Smbios30EntryPointStructure->TableMaximumSize + RecordSize);
}
- } while (!EFI_ERROR(Status));
+ } while (!EFI_ERROR (Status));
//
// Create End-Of-Table structure
//
- GetMaxSmbiosHandle(SmbiosProtocol, &SmbiosHandle);
- EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
- EndStructure.Header.Length = (UINT8) sizeof (EFI_SMBIOS_TABLE_HEADER);
- EndStructure.Header.Handle = SmbiosHandle;
- EndStructure.Tailing[0] = 0;
- EndStructure.Tailing[1] = 0;
- Smbios30EntryPointStructure->TableMaximumSize = (UINT32) (Smbios30EntryPointStructure->TableMaximumSize + sizeof (EndStructure));
+ GetMaxSmbiosHandle (SmbiosProtocol, &SmbiosHandle);
+ EndStructure.Header.Type = SMBIOS_TYPE_END_OF_TABLE;
+ EndStructure.Header.Length = (UINT8)sizeof (EFI_SMBIOS_TABLE_HEADER);
+ EndStructure.Header.Handle = SmbiosHandle;
+ EndStructure.Tailing[0] = 0;
+ EndStructure.Tailing[1] = 0;
+ Smbios30EntryPointStructure->TableMaximumSize = (UINT32)(Smbios30EntryPointStructure->TableMaximumSize + sizeof (EndStructure));
if (EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize) > mPre64BitAllocatedPages) {
//
// If new SMBIOS table size exceeds the previous allocated page,
// it is time to re-allocate memory at anywhere.
//
- DEBUG ((DEBUG_INFO, "%a() re-allocate SMBIOS 64-bit table\n",
- __FUNCTION__));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a() re-allocate SMBIOS 64-bit table\n",
+ __FUNCTION__
+ ));
if (Smbios30EntryPointStructure->TableAddress != 0) {
//
// Free the previous allocated page
//
FreePages (
- (VOID*)(UINTN)Smbios30EntryPointStructure->TableAddress,
- mPre64BitAllocatedPages
- );
+ (VOID *)(UINTN)Smbios30EntryPointStructure->TableAddress,
+ mPre64BitAllocatedPages
+ );
Smbios30EntryPointStructure->TableAddress = 0;
- mPre64BitAllocatedPages = 0;
+ mPre64BitAllocatedPages = 0;
}
Status = gBS->AllocatePages (
@@ -1338,7 +1355,7 @@ SmbiosCreate64BitTable (
return EFI_OUT_OF_RESOURCES;
} else {
Smbios30EntryPointStructure->TableAddress = PhysicalAddress;
- mPre64BitAllocatedPages = EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize);
+ mPre64BitAllocatedPages = EFI_SIZE_TO_PAGES (Smbios30EntryPointStructure->TableMaximumSize);
}
}
@@ -1346,7 +1363,7 @@ SmbiosCreate64BitTable (
// Assemble the tables
//
ASSERT (Smbios30EntryPointStructure->TableAddress != 0);
- BufferPointer = (UINT8 *) (UINTN) Smbios30EntryPointStructure->TableAddress;
+ BufferPointer = (UINT8 *)(UINTN)Smbios30EntryPointStructure->TableAddress;
CurrentSmbiosEntry = NULL;
do {
Status = GetNextSmbiosRecord (SmbiosProtocol, &CurrentSmbiosEntry, &SmbiosRecord);
@@ -1355,11 +1372,11 @@ SmbiosCreate64BitTable (
//
// This record can be added to 64-bit table
//
- GetSmbiosStructureSize(SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
+ GetSmbiosStructureSize (SmbiosProtocol, SmbiosRecord, &RecordSize, &NumOfStr);
CopyMem (BufferPointer, SmbiosRecord, RecordSize);
BufferPointer = BufferPointer + RecordSize;
}
- } while (!EFI_ERROR(Status));
+ } while (!EFI_ERROR (Status));
//
// Assemble End-Of-Table structure
@@ -1371,7 +1388,7 @@ SmbiosCreate64BitTable (
//
Smbios30EntryPointStructure->EntryPointStructureChecksum = 0;
Smbios30EntryPointStructure->EntryPointStructureChecksum =
- CalculateCheckSum8 ((UINT8 *) Smbios30EntryPointStructure, Smbios30EntryPointStructure->EntryPointLength);
+ CalculateCheckSum8 ((UINT8 *)Smbios30EntryPointStructure, Smbios30EntryPointStructure->EntryPointLength);
//
// Returns the pointer
@@ -1391,8 +1408,8 @@ SmbiosCreate64BitTable (
VOID
EFIAPI
SmbiosTableConstruction (
- BOOLEAN Smbios32BitTable,
- BOOLEAN Smbios64BitTable
+ BOOLEAN Smbios32BitTable,
+ BOOLEAN Smbios64BitTable
)
{
UINT8 *Eps;
@@ -1400,14 +1417,14 @@ SmbiosTableConstruction (
EFI_STATUS Status;
if (Smbios32BitTable) {
- Status = SmbiosCreateTable ((VOID **) &Eps);
+ Status = SmbiosCreateTable ((VOID **)&Eps);
if (!EFI_ERROR (Status)) {
gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, Eps);
}
}
if (Smbios64BitTable) {
- Status = SmbiosCreate64BitTable ((VOID **) &Eps64Bit);
+ Status = SmbiosCreate64BitTable ((VOID **)&Eps64Bit);
if (!EFI_ERROR (Status)) {
gBS->InstallConfigurationTable (&gEfiSmbios3TableGuid, Eps64Bit);
}
@@ -1428,14 +1445,15 @@ SmbiosTableConstruction (
STATIC
BOOLEAN
IsValidSmbios20Table (
- IN VOID *TableEntry,
- OUT VOID **TableAddress,
- OUT UINTN *TableMaximumSize
+ IN VOID *TableEntry,
+ OUT VOID **TableAddress,
+ OUT UINTN *TableMaximumSize
)
{
- UINT8 Checksum;
- SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
- SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *) TableEntry;
+ UINT8 Checksum;
+ SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
+
+ SmbiosTable = (SMBIOS_TABLE_ENTRY_POINT *)TableEntry;
if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) != 0) {
return FALSE;
@@ -1450,7 +1468,7 @@ IsValidSmbios20Table (
// However, it was incorrectly stated in version 2.1 of smbios specification.
// Therefore, 0x1F and 0x1E are both accepted.
//
- if (SmbiosTable->EntryPointLength != 0x1E && SmbiosTable->EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT)) {
+ if ((SmbiosTable->EntryPointLength != 0x1E) && (SmbiosTable->EntryPointLength != sizeof (SMBIOS_TABLE_ENTRY_POINT))) {
return FALSE;
}
@@ -1465,7 +1483,7 @@ IsValidSmbios20Table (
// The whole struct check sum should be zero
//
Checksum = CalculateSum8 (
- (UINT8 *) SmbiosTable,
+ (UINT8 *)SmbiosTable,
SmbiosTable->EntryPointLength
);
if (Checksum != 0) {
@@ -1476,14 +1494,14 @@ IsValidSmbios20Table (
// The Intermediate Entry Point Structure check sum should be zero.
//
Checksum = CalculateSum8 (
- (UINT8 *) SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
+ (UINT8 *)SmbiosTable + OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString),
SmbiosTable->EntryPointLength - OFFSET_OF (SMBIOS_TABLE_ENTRY_POINT, IntermediateAnchorString)
);
if (Checksum != 0) {
return FALSE;
}
- *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
+ *TableAddress = (VOID *)(UINTN)SmbiosTable->TableAddress;
*TableMaximumSize = SmbiosTable->TableLength;
return TRUE;
}
@@ -1502,21 +1520,24 @@ IsValidSmbios20Table (
STATIC
BOOLEAN
IsValidSmbios30Table (
- IN VOID *TableEntry,
- OUT VOID **TableAddress,
- OUT UINTN *TableMaximumSize
+ IN VOID *TableEntry,
+ OUT VOID **TableAddress,
+ OUT UINTN *TableMaximumSize
)
{
- UINT8 Checksum;
- SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
- SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *) TableEntry;
+ UINT8 Checksum;
+ SMBIOS_TABLE_3_0_ENTRY_POINT *SmbiosTable;
+
+ SmbiosTable = (SMBIOS_TABLE_3_0_ENTRY_POINT *)TableEntry;
if (CompareMem (SmbiosTable->AnchorString, "_SM3_", 5) != 0) {
return FALSE;
}
+
if (SmbiosTable->EntryPointLength < sizeof (SMBIOS_TABLE_3_0_ENTRY_POINT)) {
return FALSE;
}
+
if (SmbiosTable->MajorVersion < 3) {
return FALSE;
}
@@ -1525,14 +1546,14 @@ IsValidSmbios30Table (
// The whole struct check sum should be zero
//
Checksum = CalculateSum8 (
- (UINT8 *) SmbiosTable,
+ (UINT8 *)SmbiosTable,
SmbiosTable->EntryPointLength
);
if (Checksum != 0) {
return FALSE;
}
- *TableAddress = (VOID *) (UINTN) SmbiosTable->TableAddress;
+ *TableAddress = (VOID *)(UINTN)SmbiosTable->TableAddress;
*TableMaximumSize = SmbiosTable->TableMaximumSize;
return TRUE;
}
@@ -1552,19 +1573,19 @@ IsValidSmbios30Table (
STATIC
EFI_STATUS
ParseAndAddExistingSmbiosTable (
- IN EFI_HANDLE ImageHandle,
- IN SMBIOS_STRUCTURE_POINTER Smbios,
- IN UINTN Length
+ IN EFI_HANDLE ImageHandle,
+ IN SMBIOS_STRUCTURE_POINTER Smbios,
+ IN UINTN Length
)
{
- EFI_STATUS Status;
- CHAR8 *String;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- SMBIOS_STRUCTURE_POINTER SmbiosEnd;
+ EFI_STATUS Status;
+ CHAR8 *String;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ SMBIOS_STRUCTURE_POINTER SmbiosEnd;
SmbiosEnd.Raw = Smbios.Raw + Length;
- if (Smbios.Raw >= SmbiosEnd.Raw || Smbios.Raw == NULL) {
+ if ((Smbios.Raw >= SmbiosEnd.Raw) || (Smbios.Raw == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1572,39 +1593,45 @@ ParseAndAddExistingSmbiosTable (
//
// Make sure not to access memory beyond SmbiosEnd
//
- if (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw ||
- Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw) {
+ if ((Smbios.Raw + sizeof (SMBIOS_STRUCTURE) > SmbiosEnd.Raw) ||
+ (Smbios.Raw + sizeof (SMBIOS_STRUCTURE) < Smbios.Raw))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Check for end marker
//
if (Smbios.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
break;
}
+
//
// Make sure not to access memory beyond SmbiosEnd
// Each structure shall be terminated by a double-null (0000h).
//
- if (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.Raw ||
- Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw) {
+ if ((Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) > SmbiosEnd.Raw) ||
+ (Smbios.Raw + Smbios.Hdr->Length + 2 * sizeof (UINT8) < Smbios.Raw))
+ {
return EFI_INVALID_PARAMETER;
}
+
//
// Install the table
//
SmbiosHandle = Smbios.Hdr->Handle;
- Status = SmbiosAdd (
- &mPrivateData.Smbios,
- ImageHandle,
- &SmbiosHandle,
- Smbios.Hdr
- );
+ Status = SmbiosAdd (
+ &mPrivateData.Smbios,
+ ImageHandle,
+ &SmbiosHandle,
+ Smbios.Hdr
+ );
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Go to the next SMBIOS structure. Each SMBIOS structure may include 2 parts:
// 1. Formatted section; 2. Unformatted string section. So, 2 steps are needed
@@ -1614,7 +1641,7 @@ ParseAndAddExistingSmbiosTable (
//
// Step 1: Skip over formatted section.
//
- String = (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);
+ String = (CHAR8 *)(Smbios.Raw + Smbios.Hdr->Length);
//
// Step 2: Skip over unformatted string section.
@@ -1625,16 +1652,16 @@ ParseAndAddExistingSmbiosTable (
// is terminated with an additional NULL(00h) BYTE.
//
for ( ; *String != 0; String++) {
- if ((UINTN) String >= (UINTN) SmbiosEnd.Raw - sizeof (UINT8)) {
+ if ((UINTN)String >= (UINTN)SmbiosEnd.Raw - sizeof (UINT8)) {
return EFI_INVALID_PARAMETER;
}
}
- if (*(UINT8 *) ++String == 0) {
+ if (*(UINT8 *)++String == 0) {
//
// Pointer to the next SMBIOS structure.
//
- Smbios.Raw = (UINT8 *) ++String;
+ Smbios.Raw = (UINT8 *)++String;
break;
}
} while (TRUE);
@@ -1654,17 +1681,17 @@ ParseAndAddExistingSmbiosTable (
**/
EFI_STATUS
RetrieveSmbiosFromHob (
- IN EFI_HANDLE ImageHandle
+ IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- UINTN Index;
- SMBIOS_STRUCTURE_POINTER Smbios;
- EFI_HOB_GUID_TYPE *GuidHob;
- UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableAdress;
- UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
- VOID *TableAddress;
- UINTN TableMaximumSize;
+ EFI_STATUS Status;
+ UINTN Index;
+ SMBIOS_STRUCTURE_POINTER Smbios;
+ EFI_HOB_GUID_TYPE *GuidHob;
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTableAdress;
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
+ VOID *TableAddress;
+ UINTN TableMaximumSize;
Status = EFI_NOT_FOUND;
@@ -1673,17 +1700,18 @@ RetrieveSmbiosFromHob (
if (GuidHob == NULL) {
continue;
}
- GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+
+ GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (GuidHob);
if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION) {
//
// UNIVERSAL_PAYLOAD_SMBIOS_TABLE structure is used when Revision equals to UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION
//
- SmBiosTableAdress = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *) GET_GUID_HOB_DATA (GuidHob);
+ SmBiosTableAdress = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (GuidHob);
if (GenericHeader->Length >= UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SMBIOS_TABLE, SmBiosEntryPoint)) {
- if (mIsSmbiosTableValid[Index].IsValid ((VOID *) (UINTN )SmBiosTableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) {
+ if (mIsSmbiosTableValid[Index].IsValid ((VOID *)(UINTN)SmBiosTableAdress->SmBiosEntryPoint, &TableAddress, &TableMaximumSize)) {
Smbios.Raw = TableAddress;
- Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios, TableMaximumSize);
+ Status = ParseAndAddExistingSmbiosTable (ImageHandle, Smbios, TableMaximumSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "RetrieveSmbiosFromHob: Failed to parse preinstalled tables from Guid Hob\n"));
Status = EFI_UNSUPPORTED;
@@ -1695,6 +1723,7 @@ RetrieveSmbiosFromHob (
}
}
}
+
return Status;
}
@@ -1712,19 +1741,19 @@ RetrieveSmbiosFromHob (
EFI_STATUS
EFIAPI
SmbiosDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
- mPrivateData.Signature = SMBIOS_INSTANCE_SIGNATURE;
- mPrivateData.Smbios.Add = SmbiosAdd;
- mPrivateData.Smbios.UpdateString = SmbiosUpdateString;
- mPrivateData.Smbios.Remove = SmbiosRemove;
- mPrivateData.Smbios.GetNext = SmbiosGetNext;
- mPrivateData.Smbios.MajorVersion = (UINT8) (PcdGet16 (PcdSmbiosVersion) >> 8);
- mPrivateData.Smbios.MinorVersion = (UINT8) (PcdGet16 (PcdSmbiosVersion) & 0x00ff);
+ mPrivateData.Signature = SMBIOS_INSTANCE_SIGNATURE;
+ mPrivateData.Smbios.Add = SmbiosAdd;
+ mPrivateData.Smbios.UpdateString = SmbiosUpdateString;
+ mPrivateData.Smbios.Remove = SmbiosRemove;
+ mPrivateData.Smbios.GetNext = SmbiosGetNext;
+ mPrivateData.Smbios.MajorVersion = (UINT8)(PcdGet16 (PcdSmbiosVersion) >> 8);
+ mPrivateData.Smbios.MinorVersion = (UINT8)(PcdGet16 (PcdSmbiosVersion) & 0x00ff);
InitializeListHead (&mPrivateData.DataListHead);
InitializeListHead (&mPrivateData.AllocatedHandleListHead);
@@ -1734,12 +1763,12 @@ SmbiosDriverEntryPoint (
// Make a new handle and install the protocol
//
mPrivateData.Handle = NULL;
- Status = gBS->InstallProtocolInterface (
- &mPrivateData.Handle,
- &gEfiSmbiosProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mPrivateData.Smbios
- );
+ Status = gBS->InstallProtocolInterface (
+ &mPrivateData.Handle,
+ &gEfiSmbiosProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mPrivateData.Smbios
+ );
RetrieveSmbiosFromHob (ImageHandle);
return Status;