1. PI SMBIOS Checkin. Major change include:

1) Produce PI SMBIOS protocol in MdeModulePkg
2) Update all consumers (in CorePkgs and native platform pkgs) to consume SMBIOS protocol instead of DataHub
3) Pass ECC tool; Verify Nt32, Duet, Unix platform

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9455 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
davidhuang 2009-11-20 04:01:15 +00:00
parent 21020c7c8b
commit 6cfbf7adff
4 changed files with 155 additions and 159 deletions

View File

@ -20,13 +20,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/MdeModuleHii.h> #include <Guid/MdeModuleHii.h>
#include <Guid/FileSystemVolumeLabelInfo.h> #include <Guid/FileSystemVolumeLabelInfo.h>
#include <Protocol/DevicePath.h> #include <Protocol/DevicePath.h>
#include <Guid/DataHubRecords.h> #include <IndustryStandard/SmBios.h>
#include <Protocol/LoadFile.h> #include <Protocol/LoadFile.h>
#include <Protocol/CpuIo.h> #include <Protocol/CpuIo.h>
#include <Guid/FileInfo.h> #include <Guid/FileInfo.h>
#include <Protocol/HiiConfigRouting.h> #include <Protocol/HiiConfigRouting.h>
#include <Protocol/Bds.h> #include <Protocol/Bds.h>
#include <Protocol/DataHub.h> #include <Protocol/Smbios.h>
#include <Protocol/UgaDraw.h> #include <Protocol/UgaDraw.h>
#include <Protocol/BlockIo.h> #include <Protocol/BlockIo.h>
#include <Guid/GlobalVariable.h> #include <Guid/GlobalVariable.h>

View File

@ -130,9 +130,6 @@
## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device) ## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device)
gEfiFileSystemVolumeLabelInfoIdGuid ## CONSUMES ## GUID (Indicate the information type is volume) gEfiFileSystemVolumeLabelInfoIdGuid ## CONSUMES ## GUID (Indicate the information type is volume)
gEfiFileInfoGuid ## CONSUMES ## GUID (Indicate the information type is file) gEfiFileInfoGuid ## CONSUMES ## GUID (Indicate the information type is file)
gEfiMiscSubClassGuid ## CONSUMES ## GUID (Indicate the datahub for holding misc sub class record)
gEfiMemorySubClassGuid ## CONSUMES ## GUID (Indicate the datahub for holding memory record)
gEfiProcessorSubClassGuid ## CONSUMES ## GUID (Indicate the datahub for holding processor record)
gEfiHiiPlatformSetupFormsetGuid ## CONSUMES ## GUID (Indicate the formset class guid to be displayed) gEfiHiiPlatformSetupFormsetGuid ## CONSUMES ## GUID (Indicate the formset class guid to be displayed)
gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode) gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode)
@ -140,7 +137,7 @@
gEfiSimpleFileSystemProtocolGuid # PROTOCOL ALWAYS_CONSUMES gEfiSimpleFileSystemProtocolGuid # PROTOCOL ALWAYS_CONSUMES
gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_CONSUMES gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_CONSUMES
gEfiBdsArchProtocolGuid # PROTOCOL ALWAYS_PRODUCES gEfiBdsArchProtocolGuid # PROTOCOL ALWAYS_PRODUCES
gEfiDataHubProtocolGuid # PROTOCOL ALWAYS_CONSUMES gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiGenericMemTestProtocolGuid # PROTOCOL ALWAYS_CONSUMES gEfiGenericMemTestProtocolGuid # PROTOCOL ALWAYS_CONSUMES
gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMES gEfiLegacyBiosProtocolGuid # PROTOCOL ALWAYS_CONSUMES
gEfiUgaDrawProtocolGuid |PcdUgaConsumeSupport # PROTOCOL SOMETIMES_CONSUMES gEfiUgaDrawProtocolGuid |PcdUgaConsumeSupport # PROTOCOL SOMETIMES_CONSUMES

View File

