1 /** @file
2 SMM profile header file.
3 
4 Copyright (c) 2012 - 2016, 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_H_
16 #define _SMM_PROFILE_H_
17 
18 #include "SmmProfileInternal.h"
19 
20 //
21 // External functions
22 //
23 
24 /**
25   Initialize processor environment for SMM profile.
26 
27   @param  CpuIndex  The index of the processor.
28 
29 **/
30 VOID
31 ActivateSmmProfile (
32   IN UINTN CpuIndex
33   );
34 
35 /**
36   Initialize SMM profile in SMM CPU entry point.
37 
38   @param[in] Cr3  The base address of the page tables to use in SMM.
39 
40 **/
41 VOID
42 InitSmmProfile (
43   UINT32  Cr3
44   );
45 
46 /**
47   Increase SMI number in each SMI entry.
48 
49 **/
50 VOID
51 SmmProfileRecordSmiNum (
52   VOID
53   );
54 
55 /**
56   The Page fault handler to save SMM profile data.
57 
58   @param  Rip        The RIP when exception happens.
59   @param  ErrorCode  The Error code of exception.
60 
61 **/
62 VOID
63 SmmProfilePFHandler (
64   UINTN Rip,
65   UINTN ErrorCode
66   );
67 
68 /**
69   Updates page table to make some memory ranges (like system memory) absent
70   and make some memory ranges (like MMIO) present and execute disable. It also
71   update 2MB-page to 4KB-page for some memory ranges.
72 
73 **/
74 VOID
75 SmmProfileStart (
76   VOID
77   );
78 
79 /**
80   Page fault IDT handler for SMM Profile.
81 
82 **/
83 VOID
84 EFIAPI
85 PageFaultIdtHandlerSmmProfile (
86   VOID
87   );
88 
89 
90 /**
91   Check if XD feature is supported by a processor.
92 
93 **/
94 VOID
95 CheckFeatureSupported (
96   VOID
97   );
98 
99 /**
100   Update page table according to protected memory ranges and the 4KB-page mapped memory ranges.
101 
102 **/
103 VOID
104 InitPaging (
105   VOID
106   );
107 
108 /**
109   Get CPU Index from APIC ID.
110 
111 **/
112 UINTN
113 GetCpuIndex (
114   VOID
115   );
116 
117 //
118 // The flag indicates if execute-disable is supported by processor.
119 //
120 extern BOOLEAN    mXdSupported;
121 //
122 // The flag indicates if execute-disable is enabled on processor.
123 //
124 extern BOOLEAN    mXdEnabled;
125 
126 #endif // _SMM_PROFILE_H_
127