From 4eb813ba7247d9e2bebf255ecc50f68c0a71bb72 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 20 Aug 2024 02:53:51 +0200 Subject: + IMP: Using Hybrid MP services on ZKA_EFI firmware. + Implement HPET on HardwareTimer and added a SoftwareTimer. + Implemented Hybrid MP Services on EFI.hxx. Signed-off-by: Amlal El Mahrouss --- dev/ZKA/FirmwareKit/EFI/EFI.hxx | 103 ++++++++++++++++++++++++++++++++++++++- dev/ZKA/FirmwareKit/Handover.hxx | 6 ++- 2 files changed, 106 insertions(+), 3 deletions(-) (limited to 'dev/ZKA/FirmwareKit') diff --git a/dev/ZKA/FirmwareKit/EFI/EFI.hxx b/dev/ZKA/FirmwareKit/EFI/EFI.hxx index 2237ce36..13ddec1c 100644 --- a/dev/ZKA/FirmwareKit/EFI/EFI.hxx +++ b/dev/ZKA/FirmwareKit/EFI/EFI.hxx @@ -24,6 +24,10 @@ using namespace Kernel; #define EFI_API __attribute__((ms_abi)) #endif // ifndef EPI_API +#define IN +#define OUT +#define OPTIONAL + // Forward decls struct EfiTableHeader; @@ -46,7 +50,7 @@ typedef UInt64 EfiStatusType; /// This is like NT's Win32 HANDLE type. typedef struct EfiHandle { -}* EfiHandlePtr; +} * EfiHandlePtr; /* UEFI uses wide characters by default. */ typedef WideChar EfiCharType; @@ -589,7 +593,7 @@ typedef struct EfiSystemTable { EfiGUID VendorGUID; VoidPtr VendorTable; - }* ConfigurationTable; + } * ConfigurationTable; } EfiSystemTable; #define kEfiOk 0 @@ -781,4 +785,99 @@ struct EfiFileInfo final #define EFI_EXTRA_DESCRIPTOR_SIZE 8 +#define EFI_MP_SERVICES_PROTOCOL_GUID \ + { \ + 0x3fdda605, 0xa76e, 0x4f46, \ + { \ + 0xad, 0x29, 0x12, 0xf4, \ + 0x53, 0x1b, 0x3d, 0x08 \ + } \ + } + +//******************************************************* +// EFI_CPU_PHYSICAL_LOCATION +// @note As in the EFI specs. +//******************************************************* +typedef struct _EfiCPUPhyiscalLocation +{ + UInt32 Package; + UInt32 Core; + UInt32 Thread; +} EfiCPUPhyiscalLocation; + +typedef union _EfiExtendedProcessorInformation { + EfiCPUPhyiscalLocation Location2; +} EfiExtendedProcessorInformation; + +typedef struct _EfiProcessorInformation +{ + UInt64 ProcessorId; + UInt32 StatusFlag; + EfiCPUPhyiscalLocation Location; + EfiExtendedProcessorInformation ExtendedInformation; +} EfiProcessorInformation; + +#define PROCESSOR_AS_BSP_BIT 0x00000001 +#define PROCESSOR_ENABLED_BIT 0x00000002 +#define PROCESSOR_HEALTH_STATUS_BIT 0x00000004 + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)( + IN struct _EfiMpServicesProtocol* Self, + OUT UInt32* NumberOfProcessors, + OUT UInt32* NumberOfEnabledProcessors); + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_GET_PROCESSOR_INFO)( + IN struct _EfiMpServicesProtocol* Self, + IN UInt32* ProcessorNumber, + OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors); + +#define END_OF_CPU_LIST 0xffffffff + +typedef void EFI_API (*EFI_AP_PROCEDURE)( + IN VoidPtr ProcedureArgument); + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_ALL_APS)( + IN struct _EfiMpServicesProtocol* This, + IN EFI_AP_PROCEDURE Procedure, + IN Boolean SingleThread, + IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here. + IN UInt32 TimeoutInMicroSeconds, + IN Void* ProcedureArgument OPTIONAL, + OUT UInt32** FailedCpuList OPTIONAL); + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_SWITCH_BSP)( + IN struct _EfiMpServicesProtocol* This, + IN UInt32 ProcessorNumber, + IN Boolean EnableOldBSP); + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_STARTUP_THIS_AP)( + IN struct _EfiMpServicesProtocol* This, + IN EFI_AP_PROCEDURE Procedure, + IN UInt32 ProcessorNumber, + IN VoidPtr WaitEvent OPTIONAL, + IN UInt32 TimeoutInMicroseconds, + IN Void* ProcedureArgument OPTIONAL, + OUT Boolean* Finished OPTIONAL); + +typedef EfiStatusType EFI_API (*EFI_MP_SERVICES_ENABLEDISABLEAP)( + IN struct _EfiMpServicesProtocol* This, + IN UInt32 ProcessorNumber, + IN Boolean EnableAP, + IN UInt32* HealthFlag OPTIONAL); + +typedef EfiStatusType EFI_API(* EFI_MP_SERVICES_WHOAMI)( + IN struct _EfiMpServicesProtocol* This, + OUT UInt32* ProcessorNumber); + +typedef struct _EfiMpServicesProtocol +{ + EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors; + EFI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo; + EFI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs; + EFI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP; + EFI_MP_SERVICES_SWITCH_BSP SwitchBSP; + EFI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP; + EFI_MP_SERVICES_WHOAMI WhoAmI; +} EfiMpServicesProtocol; + #endif // ifndef __EFI__ diff --git a/dev/ZKA/FirmwareKit/Handover.hxx b/dev/ZKA/FirmwareKit/Handover.hxx index 96daa1dc..fba6017d 100644 --- a/dev/ZKA/FirmwareKit/Handover.hxx +++ b/dev/ZKA/FirmwareKit/Handover.hxx @@ -22,10 +22,13 @@ /* useful macros */ #define kHandoverMagic 0xBADCC -#define kHandoverVersion 0x113 +#define kHandoverVersion 0x114 #define kHandoverMaxCmdLine 8 +#define kHandoverBetterEFI "ZKA_EFI" +#define kHandoverBetterEFI_U L"ZKA_EFI" + #define kHandoverHeapSz gib_cast(2) #define kHandoverStructSz sizeof(HEL::HandoverHeader) @@ -71,6 +74,7 @@ namespace Kernel::HEL { VoidPtr f_SmBios; VoidPtr f_VendorPtr; + VoidPtr f_MPPtr; } f_HardwareTables; struct -- cgit v1.2.3