]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.h
SecurityPkg OpalPassword: Add solution without SMM device code
[mirror_edk2.git] / SecurityPkg / Tcg / Opal / OpalPasswordDxe / OpalDriver.h
CommitLineData
a06875e1
ED
1/** @file\r
2 Values defined and used by the Opal UEFI Driver.\r
3\r
4Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _OPAL_DRIVER_H_\r
16#define _OPAL_DRIVER_H_\r
17\r
18#include <PiDxe.h>\r
252b891b 19\r
a06875e1
ED
20#include <Protocol/PciIo.h>\r
21#include <Protocol/SmmCommunication.h>\r
22#include <Protocol/BlockIo.h>\r
23#include <Protocol/LoadedImage.h>\r
24#include <Protocol/DevicePath.h>\r
25#include <Protocol/DevicePathToText.h>\r
26#include <Protocol/StorageSecurityCommand.h>\r
27\r
28#include <Library/UefiLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30#include <Library/UefiRuntimeServicesTableLib.h>\r
31#include <Library/BaseMemoryLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33#include <Library/BaseLib.h>\r
34#include <Library/PrintLib.h>\r
35#include <Library/DebugLib.h>\r
36#include <Library/DevicePathLib.h>\r
37#include <Library/HiiLib.h>\r
38#include <Library/UefiHiiServicesLib.h>\r
39#include <Library/TcgStorageOpalLib.h>\r
40#include <Library/OpalPasswordSupportLib.h>\r
34c2ce65 41#include <Library/Tcg2PhysicalPresenceLib.h>\r
a06875e1
ED
42\r
43#define EFI_DRIVER_NAME_UNICODE L"1.0 UEFI Opal Driver"\r
44\r
45// UEFI 2.1\r
46#define LANGUAGE_RFC_3066_ENGLISH ((CHAR8*)"en")\r
47\r
48// UEFI/EFI < 2.1\r
49#define LANGUAGE_ISO_639_2_ENGLISH ((CHAR8*)"eng")\r
50\r
51\r
52#define UNLOCK_VAR_NAME (const CHAR16*)L"UNLOCK"\r
53#define OPAL_FILTER_DRIVER_VAR_NAME L"FILTER_DRIVER"\r
54\r
55\r
56#define CONCAT_(x, y) x ## y\r
57#define CONCAT(x, y) CONCAT_(x, y)\r
58\r
59#define UNICODE_STR(x) CONCAT( L, x )\r
60\r
61extern EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding;\r
62extern EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName;\r
63extern EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2;\r
64\r
65/**\r
66 Unloads UEFI Driver. Very useful for debugging and testing.\r
67\r
68 @param ImageHandle Image handle this driver.\r
69\r
70 @retval EFI_SUCCESS This function always complete successfully.\r
71 @retval EFI_INVALID_PARAMETER The input ImageHandle is not valid.\r
72**/\r
73EFI_STATUS\r
74EFIAPI\r
75EfiDriverUnload(\r
76 EFI_HANDLE ImageHandle\r
77 );\r
78\r
79\r
80/**\r
81 Test to see if this driver supports Controller.\r
82\r
83 @param This Protocol instance pointer.\r
84 @param ControllerHandle Handle of device to test\r
85 @param RemainingDevicePath Optional parameter use to pick a specific child\r
86 device to start.\r
87\r
88 @retval EFI_SUCCESS This driver supports this device.\r
89 @retval EFI_ALREADY_STARTED This driver is already running on this device.\r
90 @retval other This driver does not support this device.\r
91\r
92**/\r
93EFI_STATUS\r
94EFIAPI\r
95OpalEfiDriverBindingSupported(\r
96 EFI_DRIVER_BINDING_PROTOCOL* This,\r
97 EFI_HANDLE Controller,\r
98 EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath\r
99 );\r
100\r
101/**\r
102 Enables Opal Management on a supported device if available.\r
103\r
104 The start function is designed to be called after the Opal UEFI Driver has confirmed the\r
105 "controller", which is a child handle, contains the EF_STORAGE_SECURITY_COMMAND protocols.\r
106 This function will complete the other necessary checks, such as verifying the device supports\r
107 the correct version of Opal. Upon verification, it will add the device to the\r
108 Opal HII list in order to expose Opal managmeent options.\r
109\r
110 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
111 @param[in] ControllerHandle The handle of the controller to start. This handle\r
112 must support a protocol interface that supplies\r
113 an I/O abstraction to the driver.\r
114 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This\r
115 parameter is ignored by device drivers, and is optional for bus\r
116 drivers. For a bus driver, if this parameter is NULL, then handles\r
117 for all the children of Controller are created by this driver.\r
118 If this parameter is not NULL and the first Device Path Node is\r
119 not the End of Device Path Node, then only the handle for the\r
120 child device specified by the first Device Path Node of\r
121 RemainingDevicePath is created by this driver.\r
122 If the first Device Path Node of RemainingDevicePath is\r
123 the End of Device Path Node, no child handle is created by this\r
124 driver.\r
125\r
126 @retval EFI_SUCCESS Opal management was enabled.\r
127 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.\r
128 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
129 @retval Others The driver failed to start the device.\r
130\r
131**/\r
132EFI_STATUS\r
133EFIAPI\r
134OpalEfiDriverBindingStart(\r
135 EFI_DRIVER_BINDING_PROTOCOL* This,\r
136 EFI_HANDLE Controller,\r
137 EFI_DEVICE_PATH_PROTOCOL* RemainingDevicePath\r
138 );\r
139\r
140/**\r
141 Stop this driver on Controller.\r
142\r
143 @param This Protocol instance pointer.\r
144 @param Controller Handle of device to stop driver on\r
145 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
146 children is zero stop the entire bus driver.\r
147 @param ChildHandleBuffer List of Child Handles to Stop.\r
148\r
149 @retval EFI_SUCCESS This driver is removed Controller.\r
150 @retval other This driver could not be removed from this device.\r
151\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155OpalEfiDriverBindingStop(\r
156 EFI_DRIVER_BINDING_PROTOCOL* This,\r
157 EFI_HANDLE Controller,\r
158 UINTN NumberOfChildren,\r
159 EFI_HANDLE* ChildHandleBuffer\r
160 );\r
161\r
162/**\r
163 Retrieves a Unicode string that is the user readable name of the driver.\r
164\r
165 This function retrieves the user readable name of a driver in the form of a\r
166 Unicode string. If the driver specified by This has a user readable name in\r
167 the language specified by Language, then a pointer to the driver name is\r
168 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
169 by This does not support the language specified by Language,\r
170 then EFI_UNSUPPORTED is returned.\r
171\r
172 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
173 EFI_COMPONENT_NAME_PROTOCOL instance.\r
174\r
175 @param Language[in] A pointer to a Null-terminated ASCII string\r
176 array indicating the language. This is the\r
177 language of the driver name that the caller is\r
178 requesting, and it must match one of the\r
179 languages specified in SupportedLanguages. The\r
180 number of languages supported by a driver is up\r
181 to the driver writer. Language is specified\r
182 in RFC 4646 or ISO 639-2 language code format.\r
183\r
184 @param DriverName[out] A pointer to the Unicode string to return.\r
185 This Unicode string is the name of the\r
186 driver specified by This in the language\r
187 specified by Language.\r
188\r
189 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
190 This and the language specified by Language was\r
191 returned in DriverName.\r
192\r
193 @retval EFI_INVALID_PARAMETER Language is NULL.\r
194\r
195 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
196\r
197 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
198 the language specified by Language.\r
199\r
200**/\r
201EFI_STATUS\r
202EFIAPI\r
203OpalEfiDriverComponentNameGetDriverName(\r
204 EFI_COMPONENT_NAME_PROTOCOL* This,\r
205 CHAR8* Language,\r
206 CHAR16** DriverName\r
207 );\r
208\r
209/**\r
210 Retrieves a Unicode string that is the user readable name of the controller\r
211 that is being managed by a driver.\r
212\r
213 This function retrieves the user readable name of the controller specified by\r
214 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
215 driver specified by This has a user readable name in the language specified by\r
216 Language, then a pointer to the controller name is returned in ControllerName,\r
217 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
218 managing the controller specified by ControllerHandle and ChildHandle,\r
219 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
220 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
221\r
222 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
223 EFI_COMPONENT_NAME_PROTOCOL instance.\r
224\r
225 @param ControllerHandle[in] The handle of a controller that the driver\r
226 specified by This is managing. This handle\r
227 specifies the controller whose name is to be\r
228 returned.\r
229\r
230 @param ChildHandle[in] The handle of the child controller to retrieve\r
231 the name of. This is an optional parameter that\r
232 may be NULL. It will be NULL for device\r
233 drivers. It will also be NULL for a bus drivers\r
234 that wish to retrieve the name of the bus\r
235 controller. It will not be NULL for a bus\r
236 driver that wishes to retrieve the name of a\r
237 child controller.\r
238\r
239 @param Language[in] A pointer to a Null-terminated ASCII string\r
240 array indicating the language. This is the\r
241 language of the driver name that the caller is\r
242 requesting, and it must match one of the\r
243 languages specified in SupportedLanguages. The\r
244 number of languages supported by a driver is up\r
245 to the driver writer. Language is specified in\r
246 RFC 4646 or ISO 639-2 language code format.\r
247\r
248 @param ControllerName[out] A pointer to the Unicode string to return.\r
249 This Unicode string is the name of the\r
250 controller specified by ControllerHandle and\r
251 ChildHandle in the language specified by\r
252 Language from the point of view of the driver\r
253 specified by This.\r
254\r
255 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
256 the language specified by Language for the\r
257 driver specified by This was returned in\r
258 DriverName.\r
259\r
260 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
261\r
262 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
263 EFI_HANDLE.\r
264\r
265 @retval EFI_INVALID_PARAMETER Language is NULL.\r
266\r
267 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
268\r
269 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
270 managing the controller specified by\r
271 ControllerHandle and ChildHandle.\r
272\r
273 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
274 the language specified by Language.\r
275\r
276**/\r
277EFI_STATUS\r
278EFIAPI\r
279OpalEfiDriverComponentNameGetControllerName(\r
280 EFI_COMPONENT_NAME_PROTOCOL* This,\r
281 EFI_HANDLE ControllerHandle,\r
282 EFI_HANDLE ChildHandle,\r
283 CHAR8* Language,\r
284 CHAR16** ControllerName\r
285 );\r
286\r
287/**\r
288 Retrieves a Unicode string that is the user readable name of the driver.\r
289\r
290 This function retrieves the user readable name of a driver in the form of a\r
291 Unicode string. If the driver specified by This has a user readable name in\r
292 the language specified by Language, then a pointer to the driver name is\r
293 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
294 by This does not support the language specified by Language,\r
295 then EFI_UNSUPPORTED is returned.\r
296\r
297 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
298 EFI_COMPONENT_NAME_PROTOCOL instance.\r
299\r
300 @param Language[in] A pointer to a Null-terminated ASCII string\r
301 array indicating the language. This is the\r
302 language of the driver name that the caller is\r
303 requesting, and it must match one of the\r
304 languages specified in SupportedLanguages. The\r
305 number of languages supported by a driver is up\r
306 to the driver writer. Language is specified\r
307 in RFC 4646 or ISO 639-2 language code format.\r
308\r
309 @param DriverName[out] A pointer to the Unicode string to return.\r
310 This Unicode string is the name of the\r
311 driver specified by This in the language\r
312 specified by Language.\r
313\r
314 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
315 This and the language specified by Language was\r
316 returned in DriverName.\r
317\r
318 @retval EFI_INVALID_PARAMETER Language is NULL.\r
319\r
320 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
321\r
322 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
323 the language specified by Language.\r
324\r
325**/\r
326EFI_STATUS\r
327EFIAPI\r
328OpalEfiDriverComponentName2GetDriverName(\r
329 EFI_COMPONENT_NAME2_PROTOCOL* This,\r
330 CHAR8* Language,\r
331 CHAR16** DriverName\r
332 );\r
333\r
334/**\r
335 Retrieves a Unicode string that is the user readable name of the controller\r
336 that is being managed by a driver.\r
337\r
338 This function retrieves the user readable name of the controller specified by\r
339 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
340 driver specified by This has a user readable name in the language specified by\r
341 Language, then a pointer to the controller name is returned in ControllerName,\r
342 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
343 managing the controller specified by ControllerHandle and ChildHandle,\r
344 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
345 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
346\r
347 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
348 EFI_COMPONENT_NAME_PROTOCOL instance.\r
349\r
350 @param ControllerHandle[in] The handle of a controller that the driver\r
351 specified by This is managing. This handle\r
352 specifies the controller whose name is to be\r
353 returned.\r
354\r
355 @param ChildHandle[in] The handle of the child controller to retrieve\r
356 the name of. This is an optional parameter that\r
357 may be NULL. It will be NULL for device\r
358 drivers. It will also be NULL for a bus drivers\r
359 that wish to retrieve the name of the bus\r
360 controller. It will not be NULL for a bus\r
361 driver that wishes to retrieve the name of a\r
362 child controller.\r
363\r
364 @param Language[in] A pointer to a Null-terminated ASCII string\r
365 array indicating the language. This is the\r
366 language of the driver name that the caller is\r
367 requesting, and it must match one of the\r
368 languages specified in SupportedLanguages. The\r
369 number of languages supported by a driver is up\r
370 to the driver writer. Language is specified in\r
371 RFC 4646 or ISO 639-2 language code format.\r
372\r
373 @param ControllerName[out] A pointer to the Unicode string to return.\r
374 This Unicode string is the name of the\r
375 controller specified by ControllerHandle and\r
376 ChildHandle in the language specified by\r
377 Language from the point of view of the driver\r
378 specified by This.\r
379\r
380 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
381 the language specified by Language for the\r
382 driver specified by This was returned in\r
383 DriverName.\r
384\r
385 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
386\r
387 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
388 EFI_HANDLE.\r
389\r
390 @retval EFI_INVALID_PARAMETER Language is NULL.\r
391\r
392 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
393\r
394 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
395 managing the controller specified by\r
396 ControllerHandle and ChildHandle.\r
397\r
398 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
399 the language specified by Language.\r
400\r
401**/\r
402EFI_STATUS\r
403EFIAPI\r
404OpalEfiDriverComponentName2GetControllerName(\r
405 EFI_COMPONENT_NAME2_PROTOCOL* This,\r
406 EFI_HANDLE ControllerHandle,\r
407 EFI_HANDLE ChildHandle,\r
408 CHAR8* Language,\r
409 CHAR16** ControllerName\r
410 );\r
411\r
412#endif //_OPAL_DRIVER_H_\r