usbPegasusEnd.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:10k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usbPegasusEnd.h - USB Pegasus End driver header */
  2. /* Copyright 2000-2002 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01g,13dec01,wef  merge from veloce view
  7. 01f,01aug01,wef  fixed the #ifndef, was all lowercase
  8. 01e,07may01,wef  changed module number to be (module num << 8) | M_usbHostLib
  9. 01d,02may01,wef  changed module number to be M_<module> + M_usbHostLib
  10. 01c,30apr01,wef  changed USB_DEV USB_PEGASUS_DEV
  11. 01b,05dec00,wef  moved Module number defs to vwModNum.h - add this
  12.                  to #includes
  13. 01a,02may00,bri  Created
  14. */
  15. #ifndef __INCusbPegasusEndh
  16. #define __INCusbPegasusEndh
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif  /* __cplusplus */
  20. /* includes */
  21. #include "endLib.h"
  22. #include "usb/usbEnet.h"
  23. #include "vwModNum.h"           /* USB Module Number Def's */
  24. /* defines */
  25. /* Error Numbers as set the usbEnetLib  */
  26. /* usbEnetLib error values */
  27. /* 
  28.  * USB errnos are defined as being part of the USB host Module, as are all
  29.  * vxWorks module numbers, but the USB Module number is further divided into 
  30.  * sub-modules.  Each sub-module has upto 255 values for its own error codes
  31.  */
  32.  
  33. #define USB_PEGASUS_SUB_MODULE   14
  34. #define M_usbPegasusLib  ( (USB_PEGASUS_SUB_MODULE << 8) | M_usbHostLib )
  35. #define usbPegasusErr(x) (M_usbPegasusLib | (x))
  36. #define S_usbPegasusLib_NOT_INITIALIZED usbPegasusErr (1)
  37. #define S_usbPegasusLib_BAD_PARAM usbPegasusErr (2)
  38. #define S_usbPegasusLib_OUT_OF_MEMORY usbPegasusErr (3)
  39. #define S_usbPegasusLib_OUT_OF_RESOURCES usbPegasusErr (4)
  40. #define S_usbPegasusLib_GENERAL_FAULT usbPegasusErr (5)
  41. #define S_usbPegasusLib_QUEUE_FULL      usbPegasusErr (6)
  42. #define S_usbPegasusLib_QUEUE_EMPTY usbPegasusErr (7)
  43. #define S_usbPegasusLib_NOT_IMPLEMENTED usbPegasusErr (8)
  44. #define S_usbPegasusLib_USBD_FAULT      usbPegasusErr (9)
  45. #define S_usbPegasusLib_NOT_REGISTERED usbPegasusErr (10)
  46. #define S_usbPegasusLib_NOT_LOCKED      usbPegasusErr (11)
  47. #define SOHOWARE_VENDOR_ID 0x15e8
  48. #define SOHOWARE_PRODUCT_ID 0x9100
  49. #define MICRO_CONNECTOR_VENDOR_ID 0x7b8
  50. #define MICRO_CONNECTOR_PRODUCT_ID 0x4002
  51. /* Packet Filter Bitmap Constants */
  52. #define PACKET_TYPE_MULTICAST 0x10
  53. #define PACKET_TYPE_BROADCAST 0x08
  54. #define PACKET_TYPE_DIRECTED 0x04
  55. #define PACKET_TYPE_ALL_MULTICAST 0x02
  56. #define PACKET_TYPE_PROMISCOUS 0x01
  57. /* Attach codes used by USB_PEGASUS_ATTACH_CALLBACK. */
  58. #define USB_PEGASUS_ATTACH                 0      /* PEGASUS Device attached */
  59. #define USB_PEGASUS_REMOVE                 1      /* PEGASUS Device removed  */
  60. /* Vendor Specific Commands */
  61. #define USB_REQ_PEGASUS_REG_GET 0x00
  62. #define USB_REQ_PEGASUS_SET_REG_SINGLE 0x01
  63. #define USB_REQ_PEGASUS_SET_REG_MULTIPLE 0x02
  64. #define USB_PEGASUS_REG_ENET_CONTL 0x00
  65. #define USB_PEGASUS_REG_MCAST_TABL 0x08
  66. #define USB_PEGASUS_REG_ENET_ADRS 0x10
  67. #define USB_PEGASUS_REG_EEPROM_OFFSET 0x20
  68. #define USB_PEGASUS_REG_EEPROM_DATA 0x21
  69. #define USB_PEGASUS_REG_PHY_ADRS 0x25
  70. #define USB_PEGASUS_REG_PHY_DATA 0x26
  71. #define USB_PEGASUS_REG_PHY_ACC_CNTL 0x28
  72. #define USB_PEGASUS_REG_GPIO_CNTL0 0x7e
  73. #define USB_PEGASUS_REG_GPIO_CNTL1 0x7f
  74. #define USB_PEGASUS_GET_BMREQ 0xc0
  75. #define USB_PEGASUS_GET_BREQ 0xf0
  76. #define USB_PEGASUS_SET_BMREQ 0x40
  77. #define USB_PEGASUS_SET_BREQ 0xf1
  78. #undef ETHER_MAP_IP_MULTICAST
  79. /* Offsets for reading the Ethernet Functional Descriptor */
  80. #define PEGASUS_OFFSET_MACADRS 3
  81. #define PEGASUS_OFFSET_STAT_BMP 9
  82. #define PEGASUS_OFFSET_SEGMENT_SIZE 13
  83. #define PEGASUS_OFFSET_MCAST 15
  84. #define PEGASUS_M_BLK_NUM  512
  85. #define PEGASUS_CL_NUM 256
  86. /* Buffer Sizes */
  87. #define PEGASUS_OUT_BFR_SIZE       1550      /* size of output bfr */
  88. #define PEGASUS_IN_BFR_SIZE        1550 /* size of input bfr */
  89. #define PEGASUS_NO_IN_BFRS         40           /* No of Input Buffers */
  90. #define PEGASUS_NO_OUT_IRPS    5 /* No of IRPs submitted */
  91. #define USB_PEGASUS_ATTACH         0      /* CBI_UFI Device attached */
  92. #define USB_PEGASUS_REMOVE         1      /* CBI_UFI Device removed  */
  93. #define PEGASUS_NAME            "usb"
  94. #define PEGASUS_DESCRIPTION     "usb"
  95. #define PEGASUS_NAME_LEN        sizeof(PEGASUS_NAME)+1
  96. /* typedefs */
  97. /* 
  98.  * usb Device structure 
  99.  * This structure is a priliminary structure and is used in the 
  100.  * call back functions for dynamic attachment.
  101.  * Later when the final end_obj structure is created, this structure
  102.  * will be linked to the end_obj structure.
  103.  */ 
  104. typedef struct usb_pegasus_dev 
  105.     {
  106.     LINK devLink; /* linked list of device structs */    
  107.     USBD_NODE_ID nodeId; /* Node Id of the device */
  108.     UINT16 configuration; /* configuration of the device */
  109.     UINT16 interface; /* interface of the device */
  110.     UINT16 vendorId; /* Pegasus Device Vendor ID */
  111.     UINT16 productId; /* Pegasus Device Product ID */
  112.     UINT16 lockCount;       /* Count of times structure locked*/
  113.     BOOL   connected;
  114.     VOID  * pPegasusDev;
  115.     }USB_PEGASUS_DEV, *pUsbPegasusListDev;
  116. /* 
  117.  * Statistics, to be maintained by the device/driver 
  118.  * As on today all the stats are not supported by the driver.
  119.  */
  120. typedef struct pegasus_stats
  121.     {
  122.     UINT32 bitmap; /* bitmap indicating the supported stats */
  123. /* This bitmap will be in the same way as given */
  124. /* in the Function descriptor of the device. */
  125. /* Corresponding bit will be set if the stat is */
  126. /* supported both by the device and the driver */
  127.     UINT32 xmitOk; /* Frames Transmitted without errors. XMIT_OK */
  128.     UINT32 rvcOk; /* Frames received without errors. RVC_OK */
  129.     UINT32 xmitErr; /* Frames not transmitted or transmitted with errors */
  130.     UINT32 rvcErr; /* Frames recd. with errors that are not delivered */
  131. /* to usb Host */
  132.     UINT32 rvcNoBuf; /* Frames missed, nobuffers */
  133.     UINT32 rvcCrcErr; /* Frames recd. with CRC or FCS error */
  134.     UINT32 rvcOverRun; /* Frames not recd. due to over run */
  135.     }PEGASUS_STATS, *pPegasusStats;
  136. /* 
  137.  * the multicast filter support details. 
  138.  */
  139. typedef struct pegasus_mcast
  140.     {
  141.     UINT8  isMCastPerfect; /* if TRUE, the device supports perfect */
  142. /* multicast address filtering (no hashing) */
  143.     UINT16  noMCastFilters; /* No.of Multicast Address filters Supported */
  144.     }PEGASUS_MCAST_DETAILS, *pPegasusMCastDetails;
  145. /* 
  146.  * Irp buffer structure
  147.  */
  148.  typedef struct pegasus_enet_irp
  149. {
  150. USB_IRP outIrp;     /* IRP to transmit output data */
  151.     BOOL outIrpInUse;     /* TRUE while IRP is outstanding */
  152. } PEGASUS_ENET_IRP; 
  153. /* USB_PEGASUS_ATTACH_CALLBACK defines a callback routine which will be
  154.  * invoked by usbPegasusEnd.c when the attachment or removal of a Pegasus
  155.  * device is detected.  When the callback is invoked with an attach code of
  156.  * USB_PEGASUS_ATTACH, the nodeId represents the ID of newly added device.  
  157.  * When the attach code is USB_PEGASUS_REMOVE, nodeId points to the 
  158.  * PEGASUS device which is no longer attached.
  159.  */
  160. typedef VOID (*USB_PEGASUS_ATTACH_CALLBACK) 
  161.     (
  162.     pVOID arg,           /* caller-defined argument     */
  163.     USB_PEGASUS_DEV * pDev,  /* the device info             */ 
  164.     UINT16 attachCode    /* attach or remove code       */
  165.     );
  166. /* Attach request for user callback */
  167. typedef struct attach_request
  168.     {
  169.     LINK reqLink;                       /* linked list of requests */
  170.     USB_PEGASUS_ATTACH_CALLBACK callback;   /* client callback routine */
  171.     pVOID callbackArg;                  /* client callback argument*/
  172.     } ATTACH_REQUEST, *pATTACH_REQUEST;
  173.      
  174. /* 
  175.  * Usb Ethernet END Device structure.. 
  176.  * This structure is used both by the file usbPegasusEnd.c.
  177.  */
  178. typedef struct pegasus_device
  179.     {
  180.     END_OBJ endObj;     /* must be first field */
  181.     USB_PEGASUS_DEV * pDev;     /* the device info */
  182.     UINT8 unit;
  183.     USBD_NODE_ID nodeId;     /* Node Id of the device */
  184.     UINT8 communicateOk;     /* TRUE after Starting */
  185.     /* and FALSE if stopped */    
  186.     UINT8 macAdrs[6];     /* MAC adress */
  187.     CL_POOL_ID pClPoolId;     /* Pointer to the Cluster Pool */
  188.     BOOL connected;     /* TRUE if device is currently connected */
  189.     USBD_PIPE_HANDLE outPipeHandle; /* USBD pipe handle for bulk OUT pipe */
  190.  
  191.     PEGASUS_ENET_IRP * pEnetIrp;    /* pointer to details of Irp structure*/
  192.     int noOfIrps;     /* no of Irps */
  193.     int  txIrpIndex;     /* What the last submitted IRP is */
  194.     UINT8 * outBfr;     /* pointer to output buffer */
  195.     UINT16 outBfrLen;     /* size of output buffer */
  196.     UINT32 outErrors;     /* count of IRP failures */
  197.     USBD_PIPE_HANDLE inPipeHandle;  /* USBD pipe handle for bulk IN pipe */
  198.     USB_IRP inIrp;     /* IRP to monitor input from printer */
  199.     BOOL inIrpInUse;     /* TRUE while IRP is outstanding */
  200.     UINT8 ** pInBfrArray;      /* pointer to input buffers */
  201.     int noOfInBfrs;      /* no of input buffers*/
  202.     int    rxIndex;                  /* where current buffer is */
  203.     UINT16 inBfrLen;     /* size of input buffer */
  204.     UINT32 inErrors;     /* count of IRP failures */
  205.     PEGASUS_STATS stats;     /* Statistics */
  206.     LINK   pegasusDevLink;       /* Link to other Pegasus devices */  
  207.     PEGASUS_MCAST_DETAILS mCastFilters; /* Multicast address filter details */
  208.     UINT16 maxSegmentSize;     /* Max. Segment supported by the device */
  209.     UINT8 maxPower;     /* Max. Power Consumption of the device */
  210.     /* in 2mA units */
  211.     } PEGASUS_DEVICE, *pPegasusDevCtrl;
  212. LOCAL UINT16 pegasusAdapterList[][2] = {
  213.   { SOHOWARE_VENDOR_ID, SOHOWARE_PRODUCT_ID },
  214. { MICRO_CONNECTOR_VENDOR_ID, 
  215. MICRO_CONNECTOR_PRODUCT_ID},
  216.        };
  217. /* Swap macros */
  218.  
  219. #if (_BYTE_ORDER == _BIG_ENDIAN)
  220.  
  221. #define USB_PEGASUS_SWAP_32(x)  LONGSWAP((UINT)x)
  222. #define USB_PEGASUS_SWAP_16(x)  ((LSB(x) << 8)|MSB(x))
  223. #else   /* _BYTE_ORDER == _BIG_ENDIAN   */
  224.  
  225. #define USB_PEGASUS_SWAP_32
  226. #define USB_PEGASUS_SWAP_16
  227.  
  228. #endif  /* _BYTE_ORDER == _BIG_ENDIAN   */
  229. /* fucntion prototypes */
  230. STATUS usbPegasusDevLock (USBD_NODE_ID nodeId);
  231. STATUS usbPegasusDevUnlock (USBD_NODE_ID nodeId);
  232. STATUS usbPegasusDynamicAttachRegister (USB_PEGASUS_ATTACH_CALLBACK callback, 
  233.      pVOID arg);
  234. STATUS usbPegasusEndInit(void);
  235. #ifdef __cplusplus
  236. }
  237. #endif /* __cplusplus */
  238. #endif /* __INCusbPegasusEndh */