]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/SmmAccess/SmramInternal.h
OvmfPkg/Csm/LegacyBiosDxe: Fix Legacy16GetTableAddress call for E820 data
[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 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #include <Pi/PiMultiPhase.h>
12
13 //
14 // We'll have two SMRAM ranges.
15 //
16 // The first is a tiny one that hosts an SMM_S3_RESUME_STATE object, to be
17 // filled in by the CPU SMM driver during normal boot, for the PEI instance of
18 // the LockBox library (which will rely on the object during S3 resume).
19 //
20 // The other SMRAM range is the main one, for the SMM core and the SMM drivers.
21 //
22 typedef enum {
23 DescIdxSmmS3ResumeState = 0,
24 DescIdxMain = 1,
25 DescIdxCount = 2
26 } DESCRIPTOR_INDEX;
27
28 //
29 // The value of PcdQ35TsegMbytes is saved into this variable at module startup.
30 //
31 extern UINT16 mQ35TsegMbytes;
32
33 /**
34 Save PcdQ35TsegMbytes into mQ35TsegMbytes.
35 **/
36 VOID
37 InitQ35TsegMbytes (
38 VOID
39 );
40
41 /**
42 Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
43 OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
44 from the D_LCK and T_EN bits.
45
46 PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
47 the LockState and OpenState fields being up-to-date on entry, and they need
48 to restore the same invariant on exit, if they touch the bits in question.
49
50 @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
51 locked.
52 @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
53 iff SMRAM is open.
54 **/
55 VOID
56 GetStates (
57 OUT BOOLEAN *LockState,
58 OUT BOOLEAN *OpenState
59 );
60
61 //
62 // The functions below follow the PEI_SMM_ACCESS_PPI and
63 // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
64 // pointers are removed (TSEG doesn't depend on them), and so is the
65 // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
66 //
67 // The LockState and OpenState members that are common to both
68 // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
69 // isolation from the rest of the (non-shared) members.
70 //
71
72 EFI_STATUS
73 SmramAccessOpen (
74 OUT BOOLEAN *LockState,
75 OUT BOOLEAN *OpenState
76 );
77
78 EFI_STATUS
79 SmramAccessClose (
80 OUT BOOLEAN *LockState,
81 OUT BOOLEAN *OpenState
82 );
83
84 EFI_STATUS
85 SmramAccessLock (
86 OUT BOOLEAN *LockState,
87 IN OUT BOOLEAN *OpenState
88 );
89
90 EFI_STATUS
91 SmramAccessGetCapabilities (
92 IN BOOLEAN LockState,
93 IN BOOLEAN OpenState,
94 IN OUT UINTN *SmramMapSize,
95 IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
96 );