TianoCore EDK2 master
Loading...
Searching...
No Matches
OpalDriver.h
Go to the documentation of this file.
1
9#ifndef _OPAL_DRIVER_H_
10#define _OPAL_DRIVER_H_
11
12#include <PiDxe.h>
13
15
16#include <Protocol/PciIo.h>
18#include <Protocol/BlockIo.h>
20#include <Protocol/DevicePath.h>
23
24#include <Guid/EventGroup.h>
26#include <Guid/MdeModuleHii.h>
27
28#include <Library/UefiLib.h>
34#include <Library/BaseLib.h>
35#include <Library/PrintLib.h>
36#include <Library/DebugLib.h>
38#include <Library/HiiLib.h>
40#include <Library/PciLib.h>
41#include <Library/LockBoxLib.h>
44
45#include "OpalPasswordCommon.h"
46#include "OpalHiiFormValues.h"
47
48#define EFI_DRIVER_NAME_UNICODE L"1.0 UEFI Opal Driver"
49
50// UEFI 2.1
51#define LANGUAGE_RFC_3066_ENGLISH ((CHAR8*)"en")
52
53// UEFI/EFI < 2.1
54#define LANGUAGE_ISO_639_2_ENGLISH ((CHAR8*)"eng")
55
56#define CONCAT_(x, y) x ## y
57#define CONCAT(x, y) CONCAT_(x, y)
58
59#define UNICODE_STR(x) CONCAT( L, x )
60
61extern EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding;
62extern EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName;
63extern EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2;
64
65#define OPAL_MSID_LENGTH 128
66
67#define MAX_PASSWORD_TRY_COUNT 5
68
69// PSID Length
70#define PSID_CHARACTER_LENGTH 0x20
71#define MAX_PSID_TRY_COUNT 5
72
73//
74// The max timeout value assume the user can wait for the revert action. The unit of this macro is second.
75// If the revert time value bigger than this one, driver needs to popup a dialog to let user confirm the
76// revert action.
77//
78#define MAX_ACCEPTABLE_REVERTING_TIME 10
79
80#pragma pack(1)
81
82//
83// Structure that is used to represent the available actions for an OpalDisk.
84// The data can then be utilized to expose/hide certain actions available to an end user
85// by the consumer of this library.
86//
87typedef struct {
88 //
89 // Indicates if the disk can support PSID Revert action. should verify disk supports PSID authority
90 //
91 UINT16 PsidRevert : 1;
92
93 //
94 // Indicates if the disk can support Revert action
95 //
96 UINT16 Revert : 1;
97
98 //
99 // Indicates if the user must keep data for revert action. It is true if no media encryption is supported.
100 //
101 UINT16 RevertKeepDataForced : 1;
102
103 //
104 // Indicates if the disk can support set Admin password
105 //
106 UINT16 AdminPass : 1;
107
108 //
109 // Indicates if the disk can support set User password. This action requires that a user
110 // password is first enabled.
111 //
112 UINT16 UserPass : 1;
113
114 //
115 // Indicates if unlock action is available. Requires disk to be currently locked.
116 //
117 UINT16 Unlock : 1;
118
119 //
120 // Indicates if Secure Erase action is available. Action requires admin credentials and media encryption support.
121 //
122 UINT16 SecureErase : 1;
123
124 //
125 // Indicates if Disable User action is available. Action requires admin credentials.
126 //
127 UINT16 DisableUser : 1;
129
130//
131// Structure that is used to represent an OPAL_DISK.
132//
133typedef struct {
134 UINT32 MsidLength; // Byte length of MSID Pin for device
135 UINT8 Msid[OPAL_MSID_LENGTH]; // MSID Pin for device
137 UINT32 MediaId; // MediaId is used by Ssc Protocol.
138 EFI_DEVICE_PATH_PROTOCOL *OpalDevicePath;
139 UINT16 OpalBaseComId; // Opal SSC 1 base com id.
140 OPAL_OWNER_SHIP Owner;
141 OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes;
142 TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature; // Locking Feature Descriptor retrieved from performing a Level 0 Discovery
143 UINT8 PasswordLength;
144 UINT8 Password[OPAL_MAX_PASSWORD_SIZE];
145
146 UINT32 EstimateTimeCost;
147 BOOLEAN SentBlockSID; // Check whether BlockSid command has been sent.
148} OPAL_DISK;
149
150//
151// Device with block IO protocol
152//
154
159 CHAR16 *Name16;
160 CHAR8 *NameZ;
161 UINT32 MediaId;
162
165};
166
167//
168// Opal Driver UEFI Driver Model
169//
170typedef struct {
174
175#pragma pack()
176
177//
178// Retrieves a OPAL_DRIVER_DEVICE based on the pointer to its StorageSecurity protocol.
179//
180#define DRIVER_DEVICE_FROM_OPALDISK(OpalDiskPointer) (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))
181
189 VOID
190 );
191
200BOOLEAN
203 );
204
211UINT8
213 VOID
214 );
215
224VOID
226 IN OUT OPAL_DISK *OpalDisk,
227 IN VOID *Password,
228 IN UINT32 PasswordLength
229 );
230
242EFIAPI
244 IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes,
245 IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature,
246 IN UINT16 OwnerShip,
247 OUT OPAL_DISK_ACTIONS *AvalDiskActions
248 );
249
261EFIAPI
263 IN OPAL_SESSION *Session,
264 IN VOID *Msid,
265 IN UINT32 MsidLength,
266 IN VOID *Password,
267 IN UINT32 PassLength
268 );
269
279EFIAPI
281 EFI_HANDLE ImageHandle
282 );
283
298EFIAPI
301 EFI_HANDLE Controller,
302 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
303 );
304
337EFIAPI
340 EFI_HANDLE Controller,
341 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
342 );
343
358EFIAPI
361 EFI_HANDLE Controller,
362 UINTN NumberOfChildren,
363 EFI_HANDLE *ChildHandleBuffer
364 );
365
406EFIAPI
409 CHAR8 *Language,
410 CHAR16 **DriverName
411 );
412
482EFIAPI
485 EFI_HANDLE ControllerHandle,
486 EFI_HANDLE ChildHandle,
487 CHAR8 *Language,
488 CHAR16 **ControllerName
489 );
490
531EFIAPI
534 CHAR8 *Language,
535 CHAR16 **DriverName
536 );
537
607EFIAPI
610 EFI_HANDLE ControllerHandle,
611 EFI_HANDLE ChildHandle,
612 CHAR8 *Language,
613 CHAR16 **ControllerName
614 );
615
616#endif //_OPAL_DRIVER_H_
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI OpalEfiDriverComponentName2GetControllerName(EFI_COMPONENT_NAME2_PROTOCOL *This, EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle, CHAR8 *Language, CHAR16 **ControllerName)
VOID OpalSupportUpdatePassword(IN OUT OPAL_DISK *OpalDisk, IN VOID *Password, IN UINT32 PasswordLength)
Definition: OpalDriver.c:189
EFI_STATUS EFIAPI EfiDriverUnload(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI OpalEfiDriverComponentNameGetControllerName(EFI_COMPONENT_NAME_PROTOCOL *This, EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle, CHAR8 *Language, CHAR16 **ControllerName)
EFI_STATUS EFIAPI OpalEfiDriverComponentName2GetDriverName(EFI_COMPONENT_NAME2_PROTOCOL *This, CHAR8 *Language, CHAR16 **DriverName)
EFI_STATUS EFIAPI OpalEfiDriverBindingStop(EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, UINTN NumberOfChildren, EFI_HANDLE *ChildHandleBuffer)
Definition: OpalDriver.c:2947
EFI_STATUS EFIAPI OpalEfiDriverBindingStart(EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
UINT8 GetDeviceCount(VOID)
Definition: OpalDriver.c:2351
EFI_STATUS EFIAPI OpalEfiDriverBindingSupported(EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI OpalEfiDriverComponentNameGetDriverName(EFI_COMPONENT_NAME_PROTOCOL *This, CHAR8 *Language, CHAR16 **DriverName)
Definition: ComponentName.c:77
OPAL_DRIVER_DEVICE * OpalDriverGetDeviceList(VOID)
Definition: OpalDriver.c:2375
BOOLEAN OpalDriverGetDriverDeviceName(OPAL_DRIVER_DEVICE *Dev)
Definition: OpalDriver.c:2581
TCG_RESULT EFIAPI OpalSupportEnableOpalFeature(IN OPAL_SESSION *Session, IN VOID *Msid, IN UINT32 MsidLength, IN VOID *Password, IN UINT32 PassLength)
Definition: OpalDriver.c:138
TCG_RESULT EFIAPI OpalSupportGetAvailableActions(IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes, IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature, IN UINT16 OwnerShip, OUT OPAL_DISK_ACTIONS *AvalDiskActions)
Definition: OpalDriver.c:51
TCG_RESULT
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
CHAR8 * NameZ
Allocated/freed by UEFI Filter Driver at device creation/removal.
Definition: OpalDriver.h:160
EFI_HANDLE Handle
Device handle.
Definition: OpalDriver.h:157
EFI_DEVICE_PATH_PROTOCOL * OpalDevicePath
Device protocols consumed.
Definition: OpalDriver.h:164
CHAR16 * Name16
Allocated/freed by UEFI Filter Driver at device creation/removal.
Definition: OpalDriver.h:159
UINT32 MediaId
Required parameter for EFI_STORAGE_SECURITY_COMMAND_PROTOCOL, from BLOCK_IO_MEDIA.
Definition: OpalDriver.h:161
OPAL_DISK OpalDisk
User context.
Definition: OpalDriver.h:158
OPAL_DRIVER_DEVICE * Next
Linked list pointer.
Definition: OpalDriver.h:156
EFI_HANDLE Handle
Driver image handle.
Definition: OpalDriver.h:171
OPAL_DRIVER_DEVICE * DeviceList
Linked list of controllers owned by this Driver.
Definition: OpalDriver.h:172