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