]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/CpuDxe: implement Mp Protocol:GetNumberOfProcessors()
[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
d894d8b7
CF
127/**\r
128 This service retrieves the number of logical processor in the platform\r
129 and the number of those logical processors that are enabled on this boot.\r
130 This service may only be called from the BSP.\r
131\r
132 This function is used to retrieve the following information:\r
133 - The number of logical processors that are present in the system.\r
134 - The number of enabled logical processors in the system at the instant\r
135 this call is made.\r
136\r
137 Because MP Service Protocol provides services to enable and disable processors\r
138 dynamically, the number of enabled logical processors may vary during the\r
139 course of a boot session.\r
140\r
141 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
142 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
143 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
144 is returned in NumberOfProcessors, the number of currently enabled processor\r
145 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
146\r
147 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
148 instance.\r
149 @param[out] NumberOfProcessors Pointer to the total number of logical\r
150 processors in the system, including the BSP\r
151 and disabled APs.\r
152 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
153 processors that exist in system, including\r
154 the BSP.\r
155\r
156 @retval EFI_SUCCESS The number of logical processors and enabled\r
157 logical processors was retrieved.\r
158 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
159 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r
160 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r
161\r
162**/\r
163EFI_STATUS\r
164EFIAPI\r
165GetNumberOfProcessors (\r
166 IN EFI_MP_SERVICES_PROTOCOL *This,\r
167 OUT UINTN *NumberOfProcessors,\r
168 OUT UINTN *NumberOfEnabledProcessors\r
169 );\r
170\r
cfa2fac1
CF
171/**\r
172 This return the handle number for the calling processor. This service may be\r
173 called from the BSP and APs.\r
174\r
175 This service returns the processor handle number for the calling processor.\r
176 The returned value is in the range from 0 to the total number of logical\r
177 processors minus 1. The total number of logical processors can be retrieved\r
178 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r
179 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
180 is returned. Otherwise, the current processors handle number is returned in\r
181 ProcessorNumber, and EFI_SUCCESS is returned.\r
182\r
183 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
184 @param[out] ProcessorNumber The handle number of AP that is to become the new\r
185 BSP. The range is from 0 to the total number of\r
186 logical processors minus 1. The total number of\r
187 logical processors can be retrieved by\r
188 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
189\r
190 @retval EFI_SUCCESS The current processor handle number was returned\r
191 in ProcessorNumber.\r
192 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
193\r
194**/\r
195EFI_STATUS\r
196EFIAPI\r
197WhoAmI (\r
198 IN EFI_MP_SERVICES_PROTOCOL *This,\r
199 OUT UINTN *ProcessorNumber\r
200 );\r
201\r
6022e28c
JJ
202#endif // _CPU_MP_H_\r
203\r