TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbCdcNcm.h
Go to the documentation of this file.
1
8#ifndef USB_CDC_NCM_H_
9#define USB_CDC_NCM_H_
10
13#include <Library/UefiLib.h>
15#include <Library/DebugLib.h>
18#include <Library/UefiUsbLib.h>
19#include <Protocol/UsbIo.h>
21
22typedef struct {
23 UINTN Signature;
25 EFI_HANDLE UsbCdcDataHandle;
28 UINT8 NumOfInterface;
29 UINT8 BulkInEndpoint;
30 UINT8 BulkOutEndpoint;
31 UINT8 InterruptEndpoint;
32 EFI_MAC_ADDRESS MacAddress;
33 UINT16 BulkOutSequence;
34 UINT8 *BulkBuffer;
35 UINT8 TotalDatagram;
36 UINT8 NowDatagram;
38
39#define USB_NCM_DRIVER_VERSION 1
40#define USB_ETHERNET_BULK_TIMEOUT 1
41#define USB_ETHERNET_TRANSFER_TIMEOUT 200
42#define USB_NCM_MAX_NTB_SIZE 0xFFFF
43#define USB_ETHERNET_FRAME_SIZE 0x5F2 // MAX ethernet frame size
44
45// Defined in USB NCM 1.0 spec., section 3.2 and 3.3
46#define USB_NCM_NTH_SIGN_16 0x484D434E
47#define USB_NCM_NDP_SIGN_16 0x304D434E
48#define USB_NCM_NDP_SIGN_16_CRC 0x314D434E
49#define USB_NCM_NTH_LENGTH 0x000C
50#define USB_NCM_NDP_LENGTH 0x0010// at least 16
51
52// USB NCM Transfer header structure - UINT16
53typedef struct {
54 UINT32 Signature;
55 UINT16 HeaderLength;
56 UINT16 Sequence;
57 UINT16 BlockLength;
58 UINT16 NdpIndex;
60
61// USB NCM Datagram pointer structure - UINT16
62typedef struct {
63 UINT32 Signature;
64 UINT16 Length;
65 UINT16 NextNdpIndex;
67
68// USB NCM Datagram structure
69typedef struct {
70 UINT16 DatagramIndex;
71 UINT16 DatagramLength;
73
74#define USB_ETHERNET_SIGNATURE SIGNATURE_32('u', 'e', 't', 'h')
75#define USB_ETHERNET_DEV_FROM_THIS(a) CR (a, USB_ETHERNET_DRIVER, UsbEth, USB_ETHERNET_SIGNATURE)
76
77typedef struct {
78 UINT16 Src;
79 UINT16 Dst;
80} BIT_MAP;
81
82extern EFI_COMPONENT_NAME2_PROTOCOL gUsbNcmComponentName2;
83
85EFIAPI
88 IN EFI_HANDLE ControllerHandle,
89 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
90 );
91
93EFIAPI
96 IN EFI_HANDLE ControllerHandle,
97 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
98 );
99
101EFIAPI
104 IN EFI_HANDLE ControllerHandle,
105 IN UINTN NumberOfChildren,
106 IN EFI_HANDLE *ChildHandleBuffer
107 );
108
111 IN EFI_USB_IO_PROTOCOL *UsbIo,
112 OUT EFI_USB_CONFIG_DESCRIPTOR **ConfigDesc
113 );
114
115BOOLEAN
118 IN OUT UINTN *Offset
119 );
120
124 IN UINT8 FunDescriptorType,
125 OUT VOID *DataBuffer
126 );
127
128VOID
130 IN EFI_USB_IO_PROTOCOL *UsbIo,
131 IN OUT USB_ETHERNET_DRIVER *UsbEthDriver
132 );
133
135EFIAPI
137 IN PXE_CDB *Cdb,
139 IN OUT VOID *Packet,
140 IN OUT UINTN *PacketLength
141 );
142
144EFIAPI
146 IN PXE_CDB *Cdb,
148 IN VOID *Packet,
149 IN OUT UINTN *PacketLength
150 );
151
153EFIAPI
156 IN BOOLEAN IsNewTransfer,
157 IN UINTN PollingInterval,
159 );
160
162EFIAPI
164 IN VOID *Data,
165 IN UINTN DataLength,
166 IN VOID *Context,
167 IN UINT32 Status
168 );
169
171EFIAPI
174 OUT EFI_MAC_ADDRESS *MacAddress
175 );
176
178EFIAPI
181 OUT UINTN *BulkSize
182 );
183
185EFIAPI
188 OUT USB_HEADER_FUN_DESCRIPTOR *UsbHeaderFunDescriptor
189 );
190
192EFIAPI
195 OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor
196 );
197
199EFIAPI
202 OUT USB_ETHERNET_FUN_DESCRIPTOR *UsbEthFunDescriptor
203 );
204
206EFIAPI
209 IN UINT16 Value,
210 IN VOID *McastAddr
211 );
212
214EFIAPI
217 IN UINT16 Value,
218 IN UINT16 Length,
219 IN VOID *PatternFilter
220 );
221
223EFIAPI
226 IN UINT16 Value,
227 OUT BOOLEAN *PatternActive
228 );
229
231EFIAPI
234 IN UINT16 Value
235 );
236
238EFIAPI
241 IN UINT16 FeatureSelector,
242 OUT VOID *Statistic
243 );
244
245#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
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 UsbNcmDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbCdcNcm.c:293
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 GetFunctionalDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Config, IN UINT8 FunDescriptorType, OUT VOID *DataBuffer)
EFI_STATUS EFIAPI UsbEthNcmTransmit(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN VOID *Packet, IN OUT UINTN *PacketLength)
EFI_STATUS EFIAPI UsbEthNcmReceive(IN PXE_CDB *Cdb, IN EDKII_USB_ETHERNET_PROTOCOL *This, IN OUT VOID *Packet, IN OUT UINTN *PacketLength)
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 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 UsbEthNcmBulkSize(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT UINTN *BulkSize)
EFI_STATUS EFIAPI UsbEthNcmInterrupt(IN EDKII_USB_ETHERNET_PROTOCOL *This, IN BOOLEAN IsNewTransfer, IN UINTN PollingInterval, IN EFI_USB_DEVICE_REQUEST *Request)
EFI_STATUS EFIAPI UsbNcmDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbCdcNcm.c:430
EFI_STATUS EFIAPI GetUsbUnionFunDescriptor(IN EDKII_USB_ETHERNET_PROTOCOL *This, OUT USB_UNION_FUN_DESCRIPTOR *UsbUnionFunDescriptor)
EFI_STATUS EFIAPI UsbNcmDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbCdcNcm.c:67
BOOLEAN NextDescriptor(IN EFI_USB_CONFIG_DESCRIPTOR *Desc, IN OUT UINTN *Offset)