diff options
author | davidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-11-20 04:02:34 +0000 |
---|---|---|
committer | davidhuang <davidhuang@6f19259b-4bc3-4df7-8a09-765794883524> | 2009-11-20 04:02:34 +0000 |
commit | aaa2cc19dd44e68f0365c7a17a9fda27582976f8 (patch) | |
tree | 2b891550e9736937e4fe64b532dfe4db26854fd8 /UnixPkg/CpuRuntimeDxe | |
parent | 1fdd39d371ecd0c660dce8926add29846c95cd37 (diff) | |
download | edk2-platforms-aaa2cc19dd44e68f0365c7a17a9fda27582976f8.tar.xz |
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@9458 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UnixPkg/CpuRuntimeDxe')
-rw-r--r-- | UnixPkg/CpuRuntimeDxe/Cpu.c | 127 | ||||
-rw-r--r-- | UnixPkg/CpuRuntimeDxe/Cpu.inf | 10 |
2 files changed, 70 insertions, 67 deletions
diff --git a/UnixPkg/CpuRuntimeDxe/Cpu.c b/UnixPkg/CpuRuntimeDxe/Cpu.c index a151aafc07..7778c43b23 100644 --- a/UnixPkg/CpuRuntimeDxe/Cpu.c +++ b/UnixPkg/CpuRuntimeDxe/Cpu.c @@ -22,8 +22,9 @@ Abstract: --*/
#include <FrameworkDxe.h>
+#include <IndustryStandard/SmBios.h>
#include <Protocol/Cpu.h>
-#include <Protocol/DataHub.h>
+#include <Protocol/Smbios.h>
#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo.h>
#include <Protocol/FrameworkHii.h>
@@ -70,18 +71,6 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = { TRUE
};
-typedef union {
- EFI_CPU_DATA_RECORD *DataRecord;
- UINT8 *Raw;
-} EFI_CPU_DATA_RECORD_BUFFER;
-
-EFI_SUBCLASS_TYPE1_HEADER mCpuDataRecordHeader = {
- EFI_PROCESSOR_SUBCLASS_VERSION, // Version
- sizeof (EFI_SUBCLASS_TYPE1_HEADER), // Header Size
- 0, // Instance, Initialize later
- EFI_SUBCLASS_INSTANCE_NON_APPLICABLE, // SubInstance
- 0 // RecordType, Initialize later
-};
//
// Service routines for the driver
@@ -405,8 +394,36 @@ Returns: return EFI_UNSUPPORTED;
}
+
+
+/**
+ Logs SMBIOS record.
+
+ @param Smbios Pointer to SMBIOS protocol instance.
+ @param Buffer Pointer to the data buffer.
+
+**/
VOID
-CpuUpdateDataHub (
+LogSmbiosData (
+ IN EFI_SMBIOS_PROTOCOL *Smbios,
+ IN UINT8 *Buffer
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+
+ SmbiosHandle = 0;
+ Status = Smbios->Add (
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER*)Buffer
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+CpuUpdateSmbios (
VOID
)
/*++
@@ -424,32 +441,25 @@ Returns: --*/
{
EFI_STATUS Status;
- EFI_CPU_DATA_RECORD_BUFFER RecordBuffer;
- UINT32 HeaderSize;
+ EFI_SMBIOS_PROTOCOL *Smbios;
UINT32 TotalSize;
- EFI_DATA_HUB_PROTOCOL *DataHub;
EFI_HII_HANDLE HiiHandle;
+ STRING_REF Token;
+ UINTN CpuVerStrLen;
+ EFI_STRING CpuVerStr;
+ SMBIOS_TABLE_TYPE4 *SmbiosRecord;
+ CHAR8 *OptionalStrStart;
//
- // Locate DataHub protocol.
+ // Locate Smbios protocol.
//
- Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **)&DataHub);
+ Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
+
if (EFI_ERROR (Status)) {
return;
}
//
- // Initialize data record header
- //
- mCpuDataRecordHeader.Instance = 1;
- HeaderSize = sizeof (EFI_SUBCLASS_TYPE1_HEADER);
-
- RecordBuffer.Raw = AllocatePool (HeaderSize + EFI_CPU_DATA_MAXIMUM_LENGTH);
- if (RecordBuffer.Raw == NULL) {
- return ;
- }
-
- //
// Initialize strings to HII database
//
HiiHandle = HiiAddPackages (
@@ -460,40 +470,39 @@ Returns: );
ASSERT (HiiHandle != NULL);
- CopyMem (RecordBuffer.Raw, &mCpuDataRecordHeader, HeaderSize);
+ Token = STRING_TOKEN (STR_INTEL_GENUINE_PROCESSOR);
+ CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL);
+ CpuVerStrLen = StrLen(CpuVerStr);
+ ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);
- RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorVersionRecordType;
- RecordBuffer.DataRecord->VariableRecord.ProcessorVersion = STRING_TOKEN (STR_INTEL_GENUINE_PROCESSOR);
- TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_VERSION_DATA);
-
- Status = DataHub->LogData (
- DataHub,
- &gEfiProcessorSubClassGuid,
- &gEfiCallerIdGuid,
- EFI_DATA_RECORD_CLASS_DATA,
- RecordBuffer.Raw,
- TotalSize
- );
+ TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;
+ SmbiosRecord = AllocatePool(TotalSize);
+ ZeroMem(SmbiosRecord, TotalSize);
+ SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION;
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE4);
+ //
+ // Make handle chosen by smbios protocol.add automatically.
+ //
+ SmbiosRecord->Hdr.Handle = 0;
+ //
+ // Processor version is the 1st string.
+ //
+ SmbiosRecord->ProcessorVersion = 1;
//
// Store CPU frequency data record to data hub - It's an emulator so make up a value
//
- RecordBuffer.DataRecord->DataRecordHeader.RecordType = ProcessorCoreFrequencyRecordType;
- RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Value = 1234;
- RecordBuffer.DataRecord->VariableRecord.ProcessorCoreFrequency.Exponent = 6;
- TotalSize = HeaderSize + sizeof (EFI_PROCESSOR_CORE_FREQUENCY_DATA);
-
- Status = DataHub->LogData (
- DataHub,
- &gEfiProcessorSubClassGuid,
- &gEfiCallerIdGuid,
- EFI_DATA_RECORD_CLASS_DATA,
- RecordBuffer.Raw,
- TotalSize
- );
-
- FreePool (RecordBuffer.Raw);
+ SmbiosRecord->CurrentSpeed = 1234;
+
+ OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
+ UnicodeStrToAsciiStr(CpuVerStr, OptionalStrStart);
+
+ //
+ // Now we have got the full smbios record, call smbios protocol to add this record.
+ //
+ LogSmbiosData(Smbios, (UINT8 *) SmbiosRecord);
+ FreePool (SmbiosRecord);
}
EFI_STATUS
@@ -526,7 +535,7 @@ Returns: {
EFI_STATUS Status;
- CpuUpdateDataHub ();
+ CpuUpdateSmbios ();
Status = gBS->InstallMultipleProtocolInterfaces (
&mCpuTemplate.Handle,
diff --git a/UnixPkg/CpuRuntimeDxe/Cpu.inf b/UnixPkg/CpuRuntimeDxe/Cpu.inf index a0f66b6713..b96249386a 100644 --- a/UnixPkg/CpuRuntimeDxe/Cpu.inf +++ b/UnixPkg/CpuRuntimeDxe/Cpu.inf @@ -56,18 +56,12 @@ DebugLib
BaseLib
-
-[Guids]
- gEfiProcessorSubClassGuid # SOMETIMES_CONSUMED
-
-
[Protocols]
gEfiUnixIoProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
- gEfiDataHubProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
+ gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCpuIoProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
-
[Depex]
- gEfiDataHubProtocolGuid
+ gEfiSmbiosProtocolGuid
|