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

VxWorks

开发平台:

C/C++

  1. /* usbdLib.h - USBD functional interface definition */
  2. /* Copyright 2000 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01h,18sep01,wef  merge from wrs.tor2_0.usb1_1-f for veloce
  7. 01g,07may01,wef  changed module number to be (module sub num << 8) | 
  8.  M_usbHostLib
  9. 01f,02may01,wef  changed module number to be M_<module> + M_usbHostLib
  10. 01e,05dec00,wef  moved Module number defs to vwModNum.h - add this
  11.                  to #includes
  12. 01d,26jan00,rcb  Redefine <bandwidth> parameter to usbdPipeCreate() as UINT32.
  13. 01c,29nov99,rcb  Increase frame number fields to 32-bits in 
  14.  usbdCurrentFrameGet().
  15. 01b,07sep99,rcb  Add management callbacks and set-bus-state API.
  16. 01a,07may99,rcb  First.
  17. */
  18. /*
  19. DESCRIPTION
  20. Defines the USBD functional interface. Functions are provided to invoke
  21. each of the underlying USBD URBs (request blocks).
  22. */
  23. #ifndef __INCusbdLibh
  24. #define __INCusbdLibh
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. /* includes */
  29. #include "usb/usbHandleLib.h"     /* handle utility funcs */
  30. #include "usb/usb.h"     /* Basic USB definitions */
  31. #include "drv/usb/usbHcd.h"     /* USB HCD interface definitions */
  32. #include "vwModNum.h"     /* USB Module number def's */ 
  33. /* defines */
  34. /* USBD Results - URB_HEADER.Result */
  35. /* 
  36.  * USB errnos are defined as being part of the USB host Module, as are all
  37.  * vxWorks module numbers, but the USB Module number is further divided into 
  38.  * sub-modules.  Each sub-module has upto 255 values for its own error codes
  39.  */
  40.  
  41. #define USB_USBD_SUB_MODULE  5
  42. #define M_usbdLib  ( (USB_USBD_SUB_MODULE  << 8) | M_usbHostLib )
  43. #define usbdErr(x) (M_usbdLib | (x))
  44. #define S_usbdLib_BAD_CLIENT     usbdErr(1)
  45. #define S_usbdLib_BAD_PARAM     usbdErr(2)
  46. #define S_usbdLib_BAD_HANDLE     usbdErr(3)
  47. #define S_usbdLib_OUT_OF_MEMORY     usbdErr(4)
  48. #define S_usbdLib_OUT_OF_RESOURCES  usbdErr(5)
  49. #define S_usbdLib_NOT_IMPLEMENTED   usbdErr(6)
  50. #define S_usbdLib_GENERAL_FAULT     usbdErr(7)
  51. #define S_usbdLib_NOT_INITIALIZED   usbdErr(8)
  52. #define S_usbdLib_INTERNAL_FAULT    usbdErr(9)
  53. #define S_usbdLib_TIMEOUT     usbdErr(10)
  54. #define S_usbdLib_HCD_FAULT     usbdErr(11)
  55. #define S_usbdLib_IO_FAULT     usbdErr(12)
  56. #define S_usbdLib_NOT_HUB     usbdErr(13)
  57. #define S_usbdLib_CANNOT_CANCEL     usbdErr(14)
  58. #define S_usbdLib_BANDWIDTH_FAULT   usbdErr(15)
  59. #define S_usbdLib_POWER_FAULT     usbdErr(16)
  60. #define S_usbdLib_SOF_MASTER_FAULT  usbdErr(17)
  61. /* String length definitions */
  62. #define USBD_NAME_LEN 32 /* Maximum length for name */
  63. /* management events */
  64. #define USBD_MNGMT_RESUME 1 /* remote wakeup/resume */
  65. /* bus states - see usbdBusStateSet() */
  66. #define USBD_BUS_SUSPEND 0x0001 /* suspend bus */
  67. #define USBD_BUS_RESUME  0x0002 /* resume bus */
  68. /* USBD_NOTIFY_ALL pertains to dynamic attach/removal notification */
  69. #define USBD_NOTIFY_ALL  0xffff
  70. #define USBD_DYNA_ATTACH 0
  71. #define USBD_DYNA_REMOVE 1
  72. /* typedefs */
  73. /* Handles and callbacks. */
  74. typedef GENERIC_HANDLE USBD_CLIENT_HANDLE, *pUSBD_CLIENT_HANDLE;
  75. typedef GENERIC_HANDLE USBD_NODE_ID, *pUSBD_NODE_ID;
  76. typedef GENERIC_HANDLE USBD_PIPE_HANDLE, *pUSBD_PIPE_HANDLE;
  77. typedef VOID (*URB_CALLBACK) (pVOID pUrb);
  78. typedef VOID (*USBD_ATTACH_CALLBACK) 
  79.     (
  80.     USBD_NODE_ID nodeId, 
  81.     UINT16 attachAction, 
  82.     UINT16 configuration,
  83.     UINT16 interface,
  84.     UINT16 deviceClass, 
  85.     UINT16 deviceSubClass, 
  86.     UINT16 deviceProtocol
  87.     );
  88. typedef VOID (*USBD_MNGMT_CALLBACK)
  89.     (
  90.     pVOID callbackParam,
  91.     USBD_NODE_ID nodeId,
  92.     UINT16 mngmtCode
  93.     );
  94. /*
  95.  * USBD_NODE_INFO
  96.  */
  97. typedef struct usbd_node_info
  98.     {
  99.     UINT16 nodeType; /* Type of node */
  100.     UINT16 nodeSpeed; /* Speed of node, e.g., 12MBit, 1.5MBit */
  101.     USBD_NODE_ID parentHubId; /* Node Id of hub to which node is connected */
  102.     UINT16 parentHubPort; /* Port on parent hub to which connected */
  103.     USBD_NODE_ID rootId; /* Node Id of root for USB to which connected */
  104.     } USBD_NODE_INFO, *pUSBD_NODE_INFO;
  105. /*
  106.  * USBD_STATS
  107.  */
  108. typedef struct usbd_stats
  109.     {
  110.     UINT16 totalTransfersIn; /* Total # of inbound transfers */
  111.     UINT16 totalTransfersOut; /* Total # of outbound transfers */
  112.     UINT16 totalReceiveErrors; /* Errors on inbound traffic */
  113.     UINT16 totalTransmitErrors; /* Errors on transmit */
  114.     } USBD_STATS, *pUSBD_STATS;
  115. /* function prototypes */
  116. STATUS usbdInitialize (void);
  117. STATUS usbdShutdown (void);
  118. STATUS usbdClientRegister 
  119.     (
  120.     pCHAR pClientName, /* Client name */
  121.     pUSBD_CLIENT_HANDLE pClientHandle /* Client hdl returned by USBD */
  122.     );
  123. STATUS usbdClientUnregister
  124.     (
  125.     USBD_CLIENT_HANDLE clientHandle /* Client handle */
  126.     );
  127. STATUS usbdMngmtCallbackSet
  128.     (
  129.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  130.     USBD_MNGMT_CALLBACK mngmtCallback, /* management callback */
  131.     pVOID mngmtCallbackParam /* client-defined parameter */
  132.     );
  133. STATUS usbdBusStateSet
  134.     (
  135.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  136.     USBD_NODE_ID nodeId, /* node ID */
  137.     UINT16 busState /* new bus state: USBD_BUS_xxxx */
  138.     );
  139. STATUS usbdBusCountGet
  140.     (
  141.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  142.     pUINT16 pBusCount /* Word bfr to receive bus count */
  143.     );
  144. STATUS usbdRootNodeIdGet
  145.     (
  146.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  147.     UINT16 busIndex, /* Bus index */
  148.     pUSBD_NODE_ID pRootId /* bfr to receive Root Id */
  149.     );
  150. STATUS usbdHubPortCountGet
  151.     (
  152.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  153.     USBD_NODE_ID hubId,  /* Node Id for desired hub */
  154.     pUINT16 pPortCount /* UINT16 bfr to receive port count */
  155.     );
  156. STATUS usbdNodeIdGet
  157.     (
  158.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  159.     USBD_NODE_ID hubId,  /* Node Id for desired hub */
  160.     UINT16 portIndex, /* Port index */
  161.     pUINT16 pNodeType, /* bfr to receive node type */
  162.     pUSBD_NODE_ID pNodeId /* bfr to receive Node Id */
  163.     );
  164. STATUS usbdNodeInfoGet
  165.     (
  166.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  167.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  168.     pUSBD_NODE_INFO pNodeInfo, /* Structure to receive node info */
  169.     UINT16 infoLen /* Len of bfr allocated by client */
  170.     );
  171. STATUS usbdDynamicAttachRegister
  172.     (
  173.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  174.     UINT16 deviceClass,  /* USB class code */
  175.     UINT16 deviceSubClass, /* USB sub-class code */
  176.     UINT16 deviceProtocol, /* USB device protocol */
  177.     USBD_ATTACH_CALLBACK attachCallback /* User-supplied callback routine */
  178.     );
  179. STATUS usbdDynamicAttachUnRegister
  180.     (
  181.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  182.     UINT16 deviceClass,  /* USB class code */
  183.     UINT16 deviceSubClass, /* USB sub-class code */
  184.     UINT16 deviceProtocol, /* USB device protocol */
  185.     USBD_ATTACH_CALLBACK attachCallback /* User-supplied callback routine */
  186.     );
  187. STATUS usbdFeatureClear
  188.     (
  189.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  190.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  191.     UINT16 requestType,  /* Selects request type */
  192.     UINT16 feature, /* Feature selector */
  193.     UINT16 index /* Interface/endpoint index */
  194.     );
  195. STATUS usbdFeatureSet
  196.     (
  197.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  198.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  199.     UINT16 requestType,  /* Selects request type */
  200.     UINT16 feature, /* Feature selector */
  201.     UINT16 index /* Interface/endpoint index */
  202.     );
  203. STATUS usbdConfigurationGet
  204.     (
  205.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  206.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  207.     pUINT16 pConfiguration /* bfr to receive config value */
  208.     );
  209. STATUS usbdConfigurationSet
  210.     (
  211.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  212.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  213.     UINT16 configuration, /* New configuration to be set */
  214.     UINT16 maxPower /* max power this config will draw */
  215.     );
  216. STATUS usbdDescriptorGet
  217.     (
  218.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  219.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  220.     UINT8 requestType, /* specifies type of request */
  221.     UINT8 descriptorType, /* Type of descriptor */
  222.     UINT8 descriptorIndex, /* Index of descriptor */
  223.     UINT16 languageId, /* Language ID */
  224.     UINT16 bfrLen, /* Max length of data to be returned */
  225.     pUINT8 pBfr, /* Pointer to bfr to receive data */
  226.     pUINT16 pActLen /* bfr to receive actual length */
  227.     );
  228. STATUS usbdDescriptorSet
  229.     (
  230.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  231.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  232.     UINT8 requestType, /* selects request type */
  233.     UINT8 descriptorType, /* Type of descriptor */
  234.     UINT8 descriptorIndex, /* Index of descriptor */
  235.     UINT16 languageId, /* Language ID */
  236.     UINT16 bfrLen, /* Max length of data to be returned */
  237.     pUINT8 pBfr  /* Pointer to bfr to receive data */
  238.     );
  239. STATUS usbdInterfaceGet
  240.     (
  241.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  242.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  243.     UINT16 interfaceIndex, /* Index of interface */
  244.     pUINT16 pAlternateSetting /* Current alternate setting */
  245.     );
  246. STATUS usbdInterfaceSet
  247.     (
  248.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  249.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  250.     UINT16 interfaceIndex, /* Index of interface */
  251.     UINT16 alternateSetting /* Alternate setting */
  252.     );
  253. STATUS usbdStatusGet
  254.     (
  255.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  256.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  257.     UINT16 requestType,  /* Selects device/interface/endpoint */
  258.     UINT16 index, /* Interface/endpoint index */
  259.     UINT16 bfrLen, /* length of bfr */
  260.     pUINT8 pBfr, /* bfr to receive status */
  261.     pUINT16 pActLen /* bfr to receive act len xfr'd */
  262.     );
  263. STATUS usbdAddressGet
  264.     (
  265.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  266.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  267.     pUINT16 pDeviceAddress /* Currently assigned device address */
  268.     );
  269. STATUS usbdAddressSet
  270.     (
  271.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  272.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  273.     UINT16 deviceAddress /* New device address */
  274.     );
  275. STATUS usbdVendorSpecific
  276.     (
  277.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  278.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  279.     UINT8 requestType, /* bmRequestType in USB spec. */
  280.     UINT8 request, /* bRequest in USB spec. */
  281.     UINT16 value, /* wValue in USB spec. */
  282.     UINT16 index, /* wIndex in USB spec. */
  283.     UINT16 length, /* wLength in USB spec. */
  284.     pUINT8 pBfr, /* ptr to data buffer */
  285.     pUINT16 pActLen /* actual length of IN */
  286.     );
  287. STATUS usbdPipeCreate
  288.     (
  289.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  290.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  291.     UINT16 endpoint, /* Endpoint number */
  292.     UINT16 configuration, /* config w/which pipe associated */
  293.     UINT16 interface, /* interface w/which pipe associated */
  294.     UINT16 transferType, /* Type of transfer: control, bulk... */
  295.     UINT16 direction, /* Specifies IN or OUT endpoint */
  296.     UINT16 maxPayload, /* Maximum data payload per packet */
  297.     UINT32 bandwidth, /* Bandwidth required for pipe */
  298.     UINT16 serviceInterval, /* Required service interval */
  299.     pUSBD_PIPE_HANDLE pPipeHandle /* pipe handle returned by USBD */
  300.     );
  301. STATUS usbdPipeDestroy
  302.     (
  303.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  304.     USBD_PIPE_HANDLE pipeHandle  /* pipe handle */
  305.     );
  306. STATUS usbdTransfer
  307.     (
  308.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  309.     USBD_PIPE_HANDLE pipeHandle, /* Pipe handle */
  310.     pUSB_IRP pIrp /* ptr to I/O request packet */
  311.     );
  312. STATUS usbdTransferAbort
  313.     (
  314.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  315.     USBD_PIPE_HANDLE pipeHandle,     /* Pipe handle */
  316.     pUSB_IRP pIrp /* ptr to I/O to abort */
  317.     );
  318. STATUS usbdSynchFrameGet
  319.     (
  320.     USBD_CLIENT_HANDLE clientHandle, /* Client Handle */
  321.     USBD_NODE_ID nodeId, /* Node Id of device/hub */
  322.     UINT16 endpoint, /* Endpoint to be queried */
  323.     pUINT16 pFrameNo /* Frame number returned by device */
  324.     );
  325. STATUS usbdCurrentFrameGet
  326.     (
  327.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  328.     USBD_NODE_ID nodeId, /* Node Id of root for desired USB */
  329.     pUINT32 pFrameNo, /* bfr to receive current frame no. */
  330.     pUINT32 pFrameWindow /* bfr to receive frame window */
  331.     );
  332. STATUS usbdSofMasterTake
  333.     (
  334.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  335.     USBD_NODE_ID nodeId  /* Node Id of node on desired USB */
  336.     );
  337.     
  338. STATUS usbdSofMasterRelease
  339.     (
  340.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  341.     USBD_NODE_ID nodeId  /* Node Id of node on desired USB */
  342.     );
  343. STATUS usbdSofIntervalGet
  344.     (
  345.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  346.     USBD_NODE_ID nodeId, /* Node Id of node on desired USB */
  347.     pUINT16 pSofInterval /* bfr to receive SOF interval */
  348.     );
  349. STATUS usbdSofIntervalSet
  350.     (
  351.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  352.     USBD_NODE_ID nodeId, /* Node Id of node on desired USB */
  353.     UINT16 sofInterval /* new SOF interval */
  354.     );
  355. STATUS usbdVersionGet
  356.     (
  357.     pUINT16 pVersion, /* UINT16 bfr to receive version */
  358.     pCHAR pMfg /* bfr to receive USBD mfg string */
  359.     );
  360. STATUS usbdHcdAttach
  361.     (
  362.     HCD_EXEC_FUNC hcdExecFunc, /* Ptr to HCD抯 primary entry point */
  363.     pVOID param, /* HCD-specific parameter */
  364.     pGENERIC_HANDLE pAttachToken /* Token to identify HCD in future */
  365.     );
  366. STATUS usbdHcdDetach
  367.     (
  368.     GENERIC_HANDLE attachToken /* AttachToken returned */
  369.     );
  370. STATUS usbdStatisticsGet
  371.     (
  372.     USBD_CLIENT_HANDLE clientHandle, /* Client handle */
  373.     USBD_NODE_ID nodeId, /* Node Id of a node on desired USB */
  374.     pUSBD_STATS pStatistics, /* Ptr to structure to receive stats */
  375.     UINT16 statLen /* Len of bfr provided by caller */
  376.     );
  377. #ifdef __cplusplus
  378. }
  379. #endif
  380. #endif /* __INCusbdLibh */
  381. /* End of file. */