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