45 &gMtftp4DriverBinding,
83 Status =
gBS->OpenProtocol (
85 &gEfiUdp4ServiceBindingProtocolGuid,
87 This->DriverBindingHandle,
89 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
146 if (MtftpSb ==
NULL) {
147 return EFI_OUT_OF_RESOURCES;
151 MtftpSb->ServiceBinding = gMtftp4ServiceBindingTemplete;
152 MtftpSb->ChildrenNum = 0;
157 MtftpSb->TimerToGetMap =
NULL;
158 MtftpSb->Controller = Controller;
159 MtftpSb->Image = Image;
160 MtftpSb->ConnectUdp =
NULL;
165 Status =
gBS->CreateEvent (
166 EVT_NOTIFY_SIGNAL | EVT_TIMER,
172 if (EFI_ERROR (Status)) {
177 Status =
gBS->CreateEvent (
178 EVT_NOTIFY_SIGNAL | EVT_TIMER,
184 if (EFI_ERROR (Status)) {
194 Status =
gBS->CreateEvent (
199 &MtftpSb->TimerToGetMap
201 if (EFI_ERROR (Status)) {
216 if (MtftpSb->ConnectUdp ==
NULL) {
217 gBS->CloseEvent (MtftpSb->TimerToGetMap);
221 return EFI_DEVICE_ERROR;
240 gBS->CloseEvent (MtftpSb->TimerToGetMap);
241 gBS->CloseEvent (MtftpSb->TimerNotifyLevel);
242 gBS->CloseEvent (MtftpSb->Timer);
275 Status =
gBS->OpenProtocol (
277 &gEfiMtftp4ServiceBindingProtocolGuid,
279 This->DriverBindingHandle,
281 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
285 return EFI_ALREADY_STARTED;
290 if (EFI_ERROR (Status)) {
294 ASSERT (MtftpSb !=
NULL);
298 if (EFI_ERROR (Status)) {
304 if (EFI_ERROR (Status)) {
311 Status =
gBS->InstallMultipleProtocolInterfaces (
313 &gEfiMtftp4ServiceBindingProtocolGuid,
314 &MtftpSb->ServiceBinding,
318 if (EFI_ERROR (Status)) {
350 UINTN NumberOfChildren;
353 if ((Entry ==
NULL) || (Context ==
NULL)) {
354 return EFI_INVALID_PARAMETER;
357 Instance = NET_LIST_USER_STRUCT_S (Entry,
MTFTP4_PROTOCOL, Link, MTFTP4_PROTOCOL_SIGNATURE);
366 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
405 if (NicHandle ==
NULL) {
409 Status =
gBS->OpenProtocol (
411 &gEfiMtftp4ServiceBindingProtocolGuid,
412 (VOID **)&ServiceBinding,
413 This->DriverBindingHandle,
415 EFI_OPEN_PROTOCOL_GET_PROTOCOL
418 if (EFI_ERROR (Status)) {
419 return EFI_DEVICE_ERROR;
422 MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding);
428 List = &MtftpSb->Children;
429 Context.ServiceBinding = ServiceBinding;
430 Context.NumberOfChildren = NumberOfChildren;
431 Context.ChildHandleBuffer = ChildHandleBuffer;
440 if ((NumberOfChildren == 0) &&
IsListEmpty (&MtftpSb->Children)) {
441 gBS->UninstallProtocolInterface (
443 &gEfiMtftp4ServiceBindingProtocolGuid,
448 if (gMtftp4ControllerNameTable !=
NULL) {
450 gMtftp4ControllerNameTable =
NULL;
476 Instance->Signature = MTFTP4_PROTOCOL_SIGNATURE;
478 CopyMem (&Instance->Mtftp4, &gMtftp4ProtocolTemplate, sizeof (Instance->Mtftp4));
479 Instance->State = MTFTP4_STATE_UNCONFIGED;
480 Instance->Service = MtftpSb;
510 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
511 return EFI_INVALID_PARAMETER;
516 if (Instance ==
NULL) {
517 return EFI_OUT_OF_RESOURCES;
520 MtftpSb = MTFTP4_SERVICE_FROM_THIS (This);
532 if (Instance->UnicastPort ==
NULL) {
534 return EFI_OUT_OF_RESOURCES;
540 Status =
gBS->InstallMultipleProtocolInterfaces (
542 &gEfiMtftp4ProtocolGuid,
547 if (EFI_ERROR (Status)) {
553 Instance->Handle = *ChildHandle;
558 Status =
gBS->OpenProtocol (
559 MtftpSb->ConnectUdp->UdpHandle,
560 &gEfiUdp4ProtocolGuid,
564 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
566 if (EFI_ERROR (Status)) {
573 Status =
gBS->OpenProtocol (
574 Instance->UnicastPort->UdpHandle,
575 &gEfiUdp4ProtocolGuid,
579 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
581 if (EFI_ERROR (Status)) {
586 MtftpSb->ConnectUdp->UdpHandle,
587 &gEfiUdp4ProtocolGuid,
597 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
600 MtftpSb->ChildrenNum++;
602 gBS->RestoreTPL (OldTpl);
607 if (Instance->Handle !=
NULL) {
608 gBS->UninstallMultipleProtocolInterfaces (
610 &gEfiMtftp4ProtocolGuid,
647 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
648 return EFI_INVALID_PARAMETER;
654 Status =
gBS->OpenProtocol (
656 &gEfiMtftp4ProtocolGuid,
660 EFI_OPEN_PROTOCOL_GET_PROTOCOL
663 if (EFI_ERROR (Status)) {
664 return EFI_UNSUPPORTED;
667 Instance = MTFTP4_PROTOCOL_FROM_THIS (Mtftp4);
668 MtftpSb = MTFTP4_SERVICE_FROM_THIS (This);
670 if (Instance->Service != MtftpSb) {
671 return EFI_INVALID_PARAMETER;
674 if (Instance->InDestroy) {
678 Instance->InDestroy =
TRUE;
684 MtftpSb->ConnectUdp->UdpHandle,
685 &gEfiUdp4ProtocolGuid,
691 Instance->UnicastPort->UdpHandle,
692 &gEfiUdp4ProtocolGuid,
697 if (Instance->McastUdpPort !=
NULL) {
699 Instance->McastUdpPort->UdpHandle,
700 &gEfiUdp4ProtocolGuid,
709 Status =
gBS->UninstallProtocolInterface (
711 &gEfiMtftp4ProtocolGuid,
715 if (EFI_ERROR (Status)) {
716 Instance->InDestroy =
FALSE;
720 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
726 MtftpSb->ChildrenNum--;
728 gBS->RestoreTPL (OldTpl);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI Mtftp4DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI Mtftp4DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID Mtftp4InitProtocol(IN MTFTP4_SERVICE *MtftpSb, OUT MTFTP4_PROTOCOL *Instance)
VOID Mtftp4CleanService(IN MTFTP4_SERVICE *MtftpSb)
EFI_STATUS EFIAPI Mtftp4DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI Mtftp4ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI Mtftp4ConfigNullUdp(IN UDP_IO *UdpIo, IN VOID *Context)
EFI_STATUS EFIAPI Mtftp4DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
EFI_STATUS EFIAPI Mtftp4DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS Mtftp4CreateService(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, OUT MTFTP4_SERVICE **Service)
EFI_STATUS EFIAPI Mtftp4ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
VOID Mtftp4CleanOperation(IN OUT MTFTP4_PROTOCOL *Instance, IN EFI_STATUS Result)
#define MTFTP4_SERVICE_SIGNATURE
VOID EFIAPI Mtftp4OnTimerTickNotifyLevel(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI Mtftp4OnTimerTick(IN EFI_EVENT Event, IN VOID *Context)
BOOLEAN EFIAPI NetIsInHandleBuffer(IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI NetDestroyLinkList(IN LIST_ENTRY *List, IN NET_DESTROY_LINK_LIST_CALLBACK CallBack, IN VOID *Context OPTIONAL, OUT UINTN *ListLength OPTIONAL)
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMtftp4ComponentName2
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMtftp4ComponentName
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI UdpIoFreeIo(IN UDP_IO *UdpIo)
UDP_IO *EFIAPI UdpIoCreateIo(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UDP_IO_CONFIG Configure, IN UINT8 UdpVersion, IN VOID *Context)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
EFI_HANDLE DriverBindingHandle
EFI_EVENT Timer
Ticking timer for all the MTFTP clients to handle the packet timeout case.
EFI_EVENT TimerNotifyLevel
Ticking timer for all the MTFTP clients to calculate the packet live time.