]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/CpuDxe: implement Mp Protocol: WhoAmI()
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
CommitLineData
6022e28c
JJ
1/** @file\r
2 CPU DXE MP support\r
3\r
4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _CPU_MP_H_\r
16#define _CPU_MP_H_\r
17\r
003973d9 18#include <Protocol/MpService.h>\r
03673ae1 19#include <Library/SynchronizationLib.h>\r
003973d9 20\r
6022e28c
JJ
21/**\r
22 Initialize Multi-processor support.\r
23\r
24**/\r
25VOID\r
26InitializeMpSupport (\r
27 VOID\r
28 );\r
29\r
533263ee
JJ
30typedef\r
31VOID\r
32(EFIAPI *STACKLESS_AP_ENTRY_POINT)(\r
33 VOID\r
34 );\r
35\r
36/**\r
37 Starts the Application Processors and directs them to jump to the\r
38 specified routine.\r
39\r
40 The processor jumps to this code in flat mode, but the processor's\r
41 stack is not initialized.\r
42\r
43 @param ApEntryPoint Pointer to the Entry Point routine\r
44\r
45 @retval EFI_SUCCESS The APs were started\r
46 @retval EFI_OUT_OF_RESOURCES Cannot allocate memory to start APs\r
47\r
48**/\r
49EFI_STATUS\r
50StartApsStackless (\r
51 IN STACKLESS_AP_ENTRY_POINT ApEntryPoint\r
52 );\r
53\r
fab82c18
JJ
54/**\r
55 The AP entry point that the Startup-IPI target code will jump to.\r
56\r
57 The processor jumps to this code in flat mode, but the processor's\r
58 stack is not initialized.\r
59\r
60**/\r
61VOID\r
62EFIAPI\r
63AsmApEntryPoint (\r
64 VOID\r
65 );\r
66\r
67/**\r
68 Releases the lock preventing other APs from using the shared AP\r
69 stack.\r
70\r
71 Once the AP has transitioned to using a new stack, it can call this\r
72 function to allow another AP to proceed with using the shared stack.\r
73\r
74**/\r
75VOID\r
76EFIAPI\r
77AsmApDoneWithCommonStack (\r
78 VOID\r
79 );\r
80\r
03673ae1
CF
81typedef enum {\r
82 CpuStateIdle,\r
83 CpuStateBlocked,\r
84 CpuStateReady,\r
85 CpuStateBuzy,\r
86 CpuStateFinished\r
87} CPU_STATE;\r
88\r
89/**\r
90 Define Individual Processor Data block.\r
91\r
92**/\r
93typedef struct {\r
94 EFI_PROCESSOR_INFORMATION Info;\r
95 SPIN_LOCK CpuDataLock;\r
96 volatile CPU_STATE State;\r
97\r
98 EFI_AP_PROCEDURE Procedure;\r
99 VOID *Parameter;\r
100} CPU_DATA_BLOCK;\r
101\r
102/**\r
103 Define MP data block which consumes individual processor block.\r
104\r
105**/\r
106typedef struct {\r
107 CPU_DATA_BLOCK *CpuDatas;\r
108 UINTN NumberOfProcessors;\r
109 UINTN NumberOfEnabledProcessors;\r
110} MP_SYSTEM_DATA;\r
111\r
112/**\r
113 This function is called by all processors (both BSP and AP) once and collects MP related data.\r
114\r
115 @param Bsp TRUE if the CPU is BSP\r
116 @param ProcessorNumber The specific processor number\r
117\r
118 @retval EFI_SUCCESS Data for the processor collected and filled in\r
119\r
120**/\r
121EFI_STATUS\r
122FillInProcessorInformation (\r
123 IN BOOLEAN Bsp,\r
124 IN UINTN ProcessorNumber\r
125 );\r
126\r
cfa2fac1
CF
127/**\r
128 This return the handle number for the calling processor. This service may be\r
129 called from the BSP and APs.\r
130\r
131 This service returns the processor handle number for the calling processor.\r
132 The returned value is in the range from 0 to the total number of logical\r
133 processors minus 1. The total number of logical processors can be retrieved\r
134 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r
135 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
136 is returned. Otherwise, the current processors handle number is returned in\r
137 ProcessorNumber, and EFI_SUCCESS is returned.\r
138\r
139 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
140 @param[out] ProcessorNumber The handle number of AP that is to become the new\r
141 BSP. The range is from 0 to the total number of\r
142 logical processors minus 1. The total number of\r
143 logical processors can be retrieved by\r
144 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
145\r
146 @retval EFI_SUCCESS The current processor handle number was returned\r
147 in ProcessorNumber.\r
148 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153WhoAmI (\r
154 IN EFI_MP_SERVICES_PROTOCOL *This,\r
155 OUT UINTN *ProcessorNumber\r
156 );\r
157\r
6022e28c
JJ
158#endif // _CPU_MP_H_\r
159\r