3 Functions and types shared by the SMM accessor PEI and DXE modules.
5 Copyright (C) 2015, Red Hat, Inc.
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
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.
17 #include <Pi/PiMultiPhase.h>
20 // We'll have two SMRAM ranges.
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).
26 // The other SMRAM range is the main one, for the SMM core and the SMM drivers.
29 DescIdxSmmS3ResumeState
= 0,
35 // The value of PcdQ35TsegMbytes is saved into this variable at module startup.
37 extern UINT16 mQ35TsegMbytes
;
40 Save PcdQ35TsegMbytes into mQ35TsegMbytes.
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.
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.
56 @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
58 @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
63 OUT BOOLEAN
*LockState
,
64 OUT BOOLEAN
*OpenState
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).
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.
80 OUT BOOLEAN
*LockState
,
81 OUT BOOLEAN
*OpenState
86 OUT BOOLEAN
*LockState
,
87 OUT BOOLEAN
*OpenState
92 OUT BOOLEAN
*LockState
,
93 IN OUT BOOLEAN
*OpenState
97 SmramAccessGetCapabilities (
100 IN OUT UINTN
*SmramMapSize
,
101 IN OUT EFI_SMRAM_DESCRIPTOR
*SmramMap