mirror of https://github.com/acidanthera/audk.git
Add MP support. Based on PcdEmuApCount APs (Application Processors) are created in the CpuRuntimeDxe driver. If PcdEmuApCount > 0 then the MpServices protocol is created on top of pthreads and the APs are availible to use vis the MpService protocol.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11644 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e6a6082acf
commit
c4671a67d8
|
@ -326,6 +326,8 @@ InitializeCpu (
|
|||
mTimerPeriod = DivU64x64Remainder (1000000000000000, Frequency, NULL);
|
||||
|
||||
CpuUpdateSmbios ();
|
||||
|
||||
CpuMpServicesInit ();
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&mCpuTemplate.Handle,
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
Cpu.c
|
||||
CpuDriver.h
|
||||
Strings.uni
|
||||
|
||||
MpService.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
@ -53,6 +54,7 @@
|
|||
DebugLib
|
||||
BaseLib
|
||||
EmuThunkLib
|
||||
PcdLib
|
||||
|
||||
[Protocols]
|
||||
gEmuIoThunkProtocolGuid # PROTOCOL_NOTIFY SOMETIMES_CONSUMED
|
||||
|
@ -60,6 +62,11 @@
|
|||
gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
||||
gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
|
||||
gEmuPthreadThunkProtocolGuid
|
||||
gEfiMpServiceProtocolGuid
|
||||
|
||||
[Pcd]
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval
|
||||
|
||||
[Depex]
|
||||
gEfiSmbiosProtocolGuid
|
||||
|
|
|
@ -18,11 +18,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
#include <FrameworkDxe.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
|
||||
#include <Protocol/Cpu.h>
|
||||
#include <Protocol/Smbios.h>
|
||||
#include <Protocol/FrameworkHii.h>
|
||||
#include <Guid/DataHubRecords.h>
|
||||
#include <Protocol/MpService.h>
|
||||
#include <Protocol/EmuPthreadThunk.h>
|
||||
#include <Protocol/CpuIo2.h>
|
||||
|
||||
#include <Guid/DataHubRecords.h>
|
||||
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/HiiLib.h>
|
||||
|
@ -31,6 +36,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
|
||||
|
||||
extern UINT8 CpuStrings[];
|
||||
|
@ -61,6 +68,52 @@ typedef struct {
|
|||
CPU_ARCH_PROT_PRIVATE_SIGNATURE \
|
||||
)
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
CPU_STATE_IDLE,
|
||||
CPU_STATE_BLOCKED,
|
||||
CPU_STATE_READY,
|
||||
CPU_STATE_BUSY,
|
||||
CPU_STATE_FINISHED
|
||||
} PROCESSOR_STATE;
|
||||
|
||||
|
||||
//
|
||||
// Define Individual Processor Data block.
|
||||
//
|
||||
typedef struct {
|
||||
EFI_PROCESSOR_INFORMATION Info;
|
||||
EFI_AP_PROCEDURE Procedure;
|
||||
VOID *Parameter;
|
||||
VOID *StateLock;
|
||||
VOID *ProcedureLock;
|
||||
PROCESSOR_STATE State;
|
||||
EFI_EVENT CheckThisAPEvent;
|
||||
} PROCESSOR_DATA_BLOCK;
|
||||
|
||||
|
||||
//
|
||||
// Define MP data block which consumes individual processor block.
|
||||
//
|
||||
typedef struct {
|
||||
UINTN NumberOfProcessors;
|
||||
UINTN NumberOfEnabledProcessors;
|
||||
EFI_EVENT CheckAllAPsEvent;
|
||||
EFI_EVENT WaitEvent;
|
||||
UINTN FinishCount;
|
||||
UINTN StartCount;
|
||||
EFI_AP_PROCEDURE Procedure;
|
||||
VOID *ProcedureArgument;
|
||||
BOOLEAN SingleThread;
|
||||
UINTN StartedNumber;
|
||||
PROCESSOR_DATA_BLOCK *ProcessorData;
|
||||
} MP_SYSTEM_DATA;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CpuMemoryServiceRead (
|
||||
|
@ -169,4 +222,19 @@ EmuSetMemoryAttributes (
|
|||
IN UINT64 Attributes
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
CpuMpServicesInit (
|
||||
VOID
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
CpuMpServicesWhoAmI (
|
||||
IN EFI_MP_SERVICES_PROTOCOL *This,
|
||||
OUT UINTN *ProcessorNumber
|
||||
);
|
||||
|
||||
extern EFI_MP_SERVICES_PROTOCOL mMpSercicesTemplate;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -52,7 +52,7 @@
|
|||
# gEmuNetworkGuid = {0x081603B4, 0x0F1D, 0x4022, {0xB6, 0xFD, 0x4C, 0xE3, 0x5E, 0x09, 0xA1, 0xA6}}
|
||||
|
||||
[PcdsFixedAtBuild]
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageVariableBase|0x0|UINT64|0x00001014
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwSpareBase|0x0|UINT64|0x00001015
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuFlashNvStorageFtwWorkingBase|0x0|UINT64|0x00001016
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuFdBaseAddress|0x0|UINT64|0x00001017
|
||||
|
@ -81,5 +81,5 @@
|
|||
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"|VOID*|0x00001007
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"|VOID*|0x00001008
|
||||
|
||||
gInOsEmuPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval|0x100|UINT64|0x0000101a
|
||||
|
||||
|
|
|
@ -19,4 +19,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
|
||||
extern EMU_THUNK_PROTOCOL *gEmuThunk;
|
||||
|
||||
|
||||
/**
|
||||
Serach the EMU IO Thunk database for a matching EMU IO Thunk
|
||||
Protocol instance.
|
||||
|
||||
@param Protocol Protocol to search for.
|
||||
@param Instance Instance of protocol to search for.
|
||||
|
||||
@retval NULL Protocol and Instance not found.
|
||||
@retval other EMU IO Thunk protocol that matched.
|
||||
|
||||
**/
|
||||
EMU_IO_THUNK_PROTOCOL *
|
||||
EFIAPI
|
||||
GetIoThunkInstance (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN UINTN Instance
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,9 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Library/DebugLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/EmuThunkLib.h>
|
||||
|
||||
#include <Protocol/EmuThunk.h>
|
||||
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
|
||||
EMU_THUNK_PROTOCOL *gEmuThunk = NULL;
|
||||
|
||||
|
@ -50,3 +48,41 @@ DxeEmuLibConstructor (
|
|||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Serach the EMU IO Thunk database for a matching EMU IO Thunk
|
||||
Protocol instance.
|
||||
|
||||
@param Protocol Protocol to search for.
|
||||
@param Instance Instance of protocol to search for.
|
||||
|
||||
@retval NULL Protocol and Instance not found.
|
||||
@retval other EMU IO Thunk protocol that matched.
|
||||
|
||||
**/
|
||||
EMU_IO_THUNK_PROTOCOL *
|
||||
EFIAPI
|
||||
GetIoThunkInstance (
|
||||
IN EFI_GUID *Protocol,
|
||||
IN UINTN Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
|
||||
|
||||
for (Status = EFI_SUCCESS, EmuIoThunk = NULL; !EFI_ERROR (Status); ) {
|
||||
Status = gEmuThunk->GetNextProtocol (FALSE, &EmuIoThunk);
|
||||
if (EFI_ERROR (Status)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (EmuIoThunk->Instance == Instance) {
|
||||
if (CompareGuid (EmuIoThunk->Protocol, Protocol)) {
|
||||
return EmuIoThunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
[LibraryClasses]
|
||||
HobLib
|
||||
DebugLib
|
||||
BaseMemoryLib
|
||||
|
||||
|
||||
[Protocols]
|
||||
|
|
Loading…
Reference in New Issue