TianoCore EDK2 master
Loading...
Searching...
No Matches
OpalDriver.c File Reference
#include "OpalDriver.h"
#include "OpalHii.h"

Go to the source code of this file.

Functions

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)
 
VOID OpalSupportUpdatePassword (IN OUT OPAL_DISK *OpalDisk, IN VOID *Password, IN UINT32 PasswordLength)
 
VOID ExtractDeviceInfoFromDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINT32 *DevInfoLength, OUT OPAL_DEVICE_LOCKBOX_DATA *DevInfo OPTIONAL)
 
VOID BuildOpalDeviceInfo (VOID)
 
VOID SendBlockSidCommand (VOID)
 
VOID EFIAPI OpalEndOfDxeEventNotify (EFI_EVENT Event, VOID *Context)
 
CHAR8 * OpalDriverPopUpPsidInput (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *PopUpString, IN CHAR16 *PopUpString2, IN CHAR16 *PopUpString3, OUT BOOLEAN *PressEsc)
 
CHAR8 * OpalDriverPopUpPasswordInput (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *PopUpString1, IN CHAR16 *PopUpString2, IN CHAR16 *PopUpString3, OUT BOOLEAN *PressEsc)
 
CHAR16 * OpalGetPopUpString (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID OpalDriverRequestPassword (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestEnableFeature (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestDisableUser (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestPsidRevert (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestRevert (IN OPAL_DRIVER_DEVICE *Dev, IN BOOLEAN KeepUserData, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestSecureErase (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestSetUserPwd (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequestSetAdminPwd (IN OPAL_DRIVER_DEVICE *Dev, IN CHAR16 *RequestString)
 
VOID ProcessOpalRequest (IN OPAL_DRIVER_DEVICE *Dev)
 
VOID AddDeviceToTail (IN OPAL_DRIVER_DEVICE *Dev)
 
VOID RemoveDevice (IN OPAL_DRIVER_DEVICE *Dev)
 
UINT8 GetDeviceCount (VOID)
 
OPAL_DRIVER_DEVICEOpalDriverGetDeviceList (VOID)
 
VOID OpalDriverStopDevice (OPAL_DRIVER_DEVICE *Dev)
 
BOOLEAN OpalDriverGetDeviceNameByProtocol (EFI_HANDLE *AllHandlesBuffer, UINTN NumAllHandles, OPAL_DRIVER_DEVICE *Dev, BOOLEAN UseComp1)
 
BOOLEAN OpalDriverGetDriverDeviceName (OPAL_DRIVER_DEVICE *Dev)
 
EFI_STATUS EFIAPI EfiDriverEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI OpalEfiDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI OpalEfiDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN 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 OpalEfiDriverUnload (IN EFI_HANDLE ImageHandle)
 

Variables

EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID
 
BOOLEAN mOpalEndOfDxe = FALSE
 
OPAL_REQUEST_VARIABLEmOpalRequestVariable = NULL
 
UINTN mOpalRequestVariableSize = 0
 
CHAR16 mPopUpString [100]
 
OPAL_DRIVER mOpalDriver
 
EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding
 

Detailed Description

Entrypoint of Opal UEFI Driver and contains all the logic to register for new Opal device instances.

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

Definition in file OpalDriver.c.

Function Documentation

◆ AddDeviceToTail()

VOID AddDeviceToTail ( IN OPAL_DRIVER_DEVICE Dev)

Add new device to the global device list.

Parameters
DevNew create device.

Definition at line 2295 of file OpalDriver.c.

◆ BuildOpalDeviceInfo()

VOID BuildOpalDeviceInfo ( VOID  )

Build OPAL device info and save them to LockBox.

Definition at line 288 of file OpalDriver.c.

◆ EfiDriverEntryPoint()

EFI_STATUS EFIAPI EfiDriverEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Main entry for this driver.

Parameters
ImageHandleImage Handle this driver.
SystemTablePointer to SystemTable.
Return values
EFI_SUCCESSThis function always complete successfully.

Definition at line 2639 of file OpalDriver.c.

◆ ExtractDeviceInfoFromDevicePath()

VOID ExtractDeviceInfoFromDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath,
OUT UINT32 *  DevInfoLength,
OUT OPAL_DEVICE_LOCKBOX_DATA *DevInfo  OPTIONAL 
)

Extract device info from the device path.

Parameters
[in]DevicePathDevice path info for the device.
[out]DevInfoLengthDevice information length needed.
[out]DevInfoDevice information extracted.

Definition at line 208 of file OpalDriver.c.

◆ 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.

◆ OpalDriverGetDeviceNameByProtocol()

BOOLEAN OpalDriverGetDeviceNameByProtocol ( EFI_HANDLE AllHandlesBuffer,
UINTN  NumAllHandles,
OPAL_DRIVER_DEVICE Dev,
BOOLEAN  UseComp1 
)

Get devcie name through the component name protocol.

Parameters
[in]AllHandlesBufferThe handle buffer for current system.
[in]NumAllHandlesThe number of handles for the handle buffer.
[in]DevThe device which need to get name.
[in]UseComp1Whether use component name or name2 protocol.
Return values
TRUEFind the name for this device.
FALSENot found the name for this device.

Definition at line 2436 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.

◆ OpalDriverPopUpPasswordInput()

CHAR8 * OpalDriverPopUpPasswordInput ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  PopUpString1,
IN CHAR16 *  PopUpString2,
IN CHAR16 *  PopUpString3,
OUT BOOLEAN *  PressEsc 
)

Get password input from the popup window.

Parameters
[in]DevThe device which need password to unlock or process OPAL request.
[in]PopUpString1Pop up string 1.
[in]PopUpString2Pop up string 2.
[in]PopUpString3Pop up string 3.
[out]PressEscWhether user escape function through Press ESC.
Return values
Passwordstring if success. NULL if failed.

Definition at line 708 of file OpalDriver.c.

◆ OpalDriverPopUpPsidInput()

CHAR8 * OpalDriverPopUpPsidInput ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  PopUpString,
IN CHAR16 *  PopUpString2,
IN CHAR16 *  PopUpString3,
OUT BOOLEAN *  PressEsc 
)

Get Psid input from the popup window.

Parameters
[in]DevThe device which need Psid to process Psid Revert OPAL request.
[in]PopUpStringPop up string.
[in]PopUpString2Pop up string in line 2.
[in]PopUpString3Pop up string in line 3.
[out]PressEscWhether user escape function through Press ESC.
Return values
Psidstring if success. NULL if failed.

Definition at line 556 of file OpalDriver.c.

◆ OpalDriverRequestPassword()

VOID OpalDriverRequestPassword ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Check if disk is locked, show popup window and ask for password if it is.

Parameters
[in]DevThe device which need to be unlocked.
[in]RequestStringRequest string.

Definition at line 875 of file OpalDriver.c.

◆ OpalDriverStopDevice()

VOID OpalDriverStopDevice ( OPAL_DRIVER_DEVICE Dev)

Stop this Controller.

Parameters
DevThe device need to be stopped.

Definition at line 2389 of file OpalDriver.c.

◆ OpalEfiDriverBindingStart()

EFI_STATUS EFIAPI OpalEfiDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN 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.

Definition at line 2790 of file OpalDriver.c.

◆ 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 ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Tests to see if this driver supports a given controller.

This function checks to see if the controller contains an instance of the EFI_STORAGE_SECURITY_COMMAND_PROTOCOL and the EFI_BLOCK_IO_PROTOCOL and returns EFI_SUCCESS if it does.

Parameters
[in]ThisA pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
[in]ControllerHandleThe Handle of the controller to test. This Handle must support a protocol interface that supplies an I/O abstraction to the driver.
[in]RemainingDevicePathThis parameter is ignored.
Return values
EFI_SUCCESSThe device contains required protocols
EFI_ALREADY_STARTEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This.
EFI_ACCESS_DENIEDThe device specified by ControllerHandle and RemainingDevicePath is already being managed by a different driver or an application that requires exclusive access. Currently not implemented.
EFI_UNSUPPORTEDThe device does not contain requires protocols

Definition at line 2711 of file OpalDriver.c.

◆ OpalEfiDriverUnload()

EFI_STATUS EFIAPI OpalEfiDriverUnload ( IN 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.

Definition at line 2983 of file OpalDriver.c.

◆ OpalEndOfDxeEventNotify()

VOID EFIAPI OpalEndOfDxeEventNotify ( EFI_EVENT  Event,
VOID *  Context 
)

Notification function of EFI_END_OF_DXE_EVENT_GROUP_GUID event group.

This is a notification function registered on EFI_END_OF_DXE_EVENT_GROUP_GUID event group.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 491 of file OpalDriver.c.

◆ OpalGetPopUpString()

CHAR16 * OpalGetPopUpString ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Get pop up string.

Parameters
[in]DevThe OPAL device.
[in]RequestStringRequest string.
Returns
Pop up string.

Definition at line 853 of file OpalDriver.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 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.

◆ ProcessOpalRequest()

VOID ProcessOpalRequest ( IN OPAL_DRIVER_DEVICE Dev)

Process OPAL request.

Parameters
[in]DevThe device which has OPAL request.

Definition at line 2175 of file OpalDriver.c.

◆ ProcessOpalRequestDisableUser()

VOID ProcessOpalRequestDisableUser ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Disable User OPAL request.

Parameters
[in]DevThe device which has Disable User OPAL request.
[in]RequestStringRequest string.

Definition at line 1211 of file OpalDriver.c.

◆ ProcessOpalRequestEnableFeature()

VOID ProcessOpalRequestEnableFeature ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Enable Feature OPAL request.

Parameters
[in]DevThe device which has Enable Feature OPAL request.
[in]RequestStringRequest string.

Definition at line 1061 of file OpalDriver.c.

◆ ProcessOpalRequestPsidRevert()

VOID ProcessOpalRequestPsidRevert ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Psid Revert OPAL request.

Parameters
[in]DevThe device which has Psid Revert OPAL request.
[in]RequestStringRequest string.

Definition at line 1325 of file OpalDriver.c.

◆ ProcessOpalRequestRevert()

VOID ProcessOpalRequestRevert ( IN OPAL_DRIVER_DEVICE Dev,
IN BOOLEAN  KeepUserData,
IN CHAR16 *  RequestString 
)

Process Admin Revert OPAL request.

Parameters
[in]DevThe device which has Revert OPAL request.
[in]KeepUserDataWhether to keep user data or not.
[in]RequestStringRequest string.

Definition at line 1462 of file OpalDriver.c.

◆ ProcessOpalRequestSecureErase()

VOID ProcessOpalRequestSecureErase ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Secure Erase OPAL request.

Parameters
[in]DevThe device which has Secure Erase OPAL request.
[in]RequestStringRequest string.

Definition at line 1631 of file OpalDriver.c.

◆ ProcessOpalRequestSetAdminPwd()

VOID ProcessOpalRequestSetAdminPwd ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Set Admin Pwd OPAL request.

Parameters
[in]DevThe device which has Set Admin Pwd Feature OPAL request.
[in]RequestStringRequest string.

Definition at line 1975 of file OpalDriver.c.

◆ ProcessOpalRequestSetUserPwd()

VOID ProcessOpalRequestSetUserPwd ( IN OPAL_DRIVER_DEVICE Dev,
IN CHAR16 *  RequestString 
)

Process Set Admin Pwd OPAL request.

Parameters
[in]DevThe device which has Set Admin Pwd Feature OPAL request.
[in]RequestStringRequest string.

Definition at line 1769 of file OpalDriver.c.

◆ RemoveDevice()

VOID RemoveDevice ( IN OPAL_DRIVER_DEVICE Dev)

Remove one device in the global device list.

Parameters
DevThe device need to be removed.

Definition at line 2320 of file OpalDriver.c.

◆ SendBlockSidCommand()

VOID SendBlockSidCommand ( VOID  )

Send BlockSid command if needed.

Definition at line 440 of file OpalDriver.c.

Variable Documentation

◆ gOpalDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding
Initial value:
= {
0x1b,
}
#define NULL
Definition: Base.h:319
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(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: OpalDriver.c:2790
EFI_STATUS EFIAPI OpalEfiDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: OpalDriver.c:2711

Definition at line 30 of file OpalDriver.c.

◆ mOpalDeviceLockBoxGuid

EFI_GUID mOpalDeviceLockBoxGuid = OPAL_DEVICE_LOCKBOX_GUID

Definition at line 18 of file OpalDriver.c.

◆ mOpalDriver

OPAL_DRIVER mOpalDriver

Definition at line 25 of file OpalDriver.c.

◆ mOpalEndOfDxe

BOOLEAN mOpalEndOfDxe = FALSE

Definition at line 20 of file OpalDriver.c.

◆ mOpalRequestVariable

OPAL_REQUEST_VARIABLE* mOpalRequestVariable = NULL

Definition at line 21 of file OpalDriver.c.

◆ mOpalRequestVariableSize

UINTN mOpalRequestVariableSize = 0

Definition at line 22 of file OpalDriver.c.

◆ mPopUpString

CHAR16 mPopUpString[100]

Definition at line 23 of file OpalDriver.c.