]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/SmmAccess/SmramInternal.h
OvmfPkg: SmmCpuFeaturesLib: customize state save map format
[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 Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
36 OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
37 from the D_LCK and T_EN bits.
38
39 PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
40 the LockState and OpenState fields being up-to-date on entry, and they need
41 to restore the same invariant on exit, if they touch the bits in question.
42
43 @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
44 locked.
45 @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
46 iff SMRAM is open.
47 **/
48 VOID
49 GetStates (
50 OUT BOOLEAN *LockState,
51 OUT BOOLEAN *OpenState
52 );
53
54 //
55 // The functions below follow the PEI_SMM_ACCESS_PPI and
56 // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
57 // pointers are removed (TSEG doesn't depend on them), and so is the
58 // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
59 //
60 // The LockState and OpenState members that are common to both
61 // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
62 // isolation from the rest of the (non-shared) members.
63 //
64
65 EFI_STATUS
66 SmramAccessOpen (
67 OUT BOOLEAN *LockState,
68 OUT BOOLEAN *OpenState
69 );
70
71 EFI_STATUS
72 SmramAccessClose (
73 OUT BOOLEAN *LockState,
74 OUT BOOLEAN *OpenState
75 );
76
77 EFI_STATUS
78 SmramAccessLock (
79 OUT BOOLEAN *LockState,
80 IN OUT BOOLEAN *OpenState
81 );
82
83 EFI_STATUS
84 SmramAccessGetCapabilities (
85 IN BOOLEAN LockState,
86 IN BOOLEAN OpenState,
87 IN OUT UINTN *SmramMapSize,
88 IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
89 );