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