From 6879581d2eb67defc68ec800b369b70dec04a07b Mon Sep 17 00:00:00 2001 From: sfu5 Date: Thu, 25 Apr 2013 01:33:43 +0000 Subject: [PATCH] Update dual network stack drivers to produce multiple Driver Binding Protocol. Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Ouyang Qian git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14315 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 43 +- NetworkPkg/IScsiDxe/IScsiDriver.c | 615 +++++++++++++++------ NetworkPkg/IScsiDxe/IScsiDriver.h | 136 ++++- NetworkPkg/IpSecDxe/IkeService.c | 18 +- NetworkPkg/IpSecDxe/IkeService.h | 10 +- NetworkPkg/IpSecDxe/IpSecDriver.c | 472 +++++++++++----- NetworkPkg/TcpDxe/TcpDriver.c | 263 ++++++--- NetworkPkg/TcpDxe/TcpDriver.h | 75 ++- NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c | 434 +++++++++++---- NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h | 87 ++- 10 files changed, 1611 insertions(+), 542 deletions(-) diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 61e4c8c9d1..cfda3962bb 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -1,7 +1,7 @@ /** @file Network library. -Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -1788,6 +1788,7 @@ NetLibDefaultUnload ( EFI_HANDLE *DeviceHandleBuffer; UINTN DeviceHandleCount; UINTN Index; + UINTN Index2; EFI_DRIVER_BINDING_PROTOCOL *DriverBinding; EFI_COMPONENT_NAME_PROTOCOL *ComponentName; EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2; @@ -1809,28 +1810,12 @@ NetLibDefaultUnload ( return Status; } - // - // Disconnect the driver specified by ImageHandle from all - // the devices in the handle database. - // - for (Index = 0; Index < DeviceHandleCount; Index++) { - Status = gBS->DisconnectController ( - DeviceHandleBuffer[Index], - ImageHandle, - NULL - ); - } - - // - // Uninstall all the protocols installed in the driver entry point - // for (Index = 0; Index < DeviceHandleCount; Index++) { Status = gBS->HandleProtocol ( DeviceHandleBuffer[Index], &gEfiDriverBindingProtocolGuid, (VOID **) &DriverBinding ); - if (EFI_ERROR (Status)) { continue; } @@ -1838,12 +1823,28 @@ NetLibDefaultUnload ( if (DriverBinding->ImageHandle != ImageHandle) { continue; } - + + // + // Disconnect the driver specified by ImageHandle from all + // the devices in the handle database. + // + for (Index2 = 0; Index2 < DeviceHandleCount; Index2++) { + Status = gBS->DisconnectController ( + DeviceHandleBuffer[Index2], + DriverBinding->DriverBindingHandle, + NULL + ); + } + + // + // Uninstall all the protocols installed in the driver entry point + // gBS->UninstallProtocolInterface ( - ImageHandle, + DriverBinding->DriverBindingHandle, &gEfiDriverBindingProtocolGuid, DriverBinding ); + Status = gBS->HandleProtocol ( DeviceHandleBuffer[Index], &gEfiComponentNameProtocolGuid, @@ -1851,7 +1852,7 @@ NetLibDefaultUnload ( ); if (!EFI_ERROR (Status)) { gBS->UninstallProtocolInterface ( - ImageHandle, + DriverBinding->DriverBindingHandle, &gEfiComponentNameProtocolGuid, ComponentName ); @@ -1864,7 +1865,7 @@ NetLibDefaultUnload ( ); if (!EFI_ERROR (Status)) { gBS->UninstallProtocolInterface ( - ImageHandle, + DriverBinding->DriverBindingHandle, &gEfiComponentName2ProtocolGuid, ComponentName2 ); diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.c b/NetworkPkg/IScsiDxe/IScsiDriver.c index 2fd4c95a08..cc452e7110 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.c +++ b/NetworkPkg/IScsiDxe/IScsiDriver.c @@ -1,7 +1,7 @@ /** @file The entry point of IScsi driver. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -14,10 +14,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "IScsiImpl.h" -EFI_DRIVER_BINDING_PROTOCOL gIScsiDriverBinding = { - IScsiDriverBindingSupported, - IScsiDriverBindingStart, - IScsiDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gIScsiIp4DriverBinding = { + IScsiIp4DriverBindingSupported, + IScsiIp4DriverBindingStart, + IScsiIp4DriverBindingStop, + 0xa, + NULL, + NULL +}; + +EFI_DRIVER_BINDING_PROTOCOL gIScsiIp6DriverBinding = { + IScsiIp6DriverBindingSupported, + IScsiIp6DriverBindingStart, + IScsiIp6DriverBindingStop, 0xa, NULL, NULL @@ -28,7 +37,7 @@ EFI_GUID gIScsiV6PrivateGuid = ISCSI_V6_PRIVATE_GUID; ISCSI_PRIVATE_DATA *mPrivate = NULL; /** - Tests to see if this driver supports the RemainingDevicePath. + Tests to see if this driver supports the RemainingDevicePath. @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This parameter is ignored by device drivers, and is optional for bus @@ -67,22 +76,8 @@ IScsiIsDevicePathSupported ( /** - Tests to see if this driver supports a given controller. If a child device is provided, - it further tests to see if this driver supports creating a handle for the specified child device. - - This function checks to see if the driver specified by This supports the device specified by - ControllerHandle. Drivers typically use the device path attached to - ControllerHandle and/or the services from the bus I/O abstraction attached to - ControllerHandle to determine if the driver supports ControllerHandle. This function - may be called many times during platform initialization. In order to reduce boot times, the tests - performed by this function must be very small and take as little time as possible to execute. This - function must not change the state of any hardware devices, and this function must be aware that the - device specified by ControllerHandle may already be managed by the same driver or a - different driver. This function must match its calls to AllocatePages() with FreePages(), - AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). - Since ControllerHandle may have been previously started by the same driver, if a protocol is - already in the opened state, then it must not be closed with CloseProtocol(). This is required - to guarantee the state of ControllerHandle is not modified by this function. + Tests to see if this driver supports a given controller. This is the worker function for + IScsiIp4(6)DriverBindingSupported. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle The handle of the controller to test. This handle @@ -95,75 +90,51 @@ IScsiIsDevicePathSupported ( by ControllerHandle and the child controller specified by RemainingDevicePath are both supported by this bus driver. + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. @retval EFI_SUCCESS The device specified by ControllerHandle and RemainingDevicePath is supported by the driver specified by This. @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and RemainingDevicePath is already being managed by the driver specified by This. - @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and - RemainingDevicePath is already being managed by a different - driver or an application that requires exclusive access. - Currently not implemented. @retval EFI_UNSUPPORTED The device specified by ControllerHandle and RemainingDevicePath is not supported by the driver specified by This. **/ EFI_STATUS EFIAPI -IScsiDriverBindingSupported ( +IScsiSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN UINT8 IpVersion ) { EFI_STATUS Status; - BOOLEAN IsIscsi4Started; + EFI_GUID *IScsiServiceBindingGuid; + EFI_GUID *TcpServiceBindingGuid; - Status = gBS->OpenProtocol ( - ControllerHandle, - &gIScsiV4PrivateGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - IsIscsi4Started = TRUE; + if (IpVersion == IP_VERSION_4) { + IScsiServiceBindingGuid = &gIScsiV4PrivateGuid; + TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid; } else { - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiTcp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - Status = IScsiIsDevicePathSupported (RemainingDevicePath); - if (!EFI_ERROR (Status)) { - return EFI_SUCCESS; - } - } - - IsIscsi4Started = FALSE; + IScsiServiceBindingGuid = &gIScsiV6PrivateGuid; + TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; } Status = gBS->OpenProtocol ( ControllerHandle, - &gIScsiV6PrivateGuid, + IScsiServiceBindingGuid, NULL, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); if (!EFI_ERROR (Status)) { - if (IsIscsi4Started) { - return EFI_ALREADY_STARTED; - } + return EFI_ALREADY_STARTED; } else { Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiTcp6ServiceBindingProtocolGuid, + TcpServiceBindingGuid, NULL, This->DriverBindingHandle, ControllerHandle, @@ -183,13 +154,13 @@ IScsiDriverBindingSupported ( /** Start to manage the controller. This is the worker function for - IScsiDriverBindingStart. + IScsiIp4(6)DriverBindingStart. @param[in] Image Handle of the image. @param[in] ControllerHandle Handle of the controller. - @param[in] IpVersion Ip4 or Ip6 + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. - @retval EFI_SUCCES This driver supports this device. + @retval EFI_SUCCES This driver was started. @retval EFI_ALREADY_STARTED This driver is already running on this device. @retval EFI_INVALID_PARAMETER Any input parameter is invalid. @retval EFI_NOT_FOUND There is no sufficient information to establish @@ -777,83 +748,8 @@ ON_ERROR: } /** - Starts a device controller or a bus controller. - - The Start() function is designed to be invoked from the EFI boot service ConnectController(). - As a result, much of the error checking on the parameters to Start() has been moved into this - common boot service. It is legal to call Start() from other locations, - but the following calling restrictions must be followed or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE. - 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned - EFI_DEVICE_PATH_PROTOCOL. - 3. Prior to calling Start(), the Supported() function for the driver specified by This must - have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. - - @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. - @param[in] ControllerHandle The handle of the controller to start. This handle - must support a protocol interface that supplies - an I/O abstraction to the driver. - @param[in] RemainingDevicePath A 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. - - @retval EFI_SUCCESS The device was started. - @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented. - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. - @retval Others The driver failed to start the device. - -**/ -EFI_STATUS -EFIAPI -IScsiDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL - ) -{ - EFI_STATUS V4Status; - EFI_STATUS V6Status; - - V4Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4); - if (V4Status == EFI_ALREADY_STARTED) { - V4Status = EFI_SUCCESS; - } - - V6Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6); - if (V6Status == EFI_ALREADY_STARTED) { - V6Status = EFI_SUCCESS; - } - - if (!EFI_ERROR (V4Status) || !EFI_ERROR (V6Status)) { - return EFI_SUCCESS; - } else if (EFI_ERROR (V4Status)) { - return V4Status; - } else { - return V6Status; - } -} - -/** - Stops a device controller or a bus controller. - - The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). - As a result, much of the error checking on the parameters to Stop() has been moved - into this common boot service. It is legal to call Stop() from other locations, - but the following calling restrictions must be followed or the system behavior will not be deterministic. - 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this - same driver's Start() function. - 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid - EFI_HANDLE. In addition, all of these handles must have been created in this driver's - Start() function, and the Start() function must have called OpenProtocol() on - ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + Stops a device controller or a bus controller. This is the worker function for + IScsiIp4(6)DriverBindingStop. @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. @param[in] ControllerHandle A handle to the device being stopped. The handle must @@ -862,18 +758,20 @@ IScsiDriverBindingStart ( @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL if NumberOfChildren is 0. - + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. + @retval EFI_SUCCESS The device was stopped. @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. **/ EFI_STATUS EFIAPI -IScsiDriverBindingStop ( +IScsiStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL, + IN UINT8 IpVersion ) { EFI_HANDLE IScsiController; @@ -911,7 +809,7 @@ IScsiDriverBindingStop ( // the protocol here, but do not uninstall the device path protocol and // EXT SCSI PASS THRU protocol installed on ExtScsiPassThruHandle. // - if (!Conn->Ipv6Flag) { + if (IpVersion == IP_VERSION_4) { ProtocolGuid = &gEfiTcp4ProtocolGuid; } else { ProtocolGuid = &gEfiTcp6ProtocolGuid; @@ -929,18 +827,19 @@ IScsiDriverBindingStop ( // // Get the handle of the controller we are controling. // - IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid); - if (IScsiController != NULL) { + if (IpVersion == IP_VERSION_4) { ProtocolGuid = &gIScsiV4PrivateGuid; TcpProtocolGuid = &gEfiTcp4ProtocolGuid; TcpServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid; } else { - IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp6ProtocolGuid); - ASSERT (IScsiController != NULL); ProtocolGuid = &gIScsiV6PrivateGuid; TcpProtocolGuid = &gEfiTcp6ProtocolGuid; TcpServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; } + IScsiController = NetLibGetNicHandle (ControllerHandle, TcpProtocolGuid); + if (IScsiController == NULL) { + return EFI_SUCCESS; + } Status = gBS->OpenProtocol ( IScsiController, @@ -1002,6 +901,315 @@ IScsiDriverBindingStop ( return EFI_SUCCESS; } +/** + Tests to see if this driver supports a given controller. If a child device is provided, + it tests to see if this driver supports creating a handle for the specified child device. + + This function checks to see if the driver specified by This supports the device specified by + ControllerHandle. Drivers typically use the device path attached to + ControllerHandle and/or the services from the bus I/O abstraction attached to + ControllerHandle to determine if the driver supports ControllerHandle. This function + may be called many times during platform initialization. In order to reduce boot times, the tests + performed by this function must be very small and take as little time as possible to execute. This + function must not change the state of any hardware devices, and this function must be aware that the + device specified by ControllerHandle may already be managed by the same driver or a + different driver. This function must match its calls to AllocatePages() with FreePages(), + AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). + Since ControllerHandle may have been previously started by the same driver, if a protocol is + already in the opened state, then it must not be closed with CloseProtocol(). This is required + to guarantee the state of ControllerHandle is not modified by this function. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to test. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This + parameter is ignored by device drivers, and is optional for bus + drivers. For bus drivers, if this parameter is not NULL, then + the bus driver must determine if the bus controller specified + by ControllerHandle and the child controller specified + by RemainingDevicePath are both supported by this + bus driver. + + @retval EFI_SUCCESS The device specified by ControllerHandle and + RemainingDevicePath is supported by the driver specified by This. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and + RemainingDevicePath is already managed by the driver + specified by This. + @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and + RemainingDevicePath is already managed by a different + driver or an application that requires exclusive access. + Currently not implemented. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle and + RemainingDevicePath is not supported by the driver specified by This. +**/ +EFI_STATUS +EFIAPI +IScsiIp4DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IScsiSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_4 + ); +} + +/** + Starts a device controller or a bus controller. + + The Start() function is designed to be invoked from the EFI boot service ConnectController(). + As a result, much of the error checking on the parameters to Start() has been moved into this + common boot service. It is legal to call Start() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE. + 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned + EFI_DEVICE_PATH_PROTOCOL. + 3. Prior to calling Start(), the Supported() function for the driver specified by This must + have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to start. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A 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. + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + @retval Others The driver failed to start the device. + +**/ +EFI_STATUS +EFIAPI +IScsiIp4DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + EFI_STATUS Status; + + Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_4); + if (Status == EFI_ALREADY_STARTED) { + Status = EFI_SUCCESS; + } + + return Status; +} + +/** + Stops a device controller or a bus controller. + + The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). + As a result, much of the error checking on the parameters to Stop() has been moved + into this common boot service. It is legal to call Stop() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this + same driver's Start() function. + 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid + EFI_HANDLE. In addition, all of these handles must have been created in this driver's + Start() function, and the Start() function must have called OpenProtocol() on + ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + +**/ +EFI_STATUS +EFIAPI +IScsiIp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ) +{ + return IScsiStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_4 + ); +} + +/** + Tests to see if this driver supports a given controller. If a child device is provided, + it tests to see if this driver supports creating a handle for the specified child device. + + This function checks to see if the driver specified by This supports the device specified by + ControllerHandle. Drivers typically use the device path attached to + ControllerHandle and/or the services from the bus I/O abstraction attached to + ControllerHandle to determine if the driver supports ControllerHandle. This function + may be called many times during platform initialization. In order to reduce boot times, the tests + performed by this function must be very small and take as little time as possible to execute. This + function must not change the state of any hardware devices, and this function must be aware that the + device specified by ControllerHandle may already be managed by the same driver or a + different driver. This function must match its calls to AllocatePages() with FreePages(), + AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). + Since ControllerHandle may have been previously started by the same driver, if a protocol is + already in the opened state, then it must not be closed with CloseProtocol(). This is required + to guarantee the state of ControllerHandle is not modified by this function. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to test. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This + parameter is ignored by device drivers, and is optional for bus + drivers. For bus drivers, if this parameter is not NULL, then + the bus driver must determine if the bus controller specified + by ControllerHandle and the child controller specified + by RemainingDevicePath are both supported by this + bus driver. + + @retval EFI_SUCCESS The device specified by ControllerHandle and + RemainingDevicePath is supported by the driver specified by This. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and + RemainingDevicePath is already managed by the driver + specified by This. + @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and + RemainingDevicePath is already managed by a different + driver or an application that requires exclusive access. + Currently not implemented. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle and + RemainingDevicePath is not supported by the driver specified by This. +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IScsiSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_6 + ); +} + +/** + Starts a device controller or a bus controller. + + The Start() function is designed to be invoked from the EFI boot service ConnectController(). + As a result, much of the error checking on the parameters to Start() has been moved into this + common boot service. It is legal to call Start() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE. + 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned + EFI_DEVICE_PATH_PROTOCOL. + 3. Prior to calling Start(), the Supported() function for the driver specified by This must + have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to start. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A 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. + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + @retval Others The driver failed to start the device. + +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + EFI_STATUS Status; + + Status = IScsiStart (This->DriverBindingHandle, ControllerHandle, IP_VERSION_6); + if (Status == EFI_ALREADY_STARTED) { + Status = EFI_SUCCESS; + } + + return Status; +} + +/** + Stops a device controller or a bus controller. + + The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). + As a result, much of the error checking on the parameters to Stop() has been moved + into this common boot service. It is legal to call Stop() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this + same driver's Start() function. + 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid + EFI_HANDLE. In addition, all of these handles must have been created in this driver's + Start() function, and the Start() function must have called OpenProtocol() on + ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ) +{ + return IScsiStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_6 + ); +} /** Unload the iSCSI driver. @@ -1033,23 +1241,27 @@ IScsiUnload ( &DeviceHandleCount, &DeviceHandleBuffer ); - if (!EFI_ERROR (Status)) { - for (Index = 0; Index < DeviceHandleCount; Index++) { - Status = gBS->DisconnectController ( - DeviceHandleBuffer[Index], - ImageHandle, - NULL - ); - } + if (EFI_ERROR (Status)) { + return Status; + } - if (DeviceHandleBuffer != NULL) { - FreePool (DeviceHandleBuffer); - } + for (Index = 0; Index < DeviceHandleCount; Index++) { + gBS->DisconnectController ( + DeviceHandleBuffer[Index], + gIScsiIp4DriverBinding.DriverBindingHandle, + NULL + ); + gBS->DisconnectController ( + DeviceHandleBuffer[Index], + gIScsiIp6DriverBinding.DriverBindingHandle, + NULL + ); } + // // Unload the iSCSI configuration form. // - IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle); + IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle); // // Uninstall the protocols installed by iSCSI driver. @@ -1066,18 +1278,31 @@ IScsiUnload ( gIScsiControllerNameTable = NULL; } - return gBS->UninstallMultipleProtocolInterfaces ( - ImageHandle, - &gEfiDriverBindingProtocolGuid, - &gIScsiDriverBinding, - &gEfiComponentName2ProtocolGuid, - &gIScsiComponentName2, - &gEfiComponentNameProtocolGuid, - &gIScsiComponentName, - &gEfiIScsiInitiatorNameProtocolGuid, - &gIScsiInitiatorName, - NULL - ); + gBS->UninstallMultipleProtocolInterfaces ( + gIScsiIp4DriverBinding.DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, + &gIScsiIp4DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gIScsiComponentName2, + &gEfiComponentNameProtocolGuid, + &gIScsiComponentName, + &gEfiIScsiInitiatorNameProtocolGuid, + &gIScsiInitiatorName, + NULL + ); + + gBS->UninstallMultipleProtocolInterfaces ( + gIScsiIp6DriverBinding.DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, + &gIScsiIp6DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gIScsiComponentName2, + &gEfiComponentNameProtocolGuid, + &gIScsiComponentName, + NULL + ); + + return EFI_SUCCESS; } /** @@ -1125,7 +1350,7 @@ IScsiDriverEntryPoint ( Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, - &gIScsiDriverBinding, + &gIScsiIp4DriverBinding, ImageHandle, &gIScsiComponentName, &gIScsiComponentName2 @@ -1134,6 +1359,18 @@ IScsiDriverEntryPoint ( return Status; } + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gIScsiIp6DriverBinding, + NULL, + &gIScsiComponentName, + &gIScsiComponentName2 + ); + if (EFI_ERROR (Status)) { + goto Error1; + } + // // Install the iSCSI Initiator Name Protocol. // @@ -1144,7 +1381,7 @@ IScsiDriverEntryPoint ( &gIScsiInitiatorName ); if (EFI_ERROR (Status)) { - goto Error1; + goto Error2; } // @@ -1153,7 +1390,7 @@ IScsiDriverEntryPoint ( mPrivate = AllocateZeroPool (sizeof (ISCSI_PRIVATE_DATA)); if (mPrivate == NULL) { Status = EFI_OUT_OF_RESOURCES; - goto Error2; + goto Error3; } InitializeListHead (&mPrivate->NicInfoList); @@ -1162,9 +1399,9 @@ IScsiDriverEntryPoint ( // // Initialize the configuration form of iSCSI. // - Status = IScsiConfigFormInit (gIScsiDriverBinding.DriverBindingHandle); + Status = IScsiConfigFormInit (gIScsiIp4DriverBinding.DriverBindingHandle); if (EFI_ERROR (Status)) { - goto Error3; + goto Error4; } // @@ -1184,19 +1421,19 @@ IScsiDriverEntryPoint ( &gIScsiAuthenticationInfo ); if (EFI_ERROR (Status)) { - goto Error4; + goto Error5; } } return EFI_SUCCESS; -Error4: - IScsiConfigFormUnload (gIScsiDriverBinding.DriverBindingHandle); +Error5: + IScsiConfigFormUnload (gIScsiIp4DriverBinding.DriverBindingHandle); -Error3: +Error4: FreePool (mPrivate); -Error2: +Error3: gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiIScsiInitiatorNameProtocolGuid, @@ -1204,11 +1441,23 @@ Error2: NULL ); +Error2: + gBS->UninstallMultipleProtocolInterfaces ( + gIScsiIp6DriverBinding.DriverBindingHandle, + &gEfiDriverBindingProtocolGuid, + &gIScsiIp6DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gIScsiComponentName2, + &gEfiComponentNameProtocolGuid, + &gIScsiComponentName, + NULL + ); + Error1: gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, &gEfiDriverBindingProtocolGuid, - &gIScsiDriverBinding, + &gIScsiIp4DriverBinding, &gEfiComponentName2ProtocolGuid, &gIScsiComponentName2, &gEfiComponentNameProtocolGuid, diff --git a/NetworkPkg/IScsiDxe/IScsiDriver.h b/NetworkPkg/IScsiDxe/IScsiDriver.h index 8c266fe763..825394a1d2 100644 --- a/NetworkPkg/IScsiDxe/IScsiDriver.h +++ b/NetworkPkg/IScsiDxe/IScsiDriver.h @@ -1,7 +1,7 @@ /** @file The header file of IScsiDriver.c. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -126,7 +126,7 @@ typedef struct _ISCSI_PRIVATE_PROTOCOL { **/ EFI_STATUS EFIAPI -IScsiDriverBindingSupported ( +IScsiIp4DriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL @@ -169,7 +169,7 @@ IScsiDriverBindingSupported ( **/ EFI_STATUS EFIAPI -IScsiDriverBindingStart ( +IScsiIp4DriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL @@ -203,7 +203,135 @@ IScsiDriverBindingStart ( **/ EFI_STATUS EFIAPI -IScsiDriverBindingStop ( +IScsiIp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ); + +/** + Tests to see if this driver supports a given controller. If a child device is provided, + it tests to see if this driver supports creating a handle for the specified child device. + + This function checks to see if the driver specified by This supports the device specified by + ControllerHandle. Drivers typically use the device path attached to + ControllerHandle and/or the services from the bus I/O abstraction attached to + ControllerHandle to determine if the driver supports ControllerHandle. This function + may be called many times during platform initialization. In order to reduce boot times, the tests + performed by this function must be very small and take as little time as possible to execute. This + function must not change the state of any hardware devices, and this function must be aware that the + device specified by ControllerHandle may already be managed by the same driver or a + different driver. This function must match its calls to AllocatePages() with FreePages(), + AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol(). + Since ControllerHandle may have been previously started by the same driver, if a protocol is + already in the opened state, then it must not be closed with CloseProtocol(). This is required + to guarantee the state of ControllerHandle is not modified by this function. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to test. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This + parameter is ignored by device drivers, and is optional for bus + drivers. For bus drivers, if this parameter is not NULL, then + the bus driver must determine if the bus controller specified + by ControllerHandle and the child controller specified + by RemainingDevicePath are both supported by this + bus driver. + + @retval EFI_SUCCESS The device specified by ControllerHandle and + RemainingDevicePath is supported by the driver specified by This. + @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and + RemainingDevicePath is already managed by the driver + specified by This. + @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and + RemainingDevicePath is already managed by a different + driver or an application that requires exclusive access. + Currently not implemented. + @retval EFI_UNSUPPORTED The device specified by ControllerHandle and + RemainingDevicePath is not supported by the driver specified by This. +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Starts a device controller or a bus controller. + + The Start() function is designed to be invoked from the EFI boot service ConnectController(). + As a result, much of the error checking on the parameters to Start() has been moved into this + common boot service. It is legal to call Start() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE. + 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned + EFI_DEVICE_PATH_PROTOCOL. + 3. Prior to calling Start(), the Supported() function for the driver specified by This must + have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle The handle of the controller to start. This handle + must support a protocol interface that supplies + an I/O abstraction to the driver. + @param[in] RemainingDevicePath A 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. + + @retval EFI_SUCCESS The device was started. + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. Currently not implemented. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. + @retval Others The driver failed to start the device. + +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Stops a device controller or a bus controller. + + The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). + As a result, much of the error checking on the parameters to Stop() has been moved + into this common boot service. It is legal to call Stop() from other locations, + but the following calling restrictions must be followed or the system behavior will not be deterministic. + 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this + same driver's Start() function. + 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid + EFI_HANDLE. In addition, all of these handles must have been created in this driver's + Start() function, and the Start() function must have called OpenProtocol() on + ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + +**/ +EFI_STATUS +EFIAPI +IScsiIp6DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, diff --git a/NetworkPkg/IpSecDxe/IkeService.c b/NetworkPkg/IpSecDxe/IkeService.c index b68f4567c5..8e2c794dc3 100644 --- a/NetworkPkg/IpSecDxe/IkeService.c +++ b/NetworkPkg/IpSecDxe/IkeService.c @@ -1,7 +1,7 @@ /** @file Provide IPsec Key Exchange (IKE) service general interfaces. - Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -346,6 +346,7 @@ ON_EXIT: @param[in] Private Point to IPSEC_PRIVATE_DATA @param[in] Controller Handler for NIC card. + @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance. @retval EFI_SUCCESS The Operation is successful. @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated. @@ -354,7 +355,8 @@ ON_EXIT: EFI_STATUS IkeOpenInputUdp4 ( IN IPSEC_PRIVATE_DATA *Private, - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE ImageHandle ) { IKE_UDP_SERVICE *Udp4Srv; @@ -378,7 +380,7 @@ IkeOpenInputUdp4 ( // Udp4Srv->Input = UdpIoCreateIo ( Controller, - Private->ImageHandle, + ImageHandle, IkeConfigUdp4, UDP_IO_UDP4_VERSION, NULL @@ -390,7 +392,7 @@ IkeOpenInputUdp4 ( } Udp4Srv->NicHandle = Controller; - Udp4Srv->ImageHandle = Private->ImageHandle; + Udp4Srv->ImageHandle = ImageHandle; Udp4Srv->ListHead = &(Private->Udp4List); Udp4Srv->IpVersion = UDP_IO_UDP4_VERSION; Udp4Srv->IsConfigured = FALSE; @@ -417,6 +419,7 @@ IkeOpenInputUdp4 ( @param[in] Private Point to IPSEC_PRIVATE_DATA @param[in] Controller Handler for NIC card. + @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance. @retval EFI_SUCCESS The Operation is successful. @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated. @@ -425,7 +428,8 @@ IkeOpenInputUdp4 ( EFI_STATUS IkeOpenInputUdp6 ( IN IPSEC_PRIVATE_DATA *Private, - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE ImageHandle ) { IKE_UDP_SERVICE *Udp6Srv; @@ -446,7 +450,7 @@ IkeOpenInputUdp6 ( // Udp6Srv->Input = UdpIoCreateIo ( Controller, - Private->ImageHandle, + ImageHandle, IkeConfigUdp6, UDP_IO_UDP6_VERSION, NULL @@ -458,7 +462,7 @@ IkeOpenInputUdp6 ( } Udp6Srv->NicHandle = Controller; - Udp6Srv->ImageHandle = Private->ImageHandle; + Udp6Srv->ImageHandle = ImageHandle; Udp6Srv->ListHead = &(Private->Udp6List); Udp6Srv->IpVersion = UDP_IO_UDP6_VERSION; Udp6Srv->IsConfigured = FALSE; diff --git a/NetworkPkg/IpSecDxe/IkeService.h b/NetworkPkg/IpSecDxe/IkeService.h index cc21154ac6..3ebd17919a 100644 --- a/NetworkPkg/IpSecDxe/IkeService.h +++ b/NetworkPkg/IpSecDxe/IkeService.h @@ -1,7 +1,7 @@ /** @file Prototypes definitions of IKE service. - Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -143,6 +143,7 @@ typedef struct _IKE_EXCHANGE_INTERFACE { @param[in] Private Point to IPSEC_PRIVATE_DATA @param[in] Controller Handler for NIC card. + @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance. @retval EFI_SUCCESS The Operation is successful. @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated. @@ -151,7 +152,8 @@ typedef struct _IKE_EXCHANGE_INTERFACE { EFI_STATUS IkeOpenInputUdp4 ( IN IPSEC_PRIVATE_DATA *Private, - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE ImageHandle ); /** @@ -162,6 +164,7 @@ IkeOpenInputUdp4 ( @param[in] Private Point to IPSEC_PRIVATE_DATA @param[in] Controller Handler for NIC card. + @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance. @retval EFI_SUCCESS The Operation is successful. @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated. @@ -170,7 +173,8 @@ IkeOpenInputUdp4 ( EFI_STATUS IkeOpenInputUdp6 ( IN IPSEC_PRIVATE_DATA *Private, - IN EFI_HANDLE Controller + IN EFI_HANDLE Controller, + IN EFI_HANDLE ImageHandle ); /** diff --git a/NetworkPkg/IpSecDxe/IpSecDriver.c b/NetworkPkg/IpSecDxe/IpSecDriver.c index 753c70db54..454d218c75 100644 --- a/NetworkPkg/IpSecDxe/IpSecDriver.c +++ b/NetworkPkg/IpSecDxe/IpSecDriver.c @@ -1,7 +1,7 @@ /** @file Driver Binding Protocol for IPsec Driver. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -20,13 +20,15 @@ #include "IpSecDebug.h" /** - Test to see if this driver supports ControllerHandle. + Test to see if this driver supports ControllerHandle. This is the worker function + for IpSec4(6)DriverbindingSupported. @param[in] This Protocol instance pointer. @param[in] ControllerHandle Handle of device to test. @param[in] RemainingDevicePath Optional parameter used to pick a specific child device to start. - + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. + @retval EFI_SUCCES This driver supports this device. @retval EFI_ALREADY_STARTED This driver is already running on this device. @retval other This driver does not support this device. @@ -34,50 +36,45 @@ **/ EFI_STATUS EFIAPI -IpSecDriverBindingSupported ( +IpSecSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN UINT8 IpVersion ) { - EFI_STATUS Udp4Status; - EFI_STATUS Udp6Status; - - Udp4Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiUdp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - - Udp6Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiUdp6ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - - // - // The controller with either Udp4Sb or Udp6Sb is supported. - // - if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) { - return EFI_SUCCESS; + EFI_STATUS Status; + EFI_GUID *UdpServiceBindingGuid; + + if (IpVersion == IP_VERSION_4) { + UdpServiceBindingGuid = &gEfiUdp4ServiceBindingProtocolGuid; + } else { + UdpServiceBindingGuid = &gEfiUdp6ServiceBindingProtocolGuid; } - return EFI_UNSUPPORTED; + Status = gBS->OpenProtocol ( + ControllerHandle, + UdpServiceBindingGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return EFI_UNSUPPORTED; + } + return EFI_SUCCESS; } /** - Start this driver on ControllerHandle. + Start this driver on ControllerHandle. This is the worker function + for IpSec4(6)DriverbindingStart. @param[in] This Protocol instance pointer. @param[in] ControllerHandle Handle of device to bind driver to. @param[in] RemainingDevicePath Optional parameter used to pick a specific child device to start. + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. @retval EFI_SUCCES This driver is added to ControllerHandle @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle @@ -88,16 +85,15 @@ IpSecDriverBindingSupported ( **/ EFI_STATUS EFIAPI -IpSecDriverBindingStart ( +IpSecStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN UINT8 IpVersion ) { EFI_IPSEC2_PROTOCOL *IpSec; EFI_STATUS Status; - EFI_STATUS Udp4Status; - EFI_STATUS Udp6Status; IPSEC_PRIVATE_DATA *Private; // @@ -111,52 +107,56 @@ IpSecDriverBindingStart ( Private = IPSEC_PRIVATE_DATA_FROM_IPSEC (IpSec); - // - // If udp4 sb is on the controller, try to open a udp4 io for input. - // - Udp4Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiUdp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - - if (!EFI_ERROR (Udp4Status)) { - Udp4Status = IkeOpenInputUdp4 (Private, ControllerHandle); - } - // - // If udp6 sb is on the controller, try to open a udp6 io for input. - // - Udp6Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiUdp6ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - - if (!EFI_ERROR (Udp6Status)) { - Udp6Status = IkeOpenInputUdp6 (Private, ControllerHandle); + if (IpVersion == IP_VERSION_4) { + // + // Try to open a udp4 io for input. + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiUdp4ServiceBindingProtocolGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + + if (!EFI_ERROR (Status)) { + Status = IkeOpenInputUdp4 (Private, ControllerHandle, This->DriverBindingHandle); + } + } else { + // + // Try to open a udp6 io for input. + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiUdp6ServiceBindingProtocolGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + + if (!EFI_ERROR (Status)) { + Status = IkeOpenInputUdp6 (Private, ControllerHandle, This->DriverBindingHandle); + } } - if (!EFI_ERROR (Udp4Status) || !EFI_ERROR (Udp6Status)) { - return EFI_SUCCESS; + if (EFI_ERROR (Status)) { + return EFI_DEVICE_ERROR; } - - return EFI_DEVICE_ERROR; + return EFI_SUCCESS; } /** - Stop this driver on ControllerHandle. + Stop this driver on ControllerHandle. This is the worker function + for IpSec4(6)DriverbindingStop. @param[in] This Protocol instance pointer. @param[in] ControllerHandle Handle of a device to stop the driver on. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of children is zero, stop the entire bus driver. @param[in] ChildHandleBuffer List of Child Handles to Stop. + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. @retval EFI_SUCCES This driver removed ControllerHandle. @retval other This driver was not removed from this device. @@ -164,11 +164,12 @@ IpSecDriverBindingStart ( **/ EFI_STATUS EFIAPI -IpSecDriverBindingStop ( +IpSecStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_HANDLE *ChildHandleBuffer, + IN UINT8 IpVersion ) { EFI_IPSEC2_PROTOCOL *IpSec; @@ -190,69 +191,268 @@ IpSecDriverBindingStop ( Private = IPSEC_PRIVATE_DATA_FROM_IPSEC (IpSec); // - // Delete all SAs before stop Ipsec. - // - IkeDeleteAllSas (Private, FALSE); + // The SAs are shared by both IP4 and IP6 stack. So we skip the cleanup + // and leave the SAs unchanged if the other IP stack is still running. // - // If has udp4 io opened on the controller, close and free it. - // - NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) { + if ((IpVersion == IP_VERSION_4 && Private->Udp6Num ==0) || + (IpVersion == IP_VERSION_6 && Private->Udp4Num ==0)) { + IkeDeleteAllSas (Private, FALSE); + } - UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry); + if (IpVersion == IP_VERSION_4) { // - // Find the right udp service which installed on the appointed nic handle. + // If has udp4 io opened on the controller, close and free it. // - if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) { - UdpIoFreeIo (UdpSrv->Input); - UdpSrv->Input = NULL; + NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp4List) { + + UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry); + // + // Find the right udp service which installed on the appointed nic handle. + // + if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) { + UdpIoFreeIo (UdpSrv->Input); + UdpSrv->Input = NULL; + } + + if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) { + UdpIoFreeIo (UdpSrv->Output); + UdpSrv->Output = NULL; + } + + if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) { + RemoveEntryList (&UdpSrv->List); + FreePool (UdpSrv); + ASSERT (Private->Udp4Num > 0); + Private->Udp4Num--; + } } - - if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) { - UdpIoFreeIo (UdpSrv->Output); - UdpSrv->Output = NULL; - } - - if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) { - RemoveEntryList (&UdpSrv->List); - FreePool (UdpSrv); - ASSERT (Private->Udp4Num > 0); - Private->Udp4Num--; - } - } - // - // If has udp6 io opened on the controller, close and free it. - // - NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) { - - UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry); + } else { // - // Find the right udp service which installed on the appointed nic handle. + // If has udp6 io opened on the controller, close and free it. // - if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) { - UdpIoFreeIo (UdpSrv->Input); - UdpSrv->Input = NULL; - } - - if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) { - UdpIoFreeIo (UdpSrv->Output); - UdpSrv->Output = NULL; - } - - if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) { - RemoveEntryList (&UdpSrv->List); - FreePool (UdpSrv); - ASSERT (Private->Udp6Num > 0); - Private->Udp6Num--; + NET_LIST_FOR_EACH_SAFE (Entry, Next, &Private->Udp6List) { + + UdpSrv = IPSEC_UDP_SERVICE_FROM_LIST (Entry); + // + // Find the right udp service which installed on the appointed nic handle. + // + if (UdpSrv->Input != NULL && ControllerHandle == UdpSrv->Input->UdpHandle) { + UdpIoFreeIo (UdpSrv->Input); + UdpSrv->Input = NULL; + } + + if (UdpSrv->Output != NULL && ControllerHandle == UdpSrv->Output->UdpHandle) { + UdpIoFreeIo (UdpSrv->Output); + UdpSrv->Output = NULL; + } + + if (UdpSrv->Input == NULL && UdpSrv->Output == NULL) { + RemoveEntryList (&UdpSrv->List); + FreePool (UdpSrv); + ASSERT (Private->Udp6Num > 0); + Private->Udp6Num--; + } } } return EFI_SUCCESS; } -EFI_DRIVER_BINDING_PROTOCOL gIpSecDriverBinding = { - IpSecDriverBindingSupported, - IpSecDriverBindingStart, - IpSecDriverBindingStop, +/** + Test to see if this driver supports ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to test. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to start. + + @retval EFI_SUCCES This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +IpSec4DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IpSecSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_4 + ); +} + +/** + Start this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to bind driver to. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to start. + + @retval EFI_SUCCES This driver is added to ControllerHandle + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. + Currently not implemented. + @retval other This driver does not support this device + +**/ +EFI_STATUS +EFIAPI +IpSec4DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IpSecStart ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_4 + ); +} + +/** + Stop this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of a device to stop the driver on. + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of + children is zero, stop the entire bus driver. + @param[in] ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCES This driver removed ControllerHandle. + @retval other This driver was not removed from this device. + +**/ +EFI_STATUS +EFIAPI +IpSec4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + return IpSecStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_4 + ); +} + +/** + Test to see if this driver supports ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to test. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to start. + + @retval EFI_SUCCES This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +IpSec6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IpSecSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_6 + ); +} + +/** + Start this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to bind driver to. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to start. + + @retval EFI_SUCCES This driver is added to ControllerHandle + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle + @retval EFI_DEVICE_ERROR The device could not be started due to a device error. + Currently not implemented. + @retval other This driver does not support this device + +**/ +EFI_STATUS +EFIAPI +IpSec6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return IpSecStart ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_6 + ); +} + +/** + Stop this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of a device to stop the driver on. + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of + children is zero, stop the entire bus driver. + @param[in] ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCES This driver removed ControllerHandle. + @retval other This driver was not removed from this device. + +**/ +EFI_STATUS +EFIAPI +IpSec6DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + return IpSecStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_6 + ); +} + +EFI_DRIVER_BINDING_PROTOCOL gIpSec4DriverBinding = { + IpSec4DriverBindingSupported, + IpSec4DriverBindingStart, + IpSec4DriverBindingStop, + 0xa, + NULL, + NULL +}; + +EFI_DRIVER_BINDING_PROTOCOL gIpSec6DriverBinding = { + IpSec6DriverBindingSupported, + IpSec6DriverBindingStart, + IpSec6DriverBindingStop, 0xa, NULL, NULL @@ -386,7 +586,7 @@ IpSecDriverEntryPoint ( Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, - &gIpSecDriverBinding, + &gIpSec4DriverBinding, ImageHandle, &gIpSecComponentName, &gIpSecComponentName2 @@ -395,8 +595,32 @@ IpSecDriverEntryPoint ( goto ON_UNINSTALL_IPSEC; } + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gIpSec6DriverBinding, + NULL, + &gIpSecComponentName, + &gIpSecComponentName2 + ); + if (EFI_ERROR (Status)) { + goto ON_UNINSTALL_IPSEC4_DB; + } + return Status; +ON_UNINSTALL_IPSEC4_DB: + gBS->UninstallMultipleProtocolInterfaces ( + ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gIpSec4DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gIpSecComponentName2, + &gEfiComponentNameProtocolGuid, + &gIpSecComponentName, + NULL + ); + ON_UNINSTALL_IPSEC: gBS->UninstallProtocolInterface ( Private->Handle, diff --git a/NetworkPkg/TcpDxe/TcpDriver.c b/NetworkPkg/TcpDxe/TcpDriver.c index f6cbcfee52..1f0d371654 100644 --- a/NetworkPkg/TcpDxe/TcpDriver.c +++ b/NetworkPkg/TcpDxe/TcpDriver.c @@ -66,10 +66,19 @@ SOCK_INIT_DATA mTcpDefaultSockData = { NULL, }; -EFI_DRIVER_BINDING_PROTOCOL gTcpDriverBinding = { - TcpDriverBindingSupported, - TcpDriverBindingStart, - TcpDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gTcp4DriverBinding = { + Tcp4DriverBindingSupported, + Tcp4DriverBindingStart, + Tcp4DriverBindingStop, + 0xa, + NULL, + NULL +}; + +EFI_DRIVER_BINDING_PROTOCOL gTcp6DriverBinding = { + Tcp6DriverBindingSupported, + Tcp6DriverBindingStart, + Tcp6DriverBindingStop, 0xa, NULL, NULL @@ -172,7 +181,7 @@ TcpDriverEntryPoint ( Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, - &gTcpDriverBinding, + &gTcp4DriverBinding, ImageHandle, &gTcpComponentName, &gTcpComponentName2 @@ -181,6 +190,31 @@ TcpDriverEntryPoint ( return Status; } + // + // Install the TCP Driver Binding Protocol + // + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gTcp6DriverBinding, + NULL, + &gTcpComponentName, + &gTcpComponentName2 + ); + if (EFI_ERROR (Status)) { + gBS->UninstallMultipleProtocolInterfaces ( + ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gTcp4DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gTcpComponentName2, + &gEfiComponentNameProtocolGuid, + &gTcpComponentName, + NULL + ); + return Status; + } + // // Initialize ISS and random port. // @@ -496,14 +530,13 @@ TcpDestroyService ( **/ EFI_STATUS EFIAPI -TcpDriverBindingSupported ( +Tcp4DriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { EFI_STATUS Status; - BOOLEAN IsTcp4Started; // // Test for the Tcp4ServiceBinding Protocol @@ -516,29 +549,114 @@ TcpDriverBindingSupported ( ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); - if (EFI_ERROR (Status)) { - // - // Test for the Ip4ServiceBinding Protocol - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiIp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - return EFI_SUCCESS; - } + if (!EFI_ERROR (Status)) { + return EFI_ALREADY_STARTED; + } + + // + // Test for the Ip4ServiceBinding Protocol + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiIp4ServiceBindingProtocolGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + return Status; +} - IsTcp4Started = FALSE; - } else { - IsTcp4Started = TRUE; +/** + Start this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to bind driver to. + @param[in] RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS The driver is added to ControllerHandle. + @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the + driver. + @retval other The driver cannot be added to ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +Tcp4DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + EFI_STATUS Status; + + Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4); + if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) { + Status = EFI_SUCCESS; } + return Status; +} + +/** + Stop this driver on ControllerHandle. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + +**/ +EFI_STATUS +EFIAPI +Tcp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ) +{ + return TcpDestroyService ( + ControllerHandle, + This->DriverBindingHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_4 + ); +} + +/** + Test to see if this driver supports ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to test. + @param[in] RemainingDevicePath Optional parameter use to pick a specific + child device to start. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +Tcp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + EFI_STATUS Status; + // - // Check the Tcp6ServiceBinding Protocol + // Test for the Tcp6ServiceBinding Protocol // Status = gBS->OpenProtocol ( ControllerHandle, @@ -548,26 +666,22 @@ TcpDriverBindingSupported ( ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); - if (EFI_ERROR (Status)) { - // - // Test for the Ip6ServiceBinding Protocol - // - Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiIp6ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Status)) { - return EFI_SUCCESS; - } - } else if (IsTcp4Started) { + if (!EFI_ERROR (Status)) { return EFI_ALREADY_STARTED; } - - return EFI_UNSUPPORTED; + + // + // Test for the Ip6ServiceBinding Protocol + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiIp6ServiceBindingProtocolGuid, + NULL, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_TEST_PROTOCOL + ); + return Status; } /** @@ -586,32 +700,20 @@ TcpDriverBindingSupported ( **/ EFI_STATUS EFIAPI -TcpDriverBindingStart ( +Tcp6DriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - EFI_STATUS Tcp4Status; - EFI_STATUS Tcp6Status; - - Tcp4Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_4); - if ((Tcp4Status == EFI_ALREADY_STARTED) || (Tcp4Status == EFI_UNSUPPORTED)) { - Tcp4Status = EFI_SUCCESS; - } + EFI_STATUS Status; - Tcp6Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6); - if ((Tcp6Status == EFI_ALREADY_STARTED) || (Tcp6Status == EFI_UNSUPPORTED)) { - Tcp6Status = EFI_SUCCESS; + Status = TcpCreateService (ControllerHandle, This->DriverBindingHandle, IP_VERSION_6); + if ((Status == EFI_ALREADY_STARTED) || (Status == EFI_UNSUPPORTED)) { + Status = EFI_SUCCESS; } - if (!EFI_ERROR (Tcp4Status) || !EFI_ERROR (Tcp6Status)) { - return EFI_SUCCESS; - } else if (EFI_ERROR (Tcp4Status)) { - return Tcp4Status; - } else { - return Tcp6Status; - } + return Status; } /** @@ -631,37 +733,20 @@ TcpDriverBindingStart ( **/ EFI_STATUS EFIAPI -TcpDriverBindingStop ( +Tcp6DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Tcp4Status; - EFI_STATUS Tcp6Status; - - Tcp4Status = TcpDestroyService ( - ControllerHandle, - This->DriverBindingHandle, - NumberOfChildren, - ChildHandleBuffer, - IP_VERSION_4 - ); - - Tcp6Status = TcpDestroyService ( - ControllerHandle, - This->DriverBindingHandle, - NumberOfChildren, - ChildHandleBuffer, - IP_VERSION_6 - ); - - if (EFI_ERROR (Tcp4Status) && EFI_ERROR (Tcp6Status)) { - return EFI_DEVICE_ERROR; - } else { - return EFI_SUCCESS; - } + return TcpDestroyService ( + ControllerHandle, + This->DriverBindingHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_6 + ); } /** @@ -893,7 +978,7 @@ TcpServiceBindingDestroyChild ( ChildHandle, &gEfiTcp4ProtocolGuid, &Tcp, - gTcpDriverBinding.DriverBindingHandle, + gTcp4DriverBinding.DriverBindingHandle, ChildHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); @@ -905,7 +990,7 @@ TcpServiceBindingDestroyChild ( ChildHandle, &gEfiTcp6ProtocolGuid, &Tcp, - gTcpDriverBinding.DriverBindingHandle, + gTcp6DriverBinding.DriverBindingHandle, ChildHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); diff --git a/NetworkPkg/TcpDxe/TcpDriver.h b/NetworkPkg/TcpDxe/TcpDriver.h index 3949cd1543..5208048edf 100644 --- a/NetworkPkg/TcpDxe/TcpDriver.h +++ b/NetworkPkg/TcpDxe/TcpDriver.h @@ -1,7 +1,7 @@ /** @file The prototype of driver binding and service binding protocol for TCP driver. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -90,7 +90,7 @@ TcpDriverEntryPoint ( **/ EFI_STATUS EFIAPI -TcpDriverBindingSupported ( +Tcp4DriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL @@ -112,7 +112,7 @@ TcpDriverBindingSupported ( **/ EFI_STATUS EFIAPI -TcpDriverBindingStart ( +Tcp4DriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL @@ -135,7 +135,74 @@ TcpDriverBindingStart ( **/ EFI_STATUS EFIAPI -TcpDriverBindingStop ( +Tcp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer OPTIONAL + ); + +/** + Test to see if this driver supports ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of the device to test. + @param[in] RemainingDevicePath Optional parameter use to pick a specific + child device to start. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_ALREADY_STARTED This driver is already running on this device. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +Tcp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Start this driver on ControllerHandle. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to bind driver to. + @param[in] RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS The driver was added to ControllerHandle. + @retval EFI_OUT_OF_RESOURCES There are not enough resources to start the + driver. + @retval other The driver cannot be added to ControllerHandle. + +**/ +EFI_STATUS +EFIAPI +Tcp6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Stop this driver on ControllerHandle. + + @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. + @param[in] ControllerHandle A handle to the device being stopped. The handle must + support a bus specific I/O protocol for the driver + to use to stop the device. + @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer. + @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL + if NumberOfChildren is 0. + + @retval EFI_SUCCESS The device was stopped. + @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error. + +**/ +EFI_STATUS +EFIAPI +Tcp6DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c index b29df68bbd..0b2743d127 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c @@ -1,7 +1,7 @@ /** @file Driver Binding functions implementationfor for UefiPxeBc Driver. - Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -16,10 +16,19 @@ #include "PxeBcImpl.h" -EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = { - PxeBcDriverBindingSupported, - PxeBcDriverBindingStart, - PxeBcDriverBindingStop, +EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = { + PxeBcIp4DriverBindingSupported, + PxeBcIp4DriverBindingStart, + PxeBcIp4DriverBindingStop, + 0xa, + NULL, + NULL +}; + +EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = { + PxeBcIp6DriverBindingSupported, + PxeBcIp6DriverBindingStart, + PxeBcIp6DriverBindingStop, 0xa, NULL, NULL @@ -1089,82 +1098,94 @@ PxeBcDriverEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - return EfiLibInstallDriverBindingComponentName2 ( - ImageHandle, - SystemTable, - &gPxeBcDriverBinding, + EFI_STATUS Status; + + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gPxeBcIp4DriverBinding, + ImageHandle, + &gPxeBcComponentName, + &gPxeBcComponentName2 + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &gPxeBcIp6DriverBinding, + NULL, + &gPxeBcComponentName, + &gPxeBcComponentName2 + ); + if (EFI_ERROR (Status)) { + gBS->UninstallMultipleProtocolInterfaces ( ImageHandle, + &gEfiDriverBindingProtocolGuid, + &gPxeBcIp4DriverBinding, + &gEfiComponentName2ProtocolGuid, + &gPxeBcComponentName2, + &gEfiComponentNameProtocolGuid, &gPxeBcComponentName, - &gPxeBcComponentName2 + NULL ); -} + } + return Status; +} /** - Test to see if this driver supports ControllerHandle. This service - is called by the EFI boot service ConnectController(). In - order to make drivers as small as possible, there are a few calling - restrictions for this service. ConnectController() must - follow these calling restrictions. If any other agent wishes to call - Supported() it must also follow these calling restrictions. + Test to see if this driver supports ControllerHandle. This is the worker function for + PxeBcIp4(6)DriverBindingSupported. @param[in] This The pointer to the driver binding protocol. @param[in] ControllerHandle The handle of device to be tested. @param[in] RemainingDevicePath Optional parameter used to pick a specific child device to be started. - + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. + @retval EFI_SUCCESS This driver supports this device. @retval EFI_UNSUPPORTED This driver does not support this device. **/ EFI_STATUS EFIAPI -PxeBcDriverBindingSupported ( +PxeBcSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN UINT8 IpVersion ) { - EFI_STATUS Ip4Status; - EFI_STATUS Ip6Status; - - // - // Try to open the Mtftp4 and Dhcp4 protocol to test whether IPv4 stack is ready. - // - Ip4Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiDhcp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); - if (!EFI_ERROR (Ip4Status)) { - Ip4Status = gBS->OpenProtocol ( - ControllerHandle, - &gEfiMtftp4ServiceBindingProtocolGuid, - NULL, - This->DriverBindingHandle, - ControllerHandle, - EFI_OPEN_PROTOCOL_TEST_PROTOCOL - ); + EFI_STATUS Status; + EFI_GUID *DhcpServiceBindingGuid; + EFI_GUID *MtftpServiceBindingGuid; + + if (IpVersion == IP_VERSION_4) { + DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid; + MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid; + } else { + DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid; + MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid; } // - // Try to open the Mtftp6 and Dhcp6 protocol to test whether IPv4 stack is ready. + // Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready. // - Ip6Status = gBS->OpenProtocol ( + Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiDhcp6ServiceBindingProtocolGuid, + DhcpServiceBindingGuid, NULL, This->DriverBindingHandle, ControllerHandle, EFI_OPEN_PROTOCOL_TEST_PROTOCOL ); - if (!EFI_ERROR (Ip6Status)) { - Ip6Status = gBS->OpenProtocol ( + if (!EFI_ERROR (Status)) { + Status = gBS->OpenProtocol ( ControllerHandle, - &gEfiMtftp6ServiceBindingProtocolGuid, + MtftpServiceBindingGuid, NULL, This->DriverBindingHandle, ControllerHandle, @@ -1173,28 +1194,25 @@ PxeBcDriverBindingSupported ( } // - // It's unsupported case if both stack are not ready. + // It's unsupported case if IP stack are not ready. // - if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) { + if (EFI_ERROR (Status)) { return EFI_UNSUPPORTED; } return EFI_SUCCESS; } - /** - Start this driver on ControllerHandle. This service is called by the - EFI boot service ConnectController(). In order to make - drivers as small as possible, there are a few calling restrictions for - this service. ConnectController() must follow these - calling restrictions. If any other agent wishes to call Start() it - must also follow these calling restrictions. + Start this driver on ControllerHandle. This is the worker function for + PxeBcIp4(6)DriverBindingStart. @param[in] This The pointer to the driver binding protocol. @param[in] ControllerHandle The handle of device to be started. @param[in] RemainingDevicePath Optional parameter used to pick a specific child device to be started. + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. + @retval EFI_SUCCESS This driver is installed to ControllerHandle. @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle. @@ -1203,18 +1221,19 @@ PxeBcDriverBindingSupported ( **/ EFI_STATUS EFIAPI -PxeBcDriverBindingStart ( +PxeBcStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, + IN UINT8 IpVersion ) { PXEBC_PRIVATE_DATA *Private; EFI_STATUS Status; - EFI_STATUS Ip4Status; - EFI_STATUS Ip6Status; PXEBC_PRIVATE_PROTOCOL *Id; + BOOLEAN FirstStart; + FirstStart = FALSE; Status = gBS->OpenProtocol ( ControllerHandle, &gEfiCallerIdGuid, @@ -1229,6 +1248,7 @@ PxeBcDriverBindingStart ( // Private = PXEBC_PRIVATE_DATA_FROM_ID (Id); } else { + FirstStart = TRUE; // // If the driver has not been started yet, it should do initialization. // @@ -1305,17 +1325,18 @@ PxeBcDriverBindingStart ( NetLibGetSnpHandle(ControllerHandle, &Private->Snp); } - // - // Try to create virtual NIC handle for IPv4. - // - Ip4Status = PxeBcCreateIp4Children (This, ControllerHandle, Private); - - // - // Try to create virtual NIC handle for IPv6. - // - Ip6Status = PxeBcCreateIp6Children (This, ControllerHandle, Private); - - if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) { + if (IpVersion == IP_VERSION_4) { + // + // Try to create virtual NIC handle for IPv4. + // + Status = PxeBcCreateIp4Children (This, ControllerHandle, Private); + } else { + // + // Try to create virtual NIC handle for IPv6. + // + Status = PxeBcCreateIp6Children (This, ControllerHandle, Private); + } + if (EFI_ERROR (Status)) { // // Failed to start PXE driver if IPv4 and IPv6 stack are both not available. // @@ -1326,32 +1347,37 @@ PxeBcDriverBindingStart ( return EFI_SUCCESS; ON_ERROR: - gBS->UninstallProtocolInterface ( - ControllerHandle, - &gEfiCallerIdGuid, - &Private->Id - ); - PxeBcDestroyIp4Children (This, Private); - PxeBcDestroyIp6Children (This, Private); - FreePool (Private); + if (FirstStart) { + gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiCallerIdGuid, + &Private->Id + ); + if (Private != NULL) { + FreePool (Private); + } + } + + if (IpVersion == IP_VERSION_4) { + PxeBcDestroyIp4Children (This, Private); + } else { + PxeBcDestroyIp6Children (This, Private); + } return Status; } /** - Stop this driver on ControllerHandle. This service is called by the - EFI boot service DisconnectController(). In order to - make drivers as small as possible, there are a few calling - restrictions for this service. DisconnectController() - must follow these calling restrictions. If any other agent wishes - to call Stop() it must also follow these calling restrictions. + Stop this driver on ControllerHandle. This is the worker function for + PxeBcIp4(6)DriverBindingStop. @param[in] This Protocol instance pointer. @param[in] ControllerHandle Handle of device to stop driver on. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @param[in] ChildHandleBuffer List of Child Handles to Stop. + @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6. @retval EFI_SUCCESS This driver was removed ControllerHandle. @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. @@ -1360,11 +1386,12 @@ ON_ERROR: **/ EFI_STATUS EFIAPI -PxeBcDriverBindingStop ( +PxeBcStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer + IN EFI_HANDLE *ChildHandleBuffer, + IN UINT8 IpVersion ) { PXEBC_PRIVATE_DATA *Private; @@ -1394,14 +1421,13 @@ PxeBcDriverBindingStop ( // // Get the Nic handle by any pass-over service child handle. // - NicHandle = PxeBcGetNicByIp4Children (ControllerHandle); - if (NicHandle == NULL) { + if (IpVersion == IP_VERSION_4) { + NicHandle = PxeBcGetNicByIp4Children (ControllerHandle); + } else { NicHandle = PxeBcGetNicByIp6Children (ControllerHandle); - if (NicHandle == NULL) { - return EFI_SUCCESS; - } else { - IsIpv6 = TRUE; - } + } + if (NicHandle == NULL) { + return EFI_SUCCESS; } // @@ -1439,10 +1465,6 @@ PxeBcDriverBindingStop ( VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (LoadFile); Private = VirtualNic->Private; NicHandle = Private->Controller; - - if (Private->Ip6Nic == VirtualNic) { - IsIpv6 = TRUE; - } } // @@ -1454,11 +1476,11 @@ PxeBcDriverBindingStop ( } - if (Private->Ip4Nic != NULL && !IsIpv6) { + if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) { PxeBcDestroyIp4Children (This, Private); } - if (Private->Ip6Nic != NULL && IsIpv6) { + if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) { PxeBcDestroyIp6Children (This, Private); } @@ -1473,3 +1495,211 @@ PxeBcDriverBindingStop ( return EFI_SUCCESS; } + +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be tested. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_UNSUPPORTED This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp4DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return PxeBcSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_4 + ); +} + +/** + Start this driver on ControllerHandle. This service is called by the + EFI boot service ConnectController(). In order to make + drivers as small as possible, there are a few calling restrictions for + this service. ConnectController() must follow these + calling restrictions. If any other agent wishes to call Start() it + must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be started. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver is installed to ControllerHandle. + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp4DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return PxeBcStart ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_4 + ); +} + +/** + Stop this driver on ControllerHandle. This service is called by the + EFI boot service DisconnectController(). In order to + make drivers as small as possible, there are a few calling + restrictions for this service. DisconnectController() + must follow these calling restrictions. If any other agent wishes + to call Stop() it must also follow these calling restrictions. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to stop driver on + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + @param[in] ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval Others This driver was not removed from this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp4DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + return PxeBcStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_4 + ); +} + +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be tested. + @param[in] RemainingDevicePath Optional parameter use to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_UNSUPPORTED This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return PxeBcSupported ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_6 + ); +} + +/** + Start this driver on ControllerHandle. This service is called by the + EFI boot service ConnectController(). In order to make + drivers as small as possible, there are a few calling restrictions for + this service. ConnectController() must follow these + calling restrictions. If any other agent wishes to call Start() it + must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be started. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver is installed to ControllerHandle. + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return PxeBcStart ( + This, + ControllerHandle, + RemainingDevicePath, + IP_VERSION_6 + ); +} + +/** + Stop this driver on ControllerHandle. This service is called by the + EFI boot service DisconnectController(). In order to + make drivers as small as possible, there are a few calling + restrictions for this service. DisconnectController() + must follow these calling restrictions. If any other agent wishes + to call Stop() it must also follow these calling restrictions. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to stop driver on + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + @param[in] ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval Others This driver was not removed from this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + return PxeBcStop ( + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer, + IP_VERSION_6 + ); +} diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h index 8df4bae27b..f22f0f6bb3 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDriver.h @@ -1,7 +1,7 @@ /** @file Driver Binding functions declaration for UefiPxeBc Driver. - Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -38,13 +38,12 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2; **/ EFI_STATUS EFIAPI -PxeBcDriverBindingSupported ( +PxeBcIp4DriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ); - /** Start this driver on ControllerHandle. This service is called by the EFI boot service ConnectController(). In order to make @@ -65,7 +64,7 @@ PxeBcDriverBindingSupported ( **/ EFI_STATUS EFIAPI -PxeBcDriverBindingStart ( +PxeBcIp4DriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL @@ -93,12 +92,90 @@ PxeBcDriverBindingStart ( **/ EFI_STATUS EFIAPI -PxeBcDriverBindingStop ( +PxeBcIp4DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ); +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be tested. + @param[in] RemainingDevicePath Optional parameter use to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver supports this device. + @retval EFI_UNSUPPORTED This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Start this driver on ControllerHandle. This service is called by the + EFI boot service ConnectController(). In order to make + drivers as small as possible, there are a few calling restrictions for + this service. ConnectController() must follow these + calling restrictions. If any other agent wishes to call Start() it + must also follow these calling restrictions. + + @param[in] This The pointer to the driver binding protocol. + @param[in] ControllerHandle The handle of device to be started. + @param[in] RemainingDevicePath Optional parameter used to pick a specific child + device to be started. + + @retval EFI_SUCCESS This driver is installed to ControllerHandle. + @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle. + @retval other This driver does not support this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ); + +/** + Stop this driver on ControllerHandle. This service is called by the + EFI boot service DisconnectController(). In order to + make drivers as small as possible, there are a few calling + restrictions for this service. DisconnectController() + must follow these calling restrictions. If any other agent wishes + to call Stop() it must also follow these calling restrictions. + + @param[in] This Protocol instance pointer. + @param[in] ControllerHandle Handle of device to stop driver on + @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of + children is zero stop the entire bus driver. + @param[in] ChildHandleBuffer List of Child Handles to Stop. + + @retval EFI_SUCCESS This driver is removed ControllerHandle + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval Others This driver was not removed from this device. + +**/ +EFI_STATUS +EFIAPI +PxeBcIp6DriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ); #endif -- 2.39.2