TianoCore EDK2 master
Loading...
Searching...
No Matches
OpalDriver.h File Reference

Go to the source code of this file.

Data Structures

struct  OPAL_DISK_ACTIONS
 
struct  OPAL_DISK
 
struct  _OPAL_DRIVER_DEVICE
 
struct  OPAL_DRIVER
 

Macros

#define EFI_DRIVER_NAME_UNICODE   L"1.0 UEFI Opal Driver"
 
#define LANGUAGE_RFC_3066_ENGLISH   ((CHAR8*)"en")
 
#define LANGUAGE_ISO_639_2_ENGLISH   ((CHAR8*)"eng")
 
#define CONCAT_(x, y)   x ## y
 
#define CONCAT(x, y)   CONCAT_(x, y)
 
#define UNICODE_STR(x)   CONCAT( L, x )
 
#define OPAL_MSID_LENGTH   128
 
#define MAX_PASSWORD_TRY_COUNT   5
 
#define PSID_CHARACTER_LENGTH   0x20
 
#define MAX_PSID_TRY_COUNT   5
 
#define MAX_ACCEPTABLE_REVERTING_TIME   10
 
#define DRIVER_DEVICE_FROM_OPALDISK(OpalDiskPointer)   (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))
 

Typedefs

typedef struct _OPAL_DRIVER_DEVICE OPAL_DRIVER_DEVICE
 

Functions

OPAL_DRIVER_DEVICEOpalDriverGetDeviceList (VOID)
 
BOOLEAN OpalDriverGetDriverDeviceName (OPAL_DRIVER_DEVICE *Dev)
 
UINT8 GetDeviceCount (VOID)
 
VOID OpalSupportUpdatePassword (IN OUT OPAL_DISK *OpalDisk, IN VOID *Password, IN UINT32 PasswordLength)
 
TCG_RESULT EFIAPI OpalSupportGetAvailableActions (IN OPAL_DISK_SUPPORT_ATTRIBUTE *SupportedAttributes, IN TCG_LOCKING_FEATURE_DESCRIPTOR *LockingFeature, IN UINT16 OwnerShip, OUT OPAL_DISK_ACTIONS *AvalDiskActions)
 
TCG_RESULT EFIAPI OpalSupportEnableOpalFeature (IN OPAL_SESSION *Session, IN VOID *Msid, IN UINT32 MsidLength, IN VOID *Password, IN UINT32 PassLength)
 
EFI_STATUS EFIAPI EfiDriverUnload (EFI_HANDLE ImageHandle)
 
