]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmProfileArch.h
UefiCpuPkg/PiSmmCpuDxeSmm: patch "gSmbase" with PatchInstructionX86()
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / SmmProfileArch.h
CommitLineData
7947da3c
MK
1/** @file\r
2IA-32 processor specific header file to enable SMM profile.\r
3\r
4Copyright (c) 2012 - 2015, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _SMM_PROFILE_ARCH_H_\r
16#define _SMM_PROFILE_ARCH_H_\r
17\r
18#pragma pack (1)\r
19\r
20typedef struct _MSR_DS_AREA_STRUCT {\r
21 UINT32 BTSBufferBase;\r
22 UINT32 BTSIndex;\r
23 UINT32 BTSAbsoluteMaximum;\r
24 UINT32 BTSInterruptThreshold;\r
25 UINT32 PEBSBufferBase;\r
26 UINT32 PEBSIndex;\r
27 UINT32 PEBSAbsoluteMaximum;\r
28 UINT32 PEBSInterruptThreshold;\r
29 UINT32 PEBSCounterReset[4];\r
30 UINT32 Reserved;\r
31} MSR_DS_AREA_STRUCT;\r
32\r
33typedef struct _BRANCH_TRACE_RECORD {\r
34 UINT32 LastBranchFrom;\r
35 UINT32 LastBranchTo;\r
36 UINT32 Rsvd0 : 4;\r
37 UINT32 BranchPredicted : 1;\r
38 UINT32 Rsvd1 : 27;\r
39} BRANCH_TRACE_RECORD;\r
40\r
41typedef struct _PEBS_RECORD {\r
42 UINT32 Eflags;\r
43 UINT32 LinearIP;\r
44 UINT32 Eax;\r
45 UINT32 Ebx;\r
46 UINT32 Ecx;\r
47 UINT32 Edx;\r
48 UINT32 Esi;\r
49 UINT32 Edi;\r
50 UINT32 Ebp;\r
51 UINT32 Esp;\r
52} PEBS_RECORD;\r
53\r
54#pragma pack ()\r
55\r
56#define PHYSICAL_ADDRESS_MASK ((1ull << 32) - SIZE_4KB)\r
57\r
58/**\r
59 Update page table to map the memory correctly in order to make the instruction\r
60 which caused page fault execute successfully. And it also save the original page\r
61 table to be restored in single-step exception. 32-bit firmware does not need it.\r
62\r
63 @param PageTable PageTable Address.\r
64 @param PFAddress The memory address which caused page fault exception.\r
65 @param CpuIndex The index of the processor.\r
66 @param ErrorCode The Error code of exception.\r
67 @param IsValidPFAddress The flag indicates if SMM profile data need be added.\r
68\r
69**/\r
70VOID\r
71RestorePageTableAbove4G (\r
72 UINT64 *PageTable,\r
73 UINT64 PFAddress,\r
74 UINTN CpuIndex,\r
75 UINTN ErrorCode,\r
76 BOOLEAN *IsValidPFAddress\r
77 );\r
78\r
79/**\r
80 Create SMM page table for S3 path.\r
81\r
82**/\r
83VOID\r
84InitSmmS3Cr3 (\r
85 VOID\r
86 );\r
87\r
88/**\r
89 Allocate pages for creating 4KB-page based on 2MB-page when page fault happens.\r
90\r
91**/\r
92VOID\r
93InitPagesForPFHandler (\r
94 VOID\r
95 );\r
96\r
97#endif // _SMM_PROFILE_ARCH_H_\r