]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h
UefiCpuPkg: Add PiSmmCpuDxeSmm module X64 files
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / X64 / SmmProfileArch.h
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmProfileArch.h
new file mode 100644 (file)
index 0000000..32f3313
--- /dev/null
@@ -0,0 +1,105 @@
+/** @file\r
+X64 processor specific header file to enable SMM profile.\r
+\r
+Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SMM_PROFILE_ARCH_H_\r
+#define _SMM_PROFILE_ARCH_H_\r
+\r
+#pragma pack (1)\r
+\r
+typedef struct _MSR_DS_AREA_STRUCT {\r
+  UINT64  BTSBufferBase;\r
+  UINT64  BTSIndex;\r
+  UINT64  BTSAbsoluteMaximum;\r
+  UINT64  BTSInterruptThreshold;\r
+  UINT64  PEBSBufferBase;\r
+  UINT64  PEBSIndex;\r
+  UINT64  PEBSAbsoluteMaximum;\r
+  UINT64  PEBSInterruptThreshold;\r
+  UINT64  PEBSCounterReset[2];\r
+  UINT64  Reserved;\r
+} MSR_DS_AREA_STRUCT;\r
+\r
+typedef struct _BRANCH_TRACE_RECORD {\r
+  UINT64  LastBranchFrom;\r
+  UINT64  LastBranchTo;\r
+  UINT64  Rsvd0 : 4;\r
+  UINT64  BranchPredicted : 1;\r
+  UINT64  Rsvd1 : 59;\r
+} BRANCH_TRACE_RECORD;\r
+\r
+typedef struct _PEBS_RECORD {\r
+  UINT64  Rflags;\r
+  UINT64  LinearIP;\r
+  UINT64  Rax;\r
+  UINT64  Rbx;\r
+  UINT64  Rcx;\r
+  UINT64  Rdx;\r
+  UINT64  Rsi;\r
+  UINT64  Rdi;\r
+  UINT64  Rbp;\r
+  UINT64  Rsp;\r
+  UINT64  R8;\r
+  UINT64  R9;\r
+  UINT64  R10;\r
+  UINT64  R11;\r
+  UINT64  R12;\r
+  UINT64  R13;\r
+  UINT64  R14;\r
+  UINT64  R15;\r
+} PEBS_RECORD;\r
+\r
+#pragma pack ()\r
+\r
+#define PHYSICAL_ADDRESS_MASK       ((1ull << 52) - SIZE_4KB)\r
+\r
+/**\r
+  Update page table to map the memory correctly in order to make the instruction\r
+  which caused page fault execute successfully. And it also save the original page\r
+  table to be restored in single-step exception.\r
+\r
+  @param  PageTable           PageTable Address.\r
+  @param  PFAddress           The memory address which caused page fault exception.\r
+  @param  CpuIndex            The index of the processor.\r
+  @param  ErrorCode           The Error code of exception.\r
+  @param  IsValidPFAddress    The flag indicates if SMM profile data need be added.\r
+\r
+**/\r
+VOID\r
+RestorePageTableAbove4G (\r
+  UINT64        *PageTable,\r
+  UINT64        PFAddress,\r
+  UINTN         CpuIndex,\r
+  UINTN         ErrorCode,\r
+  BOOLEAN       *IsValidPFAddress\r
+  );\r
+\r
+/**\r
+  Create SMM page table for S3 path.\r
+\r
+**/\r
+VOID\r
+InitSmmS3Cr3 (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Allocate pages for creating 4KB-page based on 2MB-page when page fault happens.\r
+\r
+**/\r
+VOID\r
+InitPagesForPFHandler (\r
+  VOID\r
+  );\r
+\r
+#endif // _SMM_PROFILE_ARCH_H_\r