diff options
author | sfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-25 01:33:43 +0000 |
---|---|---|
committer | sfu5 <sfu5@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-04-25 01:33:43 +0000 |
commit | 6879581d2eb67defc68ec800b369b70dec04a07b (patch) | |
tree | 44c69e61823e474cc124dab5c336fa51303f00bb /NetworkPkg/TcpDxe | |
parent | d0ccf55e34477b2bf080f04eca835ea037ccce76 (diff) | |
download | edk2-6879581d2eb67defc68ec800b369b70dec04a07b.tar.gz edk2-6879581d2eb67defc68ec800b369b70dec04a07b.tar.bz2 edk2-6879581d2eb67defc68ec800b369b70dec04a07b.zip |
Update dual network stack drivers to produce multiple Driver Binding Protocol.
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Ouyang Qian <qian.ouyang@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14315 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'NetworkPkg/TcpDxe')
-rw-r--r-- | NetworkPkg/TcpDxe/TcpDriver.c | 263 | ||||
-rw-r--r-- | NetworkPkg/TcpDxe/TcpDriver.h | 75 |
2 files changed, 245 insertions, 93 deletions
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
@@ -182,6 +191,31 @@ TcpDriverEntryPoint ( }
//
+ // 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.
//
Seed = NetRandomInitSeed ();
@@ -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.<BR>
+ Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
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,
|