/** @file\r
+ Implementation of Mtftp drivers.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php<BR>\r
\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
- Mtftp4Driver.c\r
-\r
-Abstract:\r
-\r
-\r
**/\r
\r
#include "Mtftp4Impl.h"\r
Mtftp4ServiceBindingDestroyChild\r
};\r
\r
-//@MT: EFI_DRIVER_ENTRY_POINT (Mtftp4DriverEntryPoint)\r
\r
+/**\r
+ The driver entry point which installs multiple protocols to the ImageHandle.\r
+\r
+ @param ImageHandle The MTFTP's image handle.\r
+ @param SystemTable The system table.\r
+\r
+ @retval EFI_SUCCESS The handles are successfully installed on the image.\r
+ @retval others some EFI_ERROR occured.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
Mtftp4DriverEntryPoint (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- The driver entry point which installs multiple protocols to the ImageHandle.\r
-\r
-Arguments:\r
-\r
- ImageHandle - The MTFTP's image handle\r
- SystemTable - The system table\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - The handles are successfully installed on the image. Otherwise\r
- some EFI_ERROR.\r
-\r
---*/\r
{\r
- return NetLibInstallAllDriverProtocols (\r
+ return EfiLibInstallDriverBindingComponentName2 (\r
ImageHandle,\r
SystemTable,\r
&gMtftp4DriverBinding,\r
ImageHandle,\r
&gMtftp4ComponentName,\r
- NULL,\r
- NULL\r
+ &gMtftp4ComponentName2\r
);\r
}\r
\r
\r
@retval EFI_SUCCESS The controller has UDP service binding protocol\r
installed, MTFTP can support it.\r
- @retval Others MTFTP can't support the controller.\r
+ @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by\r
+ the driver specified by This.\r
+ @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
+ RemainingDevicePath is already being managed by a\r
+ different driver or an application that requires\r
+ exclusive access.\r
+ @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
+ RemainingDevicePath is not supported by the driver\r
+ specified by This.\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4DriverBindingSupported (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
\r
\r
/**\r
- Config a NULL UDP that is used to keep the connection between UDP\r
- and MTFTP. Just leave the Udp child unconfigured. When UDP is\r
- unloaded, MTFTP will be informed with DriverBinding Stop.\r
+ Config a NULL UDP that is used to keep the connection between UDP and MTFTP.\r
+\r
+ Just leave the Udp child unconfigured. When UDP is unloaded,\r
+ MTFTP will be informed with DriverBinding Stop.\r
\r
- @param UdpIo The UDP port to configure\r
+ @param UdpIo The UDP_IO to configure\r
@param Context The opaque parameter to the callback\r
\r
@retval EFI_SUCCESS It always return EFI_SUCCESS directly.\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4ConfigNullUdp (\r
- IN UDP_IO_PORT *UdpIo,\r
+ IN UDP_IO *UdpIo,\r
IN VOID *Context\r
)\r
{\r
**/\r
EFI_STATUS\r
Mtftp4CreateService (\r
- IN EFI_HANDLE Controller,\r
- IN EFI_HANDLE Image,\r
- OUT MTFTP4_SERVICE **Service\r
+ IN EFI_HANDLE Controller,\r
+ IN EFI_HANDLE Image,\r
+ OUT MTFTP4_SERVICE **Service\r
)\r
{\r
MTFTP4_SERVICE *MtftpSb;\r
EFI_STATUS Status;\r
\r
*Service = NULL;\r
- MtftpSb = NetAllocatePool (sizeof (MTFTP4_SERVICE));\r
+ MtftpSb = AllocatePool (sizeof (MTFTP4_SERVICE));\r
\r
if (MtftpSb == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete;\r
MtftpSb->InDestory = FALSE;\r
MtftpSb->ChildrenNum = 0;\r
- NetListInit (&MtftpSb->Children);\r
+ InitializeListHead (&MtftpSb->Children);\r
\r
MtftpSb->Timer = NULL;\r
MtftpSb->TimerToGetMap = NULL;\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- NetFreePool (MtftpSb);\r
+ FreePool (MtftpSb);\r
return Status;\r
}\r
\r
);\r
if (EFI_ERROR (Status)) {\r
gBS->CloseEvent (MtftpSb->Timer);\r
- NetFreePool (MtftpSb);\r
+ FreePool (MtftpSb);\r
return Status;\r
}\r
\r
- MtftpSb->ConnectUdp = UdpIoCreatePort (Controller, Image, Mtftp4ConfigNullUdp, NULL);\r
+ MtftpSb->ConnectUdp = UdpIoCreateIo (\r
+ Controller,\r
+ Image,\r
+ Mtftp4ConfigNullUdp,\r
+ UDP_IO_UDP4_VERSION,\r
+ NULL\r
+ );\r
\r
if (MtftpSb->ConnectUdp == NULL) {\r
gBS->CloseEvent (MtftpSb->TimerToGetMap);\r
gBS->CloseEvent (MtftpSb->Timer);\r
- NetFreePool (MtftpSb);\r
+ FreePool (MtftpSb);\r
return EFI_DEVICE_ERROR;\r
}\r
\r
\r
@param MtftpSb The MTFTP service binding instance.\r
\r
- @return None\r
-\r
**/\r
VOID\r
Mtftp4CleanService (\r
IN MTFTP4_SERVICE *MtftpSb\r
)\r
{\r
- UdpIoFreePort (MtftpSb->ConnectUdp);\r
+ UdpIoFreeIo (MtftpSb->ConnectUdp);\r
gBS->CloseEvent (MtftpSb->TimerToGetMap);\r
gBS->CloseEvent (MtftpSb->Timer);\r
}\r
\r
\r
/**\r
- Start the MTFTP driver on this controller. MTFTP driver will\r
- install a MTFTP SERVICE BINDING protocol on the supported\r
+ Start the MTFTP driver on this controller.\r
+\r
+ MTFTP driver will install a MTFTP SERVICE BINDING protocol on the supported\r
controller, which can be used to create/destroy MTFTP children.\r
\r
@param This The MTFTP driver binding protocol.\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4DriverBindingStart (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE Controller,\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ ASSERT (MtftpSb != NULL);\r
\r
Status = gBS->SetTimer (MtftpSb->Timer, TimerPeriodic, TICKS_PER_SECOND);\r
\r
\r
ON_ERROR:\r
Mtftp4CleanService (MtftpSb);\r
- NetFreePool (MtftpSb);\r
+ FreePool (MtftpSb);\r
\r
return Status;\r
}\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4DriverBindingStop (\r
- IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
- IN EFI_HANDLE Controller,\r
- IN UINTN NumberOfChildren,\r
- IN EFI_HANDLE *ChildHandleBuffer\r
+ IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
+ IN EFI_HANDLE Controller,\r
+ IN UINTN NumberOfChildren,\r
+ IN EFI_HANDLE *ChildHandleBuffer\r
)\r
{\r
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
NicHandle = NetLibGetNicHandle (Controller, &gEfiUdp4ProtocolGuid);\r
\r
if (NicHandle == NULL) {\r
- return EFI_SUCCESS;\r
+ return EFI_DEVICE_ERROR;\r
}\r
\r
Status = gBS->OpenProtocol (\r
return EFI_SUCCESS;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
- MtftpSb->InDestory = TRUE;\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
- while (!NetListIsEmpty (&MtftpSb->Children)) {\r
- Instance = NET_LIST_HEAD (&MtftpSb->Children, MTFTP4_PROTOCOL, Link);\r
- Mtftp4ServiceBindingDestroyChild (ServiceBinding, Instance->Handle);\r
- }\r
+ if (NumberOfChildren == 0) {\r
\r
- if (MtftpSb->ChildrenNum != 0) {\r
- Status = EFI_DEVICE_ERROR;\r
- goto ON_ERROR;\r
- }\r
+ MtftpSb->InDestory = TRUE;\r
\r
- Status = gBS->UninstallProtocolInterface (\r
- NicHandle,\r
- &gEfiMtftp4ServiceBindingProtocolGuid,\r
- ServiceBinding\r
- );\r
+ gBS->UninstallProtocolInterface (\r
+ NicHandle,\r
+ &gEfiMtftp4ServiceBindingProtocolGuid,\r
+ ServiceBinding\r
+ );\r
\r
- if (EFI_ERROR (Status)) {\r
- goto ON_ERROR;\r
- }\r
+ Mtftp4CleanService (MtftpSb);\r
\r
- Mtftp4CleanService (MtftpSb);\r
- NetFreePool (MtftpSb);\r
+ FreePool (MtftpSb);\r
+ } else {\r
\r
- NET_RESTORE_TPL (OldTpl);\r
- return EFI_SUCCESS;\r
+ while (!IsListEmpty (&MtftpSb->Children)) {\r
+ Instance = NET_LIST_HEAD (&MtftpSb->Children, MTFTP4_PROTOCOL, Link);\r
+ Mtftp4ServiceBindingDestroyChild (ServiceBinding, Instance->Handle);\r
+ }\r
\r
-ON_ERROR:\r
- MtftpSb->InDestory = FALSE;\r
+ if (MtftpSb->ChildrenNum != 0) {\r
+ Status = EFI_DEVICE_ERROR;\r
+ }\r
+ }\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
return Status;\r
}\r
\r
@param MtftpSb The MTFTP service binding protocol.\r
@param Instance The MTFTP instance to initialize.\r
\r
- @return None\r
-\r
**/\r
VOID\r
Mtftp4InitProtocol (\r
- IN MTFTP4_SERVICE *MtftpSb,\r
- IN MTFTP4_PROTOCOL *Instance\r
+ IN MTFTP4_SERVICE *MtftpSb,\r
+ OUT MTFTP4_PROTOCOL *Instance\r
)\r
{\r
- NetZeroMem (Instance, sizeof (MTFTP4_PROTOCOL));\r
+ ZeroMem (Instance, sizeof (MTFTP4_PROTOCOL));\r
\r
Instance->Signature = MTFTP4_PROTOCOL_SIGNATURE;\r
- NetListInit (&Instance->Link);\r
- CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (EFI_MTFTP4_PROTOCOL));\r
+ InitializeListHead (&Instance->Link);\r
+ CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));\r
Instance->State = MTFTP4_STATE_UNCONFIGED;\r
- Instance->Indestory = FALSE;\r
+ Instance->InDestory = FALSE;\r
Instance->Service = MtftpSb;\r
\r
- NetListInit (&Instance->Blocks);\r
+ InitializeListHead (&Instance->Blocks);\r
}\r
\r
\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4ServiceBindingCreateChild (\r
IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
- IN OUT EFI_HANDLE *ChildHandle\r
+ IN EFI_HANDLE *ChildHandle\r
)\r
{\r
MTFTP4_SERVICE *MtftpSb;\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- Instance = NetAllocatePool (sizeof (*Instance));\r
+ Instance = AllocatePool (sizeof (*Instance));\r
\r
if (Instance == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
\r
Mtftp4InitProtocol (MtftpSb, Instance);\r
\r
- Instance->UnicastPort = UdpIoCreatePort (\r
+ Instance->UnicastPort = UdpIoCreateIo (\r
MtftpSb->Controller,\r
MtftpSb->Image,\r
Mtftp4ConfigNullUdp,\r
+ UDP_IO_UDP4_VERSION,\r
Instance\r
);\r
\r
if (Instance->UnicastPort == NULL) {\r
- NetFreePool (Instance);\r
+ FreePool (Instance);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
//\r
// Add it to the parent's child list.\r
//\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
- NetListInsertTail (&MtftpSb->Children, &Instance->Link);\r
+ InsertTailList (&MtftpSb->Children, &Instance->Link);\r
MtftpSb->ChildrenNum++;\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
ON_ERROR:\r
\r
if (EFI_ERROR (Status)) {\r
- UdpIoFreePort (Instance->UnicastPort);\r
- NetFreePool (Instance);\r
+ UdpIoFreeIo (Instance->UnicastPort);\r
+ FreePool (Instance);\r
}\r
\r
return Status;\r
\r
**/\r
EFI_STATUS\r
+EFIAPI\r
Mtftp4ServiceBindingDestroyChild (\r
IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
IN EFI_HANDLE ChildHandle\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- if (Instance->Indestory) {\r
+ if (Instance->InDestory) {\r
return EFI_SUCCESS;\r
}\r
\r
- Instance->Indestory = TRUE;\r
+ Instance->InDestory = TRUE;\r
\r
//\r
// Close the Udp4 protocol.\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- Instance->Indestory = FALSE;\r
+ Instance->InDestory = FALSE;\r
return Status;\r
}\r
\r
- OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
\r
Mtftp4CleanOperation (Instance, EFI_DEVICE_ERROR);\r
- UdpIoFreePort (Instance->UnicastPort);\r
+ UdpIoFreeIo (Instance->UnicastPort);\r
\r
- NetListRemoveEntry (&Instance->Link);\r
+ RemoveEntryList (&Instance->Link);\r
MtftpSb->ChildrenNum--;\r
\r
- NET_RESTORE_TPL (OldTpl);\r
+ gBS->RestoreTPL (OldTpl);\r
\r
- NetFreePool (Instance);\r
+ FreePool (Instance);\r
return EFI_SUCCESS;\r
}\r