2 Entrypoint of Opal UEFI Driver and contains all the logic to
3 register for new Opal device instances.
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 // This UEFI driver consumes EFI_STORAGE_SECURITY_PROTOCOL instances and installs an
17 // HII GUI to manage Opal features if the device is Opal capable
18 // If the Opal device is being managed by the UEFI Driver, it shall provide a popup
19 // window during boot requesting a user password
21 #include "OpalDriver.h"
22 #include "OpalDriverPrivate.h"
25 OPAL_DRIVER mOpalDriver
;
27 #define MAX_PASSWORD_SIZE 32
28 #define MAX_PASSWORD_TRY_COUNT 5
33 EFI_DRIVER_BINDING_PROTOCOL gOpalDriverBinding
= {
34 OpalEfiDriverBindingSupported
,
35 OpalEfiDriverBindingStart
,
36 OpalEfiDriverBindingStop
,
44 Add new device to the global device list.
46 @param Dev New create device.
51 IN OPAL_DRIVER_DEVICE
*Dev
54 OPAL_DRIVER_DEVICE
*TmpDev
;
56 if (mOpalDriver
.DeviceList
== NULL
) {
57 mOpalDriver
.DeviceList
= Dev
;
59 TmpDev
= mOpalDriver
.DeviceList
;
60 while (TmpDev
->Next
!= NULL
) {
61 TmpDev
= TmpDev
->Next
;
69 Remove one device in the global device list.
71 @param Dev The device need to be removed.
76 IN OPAL_DRIVER_DEVICE
*Dev
79 OPAL_DRIVER_DEVICE
*TmpDev
;
81 if (mOpalDriver
.DeviceList
== NULL
) {
85 if (mOpalDriver
.DeviceList
== Dev
) {
86 mOpalDriver
.DeviceList
= NULL
;
90 TmpDev
= mOpalDriver
.DeviceList
;
91 while (TmpDev
->Next
!= NULL
) {
92 if (TmpDev
->Next
== Dev
) {
93 TmpDev
->Next
= Dev
->Next
;
100 Get current device count.
102 @retval return the current created device count.
111 OPAL_DRIVER_DEVICE
*TmpDev
;
114 TmpDev
= mOpalDriver
.DeviceList
;
116 while (TmpDev
!= NULL
) {
118 TmpDev
= TmpDev
->Next
;
125 Get password input from the popup windows, and unlock the device.
127 @param[in] Dev The device which need to be unlock.
128 @param[out] PressEsc Whether user escape function through Press ESC.
130 @retval Password string if success. NULL if failed.
134 OpalDriverPopUpHddPassword (
135 IN OPAL_DRIVER_DEVICE
*Dev
,
136 OUT BOOLEAN
*PressEsc
139 EFI_INPUT_KEY InputKey
;
141 CHAR16 Mask
[MAX_PASSWORD_SIZE
+ 1];
142 CHAR16 Unicode
[MAX_PASSWORD_SIZE
+ 1];
147 ZeroMem(Unicode
, sizeof(Unicode
));
148 ZeroMem(Mask
, sizeof(Mask
));
150 StrLength
= StrLen(Dev
->Name16
);
151 PopUpString
= (CHAR16
*) AllocateZeroPool ((8 + StrLength
) * 2);
154 if (Dev
->Name16
== NULL
) {
155 UnicodeSPrint(PopUpString
, StrLen(L
"Unlock Disk") + 1, L
"Unlock Disk");
157 UnicodeSPrint(PopUpString
, StrLen(L
"Unlock ") + StrLength
+ 1, L
"Unlock %s", Dev
->Name16
);
160 gST
->ConOut
->ClearScreen(gST
->ConOut
);
164 Mask
[InputLength
] = L
'_';
166 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
169 L
"---------------------",
177 if (InputKey
.ScanCode
== SCAN_NULL
) {
181 if (InputKey
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
183 // Add the null terminator.
185 Unicode
[InputLength
] = 0;
188 } else if ((InputKey
.UnicodeChar
== CHAR_NULL
) ||
189 (InputKey
.UnicodeChar
== CHAR_TAB
) ||
190 (InputKey
.UnicodeChar
== CHAR_LINEFEED
)
195 // delete last key entered
197 if (InputKey
.UnicodeChar
== CHAR_BACKSPACE
) {
198 if (InputLength
> 0) {
199 Unicode
[InputLength
] = 0;
200 Mask
[InputLength
] = 0;
205 // add Next key entry
207 Unicode
[InputLength
] = InputKey
.UnicodeChar
;
208 Mask
[InputLength
] = L
'*';
210 if (InputLength
== MAX_PASSWORD_SIZE
) {
212 // Add the null terminator.
214 Unicode
[InputLength
] = 0;
215 Mask
[InputLength
] = 0;
225 if (InputKey
.ScanCode
== SCAN_ESC
) {
231 gST
->ConOut
->ClearScreen(gST
->ConOut
);
233 if (InputLength
== 0 || InputKey
.ScanCode
== SCAN_ESC
) {
237 Ascii
= AllocateZeroPool (MAX_PASSWORD_SIZE
+ 1);
242 UnicodeStrToAsciiStrS (Unicode
, Ascii
, MAX_PASSWORD_SIZE
+ 1);
248 Check if disk is locked, show popup window and ask for password if it is
250 @param[in] Dev The device which need to be unlock.
254 OpalDriverRequestPassword (
255 OPAL_DRIVER_DEVICE
*Dev
264 OPAL_SESSION Session
;
274 IsEnabled
= OpalFeatureEnabled (&Dev
->OpalDisk
.SupportedAttributes
, &Dev
->OpalDisk
.LockingFeature
);
276 ZeroMem(&Session
, sizeof(Session
));
277 Session
.Sscp
= Dev
->OpalDisk
.Sscp
;
278 Session
.MediaId
= Dev
->OpalDisk
.MediaId
;
279 Session
.OpalBaseComId
= Dev
->OpalDisk
.OpalBaseComId
;
281 Locked
= OpalDeviceLocked (&Dev
->OpalDisk
.SupportedAttributes
, &Dev
->OpalDisk
.LockingFeature
);
283 while (Count
< MAX_PASSWORD_TRY_COUNT
) {
284 Password
= OpalDriverPopUpHddPassword (Dev
, &PressEsc
);
288 // Current device in the lock status and
289 // User not input password and press ESC,
290 // keep device in lock status and continue boot.
294 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
296 L
"Press ENTER to skip password, Press ESC to input password",
299 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
301 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
302 gST
->ConOut
->ClearScreen(gST
->ConOut
);
304 // Keep lock and continue boot.
309 // Let user input password again.
315 // Current device in the unlock status and
316 // User not input password and press ESC,
317 // Shutdown the device.
321 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
323 L
"Press ENTER to shutdown, Press ESC to input password",
326 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
328 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
329 gRT
->ResetSystem (EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
332 // Let user input password again.
339 if (Password
== NULL
) {
343 PasswordLen
= (UINT32
) AsciiStrLen(Password
);
346 Ret
= OpalSupportUnlock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
348 Ret
= OpalSupportLock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
349 if (Ret
== TcgResultSuccess
) {
350 Ret
= OpalSupportUnlock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
354 if (Password
!= NULL
) {
355 ZeroMem (Password
, PasswordLen
);
359 if (Ret
== TcgResultSuccess
) {
367 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
369 L
"Invalid password.",
370 L
"Press ENTER to retry",
373 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
376 if (Count
>= MAX_PASSWORD_TRY_COUNT
) {
379 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
381 L
"Opal password retry count exceeds the limit. Must shutdown!",
382 L
"Press ENTER to shutdown",
385 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
387 gRT
->ResetSystem (EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
393 Get devcie list info.
395 @retval return the device list pointer.
398 OpalDriverGetDeviceList(
402 return mOpalDriver
.DeviceList
;
406 ReadyToBoot callback to send BlockSid command.
408 @param Event Pointer to this event
409 @param Context Event hanlder private Data
414 ReadyToBootCallback (
420 OPAL_DRIVER_DEVICE
* Itr
;
422 OPAL_EXTRA_INFO_VAR OpalExtraInfo
;
424 OPAL_SESSION Session
;
426 gBS
->CloseEvent (Event
);
428 DataSize
= sizeof (OPAL_EXTRA_INFO_VAR
);
429 Status
= gRT
->GetVariable (
430 OPAL_EXTRA_INFO_VAR_NAME
,
431 &gOpalExtraInfoVariableGuid
,
436 if (EFI_ERROR (Status
)) {
440 if (OpalExtraInfo
.EnableBlockSid
== TRUE
) {
442 // Send BlockSID command to each Opal disk
444 Itr
= mOpalDriver
.DeviceList
;
445 while (Itr
!= NULL
) {
446 if (Itr
->OpalDisk
.SupportedAttributes
.BlockSid
) {
447 ZeroMem(&Session
, sizeof(Session
));
448 Session
.Sscp
= Itr
->OpalDisk
.Sscp
;
449 Session
.MediaId
= Itr
->OpalDisk
.MediaId
;
450 Session
.OpalBaseComId
= Itr
->OpalDisk
.OpalBaseComId
;
452 Result
= OpalBlockSid (&Session
, TRUE
); // HardwareReset must always be TRUE
453 if (Result
!= TcgResultSuccess
) {
454 DEBUG ((DEBUG_ERROR
, "OpalBlockSid fail\n"));
465 Stop this Controller.
467 @param Dev The device need to be stopped.
471 OpalDriverStopDevice (
472 OPAL_DRIVER_DEVICE
*Dev
478 FreePool(Dev
->Name16
);
481 // remove OPAL_DRIVER_DEVICE from the list
482 // it updates the controllerList pointer
487 // close protocols that were opened
491 &gEfiStorageSecurityCommandProtocolGuid
,
492 gOpalDriverBinding
.DriverBindingHandle
,
498 &gEfiBlockIoProtocolGuid
,
499 gOpalDriverBinding
.DriverBindingHandle
,
507 Get devcie name through the component name protocol.
509 @param[in] AllHandlesBuffer The handle buffer for current system.
510 @param[in] NumAllHandles The number of handles for the handle buffer.
511 @param[in] Dev The device which need to get name.
512 @param[in] UseComp1 Whether use component name or name2 protocol.
514 @retval TRUE Find the name for this device.
515 @retval FALSE Not found the name for this device.
518 OpalDriverGetDeviceNameByProtocol(
519 EFI_HANDLE
*AllHandlesBuffer
,
521 OPAL_DRIVER_DEVICE
*Dev
,
525 EFI_HANDLE
* ProtocolHandlesBuffer
;
526 UINTN NumProtocolHandles
;
528 EFI_COMPONENT_NAME2_PROTOCOL
* Cnp1_2
; // efi component name and componentName2 have same layout
531 EFI_DEVICE_PATH_PROTOCOL
* TmpDevPath
;
534 EFI_HANDLE TmpHandle
;
537 if (Dev
== NULL
|| AllHandlesBuffer
== NULL
|| NumAllHandles
== 0) {
541 Protocol
= UseComp1
? gEfiComponentNameProtocolGuid
: gEfiComponentName2ProtocolGuid
;
544 // Find all EFI_HANDLES with protocol
546 Status
= gBS
->LocateHandleBuffer(
551 &ProtocolHandlesBuffer
553 if (EFI_ERROR(Status
)) {
559 // Exit early if no supported devices
561 if (NumProtocolHandles
== 0) {
566 // Get printable name by iterating through all protocols
567 // using the handle as the child, and iterate through all handles for the controller
568 // exit loop early once found, if not found, then delete device
569 // storage security protocol instances already exist, add them to internal list
571 Status
= EFI_DEVICE_ERROR
;
572 for (Index1
= 0; Index1
< NumProtocolHandles
; Index1
++) {
575 if (Dev
->Name16
!= NULL
) {
579 TmpHandle
= ProtocolHandlesBuffer
[Index1
];
581 Status
= gBS
->OpenProtocol(
587 EFI_OPEN_PROTOCOL_GET_PROTOCOL
589 if (EFI_ERROR(Status
) || Cnp1_2
== NULL
) {
594 // Use all handles array as controller handle
596 for (Index2
= 0; Index2
< NumAllHandles
; Index2
++) {
597 Status
= Cnp1_2
->GetControllerName(
599 AllHandlesBuffer
[Index2
],
601 LANGUAGE_ISO_639_2_ENGLISH
,
604 if (EFI_ERROR(Status
)) {
605 Status
= Cnp1_2
->GetControllerName(
607 AllHandlesBuffer
[Index2
],
609 LANGUAGE_RFC_3066_ENGLISH
,
613 if (!EFI_ERROR(Status
) && DevName
!= NULL
) {
614 StrLength
= StrLen(DevName
) + 1; // Add one for NULL terminator
615 Dev
->Name16
= AllocateZeroPool(StrLength
* sizeof (CHAR16
));
616 ASSERT (Dev
->Name16
!= NULL
);
617 StrCpyS (Dev
->Name16
, StrLength
, DevName
);
618 Dev
->NameZ
= (CHAR8
*)AllocateZeroPool(StrLength
);
619 UnicodeStrToAsciiStrS (DevName
, Dev
->NameZ
, StrLength
);
622 // Retrieve bridge BDF info and port number or namespace depending on type
625 Status
= gBS
->OpenProtocol(
627 &gEfiDevicePathProtocolGuid
,
631 EFI_OPEN_PROTOCOL_GET_PROTOCOL
633 if (!EFI_ERROR(Status
)) {
634 Dev
->OpalDevicePath
= DuplicateDevicePath (TmpDevPath
);
638 if (Dev
->Name16
!= NULL
) {
639 FreePool(Dev
->Name16
);
642 if (Dev
->NameZ
!= NULL
) {
643 FreePool(Dev
->NameZ
);
654 Get devcie name through the component name protocol.
656 @param[in] Dev The device which need to get name.
658 @retval TRUE Find the name for this device.
659 @retval FALSE Not found the name for this device.
662 OpalDriverGetDriverDeviceName(
663 OPAL_DRIVER_DEVICE
*Dev
666 EFI_HANDLE
* AllHandlesBuffer
;
671 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "OpalDriverGetDriverDeviceName Exiting, Dev=NULL\n"));
676 // Iterate through ComponentName2 handles to get name, if fails, try ComponentName
678 if (Dev
->Name16
== NULL
) {
679 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "Name is null, update it\n"));
681 // Find all EFI_HANDLES
683 Status
= gBS
->LocateHandleBuffer(
690 if (EFI_ERROR(Status
)) {
691 DEBUG ((DEBUG_INFO
, "LocateHandleBuffer for AllHandles failed %r\n", Status
));
696 // Try component Name2
698 if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer
, NumAllHandles
, Dev
, FALSE
)) {
699 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "ComponentName2 failed to get device name, try ComponentName\n"));
700 if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer
, NumAllHandles
, Dev
, TRUE
)) {
701 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "ComponentName failed to get device name, skip device\n"));
711 Main entry for this driver.
713 @param ImageHandle Image Handle this driver.
714 @param SystemTable Pointer to SystemTable.
716 @retval EFI_SUCESS This function always complete successfully.
721 IN EFI_HANDLE ImageHandle
,
722 IN EFI_SYSTEM_TABLE
* SystemTable
726 EFI_EVENT ReadyToBootEvent
;
728 Status
= EfiLibInstallDriverBindingComponentName2 (
737 if (EFI_ERROR(Status
)) {
738 DEBUG((DEBUG_ERROR
, "Install protocols to Opal driver Handle failed\n"));
743 // Initialize Driver object
745 ZeroMem(&mOpalDriver
, sizeof(mOpalDriver
));
746 mOpalDriver
.Handle
= ImageHandle
;
749 // register a ReadyToBoot event callback for sending BlockSid command
751 Status
= EfiCreateEventReadyToBootEx (
754 (VOID
*) &ImageHandle
,
759 // Install Hii packages.
767 Tests to see if this driver supports a given controller.
769 This function checks to see if the controller contains an instance of the
770 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL and the EFI_BLOCK_IO_PROTOCL
771 and returns EFI_SUCCESS if it does.
773 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
774 @param[in] ControllerHandle The Handle of the controller to test. This Handle
775 must support a protocol interface that supplies
776 an I/O abstraction to the driver.
777 @param[in] RemainingDevicePath This parameter is ignored.
779 @retval EFI_SUCCESS The device contains required protocols
780 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
781 RemainingDevicePath is already being managed by the driver
783 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
784 RemainingDevicePath is already being managed by a different
785 driver or an application that requires exclusive access.
786 Currently not implemented.
787 @retval EFI_UNSUPPORTED The device does not contain requires protocols
792 OpalEfiDriverBindingSupported(
793 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
794 IN EFI_HANDLE Controller
,
795 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath
799 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
* SecurityCommand
;
800 EFI_BLOCK_IO_PROTOCOL
* BlkIo
;
803 // Test EFI_STORAGE_SECURITY_COMMAND_PROTOCOL on controller Handle.
805 Status
= gBS
->OpenProtocol(
807 &gEfiStorageSecurityCommandProtocolGuid
,
808 ( VOID
** )&SecurityCommand
,
809 This
->DriverBindingHandle
,
811 EFI_OPEN_PROTOCOL_BY_DRIVER
814 if (Status
== EFI_ALREADY_STARTED
) {
818 if (EFI_ERROR(Status
)) {
823 // Close protocol and reopen in Start call
827 &gEfiStorageSecurityCommandProtocolGuid
,
828 This
->DriverBindingHandle
,
833 // Test EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
836 Status
= gBS
->OpenProtocol(
838 &gEfiBlockIoProtocolGuid
,
840 This
->DriverBindingHandle
,
842 EFI_OPEN_PROTOCOL_BY_DRIVER
845 if (EFI_ERROR(Status
)) {
846 DEBUG((DEBUG_INFO
, "No EFI_BLOCK_IO_PROTOCOL on controller\n"));
851 // Close protocol and reopen in Start call
855 &gEfiBlockIoProtocolGuid
,
856 This
->DriverBindingHandle
,
864 Enables Opal Management on a supported device if available.
866 The start function is designed to be called after the Opal UEFI Driver has confirmed the
867 "controller", which is a child Handle, contains the EF_STORAGE_SECURITY_COMMAND protocols.
868 This function will complete the other necessary checks, such as verifying the device supports
869 the correct version of Opal. Upon verification, it will add the device to the
870 Opal HII list in order to expose Opal managmeent options.
872 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
873 @param[in] ControllerHandle The Handle of the controller to start. This Handle
874 must support a protocol interface that supplies
875 an I/O abstraction to the driver.
876 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
877 parameter is ignored by device drivers, and is optional for bus
878 drivers. For a bus driver, if this parameter is NULL, then handles
879 for all the children of Controller are created by this driver.
880 If this parameter is not NULL and the first Device Path Node is
881 not the End of Device Path Node, then only the Handle for the
882 child device specified by the first Device Path Node of
883 RemainingDevicePath is created by this driver.
884 If the first Device Path Node of RemainingDevicePath is
885 the End of Device Path Node, no child Handle is created by this
888 @retval EFI_SUCCESS Opal management was enabled.
889 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
890 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
891 @retval Others The driver failed to start the device.
896 OpalEfiDriverBindingStart(
897 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
898 IN EFI_HANDLE Controller
,
899 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath
903 EFI_BLOCK_IO_PROTOCOL
*BlkIo
;
904 OPAL_DRIVER_DEVICE
*Dev
;
905 OPAL_DRIVER_DEVICE
*Itr
;
908 Itr
= mOpalDriver
.DeviceList
;
909 while (Itr
!= NULL
) {
910 if (Controller
== Itr
->Handle
) {
917 // Create internal device for tracking. This allows all disks to be tracked
920 Dev
= (OPAL_DRIVER_DEVICE
*)AllocateZeroPool(sizeof(OPAL_DRIVER_DEVICE
));
922 return EFI_OUT_OF_RESOURCES
;
924 Dev
->Handle
= Controller
;
927 // Open EFI_STORAGE_SECURITY_COMMAND_PROTOCOL to perform Opal supported checks
929 Status
= gBS
->OpenProtocol(
931 &gEfiStorageSecurityCommandProtocolGuid
,
933 This
->DriverBindingHandle
,
935 EFI_OPEN_PROTOCOL_BY_DRIVER
937 if (EFI_ERROR(Status
)) {
943 // Open EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
946 Status
= gBS
->OpenProtocol(
948 &gEfiBlockIoProtocolGuid
,
950 This
->DriverBindingHandle
,
952 EFI_OPEN_PROTOCOL_BY_DRIVER
954 if (EFI_ERROR(Status
)) {
956 // Close storage security that was opened
960 &gEfiStorageSecurityCommandProtocolGuid
,
961 This
->DriverBindingHandle
,
972 Dev
->MediaId
= BlkIo
->Media
->MediaId
;
976 &gEfiBlockIoProtocolGuid
,
977 This
->DriverBindingHandle
,
982 // Acquire Ascii printable name of child, if not found, then ignore device
984 Result
= OpalDriverGetDriverDeviceName (Dev
);
989 Status
= OpalDiskInitialize (Dev
);
990 if (EFI_ERROR (Status
)) {
994 AddDeviceToTail(Dev
);
997 // check if device is locked and prompt for password
999 OpalDriverRequestPassword (Dev
);
1005 // free device, close protocols and exit
1009 &gEfiStorageSecurityCommandProtocolGuid
,
1010 This
->DriverBindingHandle
,
1016 return EFI_DEVICE_ERROR
;
1020 Stop this driver on Controller.
1022 @param This Protocol instance pointer.
1023 @param Controller Handle of device to stop driver on
1024 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1025 children is zero stop the entire bus driver.
1026 @param ChildHandleBuffer List of Child Handles to Stop.
1028 @retval EFI_SUCCESS This driver is removed Controller.
1029 @retval other This driver could not be removed from this device.
1034 OpalEfiDriverBindingStop(
1035 EFI_DRIVER_BINDING_PROTOCOL
* This
,
1036 EFI_HANDLE Controller
,
1037 UINTN NumberOfChildren
,
1038 EFI_HANDLE
* ChildHandleBuffer
1041 OPAL_DRIVER_DEVICE
* Itr
;
1043 Itr
= mOpalDriver
.DeviceList
;
1046 // does Controller match any of the devices we are managing for Opal
1048 while (Itr
!= NULL
) {
1049 if (Itr
->Handle
== Controller
) {
1050 OpalDriverStopDevice (Itr
);
1057 return EFI_NOT_FOUND
;
1062 Unloads UEFI Driver. Very useful for debugging and testing.
1064 @param ImageHandle Image Handle this driver.
1066 @retval EFI_SUCCESS This function always complete successfully.
1067 @retval EFI_INVALID_PARAMETER The input ImageHandle is not valid.
1071 OpalEfiDriverUnload (
1072 IN EFI_HANDLE ImageHandle
1076 OPAL_DRIVER_DEVICE
*Itr
;
1078 Status
= EFI_SUCCESS
;
1080 if (ImageHandle
!= gImageHandle
) {
1081 return (EFI_INVALID_PARAMETER
);
1085 // Uninstall any interface added to each device by us
1087 while (mOpalDriver
.DeviceList
) {
1088 Itr
= mOpalDriver
.DeviceList
;
1090 // Remove OPAL_DRIVER_DEVICE from the list
1091 // it updates the controllerList pointer
1093 OpalDriverStopDevice(Itr
);
1097 // Uninstall the HII capability
1099 Status
= HiiUninstall();