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