2 Driver for USB Ethernet Control Model devices
3 Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
4 Distributed under the terms of the MIT license.
6 #ifndef _USB_ECM_DEVICE_H_
7 #define _USB_ECM_DEVICE_H_
13 ECMDevice(usb_device device
);
16 status_t
InitCheck() { return fStatus
; };
19 bool IsOpen() { return fOpen
; };
24 status_t
Read(uint8
*buffer
, size_t *numBytes
);
25 status_t
Write(const uint8
*buffer
, size_t *numBytes
);
26 status_t
Control(uint32 op
, void *buffer
, size_t length
);
29 bool IsRemoved() { return fRemoved
; };
31 status_t
CompareAndReattach(usb_device device
);
34 static void _ReadCallback(void *cookie
, int32 status
,
35 void *data
, size_t actualLength
);
36 static void _WriteCallback(void *cookie
, int32 status
,
37 void *data
, size_t actualLength
);
38 static void _NotifyCallback(void *cookie
, int32 status
,
39 void *data
, size_t actualLength
);
41 status_t
_SetupDevice();
42 status_t
_ReadMACAddress(usb_device device
, uint8
*buffer
);
53 // interface and device infos
54 uint8 fControlInterfaceIndex
;
55 uint8 fDataInterfaceIndex
;
56 uint8 fMACAddressIndex
;
57 uint16 fMaxSegmentSize
;
59 // pipes for notifications and data io
60 usb_pipe fNotifyEndpoint
;
61 usb_pipe fReadEndpoint
;
62 usb_pipe fWriteEndpoint
;
64 // data stores for async usb transfers
65 uint32 fActualLengthRead
;
66 uint32 fActualLengthWrite
;
69 sem_id fNotifyReadSem
;
70 sem_id fNotifyWriteSem
;
72 uint8
* fNotifyBuffer
;
73 uint32 fNotifyBufferLength
;
76 sem_id fLinkStateChangeSem
;
79 uint32 fDownstreamSpeed
;
80 uint32 fUpstreamSpeed
;
83 #endif //_USB_ECM_DEVICE_H_