/** @file\r
+ The driver binding for UEFI PXEBC protocol.\r
\r
-Copyright (c) 2007 - 2008, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- PxeBcDriver.c\r
-\r
-Abstract:\r
-\r
- The driver binding for IP4 CONFIG protocol.\r
-\r
-\r
**/\r
\r
\r
#include "PxeBcImpl.h"\r
\r
+EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {\r
+ PxeBcDriverBindingSupported,\r
+ PxeBcDriverBindingStart,\r
+ PxeBcDriverBindingStop,\r
+ 0xa,\r
+ NULL,\r
+ NULL\r
+};\r
\r
/**\r
- The entry point for PxeBc driver which install the driver\r
- binding and component name protocol on its image.\r
+ This is the declaration of an EFI image entry point. This entry point is\r
+ the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
+ both device drivers and bus drivers.\r
\r
- @param ImageHandle The Image handle of the driver\r
- @param SystemTable The system table\r
+ @param ImageHandle The firmware allocated handle for the UEFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
\r
- @return EFI_SUCCESS\r
- @return Others\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
PxeBcDriverEntryPoint (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
\r
\r
/**\r
- Test to see if this driver supports ControllerHandle.\r
-\r
- @param This Protocol instance pointer.\r
- @param ControllerHandle Handle of device to test\r
- @param RemainingDevicePath Optional parameter use to pick a specific child\r
- device to start.\r
-\r
- @return EFI_SUCCES\r
- @return EFI_ALREADY_STARTED\r
- @return Others\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
+ PxeBc requires DHCP4 and MTFTP4 protocols.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to test\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device\r
+ @retval EFI_ALREADY_STARTED This driver is already running on this device\r
+ @retval other This driver does not support this device\r
\r
**/\r
EFI_STATUS\r
\r
\r
/**\r
- Start this driver on ControllerHandle.\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 This Protocol instance pointer.\r
@param ControllerHandle Handle of device to bind driver to\r
@param RemainingDevicePath Optional parameter use to pick a specific child\r
device to start.\r
\r
- @return EFI_SUCCES\r
- @return EFI_ALREADY_STARTED\r
- @return EFI_OUT_OF_RESOURCES\r
- @return Others\r
+ @retval EFI_SUCCESS This driver is added 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
PXEBC_PRIVATE_DATA *Private;\r
UINTN Index;\r
EFI_STATUS Status;\r
+ EFI_IP4_MODE_DATA Ip4ModeData;\r
\r
Private = AllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA));\r
if (Private == NULL) {\r
}\r
\r
//\r
- // Get the NII interface\r
+ // Get the NII interface if it exists.\r
//\r
Status = gBS->OpenProtocol (\r
ControllerHandle,\r
EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
);\r
if (EFI_ERROR (Status)) {\r
- goto ON_ERROR;\r
+ Private->Nii = NULL;\r
}\r
\r
Status = NetLibCreateServiceChild (\r
if (EFI_ERROR (Status)) {\r
goto ON_ERROR;\r
}\r
+
+ //
+ // Get max packet size from Ip4 to calculate block size for Tftp later.\r
+ //
+ Status = Private->Ip4->GetModeData (Private->Ip4, &Ip4ModeData, NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ goto ON_ERROR;
+ }
+
+ Private->Ip4MaxPacketSize = Ip4ModeData.MaxPacketSize;\r
\r
Status = NetLibCreateServiceChild (\r
ControllerHandle,\r
// The UDP instance for EfiPxeBcUdpWrite\r
//\r
Status = NetLibCreateServiceChild (\r
- ControllerHandle, \r
+ ControllerHandle,\r
This->DriverBindingHandle,\r
&gEfiUdp4ServiceBindingProtocolGuid,\r
&Private->Udp4WriteChild\r
Private->Udp4CfgData.TypeOfService = DEFAULT_ToS;\r
Private->Udp4CfgData.TimeToLive = DEFAULT_TTL;\r
Private->Udp4CfgData.DoNotFragment = FALSE;\r
- Private->Udp4CfgData.ReceiveTimeout = 50000; // 50 milliseconds\r
+ Private->Udp4CfgData.ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;\r
Private->Udp4CfgData.UseDefaultAddress = FALSE;\r
\r
PxeBcInitSeedPacket (&Private->SeedPacket, Private->Udp4Read);\r
);\r
}\r
\r
- gBS->FreePool (Private);\r
+ FreePool (Private);\r
\r
return Status;\r
}\r
\r
\r
/**\r
- Stop this driver on ControllerHandle.\r
-\r
- @param This Protocol instance pointer.\r
- @param ControllerHandle Handle of device to stop driver on\r
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
- children is zero stop the entire bus driver.\r
- @param ChildHandleBuffer List of Child Handles to Stop.\r
-\r
- @return EFI_SUCCESS\r
- @return EFI_DEVICE_ERROR\r
- @return Others\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 This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to stop driver on\r
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval other This driver was not removed from this device\r
\r
**/\r
EFI_STATUS\r
return Status;\r
}\r
\r
+ //\r
+ // Stop functionality of PXE Base Code protocol\r
+ //\r
+ Status = PxeBc->Stop (PxeBc);\r
+ if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {\r
+ return Status;\r
+ }\r
+\r
Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc);\r
\r
Status = gBS->UninstallMultipleProtocolInterfaces (\r
Private->ArpChild\r
);\r
\r
- gBS->FreePool (Private);\r
+ FreePool (Private);\r
}\r
\r
return Status;\r
}\r
\r
-EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {\r
- PxeBcDriverBindingSupported,\r
- PxeBcDriverBindingStart,\r
- PxeBcDriverBindingStop,\r
- 0xa,\r
- NULL,\r
- NULL\r
-};\r
-\r
\r