Fix issue with SMBIOS driver assumming memory exists below 4GB.

approved-by: andrewfish
reviewed-by: li-elvin



git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12220 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2011-08-29 20:47:22 +00:00
parent df1b7575ba
commit c7ce516971
1 changed files with 27 additions and 10 deletions

View File

@ -103,6 +103,7 @@ SMBIOS_TABLE_ENTRY_POINT EntryPointStructureData = {
}; };
/** /**
Get the full size of SMBIOS structure including optional strings that follow the formatted structure. Get the full size of SMBIOS structure including optional strings that follow the formatted structure.
@ -889,7 +890,11 @@ SmbiosCreateTable (
// //
SmbiosProtocol = &mPrivateData.Smbios; SmbiosProtocol = &mPrivateData.Smbios;
if (EntryPointStructure->TableAddress == 0) {
PreAllocatedPages = 0;
} else {
PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength); PreAllocatedPages = EFI_SIZE_TO_PAGES (EntryPointStructure->TableLength);
}
// //
// Make some statistics about all the structures // Make some statistics about all the structures
@ -957,10 +962,13 @@ SmbiosCreateTable (
&PhysicalAddress &PhysicalAddress
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "SmbiosCreateTable() could not allocate SMBIOS table < 4GB\n"));
EntryPointStructure->TableAddress = 0;
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} } else {
EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;
} }
}
// //
// Assemble the tables // Assemble the tables
@ -1060,9 +1068,18 @@ SmbiosDriverEntryPoint (
EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)), EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
&PhysicalAddress &PhysicalAddress
); );
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate EntryPointStructure < 4GB\n"));
Status = gBS->AllocatePages (
AllocateAnyPages,
EfiReservedMemoryType,
EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT)),
&PhysicalAddress
);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
}
EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) PhysicalAddress; EntryPointStructure = (SMBIOS_TABLE_ENTRY_POINT *) (UINTN) PhysicalAddress;
@ -1086,13 +1103,13 @@ SmbiosDriverEntryPoint (
&PhysicalAddress &PhysicalAddress
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
FreePages ((VOID*) EntryPointStructure, EFI_SIZE_TO_PAGES (sizeof (SMBIOS_TABLE_ENTRY_POINT))); DEBUG ((EFI_D_ERROR, "SmbiosDriverEntryPoint() could not allocate SMBIOS table < 4GB\n"));
EntryPointStructure = NULL; EntryPointStructure->TableAddress = 0;
return EFI_OUT_OF_RESOURCES; EntryPointStructure->TableLength = 0;
} } else {
EntryPointStructure->TableAddress = (UINT32) PhysicalAddress; EntryPointStructure->TableAddress = (UINT32) PhysicalAddress;
EntryPointStructure->TableLength = EFI_PAGES_TO_SIZE (1); EntryPointStructure->TableLength = EFI_PAGES_TO_SIZE (1);
}
// //
// Make a new handle and install the protocol // Make a new handle and install the protocol