]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/CpuDxe: implement Mp Protocol:GetNumberOfProcessors()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
index dd2d0e1200ca7b4274eb6b868a5ec126634e5b0b..764db6a6f20f2edf0ef4d80349459112b32f13ff 100644 (file)
@@ -15,6 +15,9 @@
 #ifndef _CPU_MP_H_\r
 #define _CPU_MP_H_\r
 \r
+#include <Protocol/MpService.h>\r
+#include <Library/SynchronizationLib.h>\r
+\r
 /**\r
   Initialize Multi-processor support.\r
 \r
@@ -24,6 +27,30 @@ InitializeMpSupport (
   VOID\r
   );\r
 \r
+typedef\r
+VOID\r
+(EFIAPI *STACKLESS_AP_ENTRY_POINT)(\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Starts the Application Processors and directs them to jump to the\r
+  specified routine.\r
+\r
+  The processor jumps to this code in flat mode, but the processor's\r
+  stack is not initialized.\r
+\r
+  @param ApEntryPoint    Pointer to the Entry Point routine\r
+\r
+  @retval EFI_SUCCESS           The APs were started\r
+  @retval EFI_OUT_OF_RESOURCES  Cannot allocate memory to start APs\r
+\r
+**/\r
+EFI_STATUS\r
+StartApsStackless (\r
+  IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r
+  );\r
+\r
 /**\r
   The AP entry point that the Startup-IPI target code will jump to.\r
 \r
@@ -51,5 +78,126 @@ AsmApDoneWithCommonStack (
   VOID\r
   );\r
 \r
+typedef enum {\r
+  CpuStateIdle,\r
+  CpuStateBlocked,\r
+  CpuStateReady,\r
+  CpuStateBuzy,\r
+  CpuStateFinished\r
+} CPU_STATE;\r
+\r
+/**\r
+  Define Individual Processor Data block.\r
+\r
+**/\r
+typedef struct {\r
+  EFI_PROCESSOR_INFORMATION      Info;\r
+  SPIN_LOCK                      CpuDataLock;\r
+  volatile CPU_STATE             State;\r
+\r
+  EFI_AP_PROCEDURE               Procedure;\r
+  VOID                           *Parameter;\r
+} CPU_DATA_BLOCK;\r
+\r
+/**\r
+  Define MP data block which consumes individual processor block.\r
+\r
+**/\r
+typedef struct {\r
+  CPU_DATA_BLOCK              *CpuDatas;\r
+  UINTN                       NumberOfProcessors;\r
+  UINTN                       NumberOfEnabledProcessors;\r
+} MP_SYSTEM_DATA;\r
+\r
+/**\r
+  This function is called by all processors (both BSP and AP) once and collects MP related data.\r
+\r
+  @param Bsp             TRUE if the CPU is BSP\r
+  @param ProcessorNumber The specific processor number\r
+\r
+  @retval EFI_SUCCESS    Data for the processor collected and filled in\r
+\r
+**/\r
+EFI_STATUS\r
+FillInProcessorInformation (\r
+  IN     BOOLEAN              Bsp,\r
+  IN     UINTN                ProcessorNumber\r
+  );\r
+\r
+/**\r
+  This service retrieves the number of logical processor in the platform\r
+  and the number of those logical processors that are enabled on this boot.\r
+  This service may only be called from the BSP.\r
+\r
+  This function is used to retrieve the following information:\r
+    - The number of logical processors that are present in the system.\r
+    - The number of enabled logical processors in the system at the instant\r
+      this call is made.\r
+\r
+  Because MP Service Protocol provides services to enable and disable processors\r
+  dynamically, the number of enabled logical processors may vary during the\r
+  course of a boot session.\r
+\r
+  If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
+  If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
+  EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
+  is returned in NumberOfProcessors, the number of currently enabled processor\r
+  is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
+\r
+  @param[in]  This                        A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+                                          instance.\r
+  @param[out] NumberOfProcessors          Pointer to the total number of logical\r
+                                          processors in the system, including the BSP\r
+                                          and disabled APs.\r
+  @param[out] NumberOfEnabledProcessors   Pointer to the number of enabled logical\r
+                                          processors that exist in system, including\r
+                                          the BSP.\r
+\r
+  @retval EFI_SUCCESS             The number of logical processors and enabled\r
+                                  logical processors was retrieved.\r
+  @retval EFI_DEVICE_ERROR        The calling processor is an AP.\r
+  @retval EFI_INVALID_PARAMETER   NumberOfProcessors is NULL.\r
+  @retval EFI_INVALID_PARAMETER   NumberOfEnabledProcessors is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetNumberOfProcessors (\r
+  IN  EFI_MP_SERVICES_PROTOCOL  *This,\r
+  OUT UINTN                     *NumberOfProcessors,\r
+  OUT UINTN                     *NumberOfEnabledProcessors\r
+  );\r
+\r
+/**\r
+  This return the handle number for the calling processor.  This service may be\r
+  called from the BSP and APs.\r
+\r
+  This service returns the processor handle number for the calling processor.\r
+  The returned value is in the range from 0 to the total number of logical\r
+  processors minus 1. The total number of logical processors can be retrieved\r
+  with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r
+  called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
+  is returned. Otherwise, the current processors handle number is returned in\r
+  ProcessorNumber, and EFI_SUCCESS is returned.\r
+\r
+  @param[in]  This             A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
+  @param[out] ProcessorNumber  The handle number of AP that is to become the new\r
+                               BSP. The range is from 0 to the total number of\r
+                               logical processors minus 1. The total number of\r
+                               logical processors can be retrieved by\r
+                               EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
+\r
+  @retval EFI_SUCCESS             The current processor handle number was returned\r
+                                  in ProcessorNumber.\r
+  @retval EFI_INVALID_PARAMETER   ProcessorNumber is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+WhoAmI (\r
+  IN EFI_MP_SERVICES_PROTOCOL  *This,\r
+  OUT UINTN                    *ProcessorNumber\r
+  );\r
+\r
 #endif // _CPU_MP_H_\r
 \r