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 | Save PcdQ35SmramAtDefaultSmbase into mQ35SmramAtDefaultSmbase.
|
---|
43 | **/
|
---|
44 | VOID
|
---|
45 | InitQ35SmramAtDefaultSmbase (
|
---|
46 | VOID
|
---|
47 | );
|
---|
48 |
|
---|
49 | /**
|
---|
50 | Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
|
---|
51 | OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
|
---|
52 | from the D_LCK and T_EN bits.
|
---|
53 |
|
---|
54 | PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
|
---|
55 | the LockState and OpenState fields being up-to-date on entry, and they need
|
---|
56 | to restore the same invariant on exit, if they touch the bits in question.
|
---|
57 |
|
---|
58 | @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
|
---|
59 | locked.
|
---|
60 | @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
|
---|
61 | iff SMRAM is open.
|
---|
62 | **/
|
---|
63 | VOID
|
---|
64 | GetStates (
|
---|
65 | OUT BOOLEAN *LockState,
|
---|
66 | OUT BOOLEAN *OpenState
|
---|
67 | );
|
---|
68 |
|
---|
69 | //
|
---|
70 | // The functions below follow the PEI_SMM_ACCESS_PPI and
|
---|
71 | // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
|
---|
72 | // pointers are removed (TSEG doesn't depend on them), and so is the
|
---|
73 | // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
|
---|
74 | //
|
---|
75 | // The LockState and OpenState members that are common to both
|
---|
76 | // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
|
---|
77 | // isolation from the rest of the (non-shared) members.
|
---|
78 | //
|
---|
79 |
|
---|
80 | EFI_STATUS
|
---|
81 | SmramAccessOpen (
|
---|
82 | OUT BOOLEAN *LockState,
|
---|
83 | OUT BOOLEAN *OpenState
|
---|
84 | );
|
---|
85 |
|
---|
86 | EFI_STATUS
|
---|
87 | SmramAccessClose (
|
---|
88 | OUT BOOLEAN *LockState,
|
---|
89 | OUT BOOLEAN *OpenState
|
---|
90 | );
|
---|
91 |
|
---|
92 | EFI_STATUS
|
---|
93 | SmramAccessLock (
|
---|
94 | OUT BOOLEAN *LockState,
|
---|
95 | IN OUT BOOLEAN *OpenState
|
---|
96 | );
|
---|
97 |
|
---|
98 | EFI_STATUS
|
---|
99 | SmramAccessGetCapabilities (
|
---|
100 | IN BOOLEAN LockState,
|
---|
101 | IN BOOLEAN OpenState,
|
---|
102 | IN OUT UINTN *SmramMapSize,
|
---|
103 | IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
|
---|
104 | );
|
---|