/** Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver. This function retrieves the user readable name of the controller specified by ControllerHandle and ChildHandle in the form of a Unicode string. If the driver specified by This has a user readable name in the language specified by Language, then a pointer to the controller name is returned in ControllerName, and EFI_SUCCESS is returned. If the driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle, then EFI_UNSUPPORTED is returned. If the driver specified by This does not support the language specified by Language, then EFI_UNSUPPORTED is returned. @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or EFI_COMPONENT_NAME_PROTOCOL instance. @param[in] ControllerHandle The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned. @param[in] ChildHandle The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller. @param[in] Language A pointer to a Null-terminated ASCII string array indicating the language. This is the language of the driver name that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. Language is specified in RFC 4646 or ISO 639-2 language code format. @param[out] ControllerName A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This. @retval EFI_SUCCESS The Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. @retval EFI_INVALID_PARAMETER Language is NULL. @retval EFI_INVALID_PARAMETER ControllerName is NULL. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle. @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language. **/ EFI_STATUS EFIAPI PxeBcComponentNameGetControllerName ( IN EFI_COMPONENT_NAME_PROTOCOL * This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName ) { EFI_PXE_BASE_CODE_PROTOCOL *PxeBc; EFI_HANDLE NicHandle; EFI_STATUS Status; if (ControllerHandle == NULL || ChildHandle != NULL) { return EFI_UNSUPPORTED; } NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiMtftp4ProtocolGuid); if (NicHandle == NULL) { return EFI_UNSUPPORTED; } } } } } Status = gBS->OpenProtocol ( NicHandle, &gEfiPxeBaseCodeProtocolGuid, (VOID **) &PxeBc, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } return LookupUnicodeString2 ( Language, This->SupportedLanguages, mPxeBcControllerNameTable, ControllerName, (BOOLEAN)(This == &gPxeBcComponentName) ); }
/** Get the Nic handle using any child handle in the IPv4 stack. @param[in] ControllerHandle Pointer to child handle over IPv4. @return NicHandle The pointer to the Nic handle. **/ EFI_HANDLE PxeBcGetNicByIp4Children ( IN EFI_HANDLE ControllerHandle ) { EFI_HANDLE NicHandle; NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiMtftp4ProtocolGuid); if (NicHandle == NULL) { return NULL; } } } } } return NicHandle; }
/** Get the Nic handle using any child handle in the IPv6 stack. @param[in] ControllerHandle Pointer to child handle over IPv6. @return NicHandle The pointer to the Nic handle. @return NULL Can't find the Nic handle. **/ EFI_HANDLE HttpBootGetNicByIp6Children ( IN EFI_HANDLE ControllerHandle ) { EFI_HANDLE NicHandle; NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiHttpProtocolGuid); if (NicHandle == NULL) { NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp6ProtocolGuid); if (NicHandle == NULL) { return NULL; } } return NicHandle; }
/** Retrieves a Unicode string that is the user readable name of the controller that is being managed by an EFI Driver.Currently not implemented. @param[in] This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. @param[in] ControllerHandle The handle of a controller that the driver specified by This is managing. This handle specifies the controller whose name is to be returned. @param[in] ChildHandle The handle of the child controller to retrieve the name of. This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to retrieve the name of the bus controller. It will not be NULL for a bus driver that wishes to retrieve the name of a child controller. @param[in] Language A pointer to a three character ISO 639-2 language identifier. This is the language of the controller name that that the caller is requesting, and it must match one of the languages specified in SupportedLanguages. The number of languages supported by a driver is up to the driver writer. @param[out] ControllerName A pointer to the Unicode string to return. This Unicode string is the name of the controller specified by ControllerHandle and ChildHandle in the language specified by Language from the point of view of the driver specified by This. @retval EFI_SUCCESS The Unicode string for the user readable name in the language specified by Language for the driver specified by This was returned in DriverName. @retval EFI_INVALID_PARAMETER ControllerHandle is NULL. @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE. @retval EFI_INVALID_PARAMETER Language is NULL. @retval EFI_INVALID_PARAMETER ControllerName is NULL. @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller specified by ControllerHandle and ChildHandle. @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language. **/ EFI_STATUS EFIAPI IScsiComponentNameGetControllerName ( IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName ) { EFI_HANDLE IScsiController; ISCSI_PRIVATE_PROTOCOL *IScsiIdentifier; EFI_STATUS Status; // // Get the handle of the controller we are controling. // IScsiController = NetLibGetNicHandle (ControllerHandle, &gEfiTcp4ProtocolGuid); if (IScsiController == NULL) { return EFI_UNSUPPORTED; } Status = gBS->OpenProtocol ( IScsiController, &gEfiCallerIdGuid, (VOID **)&IScsiIdentifier, NULL, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return Status; } return LookupUnicodeString2 ( Language, This->SupportedLanguages, mIScsiControllerNameTable, ControllerName, (BOOLEAN)(This == &gIScsiComponentName) ); }
/** Stop the MTFTP driver on controller. The controller is a UDP child handle. @param This The MTFTP driver binding protocol @param Controller The controller to stop @param NumberOfChildren The number of children @param ChildHandleBuffer The array of the child handle. @retval EFI_SUCCESS The driver is stopped on the controller. @retval EFI_DEVICE_ERROR Failed to stop the driver on the controller. **/ EFI_STATUS EFIAPI Mtftp4DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) { EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; MTFTP4_SERVICE *MtftpSb; EFI_HANDLE NicHandle; EFI_STATUS Status; LIST_ENTRY *List; MTFTP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; // // MTFTP driver opens UDP child, So, Controller is a UDP // child handle. Locate the Nic handle first. Then get the // MTFTP private data back. // NicHandle = NetLibGetNicHandle (Controller, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { return EFI_SUCCESS; } Status = gBS->OpenProtocol ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, (VOID **) &ServiceBinding, This->DriverBindingHandle, NicHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding); if (!IsListEmpty (&MtftpSb->Children)) { // // Destroy the Mtftp4 child instance in ChildHandleBuffer. // List = &MtftpSb->Children; Context.ServiceBinding = ServiceBinding; Context.NumberOfChildren = NumberOfChildren; Context.ChildHandleBuffer = ChildHandleBuffer; Status = NetDestroyLinkList ( List, Mtftp4DestroyChildEntryInHandleBuffer, &Context, NULL ); } if (NumberOfChildren == 0 && IsListEmpty (&MtftpSb->Children)) { gBS->UninstallProtocolInterface ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, ServiceBinding ); Mtftp4CleanService (MtftpSb); if (gMtftp4ControllerNameTable != NULL) { FreeUnicodeStringTable (gMtftp4ControllerNameTable); gMtftp4ControllerNameTable = NULL; } FreePool (MtftpSb); Status = EFI_SUCCESS; } return Status; }
/** Destroy a TCP6 or TCP4 service binding instance. It will release all the resources allocated by the instance. @param[in] Controller Controller handle of device to bind driver to. @param[in] ImageHandle The TCP driver's image handle. @param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of children is zero stop the entire bus driver. @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL if NumberOfChildren is 0. @param[in] IpVersion IP_VERSION_4 or IP_VERSION_6 @retval EFI_SUCCESS The resources used by the instance were cleaned up. @retval Others Failed to clean up some of the resources. **/ EFI_STATUS TcpDestroyService ( IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer, OPTIONAL IN UINT8 IpVersion ) { EFI_HANDLE NicHandle; EFI_GUID *IpProtocolGuid; EFI_GUID *ServiceBindingGuid; EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; TCP_SERVICE_DATA *TcpServiceData; EFI_STATUS Status; LIST_ENTRY *List; TCP_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context; ASSERT ((IpVersion == IP_VERSION_4) || (IpVersion == IP_VERSION_6)); if (IpVersion == IP_VERSION_4) { IpProtocolGuid = &gEfiIp4ProtocolGuid; ServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid; } else { IpProtocolGuid = &gEfiIp6ProtocolGuid; ServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid; } NicHandle = NetLibGetNicHandle (Controller, IpProtocolGuid); if (NicHandle == NULL) { return EFI_SUCCESS; } Status = gBS->OpenProtocol ( NicHandle, ServiceBindingGuid, (VOID **) &ServiceBinding, ImageHandle, Controller, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } TcpServiceData = TCP_SERVICE_FROM_THIS (ServiceBinding); if (NumberOfChildren != 0) { List = &TcpServiceData->SocketList; Context.ServiceBinding = ServiceBinding; Context.NumberOfChildren = NumberOfChildren; Context.ChildHandleBuffer = ChildHandleBuffer; Status = NetDestroyLinkList ( List, TcpDestroyChildEntryInHandleBuffer, &Context, NULL ); } else if (IsListEmpty (&TcpServiceData->SocketList)) { // // Uninstall TCP servicebinding protocol // gBS->UninstallMultipleProtocolInterfaces ( NicHandle, ServiceBindingGuid, ServiceBinding, NULL ); // // Destroy the IpIO consumed by TCP driver // IpIoDestroy (TcpServiceData->IpIo); TcpServiceData->IpIo = NULL; // // Destroy the heartbeat timer. // TcpDestroyTimer (); // // Release the TCP service data // FreePool (TcpServiceData); Status = EFI_SUCCESS; } return Status; }
EFI_STATUS Mtftp4DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) /*++ Routine Description: Stop the MTFTP driver on controller. The controller is a UDP child handle. Arguments: This - The MTFTP driver binding protocol Controller - The controller to stop NumberOfChildren - The number of children ChildHandleBuffer - The array of the child handle. Returns: EFI_SUCCESS - The driver is stopped on the controller. EFI_DEVICE_ERROR - Failed to stop the driver on the controller. --*/ { EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; MTFTP4_SERVICE *MtftpSb; MTFTP4_PROTOCOL *Instance; EFI_HANDLE NicHandle; EFI_STATUS Status; EFI_TPL OldTpl; // // MTFTP driver opens UDP child, So, Controller is a UDP // child handle. Locate the Nic handle first. Then get the // MTFTP private data back. // NicHandle = NetLibGetNicHandle (Controller, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { return EFI_DEVICE_ERROR; } Status = gBS->OpenProtocol ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, (VOID **) &ServiceBinding, This->DriverBindingHandle, NicHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding); if (MtftpSb->InDestory) { return EFI_SUCCESS; } OldTpl = NET_RAISE_TPL (NET_TPL_LOCK); if (NumberOfChildren == 0) { MtftpSb->InDestory = TRUE; gBS->UninstallProtocolInterface ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, ServiceBinding ); Mtftp4CleanService (MtftpSb); NetFreePool (MtftpSb); } else { while (!NetListIsEmpty (&MtftpSb->Children)) { Instance = NET_LIST_HEAD (&MtftpSb->Children, MTFTP4_PROTOCOL, Link); Mtftp4ServiceBindingDestroyChild (ServiceBinding, Instance->Handle); } if (MtftpSb->ChildrenNum != 0) { Status = EFI_DEVICE_ERROR; } } NET_RESTORE_TPL (OldTpl); return Status; }
/** Stop the MTFTP driver on controller. The controller is a UDP child handle. @param This The MTFTP driver binding protocol @param Controller The controller to stop @param NumberOfChildren The number of children @param ChildHandleBuffer The array of the child handle. @retval EFI_SUCCESS The driver is stopped on the controller. @retval EFI_DEVICE_ERROR Failed to stop the driver on the controller. **/ EFI_STATUS EFIAPI Mtftp4DriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer ) { EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding; MTFTP4_SERVICE *MtftpSb; MTFTP4_PROTOCOL *Instance; EFI_HANDLE NicHandle; EFI_STATUS Status; EFI_TPL OldTpl; // // MTFTP driver opens UDP child, So, Controller is a UDP // child handle. Locate the Nic handle first. Then get the // MTFTP private data back. // NicHandle = NetLibGetNicHandle (Controller, &gEfiUdp4ProtocolGuid); if (NicHandle == NULL) { return EFI_DEVICE_ERROR; } Status = gBS->OpenProtocol ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, (VOID **) &ServiceBinding, This->DriverBindingHandle, NicHandle, EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { return EFI_DEVICE_ERROR; } MtftpSb = MTFTP4_SERVICE_FROM_THIS (ServiceBinding); if (MtftpSb->InDestory) { return EFI_SUCCESS; } OldTpl = gBS->RaiseTPL (TPL_CALLBACK); if (NumberOfChildren == 0) { MtftpSb->InDestory = TRUE; gBS->UninstallProtocolInterface ( NicHandle, &gEfiMtftp4ServiceBindingProtocolGuid, ServiceBinding ); Mtftp4CleanService (MtftpSb); FreePool (MtftpSb); } else { while (!IsListEmpty (&MtftpSb->Children)) { Instance = NET_LIST_HEAD (&MtftpSb->Children, MTFTP4_PROTOCOL, Link); Mtftp4ServiceBindingDestroyChild (ServiceBinding, Instance->Handle); } if (MtftpSb->ChildrenNum != 0) { Status = EFI_DEVICE_ERROR; } } gBS->RestoreTPL (OldTpl); return Status; }