43 ASSERT (Service->ChildrenNum == 0);
45 if (Service->DummyUdpIo !=
NULL) {
49 if (Service->Timer !=
NULL) {
50 gBS->CloseEvent (Service->Timer);
80 ASSERT (Service !=
NULL);
85 if (Mtftp6Srv ==
NULL) {
86 return EFI_OUT_OF_RESOURCES;
89 Mtftp6Srv->Signature = MTFTP6_SERVICE_SIGNATURE;
90 Mtftp6Srv->Controller = Controller;
91 Mtftp6Srv->Image = Image;
92 Mtftp6Srv->ChildrenNum = 0;
95 &Mtftp6Srv->ServiceBinding,
96 &gMtftp6ServiceBindingTemplate,
105 Status =
gBS->CreateEvent (
106 EVT_NOTIFY_SIGNAL | EVT_TIMER,
113 if (EFI_ERROR (Status)) {
130 if (Mtftp6Srv->DummyUdpIo ==
NULL) {
131 gBS->CloseEvent (Mtftp6Srv->Timer);
133 return EFI_DEVICE_ERROR;
136 *Service = Mtftp6Srv;
155 if (Instance->Config !=
NULL) {
159 if ((Instance->Token !=
NULL) && (Instance->Token->Event !=
NULL)) {
160 gBS->SignalEvent (Instance->Token->Event);
163 if (Instance->LastPacket !=
NULL) {
167 if (Instance->UdpIo !=
NULL) {
171 if (Instance->McastUdpIo !=
NULL) {
175 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Instance->BlkList) {
205 if (Mtftp6Ins ==
NULL) {
206 return EFI_OUT_OF_RESOURCES;
209 Mtftp6Ins->Signature = MTFTP6_INSTANCE_SIGNATURE;
210 Mtftp6Ins->InDestroy =
FALSE;
211 Mtftp6Ins->Service = Service;
215 &gMtftp6ProtocolTemplate,
222 *Instance = Mtftp6Ins;
246 UINTN NumberOfChildren;
249 if ((Entry ==
NULL) || (Context ==
NULL)) {
250 return EFI_INVALID_PARAMETER;
253 Instance = NET_LIST_USER_STRUCT_S (Entry,
MTFTP6_INSTANCE, Link, MTFTP6_INSTANCE_SIGNATURE);
262 return ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
289 &gMtftp6DriverBinding,
291 &gMtftp6ComponentName,
292 &gMtftp6ComponentName2
321 return gBS->OpenProtocol (
323 &gEfiUdp6ServiceBindingProtocolGuid,
325 This->DriverBindingHandle,
327 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
363 Status =
gBS->OpenProtocol (
365 &gEfiMtftp6ServiceBindingProtocolGuid,
367 This->DriverBindingHandle,
369 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
372 if (!EFI_ERROR (Status)) {
373 return EFI_ALREADY_STARTED;
381 This->DriverBindingHandle,
385 if (EFI_ERROR (Status)) {
389 ASSERT (Service !=
NULL);
394 Status =
gBS->SetTimer (
400 if (EFI_ERROR (Status)) {
407 Status =
gBS->InstallMultipleProtocolInterfaces (
409 &gEfiMtftp6ServiceBindingProtocolGuid,
410 &Service->ServiceBinding,
414 if (EFI_ERROR (Status)) {
466 if (NicHandle ==
NULL) {
470 Status =
gBS->OpenProtocol (
472 &gEfiMtftp6ServiceBindingProtocolGuid,
473 (VOID **)&ServiceBinding,
474 This->DriverBindingHandle,
476 EFI_OPEN_PROTOCOL_GET_PROTOCOL
479 if (EFI_ERROR (Status)) {
480 return EFI_DEVICE_ERROR;
483 Service = MTFTP6_SERVICE_FROM_THIS (ServiceBinding);
489 List = &Service->Children;
490 Context.ServiceBinding = ServiceBinding;
491 Context.NumberOfChildren = NumberOfChildren;
492 Context.ChildHandleBuffer = ChildHandleBuffer;
501 if ((NumberOfChildren == 0) &&
IsListEmpty (&Service->Children)) {
505 gBS->UninstallProtocolInterface (
507 &gEfiMtftp6ServiceBindingProtocolGuid,
548 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
549 return EFI_INVALID_PARAMETER;
552 Service = MTFTP6_SERVICE_FROM_THIS (This);
556 if (EFI_ERROR (Status)) {
560 ASSERT (Instance !=
NULL);
565 Status =
gBS->InstallMultipleProtocolInterfaces (
567 &gEfiMtftp6ProtocolGuid,
572 if (EFI_ERROR (Status)) {
576 Instance->Handle = *ChildHandle;
581 Status =
gBS->OpenProtocol (
582 Service->DummyUdpIo->UdpHandle,
583 &gEfiUdp6ProtocolGuid,
587 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
590 if (EFI_ERROR (Status)) {
591 gBS->UninstallMultipleProtocolInterfaces (
593 &gEfiMtftp6ProtocolGuid,
604 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
607 Service->ChildrenNum++;
609 gBS->RestoreTPL (OldTpl);
647 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
648 return EFI_INVALID_PARAMETER;
654 Status =
gBS->OpenProtocol (
656 &gEfiMtftp6ProtocolGuid,
660 EFI_OPEN_PROTOCOL_GET_PROTOCOL
663 if (EFI_ERROR (Status)) {
664 return EFI_UNSUPPORTED;
667 Instance = MTFTP6_INSTANCE_FROM_THIS (Mtftp6);
668 Service = MTFTP6_SERVICE_FROM_THIS (This);
670 if (Instance->Service != Service) {
671 return EFI_INVALID_PARAMETER;
677 if (Instance->InDestroy) {
681 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
683 Instance->InDestroy =
TRUE;
686 Service->DummyUdpIo->UdpHandle,
687 &gEfiUdp6ProtocolGuid,
692 if (Instance->UdpIo !=
NULL) {
694 Instance->UdpIo->UdpHandle,
695 &gEfiUdp6ProtocolGuid,
701 if (Instance->McastUdpIo !=
NULL) {
703 Instance->McastUdpIo->UdpHandle,
704 &gEfiUdp6ProtocolGuid,
713 gBS->RestoreTPL (OldTpl);
714 Status =
gBS->UninstallProtocolInterface (
716 &gEfiMtftp6ProtocolGuid,
719 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
720 if (EFI_ERROR (Status)) {
721 Instance->InDestroy =
FALSE;
722 gBS->RestoreTPL (OldTpl);
730 Service->ChildrenNum--;
732 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 AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI Mtftp6DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
VOID Mtftp6DestroyService(IN MTFTP6_SERVICE *Service)
EFI_STATUS EFIAPI Mtftp6ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
EFI_STATUS EFIAPI Mtftp6DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
VOID Mtftp6DestroyInstance(IN MTFTP6_INSTANCE *Instance)
EFI_STATUS EFIAPI Mtftp6DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI Mtftp6DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
EFI_STATUS Mtftp6CreateInstance(IN MTFTP6_SERVICE *Service, OUT MTFTP6_INSTANCE **Instance)
EFI_STATUS EFIAPI Mtftp6DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI Mtftp6ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS Mtftp6CreateService(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, OUT MTFTP6_SERVICE **Service)
EFI_STATUS EFIAPI Mtftp6ConfigDummyUdpIo(IN UDP_IO *UdpIo, IN VOID *Context)
VOID EFIAPI Mtftp6OnTimerTick(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
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)
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_HANDLE DriverBindingHandle