]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/SmmAccess/SmramInternal.h
OvmfPkg/SmmCpuFeaturesLib: SEV: encrypt+free pages of init. save state map
[mirror_edk2.git] / OvmfPkg / SmmAccess / SmramInternal.h
1 /** @file
2
3 Functions and types shared by the SMM accessor PEI and DXE modules.
4
5 Copyright (C) 2015, Red Hat, Inc.
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <Pi/PiMultiPhase.h>
18
19 //
20 // We'll have two SMRAM ranges.
21 //
22 // The first is a tiny one that hosts an SMM_S3_RESUME_STATE object, to be
23 // filled in by the CPU SMM driver during normal boot, for the PEI instance of
24 // the LockBox library (which will rely on the object during S3 resume).
25 //
26 // The other SMRAM range is the main one, for the SMM core and the SMM drivers.
27 //
28 typedef enum {
29 DescIdxSmmS3ResumeState = 0,
30 DescIdxMain = 1,
31 DescIdxCount = 2
32 } DESCRIPTOR_INDEX;
33
34 //
35 // The value of PcdQ35TsegMbytes is saved into this variable at module startup.
36 //
37 extern UINT16 mQ35TsegMbytes;
38
39 /**
40 Save PcdQ35TsegMbytes into mQ35TsegMbytes.
41 **/
42 VOID
43 InitQ35TsegMbytes (
44 VOID
45 );
46
47 /**
48 Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
49 OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
50 from the D_LCK and T_EN bits.
51
52 PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
53 the LockState and OpenState fields being up-to-date on entry, and they need
54 to restore the same invariant on exit, if they touch the bits in question.
55
56 @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
57 locked.
58 @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
59 iff SMRAM is open.
60 **/
61 VOID
62 GetStates (
63 OUT BOOLEAN *LockState,
64 OUT BOOLEAN *OpenState
65 );
66
67 //
68 // The functions below follow the PEI_SMM_ACCESS_PPI and
69 // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
70 // pointers are removed (TSEG doesn't depend on them), and so is the
71 // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
72 //
73 // The LockState and OpenState members that are common to both
74 // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
75 // isolation from the rest of the (non-shared) members.
76 //
77
78 EFI_STATUS
79 SmramAccessOpen (
80 OUT BOOLEAN *LockState,
81 OUT BOOLEAN *OpenState
82 );
83
84 EFI_STATUS
85 SmramAccessClose (
86 OUT BOOLEAN *LockState,
87 OUT BOOLEAN *OpenState
88 );
89
90 EFI_STATUS
91 SmramAccessLock (
92 OUT BOOLEAN *LockState,
93 IN OUT BOOLEAN *OpenState
94 );
95
96 EFI_STATUS
97 SmramAccessGetCapabilities (
98 IN BOOLEAN LockState,
99 IN BOOLEAN OpenState,
100 IN OUT UINTN *SmramMapSize,
101 IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
102 );