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 | Copyright (c) 2024 Intel Corporation.
|
---|
7 |
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #include <Pi/PiMultiPhase.h>
|
---|
13 |
|
---|
14 | #include <Guid/SmramMemoryReserve.h>
|
---|
15 | #include <Library/HobLib.h>
|
---|
16 |
|
---|
17 | //
|
---|
18 | // The value of PcdQ35TsegMbytes is saved into this variable at module startup.
|
---|
19 | //
|
---|
20 | extern UINT16 mQ35TsegMbytes;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | Save PcdQ35TsegMbytes into mQ35TsegMbytes.
|
---|
24 | **/
|
---|
25 | VOID
|
---|
26 | InitQ35TsegMbytes (
|
---|
27 | VOID
|
---|
28 | );
|
---|
29 |
|
---|
30 | /**
|
---|
31 | Save PcdQ35SmramAtDefaultSmbase into mQ35SmramAtDefaultSmbase.
|
---|
32 | **/
|
---|
33 | VOID
|
---|
34 | InitQ35SmramAtDefaultSmbase (
|
---|
35 | VOID
|
---|
36 | );
|
---|
37 |
|
---|
38 | /**
|
---|
39 | Read the MCH_SMRAM and ESMRAMC registers, and update the LockState and
|
---|
40 | OpenState fields in the PEI_SMM_ACCESS_PPI / EFI_SMM_ACCESS2_PROTOCOL object,
|
---|
41 | from the D_LCK and T_EN bits.
|
---|
42 |
|
---|
43 | PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL member functions can rely on
|
---|
44 | the LockState and OpenState fields being up-to-date on entry, and they need
|
---|
45 | to restore the same invariant on exit, if they touch the bits in question.
|
---|
46 |
|
---|
47 | @param[out] LockState Reflects the D_LCK bit on output; TRUE iff SMRAM is
|
---|
48 | locked.
|
---|
49 | @param[out] OpenState Reflects the inverse of the T_EN bit on output; TRUE
|
---|
50 | iff SMRAM is open.
|
---|
51 | **/
|
---|
52 | VOID
|
---|
53 | GetStates (
|
---|
54 | OUT BOOLEAN *LockState,
|
---|
55 | OUT BOOLEAN *OpenState
|
---|
56 | );
|
---|
57 |
|
---|
58 | //
|
---|
59 | // The functions below follow the PEI_SMM_ACCESS_PPI and
|
---|
60 | // EFI_SMM_ACCESS2_PROTOCOL member declarations. The PeiServices and This
|
---|
61 | // pointers are removed (TSEG doesn't depend on them), and so is the
|
---|
62 | // DescriptorIndex parameter (TSEG doesn't support range-wise locking).
|
---|
63 | //
|
---|
64 | // The LockState and OpenState members that are common to both
|
---|
65 | // PEI_SMM_ACCESS_PPI and EFI_SMM_ACCESS2_PROTOCOL are taken and updated in
|
---|
66 | // isolation from the rest of the (non-shared) members.
|
---|
67 | //
|
---|
68 |
|
---|
69 | EFI_STATUS
|
---|
70 | SmramAccessOpen (
|
---|
71 | OUT BOOLEAN *LockState,
|
---|
72 | OUT BOOLEAN *OpenState
|
---|
73 | );
|
---|
74 |
|
---|
75 | EFI_STATUS
|
---|
76 | SmramAccessClose (
|
---|
77 | OUT BOOLEAN *LockState,
|
---|
78 | OUT BOOLEAN *OpenState
|
---|
79 | );
|
---|
80 |
|
---|
81 | EFI_STATUS
|
---|
82 | SmramAccessLock (
|
---|
83 | OUT BOOLEAN *LockState,
|
---|
84 | IN OUT BOOLEAN *OpenState
|
---|
85 | );
|
---|
86 |
|
---|
87 | EFI_STATUS
|
---|
88 | SmramAccessGetCapabilities (
|
---|
89 | IN OUT UINTN *SmramMapSize,
|
---|
90 | IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
|
---|
91 | );
|
---|