X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=UefiCpuPkg%2FPiSmmCpuDxeSmm%2FPiSmmCpuDxeSmm.h;h=df5980cd420f3520e795fc699327f055fa8a9126;hb=ed3d5ecb342dd6cca299ac72b30d4855a8b804a4;hp=106e67465c0a4c7112fecc8a962c7a538fafaaa8;hpb=fe5f19494353421d3382f32f31a627e09724bbb2;p=mirror_edk2.git diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 106e67465c..df5980cd42 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1,7 +1,7 @@ /** @file Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU. -Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -53,6 +53,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include "CpuService.h" #include "SmmProfile.h" @@ -71,15 +72,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// #define IA32_PG_P BIT0 #define IA32_PG_RW BIT1 +#define IA32_PG_U BIT2 #define IA32_PG_WT BIT3 #define IA32_PG_CD BIT4 #define IA32_PG_A BIT5 +#define IA32_PG_D BIT6 #define IA32_PG_PS BIT7 #define IA32_PG_PAT_2M BIT12 #define IA32_PG_PAT_4K IA32_PG_PS #define IA32_PG_PMNT BIT62 #define IA32_PG_NX BIT63 +#define PAGE_ATTRIBUTE_BITS (IA32_PG_RW | IA32_PG_P) +// +// Bits 1, 2, 5, 6 are reserved in the IA32 PAE PDPTE +// X64 PAE PDPTE does not have such restriction +// +#define IA32_PAE_PDPTE_ATTRIBUTE_BITS (IA32_PG_P) + // // Size of Task-State Segment defined in IA32 Manual // @@ -285,11 +295,11 @@ SmmRelocationSemaphoreComplete ( /// The type of SMM CPU Information /// typedef struct { - SPIN_LOCK Busy; + SPIN_LOCK *Busy; volatile EFI_AP_PROCEDURE Procedure; volatile VOID *Parameter; - volatile UINT32 Run; - volatile BOOLEAN Present; + volatile UINT32 *Run; + volatile BOOLEAN *Present; } SMM_CPU_DATA_BLOCK; typedef enum { @@ -304,10 +314,10 @@ typedef struct { // so that UC cache-ability can be set together. // SMM_CPU_DATA_BLOCK *CpuData; - volatile UINT32 Counter; + volatile UINT32 *Counter; volatile UINT32 BspIndex; - volatile BOOLEAN InsideSmm; - volatile BOOLEAN AllCpusInSync; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; volatile SMM_CPU_SYNC_MODE EffectiveSyncMode; volatile BOOLEAN SwitchBsp; volatile BOOLEAN *CandidateBsp; @@ -344,6 +354,36 @@ typedef struct { UINT64 MtrrBaseMaskPtr; // Offset 0x58 } PROCESSOR_SMM_DESCRIPTOR; + +/// +/// All global semaphores' pointer +/// +typedef struct { + volatile UINT32 *Counter; + volatile BOOLEAN *InsideSmm; + volatile BOOLEAN *AllCpusInSync; + SPIN_LOCK *PFLock; + SPIN_LOCK *CodeAccessCheckLock; +} SMM_CPU_SEMAPHORE_GLOBAL; + +/// +/// All semaphores for each processor +/// +typedef struct { + SPIN_LOCK *Busy; + volatile UINT32 *Run; + volatile BOOLEAN *Present; +} SMM_CPU_SEMAPHORE_CPU; + + +/// +/// All semaphores' information +/// +typedef struct { + SMM_CPU_SEMAPHORE_GLOBAL SemaphoreGlobal; + SMM_CPU_SEMAPHORE_CPU SemaphoreCpu; +} SMM_CPU_SEMAPHORES; + extern IA32_DESCRIPTOR gcSmiGdtr; extern IA32_DESCRIPTOR gcSmiIdtr; extern VOID *gcSmiIdtrPtr; @@ -359,17 +399,21 @@ extern UINTN mSmmStackArrayEnd; extern UINTN mSmmStackSize; extern EFI_SMM_CPU_SERVICE_PROTOCOL mSmmCpuService; extern IA32_DESCRIPTOR gcSmiInitGdtr; +extern SPIN_LOCK *mPFLock; +extern SPIN_LOCK *mConfigSmmCodeAccessCheckLock; /** Create 4G PageTable in SMRAM. @param ExtraPages Additional page numbers besides for 4G memory + @param Is32BitPageTable Whether the page table is 32-bit PAE @return PageTable Address **/ UINT32 Gen4GPageTable ( - IN UINTN ExtraPages + IN UINTN ExtraPages, + IN BOOLEAN Is32BitPageTable ); @@ -586,6 +630,15 @@ PerformRemainingTasks ( VOID ); +/** + Perform the pre tasks. + +**/ +VOID +PerformPreTasks ( + VOID + ); + /** Initialize MSR spin lock by MSR index. @@ -709,4 +762,25 @@ VOID DumpModuleInfoByIp ( IN UINTN CallerIpAddress ); + +/** + This API provides a way to allocate memory for page table. + + This API can be called more once to allocate memory for page tables. + + Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL + is returned. If there is not enough memory remaining to satisfy the request, then NULL is + returned. + + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +AllocatePageTableMemory ( + IN UINTN Pages + ); + #endif