2 The entry point of IScsi driver.
\r
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
\r
5 This program and the accompanying materials
\r
6 are licensed and made available under the terms and conditions of the BSD License
\r
7 which accompanies this distribution. The full text of the license may be found at
\r
8 http://opensource.org/licenses/bsd-license.php
\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
\r
15 #include "IScsiImpl.h"
\r
17 EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = {
\r
18 IScsiIp4DriverBindingSupported,
\r
19 IScsiIp4DriverBindingStart,
\r
20 IScsiIp4DriverBindingStop,
\r
26 EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = {
\r
27 IScsiIp6DriverBindingSupported,
\r
28 IScsiIp6DriverBindingStart,
\r
29 IScsiIp6DriverBindingStop,
\r
35 EFI_GUID gIScsiV4PrivateGuid = ISCSI_V4_PRIVATE_GUID;
\r
36 EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID;
\r
37 ISCSI_PRIVATE_DATA *mPrivate = NULL;
\r
40 Tests to see if this driver supports the RemainingDevicePath.
\r
42 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
43 parameter is ignored by device drivers, and is optional for bus
\r
44 drivers. For bus drivers, if this parameter is not NULL, then
\r
45 the bus driver must determine if the bus controller specified
\r
46 by ControllerHandle and the child controller specified
\r
47 by RemainingDevicePath are both supported by this
\r
50 @retval EFI_SUCCESS The RemainingDevicePath is supported or NULL.
\r
51 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
\r
52 RemainingDevicePath is not supported by the driver specified by This.
\r
55 IScsiIsDevicePathSupported (
\r
56 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
\r
59 EFI_DEVICE_PATH_PROTOCOL *CurrentDevicePath;
\r
61 CurrentDevicePath = RemainingDevicePath;
\r
62 if (CurrentDevicePath != NULL) {
\r
63 while (!IsDevicePathEnd (CurrentDevicePath)) {
\r
64 if ((CurrentDevicePath->Type == MESSAGING_DEVICE_PATH) && (CurrentDevicePath->SubType == MSG_ISCSI_DP)) {
\r
68 CurrentDevicePath = NextDevicePathNode (CurrentDevicePath);
\r
71 return EFI_UNSUPPORTED;
\r
79 Tests to see if this driver supports a given controller. This is the worker function for
\r
80 IScsiIp4(6)DriverBindingSupported.
\r
82 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
83 @param[in] ControllerHandle The handle of the controller to test. This handle
\r
84 must support a protocol interface that supplies
\r
85 an I/O abstraction to the driver.
\r
86 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
87 parameter is ignored by device drivers, and is optional for bus
\r
88 drivers. For bus drivers, if this parameter is not NULL, then
\r
89 the bus driver must determine if the bus controller specified
\r
90 by ControllerHandle and the child controller specified
\r
91 by RemainingDevicePath are both supported by this
\r
93 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
\r
95 @retval EFI_SUCCESS The device specified by ControllerHandle and
\r
96 RemainingDevicePath is supported by the driver specified by This.
\r
97 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
\r
98 RemainingDevicePath is already being managed by the driver
\r
100 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
\r
101 RemainingDevicePath is not supported by the driver specified by This.
\r
106 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
107 IN EFI_HANDLE ControllerHandle,
\r
108 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
\r
113 EFI_GUID *IScsiServiceBindingGuid;
\r
114 EFI_GUID *TcpServiceBindingGuid;
\r
115 EFI_GUID *DhcpServiceBindingGuid;
\r
117 if (IpVersion == IP_VERSION_4) {
\r
118 IScsiServiceBindingGuid = &gIScsiV4PrivateGuid;
\r
119 TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
\r
120 DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;
\r
122 IScsiServiceBindingGuid = &gIScsiV6PrivateGuid;
\r
123 TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
\r
124 DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;
\r
127 Status = gBS->OpenProtocol (
\r
129 IScsiServiceBindingGuid,
\r
131 This->DriverBindingHandle,
\r
133 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
\r
135 if (!EFI_ERROR (Status)) {
\r
136 return EFI_ALREADY_STARTED;
\r
139 Status = gBS->OpenProtocol (
\r
141 TcpServiceBindingGuid,
\r
143 This->DriverBindingHandle,
\r
145 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
\r
147 if (EFI_ERROR (Status)) {
\r
148 return EFI_UNSUPPORTED;
\r
151 Status = IScsiIsDevicePathSupported (RemainingDevicePath);
\r
152 if (EFI_ERROR (Status)) {
\r
153 return EFI_UNSUPPORTED;
\r
156 if (IScsiDhcpIsConfigured (ControllerHandle, IpVersion)) {
\r
157 Status = gBS->OpenProtocol (
\r
159 DhcpServiceBindingGuid,
\r
161 This->DriverBindingHandle,
\r
163 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
\r
165 if (EFI_ERROR (Status)) {
\r
166 return EFI_UNSUPPORTED;
\r
170 return EFI_SUCCESS;
\r
175 Start to manage the controller. This is the worker function for
\r
176 IScsiIp4(6)DriverBindingStart.
\r
178 @param[in] Image Handle of the image.
\r
179 @param[in] ControllerHandle Handle of the controller.
\r
180 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
\r
182 @retval EFI_SUCCES This driver was started.
\r
183 @retval EFI_ALREADY_STARTED This driver is already running on this device.
\r
184 @retval EFI_INVALID_PARAMETER Any input parameter is invalid.
\r
185 @retval EFI_NOT_FOUND There is no sufficient information to establish
\r
187 @retval EFI_DEVICE_ERROR Failed to get TCP connection device path.
\r
192 IN EFI_HANDLE Image,
\r
193 IN EFI_HANDLE ControllerHandle,
\r
198 ISCSI_DRIVER_DATA *Private;
\r
200 LIST_ENTRY *NextEntry;
\r
201 ISCSI_ATTEMPT_CONFIG_NVDATA *AttemptConfigData;
\r
202 ISCSI_SESSION *Session;
\r
204 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExistIScsiExtScsiPassThru;
\r
205 ISCSI_DRIVER_DATA *ExistPrivate;
\r
206 UINT8 *AttemptConfigOrder;
\r
207 UINTN AttemptConfigOrderSize;
\r
208 UINT8 BootSelected;
\r
209 EFI_HANDLE *HandleBuffer;
\r
210 UINTN NumberOfHandles;
\r
211 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
\r
212 EFI_GUID *IScsiPrivateGuid;
\r
213 EFI_GUID *TcpServiceBindingGuid;
\r
214 CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN];
\r
215 BOOLEAN NeedUpdate;
\r
217 EFI_GUID *ProtocolGuid;
\r
220 // Test to see if iSCSI driver supports the given controller.
\r
223 if (IpVersion == IP_VERSION_4) {
\r
224 IScsiPrivateGuid = &gIScsiV4PrivateGuid;
\r
225 TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
\r
226 ProtocolGuid = &gEfiTcp4ProtocolGuid;
\r
227 } else if (IpVersion == IP_VERSION_6) {
\r
228 IScsiPrivateGuid = &gIScsiV6PrivateGuid;
\r
229 TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
\r
230 ProtocolGuid = &gEfiTcp6ProtocolGuid;
\r
232 return EFI_INVALID_PARAMETER;
\r
235 Status = gBS->OpenProtocol (
\r
241 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
\r
243 if (!EFI_ERROR (Status)) {
\r
244 return EFI_ALREADY_STARTED;
\r
247 Status = gBS->OpenProtocol (
\r
249 TcpServiceBindingGuid,
\r
253 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
\r
255 if (EFI_ERROR (Status)) {
\r
256 return EFI_UNSUPPORTED;
\r
260 // Record the incoming NIC info.
\r
262 Status = IScsiAddNic (ControllerHandle);
\r
263 if (EFI_ERROR (Status)) {
\r
268 // Create the instance private data.
\r
270 Private = IScsiCreateDriverData (Image, ControllerHandle);
\r
271 if (Private == NULL) {
\r
272 return EFI_OUT_OF_RESOURCES;
\r
276 // Create a underlayer child instance, but not need to configure it. Just open ChildHandle
\r
277 // via BY_DRIVER. That is, establishing the relationship between ControllerHandle and ChildHandle.
\r
278 // Therefore, when DisconnectController(), especially VLAN virtual controller handle,
\r
279 // IScsiDriverBindingStop() will be called.
\r
281 Status = NetLibCreateServiceChild (
\r
284 TcpServiceBindingGuid,
\r
285 &Private->ChildHandle
\r
288 if (EFI_ERROR (Status)) {
\r
292 Status = gBS->OpenProtocol (
\r
293 Private->ChildHandle,
\r
298 EFI_OPEN_PROTOCOL_BY_DRIVER
\r
301 if (EFI_ERROR (Status)) {
\r
306 // Always install private protocol no matter what happens later. We need to
\r
307 // keep the relationship between ControllerHandle and ChildHandle.
\r
309 Status = gBS->InstallProtocolInterface (
\r
312 EFI_NATIVE_INTERFACE,
\r
313 &Private->IScsiIdentifier
\r
315 if (EFI_ERROR (Status)) {
\r
319 if (IpVersion == IP_VERSION_4) {
\r
320 mPrivate->Ipv6Flag = FALSE;
\r
322 mPrivate->Ipv6Flag = TRUE;
\r
326 // Get the current iSCSI configuration data.
\r
328 Status = IScsiGetConfigData (Private);
\r
329 if (EFI_ERROR (Status)) {
\r
334 // If there is already a successul attempt, check whether this attempt is the
\r
335 // first "enabled for MPIO" attempt. If not, still try the first attempt.
\r
336 // In single path mode, try all attempts.
\r
338 ExistPrivate = NULL;
\r
339 Status = EFI_NOT_FOUND;
\r
341 if (mPrivate->OneSessionEstablished && mPrivate->EnableMpio) {
\r
342 AttemptConfigData = NULL;
\r
343 NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
\r
344 AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
\r
345 if (AttemptConfigData->SessionConfigData.Enabled == ISCSI_ENABLED_FOR_MPIO) {
\r
350 if (AttemptConfigData == NULL) {
\r
354 if (AttemptConfigData->AttemptConfigIndex == mPrivate->BootSelectedIndex) {
\r
359 // Uninstall the original ExtScsiPassThru first.
\r
363 // Locate all ExtScsiPassThru protocol instances.
\r
365 Status = gBS->LocateHandleBuffer (
\r
367 &gEfiExtScsiPassThruProtocolGuid,
\r
372 if (EFI_ERROR (Status)) {
\r
377 // Find ExtScsiPassThru protocol instance produced by this driver.
\r
379 ExistIScsiExtScsiPassThru = NULL;
\r
380 for (Index = 0; Index < NumberOfHandles && ExistIScsiExtScsiPassThru == NULL; Index++) {
\r
381 Status = gBS->HandleProtocol (
\r
382 HandleBuffer[Index],
\r
383 &gEfiDevicePathProtocolGuid,
\r
384 (VOID **) &DevicePath
\r
386 if (EFI_ERROR (Status)) {
\r
390 while (!IsDevicePathEnd (DevicePath)) {
\r
391 if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == MSG_MAC_ADDR_DP)) {
\r
393 // Get the ExtScsiPassThru protocol instance.
\r
395 Status = gBS->HandleProtocol (
\r
396 HandleBuffer[Index],
\r
397 &gEfiExtScsiPassThruProtocolGuid,
\r
398 (VOID **) &ExistIScsiExtScsiPassThru
\r
400 ASSERT_EFI_ERROR (Status);
\r
404 DevicePath = NextDevicePathNode (DevicePath);
\r
408 FreePool (HandleBuffer);
\r
410 if (ExistIScsiExtScsiPassThru == NULL) {
\r
411 Status = EFI_NOT_FOUND;
\r
415 ExistPrivate = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (ExistIScsiExtScsiPassThru);
\r
417 Status = gBS->UninstallProtocolInterface (
\r
418 ExistPrivate->ExtScsiPassThruHandle,
\r
419 &gEfiExtScsiPassThruProtocolGuid,
\r
420 &ExistPrivate->IScsiExtScsiPassThru
\r
422 if (EFI_ERROR (Status)) {
\r
428 // Install the Ext SCSI PASS THRU protocol.
\r
430 Status = gBS->InstallProtocolInterface (
\r
431 &Private->ExtScsiPassThruHandle,
\r
432 &gEfiExtScsiPassThruProtocolGuid,
\r
433 EFI_NATIVE_INTERFACE,
\r
434 &Private->IScsiExtScsiPassThru
\r
436 if (EFI_ERROR (Status)) {
\r
442 NET_LIST_FOR_EACH_SAFE (Entry, NextEntry, &mPrivate->AttemptConfigs) {
\r
443 AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
\r
445 // Don't process the attempt that does not associate with the current NIC or
\r
446 // this attempt is disabled or established.
\r
448 if (AttemptConfigData->NicIndex != mPrivate->CurrentNic ||
\r
449 AttemptConfigData->SessionConfigData.Enabled == ISCSI_DISABLED ||
\r
450 AttemptConfigData->ValidPath) {
\r
455 // In multipath mode, don't process attempts configured for single path.
\r
456 // In default single path mode, don't process attempts configured for multipath.
\r
458 if ((mPrivate->EnableMpio &&
\r
459 AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO) ||
\r
460 (!mPrivate->EnableMpio &&
\r
461 AttemptConfigData->SessionConfigData.Enabled != ISCSI_ENABLED)) {
\r
466 // Don't process the attempt that fails to get the init/target information from DHCP.
\r
468 if (AttemptConfigData->SessionConfigData.InitiatorInfoFromDhcp &&
\r
469 !AttemptConfigData->DhcpSuccess) {
\r
470 if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
\r
471 mPrivate->ValidSinglePathCount--;
\r
477 // Don't process the autoconfigure path if it is already established.
\r
479 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
\r
480 AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_SUCCESS) {
\r
485 // Don't process the attempt if its IP mode is not in the current IP version.
\r
487 if (!mPrivate->Ipv6Flag) {
\r
488 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP6) {
\r
491 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
\r
492 AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP6) {
\r
496 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_IP4) {
\r
499 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG &&
\r
500 AttemptConfigData->AutoConfigureMode == IP_MODE_AUTOCONFIG_IP4) {
\r
506 // Fill in the Session and init it.
\r
508 Session = (ISCSI_SESSION *) AllocateZeroPool (sizeof (ISCSI_SESSION));
\r
509 if (Session == NULL) {
\r
510 Status = EFI_OUT_OF_RESOURCES;
\r
514 Session->Private = Private;
\r
515 Session->ConfigData = AttemptConfigData;
\r
516 Session->AuthType = AttemptConfigData->AuthenticationType;
\r
518 AsciiStrToUnicodeStr (AttemptConfigData->MacString, MacString);
\r
520 mPrivate->PortString,
\r
521 (UINTN) ISCSI_NAME_IFR_MAX_SIZE,
\r
524 (UINTN) AttemptConfigData->AttemptConfigIndex
\r
527 if (Session->AuthType == ISCSI_AUTH_TYPE_CHAP) {
\r
528 Session->AuthData.CHAP.AuthConfig = &AttemptConfigData->AuthConfigData.CHAP;
\r
531 IScsiSessionInit (Session, FALSE);
\r
534 // Try to login and create an iSCSI session according to the configuration.
\r
536 Status = IScsiSessionLogin (Session);
\r
537 if (Status == EFI_MEDIA_CHANGED) {
\r
539 // The specified target is not available, and the redirection information is
\r
540 // received. Login the session again with the updated target address.
\r
542 Status = IScsiSessionLogin (Session);
\r
543 } else if (Status == EFI_NOT_READY) {
\r
544 Status = IScsiSessionReLogin (Session);
\r
547 if (EFI_ERROR (Status)) {
\r
549 // In Single path mode, only the successful attempt will be recorded in iBFT;
\r
550 // in multi-path mode, all the attempt entries in MPIO will be recorded in iBFT.
\r
552 if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
\r
553 mPrivate->ValidSinglePathCount--;
\r
556 FreePool (Session);
\r
559 AttemptConfigData->ValidPath = TRUE;
\r
562 // Do not record the attempt in iBFT if it login with KRB5.
\r
563 // TODO: record KRB5 attempt information in the iSCSI device path.
\r
565 if (Session->AuthType == ISCSI_AUTH_TYPE_KRB) {
\r
566 if (!mPrivate->EnableMpio && mPrivate->ValidSinglePathCount > 0) {
\r
567 mPrivate->ValidSinglePathCount--;
\r
570 AttemptConfigData->ValidiBFTPath = FALSE;
\r
572 AttemptConfigData->ValidiBFTPath = TRUE;
\r
576 // IScsi session success. Update the attempt state to NVR.
\r
578 if (AttemptConfigData->SessionConfigData.IpMode == IP_MODE_AUTOCONFIG) {
\r
579 AttemptConfigData->AutoConfigureMode = IP_MODE_AUTOCONFIG_SUCCESS;
\r
583 mPrivate->PortString,
\r
584 &gEfiIScsiInitiatorNameProtocolGuid,
\r
585 ISCSI_CONFIG_VAR_ATTR,
\r
586 sizeof (ISCSI_ATTEMPT_CONFIG_NVDATA),
\r
591 // Select the first login session. Abort others.
\r
593 if (Private->Session == NULL) {
\r
594 Private->Session = Session;
\r
595 BootSelected = AttemptConfigData->AttemptConfigIndex;
\r
597 // Don't validate other attempt in multipath mode if one is success.
\r
599 if (mPrivate->EnableMpio) {
\r
603 IScsiSessionAbort (Session);
\r
604 FreePool (Session);
\r
610 // All attempts configured for this driver instance are not valid.
\r
612 if (Private->Session == NULL) {
\r
613 Status = gBS->UninstallProtocolInterface (
\r
614 Private->ExtScsiPassThruHandle,
\r
615 &gEfiExtScsiPassThruProtocolGuid,
\r
616 &Private->IScsiExtScsiPassThru
\r
618 ASSERT_EFI_ERROR (Status);
\r
619 Private->ExtScsiPassThruHandle = NULL;
\r
622 // Reinstall the original ExtScsiPassThru back.
\r
624 if (mPrivate->OneSessionEstablished && ExistPrivate != NULL) {
\r
625 Status = gBS->InstallProtocolInterface (
\r
626 &ExistPrivate->ExtScsiPassThruHandle,
\r
627 &gEfiExtScsiPassThruProtocolGuid,
\r
628 EFI_NATIVE_INTERFACE,
\r
629 &ExistPrivate->IScsiExtScsiPassThru
\r
631 if (EFI_ERROR (Status)) {
\r
638 Status = EFI_NOT_FOUND;
\r
645 // More than one attempt successes.
\r
647 if (Private->Session != NULL && mPrivate->OneSessionEstablished) {
\r
649 AttemptConfigOrder = IScsiGetVariableAndSize (
\r
652 &AttemptConfigOrderSize
\r
654 if (AttemptConfigOrder == NULL) {
\r
657 for (Index = 0; Index < AttemptConfigOrderSize / sizeof (UINT8); Index++) {
\r
658 if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex ||
\r
659 AttemptConfigOrder[Index] == BootSelected) {
\r
664 if (mPrivate->EnableMpio) {
\r
666 // Use the attempt in earlier order. Abort the later one in MPIO.
\r
668 if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) {
\r
669 IScsiSessionAbort (Private->Session);
\r
670 FreePool (Private->Session);
\r
671 Private->Session = NULL;
\r
672 gBS->UninstallProtocolInterface (
\r
673 Private->ExtScsiPassThruHandle,
\r
674 &gEfiExtScsiPassThruProtocolGuid,
\r
675 &Private->IScsiExtScsiPassThru
\r
677 Private->ExtScsiPassThruHandle = NULL;
\r
680 // Reinstall the original ExtScsiPassThru back.
\r
682 Status = gBS->InstallProtocolInterface (
\r
683 &ExistPrivate->ExtScsiPassThruHandle,
\r
684 &gEfiExtScsiPassThruProtocolGuid,
\r
685 EFI_NATIVE_INTERFACE,
\r
686 &ExistPrivate->IScsiExtScsiPassThru
\r
688 if (EFI_ERROR (Status)) {
\r
694 if (AttemptConfigOrder[Index] != BootSelected) {
\r
697 mPrivate->BootSelectedIndex = BootSelected;
\r
699 // Clear the resource in ExistPrivate.
\r
701 gBS->UninstallProtocolInterface (
\r
702 ExistPrivate->Controller,
\r
704 &ExistPrivate->IScsiIdentifier
\r
707 IScsiRemoveNic (ExistPrivate->Controller);
\r
708 if (ExistPrivate->Session != NULL) {
\r
709 IScsiSessionAbort (ExistPrivate->Session);
\r
712 IScsiCleanDriverData (ExistPrivate);
\r
716 // Use the attempt in earlier order as boot selected in single path mode.
\r
718 if (AttemptConfigOrder[Index] == mPrivate->BootSelectedIndex) {
\r
719 NeedUpdate = FALSE;
\r
726 mPrivate->OneSessionEstablished = TRUE;
\r
727 mPrivate->BootSelectedIndex = BootSelected;
\r
731 // Duplicate the Session's tcp connection device path. The source port field
\r
732 // will be set to zero as one iSCSI session is comprised of several iSCSI
\r
735 Private->DevicePath = IScsiGetTcpConnDevicePath (Private->Session);
\r
736 if (Private->DevicePath == NULL) {
\r
737 Status = EFI_DEVICE_ERROR;
\r
741 // Install the updated device path onto the ExtScsiPassThruHandle.
\r
743 Status = gBS->InstallProtocolInterface (
\r
744 &Private->ExtScsiPassThruHandle,
\r
745 &gEfiDevicePathProtocolGuid,
\r
746 EFI_NATIVE_INTERFACE,
\r
747 Private->DevicePath
\r
749 if (EFI_ERROR (Status)) {
\r
756 // Update/Publish the iSCSI Boot Firmware Table.
\r
758 if (mPrivate->BootSelectedIndex != 0) {
\r
759 IScsiPublishIbft ();
\r
762 return EFI_SUCCESS;
\r
766 if (Private->Session != NULL) {
\r
767 IScsiSessionAbort (Private->Session);
\r
774 Stops a device controller or a bus controller. This is the worker function for
\r
775 IScsiIp4(6)DriverBindingStop.
\r
777 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
778 @param[in] ControllerHandle A handle to the device being stopped. The handle must
\r
779 support a bus specific I/O protocol for the driver
\r
780 to use to stop the device.
\r
781 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
\r
782 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
\r
783 if NumberOfChildren is 0.
\r
784 @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.
\r
786 @retval EFI_SUCCESS The device was stopped.
\r
787 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
\r
793 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
794 IN EFI_HANDLE ControllerHandle,
\r
795 IN UINTN NumberOfChildren,
\r
796 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL,
\r
800 EFI_HANDLE IScsiController;
\r
802 ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier;
\r
803 ISCSI_DRIVER_DATA *Private;
\r
804 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru;
\r
805 ISCSI_CONNECTION *Conn;
\r
806 EFI_GUID *ProtocolGuid;
\r
807 EFI_GUID *TcpServiceBindingGuid;
\r
808 EFI_GUID *TcpProtocolGuid;
\r
811 if (NumberOfChildren != 0) {
\r
813 // We should have only one child.
\r
815 Status = gBS->OpenProtocol (
\r
816 ChildHandleBuffer[0],
\r
817 &gEfiExtScsiPassThruProtocolGuid,
\r
818 (VOID **) &PassThru,
\r
819 This->DriverBindingHandle,
\r
821 EFI_OPEN_PROTOCOL_GET_PROTOCOL
\r
823 if (EFI_ERROR (Status)) {
\r
824 return EFI_DEVICE_ERROR;
\r
827 Private = ISCSI_DRIVER_DATA_FROM_EXT_SCSI_PASS_THRU (PassThru);
\r
828 Conn = NET_LIST_HEAD (&Private->Session->Conns, ISCSI_CONNECTION, Link);
\r
831 // Previously the TCP protocol is opened BY_CHILD_CONTROLLER. Just close
\r
832 // the protocol here, but do not uninstall the device path protocol and
\r
833 // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle.
\r
835 if (IpVersion == IP_VERSION_4) {
\r
836 ProtocolGuid = &gEfiTcp4ProtocolGuid;
\r
838 ProtocolGuid = &gEfiTcp6ProtocolGuid;
\r
841 gBS->CloseProtocol (
\r
842 Conn->TcpIo.Handle,
\r
845 Private->ExtScsiPassThruHandle
\r
848 return EFI_SUCCESS;
\r
851 // Get the handle of the controller we are controling.
\r
853 if (IpVersion == IP_VERSION_4) {
\r
854 ProtocolGuid = &gIScsiV4PrivateGuid;
\r
855 TcpProtocolGuid = &gEfiTcp4ProtocolGuid;
\r
856 TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
\r
858 ProtocolGuid = &gIScsiV6PrivateGuid;
\r
859 TcpProtocolGuid = &gEfiTcp6ProtocolGuid;
\r
860 TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
\r
862 IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid);
\r
863 if (IScsiController == NULL) {
\r
864 return EFI_SUCCESS;
\r
867 Status = gBS->OpenProtocol (
\r
870 (VOID **) &IScsiIdentifier,
\r
871 This->DriverBindingHandle,
\r
873 EFI_OPEN_PROTOCOL_GET_PROTOCOL
\r
875 if (EFI_ERROR (Status)) {
\r
876 return EFI_DEVICE_ERROR;
\r
879 Private = ISCSI_DRIVER_DATA_FROM_IDENTIFIER (IScsiIdentifier);
\r
880 ASSERT (Private != NULL);
\r
882 if (Private->ChildHandle != NULL) {
\r
883 Status = gBS->CloseProtocol (
\r
884 Private->ChildHandle,
\r
886 This->DriverBindingHandle,
\r
890 ASSERT (!EFI_ERROR (Status));
\r
892 Status = NetLibDestroyServiceChild (
\r
894 This->DriverBindingHandle,
\r
895 TcpServiceBindingGuid,
\r
896 Private->ChildHandle
\r
899 ASSERT (!EFI_ERROR (Status));
\r
902 gBS->UninstallProtocolInterface (
\r
905 &Private->IScsiIdentifier
\r
909 // Remove this NIC.
\r
911 IScsiRemoveNic (IScsiController);
\r
914 // Update the iSCSI Boot Firware Table.
\r
916 IScsiPublishIbft ();
\r
918 if (Private->Session != NULL) {
\r
919 IScsiSessionAbort (Private->Session);
\r
922 IScsiCleanDriverData (Private);
\r
924 return EFI_SUCCESS;
\r
928 Tests to see if this driver supports a given controller. If a child device is provided,
\r
929 it tests to see if this driver supports creating a handle for the specified child device.
\r
931 This function checks to see if the driver specified by This supports the device specified by
\r
932 ControllerHandle. Drivers typically use the device path attached to
\r
933 ControllerHandle and/or the services from the bus I/O abstraction attached to
\r
934 ControllerHandle to determine if the driver supports ControllerHandle. This function
\r
935 may be called many times during platform initialization. In order to reduce boot times, the tests
\r
936 performed by this function must be very small and take as little time as possible to execute. This
\r
937 function must not change the state of any hardware devices, and this function must be aware that the
\r
938 device specified by ControllerHandle may already be managed by the same driver or a
\r
939 different driver. This function must match its calls to AllocatePages() with FreePages(),
\r
940 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
\r
941 Since ControllerHandle may have been previously started by the same driver, if a protocol is
\r
942 already in the opened state, then it must not be closed with CloseProtocol(). This is required
\r
943 to guarantee the state of ControllerHandle is not modified by this function.
\r
945 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
946 @param[in] ControllerHandle The handle of the controller to test. This handle
\r
947 must support a protocol interface that supplies
\r
948 an I/O abstraction to the driver.
\r
949 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
950 parameter is ignored by device drivers, and is optional for bus
\r
951 drivers. For bus drivers, if this parameter is not NULL, then
\r
952 the bus driver must determine if the bus controller specified
\r
953 by ControllerHandle and the child controller specified
\r
954 by RemainingDevicePath are both supported by this
\r
957 @retval EFI_SUCCESS The device specified by ControllerHandle and
\r
958 RemainingDevicePath is supported by the driver specified by This.
\r
959 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
\r
960 RemainingDevicePath is already managed by the driver
\r
962 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
\r
963 RemainingDevicePath is already managed by a different
\r
964 driver or an application that requires exclusive access.
\r
965 Currently not implemented.
\r
966 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
\r
967 RemainingDevicePath is not supported by the driver specified by This.
\r
971 IScsiIp4DriverBindingSupported (
\r
972 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
973 IN EFI_HANDLE ControllerHandle,
\r
974 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
\r
977 return IScsiSupported (
\r
980 RemainingDevicePath,
\r
986 Starts a device controller or a bus controller.
\r
988 The Start() function is designed to be invoked from the EFI boot service ConnectController().
\r
989 As a result, much of the error checking on the parameters to Start() has been moved into this
\r
990 common boot service. It is legal to call Start() from other locations,
\r
991 but the following calling restrictions must be followed or the system behavior will not be deterministic.
\r
992 1. ControllerHandle must be a valid EFI_HANDLE.
\r
993 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
\r
994 EFI_DEVICE_PATH_PROTOCOL.
\r
995 3. Prior to calling Start(), the Supported() function for the driver specified by This must
\r
996 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
\r
998 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
999 @param[in] ControllerHandle The handle of the controller to start. This handle
\r
1000 must support a protocol interface that supplies
\r
1001 an I/O abstraction to the driver.
\r
1002 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
1003 parameter is ignored by device drivers, and is optional for bus
\r
1004 drivers. For a bus driver, if this parameter is NULL, then handles
\r
1005 for all the children of Controller are created by this driver.
\r
1006 If this parameter is not NULL and the first Device Path Node is
\r
1007 not the End of Device Path Node, then only the handle for the
\r
1008 child device specified by the first Device Path Node of
\r
1009 RemainingDevicePath is created by this driver.
\r
1010 If the first Device Path Node of RemainingDevicePath is
\r
1011 the End of Device Path Node, no child handle is created by this
\r
1014 @retval EFI_SUCCESS The device was started.
\r
1015 @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
\r
1016 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
\r
1017 @retval Others The driver failed to start the device.
\r
1022 IScsiIp4DriverBindingStart (
\r
1023 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
1024 IN EFI_HANDLE ControllerHandle,
\r
1025 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
\r
1028 EFI_STATUS Status;
\r
1030 Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4);
\r
1031 if (Status == EFI_ALREADY_STARTED) {
\r
1032 Status = EFI_SUCCESS;
\r
1039 Stops a device controller or a bus controller.
\r
1041 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
\r
1042 As a result, much of the error checking on the parameters to Stop() has been moved
\r
1043 into this common boot service. It is legal to call Stop() from other locations,
\r
1044 but the following calling restrictions must be followed or the system behavior will not be deterministic.
\r
1045 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
\r
1046 same driver's Start() function.
\r
1047 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
\r
1048 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
\r
1049 Start() function, and the Start() function must have called OpenProtocol() on
\r
1050 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
\r
1052 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
1053 @param[in] ControllerHandle A handle to the device being stopped. The handle must
\r
1054 support a bus specific I/O protocol for the driver
\r
1055 to use to stop the device.
\r
1056 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
\r
1057 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
\r
1058 if NumberOfChildren is 0.
\r
1060 @retval EFI_SUCCESS The device was stopped.
\r
1061 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
\r
1066 IScsiIp4DriverBindingStop (
\r
1067 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
1068 IN EFI_HANDLE ControllerHandle,
\r
1069 IN UINTN NumberOfChildren,
\r
1070 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
\r
1073 return IScsiStop (
\r
1077 ChildHandleBuffer,
\r
1083 Tests to see if this driver supports a given controller. If a child device is provided,
\r
1084 it tests to see if this driver supports creating a handle for the specified child device.
\r
1086 This function checks to see if the driver specified by This supports the device specified by
\r
1087 ControllerHandle. Drivers typically use the device path attached to
\r
1088 ControllerHandle and/or the services from the bus I/O abstraction attached to
\r
1089 ControllerHandle to determine if the driver supports ControllerHandle. This function
\r
1090 may be called many times during platform initialization. In order to reduce boot times, the tests
\r
1091 performed by this function must be very small and take as little time as possible to execute. This
\r
1092 function must not change the state of any hardware devices, and this function must be aware that the
\r
1093 device specified by ControllerHandle may already be managed by the same driver or a
\r
1094 different driver. This function must match its calls to AllocatePages() with FreePages(),
\r
1095 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
\r
1096 Since ControllerHandle may have been previously started by the same driver, if a protocol is
\r
1097 already in the opened state, then it must not be closed with CloseProtocol(). This is required
\r
1098 to guarantee the state of ControllerHandle is not modified by this function.
\r
1100 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
1101 @param[in] ControllerHandle The handle of the controller to test. This handle
\r
1102 must support a protocol interface that supplies
\r
1103 an I/O abstraction to the driver.
\r
1104 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
1105 parameter is ignored by device drivers, and is optional for bus
\r
1106 drivers. For bus drivers, if this parameter is not NULL, then
\r
1107 the bus driver must determine if the bus controller specified
\r
1108 by ControllerHandle and the child controller specified
\r
1109 by RemainingDevicePath are both supported by this
\r
1112 @retval EFI_SUCCESS The device specified by ControllerHandle and
\r
1113 RemainingDevicePath is supported by the driver specified by This.
\r
1114 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
\r
1115 RemainingDevicePath is already managed by the driver
\r
1116 specified by This.
\r
1117 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
\r
1118 RemainingDevicePath is already managed by a different
\r
1119 driver or an application that requires exclusive access.
\r
1120 Currently not implemented.
\r
1121 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
\r
1122 RemainingDevicePath is not supported by the driver specified by This.
\r
1126 IScsiIp6DriverBindingSupported (
\r
1127 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
1128 IN EFI_HANDLE ControllerHandle,
\r
1129 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
\r
1132 return IScsiSupported (
\r
1135 RemainingDevicePath,
\r
1141 Starts a device controller or a bus controller.
\r
1143 The Start() function is designed to be invoked from the EFI boot service ConnectController().
\r
1144 As a result, much of the error checking on the parameters to Start() has been moved into this
\r
1145 common boot service. It is legal to call Start() from other locations,
\r
1146 but the following calling restrictions must be followed or the system behavior will not be deterministic.
\r
1147 1. ControllerHandle must be a valid EFI_HANDLE.
\r
1148 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
\r
1149 EFI_DEVICE_PATH_PROTOCOL.
\r
1150 3. Prior to calling Start(), the Supported() function for the driver specified by This must
\r
1151 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
\r
1153 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
1154 @param[in] ControllerHandle The handle of the controller to start. This handle
\r
1155 must support a protocol interface that supplies
\r
1156 an I/O abstraction to the driver.
\r
1157 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
\r
1158 parameter is ignored by device drivers, and is optional for bus
\r
1159 drivers. For a bus driver, if this parameter is NULL, then handles
\r
1160 for all the children of Controller are created by this driver.
\r
1161 If this parameter is not NULL and the first Device Path Node is
\r
1162 not the End of Device Path Node, then only the handle for the
\r
1163 child device specified by the first Device Path Node of
\r
1164 RemainingDevicePath is created by this driver.
\r
1165 If the first Device Path Node of RemainingDevicePath is
\r
1166 the End of Device Path Node, no child handle is created by this
\r
1169 @retval EFI_SUCCESS The device was started.
\r
1170 @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented.
\r
1171 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
\r
1172 @retval Others The driver failed to start the device.
\r
1177 IScsiIp6DriverBindingStart (
\r
1178 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
1179 IN EFI_HANDLE ControllerHandle,
\r
1180 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
\r
1183 EFI_STATUS Status;
\r
1185 Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6);
\r
1186 if (Status == EFI_ALREADY_STARTED) {
\r
1187 Status = EFI_SUCCESS;
\r
1194 Stops a device controller or a bus controller.
\r
1196 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
\r
1197 As a result, much of the error checking on the parameters to Stop() has been moved
\r
1198 into this common boot service. It is legal to call Stop() from other locations,
\r
1199 but the following calling restrictions must be followed or the system behavior will not be deterministic.
\r
1200 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
\r
1201 same driver's Start() function.
\r
1202 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
\r
1203 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
\r
1204 Start() function, and the Start() function must have called OpenProtocol() on
\r
1205 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
\r
1207 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
\r
1208 @param[in] ControllerHandle A handle to the device being stopped. The handle must
\r
1209 support a bus specific I/O protocol for the driver
\r
1210 to use to stop the device.
\r
1211 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
\r
1212 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
\r
1213 if NumberOfChildren is 0.
\r
1215 @retval EFI_SUCCESS The device was stopped.
\r
1216 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
\r
1221 IScsiIp6DriverBindingStop (
\r
1222 IN EFI_DRIVER_BINDING_PROTOCOL *This,
\r
1223 IN EFI_HANDLE ControllerHandle,
\r
1224 IN UINTN NumberOfChildren,
\r
1225 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
\r
1228 return IScsiStop (
\r
1232 ChildHandleBuffer,
\r
1238 Unload the iSCSI driver.
\r
1240 @param[in] ImageHandle The handle of the driver image.
\r
1242 @retval EFI_SUCCESS The driver is unloaded.
\r
1243 @retval EFI_DEVICE_ERROR An unexpected error occurred.
\r
1249 IN EFI_HANDLE ImageHandle
\r
1252 EFI_STATUS Status;
\r
1253 UINTN DeviceHandleCount;
\r
1254 EFI_HANDLE *DeviceHandleBuffer;
\r
1256 EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
\r
1257 EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
\r
1260 // Try to disonnect the driver from the devices it's controlling.
\r
1262 Status = gBS->LocateHandleBuffer (
\r
1266 &DeviceHandleCount,
\r
1267 &DeviceHandleBuffer
\r
1269 if (EFI_ERROR (Status)) {
\r
1274 // Disconnect the iSCSI4 driver from the controlled device.
\r
1276 for (Index = 0; Index < DeviceHandleCount; Index++) {
\r
1277 Status = IScsiTestManagedDevice (
\r
1278 DeviceHandleBuffer[Index],
\r
1279 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1280 &gEfiTcp4ProtocolGuid)
\r
1282 if (EFI_ERROR (Status)) {
\r
1285 Status = gBS->DisconnectController (
\r
1286 DeviceHandleBuffer[Index],
\r
1287 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1290 if (EFI_ERROR (Status)) {
\r
1296 // Disconnect the iSCSI6 driver from the controlled device.
\r
1298 for (Index = 0; Index < DeviceHandleCount; Index++) {
\r
1299 Status = IScsiTestManagedDevice (
\r
1300 DeviceHandleBuffer[Index],
\r
1301 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1302 &gEfiTcp6ProtocolGuid
\r
1304 if (EFI_ERROR (Status)) {
\r
1307 Status = gBS->DisconnectController (
\r
1308 DeviceHandleBuffer[Index],
\r
1309 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1312 if (EFI_ERROR (Status)) {
\r
1318 // Unload the iSCSI configuration form.
\r
1320 Status = IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
\r
1321 if (EFI_ERROR (Status)) {
\r
1326 // Uninstall the protocols installed by iSCSI driver.
\r
1328 Status = gBS->UninstallMultipleProtocolInterfaces (
\r
1330 &gEfiAuthenticationInfoProtocolGuid,
\r
1331 &gIScsiAuthenticationInfo,
\r
1334 if (EFI_ERROR (Status)) {
\r
1338 if (gIScsiControllerNameTable!= NULL) {
\r
1339 Status = FreeUnicodeStringTable (gIScsiControllerNameTable);
\r
1340 if (EFI_ERROR (Status)) {
\r
1343 gIScsiControllerNameTable = NULL;
\r
1347 // Uninstall the ComponentName and ComponentName2 protocol from iSCSI4 driver binding handle
\r
1348 // if it has been installed.
\r
1350 Status = gBS->HandleProtocol (
\r
1351 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1352 &gEfiComponentNameProtocolGuid,
\r
1353 (VOID **) &ComponentName
\r
1355 if (!EFI_ERROR (Status)) {
\r
1356 Status = gBS->UninstallMultipleProtocolInterfaces (
\r
1357 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1358 &gEfiComponentNameProtocolGuid,
\r
1362 if (EFI_ERROR (Status)) {
\r
1367 Status = gBS->HandleProtocol (
\r
1368 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1369 &gEfiComponentName2ProtocolGuid,
\r
1370 (VOID **) &ComponentName2
\r
1372 if (!EFI_ERROR (Status)) {
\r
1373 gBS->UninstallMultipleProtocolInterfaces (
\r
1374 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1375 &gEfiComponentName2ProtocolGuid,
\r
1379 if (EFI_ERROR (Status)) {
\r
1385 // Uninstall the ComponentName and ComponentName2 protocol from iSCSI6 driver binding handle
\r
1386 // if it has been installed.
\r
1388 Status = gBS->HandleProtocol (
\r
1389 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1390 &gEfiComponentNameProtocolGuid,
\r
1391 (VOID **) &ComponentName
\r
1393 if (!EFI_ERROR (Status)) {
\r
1394 Status = gBS->UninstallMultipleProtocolInterfaces (
\r
1395 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1396 &gEfiComponentNameProtocolGuid,
\r
1400 if (EFI_ERROR (Status)) {
\r
1405 Status = gBS->HandleProtocol (
\r
1406 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1407 &gEfiComponentName2ProtocolGuid,
\r
1408 (VOID **) &ComponentName2
\r
1410 if (!EFI_ERROR (Status)) {
\r
1411 gBS->UninstallMultipleProtocolInterfaces (
\r
1412 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1413 &gEfiComponentName2ProtocolGuid,
\r
1417 if (EFI_ERROR (Status)) {
\r
1423 // Uninstall the IScsiInitiatorNameProtocol and all the driver binding protocols.
\r
1425 Status = gBS->UninstallMultipleProtocolInterfaces (
\r
1426 gIScsiIp4DriverBinding.DriverBindingHandle,
\r
1427 &gEfiDriverBindingProtocolGuid,
\r
1428 &gIScsiIp4DriverBinding,
\r
1429 &gEfiIScsiInitiatorNameProtocolGuid,
\r
1430 &gIScsiInitiatorName,
\r
1433 if (EFI_ERROR (Status)) {
\r
1437 Status = gBS->UninstallMultipleProtocolInterfaces (
\r
1438 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1439 &gEfiDriverBindingProtocolGuid,
\r
1440 &gIScsiIp6DriverBinding,
\r
1446 if (DeviceHandleBuffer != NULL) {
\r
1447 FreePool (DeviceHandleBuffer);
\r
1454 This is the declaration of an EFI image entry point. This entry point is
\r
1455 the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
\r
1456 both device drivers and bus drivers.
\r
1458 The entry point for iSCSI driver which initializes the global variables and
\r
1459 installs the driver binding, component name protocol, iSCSI initiator name
\r
1460 protocol and Authentication Info protocol on its image.
\r
1462 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
\r
1463 @param[in] SystemTable A pointer to the EFI System Table.
\r
1465 @retval EFI_SUCCESS The operation completed successfully.
\r
1466 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
\r
1471 IScsiDriverEntryPoint (
\r
1472 IN EFI_HANDLE ImageHandle,
\r
1473 IN EFI_SYSTEM_TABLE *SystemTable
\r
1476 EFI_STATUS Status;
\r
1477 EFI_ISCSI_INITIATOR_NAME_PROTOCOL *IScsiInitiatorName;
\r
1478 EFI_AUTHENTICATION_INFO_PROTOCOL *AuthenticationInfo;
\r
1481 // There should be only one EFI_ISCSI_INITIATOR_NAME_PROTOCOL.
\r
1483 Status = gBS->LocateProtocol (
\r
1484 &gEfiIScsiInitiatorNameProtocolGuid,
\r
1486 (VOID **) &IScsiInitiatorName
\r
1488 if (!EFI_ERROR (Status)) {
\r
1489 return EFI_ACCESS_DENIED;
\r
1493 // Initialize the EFI Driver Library.
\r
1495 Status = EfiLibInstallDriverBindingComponentName2 (
\r
1498 &gIScsiIp4DriverBinding,
\r
1500 &gIScsiComponentName,
\r
1501 &gIScsiComponentName2
\r
1503 if (EFI_ERROR (Status)) {
\r
1507 Status = EfiLibInstallDriverBindingComponentName2 (
\r
1510 &gIScsiIp6DriverBinding,
\r
1512 &gIScsiComponentName,
\r
1513 &gIScsiComponentName2
\r
1515 if (EFI_ERROR (Status)) {
\r
1520 // Install the iSCSI Initiator Name Protocol.
\r
1522 Status = gBS->InstallProtocolInterface (
\r
1524 &gEfiIScsiInitiatorNameProtocolGuid,
\r
1525 EFI_NATIVE_INTERFACE,
\r
1526 &gIScsiInitiatorName
\r
1528 if (EFI_ERROR (Status)) {
\r
1533 // Create the private data structures.
\r
1535 mPrivate = AllocateZeroPool (sizeof (ISCSI_PRIVATE_DATA));
\r
1536 if (mPrivate == NULL) {
\r
1537 Status = EFI_OUT_OF_RESOURCES;
\r
1541 InitializeListHead (&mPrivate->NicInfoList);
\r
1542 InitializeListHead (&mPrivate->AttemptConfigs);
\r
1545 // Initialize the configuration form of iSCSI.
\r
1547 Status = IScsiConfigFormInit (gIScsiIp4DriverBinding.DriverBindingHandle);
\r
1548 if (EFI_ERROR (Status)) {
\r
1553 // There should be only one EFI_AUTHENTICATION_INFO_PROTOCOL. If already exists,
\r
1554 // do not produce the protocol instance.
\r
1556 Status = gBS->LocateProtocol (
\r
1557 &gEfiAuthenticationInfoProtocolGuid,
\r
1559 (VOID **) &AuthenticationInfo
\r
1561 if (Status == EFI_NOT_FOUND) {
\r
1562 Status = gBS->InstallProtocolInterface (
\r
1564 &gEfiAuthenticationInfoProtocolGuid,
\r
1565 EFI_NATIVE_INTERFACE,
\r
1566 &gIScsiAuthenticationInfo
\r
1568 if (EFI_ERROR (Status)) {
\r
1573 return EFI_SUCCESS;
\r
1576 IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle);
\r
1579 FreePool (mPrivate);
\r
1582 gBS->UninstallMultipleProtocolInterfaces (
\r
1584 &gEfiIScsiInitiatorNameProtocolGuid,
\r
1585 &gIScsiInitiatorName,
\r
1590 gBS->UninstallMultipleProtocolInterfaces (
\r
1591 gIScsiIp6DriverBinding.DriverBindingHandle,
\r
1592 &gEfiDriverBindingProtocolGuid,
\r
1593 &gIScsiIp6DriverBinding,
\r
1594 &gEfiComponentName2ProtocolGuid,
\r
1595 &gIScsiComponentName2,
\r
1596 &gEfiComponentNameProtocolGuid,
\r
1597 &gIScsiComponentName,
\r
1602 gBS->UninstallMultipleProtocolInterfaces (
\r
1604 &gEfiDriverBindingProtocolGuid,
\r
1605 &gIScsiIp4DriverBinding,
\r
1606 &gEfiComponentName2ProtocolGuid,
\r
1607 &gIScsiComponentName2,
\r
1608 &gEfiComponentNameProtocolGuid,
\r
1609 &gIScsiComponentName,
\r