36 Status = UsbIo->UsbGetConfigDescriptor (UsbIo, &Tmp);
44 USB_DESC_TYPE_CONFIG << 8 | (Tmp.ConfigurationValue - 1),
70 if ((Desc ==
NULL) || (*Offset >= Desc->TotalLength)) {
79 if ( *Offset >= Desc->TotalLength ) {
102 IN UINT8 FunDescriptorType,
110 Status = EFI_NOT_FOUND;
114 if (Interface->DescriptorType == USB_DESC_TYPE_CS_INTERFACE) {
116 switch (FunDescriptorType) {
117 case HEADER_FUN_DESCRIPTOR:
124 case UNION_FUN_DESCRIPTOR:
131 case ETHERNET_FUN_DESCRIPTOR:
139 Status = EFI_UNSUPPORTED;
168 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);
171 if (Interface.NumEndpoints == 0) {
172 Status =
UsbSetInterface (UsbIo, Interface.InterfaceNumber, 1, &Result);
175 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &Interface);
179 for (Index = 0; Index < Interface.NumEndpoints; Index++) {
180 Status = UsbIo->UsbGetEndpointDescriptor (UsbIo, Index, &Endpoint);
183 switch ((Endpoint.Attributes & (BIT0 | BIT1))) {
184 case USB_ENDPOINT_BULK:
185 if (Endpoint.EndpointAddress & BIT7) {
186 UsbEthDriver->BulkInEndpoint = Endpoint.EndpointAddress;
188 UsbEthDriver->BulkOutEndpoint = Endpoint.EndpointAddress;
192 case USB_ENDPOINT_INTERRUPT:
193 UsbEthDriver->InterruptEndpoint = Endpoint.EndpointAddress;
229 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
231 Status =
gBS->HandleProtocol (
232 UsbEthDriver->UsbCdcDataHandle,
233 &gEfiUsbIoProtocolGuid,
236 if (EFI_ERROR (Status)) {
240 if (UsbEthDriver->BulkInEndpoint == 0) {
244 Status = UsbIo->UsbBulkTransfer (
246 UsbEthDriver->BulkInEndpoint,
249 USB_ETHERNET_BULK_TIMEOUT,
285 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
287 Status =
gBS->HandleProtocol (
288 UsbEthDriver->UsbCdcDataHandle,
289 &gEfiUsbIoProtocolGuid,
292 if (EFI_ERROR (Status)) {
296 if (UsbEthDriver->BulkOutEndpoint == 0) {
300 Status = UsbIo->UsbBulkTransfer (
302 UsbEthDriver->BulkOutEndpoint,
305 USB_ETHERNET_BULK_TIMEOUT,
334 if ((Data ==
NULL) || (Context ==
NULL)) {
335 return EFI_INVALID_PARAMETER;
370 IN BOOLEAN IsNewTransfer,
379 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
384 Status = UsbEthDriver->UsbIo->UsbAsyncInterruptTransfer (
386 UsbEthDriver->InterruptEndpoint,
394 Status = UsbEthDriver->UsbIo->UsbAsyncInterruptTransfer (
396 UsbEthDriver->InterruptEndpoint,
436 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
438 Status = This->UsbEthFunDescriptor (This, &UsbEthDescriptor);
439 if (EFI_ERROR (Status)) {
440 DEBUG ((DEBUG_ERROR,
"%a:UsbEthFunDescriptor status = %r\n", __func__, Status));
444 Status = UsbEthDriver->UsbIo->UsbGetStringDescriptor (
447 UsbEthDescriptor.MacAddress,
450 if (EFI_ERROR (Status)) {
451 DEBUG ((DEBUG_ERROR,
"%a:UsbGetStringDescriptor status = %r\n", __func__, Status));
456 for (Index = 0; Index < PXE_HWADDR_LEN_ETHER; Index++) {
457 CopyMem (TmpStr, DataPtr,
sizeof (CHAR16));
460 CopyMem (TmpStr, DataPtr,
sizeof (CHAR16));
463 MacAddress->Addr[Index] = (Hi << 4) | Low;
489 Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
490 if (EFI_ERROR (Status)) {
494 *BulkSize = (
UINTN)UsbEthFunDescriptor.MaxSegmentSize;
519 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
521 if (UsbHeaderFunDescriptor ==
NULL) {
522 return EFI_INVALID_PARAMETER;
550 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
552 if (UsbUnionFunDescriptor ==
NULL) {
553 return EFI_INVALID_PARAMETER;
585 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
587 if (UsbEthFunDescriptor ==
NULL) {
588 return EFI_INVALID_PARAMETER;
624 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
626 Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
627 if (EFI_ERROR (Status)) {
631 if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
632 return EFI_UNSUPPORTED;
635 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
636 Request.Request = SET_ETH_MULTICAST_FILTERS_REQ;
637 Request.Value = Value;
638 Request.Index = UsbEthDriver->NumOfInterface;
639 Request.Length = Value * 6;
641 return UsbEthDriver->UsbIo->UsbControlTransfer (
645 USB_ETHERNET_TRANSFER_TIMEOUT,
674 IN VOID *PatternFilter
681 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
683 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
684 Request.Request = SET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ;
685 Request.Value = Value;
686 Request.Index = UsbEthDriver->NumOfInterface;
687 Request.Length = Length;
689 return UsbEthDriver->UsbIo->UsbControlTransfer (
693 USB_ETHERNET_TRANSFER_TIMEOUT,
720 OUT BOOLEAN *PatternActive
727 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
729 Request.RequestType = USB_ETHERNET_GET_REQ_TYPE;
730 Request.Request = GET_ETH_POWER_MANAGEMENT_PATTERN_FILTER_REQ;
731 Request.Value = Value;
732 Request.Index = UsbEthDriver->NumOfInterface;
733 Request.Length = USB_ETH_POWER_FILTER_LENGTH;
735 return UsbEthDriver->UsbIo->UsbControlTransfer (
739 USB_ETHERNET_TRANSFER_TIMEOUT,
741 USB_ETH_POWER_FILTER_LENGTH,
764 OUT UINT16 *CdcFilter
770 Count =
sizeof (gTable)/
sizeof (gTable[0]);
772 for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
773 if (gTable[Index].Src & Value) {
774 *CdcFilter |= gTable[Index].Dst;
802 UINT16 CommandFilter;
804 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
809 Request.RequestType = USB_ETHERNET_SET_REQ_TYPE;
810 Request.Request = SET_ETH_PACKET_FILTER_REQ;
811 Request.Value = CommandFilter;
812 Request.Index = UsbEthDriver->NumOfInterface;
813 Request.Length = USB_ETH_PACKET_FILTER_LENGTH;
815 return UsbEthDriver->UsbIo->UsbControlTransfer (
819 USB_ETHERNET_TRANSFER_TIMEOUT,
821 USB_ETH_PACKET_FILTER_LENGTH,
844 IN UINT16 FeatureSelector,
854 UsbEthDriver = USB_ETHERNET_DEV_FROM_THIS (This);
856 Status = This->UsbEthFunDescriptor (This, &UsbEthFunDescriptor);
857 if (EFI_ERROR (Status)) {
861 if (UsbEthFunDescriptor.EthernetStatistics == 0) {
862 return EFI_UNSUPPORTED;
865 Request.RequestType = USB_ETHERNET_GET_REQ_TYPE;
866 Request.Request = GET_ETH_STATISTIC_REQ;
867 Request.Value = FeatureSelector;
868 Request.Index = UsbEthDriver->NumOfInterface;
869 Request.Length = USB_ETH_STATISTIC;
871 return UsbEthDriver->UsbIo->UsbControlTransfer (
875 USB_ETHERNET_TRANSFER_TIMEOUT,
UINTN EFIAPI StrHexToUintn(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST
#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS
#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST
#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST
#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST
EFI_STATUS EFIAPI UsbSetInterface(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Interface, IN UINT16 AlternateSetting, OUT UINT32 *Status)
EFI_STATUS EFIAPI UsbGetDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINT16 Value, IN UINT16 Index, IN UINT16 DescriptorLength, OUT VOID *Descriptor, OUT UINT32 *Status)
EFI_STATUS EFIAPI GetUsbEthMacAddress(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
EFI_STATUS EFIAPI SetUsbEthPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
EFI_STATUS EFIAPI SetUsbEthPacketFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
EFI_STATUS EFIAPI UsbEthEcmInterrupt(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Request)
EFI_STATUS EFIAPI InterruptCallback(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
VOID GetEndpoint(IN EFI_USB_IO_PROTOCOL *UsbIo, IN OUT USB_ETHERNET_DRIVER *UsbEthDriver)
EFI_STATUS EFIAPI UsbEthEcmBulkSize(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS GetFunctionalDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Config, IN UINT8 FunDescriptorType, OUT VOID *DataBuffer)
EFI_STATUS EFIAPI GetUsbEthFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
EFI_STATUS EFIAPI GetUsbEthPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, OUT BOOLEAN *PatternActive)
EFI_STATUS LoadAllDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc)
EFI_STATUS EFIAPI UsbEthEcmTransmit(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS EFIAPI GetUsbEthStatistic(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 FeatureSelector, OUT VOID *Statistic)
EFI_STATUS EFIAPI SetUsbEthMcastFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
EFI_STATUS EFIAPI UsbEthEcmReceive(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
VOID ConvertFilter(IN UINT16 Value, OUT UINT16 *CdcFilter)
BOOLEAN NextDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Desc, IN OUT UINTN *Offset)