@ -1,7 +1,7 @@
/** @file /** @file
Utility routines used by boot maintenance modules. Utility routines used by boot maintenance modules.
Copyright (c) 2004 - 2008, Intel Corporation. <BR> Copyright (c) 2004 - 2009, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -431,64 +431,5 @@ EfiLibStrFromDatahub (
IN EFI_DEVICE_PATH_PROTOCOL *DevPath IN EFI_DEVICE_PATH_PROTOCOL *DevPath
) )
{ {
EFI_STATUS Status;
UINT16 *Desc;
EFI_DATA_HUB_PROTOCOL *Datahub;
UINT64 Count;
EFI_DATA_RECORD_HEADER *Record;
EFI_SUBCLASS_TYPE1_HEADER *DataHdr;
EFI_GUID MiscGuid;
EFI_MISC_ONBOARD_DEVICE_DATA *Ob;
EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *Port;
EFI_TIME CurTime;
CopyGuid (&MiscGuid, &gEfiMiscSubClassGuid);
Status = gBS->LocateProtocol (
&gEfiDataHubProtocolGuid,
NULL,
(VOID **) &Datahub
);
if (EFI_ERROR (Status)) {
return NULL;
}
Status = gRT->GetTime (&CurTime, NULL);
if (EFI_ERROR (Status)) {
return NULL;
}
Count = 0;
do {
Status = Datahub->GetNextRecord (Datahub, &Count, NULL, &Record);
if (EFI_ERROR (Status)) {
break;
}
if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA && CompareGuid (&Record->DataRecordGuid, &MiscGuid)) {
//
// This record is what we need
//
DataHdr = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
if (EFI_MISC_ONBOARD_DEVICE_RECORD_NUMBER == DataHdr->RecordType) {
Ob = (EFI_MISC_ONBOARD_DEVICE_DATA *) (DataHdr + 1);
if (BdsLibMatchDevicePaths ((EFI_DEVICE_PATH_PROTOCOL *) &Ob->OnBoardDevicePath, DevPath)) {
GetProducerString (&Record->ProducerName, Ob->OnBoardDeviceDescription, &Desc);
return Desc;
}
}
if (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER == DataHdr->RecordType) {
Port = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) (DataHdr + 1);
if (BdsLibMatchDevicePaths ((EFI_DEVICE_PATH_PROTOCOL *) &Port->PortPath, DevPath)) {
GetProducerString (&Record->ProducerName, Port->PortExternalConnectorDesignator, &Desc);
return Desc;
}
}
}
} while (TimeCompare (&Record->LogTime, &CurTime) && Count != 0);
return NULL; return NULL;
} }

View File

@ -577,22 +577,24 @@ GetProducerString (
Convert Processor Frequency Data to a string. Convert Processor Frequency Data to a string.
@param ProcessorFrequency The frequency data to process @param ProcessorFrequency The frequency data to process
@param Base10Exponent The exponent based on 10
@param String The string that is created @param String The string that is created
**/ **/
VOID VOID
ConvertProcessorToString ( ConvertProcessorToString (
IN EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency, IN UINT16 ProcessorFrequency,
OUT CHAR16 **String IN UINT16 Base10Exponent,
OUT CHAR16 **String
) )
{ {
CHAR16 *StringBuffer; CHAR16 *StringBuffer;
UINTN Index; UINTN Index;
UINT32 FreqMhz; UINT32 FreqMhz;
if (ProcessorFrequency->Exponent >= 6) { if (Base10Exponent >= 6) {
FreqMhz = ProcessorFrequency->Value; FreqMhz = ProcessorFrequency;
for (Index = 0; Index < (UINTN) (ProcessorFrequency->Exponent - 6); Index++) { for (Index = 0; Index < (UINTN) (Base10Exponent - 6); Index++) {
FreqMhz *= 10; FreqMhz *= 10;
} }
} else { } else {
@ -605,12 +607,11 @@ ConvertProcessorToString (
StrCat (StringBuffer, L"."); StrCat (StringBuffer, L".");
UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2); UnicodeValueToString (StringBuffer + Index + 1, PREFIX_ZERO, (FreqMhz % 1000) / 10, 2);
StrCat (StringBuffer, L" GHz"); StrCat (StringBuffer, L" GHz");
*String = (CHAR16 *) StringBuffer; *String = (CHAR16 *) StringBuffer;
return ; return ;
} }
/** /**
Convert Memory Size to a string. Convert Memory Size to a string.
@ -636,6 +637,74 @@ ConvertMemorySizeToString (
return ; return ;
} }
/**
Acquire the string associated with the Index from smbios structure and return it.
The caller is responsible for free the string buffer.
@param OptionalStrStart The start position to search the string
@param Index The index of the string to extract
@param String The string that is extracted
@retval EFI_SUCCESS The function returns EFI_SUCCESS always.
**/
EFI_STATUS
GetOptionalStringByIndex (
IN CHAR8 *OptionalStrStart,
IN UINT8 Index,
OUT CHAR16 **String
)
{
UINT8 StrNum;
UINTN CurrentStrLen;
CHAR8* CharInStr;
EFI_STATUS Status;
StrNum = 0;
Status = EFI_NOT_FOUND;
CharInStr = OptionalStrStart;
if (Index != 1) {
CurrentStrLen = 0;
//
// look for the two consecutive zeros, check the string limit by the way.
//
while (*CharInStr != 0 || *(CharInStr+1) != 0) {
if (*CharInStr == 0) {
StrNum += 1;
CharInStr++;
}
if (StrNum == Index) {
Status = EFI_SUCCESS;
break;
}
CurrentStrLen = AsciiStrLen(CharInStr);
//
// forward the pointer
//
OptionalStrStart = CharInStr;
CharInStr += CurrentStrLen;
}
if (EFI_ERROR (Status)) {
*String = GetStringById (STRING_TOKEN (STR_MISSING_STRING));
return Status;
}
} else {
CurrentStrLen = AsciiStrLen(CharInStr);
}
*String = AllocatePool((CurrentStrLen + 1)*sizeof(CHAR16));
AsciiStrToUnicodeStr(OptionalStrStart, *String);
return EFI_SUCCESS;
}
/** /**
Update the banner information for the Front Page based on DataHub information. Update the banner information for the Front Page based on DataHub information.
@ -645,19 +714,18 @@ UpdateFrontPageStrings (
VOID VOID
) )
{ {
UINT8 StrIndex;
CHAR16 *NewString;
BOOLEAN Find[5];
EFI_STATUS Status; EFI_STATUS Status;
EFI_STRING_ID TokenToUpdate; EFI_STRING_ID TokenToUpdate;
CHAR16 *NewString; EFI_SMBIOS_HANDLE SmbiosHandle;
UINT64 MonotonicCount; EFI_SMBIOS_PROTOCOL *Smbios;
EFI_DATA_HUB_PROTOCOL *DataHub; SMBIOS_TABLE_TYPE0 *Type0Record;
EFI_DATA_RECORD_HEADER *Record; SMBIOS_TABLE_TYPE1 *Type1Record;
EFI_SUBCLASS_TYPE1_HEADER *DataHeader; SMBIOS_TABLE_TYPE4 *Type4Record;
EFI_MISC_BIOS_VENDOR_DATA *BiosVendor; SMBIOS_TABLE_TYPE19 *Type19Record;
EFI_MISC_SYSTEM_MANUFACTURER_DATA *SystemManufacturer; EFI_SMBIOS_TABLE_HEADER *Record;
EFI_PROCESSOR_VERSION_DATA *ProcessorVersion;
EFI_PROCESSOR_CORE_FREQUENCY_DATA *ProcessorFrequency;
EFI_MEMORY_ARRAY_START_ADDRESS_DATA *MemoryArray;
BOOLEAN Find[5];
ZeroMem (Find, sizeof (Find)); ZeroMem (Find, sizeof (Find));
@ -665,89 +733,79 @@ UpdateFrontPageStrings (
// Update Front Page strings // Update Front Page strings
// //
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiDataHubProtocolGuid, &gEfiSmbiosProtocolGuid,
NULL, NULL,
(VOID **) &DataHub (VOID **) &Smbios
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
MonotonicCount = 0; SmbiosHandle = 0;
Record = NULL;
do { do {
Status = DataHub->GetNextRecord (DataHub, &MonotonicCount, NULL, &Record); Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
if (EFI_ERROR (Status) || Record == NULL) { if (EFI_ERROR(Status)) {
break; break;
} }
if (Record->DataRecordClass == EFI_DATA_RECORD_CLASS_DATA) {
DataHeader = (EFI_SUBCLASS_TYPE1_HEADER *) (Record + 1);
if (CompareGuid (&Record->DataRecordGuid, &gEfiMiscSubClassGuid) &&
(DataHeader->RecordType == EFI_MISC_BIOS_VENDOR_RECORD_NUMBER)
) {
BiosVendor = (EFI_MISC_BIOS_VENDOR_DATA *) (DataHeader + 1);
GetProducerString (&Record->ProducerName, BiosVendor->BiosVersion, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[0] = TRUE;
}
if (CompareGuid (&Record->DataRecordGuid, &gEfiMiscSubClassGuid) && if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
(DataHeader->RecordType == EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER) Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
) { StrIndex = Type0Record->BiosVersion;
SystemManufacturer = (EFI_MISC_SYSTEM_MANUFACTURER_DATA *) (DataHeader + 1); GetOptionalStringByIndex ((CHAR8*)(Type0Record+1), StrIndex, &NewString);
GetProducerString (&Record->ProducerName, SystemManufacturer->SystemProductName, &NewString); TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL); HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); FreePool (NewString);
FreePool (NewString); Find[0] = TRUE;
Find[1] = TRUE; }
}
if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) && if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
(DataHeader->RecordType == ProcessorVersionRecordType) Type1Record = (SMBIOS_TABLE_TYPE1 *) Record;
) { StrIndex = Type1Record->ProductName;
ProcessorVersion = (EFI_PROCESSOR_VERSION_DATA *) (DataHeader + 1); GetOptionalStringByIndex ((CHAR8*)(Type1Record+1), StrIndex, &NewString);
GetProducerString (&Record->ProducerName, *ProcessorVersion, &NewString); TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL); HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL); FreePool (NewString);
FreePool (NewString); Find[1] = TRUE;
Find[2] = TRUE;
}
if (CompareGuid (&Record->DataRecordGuid, &gEfiProcessorSubClassGuid) &&
(DataHeader->RecordType == ProcessorCoreFrequencyRecordType)
) {
ProcessorFrequency = (EFI_PROCESSOR_CORE_FREQUENCY_DATA *) (DataHeader + 1);
ConvertProcessorToString (ProcessorFrequency, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[3] = TRUE;
}
if (CompareGuid (&Record->DataRecordGuid, &gEfiMemorySubClassGuid) &&
(DataHeader->RecordType == EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER)
) {
MemoryArray = (EFI_MEMORY_ARRAY_START_ADDRESS_DATA *) (DataHeader + 1);
ConvertMemorySizeToString (
(UINT32)(RShiftU64((MemoryArray->MemoryArrayEndAddress - MemoryArray->MemoryArrayStartAddress + 1), 20)),
&NewString
);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[4] = TRUE;
}
} }
} while (!EFI_ERROR (Status) && (MonotonicCount != 0) && !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
StrIndex = Type4Record->ProcessorVersion;
GetOptionalStringByIndex ((CHAR8*)(Type4Record+1), StrIndex, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[2] = TRUE;
}
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
Type4Record = (SMBIOS_TABLE_TYPE4 *) Record;
ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[3] = TRUE;
}
if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
ConvertMemorySizeToString (
(UINT32)(RShiftU64((Type19Record->EndingAddress - Type19Record->StartingAddress + 1), 10)),
&NewString
);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
FreePool (NewString);
Find[4] = TRUE;
}
} while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
return ; return ;
} }
/** /**
Function waits for a given event to fire, or for an optional timeout to expire. Function waits for a given event to fire, or for an optional timeout to expire.
@param Event The event to wait for @param Event The event to wait for
@param Timeout An optional timeout value in 100 ns units. @param Timeout An optional timeout value in 100 ns units.
@retval EFI_SUCCESS Event fired before Timeout expired. @retval EFI_SUCCESS Event fired before Timeout expired.
@retval EFI_TIME_OUT Timout expired before Event fired.. @retval EFI_TIME_OUT Timout expired before Event fired..
@ -759,8 +817,8 @@ WaitForSingleEvent (
IN UINT64 Timeout OPTIONAL IN UINT64 Timeout OPTIONAL
) )
{ {
EFI_STATUS Status;
UINTN Index; UINTN Index;
EFI_STATUS Status;
EFI_EVENT TimerEvent; EFI_EVENT TimerEvent;
EFI_EVENT WaitList[2]; EFI_EVENT WaitList[2];
@ -774,10 +832,10 @@ WaitForSingleEvent (
// Set the timer event // Set the timer event
// //
gBS->SetTimer ( gBS->SetTimer (
TimerEvent, TimerEvent,
TimerRelative, TimerRelative,
Timeout Timeout
); );
// //
// Wait for the original event or the timer // Wait for the original event or the timer
@ -810,7 +868,7 @@ WaitForSingleEvent (
Function show progress bar to wait for user input. Function show progress bar to wait for user input.
@param TimeoutDefault The fault time out value before the system continue to boot. @param TimeoutDefault The fault time out value before the system continue to boot.
@retval EFI_SUCCESS User pressed some key except "Enter" @retval EFI_SUCCESS User pressed some key except "Enter"
@retval EFI_TIME_OUT Timout expired or user press "Enter" @retval EFI_TIME_OUT Timout expired or user press "Enter"
@ -821,13 +879,13 @@ ShowProgress (
IN UINT16 TimeoutDefault IN UINT16 TimeoutDefault
) )
{ {
EFI_STATUS Status;
CHAR16 *TmpStr; CHAR16 *TmpStr;
UINT16 TimeoutRemain;
EFI_STATUS Status;
EFI_INPUT_KEY Key;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color; EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
EFI_INPUT_KEY Key;
UINT16 TimeoutRemain;
if (TimeoutDefault == 0) { if (TimeoutDefault == 0) {
return EFI_TIMEOUT; return EFI_TIMEOUT;