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);
243 ZeroMem (Unicode
, sizeof (Unicode
));
249 Check if disk is locked, show popup window and ask for password if it is
251 @param[in] Dev The device which need to be unlock.
255 OpalDriverRequestPassword (
256 OPAL_DRIVER_DEVICE
*Dev
265 OPAL_SESSION Session
;
275 IsEnabled
= OpalFeatureEnabled (&Dev
->OpalDisk
.SupportedAttributes
, &Dev
->OpalDisk
.LockingFeature
);
277 ZeroMem(&Session
, sizeof(Session
));
278 Session
.Sscp
= Dev
->OpalDisk
.Sscp
;
279 Session
.MediaId
= Dev
->OpalDisk
.MediaId
;
280 Session
.OpalBaseComId
= Dev
->OpalDisk
.OpalBaseComId
;
282 Locked
= OpalDeviceLocked (&Dev
->OpalDisk
.SupportedAttributes
, &Dev
->OpalDisk
.LockingFeature
);
284 while (Count
< MAX_PASSWORD_TRY_COUNT
) {
285 Password
= OpalDriverPopUpHddPassword (Dev
, &PressEsc
);
289 // Current device in the lock status and
290 // User not input password and press ESC,
291 // keep device in lock status and continue boot.
295 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
297 L
"Press ENTER to skip password, Press ESC to input password",
300 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
302 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
303 gST
->ConOut
->ClearScreen(gST
->ConOut
);
305 // Keep lock and continue boot.
310 // Let user input password again.
316 // Current device in the unlock status and
317 // User not input password and press ESC,
318 // Shutdown the device.
322 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
324 L
"Press ENTER to shutdown, Press ESC to input password",
327 } while ((Key
.ScanCode
!= SCAN_ESC
) && (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
));
329 if (Key
.UnicodeChar
== CHAR_CARRIAGE_RETURN
) {
330 gRT
->ResetSystem (EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
333 // Let user input password again.
340 if (Password
== NULL
) {
344 PasswordLen
= (UINT32
) AsciiStrLen(Password
);
347 Ret
= OpalSupportUnlock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
349 Ret
= OpalSupportLock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
350 if (Ret
== TcgResultSuccess
) {
351 Ret
= OpalSupportUnlock(&Session
, Password
, PasswordLen
, Dev
->OpalDevicePath
);
355 if (Password
!= NULL
) {
356 ZeroMem (Password
, PasswordLen
);
360 if (Ret
== TcgResultSuccess
) {
368 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
370 L
"Invalid password.",
371 L
"Press ENTER to retry",
374 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
377 if (Count
>= MAX_PASSWORD_TRY_COUNT
) {
380 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
382 L
"Opal password retry count exceeds the limit. Must shutdown!",
383 L
"Press ENTER to shutdown",
386 } while (Key
.UnicodeChar
!= CHAR_CARRIAGE_RETURN
);
388 gRT
->ResetSystem (EfiResetShutdown
, EFI_SUCCESS
, 0, NULL
);
394 Get devcie list info.
396 @retval return the device list pointer.
399 OpalDriverGetDeviceList(
403 return mOpalDriver
.DeviceList
;
407 ReadyToBoot callback to send BlockSid command.
409 @param Event Pointer to this event
410 @param Context Event handler private Data
415 ReadyToBootCallback (
420 OPAL_DRIVER_DEVICE
*Itr
;
422 OPAL_SESSION Session
;
423 UINT32 PpStorageFlag
;
425 gBS
->CloseEvent (Event
);
427 PpStorageFlag
= Tcg2PhysicalPresenceLibGetManagementFlags ();
428 if ((PpStorageFlag
& TCG2_BIOS_STORAGE_MANAGEMENT_FLAG_ENABLE_BLOCK_SID
) != 0) {
430 // Send BlockSID command to each Opal disk
432 Itr
= mOpalDriver
.DeviceList
;
433 while (Itr
!= NULL
) {
434 if (Itr
->OpalDisk
.SupportedAttributes
.BlockSid
) {
435 ZeroMem(&Session
, sizeof(Session
));
436 Session
.Sscp
= Itr
->OpalDisk
.Sscp
;
437 Session
.MediaId
= Itr
->OpalDisk
.MediaId
;
438 Session
.OpalBaseComId
= Itr
->OpalDisk
.OpalBaseComId
;
440 Result
= OpalBlockSid (&Session
, TRUE
); // HardwareReset must always be TRUE
441 if (Result
!= TcgResultSuccess
) {
442 DEBUG ((DEBUG_ERROR
, "OpalBlockSid fail\n"));
453 Stop this Controller.
455 @param Dev The device need to be stopped.
459 OpalDriverStopDevice (
460 OPAL_DRIVER_DEVICE
*Dev
466 FreePool(Dev
->Name16
);
469 // remove OPAL_DRIVER_DEVICE from the list
470 // it updates the controllerList pointer
475 // close protocols that were opened
479 &gEfiStorageSecurityCommandProtocolGuid
,
480 gOpalDriverBinding
.DriverBindingHandle
,
486 &gEfiBlockIoProtocolGuid
,
487 gOpalDriverBinding
.DriverBindingHandle
,
495 Get devcie name through the component name protocol.
497 @param[in] AllHandlesBuffer The handle buffer for current system.
498 @param[in] NumAllHandles The number of handles for the handle buffer.
499 @param[in] Dev The device which need to get name.
500 @param[in] UseComp1 Whether use component name or name2 protocol.
502 @retval TRUE Find the name for this device.
503 @retval FALSE Not found the name for this device.
506 OpalDriverGetDeviceNameByProtocol(
507 EFI_HANDLE
*AllHandlesBuffer
,
509 OPAL_DRIVER_DEVICE
*Dev
,
513 EFI_HANDLE
* ProtocolHandlesBuffer
;
514 UINTN NumProtocolHandles
;
516 EFI_COMPONENT_NAME2_PROTOCOL
* Cnp1_2
; // efi component name and componentName2 have same layout
519 EFI_DEVICE_PATH_PROTOCOL
* TmpDevPath
;
522 EFI_HANDLE TmpHandle
;
525 if (Dev
== NULL
|| AllHandlesBuffer
== NULL
|| NumAllHandles
== 0) {
529 Protocol
= UseComp1
? gEfiComponentNameProtocolGuid
: gEfiComponentName2ProtocolGuid
;
532 // Find all EFI_HANDLES with protocol
534 Status
= gBS
->LocateHandleBuffer(
539 &ProtocolHandlesBuffer
541 if (EFI_ERROR(Status
)) {
547 // Exit early if no supported devices
549 if (NumProtocolHandles
== 0) {
554 // Get printable name by iterating through all protocols
555 // using the handle as the child, and iterate through all handles for the controller
556 // exit loop early once found, if not found, then delete device
557 // storage security protocol instances already exist, add them to internal list
559 Status
= EFI_DEVICE_ERROR
;
560 for (Index1
= 0; Index1
< NumProtocolHandles
; Index1
++) {
563 if (Dev
->Name16
!= NULL
) {
567 TmpHandle
= ProtocolHandlesBuffer
[Index1
];
569 Status
= gBS
->OpenProtocol(
575 EFI_OPEN_PROTOCOL_GET_PROTOCOL
577 if (EFI_ERROR(Status
) || Cnp1_2
== NULL
) {
582 // Use all handles array as controller handle
584 for (Index2
= 0; Index2
< NumAllHandles
; Index2
++) {
585 Status
= Cnp1_2
->GetControllerName(
587 AllHandlesBuffer
[Index2
],
589 LANGUAGE_ISO_639_2_ENGLISH
,
592 if (EFI_ERROR(Status
)) {
593 Status
= Cnp1_2
->GetControllerName(
595 AllHandlesBuffer
[Index2
],
597 LANGUAGE_RFC_3066_ENGLISH
,
601 if (!EFI_ERROR(Status
) && DevName
!= NULL
) {
602 StrLength
= StrLen(DevName
) + 1; // Add one for NULL terminator
603 Dev
->Name16
= AllocateZeroPool(StrLength
* sizeof (CHAR16
));
604 ASSERT (Dev
->Name16
!= NULL
);
605 StrCpyS (Dev
->Name16
, StrLength
, DevName
);
606 Dev
->NameZ
= (CHAR8
*)AllocateZeroPool(StrLength
);
607 UnicodeStrToAsciiStrS (DevName
, Dev
->NameZ
, StrLength
);
610 // Retrieve bridge BDF info and port number or namespace depending on type
613 Status
= gBS
->OpenProtocol(
615 &gEfiDevicePathProtocolGuid
,
619 EFI_OPEN_PROTOCOL_GET_PROTOCOL
621 if (!EFI_ERROR(Status
)) {
622 Dev
->OpalDevicePath
= DuplicateDevicePath (TmpDevPath
);
626 if (Dev
->Name16
!= NULL
) {
627 FreePool(Dev
->Name16
);
630 if (Dev
->NameZ
!= NULL
) {
631 FreePool(Dev
->NameZ
);
642 Get devcie name through the component name protocol.
644 @param[in] Dev The device which need to get name.
646 @retval TRUE Find the name for this device.
647 @retval FALSE Not found the name for this device.
650 OpalDriverGetDriverDeviceName(
651 OPAL_DRIVER_DEVICE
*Dev
654 EFI_HANDLE
* AllHandlesBuffer
;
659 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "OpalDriverGetDriverDeviceName Exiting, Dev=NULL\n"));
664 // Iterate through ComponentName2 handles to get name, if fails, try ComponentName
666 if (Dev
->Name16
== NULL
) {
667 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "Name is null, update it\n"));
669 // Find all EFI_HANDLES
671 Status
= gBS
->LocateHandleBuffer(
678 if (EFI_ERROR(Status
)) {
679 DEBUG ((DEBUG_INFO
, "LocateHandleBuffer for AllHandles failed %r\n", Status
));
684 // Try component Name2
686 if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer
, NumAllHandles
, Dev
, FALSE
)) {
687 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "ComponentName2 failed to get device name, try ComponentName\n"));
688 if (!OpalDriverGetDeviceNameByProtocol(AllHandlesBuffer
, NumAllHandles
, Dev
, TRUE
)) {
689 DEBUG((DEBUG_ERROR
| DEBUG_INIT
, "ComponentName failed to get device name, skip device\n"));
699 Main entry for this driver.
701 @param ImageHandle Image Handle this driver.
702 @param SystemTable Pointer to SystemTable.
704 @retval EFI_SUCESS This function always complete successfully.
709 IN EFI_HANDLE ImageHandle
,
710 IN EFI_SYSTEM_TABLE
* SystemTable
714 EFI_EVENT ReadyToBootEvent
;
716 Status
= EfiLibInstallDriverBindingComponentName2 (
725 if (EFI_ERROR(Status
)) {
726 DEBUG((DEBUG_ERROR
, "Install protocols to Opal driver Handle failed\n"));
731 // Initialize Driver object
733 ZeroMem(&mOpalDriver
, sizeof(mOpalDriver
));
734 mOpalDriver
.Handle
= ImageHandle
;
737 // register a ReadyToBoot event callback for sending BlockSid command
739 Status
= EfiCreateEventReadyToBootEx (
742 (VOID
*) &ImageHandle
,
747 // Install Hii packages.
755 Tests to see if this driver supports a given controller.
757 This function checks to see if the controller contains an instance of the
758 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL and the EFI_BLOCK_IO_PROTOCL
759 and returns EFI_SUCCESS if it does.
761 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
762 @param[in] ControllerHandle The Handle of the controller to test. This Handle
763 must support a protocol interface that supplies
764 an I/O abstraction to the driver.
765 @param[in] RemainingDevicePath This parameter is ignored.
767 @retval EFI_SUCCESS The device contains required protocols
768 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
769 RemainingDevicePath is already being managed by the driver
771 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
772 RemainingDevicePath is already being managed by a different
773 driver or an application that requires exclusive access.
774 Currently not implemented.
775 @retval EFI_UNSUPPORTED The device does not contain requires protocols
780 OpalEfiDriverBindingSupported(
781 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
782 IN EFI_HANDLE Controller
,
783 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath
787 EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
* SecurityCommand
;
788 EFI_BLOCK_IO_PROTOCOL
* BlkIo
;
791 // Test EFI_STORAGE_SECURITY_COMMAND_PROTOCOL on controller Handle.
793 Status
= gBS
->OpenProtocol(
795 &gEfiStorageSecurityCommandProtocolGuid
,
796 ( VOID
** )&SecurityCommand
,
797 This
->DriverBindingHandle
,
799 EFI_OPEN_PROTOCOL_BY_DRIVER
802 if (Status
== EFI_ALREADY_STARTED
) {
806 if (EFI_ERROR(Status
)) {
811 // Close protocol and reopen in Start call
815 &gEfiStorageSecurityCommandProtocolGuid
,
816 This
->DriverBindingHandle
,
821 // Test EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
824 Status
= gBS
->OpenProtocol(
826 &gEfiBlockIoProtocolGuid
,
828 This
->DriverBindingHandle
,
830 EFI_OPEN_PROTOCOL_BY_DRIVER
833 if (EFI_ERROR(Status
)) {
834 DEBUG((DEBUG_INFO
, "No EFI_BLOCK_IO_PROTOCOL on controller\n"));
839 // Close protocol and reopen in Start call
843 &gEfiBlockIoProtocolGuid
,
844 This
->DriverBindingHandle
,
852 Enables Opal Management on a supported device if available.
854 The start function is designed to be called after the Opal UEFI Driver has confirmed the
855 "controller", which is a child Handle, contains the EF_STORAGE_SECURITY_COMMAND protocols.
856 This function will complete the other necessary checks, such as verifying the device supports
857 the correct version of Opal. Upon verification, it will add the device to the
858 Opal HII list in order to expose Opal managmeent options.
860 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
861 @param[in] ControllerHandle The Handle of the controller to start. This Handle
862 must support a protocol interface that supplies
863 an I/O abstraction to the driver.
864 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
865 parameter is ignored by device drivers, and is optional for bus
866 drivers. For a bus driver, if this parameter is NULL, then handles
867 for all the children of Controller are created by this driver.
868 If this parameter is not NULL and the first Device Path Node is
869 not the End of Device Path Node, then only the Handle for the
870 child device specified by the first Device Path Node of
871 RemainingDevicePath is created by this driver.
872 If the first Device Path Node of RemainingDevicePath is
873 the End of Device Path Node, no child Handle is created by this
876 @retval EFI_SUCCESS Opal management was enabled.
877 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
878 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
879 @retval Others The driver failed to start the device.
884 OpalEfiDriverBindingStart(
885 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
886 IN EFI_HANDLE Controller
,
887 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath
891 EFI_BLOCK_IO_PROTOCOL
*BlkIo
;
892 OPAL_DRIVER_DEVICE
*Dev
;
893 OPAL_DRIVER_DEVICE
*Itr
;
896 Itr
= mOpalDriver
.DeviceList
;
897 while (Itr
!= NULL
) {
898 if (Controller
== Itr
->Handle
) {
905 // Create internal device for tracking. This allows all disks to be tracked
908 Dev
= (OPAL_DRIVER_DEVICE
*)AllocateZeroPool(sizeof(OPAL_DRIVER_DEVICE
));
910 return EFI_OUT_OF_RESOURCES
;
912 Dev
->Handle
= Controller
;
915 // Open EFI_STORAGE_SECURITY_COMMAND_PROTOCOL to perform Opal supported checks
917 Status
= gBS
->OpenProtocol(
919 &gEfiStorageSecurityCommandProtocolGuid
,
921 This
->DriverBindingHandle
,
923 EFI_OPEN_PROTOCOL_BY_DRIVER
925 if (EFI_ERROR(Status
)) {
931 // Open EFI_BLOCK_IO_PROTOCOL on controller Handle, required by EFI_STORAGE_SECURITY_COMMAND_PROTOCOL
934 Status
= gBS
->OpenProtocol(
936 &gEfiBlockIoProtocolGuid
,
938 This
->DriverBindingHandle
,
940 EFI_OPEN_PROTOCOL_BY_DRIVER
942 if (EFI_ERROR(Status
)) {
944 // Close storage security that was opened
948 &gEfiStorageSecurityCommandProtocolGuid
,
949 This
->DriverBindingHandle
,
960 Dev
->MediaId
= BlkIo
->Media
->MediaId
;
964 &gEfiBlockIoProtocolGuid
,
965 This
->DriverBindingHandle
,
970 // Acquire Ascii printable name of child, if not found, then ignore device
972 Result
= OpalDriverGetDriverDeviceName (Dev
);
977 Status
= OpalDiskInitialize (Dev
);
978 if (EFI_ERROR (Status
)) {
982 AddDeviceToTail(Dev
);
985 // check if device is locked and prompt for password
987 OpalDriverRequestPassword (Dev
);
993 // free device, close protocols and exit
997 &gEfiStorageSecurityCommandProtocolGuid
,
998 This
->DriverBindingHandle
,
1004 return EFI_DEVICE_ERROR
;
1008 Stop this driver on Controller.
1010 @param This Protocol instance pointer.
1011 @param Controller Handle of device to stop driver on
1012 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
1013 children is zero stop the entire bus driver.
1014 @param ChildHandleBuffer List of Child Handles to Stop.
1016 @retval EFI_SUCCESS This driver is removed Controller.
1017 @retval other This driver could not be removed from this device.
1022 OpalEfiDriverBindingStop(
1023 EFI_DRIVER_BINDING_PROTOCOL
* This
,
1024 EFI_HANDLE Controller
,
1025 UINTN NumberOfChildren
,
1026 EFI_HANDLE
* ChildHandleBuffer
1029 OPAL_DRIVER_DEVICE
* Itr
;
1031 Itr
= mOpalDriver
.DeviceList
;
1034 // does Controller match any of the devices we are managing for Opal
1036 while (Itr
!= NULL
) {
1037 if (Itr
->Handle
== Controller
) {
1038 OpalDriverStopDevice (Itr
);
1045 return EFI_NOT_FOUND
;
1050 Unloads UEFI Driver. Very useful for debugging and testing.
1052 @param ImageHandle Image Handle this driver.
1054 @retval EFI_SUCCESS This function always complete successfully.
1055 @retval EFI_INVALID_PARAMETER The input ImageHandle is not valid.
1059 OpalEfiDriverUnload (
1060 IN EFI_HANDLE ImageHandle
1064 OPAL_DRIVER_DEVICE
*Itr
;
1066 Status
= EFI_SUCCESS
;
1068 if (ImageHandle
!= gImageHandle
) {
1069 return (EFI_INVALID_PARAMETER
);
1073 // Uninstall any interface added to each device by us
1075 while (mOpalDriver
.DeviceList
) {
1076 Itr
= mOpalDriver
.DeviceList
;
1078 // Remove OPAL_DRIVER_DEVICE from the list
1079 // it updates the controllerList pointer
1081 OpalDriverStopDevice(Itr
);
1085 // Uninstall the HII capability
1087 Status
= HiiUninstall();