EFI_STATUS EFIAPI OpalEfiDriverBindingSupported (EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI OpalEfiDriverBindingStart (EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI OpalEfiDriverBindingStop (EFI_DRIVER_BINDING_PROTOCOL *This, EFI_HANDLE Controller, UINTN NumberOfChildren, EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI OpalEfiDriverComponentNameGetDriverName (EFI_COMPONENT_NAME_PROTOCOL *This, CHAR8 *Language, CHAR16 **DriverName)
 
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 OpalEfiDriverComponentName2GetControllerName (EFI_COMPONENT_NAME2_PROTOCOL *This, EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle, CHAR8 *Language, CHAR16 **ControllerName)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding
 
EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName
 
EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2
 

Detailed Description

Values defined and used by the Opal UEFI Driver.

Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file OpalDriver.h.

Macro Definition Documentation

◆ CONCAT

#define CONCAT (   x,
 
)    CONCAT_(x, y)

Definition at line 57 of file OpalDriver.h.

◆ CONCAT_

#define CONCAT_ (   x,
 
)    x ## y

Definition at line 56 of file OpalDriver.h.

◆ DRIVER_DEVICE_FROM_OPALDISK

#define DRIVER_DEVICE_FROM_OPALDISK (   OpalDiskPointer)    (OPAL_DRIVER_DEVICE*)(BASE_CR(OpalDiskPointer, OPAL_DRIVER_DEVICE, OpalDisk))

Definition at line 180 of file OpalDriver.h.

◆ EFI_DRIVER_NAME_UNICODE

#define EFI_DRIVER_NAME_UNICODE   L"1.0 UEFI Opal Driver"

Definition at line 48 of file OpalDriver.h.

◆ LANGUAGE_ISO_639_2_ENGLISH

#define LANGUAGE_ISO_639_2_ENGLISH   ((CHAR8*)"eng")

Definition at line 54 of file OpalDriver.h.

◆ LANGUAGE_RFC_3066_ENGLISH

#define LANGUAGE_RFC_3066_ENGLISH   ((CHAR8*)"en")

Definition at line 51 of file OpalDriver.h.

◆ MAX_ACCEPTABLE_REVERTING_TIME

#define MAX_ACCEPTABLE_REVERTING_TIME   10

Definition at line 78 of file OpalDriver.h.

◆ MAX_PASSWORD_TRY_COUNT

#define MAX_PASSWORD_TRY_COUNT   5

Definition at line 67 of file OpalDriver.h.

◆ MAX_PSID_TRY_COUNT

#define MAX_PSID_TRY_COUNT   5

Definition at line 71 of file OpalDriver.h.

◆ OPAL_MSID_LENGTH

#define OPAL_MSID_LENGTH   128

Definition at line 65 of file OpalDriver.h.

◆ PSID_CHARACTER_LENGTH

#define PSID_CHARACTER_LENGTH   0x20

Definition at line 70 of file OpalDriver.h.

◆ UNICODE_STR

#define UNICODE_STR (   x)    CONCAT( L, x )

Definition at line 59 of file OpalDriver.h.

Typedef Documentation

◆ OPAL_DRIVER_DEVICE

Definition at line 153 of file OpalDriver.h.

Function Documentation

◆ EfiDriverUnload()

EFI_STATUS EFIAPI EfiDriverUnload ( EFI_HANDLE  ImageHandle)

Unloads UEFI Driver. Very useful for debugging and testing.

Parameters
ImageHandleImage handle this driver.
Return values
EFI_SUCCESSThis function always complete successfully.
EFI_INVALID_PARAMETERThe input ImageHandle is not valid.

◆ GetDeviceCount()

UINT8 GetDeviceCount ( VOID  )

Get current device count.

Return values
returnthe current created device count.

Definition at line 2351 of file OpalDriver.c.

◆ OpalDriverGetDeviceList()

OPAL_DRIVER_DEVICE * OpalDriverGetDeviceList ( VOID  )

Get devcie list info.

Return values
returnthe device list pointer.

Definition at line 2375 of file OpalDriver.c.

◆ OpalDriverGetDriverDeviceName()

BOOLEAN OpalDriverGetDriverDeviceName ( OPAL_DRIVER_DEVICE Dev)

Get devcie name through the component name protocol.

Parameters
[in]DevThe device which need to get name.
Return values
TRUEFind the name for this device.
FALSENot found the name for this device.

Definition at line 2581 of file OpalDriver.c.

◆ OpalEfiDriverBindingStart()

EFI_STATUS EFIAPI OpalEfiDriverBindingStart ( EFI_DRIVER_BINDING_PROTOCOL This,
EFI_HANDLE  Controller,
EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Enables Opal Management on a supported device if available.

The start function is designed to be called after the Opal UEFI Driver has confirmed the "controller", which is a child handle, contains the EF_STORAGE_SECURITY_COMMAND protocols. This function will complete the other necessary checks, such as verifying the device supports the correct version of Opal. Upon verification, it will add the device to the Opal HII list in order to expose Opal management options.

Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe handle of the controller to start. This handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathA pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus drivers. For a bus driver, if this parameter is NULL, then handles for all the children of Controller are created by this driver. If this parameter is not NULL and the first Device Path Node is not the End of Device Path Node, then only the handle for the child device specified by the first Device Path Node of RemainingDevicePath is created by this driver. If the first Device Path Node of RemainingDevicePath is the End of Device Path Node, no child handle is created by this driver.
Return values
EFI_SUCCESSOpal management was enabled.
EFI_DEVICE_ERRORThe device could not be started due to a device error.Currently not implemented.
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources.
OthersThe driver failed to start the device.

◆ OpalEfiDriverBindingStop()

EFI_STATUS EFIAPI OpalEfiDriverBindingStop ( EFI_DRIVER_BINDING_PROTOCOL This,
EFI_HANDLE  Controller,
UINTN  NumberOfChildren,
EFI_HANDLE ChildHandleBuffer 
)

Stop this driver on Controller.

Parameters
ThisProtocol instance pointer.
ControllerHandle of device to stop driver on
NumberOfChildrenNumber of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver.
ChildHandleBufferList of Child Handles to Stop.
Return values
EFI_SUCCESSThis driver is removed Controller.
otherThis driver could not be removed from this device.

Definition at line 2947 of file OpalDriver.c.

◆ OpalEfiDriverBindingSupported()

EFI_STATUS EFIAPI OpalEfiDriverBindingSupported ( EFI_DRIVER_BINDING_PROTOCOL This,
EFI_HANDLE  Controller,
EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Test to see if this driver supports Controller.

Parameters
ThisProtocol instance pointer.
ControllerHandleHandle of device to test
RemainingDevicePathOptional parameter use to pick a specific child device to start.
Return values
EFI_SUCCESSThis driver supports this device.
EFI_ALREADY_STARTEDThis driver is already running on this device.
otherThis driver does not support this device.

◆ OpalEfiDriverComponentName2GetControllerName()

EFI_STATUS EFIAPI OpalEfiDriverComponentName2GetControllerName ( EFI_COMPONENT_NAME2_PROTOCOL This,
EFI_HANDLE  ControllerHandle,
EFI_HANDLE  ChildHandle,
CHAR8 *  Language,
CHAR16 **  ControllerName 
)

Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver.

This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle[in]The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned.
ChildHandle[in]The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
ControllerName[out]A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This.
Return values
EFI_SUCCESSThe Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName.
EFI_INVALID_PARAMETERControllerHandle is NULL.
EFI_INVALID_PARAMETERChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERControllerName is NULL.
EFI_UNSUPPORTEDThe driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 381 of file ComponentName.c.

◆ OpalEfiDriverComponentName2GetDriverName()

EFI_STATUS EFIAPI OpalEfiDriverComponentName2GetDriverName ( EFI_COMPONENT_NAME2_PROTOCOL This,
CHAR8 *  Language,
CHAR16 **  DriverName 
)

Retrieves a Unicode string that is the user readable name of the driver.

This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
DriverName[out]A pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERDriverName is NULL.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 133 of file ComponentName.c.

◆ OpalEfiDriverComponentNameGetControllerName()

EFI_STATUS EFIAPI OpalEfiDriverComponentNameGetControllerName ( EFI_COMPONENT_NAME_PROTOCOL This,
EFI_HANDLE  ControllerHandle,
EFI_HANDLE  ChildHandle,
CHAR8 *  Language,
CHAR16 **  ControllerName 
)

Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver.

This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle[in]The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned.
ChildHandle[in]The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
ControllerName[out]A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This.
Return values
EFI_SUCCESSThe Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName.
EFI_INVALID_PARAMETERControllerHandle is NULL.
EFI_INVALID_PARAMETERChildHandle is not NULL and it is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERControllerName is NULL.
EFI_UNSUPPORTEDThe driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 300 of file ComponentName.c.

◆ OpalEfiDriverComponentNameGetDriverName()

EFI_STATUS EFIAPI OpalEfiDriverComponentNameGetDriverName ( EFI_COMPONENT_NAME_PROTOCOL This,
CHAR8 *  Language,
CHAR16 **  DriverName 
)

Retrieves a Unicode string that is the user readable name of the driver.

This function retrieves the user readable name of a driver in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the driver name is returned in DriverName, and EFI_SUCCESS is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned.

Parameters
This[in]A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance.
Language[in]A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format.
DriverName[out]A pointer to the Unicode string to return. This Unicode string is the name of the driver specified by This in the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string for the Driver specified by This and the language specified by Language was returned in DriverName.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERDriverName is NULL.
EFI_UNSUPPORTEDThe driver specified by This does not support the language specified by Language.

Definition at line 77 of file ComponentName.c.

◆ OpalSupportEnableOpalFeature()

TCG_RESULT EFIAPI OpalSupportEnableOpalFeature ( IN OPAL_SESSION Session,
IN VOID *  Msid,
IN UINT32  MsidLength,
IN VOID *  Password,
IN UINT32  PassLength 
)

Enable Opal Feature for the input device.

Parameters
[in]SessionThe opal session for the opal device.
[in]MsidMsid
[in]MsidLengthMsid Length
[in]PasswordAdmin password
[in]PassLengthLength of password in bytes

Definition at line 138 of file OpalDriver.c.

◆ OpalSupportGetAvailableActions()

TCG_RESULT EFIAPI OpalSupportGetAvailableActions ( IN OPAL_DISK_SUPPORT_ATTRIBUTE SupportedAttributes,
IN TCG_LOCKING_FEATURE_DESCRIPTOR LockingFeature,
IN UINT16  OwnerShip,
OUT OPAL_DISK_ACTIONS AvalDiskActions 
)

The function performs determines the available actions for the OPAL_DISK provided.

Parameters
[in]SupportedAttributesThe support attribute for the device.
[in]LockingFeatureThe locking status for the device.
[in]OwnerShipThe ownership for the device.
[out]AvalDiskActionsPointer to fill-out with appropriate disk actions.

The function determines the available actions for the OPAL_DISK provided.

Parameters
[in]SupportedAttributesThe supported attributes for the device.
[in]LockingFeatureThe locking status for the device.
[in]OwnerShipThe ownership for the device.
[out]AvalDiskActionsPointer to fill-out with appropriate disk actions.

Definition at line 51 of file OpalDriver.c.

◆ OpalSupportUpdatePassword()

VOID OpalSupportUpdatePassword ( IN OUT OPAL_DISK OpalDisk,
IN VOID *  Password,
IN UINT32  PasswordLength 
)

Update password for the Opal disk.

Parameters
[in,out]OpalDiskThe disk to update password.
[in]PasswordThe input password.
[in]PasswordLengthThe input password length.

Definition at line 189 of file OpalDriver.c.

Variable Documentation

◆ gOpalComponentName

EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName
extern

Definition at line 14 of file ComponentName.c.

◆ gOpalComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2
extern

Definition at line 23 of file ComponentName.c.

◆ gOpalDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding
extern

Definition at line 30 of file OpalDriver.c.