]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: implement Mp Protocol: WhoAmI()
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Thu, 13 Nov 2014 18:26:32 +0000 (18:26 +0000)
committerjljusten <jljusten@Edk2>
Thu, 13 Nov 2014 18:26:32 +0000 (18:26 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16354 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/CpuDxe/CpuMp.h

index de599dad6a51423a00c9566b6c9c66237d65ce98..88bf95269dddefc580f3918785f0c51138015fdb 100644 (file)
@@ -31,9 +31,58 @@ EFI_MP_SERVICES_PROTOCOL  mMpServicesTemplate = {
   NULL, // StartupThisAP,\r
   NULL, // SwitchBSP,\r
   NULL, // EnableDisableAP,\r
-  NULL  // WhoAmI\r
+  WhoAmI\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
+  UINTN   Index;\r
+  UINT32  ProcessorId;\r
+\r
+  if (ProcessorNumber == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  ProcessorId = GetApicId ();\r
+  for (Index = 0; Index < mMpSystemData.NumberOfProcessors; Index++) {\r
+    if (mMpSystemData.CpuDatas[Index].Info.ProcessorId == ProcessorId) {\r
+      break;\r
+    }\r
+  }\r
+\r
+  *ProcessorNumber = Index;\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   Application Processors do loop routine\r
   after switch to its own stack.\r
index 481f7b16183527af8d181e9ceec984fb1a8638ac..66bf04782708b4d8210def731199c7a8bce5ae1a 100644 (file)
@@ -124,5 +124,36 @@ FillInProcessorInformation (
   IN     UINTN                ProcessorNumber\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