]>
Commit | Line | Data |
---|---|---|
3e8ad6bd JF |
1 | /** @file\r |
2 | Common header file for MP Initialize Library.\r | |
3 | \r | |
4 | Copyright (c) 2016, 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 _MP_LIB_H_\r | |
16 | #define _MP_LIB_H_\r | |
17 | \r | |
18 | #include <PiPei.h>\r | |
19 | \r | |
20 | #include <Register/Cpuid.h>\r | |
21 | #include <Register/Msr.h>\r | |
22 | #include <Register/LocalApic.h>\r | |
23 | #include <Register/Microcode.h>\r | |
24 | \r | |
25 | #include <Library/MpInitLib.h>\r | |
26 | #include <Library/BaseLib.h>\r | |
27 | #include <Library/BaseMemoryLib.h>\r | |
28 | #include <Library/MemoryAllocationLib.h>\r | |
29 | #include <Library/DebugLib.h>\r | |
30 | #include <Library/LocalApicLib.h>\r | |
31 | #include <Library/CpuLib.h>\r | |
32 | #include <Library/UefiCpuLib.h>\r | |
33 | #include <Library/TimerLib.h>\r | |
34 | #include <Library/SynchronizationLib.h>\r | |
35 | #include <Library/MtrrLib.h>\r | |
36 | #include <Library/HobLib.h>\r | |
37 | \r | |
9ebcf0f4 JF |
38 | //\r |
39 | // AP loop state when APs are in idle state\r | |
40 | // It's value is the same with PcdCpuApLoopMode\r | |
41 | //\r | |
42 | typedef enum {\r | |
43 | ApInHltLoop = 1,\r | |
44 | ApInMwaitLoop = 2,\r | |
45 | ApInRunLoop = 3\r | |
46 | } AP_LOOP_MODE;\r | |
47 | \r | |
e59f8f6b JF |
48 | //\r |
49 | // AP initialization state during APs wakeup\r | |
50 | //\r | |
51 | typedef enum {\r | |
52 | ApInitConfig = 1,\r | |
53 | ApInitReconfig = 2,\r | |
54 | ApInitDone = 3\r | |
55 | } AP_INIT_STATE;\r | |
56 | \r | |
57 | //\r | |
58 | // AP related data\r | |
59 | //\r | |
60 | typedef struct {\r | |
61 | SPIN_LOCK ApLock;\r | |
62 | volatile UINT32 *StartupApSignal;\r | |
63 | volatile UINTN ApFunction;\r | |
64 | volatile UINTN ApFunctionArgument;\r | |
65 | UINT32 InitialApicId;\r | |
66 | UINT32 ApicId;\r | |
67 | UINT32 Health;\r | |
68 | BOOLEAN CpuHealthy;\r | |
69 | BOOLEAN Waiting;\r | |
70 | BOOLEAN *Finished;\r | |
71 | UINT64 ExpectedTime;\r | |
72 | UINT64 CurrentTime;\r | |
73 | UINT64 TotalTime;\r | |
74 | EFI_EVENT WaitEvent;\r | |
75 | } CPU_AP_DATA;\r | |
76 | \r | |
77 | //\r | |
78 | // Basic CPU information saved in Guided HOB.\r | |
79 | // Because the contents will be shard between PEI and DXE,\r | |
80 | // we need to make sure the each fields offset same in different\r | |
81 | // architecture.\r | |
82 | //\r | |
83 | typedef struct {\r | |
84 | UINT32 InitialApicId;\r | |
85 | UINT32 ApicId;\r | |
86 | UINT32 Health;\r | |
87 | } CPU_INFO_IN_HOB;\r | |
88 | \r | |
f7f85d83 JF |
89 | //\r |
90 | // AP reset code information including code address and size,\r | |
91 | // this structure will be shared be C code and assembly code.\r | |
92 | // It is natural aligned by design.\r | |
93 | //\r | |
94 | typedef struct {\r | |
95 | UINT8 *RendezvousFunnelAddress;\r | |
96 | UINTN ModeEntryOffset;\r | |
97 | UINTN RendezvousFunnelSize;\r | |
98 | UINT8 *RelocateApLoopFuncAddress;\r | |
99 | UINTN RelocateApLoopFuncSize;\r | |
100 | } MP_ASSEMBLY_ADDRESS_MAP;\r | |
3e8ad6bd | 101 | \r |
e59f8f6b JF |
102 | typedef struct _CPU_MP_DATA CPU_MP_DATA;\r |
103 | \r | |
d94e5f67 JF |
104 | #pragma pack(1)\r |
105 | \r | |
106 | //\r | |
107 | // MP CPU exchange information for AP reset code\r | |
108 | // This structure is required to be packed because fixed field offsets\r | |
109 | // into this structure are used in assembly code in this module\r | |
110 | //\r | |
111 | typedef struct {\r | |
112 | UINTN Lock;\r | |
113 | UINTN StackStart;\r | |
114 | UINTN StackSize;\r | |
115 | UINTN CFunction;\r | |
116 | IA32_DESCRIPTOR GdtrProfile;\r | |
117 | IA32_DESCRIPTOR IdtrProfile;\r | |
118 | UINTN BufferStart;\r | |
119 | UINTN ModeOffset;\r | |
120 | UINTN NumApsExecuting;\r | |
121 | UINTN CodeSegment;\r | |
122 | UINTN DataSegment;\r | |
5c66d125 | 123 | UINTN EnableExecuteDisable;\r |
d94e5f67 | 124 | UINTN Cr3;\r |
e59f8f6b | 125 | CPU_MP_DATA *CpuMpData;\r |
d94e5f67 JF |
126 | } MP_CPU_EXCHANGE_INFO;\r |
127 | \r | |
128 | #pragma pack()\r | |
e59f8f6b JF |
129 | \r |
130 | //\r | |
131 | // CPU MP Data save in memory\r | |
132 | //\r | |
133 | struct _CPU_MP_DATA {\r | |
134 | UINT64 CpuInfoInHob;\r | |
135 | UINT32 CpuCount;\r | |
136 | UINT32 BspNumber;\r | |
137 | //\r | |
138 | // The above fields data will be passed from PEI to DXE\r | |
139 | // Please make sure the fields offset same in the different\r | |
140 | // architecture.\r | |
141 | //\r | |
142 | SPIN_LOCK MpLock;\r | |
143 | UINTN Buffer;\r | |
144 | UINTN CpuApStackSize;\r | |
145 | MP_ASSEMBLY_ADDRESS_MAP AddressMap;\r | |
146 | UINTN WakeupBuffer;\r | |
147 | UINTN BackupBuffer;\r | |
148 | UINTN BackupBufferSize;\r | |
149 | BOOLEAN EndOfPeiFlag;\r | |
150 | \r | |
151 | volatile UINT32 StartCount;\r | |
152 | volatile UINT32 FinishedCount;\r | |
153 | volatile UINT32 RunningCount;\r | |
154 | BOOLEAN SingleThread;\r | |
155 | EFI_AP_PROCEDURE Procedure;\r | |
156 | VOID *ProcArguments;\r | |
157 | BOOLEAN *Finished;\r | |
158 | UINT64 ExpectedTime;\r | |
159 | UINT64 CurrentTime;\r | |
160 | UINT64 TotalTime;\r | |
161 | EFI_EVENT WaitEvent;\r | |
162 | UINTN **FailedCpuList;\r | |
163 | \r | |
164 | AP_INIT_STATE InitFlag;\r | |
165 | BOOLEAN X2ApicEnable;\r | |
166 | MTRR_SETTINGS MtrrTable;\r | |
167 | UINT8 ApLoopMode;\r | |
168 | UINT8 ApTargetCState;\r | |
169 | UINT16 PmCodeSegment;\r | |
170 | CPU_AP_DATA *CpuData;\r | |
171 | volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;\r | |
172 | };\r | |
76157021 JF |
173 | /**\r |
174 | Assembly code to place AP into safe loop mode.\r | |
175 | \r | |
176 | Place AP into targeted C-State if MONITOR is supported, otherwise\r | |
177 | place AP into hlt state.\r | |
178 | Place AP in protected mode if the current is long mode. Due to AP maybe\r | |
179 | wakeup by some hardware event. It could avoid accessing page table that\r | |
180 | may not available during booting to OS.\r | |
181 | \r | |
182 | @param[in] MwaitSupport TRUE indicates MONITOR is supported.\r | |
183 | FALSE indicates MONITOR is not supported.\r | |
184 | @param[in] ApTargetCState Target C-State value.\r | |
185 | @param[in] PmCodeSegment Protected mode code segment value.\r | |
186 | **/\r | |
187 | typedef\r | |
188 | VOID\r | |
189 | (EFIAPI * ASM_RELOCATE_AP_LOOP) (\r | |
190 | IN BOOLEAN MwaitSupport,\r | |
191 | IN UINTN ApTargetCState,\r | |
192 | IN UINTN PmCodeSegment\r | |
193 | );\r | |
f7f85d83 JF |
194 | \r |
195 | /**\r | |
196 | Assembly code to get starting address and size of the rendezvous entry for APs.\r | |
197 | Information for fixing a jump instruction in the code is also returned.\r | |
198 | \r | |
199 | @param[out] AddressMap Output buffer for address map information.\r | |
200 | **/\r | |
201 | VOID\r | |
202 | EFIAPI\r | |
203 | AsmGetAddressMap (\r | |
204 | OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap\r | |
205 | );\r | |
206 | \r | |
3e8ad6bd JF |
207 | #endif\r |
208 | \r |