core.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef _CORE_H_
00046 #define _CORE_H_
00047
00048 #include <types.h>
00049 #include <hextwelve/lib/list.h>
00050 #include <broadway.h>
00051
00052 inline static void wait_ms(int ms)
00053 {
00054 while(ms--)
00055 udelay(1000);
00056 }
00057
00058 typedef struct usb_device {
00059 u8 address;
00060 u8 fullspeed;
00061 u32 ohci;
00062
00063
00064 u8 bLength;
00065 u8 bDescriptorType;
00066 u16 bcdUSB;
00067 u8 bDeviceClass;
00068 u8 bDeviceSubClass;
00069 u8 bDeviceProtocoll;
00070 u8 bMaxPacketSize0;
00071 u16 idVendor;
00072 u16 idProduct;
00073 u16 bcdDevice;
00074 u8 iManufacturer;
00075 u8 iProduct;
00076 u8 iSerialNumber;
00077 u8 bNumConfigurations;
00078
00079 u8 epSize[16];
00080 u8 epTogl[16];
00081
00082 struct usb_conf *conf;
00083 struct usb_device *next;
00084 } usb_device;
00085
00086 typedef struct usb_conf {
00087 u8 bLength;
00088 u8 bDescriptorType;
00089 u16 wTotalLength;
00090 u8 bNumInterfaces;
00091 u8 bConfigurationValue;
00092 u8 iConfiguration;
00093 u8 bmAttributes;
00094 u8 bMaxPower;
00095
00096 struct usb_conf *next;
00097 struct usb_intf *intf;
00098 } usb_conf;
00099
00100 typedef struct usb_intf {
00101 u8 bLength;
00102 u8 bDescriptorType;
00103 u8 bInterfaceNumber;
00104 u8 bAlternateSetting;
00105 u8 bNumEndpoints;
00106 u8 bInterfaceClass;
00107 u8 bInterfaceSubClass;
00108 u8 bInterfaceProtocol;
00109 u8 iInterface;
00110
00111 struct usb_intf *next;
00112 struct usb_endp *endp;
00113 } usb_intf;
00114
00115 typedef struct usb_endp {
00116 u8 bLength;
00117 u8 bDescriptorType;
00118 u8 bEndpointAddress;
00119 u8 bmAttributes;
00120 u16 wMaxPacketSize;
00121 u8 bInterval;
00122
00123 struct usb_endp *next;
00124 } usb_endp;
00125
00126 typedef struct usb_endpoint {
00127 u8 type;
00128 u8 size;
00129 u8 togl;
00130 struct usb_endpoint *next;
00131 } usb_endpoint;
00132
00133 typedef struct usb_transfer_descriptor_ep {
00134 struct usb_transfer_descriptor_ep *next;
00135 u8 device_address;
00136 u8 endpoint;
00137 struct usb_transfer_descriptor *start;
00138 } usb_transfer_descriptor_ep;
00139
00143 typedef struct usb_driver {
00144 char* name;
00145 void (*probe)(void);
00146 void (*check)(void);
00147 void (*remove)(void);
00148 void *data;
00149 struct usb_driver *next;
00150 } usb_driver;
00151
00152
00157 typedef struct usb_irp {
00158 struct usb_device *dev;
00159
00160 u8 endpoint;
00161 u8 epsize;
00162
00163 u8 type;
00164
00165 u8 *buffer;
00166 u16 len;
00167
00168
00169 u16 timeout;
00170 } usb_irp;
00171
00172
00176 typedef struct usb_transfer_descriptor {
00177 u8 devaddress;
00178 u8 endpoint;
00179 u8 fullspeed;
00180 u8 type;
00181
00182
00183 u8 pid;
00184 u8 iso;
00185 u8 togl;
00186
00187 u8 *buffer;
00188 u16 actlen;
00189
00190 u8 state;
00191 struct usb_transfer_descriptor *next;
00192 u8 maxp;
00193 } usb_transfer_descriptor;
00194
00195 struct usb_core {
00196 u8 nextaddress;
00197 void (*stdout)(char * arg);
00198
00199 struct list *drivers;
00200 struct list *devices;
00201 } core;
00202
00203 void usb_init(u32 reg);
00204 void usb_periodic();
00205 u8 usb_next_address();
00206
00207
00208 struct usb_device *usb_add_device(u8 lowspeed, u32 reg);
00209 u8 usb_remove_device(struct usb_device *dev);
00210 u8 usb_register_driver(struct usb_driver *driver);
00211 void usb_probe_driver();
00212
00213 void lsusb(struct usb_device *dev);
00214
00215 struct usb_irp *usb_get_irp();
00216 u8 usb_remove_irp(struct usb_irp *irp);
00217 u16 usb_submit_irp(struct usb_irp *irp);
00218
00219
00220 struct usb_transfer_descriptor *usb_create_transfer_descriptor(struct usb_irp *irp);
00221
00222
00223 #define USB_IRP_WAITING 1
00224
00225
00226 #define USB_TRANSFER_DESCR_NONE 1
00227 #define USB_TRANSFER_DESCR_SEND 2
00228
00229 #endif //_CORE_H_