15 USB_RNDIS_DRIVER_VERSION,
37 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor);
38 if (EFI_ERROR (Status)) {
43 if (((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
44 (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
45 (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL)) || \
46 ((InterfaceDescriptor.InterfaceClass == USB_MISC_CLASS) &&
47 (InterfaceDescriptor.InterfaceSubClass == USB_RNDIS_SUBCLASS) &&
48 (InterfaceDescriptor.InterfaceProtocol == USB_RNDIS_ETHERNET_PROTOCOL)) || \
49 ((InterfaceDescriptor.InterfaceClass == USB_CDC_DATA_CLASS) &&
50 (InterfaceDescriptor.InterfaceSubClass == USB_CDC_DATA_SUBCLASS) &&
51 (InterfaceDescriptor.InterfaceProtocol == USB_NO_CLASS_PROTOCOL))
76 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor);
77 if (EFI_ERROR (Status)) {
82 if (((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
83 (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
84 (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL)) || \
85 ((InterfaceDescriptor.InterfaceClass == USB_MISC_CLASS) &&
86 (InterfaceDescriptor.InterfaceSubClass == USB_RNDIS_SUBCLASS) &&
87 (InterfaceDescriptor.InterfaceProtocol == USB_RNDIS_ETHERNET_PROTOCOL))
112 DEBUG ((DEBUG_VERBOSE,
"IsSameDevice Entry \n"));
120 return EFI_UNSUPPORTED;
124 return EFI_UNSUPPORTED;
132 DEBUG ((DEBUG_VERBOSE,
"IsSameDevice Exit \n"));
152 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor);
153 if (EFI_ERROR (Status)) {
158 if ((InterfaceDescriptor.InterfaceClass == USB_CDC_DATA_CLASS) &&
159 (InterfaceDescriptor.InterfaceSubClass == USB_CDC_DATA_SUBCLASS) &&
160 (InterfaceDescriptor.InterfaceProtocol == USB_NO_CLASS_PROTOCOL))
185 Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &InterfaceDescriptor);
186 if (EFI_ERROR (Status)) {
191 if ((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
192 (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
193 (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL))
225 BOOLEAN IsRndisInterfaceFlag;
227 IsRndisInterfaceFlag =
FALSE;
229 Status =
gBS->LocateHandleBuffer (
231 &gEdkIIUsbEthProtocolGuid,
236 if (EFI_ERROR (Status)) {
240 for (Index = 0; Index < HandleCount; Index++) {
241 Status =
gBS->HandleProtocol (
243 &gEdkIIUsbEthProtocolGuid,
244 (VOID **)&UsbEthDevice
246 if (EFI_ERROR (Status)) {
250 Status =
gBS->HandleProtocol (
252 &gEfiUsbIoProtocolGuid,
255 if (EFI_ERROR (Status)) {
260 if (IsRndisInterfaceFlag ==
FALSE) {
264 Status =
gBS->HandleProtocol (
266 &gEfiDevicePathProtocolGuid,
267 (VOID **)&UsbRndisDataPath
269 if (EFI_ERROR (Status)) {
273 Status =
IsSameDevice (UsbRndisDataPath, UsbCdcDataPath);
275 DEBUG ((DEBUG_VERBOSE,
"Rndis IsSameDevice %r\n", Status));
277 if (!EFI_ERROR (Status)) {
278 *UsbRndisDevice = USB_RNDIS_DEVICE_FROM_THIS (UsbEthDevice);
285 return EFI_NOT_FOUND;
310 Status =
gBS->HandleProtocol (
311 UsbRndisDevice->UsbRndisHandle,
312 &gEfiDevicePathProtocolGuid,
313 (VOID **)&UsbRndisDataPath
316 if (EFI_ERROR (Status)) {
320 Status =
gBS->LocateHandleBuffer (
322 &gEfiUsbIoProtocolGuid,
327 if (EFI_ERROR (Status)) {
331 for (Index = 0; Index < HandleCount; Index++) {
332 Status =
gBS->HandleProtocol (
334 &gEfiUsbIoProtocolGuid,
340 DEBUG ((DEBUG_VERBOSE,
"Rndis FindMatchingCdcData CDCData interface found\n"));
342 Status =
gBS->HandleProtocol (
344 &gEfiDevicePathProtocolGuid,
345 (VOID **)&UsbCdcDataPath
347 if (EFI_ERROR (Status)) {
348 DEBUG ((DEBUG_VERBOSE,
"Rndis CDCData DevicePath not found\n"));
353 Status =
IsSameDevice (UsbRndisDataPath, UsbCdcDataPath);
354 DEBUG ((DEBUG_VERBOSE,
"Rndis IsSameDevice %r\n", Status));
355 if (!EFI_ERROR (Status)) {
356 UsbRndisDevice->UsbCdcDataHandle = HandleBuffer[Index];
357 UsbRndisDevice->UsbIoCdcData = UsbIo;
358 GetEndpoint (UsbRndisDevice->UsbIoCdcData, UsbRndisDevice);
397 Status =
gBS->HandleProtocol (
399 &gEfiDevicePathProtocolGuid,
400 (VOID **)&UsbCdcDataPath
403 if (EFI_ERROR (Status)) {
407 Status =
gBS->LocateHandleBuffer (
409 &gEfiUsbIoProtocolGuid,
414 if (EFI_ERROR (Status)) {
418 for (Index = 0; Index < HandleCount; Index++) {
419 Status =
gBS->HandleProtocol (
421 &gEfiUsbIoProtocolGuid,
424 if (EFI_ERROR (Status)) {
429 Status =
gBS->HandleProtocol (
431 &gEfiDevicePathProtocolGuid,
432 (VOID **)&UsbRndisDataPath
434 if (EFI_ERROR (Status)) {
435 DEBUG ((DEBUG_ERROR,
"Usb Rndis DevicePath not found\n"));
439 Status =
IsSameDevice (UsbRndisDataPath, UsbCdcDataPath);
441 if (!EFI_ERROR (Status)) {
442 *RndisHandle = HandleBuffer[Index];
452 return EFI_NOT_FOUND;
479 Status =
gBS->OpenProtocol (
481 &gEfiUsbIoProtocolGuid,
483 This->DriverBindingHandle,
485 EFI_OPEN_PROTOCOL_BY_DRIVER
487 if (EFI_ERROR (Status)) {
495 &gEfiUsbIoProtocolGuid,
496 This->DriverBindingHandle,
531 RndisHandle = ControllerHandle;
533 Status =
gBS->OpenProtocol (
535 &gEfiUsbIoProtocolGuid,
537 This->DriverBindingHandle,
539 EFI_OPEN_PROTOCOL_BY_DRIVER
541 if (EFI_ERROR (Status)) {
545 Status =
gBS->OpenProtocol (
547 &gEfiDevicePathProtocolGuid,
548 (VOID **)&UsbEthPath,
549 This->DriverBindingHandle,
551 EFI_OPEN_PROTOCOL_BY_DRIVER
553 if (EFI_ERROR (Status)) {
556 &gEfiUsbIoProtocolGuid,
557 This->DriverBindingHandle,
565 &gEfiDevicePathProtocolGuid,
566 This->DriverBindingHandle,
572 DEBUG ((DEBUG_INFO,
"Rndis CDCData interface found\n"));
580 if (!EFI_ERROR (Status)) {
581 DEBUG ((DEBUG_INFO,
"Rndis Matching interface found\n"));
582 UsbRndisDevice->UsbCdcDataHandle = ControllerHandle;
583 UsbRndisDevice->UsbIoCdcData = UsbIo;
584 GetEndpoint (UsbRndisDevice->UsbIoCdcData, UsbRndisDevice);
594 if (EFI_ERROR (Status)) {
597 &gEfiUsbIoProtocolGuid,
598 This->DriverBindingHandle,
608 if (!UsbRndisDevice) {
609 DEBUG ((DEBUG_ERROR,
"AllocateZeroPool Fail\n"));
613 &gEfiUsbIoProtocolGuid,
614 This->DriverBindingHandle,
617 return EFI_OUT_OF_RESOURCES;
622 &UsbRndisDevice->Config
624 if (EFI_ERROR (Status)) {
625 DEBUG ((DEBUG_ERROR,
"%a:LoadAllDescriptor status = %r\n", __func__, Status));
628 &gEfiUsbIoProtocolGuid,
629 This->DriverBindingHandle,
636 Status = UsbIo->UsbGetInterfaceDescriptor (
640 if (EFI_ERROR (Status)) {
641 DEBUG ((DEBUG_ERROR,
"%a:UsbGetInterfaceDescriptor status = %r\n", __func__, Status));
644 &gEfiUsbIoProtocolGuid,
645 This->DriverBindingHandle,
653 UsbRndisDevice->Signature = USB_RNDIS_SIGNATURE;
654 UsbRndisDevice->NumOfInterface = Interface.InterfaceNumber;
655 UsbRndisDevice->UsbRndisHandle = RndisHandle;
656 UsbRndisDevice->UsbCdcDataHandle = 0;
657 UsbRndisDevice->UsbIo = UsbIo;
668 UsbRndisDevice->UsbEth.GetUsbEthPowerPatternFilter = GetUsbRndisPowerFilter;
670 UsbRndisDevice->UsbEth.GetUsbEthStatistic = GetRndisStatistic;
673 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStart =
RndisUndiStart;
674 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStop =
RndisUndiStop;
678 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiReset =
RndisUndiReset;
680 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiInterruptEnable =
RndisDummyReturn;
682 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStationAddress =
RndisDummyReturn;
683 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiStatistics =
NULL;
688 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiTransmit =
NULL;
689 UsbRndisDevice->UsbEth.UsbEthUndi.UsbEthUndiReceive =
NULL;
691 UsbRndisDevice->MaxTransferSize = RNDIS_MAX_TRANSFER_SIZE;
692 UsbRndisDevice->MaxPacketsPerTransfer = 1;
693 UsbRndisDevice->PacketAlignmentFactor = 0;
700 if (UsbRndisDevice->UsbIoCdcData) {
701 Status =
gBS->InstallProtocolInterface (
703 &gEdkIIUsbEthProtocolGuid,
705 &(UsbRndisDevice->UsbEth)
707 if (EFI_ERROR (Status)) {
710 &gEfiUsbIoProtocolGuid,
711 This->DriverBindingHandle,
720 GetEndpoint (UsbRndisDevice->UsbIo, UsbRndisDevice);
722 DEBUG ((DEBUG_INFO,
"Rndis DeviceHandle %r\n", UsbRndisDevice->UsbRndisHandle));
723 DEBUG ((DEBUG_INFO,
"CDC DeviceHandle %r\n", UsbRndisDevice->UsbCdcDataHandle));
754 Status =
gBS->OpenProtocol (
756 &gEfiUsbIoProtocolGuid,
758 This->DriverBindingHandle,
760 EFI_OPEN_PROTOCOL_GET_PROTOCOL
762 if (EFI_ERROR (Status)) {
767 Status =
gBS->CloseProtocol (
769 &gEfiUsbIoProtocolGuid,
770 This->DriverBindingHandle,
773 DEBUG ((DEBUG_ERROR,
"Rndis ControllerHandle Stop %r\n", Status));
777 return EFI_UNSUPPORTED;
806 DEBUG ((DEBUG_INFO,
"UsbRndisDriverStop ControllerHandle %lx\n", ControllerHandle));
808 Status =
gBS->OpenProtocol (
810 &gEdkIIUsbEthProtocolGuid,
811 (VOID **)&UsbEthProtocol,
812 This->DriverBindingHandle,
814 EFI_OPEN_PROTOCOL_GET_PROTOCOL
816 if (EFI_ERROR (Status)) {
821 UsbRndisDevice = USB_RNDIS_DEVICE_FROM_THIS (UsbEthProtocol);
823 Status =
gBS->CloseProtocol (
824 UsbRndisDevice->UsbCdcDataHandle,
825 &gEfiUsbIoProtocolGuid,
826 This->DriverBindingHandle,
827 UsbRndisDevice->UsbCdcDataHandle
829 if (EFI_ERROR (Status)) {
830 DEBUG ((DEBUG_ERROR,
"%a:CloseProtocol status = %r\n", __func__, Status));
833 Status =
gBS->UninstallProtocolInterface (
835 &gEdkIIUsbEthProtocolGuid,
838 if (EFI_ERROR (Status)) {
842 Status =
gBS->CloseProtocol (
844 &gEfiUsbIoProtocolGuid,
845 This->DriverBindingHandle,
852 DEBUG ((DEBUG_INFO,
"UsbRndisDriverStop %r\n", Status));
878 return gBS->InstallMultipleProtocolInterfaces (
880 &gEfiDriverBindingProtocolGuid,
881 &gUsbRndisDriverBinding,
882 &gEfiComponentName2ProtocolGuid,
883 &gUsbRndisComponentName2,
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS EFIAPI GetUsbEthMacAddress(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT EFI_MAC_ADDRESS *MacAddress)
VOID GetEndpoint(IN EFI_USB_IO_PROTOCOL *UsbIo, IN OUT USB_ETHERNET_DRIVER *UsbEthDriver)
EFI_STATUS LoadAllDescriptor(IN EFI_USB_IO_PROTOCOL *UsbIo, OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc)
EFI_STATUS EFIAPI GetUsbHeaderFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor)
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
BOOLEAN IsUsbRndis(IN EFI_USB_IO_PROTOCOL *UsbIo)
EFI_STATUS EFIAPI UsbRndisEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI UsbRndisDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI CheckandStopRndisDevice(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle)
BOOLEAN IsRndisInterface(IN EFI_USB_IO_PROTOCOL *UsbIo)
BOOLEAN IsSupportedDevice(IN EFI_USB_IO_PROTOCOL *UsbIo)
EFI_STATUS EFIAPI UsbRndisDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
VOID FindMatchingCdcData(IN USB_RNDIS_DEVICE *UsbRndisDevice)
EFI_STATUS UpdateRndisDevice(IN EFI_DEVICE_PATH_PROTOCOL *UsbCdcDataPath, OUT USB_RNDIS_DEVICE **UsbRndisDevice)
EFI_STATUS IsSameDevice(IN EFI_DEVICE_PATH_PROTOCOL *UsbRndisDataPath, IN EFI_DEVICE_PATH_PROTOCOL *UsbCdcDataPath)
BOOLEAN IsUsbCdcData(IN EFI_USB_IO_PROTOCOL *UsbIo)
EFI_STATUS EFIAPI FindMatchingRndisDev(IN EFI_HANDLE CdcHandle, OUT EFI_USB_IO_PROTOCOL **CdcUsbIo, OUT EFI_HANDLE *RndisHandle)
EFI_STATUS EFIAPI UsbRndisDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI GetUsbRndisFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor)
EFI_STATUS EFIAPI RndisUndiShutdown(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiReceiveFilter(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiStop(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiReceive(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *BulkInData, IN OUT UINTN *DataLength)
EFI_STATUS EFIAPI SetUsbRndisPacketFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value)
EFI_STATUS EFIAPI RndisUndiReset(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiGetConfigInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI SetUsbRndisMcastFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN VOID *McastAddr)
EFI_STATUS EFIAPI UsbRndisInterrupt(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Requst)
EFI_STATUS EFIAPI UsbEthBulkSize(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS EFIAPI RndisDummyReturn(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiGetStatus(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiInitialize(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiGetInitInfo(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiStart(IN PXE_CDB *Cdb, IN NIC_DATA *Nic)
EFI_STATUS EFIAPI RndisUndiTransmit(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *BulkOutData, IN OUT UINTN *DataLength)
EFI_STATUS EFIAPI SetUsbRndisPowerFilter(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN UINT16 Value, IN UINT16 Length, IN VOID *PatternFilter)
EFI_HANDLE DriverBindingHandle