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