21extern CONST UINT8 mPostSmmPen[];
22extern CONST UINT16 mPostSmmPenSize;
23extern CONST UINT8 mFirstSmiHandler[];
24extern CONST UINT16 mFirstSmiHandlerSize;
49 OUT UINT32 *PenAddress,
60 if (mPostSmmPenSize >= EFI_PAGE_SIZE) {
61 Status = EFI_BAD_BUFFER_SIZE;
64 "%a: mPostSmmPenSize=%u: %r\n",
72 Address = BASE_1MB - 1;
73 Status = BootServices->AllocatePages (
79 if (EFI_ERROR (Status)) {
80 DEBUG ((DEBUG_ERROR,
"%a: AllocatePages(): %r\n", __func__, Status));
84 DEBUG ((DEBUG_INFO,
"%a: Post-SMM Pen at 0x%Lx\n", __func__, Address));
85 *PenAddress = (UINT32)Address;
105 CopyMem ((VOID *)(
UINTN)PenAddress, mPostSmmPen, mPostSmmPenSize);
122 IN UINT32 PenAddress,
126 BootServices->FreePages (PenAddress, 1);
154 Context->ApicIdGate = MAX_UINT64;
205 volatile UINT8 *SmmVacated;
207 UINT64 ExchangeResult;
209 if (Smbase > MAX_UINT32) {
210 Status = EFI_INVALID_PARAMETER;
213 "%a: ApicId=" FMT_APIC_ID
" Smbase=0x%Lx: %r\n",
222 SmmVacated = (UINT8 *)(
UINTN)PenAddress + (EFI_PAGE_SIZE - 1);
230 Context->AboutToLeaveSmm = 0;
277 Context->NewSmbase = (UINT32)Smbase;
283 &Context->ApicIdGate,
287 if (ExchangeResult != MAX_UINT64) {
288 Status = EFI_PROTOCOL_ERROR;
291 "%a: ApicId=" FMT_APIC_ID
" ApicIdGate=0x%Lx: %r\n",
303 while (Context->AboutToLeaveSmm == 0) {
311 while (*SmmVacated == 0) {
VOID EFIAPI CpuPause(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI SendSmiIpi(IN UINT32 ApicId)
VOID EFIAPI SendInitSipiSipi(IN UINT32 ApicId, IN UINT32 StartupRoutine)
#define DEBUG(Expression)
#define SMM_HANDLER_OFFSET
#define SMM_DEFAULT_SMBASE
EFI_STATUS SmbaseAllocatePostSmmPen(OUT UINT32 *PenAddress, IN CONST EFI_BOOT_SERVICES *BootServices)
VOID SmbaseInstallFirstSmiHandler(VOID)
VOID SmbaseReinstallPostSmmPen(IN UINT32 PenAddress)
VOID SmbaseReleasePostSmmPen(IN UINT32 PenAddress, IN CONST EFI_BOOT_SERVICES *BootServices)
EFI_STATUS SmbaseRelocate(IN APIC_ID ApicId, IN UINTN Smbase, IN UINT32 PenAddress)
UINT64 EFIAPI InterlockedCompareExchange64(IN OUT volatile UINT64 *Value, IN UINT64 CompareValue, IN UINT64 ExchangeValue)
UINT64 EFI_PHYSICAL_ADDRESS