|
@@ -26,31 +26,32 @@
|
|
|
#define UINT unsigned int
|
|
|
#endif
|
|
|
|
|
|
-/// Device type codes, but these don't need to be extended - a succession is assumed
|
|
|
-/// These are set for usb from the bcdDevice field (suitably mangled). Future devices
|
|
|
-/// will be added in order of device creation to the list, so the names here are just
|
|
|
-/// to help use remember which device is which. The U14ERR_... values follow the same
|
|
|
-/// pattern for modern devices.
|
|
|
-#define TYPEUNKNOWN -1 // dont know
|
|
|
-#define TYPE1401 0 // standard 1401
|
|
|
-#define TYPEPLUS 1 // 1401 plus
|
|
|
-#define TYPEU1401 2 // u1401
|
|
|
-#define TYPEPOWER 3 // Power1401
|
|
|
-#define TYPEU14012 4 // u1401 mkII
|
|
|
-#define TYPEPOWER2 5 // Power1401 mk II
|
|
|
-#define TYPEMICRO3 6 // Micro1401-3
|
|
|
-#define TYPEPOWER3 7 // Power1401-3
|
|
|
-
|
|
|
-/// Some useful defines of constants. DONT FORGET to change the version in the
|
|
|
-/// resources whenever you change it here!.
|
|
|
-#define DRIVERMAJREV 2 // driver revision level major (match windows)
|
|
|
-#define DRIVERMINREV 0 // driver revision level minor
|
|
|
-
|
|
|
-/// Definitions of the various block transfer command codes
|
|
|
-#define TM_EXTTOHOST 8 // extended tohost
|
|
|
-#define TM_EXTTO1401 9 // extended to1401
|
|
|
-
|
|
|
-/// Definitions of values in usbReqtype. Used in sorting out setup actions
|
|
|
+/** Device type codes, but these don't need to be extended - a succession is assumed
|
|
|
+** These are set for usb from the bcdDevice field (suitably mangled). Future devices
|
|
|
+** will be added in order of device creation to the list, so the names here are just
|
|
|
+** to help use remember which device is which. The U14ERR_... values follow the same
|
|
|
+** pattern for modern devices.a
|
|
|
+**/
|
|
|
+#define TYPEUNKNOWN -1 /* dont know */
|
|
|
+#define TYPE1401 0 /* standard 1401 */
|
|
|
+#define TYPEPLUS 1 /* 1401 plus */
|
|
|
+#define TYPEU1401 2 /* u1401 */
|
|
|
+#define TYPEPOWER 3 /* Power1401 */
|
|
|
+#define TYPEU14012 4 /* u1401 mkII */
|
|
|
+#define TYPEPOWER2 5 /* Power1401 mk II */
|
|
|
+#define TYPEMICRO3 6 /* Micro1401-3 */
|
|
|
+#define TYPEPOWER3 7 /* Power1401-3 */
|
|
|
+
|
|
|
+/* Some useful defines of constants. DONT FORGET to change the version in the */
|
|
|
+/* resources whenever you change it here!. */
|
|
|
+#define DRIVERMAJREV 2 /* driver revision level major (match windows) */
|
|
|
+#define DRIVERMINREV 0 /* driver revision level minor */
|
|
|
+
|
|
|
+/* Definitions of the various block transfer command codes */
|
|
|
+#define TM_EXTTOHOST 8 /* extended tohost */
|
|
|
+#define TM_EXTTO1401 9 /* extended to1401 */
|
|
|
+
|
|
|
+/* Definitions of values in usbReqtype. Used in sorting out setup actions */
|
|
|
#define H_TO_D 0x00
|
|
|
#define D_TO_H 0x80
|
|
|
#define VENDOR 0x40
|
|
@@ -58,7 +59,7 @@
|
|
|
#define INTREQ 0x01
|
|
|
#define ENDREQ 0x02
|
|
|
|
|
|
-/// Definition of values in usbRequest, again used to sort out setup
|
|
|
+/* Definition of values in usbRequest, again used to sort out setup */
|
|
|
#define GET_STATUS 0x00
|
|
|
#define CLEAR_FEATURE 0x01
|
|
|
#define SET_FEATURE 0x03
|
|
@@ -71,8 +72,8 @@
|
|
|
#define SET_INTERFACE 0x0b
|
|
|
#define SYNCH_FRAME 0x0c
|
|
|
|
|
|
-/// Definitions of the various debug command codes understood by the 1401. These
|
|
|
-/// are used in various vendor-specific commands to achieve the desired effect
|
|
|
+/* Definitions of the various debug command codes understood by the 1401. These */
|
|
|
+/* are used in various vendor-specific commands to achieve the desired effect */
|
|
|
#define DB_GRAB 0x50 /* Grab is a NOP for USB */
|
|
|
#define DB_FREE 0x51 /* Free is a NOP for the USB */
|
|
|
#define DB_SETADD 0x52 /* Set debug address (double) */
|
|
@@ -91,35 +92,35 @@
|
|
|
#define CR_CHAR 0x0D /* The carriage return character */
|
|
|
#define CR_CHAR_80 0x8d /* and with bit 7 set */
|
|
|
|
|
|
-/// A structure holding information about a block of memory for use in circular transfers
|
|
|
+/* A structure holding information about a block of memory for use in circular transfers */
|
|
|
typedef struct circBlk
|
|
|
{
|
|
|
volatile UINT dwOffset; /* Offset within area of block start */
|
|
|
volatile UINT dwSize; /* Size of the block, in bytes (0 = unused) */
|
|
|
} CIRCBLK;
|
|
|
|
|
|
-/// A structure holding all of the information about a transfer area - an area of
|
|
|
-/// memory set up for use either as a source or destination in DMA transfers.
|
|
|
+/* A structure holding all of the information about a transfer area - an area of */
|
|
|
+/* memory set up for use either as a source or destination in DMA transfers. */
|
|
|
typedef struct transarea
|
|
|
{
|
|
|
- void* lpvBuff; // User address of xfer area saved for completeness
|
|
|
- UINT dwBaseOffset; // offset to start of xfer area in first page
|
|
|
- UINT dwLength; // Length of xfer area, in bytes
|
|
|
- struct page **pPages; // Points at array of locked down pages
|
|
|
- int nPages; // number of pages that are locked down
|
|
|
- bool bUsed; // Is this structure in use?
|
|
|
- bool bCircular; // Is this area for circular transfers?
|
|
|
- bool bCircToHost; // Flag for direction of circular transfer
|
|
|
- bool bEventToHost; // Set event on transfer to host?
|
|
|
- int iWakeUp; // Set 1 on event, cleared by TestEvent()
|
|
|
- UINT dwEventSt; // Defines section within xfer area for...
|
|
|
- UINT dwEventSz; // ...notification by the event SZ is 0 if unset
|
|
|
- CIRCBLK aBlocks[2]; // Info on a pair of circular blocks
|
|
|
- wait_queue_head_t wqEvent; // The wait queue for events in this area MUST BE LAST
|
|
|
+ void* lpvBuff; /* User address of xfer area saved for completeness */
|
|
|
+ UINT dwBaseOffset; /* offset to start of xfer area in first page */
|
|
|
+ UINT dwLength; /* Length of xfer area, in bytes */
|
|
|
+ struct page **pPages; /* Points at array of locked down pages */
|
|
|
+ int nPages; /* number of pages that are locked down */
|
|
|
+ bool bUsed; /* Is this structure in use? */
|
|
|
+ bool bCircular; /* Is this area for circular transfers? */
|
|
|
+ bool bCircToHost; /* Flag for direction of circular transfer */
|
|
|
+ bool bEventToHost; /* Set event on transfer to host? */
|
|
|
+ int iWakeUp; /* Set 1 on event, cleared by TestEvent() */
|
|
|
+ UINT dwEventSt; /* Defines section within xfer area for... */
|
|
|
+ UINT dwEventSz; /* ...notification by the event SZ is 0 if unset */
|
|
|
+ CIRCBLK aBlocks[2]; /* Info on a pair of circular blocks */
|
|
|
+ wait_queue_head_t wqEvent; /* The wait queue for events in this area MUST BE LAST */
|
|
|
} TRANSAREA;
|
|
|
|
|
|
-/// The DMADESC structure is used to hold information on the transfer in progress. It
|
|
|
-/// is set up by ReadDMAInfo, using information sent by the 1401 in an escape sequence.
|
|
|
+/* The DMADESC structure is used to hold information on the transfer in progress. It */
|
|
|
+/* is set up by ReadDMAInfo, using information sent by the 1401 in an escape sequence. */
|
|
|
typedef struct dmadesc
|
|
|
{
|
|
|
unsigned short wTransType; /* transfer type as TM_xxx above */
|
|
@@ -131,10 +132,10 @@ typedef struct dmadesc
|
|
|
|
|
|
#define INBUF_SZ 256 /* input buffer size */
|
|
|
#define OUTBUF_SZ 256 /* output buffer size */
|
|
|
-#define STAGED_SZ 0x10000 // size of coherent buffer for staged transfers
|
|
|
+#define STAGED_SZ 0x10000 /* size of coherent buffer for staged transfers */
|
|
|
|
|
|
-/// Structure to hold all of our device specific stuff. We are making this as similar as we
|
|
|
-/// can to the Windows driver to help in our understanding of what is going on.
|
|
|
+/* Structure to hold all of our device specific stuff. We are making this as similar as we */
|
|
|
+/* can to the Windows driver to help in our understanding of what is going on. */
|
|
|
typedef struct _DEVICE_EXTENSION
|
|
|
{
|
|
|
char inputBuffer[INBUF_SZ]; /* The two buffers */
|
|
@@ -159,58 +160,58 @@ typedef struct _DEVICE_EXTENSION
|
|
|
|
|
|
volatile unsigned int dwDMAFlag; /* state of DMA */
|
|
|
TRANSAREA rTransDef[MAX_TRANSAREAS];/* transfer area info */
|
|
|
- volatile DMADESC rDMAInfo; // info on current DMA transfer
|
|
|
- volatile bool bXFerWaiting; // Flag set if DMA transfer stalled
|
|
|
- volatile bool bInDrawDown; // Flag that we want to halt transfers
|
|
|
-
|
|
|
- // Parameters relating to a block read\write that is in progress. Some of these values
|
|
|
- // are equivalent to values in rDMAInfo. The values here are those in use, while those
|
|
|
- // in rDMAInfo are those received from the 1401 via an escape sequence. If another
|
|
|
- // escape sequence arrives before the previous xfer ends, rDMAInfo values are updated while these
|
|
|
- // are used to finish off the current transfer.
|
|
|
- volatile short StagedId; // The transfer area id for this transfer
|
|
|
- volatile bool StagedRead; // Flag TRUE for read from 1401, FALSE for write
|
|
|
- volatile unsigned int StagedLength; // Total length of this transfer
|
|
|
- volatile unsigned int StagedOffset; // Offset within memory area for transfer start
|
|
|
- volatile unsigned int StagedDone; // Bytes transferred so far
|
|
|
- volatile bool bStagedUrbPending; // Flag to indicate active
|
|
|
- char* pCoherStagedIO; // buffer used for block transfers
|
|
|
- struct urb* pStagedUrb; // The URB to use
|
|
|
- spinlock_t stagedLock; // protects ReadWriteMem() and circular buffer stuff
|
|
|
-
|
|
|
- short s1401Type; // type of 1401 attached
|
|
|
- short sCurrentState; // current error state
|
|
|
- bool bIsUSB2; // type of the interface we connect to
|
|
|
- bool bForceReset; // Flag to make sure we get a real reset
|
|
|
- __u32 statBuf[2]; // buffer for 1401 state info
|
|
|
-
|
|
|
- unsigned long ulSelfTestTime; // used to timeout self test
|
|
|
-
|
|
|
- int nPipes; // Should be 3 or 4 depending on 1401 usb chip
|
|
|
- int bPipeError[4]; // set non-zero if an error on one of the pipe
|
|
|
- __u8 epAddr[4]; // addresses of the 3/4 end points
|
|
|
-
|
|
|
- struct usb_device *udev; // the usb device for this device
|
|
|
- struct usb_interface *interface; // the interface for this device, NULL if removed
|
|
|
- struct usb_anchor submitted; // in case we need to retract our submissions
|
|
|
- struct mutex io_mutex; // synchronize I/O with disconnect, one user-mode caller at a time
|
|
|
-
|
|
|
- int errors; // the last request tanked
|
|
|
- int open_count; // count the number of openers
|
|
|
- spinlock_t err_lock; // lock for errors
|
|
|
+ volatile DMADESC rDMAInfo; /* info on current DMA transfer */
|
|
|
+ volatile bool bXFerWaiting; /* Flag set if DMA transfer stalled */
|
|
|
+ volatile bool bInDrawDown; /* Flag that we want to halt transfers */
|
|
|
+
|
|
|
+ /* Parameters relating to a block read\write that is in progress. Some of these values */
|
|
|
+ /* are equivalent to values in rDMAInfo. The values here are those in use, while those */
|
|
|
+ /* in rDMAInfo are those received from the 1401 via an escape sequence. If another */
|
|
|
+ /* escape sequence arrives before the previous xfer ends, rDMAInfo values are updated while these */
|
|
|
+ /* are used to finish off the current transfer. */
|
|
|
+ volatile short StagedId; /* The transfer area id for this transfer */
|
|
|
+ volatile bool StagedRead; /* Flag TRUE for read from 1401, FALSE for write */
|
|
|
+ volatile unsigned int StagedLength; /* Total length of this transfer */
|
|
|
+ volatile unsigned int StagedOffset; /* Offset within memory area for transfer start */
|
|
|
+ volatile unsigned int StagedDone; /* Bytes transferred so far */
|
|
|
+ volatile bool bStagedUrbPending; /* Flag to indicate active */
|
|
|
+ char* pCoherStagedIO; /* buffer used for block transfers */
|
|
|
+ struct urb* pStagedUrb; /* The URB to use */
|
|
|
+ spinlock_t stagedLock; /* protects ReadWriteMem() and circular buffer stuff */
|
|
|
+
|
|
|
+ short s1401Type; /* type of 1401 attached */
|
|
|
+ short sCurrentState; /* current error state */
|
|
|
+ bool bIsUSB2; /* type of the interface we connect to */
|
|
|
+ bool bForceReset; /* Flag to make sure we get a real reset */
|
|
|
+ __u32 statBuf[2]; /* buffer for 1401 state info */
|
|
|
+
|
|
|
+ unsigned long ulSelfTestTime; /* used to timeout self test */
|
|
|
+
|
|
|
+ int nPipes; /* Should be 3 or 4 depending on 1401 usb chip */
|
|
|
+ int bPipeError[4]; /* set non-zero if an error on one of the pipe */
|
|
|
+ __u8 epAddr[4]; /* addresses of the 3/4 end points */
|
|
|
+
|
|
|
+ struct usb_device *udev; /* the usb device for this device */
|
|
|
+ struct usb_interface *interface; /* the interface for this device, NULL if removed */
|
|
|
+ struct usb_anchor submitted; /* in case we need to retract our submissions */
|
|
|
+ struct mutex io_mutex; /* synchronize I/O with disconnect, one user-mode caller at a time */
|
|
|
+
|
|
|
+ int errors; /* the last request tanked */
|
|
|
+ int open_count; /* count the number of openers */
|
|
|
+ spinlock_t err_lock; /* lock for errors */
|
|
|
struct kref kref;
|
|
|
}DEVICE_EXTENSION, *PDEVICE_EXTENSION;
|
|
|
#define to_DEVICE_EXTENSION(d) container_of(d, DEVICE_EXTENSION, kref)
|
|
|
|
|
|
-/// Definitions of routimes used between compilation object files
|
|
|
-// in usb1401.c
|
|
|
+/* Definitions of routimes used between compilation object files */
|
|
|
+/* in usb1401.c */
|
|
|
extern int Allowi(DEVICE_EXTENSION* pdx);
|
|
|
extern int SendChars(DEVICE_EXTENSION* pdx);
|
|
|
extern void ced_draw_down(DEVICE_EXTENSION *pdx);
|
|
|
extern int ReadWriteMem(DEVICE_EXTENSION *pdx, bool Read, unsigned short wIdent,
|
|
|
unsigned int dwOffs, unsigned int dwLen);
|
|
|
|
|
|
-// in ced_ioc.c
|
|
|
+/* in ced_ioc.c */
|
|
|
extern int ClearArea(DEVICE_EXTENSION *pdx, int nArea);
|
|
|
extern int SendString(DEVICE_EXTENSION* pdx, const char __user* pData, unsigned int n);
|
|
|
extern int SendChar(DEVICE_EXTENSION *pdx, char c);
|