]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkSocPkg/QuarkNorthCluster/Smm/Dxe/SmmAccessDxe/SmmAccessDriver.h
QuarkSocPkg/SmmAccessDxe: Set region to UC on SMRAM close
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / Smm / Dxe / SmmAccessDxe / SmmAccessDriver.h
1 /** @file
2 Header file for SMM Access Driver.
3
4 This file includes package header files, library classes and protocol, PPI & GUID definitions.
5
6 Copyright (c) 2013-2019 Intel Corporation.
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9 **/
10
11 #ifndef _SMM_ACCESS_DRIVER_H
12 #define _SMM_ACCESS_DRIVER_H
13
14 #include <PiDxe.h>
15 #include <IndustryStandard/Pci.h>
16
17 #include <Library/HobLib.h>
18 #include <Library/BaseLib.h>
19 #include <Library/UefiLib.h>
20 #include <Library/DebugLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/DxeServicesTableLib.h>
25 #include <Library/PcdLib.h>
26
27 //
28 // Driver Consumed Protocol Prototypes
29 //
30 #include <Protocol/PciRootBridgeIo.h>
31
32 //
33 // Driver Consumed GUID Prototypes
34 //
35 #include <Guid/SmramMemoryReserve.h>
36
37 //
38 // Driver produced protocol
39 //
40 #include <Protocol/SmmAccess2.h>
41
42 #include <Library/QNCSmmLib.h>
43 #include <QNCAccess.h>
44
45 #define MAX_CPU_SOCKET 1
46 #define MAX_SMRAM_RANGES 4
47
48 //
49 // Private data structure
50 //
51 #define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('i', 's', 'm', 'a')
52
53 typedef struct {
54 UINTN Signature;
55 EFI_HANDLE Handle;
56 EFI_SMM_ACCESS2_PROTOCOL SmmAccess;
57 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
58 UINTN NumberRegions;
59 EFI_SMRAM_DESCRIPTOR SmramDesc[MAX_SMRAM_RANGES];
60 UINT8 TsegSize;
61 UINT8 MaxBusNumber;
62 UINT8 SocketPopulated[MAX_CPU_SOCKET];
63 UINT64 SMMRegionState;
64 UINT8 ActualNLIioBusNumber;
65 } SMM_ACCESS_PRIVATE_DATA;
66
67
68 #define SMM_ACCESS_PRIVATE_DATA_FROM_THIS(a) \
69 CR ( \
70 a, \
71 SMM_ACCESS_PRIVATE_DATA, \
72 SmmAccess, \
73 SMM_ACCESS_PRIVATE_DATA_SIGNATURE \
74 )
75
76
77 //
78 // Prototypes
79 // Driver model protocol interface
80 //
81 EFI_STATUS
82 EFIAPI
83 SmmAccessDriverEntryPoint (
84 IN EFI_HANDLE ImageHandle,
85 IN EFI_SYSTEM_TABLE *SystemTable
86 )
87 /*++
88
89 Routine Description:
90
91 This is the standard EFI driver point that detects
92 whether there is an proper chipset in the system
93 and if so, installs an SMM Access Protocol.
94
95 Arguments:
96
97 ImageHandle - Handle for the image of this driver.
98 SystemTable - Pointer to the EFI System Table.
99
100 Returns:
101
102 EFI_SUCCESS - Protocol successfully started and installed.
103 EFI_UNSUPPORTED - Protocol can't be started.
104
105 --*/
106 ;
107
108 EFI_STATUS
109 EFIAPI
110 Open (
111 IN EFI_SMM_ACCESS2_PROTOCOL *This
112 )
113 /*++
114
115 Routine Description:
116
117 This routine accepts a request to "open" a region of SMRAM. The
118 region could be legacy ABSEG, HSEG, or TSEG near top of physical memory.
119 The use of "open" means that the memory is visible from all boot-service
120 and SMM agents.
121
122 Arguments:
123
124 This - Pointer to the SMM Access Interface.
125 DescriptorIndex - Region of SMRAM to Open.
126
127 Returns:
128
129 EFI_SUCCESS - The region was successfully opened.
130 EFI_DEVICE_ERROR - The region could not be opened because locked by
131 chipset.
132 EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
133
134 --*/
135 ;
136
137 EFI_STATUS
138 EFIAPI
139 Close (
140 IN EFI_SMM_ACCESS2_PROTOCOL *This
141 )
142 /*++
143
144 Routine Description:
145
146 This routine accepts a request to "close" a region of SMRAM. This is valid for
147 compatible SMRAM region.
148
149 Arguments:
150
151 This - Pointer to the SMM Access Interface.
152 DescriptorIndex - Region of SMRAM to Close.
153
154 Returns:
155
156 EFI_SUCCESS - The region was successfully closed.
157 EFI_DEVICE_ERROR - The region could not be closed because locked by
158 chipset.
159 EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
160
161 --*/
162 ;
163
164 EFI_STATUS
165 EFIAPI
166 Lock (
167 IN EFI_SMM_ACCESS2_PROTOCOL *This
168 )
169 /*++
170
171 Routine Description:
172
173 This routine accepts a request to "lock" SMRAM. The
174 region could be legacy AB or TSEG near top of physical memory.
175 The use of "lock" means that the memory can no longer be opened
176 to BS state..
177
178 Arguments:
179
180 This - Pointer to the SMM Access Interface.
181 DescriptorIndex - Region of SMRAM to Lock.
182
183 Returns:
184
185 EFI_SUCCESS - The region was successfully locked.
186 EFI_DEVICE_ERROR - The region could not be locked because at least
187 one range is still open.
188 EFI_INVALID_PARAMETER - The descriptor index was out of bounds.
189
190 --*/
191 ;
192
193 EFI_STATUS
194 EFIAPI
195 GetCapabilities (
196 IN CONST EFI_SMM_ACCESS2_PROTOCOL *This,
197 IN OUT UINTN *SmramMapSize,
198 IN OUT EFI_SMRAM_DESCRIPTOR *SmramMap
199 )
200 /*++
201
202 Routine Description:
203
204 This routine services a user request to discover the SMRAM
205 capabilities of this platform. This will report the possible
206 ranges that are possible for SMRAM access, based upon the
207 memory controller capabilities.
208
209 Arguments:
210
211 This - Pointer to the SMRAM Access Interface.
212 SmramMapSize - Pointer to the variable containing size of the
213 buffer to contain the description information.
214 SmramMap - Buffer containing the data describing the Smram
215 region descriptors.
216
217 Returns:
218
219 EFI_BUFFER_TOO_SMALL - The user did not provide a sufficient buffer.
220 EFI_SUCCESS - The user provided a sufficiently-sized buffer.
221
222 --*/
223 ;
224 VOID
225 SyncRegionState2SmramDesc(
226 IN BOOLEAN OrAnd,
227 IN UINT64 Value
228 );
229
230 #endif