TianoCore EDK2 master
Loading...
Searching...
No Matches
PiSmmCpuStandaloneMm.c
Go to the documentation of this file.
1
10#include "PiSmmCpuCommon.h"
11
12//
13// TRUE to indicate it's the MM_STANDALONE MM CPU driver.
14// FALSE to indicate it's the DXE_SMM_DRIVER SMM CPU driver.
15//
16const BOOLEAN mIsStandaloneMm = TRUE;
17
18//
19// RemainingTasks Done flag
20//
21BOOLEAN mRemainingTasksDone = FALSE;
22
30BOOLEAN
32 VOID
33 )
34{
35 UINT64 SmmProfileSize;
36
37 GetSmmProfileData (&SmmProfileSize);
38 if (SmmProfileSize == 0) {
39 return FALSE;
40 }
41
42 return TRUE;
43}
44
49VOID
51 VOID
52 )
53{
54 EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable;
55
56 if (!mRemainingTasksDone) {
58
59 //
60 // gEdkiiPiSmmMemoryAttributesTableGuid should have been published after SmmCore dispatched all MM drivers (MmDriverDispatchHandler).
61 // Note: gEdkiiPiSmmMemoryAttributesTableGuid is not always installed since it depends on
62 // the memory protection attribute setting in MM Core.
63 //
64 SmmGetSystemConfigurationTable (&gEdkiiPiSmmMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable);
65
66 //
67 // Set critical region attribute in page table according to the MemoryAttributesTable
68 //
69 if (MemoryAttributesTable != NULL) {
70 SetMemMapAttributes (MemoryAttributesTable);
71 }
72
73 //
74 // Set page table itself to be read-only
75 //
77
78 //
79 // Measure performance of SmmCpuFeaturesCompleteSmmReadyToLock() from caller side
80 // as the implementation is provided by platform.
81 //
82 PERF_START (NULL, "SmmCompleteReadyToLock", NULL, 0);
84 PERF_END (NULL, "SmmCompleteReadyToLock", NULL, 0);
85
86 //
87 // Mark RemainingTasks Done flag to TRUE
88 //
89 mRemainingTasksDone = TRUE;
90
92 }
93}
94
99VOID
101 VOID
102 )
103{
104 mSmiCommandPort = 0xB2;
105 DEBUG ((DEBUG_INFO, "mSmiCommandPort = %x\n", mSmiCommandPort));
106}
107
117VOID
119 IN OUT BOOLEAN *RelaxedMode, OPTIONAL
120 IN OUT UINT64 *SyncTimeout, OPTIONAL
121 IN OUT UINT64 *SyncTimeout2 OPTIONAL
122 )
123{
124 EFI_HOB_GUID_TYPE *GuidHob;
125 MM_CPU_SYNC_CONFIG *MmCpuSyncConfigHob;
126
127 MmCpuSyncConfigHob = NULL;
128
129 //
130 // Get MM_CPU_SYNC_CONFIG for Standalone MM init.
131 //
132 GuidHob = GetFirstGuidHob (&gMmCpuSyncConfigHobGuid);
133 ASSERT (GuidHob != NULL);
134 if (GuidHob != NULL) {
135 MmCpuSyncConfigHob = GET_GUID_HOB_DATA (GuidHob);
136 }
137
138 if (MmCpuSyncConfigHob != NULL) {
139 if (RelaxedMode != NULL) {
140 *RelaxedMode = ((MmCpuSyncConfigHob->RelaxedApMode == MmCpuSyncModeRelaxedAp) ? TRUE : FALSE);
141 }
142
143 if (SyncTimeout != NULL) {
144 *SyncTimeout = MmCpuSyncConfigHob->Timeout;
145 }
146
147 if (SyncTimeout2 != NULL) {
148 *SyncTimeout2 = MmCpuSyncConfigHob->Timeout2;
149 }
150 }
151}
152
157VOID
159 VOID
160 )
161{
162 EFI_HOB_GUID_TYPE *GuidHob;
163 MM_ACPI_S3_ENABLE *MmAcpiS3EnableHob;
164
165 MmAcpiS3EnableHob = NULL;
166
167 //
168 // Get MM_ACPI_S3_ENABLE for Standalone MM init.
169 //
170 GuidHob = GetFirstGuidHob (&gMmAcpiS3EnableHobGuid);
171 ASSERT (GuidHob != NULL);
172 if (GuidHob != NULL) {
173 MmAcpiS3EnableHob = GET_GUID_HOB_DATA (GuidHob);
174 }
175
176 if (MmAcpiS3EnableHob != NULL) {
177 mAcpiS3Enable = MmAcpiS3EnableHob->AcpiS3Enable;
178 }
179}
180
187UINTN
189 VOID
190 )
191{
192 ASSERT (FALSE);
193
194 return 0;
195}
196
207 OUT UINTN *NumberOfCpus,
208 OUT UINTN *MaxNumberOfCpus
209 )
210{
211 ASSERT (FALSE);
212
213 return NULL;
214}
215
227EFIAPI
229 IN EFI_HANDLE ImageHandle,
230 IN EFI_MM_SYSTEM_TABLE *SystemTable
231 )
232{
233 EFI_STATUS Status;
234
235 Status = PiSmmCpuEntryCommon ();
236
237 ASSERT_EFI_ERROR (Status);
238
239 if (mSmmProfileEnabled) {
240 //
241 // Get Software SMI
242 //
244
245 //
246 // Initialize protected memory range for patching page table later.
247 //
249
250 //
251 // Start SMM Profile feature
252 //
254 }
255
256 //
257 // Install the SMM Configuration Protocol onto a new handle on the handle database.
258 // The entire SMM Configuration Protocol is allocated from SMRAM, so only a pointer
259 // to an SMRAM address will be present in the handle database
260 //
261 Status = gMmst->MmInstallProtocolInterface (
262 &gSmmCpuPrivate->SmmCpuHandle,
263 &gEfiSmmConfigurationProtocolGuid,
265 &gSmmCpuPrivate->SmmConfiguration
266 );
267 ASSERT_EFI_ERROR (Status);
268
269 return Status;
270}
UINT64 UINTN
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
EFI_PHYSICAL_ADDRESS GetSmmProfileData(IN OUT UINT64 *Size)
VOID EFIAPI SmmCpuFeaturesCompleteSmmReadyToLock(VOID)
#define PERF_FUNCTION_END()
#define PERF_END(Handle, Token, Module, TimeStamp)
#define PERF_FUNCTION_BEGIN()
#define PERF_START(Handle, Token, Module, TimeStamp)
EFI_STATUS PiSmmCpuEntryCommon(VOID)
EFI_STATUS EFIAPI SmmGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
VOID SetMemMapAttributes(EDKII_PI_SMM_MEMORY_ATTRIBUTES_TABLE *MemoryAttributesTable)
VOID SetPageTableAttributes(VOID)
EFI_STATUS EFIAPI PiCpuStandaloneMmEntry(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *SystemTable)
VOID GetAcpiS3EnableFlag(VOID)
VOID PerformRemainingTasks(VOID)
EFI_PROCESSOR_INFORMATION * GetMpInformationFromMpServices(OUT UINTN *NumberOfCpus, OUT UINTN *MaxNumberOfCpus)
VOID GetSmmCpuSyncConfigData(IN OUT BOOLEAN *RelaxedMode, OPTIONAL IN OUT UINT64 *SyncTimeout, OPTIONAL IN OUT UINT64 *SyncTimeout2 OPTIONAL)
BOOLEAN IsSmmProfileEnabled(VOID)
VOID GetSmiCommandPort(VOID)
UINTN GetSupportedMaxLogicalProcessorNumber(VOID)
VOID SmmProfileStart(VOID)
Definition: SmmProfile.c:682
VOID InitProtectedMemRange(VOID)
Definition: SmmProfile.c:420
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_INSTALL_PROTOCOL_INTERFACE MmInstallProtocolInterface
Definition: PiMmCis.h:327
MM_CPU_SYNC_MODE RelaxedApMode