usbdevice_fs.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:6k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*****************************************************************************/
  2. /*
  3.  * usbdevice_fs.h  --  USB device file system.
  4.  *
  5.  * Copyright (C) 2000
  6.  *          Thomas Sailer (sailer@ife.ee.ethz.ch)
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  *  History:
  23.  *   0.1  04.01.2000  Created
  24.  *
  25.  *  $Id: usbdevice_fs.h,v 1.1 2000/01/06 18:40:41 tom Exp $
  26.  */
  27. /*****************************************************************************/
  28. #ifndef _LINUX_USBDEVICE_FS_H
  29. #define _LINUX_USBDEVICE_FS_H
  30. #include <linux/types.h>
  31. /* --------------------------------------------------------------------- */
  32. #define USBDEVICE_SUPER_MAGIC 0x9fa2
  33. /* usbdevfs ioctl codes */
  34. struct usbdevfs_ctrltransfer {
  35. __u8 requesttype;
  36. __u8 request;
  37. __u16 value;
  38. __u16 index;
  39. __u16 length;
  40. __u32 timeout;  /* in milliseconds */
  41.   void *data;
  42. };
  43. struct usbdevfs_bulktransfer {
  44. unsigned int ep;
  45. unsigned int len;
  46. unsigned int timeout; /* in milliseconds */
  47. void *data;
  48. };
  49. struct usbdevfs_setinterface {
  50. unsigned int interface;
  51. unsigned int altsetting;
  52. };
  53. struct usbdevfs_disconnectsignal {
  54. unsigned int signr;
  55. void *context;
  56. };
  57. #define USBDEVFS_MAXDRIVERNAME 255
  58. struct usbdevfs_getdriver {
  59. unsigned int interface;
  60. char driver[USBDEVFS_MAXDRIVERNAME + 1];
  61. };
  62. struct usbdevfs_connectinfo {
  63. unsigned int devnum;
  64. unsigned char slow;
  65. };
  66. #define USBDEVFS_URB_DISABLE_SPD           1
  67. #define USBDEVFS_URB_ISO_ASAP              2
  68. #define USBDEVFS_URB_QUEUE_BULK            0x10
  69. #define USBDEVFS_URB_TYPE_ISO    0
  70. #define USBDEVFS_URB_TYPE_INTERRUPT    1
  71. #define USBDEVFS_URB_TYPE_CONTROL    2
  72. #define USBDEVFS_URB_TYPE_BULK    3
  73. struct usbdevfs_iso_packet_desc {
  74. unsigned int length;
  75. unsigned int actual_length;
  76. unsigned int status;
  77. };
  78. struct usbdevfs_urb {
  79. unsigned char type;
  80. unsigned char endpoint;
  81. int status;
  82. unsigned int flags;
  83. void *buffer;
  84. int buffer_length;
  85. int actual_length;
  86. int start_frame;
  87. int number_of_packets;
  88. int error_count;
  89. unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
  90. void *usercontext;
  91. struct usbdevfs_iso_packet_desc iso_frame_desc[0];
  92. };
  93. /* ioctls for talking to drivers in the usbcore module: */
  94. struct usbdevfs_ioctl {
  95. int ifno; /* interface 0..N ; negative numbers reserved */
  96. int ioctl_code; /* MUST encode size + direction of data so the
  97.  * macros in <asm/ioctl.h> give correct values */
  98. void *data; /* param buffer (in, or out) */
  99. };
  100. /* You can do most things with hubs just through control messages,
  101.  * except find out what device connects to what port. */
  102. struct usbdevfs_hub_portinfo {
  103. char nports; /* number of downstream ports in this hub */
  104. char port [127]; /* e.g. port 3 connects to device 27 */
  105. };
  106. #define USBDEVFS_CONTROL           _IOWR('U', 0, struct usbdevfs_ctrltransfer)
  107. #define USBDEVFS_BULK              _IOWR('U', 2, struct usbdevfs_bulktransfer)
  108. #define USBDEVFS_RESETEP           _IOR('U', 3, unsigned int)
  109. #define USBDEVFS_SETINTERFACE      _IOR('U', 4, struct usbdevfs_setinterface)
  110. #define USBDEVFS_SETCONFIGURATION  _IOR('U', 5, unsigned int)
  111. #define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
  112. #define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
  113. #define USBDEVFS_DISCARDURB        _IO('U', 11)
  114. #define USBDEVFS_REAPURB           _IOW('U', 12, void *)
  115. #define USBDEVFS_REAPURBNDELAY     _IOW('U', 13, void *)
  116. #define USBDEVFS_DISCSIGNAL        _IOR('U', 14, struct usbdevfs_disconnectsignal)
  117. #define USBDEVFS_CLAIMINTERFACE    _IOR('U', 15, unsigned int)
  118. #define USBDEVFS_RELEASEINTERFACE  _IOR('U', 16, unsigned int)
  119. #define USBDEVFS_CONNECTINFO       _IOW('U', 17, struct usbdevfs_connectinfo)
  120. #define USBDEVFS_IOCTL             _IOWR('U', 18, struct usbdevfs_ioctl)
  121. #define USBDEVFS_HUB_PORTINFO      _IOR('U', 19, struct usbdevfs_hub_portinfo)
  122. #define USBDEVFS_RESET             _IO('U', 20)
  123. #define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
  124. /* --------------------------------------------------------------------- */
  125. #ifdef __KERNEL__
  126. #include <linux/list.h>
  127. #include <asm/semaphore.h>
  128. /*
  129.  * inode number macros
  130.  */
  131. #define ITYPE(x)   ((x)&(0xf<<28))
  132. #define ISPECIAL   (0<<28)
  133. #define IBUS       (1<<28)
  134. #define IDEVICE    (2<<28)
  135. #define IBUSNR(x)  (((x)>>8)&0xff)
  136. #define IDEVNR(x)  ((x)&0xff)
  137. #define IROOT      1
  138. struct dev_state {
  139. struct list_head list;      /* state list */
  140. struct rw_semaphore devsem; /* protects modifications to dev (dev == NULL indicating disconnect) */ 
  141. struct usb_device *dev;
  142. struct file *file;
  143. spinlock_t lock;            /* protects the async urb lists */
  144. struct list_head async_pending;
  145. struct list_head async_completed;
  146. wait_queue_head_t wait;     /* wake up if a request completed */
  147. unsigned int discsignr;
  148. struct task_struct *disctask;
  149. void *disccontext;
  150. unsigned long ifclaimed;
  151. };
  152. /* internal methods & data */
  153. extern struct usb_driver usbdevfs_driver;
  154. extern struct file_operations usbdevfs_drivers_fops;
  155. extern struct file_operations usbdevfs_devices_fops;
  156. extern struct file_operations usbdevfs_device_file_operations;
  157. extern struct inode_operations usbdevfs_device_inode_operations;
  158. extern struct inode_operations usbdevfs_bus_inode_operations;
  159. extern struct file_operations usbdevfs_bus_file_operations;
  160. extern void usbdevfs_conn_disc_event(void);
  161. #endif /* __KERNEL__ */
  162. /* --------------------------------------------------------------------- */
  163. #endif /* _LINUX_USBDEVICE_FS_H */