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

VxWorks

开发平台:

C/C++

  1. /* usbHcd.h - General definitions for a USB HCD (Host Controller Driver) */
  2. /* Copyright 2000 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01i,18sep01,wef  merge from wrs.tor2_0.usb1_1-f for veloce
  7. 01h,07may01,wef  changed module number to be (module num << 8) | M_usbHostLib
  8. 01g,02may01,wef  changed module number to be M_<module> + M_usbHostLib
  9. 01f,05dec00,wef  moved Module number defs to vwModNum.h - add this
  10.                  to #includes
  11. 01e,26jan00,rcb  Change "bytesPerFrame" field in HRB_PIPE_CREATE to
  12.  "bandwidth" and redefined as UINT32.
  13. 01d,29nov99,rcb  Remove obsolete function HCD_FNC_BUS_RESET.
  14.  Increase frame number fields to 32-bits.
  15. 01c,23nov99,rcb  Replace bandwidth alloc/release functions with pipe
  16.  create/destroy functions...generalizes approach for use
  17.  with OHCI HCD.
  18. 01b,07sep99,rcb  Add management callback to attach function.
  19. 01a,03jun99,rcb  First.
  20. */
  21. /*
  22. DESCRIPTION
  23. This file defines the interface to a USB HCD (Host Controller Driver). This
  24. interface is generic across HCD implementations.
  25. NOTE: All HCD functions execute synchronously. However, all HCD functions
  26. have been designed to allow for rapid processing.  Delayed results, such as the
  27. completion of an IRP, are reported through callbacks.
  28. NOTE: The USB specification states that a host controller will incorporate the
  29. "root hub".  The caller of the HCD, generally the USBD, communicates with this
  30. root hub using the same IRPs that are used to communicate with other USB 
  31. devices and hubs.  The HCD is responsible for recognizing IRPs addressed to
  32. the root hub and processing them correctly, often by emulating the USB request
  33. behavior of the root hub.
  34. */
  35. #ifndef __INCusbHcdh
  36. #define __INCusbHcdh
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /* includes */
  41. #include "usb/usbHandleLib.h"
  42. #include "usb/usb.h"
  43. #include "vwModNum.h"           /* USB Module Number Def's */
  44. /* defines */
  45. /* HRB function codes */
  46. #define HCD_FNC_ATTACH     0x0000  /* attach/init */
  47. #define HCD_FNC_DETACH     0x0001  /* detach/shutdown */
  48. #define HCD_FNC_SET_BUS_STATE     0x0100  /* set bus suspend/resume state */
  49. #define HCD_FNC_SOF_INTERVAL_GET    0x0101  /* retrieve SOF interval */
  50. #define HCD_FNC_SOF_INTERVAL_SET    0x0102  /* set SOF interval */
  51. #define HCD_FNC_CURRENT_FRAME_GET   0x0200  /* get current frame no */
  52. #define HCD_FNC_IRP_SUBMIT     0x0201  /* submit an IRP for exection */
  53. #define HCD_FNC_IRP_CANCEL     0x0202  /* cancel a pending IRP */
  54. #define HCD_FNC_PIPE_CREATE     0x0300  /* create pipe & reserve bandwidth */
  55. #define HCD_FNC_PIPE_DESTROY     0x0301  /* destroy pipe */
  56. #define HCD_FNC_PIPE_MODIFY     0x0302  /* modify pipe parameters */
  57. /* HRB result codes */
  58. /* 
  59.  * USB errnos are defined as being part of the USB host Module, as are all
  60.  * vxWorks module numbers, but the USB Module number is further divided into 
  61.  * sub-modules.  Each sub-module has upto 255 values for its own error codes
  62.  */
  63.  
  64. #define USB_HCD_SUB_MODULE  4
  65. #define M_usbHcdLib  ( (USB_HCD_SUB_MODULE  << 8) | M_usbHostLib )
  66. #define hcdErr(x) (M_usbHcdLib | (x))
  67. #define S_usbHcdLib_BAD_CLIENT hcdErr(1)
  68. #define S_usbHcdLib_BAD_PARAM hcdErr(2)
  69. #define S_usbHcdLib_BAD_HANDLE hcdErr(3)
  70. #define S_usbHcdLib_OUT_OF_MEMORY hcdErr(4)
  71. #define S_usbHcdLib_OUT_OF_RESOURCES hcdErr(5) 
  72. #define S_usbHcdLib_NOT_IMPLEMENTED hcdErr(6)
  73. #define S_usbHcdLib_GENERAL_FAULT hcdErr(7)
  74. #define S_usbHcdLib_NOT_INITIALIZED hcdErr(8)
  75. #define S_usbHcdLib_INT_HOOK_FAILED hcdErr(9)
  76. #define S_usbHcdLib_STRUCT_SIZE_FAULT hcdErr(10)
  77. #define S_usbHcdLib_HW_NOT_READY hcdErr(11)
  78. #define S_usbHcdLib_NOT_SUPPORTED hcdErr(12)
  79. #define S_usbHcdLib_SHUTDOWN hcdErr(13)
  80. #define S_usbHcdLib_IRP_CANCELED hcdErr(14)
  81. #define S_usbHcdLib_STALLED hcdErr(15)
  82. #define S_usbHcdLib_DATA_BFR_FAULT hcdErr(16)
  83. #define S_usbHcdLib_BABBLE hcdErr(17)
  84. #define S_usbHcdLib_CRC_TIMEOUT  hcdErr(18)
  85. #define S_usbHcdLib_TIMEOUT hcdErr(19)
  86. #define S_usbHcdLib_BITSTUFF_FAULT hcdErr(20)
  87. #define S_usbHcdLib_SHORT_PACKET hcdErr(21)
  88. #define S_usbHcdLib_CANNOT_CANCEL hcdErr(22)
  89. #define S_usbHcdLib_BANDWIDTH_FAULT hcdErr(23)
  90. #define S_usbHcdLib_SOF_INTERVAL_FAULT hcdErr(24)
  91. #define S_usbHcdLib_DATA_TOGGLE_FAULT hcdErr(25)
  92. #define S_usbHcdLib_PID_FAULT hcdErr(26)
  93. #define S_usbHcdLib_ISOCH_FAULT  hcdErr(27)
  94. /* management events */
  95. #define HCD_MNGMT_RESUME 1     /* remote resume */
  96. /* bus states, bit mask */
  97. #define HCD_BUS_SUSPEND  0x0001
  98. #define HCD_BUS_RESUME 0x0002
  99. /* typedefs */
  100. /* HCD_CLIENT_HANDLE */
  101. typedef GENERIC_HANDLE HCD_CLIENT_HANDLE, *pHCD_CLIENT_HANDLE;
  102. /* HCD_PIPE_HANDLE */
  103. typedef GENERIC_HANDLE HCD_PIPE_HANDLE, *pHCD_PIPE_HANDLE;
  104. /*
  105.  * HCD_EXEC_FUNC
  106.  *
  107.  * HCD_EXEC_FUNC is the primary entry point for an HCD.  The caller passes 
  108.  * HRBs (HCD Request Blocks) through this interface for execution by the HCD.
  109.  */
  110. typedef STATUS (*HCD_EXEC_FUNC) (pVOID pHrb);
  111. /* management notification callback function */
  112. typedef VOID (*USB_HCD_MNGMT_CALLBACK)
  113.     (
  114.     pVOID mngmtCallbackParam,     /* caller-defined param */
  115.     HCD_CLIENT_HANDLE handle,     /* handle to host controller */
  116.     UINT16 busNo,     /* bus number */
  117.     UINT16 mngmtCode     /* management code */
  118.     );
  119. /*
  120.  * HRB_HEADER
  121.  *
  122.  * All requests to an HCD begin with an HRB (HCD Request Block) header.
  123.  */
  124. typedef struct hrb_header
  125.     {
  126.     HCD_CLIENT_HANDLE handle; /* I/O caller's HCD client handle */
  127.     UINT16 function; /* IN HCD function code */
  128.     UINT16 hrbLength; /* IN Length of the total HRB */
  129.     } HRB_HEADER, *pHRB_HEADER;
  130. /*
  131.  * HRB_ATTACH
  132.  */
  133. typedef struct hrb_attach
  134.     {
  135.     HRB_HEADER header; /* HRB header */
  136.     pVOID param; /* IN HCD-specific parameter */
  137.     USB_HCD_MNGMT_CALLBACK mngmtCallback;
  138. /* IN USBD's callback for mngmt events */
  139.     pVOID mngmtCallbackParam; /* IN USBD-defined parameter to callback */
  140.     UINT16 busCount; /* OUT number of buses managed by HCD */
  141.     } HRB_ATTACH, *pHRB_ATTACH;
  142. /*
  143.  * HRB_DETACH
  144.  */
  145. typedef struct hrb_detach
  146.     {
  147.     HRB_HEADER header; /* HRB header */
  148.     } HRB_DETACH, *pHRB_DETACH;
  149. /*
  150.  * HRB_BUS_RESET
  151.  */
  152. typedef struct hrb_bus_reset
  153.     {
  154.     HRB_HEADER header; /* HRB header */
  155.     UINT16 busNo; /* IN bus number to reset */
  156.     } HRB_BUS_RESET, *pHRB_BUS_RESET;
  157. /*
  158.  * HRB_SET_BUS_STATE
  159.  */
  160. typedef struct hrb_set_bus_state
  161.     {
  162.     HRB_HEADER header; /* HRB header */
  163.     UINT16 busNo; /* IN bus number */
  164.     UINT16 busState; /* IN new bus state, HCD_BUS_xxxx */
  165.     } HRB_SET_BUS_STATE, *pHRB_SET_BUS_STATE;
  166. /*
  167.  * HRB_CURRENT_FRAME_GET
  168.  */
  169. typedef struct hrb_current_frame_get
  170.     {
  171.     HRB_HEADER header; /* HRB header */
  172.     UINT16 busNo; /* IN bus index: 0, 1, ... */
  173.     UINT32 frameNo; /* OUT current frame number */
  174.     UINT32 frameWindow;  /* OUT frame window size */
  175.     } HRB_CURRENT_FRAME_GET, *pHRB_CURRENT_FRAME_GET;
  176. /*
  177.  * HRB_PIPE_CREATE
  178.  */
  179. typedef struct hrb_pipe_create
  180.     {
  181.     HRB_HEADER header; /* HRB header */
  182.     UINT16 busNo; /* IN bus index: 0, 1, ... */
  183.     UINT16 busAddress; /* IN bus address of USB device */
  184.     UINT16 endpoint; /* IN endpoint on device */
  185.     UINT16 transferType; /* IN transfer type */
  186.     UINT16 direction; /* IN transfer/pipe direction */
  187.     UINT16 speed; /* IN transfer speed */
  188.     UINT16 maxPacketSize; /* IN packet size */
  189.     UINT32 bandwidth; /* IN bandwidth required by pipe */
  190.     UINT16 interval; /* IN service interval */
  191.     UINT32 time; /* OUT calculated transfer time in nanoseconds */
  192.     HCD_PIPE_HANDLE pipeHandle; /* OUT pipe handle */
  193.     } HRB_PIPE_CREATE, *pHRB_PIPE_CREATE;
  194. /*
  195.  * HRB_PIPE_DESTROY
  196.  */
  197. typedef struct hrb_pipe_destroy
  198.     {
  199.     HRB_HEADER header; /* HRB header */
  200.     HCD_PIPE_HANDLE pipeHandle; /* IN pipe to be destroyed */
  201.     } HRB_PIPE_DESTROY, *pHRB_PIPE_DESTROY;
  202. /*
  203.  * HRB_PIPE_MODIFY
  204.  */
  205. typedef struct hrb_pipe_modify
  206.     {
  207.     HRB_HEADER header; /* HRB header */
  208.     HCD_PIPE_HANDLE pipeHandle; /* IN pipe to modify */
  209.     UINT16 busAddress; /* IN new bus address, or 0 if unchanged */
  210.     UINT16 maxPacketSize; /* IN new max packet size, or 0 if unchanged */
  211.     } HRB_PIPE_MODIFY, *pHRB_PIPE_MODIFY;
  212. /* 
  213.  * HRB_IRP_SUBMIT
  214.  */
  215. typedef struct hrb_irp_submit
  216.     {
  217.     HRB_HEADER header; /* HRB header */
  218.     HCD_PIPE_HANDLE pipeHandle; /* IN pipe to which IRP is directed */
  219.     pUSB_IRP pIrp; /* IN ptr to IRP */
  220.     } HRB_IRP_SUBMIT, *pHRB_IRP_SUBMIT;
  221. /*
  222.  * HRB_IRP_CANCEL
  223.  */
  224. typedef struct hrb_irp_cancel
  225.     {
  226.     HRB_HEADER header; /* HRB header */
  227.     pUSB_IRP pIrp; /* IN ptr to IPR to be canceled */
  228.     } HRB_IRP_CANCEL, *pHRB_IRP_CANCEL;
  229. /*
  230.  * HRB_SOF_INTERVAL_GET_SET
  231.  */
  232. typedef struct hrb_sof_interval_get_set
  233.     {
  234.     HRB_HEADER header; /* HRB header */
  235.     UINT16 busNo; /* IN bus index */
  236.     UINT16 sofInterval;  /* I/O SOF interval */
  237.     } HRB_SOF_INTERVAL_GET_SET, *pHRB_SOF_INTERVAL_GET_SET;
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241. #endif /* __INCusbHcdh */
  242. /* End of file. */