summaryrefslogtreecommitdiff
path: root/EmulatorPkg
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2012-01-24 08:39:11 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2012-01-24 08:39:11 +0000
commita0af6b27288fb1797e618d45ba3b4d6a9c742944 (patch)
tree7c3b3f1b2caedaa0b9eca520fef8bd703e916efb /EmulatorPkg
parent28d903168c23c808e069546b12a14e2e112a72cd (diff)
downloadedk2-platforms-a0af6b27288fb1797e618d45ba3b4d6a9c742944.tar.xz
Remove Framework concepts and fully port to PI. Remove the use of Hii for hard coded strings.
Note: The LogSmbiosData() function should probably be an MdeModulePkg library function. signed-off-by: andrewfish git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12954 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmulatorPkg')
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/Cpu.c286
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/Cpu.inf3
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/CpuDriver.h8
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/CpuIo.c5
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/MpService.c12
-rw-r--r--EmulatorPkg/CpuRuntimeDxe/Strings.unibin1712 -> 0 bytes
6 files changed, 195 insertions, 119 deletions
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.c b/EmulatorPkg/CpuRuntimeDxe/Cpu.c
index 07d6420807..7be4146b49 100644
--- a/EmulatorPkg/CpuRuntimeDxe/Cpu.c
+++ b/EmulatorPkg/CpuRuntimeDxe/Cpu.c
@@ -2,7 +2,7 @@
Emu driver to produce CPU Architectural Protocol.
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
-Portions copyright (c) 2011, Apple Inc. All rights reserved.
+Portions copyright (c) 2011 - 2012, Apple Inc. 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
@@ -47,6 +47,179 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
#define EFI_CPU_DATA_MAXIMUM_LENGTH 0x100
+SMBIOS_TABLE_TYPE4 mCpuSmbiosType4 = {
+ { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},
+ 1, // Socket String
+ ProcessorOther, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.
+ ProcessorFamilyOther, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY_DATA.
+ 2, // ProcessorManufacture String;
+ { // ProcessorId;
+ { // PROCESSOR_SIGNATURE
+ 0, // ProcessorSteppingId:4;
+ 0, // ProcessorModel: 4;
+ 0, // ProcessorFamily: 4;
+ 0, // ProcessorType: 2;
+ 0, // ProcessorReserved1: 2;
+ 0, // ProcessorXModel: 4;
+ 0, // ProcessorXFamily: 8;
+ 0, // ProcessorReserved2: 4;
+ },
+ { // PROCESSOR_FEATURE_FLAGS
+ 0, // ProcessorFpu :1;
+ 0, // ProcessorVme :1;
+ 0, // ProcessorDe :1;
+ 0, // ProcessorPse :1;
+ 0, // ProcessorTsc :1;
+ 0, // ProcessorMsr :1;
+ 0, // ProcessorPae :1;
+ 0, // ProcessorMce :1;
+ 0, // ProcessorCx8 :1;
+ 0, // ProcessorApic :1;
+ 0, // ProcessorReserved1 :1;
+ 0, // ProcessorSep :1;
+ 0, // ProcessorMtrr :1;
+ 0, // ProcessorPge :1;
+ 0, // ProcessorMca :1;
+ 0, // ProcessorCmov :1;
+ 0, // ProcessorPat :1;
+ 0, // ProcessorPse36 :1;
+ 0, // ProcessorPsn :1;
+ 0, // ProcessorClfsh :1;
+ 0, // ProcessorReserved2 :1;
+ 0, // ProcessorDs :1;
+ 0, // ProcessorAcpi :1;
+ 0, // ProcessorMmx :1;
+ 0, // ProcessorFxsr :1;
+ 0, // ProcessorSse :1;
+ 0, // ProcessorSse2 :1;
+ 0, // ProcessorSs :1;
+ 0, // ProcessorReserved3 :1;
+ 0, // ProcessorTm :1;
+ 0, // ProcessorReserved4 :2;
+ }
+ },
+ 3, // ProcessorVersion String;
+ { // Voltage;
+ 1, // ProcessorVoltageCapability5V :1;
+ 1, // ProcessorVoltageCapability3_3V :1;
+ 1, // ProcessorVoltageCapability2_9V :1;
+ 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.
+ 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be zero.
+ 0 // ProcessorVoltageIndicateLegacy :1;
+ },
+ 0, // ExternalClock;
+ 0, // MaxSpeed;
+ 0, // CurrentSpeed;
+ 0x41, // Status;
+ ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration value from PROCESSOR_UPGRADE.
+ 0, // L1CacheHandle;
+ 0, // L2CacheHandle;
+ 0, // L3CacheHandle;
+ 4, // SerialNumber;
+ 5, // AssetTag;
+ 6, // PartNumber;
+ 0, // CoreCount;
+ 0, // EnabledCoreCount;
+ 0, // ThreadCount;
+ 0, // ProcessorCharacteristics;
+ 0, // ProcessorFamily2;
+};
+
+CHAR8 *mCpuSmbiosType4Strings[] = {
+ "Socket",
+ "edk2.svn.sourceforge.net",
+ "Emulated Processor",
+ "1.0",
+ "1.0",
+ "1.0",
+ NULL
+};
+
+
+/**
+ Logs SMBIOS record.
+
+ Note: This should be a genric library function.
+
+ @param Template Fixed SMBIOS structure
+ @param StringPack Array of strings to convert to an SMBIOS string pack.
+
+**/
+EFI_STATUS
+LogSmbiosData (
+ IN EFI_SMBIOS_TABLE_HEADER *Template,
+ IN CHAR8 **StringPack
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ EFI_SMBIOS_TABLE_HEADER *Record;
+ UINTN Index;
+ UINTN StringSize;
+ UINTN Size;
+ CHAR8 *Str;
+
+ //
+ // Locate Smbios protocol.
+ //
+ Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Calculate the size of the fixed record and optional string pack
+ Size = Template->Length;
+ for (Index = 0; StringPack[Index] != NULL; Index++) {
+ StringSize = AsciiStrSize (StringPack[Index]);
+ Size += StringSize;
+ }
+ // Don't forget the terminating double null
+ Size += 1;
+
+ // Copy over Template
+ Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);
+ if (Record == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CopyMem (Record, Template, Template->Length);
+
+ // Append string pack
+ Str = ((CHAR8 *)Record) + Record->Length;
+ for (Index = 0; StringPack[Index] != NULL; Index++) {
+ StringSize = AsciiStrSize (StringPack[Index]);
+ CopyMem (Str, StringPack[Index], StringSize);
+ Str += StringSize;
+ }
+ *Str = 0;
+
+ SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
+ Status = Smbios->Add (
+ Smbios,
+ gImageHandle,
+ &SmbiosHandle,
+ Record
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ FreePool (Record);
+ return Status;
+}
+
+
+
+
+VOID
+CpuUpdateSmbios (
+ IN UINTN MaxCpus
+ )
+{
+ mCpuSmbiosType4.CoreCount = MaxCpus;
+ mCpuSmbiosType4.EnabledCoreCount = MaxCpus;
+ mCpuSmbiosType4.ThreadCount = MaxCpus;
+
+ LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER *)&mCpuSmbiosType4, mCpuSmbiosType4Strings);
+}
//
@@ -127,6 +300,9 @@ EmuInit (
IN EFI_CPU_INIT_TYPE InitType
)
{
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
+
+ Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
@@ -138,6 +314,8 @@ EmuRegisterInterruptHandler (
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
)
{
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
+
//
// Do parameter checking for EFI spec conformance
//
@@ -147,6 +325,7 @@ EmuRegisterInterruptHandler (
//
// Do nothing for Emu emulation
//
+ Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
@@ -186,6 +365,8 @@ EmuSetMemoryAttributes (
IN UINT64 Attributes
)
{
+ CPU_ARCH_PROTOCOL_PRIVATE *Private;
+
//
// Check for invalid parameter for Spec conformance
//
@@ -196,107 +377,12 @@ EmuSetMemoryAttributes (
//
// Do nothing for Nt32 emulation
//
+ Private = CPU_ARCH_PROTOCOL_PRIVATE_DATA_FROM_THIS (This);
return EFI_UNSUPPORTED;
}
-/**
- Logs SMBIOS record.
-
- @param Smbios Pointer to SMBIOS protocol instance.
- @param Buffer Pointer to the data buffer.
-
-**/
-VOID
-LogSmbiosData (
- IN EFI_SMBIOS_PROTOCOL *Smbios,
- IN UINT8 *Buffer
- )
-{
- EFI_STATUS Status;
- EFI_SMBIOS_HANDLE SmbiosHandle;
-
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios->Add (
- Smbios,
- NULL,
- &SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER*)Buffer
- );
- ASSERT_EFI_ERROR (Status);
-}
-
-VOID
-CpuUpdateSmbios (
- VOID
- )
-{
- EFI_STATUS Status;
- UINT32 TotalSize;
- EFI_SMBIOS_PROTOCOL *Smbios;
- EFI_HII_HANDLE HiiHandle;
- STRING_REF Token;
- UINTN CpuVerStrLen;
- EFI_STRING CpuVerStr;
- SMBIOS_TABLE_TYPE4 *SmbiosRecord;
- CHAR8 *OptionalStrStart;
-
- //
- // Locate Smbios protocol.
- //
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
-
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Initialize strings to HII database
- //
- HiiHandle = HiiAddPackages (
- &gEfiCallerIdGuid,
- NULL,
- CpuStrings,
- NULL
- );
- ASSERT (HiiHandle != NULL);
-
- Token = STRING_TOKEN (STR_PROCESSOR_VERSION);
- CpuVerStr = HiiGetPackageString(&gEfiCallerIdGuid, Token, NULL);
- CpuVerStrLen = StrLen(CpuVerStr);
- ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);
-
- 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
- //
- 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);
-}
-
-
/**
Callback function for idle events.
@@ -327,6 +413,7 @@ InitializeCpu (
EFI_STATUS Status;
UINT64 Frequency;
EFI_EVENT IdleLoopEvent;
+ UINTN MaxCpu;
//
// Retrieve the frequency of the performance counter in Hz.
@@ -338,9 +425,10 @@ InitializeCpu (
//
mTimerPeriod = DivU64x64Remainder (1000000000000000ULL, Frequency, NULL);
- CpuUpdateSmbios ();
+ CpuMpServicesInit (&MaxCpu);
+
+ CpuUpdateSmbios (MaxCpu);
- CpuMpServicesInit ();
Status = gBS->CreateEventEx (
EVT_NOTIFY_SIGNAL,
diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.inf b/EmulatorPkg/CpuRuntimeDxe/Cpu.inf
index e87c50a6fc..b8e8ebd8e2 100644
--- a/EmulatorPkg/CpuRuntimeDxe/Cpu.inf
+++ b/EmulatorPkg/CpuRuntimeDxe/Cpu.inf
@@ -34,14 +34,12 @@
CpuIo.c
Cpu.c
CpuDriver.h
- Strings.uni
MpService.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
- IntelFrameworkPkg/IntelFrameworkPkg.dec
EmulatorPkg/EmulatorPkg.dec
@@ -60,7 +58,6 @@
[Protocols]
gEmuIoThunkProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEmuThreadThunkProtocolGuid
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h b/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
index 3ede8473d3..5ec515dcbe 100644
--- a/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
+++ b/EmulatorPkg/CpuRuntimeDxe/CpuDriver.h
@@ -17,22 +17,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define _CPU_ARCHITECTURAL_PROTOCOL_DRIVER_H_
-#include <FrameworkDxe.h>
+#include <PiDxe.h>
#include <IndustryStandard/SmBios.h>
#include <Protocol/Cpu.h>
#include <Protocol/Smbios.h>
-#include <Protocol/FrameworkHii.h>
#include <Protocol/MpService.h>
#include <Protocol/EmuThread.h>
#include <Protocol/CpuIo2.h>
-#include <Guid/DataHubRecords.h>
#include <Guid/IdleLoopEvent.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
-#include <Library/HiiLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -42,7 +39,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/PcdLib.h>
-extern UINT8 CpuStrings[];
//
// Internal Data Structures
@@ -230,7 +226,7 @@ EmuSetMemoryAttributes (
EFI_STATUS
CpuMpServicesInit (
- VOID
+ OUT UINTN *MaxCores
);
EFI_STATUS
diff --git a/EmulatorPkg/CpuRuntimeDxe/CpuIo.c b/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
index a8c10ba555..3d4309d422 100644
--- a/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
+++ b/EmulatorPkg/CpuRuntimeDxe/CpuIo.c
@@ -18,12 +18,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
-#include <FrameworkDxe.h>
+#include <PiDxe.h>
#include <Protocol/Cpu.h>
-#include <Protocol/DataHub.h>
-#include <Guid/DataHubRecords.h>
#include <Protocol/CpuIo2.h>
-#include <Protocol/FrameworkHii.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c b/EmulatorPkg/CpuRuntimeDxe/MpService.c
index ba0ad82504..6eecbbc9bd 100644
--- a/EmulatorPkg/CpuRuntimeDxe/MpService.c
+++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c
@@ -1308,35 +1308,33 @@ CpuReadToBootFunction (
EFI_STATUS
CpuMpServicesInit (
- VOID
+ OUT UINTN *MaxCpus
)
{
EFI_STATUS Status;
EFI_HANDLE Handle;
EMU_IO_THUNK_PROTOCOL *IoThunk;
- UINTN MaxCpus;
-
- MaxCpus = 1; // BSP
+ *MaxCpus = 1; // BSP
IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
if (IoThunk != NULL) {
Status = IoThunk->Open (IoThunk);
if (!EFI_ERROR (Status)) {
if (IoThunk->ConfigString != NULL) {
- MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);
+ *MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);
gThread = IoThunk->Interface;
}
}
}
- if (MaxCpus == 1) {
+ if (*MaxCpus == 1) {
// We are not MP so nothing to do
return EFI_SUCCESS;
}
gPollInterval = PcdGet64 (PcdEmuMpServicesPollingInterval);
- Status = InitializeMpSystemData (MaxCpus);
+ Status = InitializeMpSystemData (*MaxCpus);
if (EFI_ERROR (Status)) {
return Status;
}
diff --git a/EmulatorPkg/CpuRuntimeDxe/Strings.uni b/EmulatorPkg/CpuRuntimeDxe/Strings.uni
deleted file mode 100644
index f5aa4ddb43..0000000000
--- a/EmulatorPkg/CpuRuntimeDxe/Strings.uni
+++ /dev/null
Binary files differ