/** @file\r
Driver Binding functions implementationfor for UefiPxeBc Driver.\r
\r
- Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
#include "PxeBcImpl.h"\r
\r
\r
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {\r
- PxeBcDriverBindingSupported,\r
- PxeBcDriverBindingStart,\r
- PxeBcDriverBindingStop,\r
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp4DriverBinding = {\r
+ PxeBcIp4DriverBindingSupported,\r
+ PxeBcIp4DriverBindingStart,\r
+ PxeBcIp4DriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
+\r
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcIp6DriverBinding = {\r
+ PxeBcIp6DriverBindingSupported,\r
+ PxeBcIp6DriverBindingStart,\r
+ PxeBcIp6DriverBindingStop,\r
0xa,\r
NULL,\r
NULL\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- return EfiLibInstallDriverBindingComponentName2 (\r
- ImageHandle,\r
- SystemTable,\r
- &gPxeBcDriverBinding,\r
+ EFI_STATUS Status;\r
+\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gPxeBcIp4DriverBinding,\r
+ ImageHandle,\r
+ &gPxeBcComponentName,\r
+ &gPxeBcComponentName2\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ Status = EfiLibInstallDriverBindingComponentName2 (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gPxeBcIp6DriverBinding,\r
+ NULL,\r
+ &gPxeBcComponentName,\r
+ &gPxeBcComponentName2\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->UninstallMultipleProtocolInterfaces (\r
ImageHandle,\r
+ &gEfiDriverBindingProtocolGuid,\r
+ &gPxeBcIp4DriverBinding,\r
+ &gEfiComponentName2ProtocolGuid,\r
+ &gPxeBcComponentName2,\r
+ &gEfiComponentNameProtocolGuid,\r
&gPxeBcComponentName,\r
- &gPxeBcComponentName2\r
+ NULL\r
);\r
-}\r
+ }\r
\r
+ return Status;\r
+}\r
\r
/**\r
- Test to see if this driver supports ControllerHandle. This service\r
- is called by the EFI boot service ConnectController(). In\r
- order to make drivers as small as possible, there are a few calling\r
- restrictions for this service. ConnectController() must\r
- follow these calling restrictions. If any other agent wishes to call\r
- Supported() it must also follow these calling restrictions.\r
+ Test to see if this driver supports ControllerHandle. This is the worker function for\r
+ PxeBcIp4(6)DriverBindingSupported.\r
\r
@param[in] This The pointer to the driver binding protocol.\r
@param[in] ControllerHandle The handle of device to be tested.\r
@param[in] RemainingDevicePath Optional parameter used to pick a specific child\r
device to be started.\r
-\r
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
+ \r
@retval EFI_SUCCESS This driver supports this device.\r
@retval EFI_UNSUPPORTED This driver does not support this device.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
-PxeBcDriverBindingSupported (\r
+PxeBcSupported (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r
+ IN UINT8 IpVersion\r
)\r
{\r
- EFI_STATUS Ip4Status;\r
- EFI_STATUS Ip6Status;\r
-\r
- //\r
- // Try to open the Mtftp4 and Dhcp4 protocol to test whether IPv4 stack is ready.\r
- //\r
- Ip4Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiDhcp4ServiceBindingProtocolGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
- if (!EFI_ERROR (Ip4Status)) {\r
- Ip4Status = gBS->OpenProtocol (\r
- ControllerHandle,\r
- &gEfiMtftp4ServiceBindingProtocolGuid,\r
- NULL,\r
- This->DriverBindingHandle,\r
- ControllerHandle,\r
- EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
- );\r
+ EFI_STATUS Status;\r
+ EFI_GUID *DhcpServiceBindingGuid;\r
+ EFI_GUID *MtftpServiceBindingGuid;\r
+ \r
+ if (IpVersion == IP_VERSION_4) {\r
+ DhcpServiceBindingGuid = &gEfiDhcp4ServiceBindingProtocolGuid;\r
+ MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;\r
+ } else {\r
+ DhcpServiceBindingGuid = &gEfiDhcp6ServiceBindingProtocolGuid;\r
+ MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;\r
}\r
\r
//\r
- // Try to open the Mtftp6 and Dhcp6 protocol to test whether IPv4 stack is ready.\r
+ // Try to open the Mtftp and Dhcp protocol to test whether IP stack is ready.\r
//\r
- Ip6Status = gBS->OpenProtocol (\r
+ Status = gBS->OpenProtocol (\r
ControllerHandle,\r
- &gEfiDhcp6ServiceBindingProtocolGuid,\r
+ DhcpServiceBindingGuid,\r
NULL,\r
This->DriverBindingHandle,\r
ControllerHandle,\r
EFI_OPEN_PROTOCOL_TEST_PROTOCOL\r
);\r
- if (!EFI_ERROR (Ip6Status)) {\r
- Ip6Status = gBS->OpenProtocol (\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = gBS->OpenProtocol (\r
ControllerHandle,\r
- &gEfiMtftp6ServiceBindingProtocolGuid,\r
+ MtftpServiceBindingGuid,\r
NULL,\r
This->DriverBindingHandle,\r
ControllerHandle,\r
}\r
\r
//\r
- // It's unsupported case if both stack are not ready.\r
+ // It's unsupported case if IP stack are not ready.\r
//\r
- if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {\r
+ if (EFI_ERROR (Status)) {\r
return EFI_UNSUPPORTED;\r
}\r
\r
return EFI_SUCCESS;\r
}\r
\r
-\r
/**\r
- Start this driver on ControllerHandle. This service is called by the\r
- EFI boot service ConnectController(). In order to make\r
- drivers as small as possible, there are a few calling restrictions for\r
- this service. ConnectController() must follow these\r
- calling restrictions. If any other agent wishes to call Start() it\r
- must also follow these calling restrictions.\r
+ Start this driver on ControllerHandle. This is the worker function for\r
+ PxeBcIp4(6)DriverBindingStart.\r
\r
@param[in] This The pointer to the driver binding protocol.\r
@param[in] ControllerHandle The handle of device to be started.\r
@param[in] RemainingDevicePath Optional parameter used to pick a specific child\r
device to be started.\r
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
+\r
\r
@retval EFI_SUCCESS This driver is installed to ControllerHandle.\r
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-PxeBcDriverBindingStart (\r
+PxeBcStart (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE ControllerHandle,\r
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,\r
+ IN UINT8 IpVersion\r
)\r
{\r
PXEBC_PRIVATE_DATA *Private;\r
EFI_STATUS Status;\r
- EFI_STATUS Ip4Status;\r
- EFI_STATUS Ip6Status;\r
PXEBC_PRIVATE_PROTOCOL *Id;\r
+ BOOLEAN FirstStart;\r
\r
+ FirstStart = FALSE;\r
Status = gBS->OpenProtocol (\r
ControllerHandle,\r
&gEfiCallerIdGuid,\r
//\r
Private = PXEBC_PRIVATE_DATA_FROM_ID (Id);\r
} else {\r
+ FirstStart = TRUE;\r
//\r
// If the driver has not been started yet, it should do initialization.\r
//\r
NetLibGetSnpHandle(ControllerHandle, &Private->Snp); \r
}\r
\r
- //\r
- // Try to create virtual NIC handle for IPv4.\r
- //\r
- Ip4Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);\r
-\r
- //\r
- // Try to create virtual NIC handle for IPv6.\r
- //\r
- Ip6Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);\r
-\r
- if (EFI_ERROR (Ip4Status) && EFI_ERROR (Ip6Status)) {\r
+ if (IpVersion == IP_VERSION_4) {\r
+ //\r
+ // Try to create virtual NIC handle for IPv4.\r
+ //\r
+ Status = PxeBcCreateIp4Children (This, ControllerHandle, Private);\r
+ } else {\r
+ //\r
+ // Try to create virtual NIC handle for IPv6.\r
+ //\r
+ Status = PxeBcCreateIp6Children (This, ControllerHandle, Private);\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
//\r
// Failed to start PXE driver if IPv4 and IPv6 stack are both not available.\r
//\r
return EFI_SUCCESS;\r
\r
ON_ERROR:\r
- gBS->UninstallProtocolInterface (\r
- ControllerHandle,\r
- &gEfiCallerIdGuid,\r
- &Private->Id\r
- );\r
- PxeBcDestroyIp4Children (This, Private);\r
- PxeBcDestroyIp6Children (This, Private);\r
- FreePool (Private);\r
+ if (FirstStart) {\r
+ gBS->UninstallProtocolInterface (\r
+ ControllerHandle,\r
+ &gEfiCallerIdGuid,\r
+ &Private->Id\r
+ );\r
+ }\r
+\r
+ if (IpVersion == IP_VERSION_4) {\r
+ PxeBcDestroyIp4Children (This, Private);\r
+ } else {\r
+ PxeBcDestroyIp6Children (This, Private);\r
+ }\r
+\r
+ if (FirstStart && Private != NULL) {\r
+ FreePool (Private);\r
+ }\r
\r
return Status;\r
}\r
\r
\r
/**\r
- Stop this driver on ControllerHandle. This service is called by the\r
- EFI boot service DisconnectController(). In order to\r
- make drivers as small as possible, there are a few calling\r
- restrictions for this service. DisconnectController()\r
- must follow these calling restrictions. If any other agent wishes\r
- to call Stop() it must also follow these calling restrictions.\r
+ Stop this driver on ControllerHandle. This is the worker function for\r
+ PxeBcIp4(6)DriverBindingStop.\r
\r
@param[in] This Protocol instance pointer.\r
@param[in] ControllerHandle Handle of device to stop driver on.\r
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
children is zero stop the entire bus driver.\r
@param[in] ChildHandleBuffer List of Child Handles to Stop.\r
+ @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6.\r
\r
@retval EFI_SUCCESS This driver was removed ControllerHandle.\r
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-PxeBcDriverBindingStop (\r
+PxeBcStop (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE ControllerHandle,\r
IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
+ IN EFI_HANDLE *ChildHandleBuffer,\r
+ IN UINT8 IpVersion\r
)\r
{\r
PXEBC_PRIVATE_DATA *Private;\r
//\r
// Get the Nic handle by any pass-over service child handle.\r
//\r
- NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);\r
- if (NicHandle == NULL) {\r
+ if (IpVersion == IP_VERSION_4) {\r
+ NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);\r
+ } else {\r
NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);\r
- if (NicHandle == NULL) {\r
- return EFI_DEVICE_ERROR;\r
- } else {\r
- IsIpv6 = TRUE;\r
- }\r
+ }\r
+ if (NicHandle == NULL) {\r
+ return EFI_SUCCESS;\r
}\r
\r
//\r
VirtualNic = PXEBC_VIRTUAL_NIC_FROM_LOADFILE (LoadFile);\r
Private = VirtualNic->Private;\r
NicHandle = Private->Controller;\r
-\r
- if (Private->Ip6Nic == VirtualNic) {\r
- IsIpv6 = TRUE;\r
- }\r
}\r
\r
//\r
}\r
\r
\r
- if (Private->Ip4Nic != NULL && !IsIpv6) {\r
+ if (Private->Ip4Nic != NULL && IpVersion == IP_VERSION_4) {\r
PxeBcDestroyIp4Children (This, Private);\r
}\r
\r
- if (Private->Ip6Nic != NULL && IsIpv6) {\r
+ if (Private->Ip6Nic != NULL && IpVersion == IP_VERSION_6) {\r
PxeBcDestroyIp6Children (This, Private);\r
}\r
\r
\r
return EFI_SUCCESS;\r
}\r
+\r
+/**\r
+ Test to see if this driver supports ControllerHandle. This service\r
+ is called by the EFI boot service ConnectController(). In\r
+ order to make drivers as small as possible, there are a few calling\r
+ restrictions for this service. ConnectController() must\r
+ follow these calling restrictions. If any other agent wishes to call\r
+ Supported() it must also follow these calling restrictions.\r
+\r
+ @param[in] This The pointer to the driver binding protocol.\r
+ @param[in] ControllerHandle The handle of device to be tested.\r
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r
+ device to be started.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device.\r
+ @retval EFI_UNSUPPORTED This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp4DriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+{\r
+ return PxeBcSupported (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ IP_VERSION_4\r
+ );\r
+}\r
+\r
+/**\r
+ Start this driver on ControllerHandle. This service is called by the\r
+ EFI boot service ConnectController(). In order to make\r
+ drivers as small as possible, there are a few calling restrictions for\r
+ this service. ConnectController() must follow these\r
+ calling restrictions. If any other agent wishes to call Start() it\r
+ must also follow these calling restrictions.\r
+\r
+ @param[in] This The pointer to the driver binding protocol.\r
+ @param[in] ControllerHandle The handle of device to be started.\r
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r
+ device to be started.\r
+\r
+ @retval EFI_SUCCESS This driver is installed to ControllerHandle.\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
+ @retval other This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp4DriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+{\r
+ return PxeBcStart (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ IP_VERSION_4\r
+ );\r
+}\r
+\r
+/**\r
+ Stop this driver on ControllerHandle. This service is called by the\r
+ EFI boot service DisconnectController(). In order to\r
+ make drivers as small as possible, there are a few calling\r
+ restrictions for this service. DisconnectController()\r
+ must follow these calling restrictions. If any other agent wishes\r
+ to call Stop() it must also follow these calling restrictions.\r
+\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ControllerHandle Handle of device to stop driver on\r
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval Others This driver was not removed from this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp4DriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+{\r
+ return PxeBcStop (\r
+ This,\r
+ ControllerHandle,\r
+ NumberOfChildren,\r
+ ChildHandleBuffer,\r
+ IP_VERSION_4\r
+ );\r
+}\r
+\r
+/**\r
+ Test to see if this driver supports ControllerHandle. This service\r
+ is called by the EFI boot service ConnectController(). In\r
+ order to make drivers as small as possible, there are a few calling\r
+ restrictions for this service. ConnectController() must\r
+ follow these calling restrictions. If any other agent wishes to call\r
+ Supported() it must also follow these calling restrictions.\r
+\r
+ @param[in] This The pointer to the driver binding protocol.\r
+ @param[in] ControllerHandle The handle of device to be tested.\r
+ @param[in] RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to be started.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device.\r
+ @retval EFI_UNSUPPORTED This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp6DriverBindingSupported (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+{\r
+ return PxeBcSupported (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ IP_VERSION_6\r
+ );\r
+}\r
+\r
+/**\r
+ Start this driver on ControllerHandle. This service is called by the\r
+ EFI boot service ConnectController(). In order to make\r
+ drivers as small as possible, there are a few calling restrictions for\r
+ this service. ConnectController() must follow these\r
+ calling restrictions. If any other agent wishes to call Start() it\r
+ must also follow these calling restrictions.\r
+\r
+ @param[in] This The pointer to the driver binding protocol.\r
+ @param[in] ControllerHandle The handle of device to be started.\r
+ @param[in] RemainingDevicePath Optional parameter used to pick a specific child\r
+ device to be started.\r
+\r
+ @retval EFI_SUCCESS This driver is installed to ControllerHandle.\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.\r
+ @retval other This driver does not support this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp6DriverBindingStart (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
+ )\r
+{\r
+ return PxeBcStart (\r
+ This,\r
+ ControllerHandle,\r
+ RemainingDevicePath,\r
+ IP_VERSION_6\r
+ );\r
+}\r
+\r
+/**\r
+ Stop this driver on ControllerHandle. This service is called by the\r
+ EFI boot service DisconnectController(). In order to\r
+ make drivers as small as possible, there are a few calling\r
+ restrictions for this service. DisconnectController()\r
+ must follow these calling restrictions. If any other agent wishes\r
+ to call Stop() it must also follow these calling restrictions.\r
+\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] ControllerHandle Handle of device to stop driver on\r
+ @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param[in] ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
+ @retval Others This driver was not removed from this device.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PxeBcIp6DriverBindingStop (\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE ControllerHandle,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
+ )\r
+{\r
+ return PxeBcStop (\r
+ This,\r
+ ControllerHandle,\r
+ NumberOfChildren,\r
+ ChildHandleBuffer,\r
+ IP_VERSION_6\r
+ );\r
+}\r