#ifndef __NUSBH_H__ #define __NUSBH_H__ typedef unsigned long ERRCODE; #define USBCOREH_MAJOR_NUM 3 #define USBCOREH_MINOR_NUM 60 #define USBCOREH_BUILD_NUM 001 // E_USBCOREH_UNDEFINE Error not defined. // E_USBCOREH_NULL_POINTER NULL pointer is passed. // E_USBCOREH_NOT_ENOUGH_MEMORY Not enough memory // E_USBCOREH_IO_ERROR IO error // E_USBCOREH_RESET_TIMEOUT Reset Timeout // E_USBCOREH_INIT_FAIL Initialization fail // E_USBCOREH_NO_DEVICE Device not exist // E_USBCOREH_PARAMETER_ERROR Parameter error // E_USBCOREH_INVALID_CONFIGURATION Invalid configuration selected // E_USBCOREH_INVALID_INTERFACE Invalid interface selected // E_USBCOREH_INPROGRESS Transfer in progress // E_USBCOREH_ENOENT No such file or directory // E_USBCOREH_TIMEDOUT Connection Timeout // E_USBCOREH_PIPE Broken PIPE /* USB constants */ /* * Device and/or Interface Class codes */ #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ #define USB_CLASS_AUDIO 1 #define USB_CLASS_COMM 2 #define USB_CLASS_HID 3 #define USB_CLASS_PHYSICAL 5 #define USB_CLASS_PRINTER 7 #define USB_CLASS_MASS_STORAGE 8 #define USB_CLASS_HUB 9 #define USB_CLASS_DATA 10 #define USB_CLASS_APP_SPEC 0xfe #define USB_CLASS_VENDOR_SPEC 0xff /* * USB types */ #define USB_TYPE_STANDARD (0x00 << 5) #define USB_TYPE_CLASS (0x01 << 5) #define USB_TYPE_VENDOR (0x02 << 5) #define USB_TYPE_RESERVED (0x03 << 5) /* * USB recipients */ #define USB_RECIP_MASK 0x1f #define USB_RECIP_DEVICE 0x00 #define USB_RECIP_INTERFACE 0x01 #define USB_RECIP_ENDPOINT 0x02 #define USB_RECIP_OTHER 0x03 /* * USB directions */ #define USB_DIR_OUT 0 #define USB_DIR_IN 0x80 /* * Descriptor types */ #define USB_DT_DEVICE 0x01 #define USB_DT_CONFIG 0x02 #define USB_DT_STRING 0x03 #define USB_DT_INTERFACE 0x04 #define USB_DT_ENDPOINT 0x05 #define USB_DT_HID (USB_TYPE_CLASS | 0x01) #define USB_DT_REPORT (USB_TYPE_CLASS | 0x02) #define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03) #define USB_DT_HUB (USB_TYPE_CLASS | 0x09) /* * Descriptor sizes per descriptor type */ #define USB_DT_DEVICE_SIZE 18 #define USB_DT_CONFIG_SIZE 9 #define USB_DT_INTERFACE_SIZE 9 #define USB_DT_ENDPOINT_SIZE 7 #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ #define USB_DT_HUB_NONVAR_SIZE 7 #define USB_DT_HID_SIZE 9 /* * Endpoints */ #define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */ #define USB_ENDPOINT_DIR_MASK 0x80 #define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */ #define USB_ENDPOINT_XFER_CONTROL 0 #define USB_ENDPOINT_XFER_ISOC 1 #define USB_ENDPOINT_XFER_BULK 2 #define USB_ENDPOINT_XFER_INT 3 /* * USB Packet IDs (PIDs) */ #define USB_PID_UNDEF_0 0xf0 #define USB_PID_OUT 0xe1 #define USB_PID_ACK 0xd2 #define USB_PID_DATA0 0xc3 #define USB_PID_PING 0xb4 /* USB 2.0 */ #define USB_PID_SOF 0xa5 #define USB_PID_NYET 0x96 /* USB 2.0 */ #define USB_PID_DATA2 0x87 /* USB 2.0 */ #define USB_PID_SPLIT 0x78 /* USB 2.0 */ #define USB_PID_IN 0x69 #define USB_PID_NAK 0x5a #define USB_PID_DATA1 0x4b #define USB_PID_PREAMBLE 0x3c /* Token mode */ #define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */ #define USB_PID_SETUP 0x2d #define USB_PID_STALL 0x1e #define USB_PID_MDATA 0x0f /* USB 2.0 */ /* * Standard requests */ #define USB_REQ_GET_STATUS 0x00 #define USB_REQ_CLEAR_FEATURE 0x01 #define USB_REQ_SET_FEATURE 0x03 #define USB_REQ_SET_ADDRESS 0x05 #define USB_REQ_GET_DESCRIPTOR 0x06 #define USB_REQ_SET_DESCRIPTOR 0x07 #define USB_REQ_GET_CONFIGURATION 0x08 #define USB_REQ_SET_CONFIGURATION 0x09 #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C /* * HID requests */ #define USB_REQ_GET_REPORT 0x01 #define USB_REQ_GET_IDLE 0x02 #define USB_REQ_GET_PROTOCOL 0x03 #define USB_REQ_SET_REPORT 0x09 #define USB_REQ_SET_IDLE 0x0A #define USB_REQ_SET_PROTOCOL 0x0B /* * urb->transfer_flags: */ #define USB_DISABLE_SPD 0x0001 #define URB_SHORT_NOT_OK USB_DISABLE_SPD #define USB_ISO_ASAP 0x0002 #define USB_ASYNC_UNLINK 0x0008 #define USB_QUEUE_BULK 0x0010 #define USB_NO_FSBR 0x0020 #define USB_ZERO_PACKET 0x0040 // Finish bulk OUTs always with zero length packet #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ /* ... less overhead for QUEUE_BULK */ #define USB_TIMEOUT_KILLED 0x1000 // only set by HCD! /* * Device table entry for "new style" table-driven USB drivers. * User mode code can read these tables to choose which modules to load. * Declare the table as __devinitdata, and as a MODULE_DEVICE_TABLE. * * With a device table provide bind() instead of probe(). Then the * third bind() parameter will point to a matching entry from this * table. (Null value reserved.) * * Terminate the driver's table with an all-zeroes entry. * Init the fields you care about; zeroes are not used in comparisons. */ #define USB_DEVICE_ID_MATCH_VENDOR 0x0001 #define USB_DEVICE_ID_MATCH_PRODUCT 0x0002 #define USB_DEVICE_ID_MATCH_DEV_LO 0x0004 #define USB_DEVICE_ID_MATCH_DEV_HI 0x0008 #define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010 #define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020 #define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040 #define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080 #define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200 #define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) #define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI) #define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE) #define USB_DEVICE_ID_MATCH_DEV_INFO \ (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL) #define USB_DEVICE_ID_MATCH_INT_INFO \ (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL) /* Some useful macros */ #define _USBCOREH_USB_DEVICE(vend,prod) \ { USB_DEVICE_ID_MATCH_DEVICE, vend, prod, 0, 0, 0, 0, 0, 0, 0, 0, 0 } #define _USBCOREH_USB_DEVICE_VER(vend,prod,lo,hi) \ { USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, vend, prod, lo, hi, 0, 0, 0, 0, 0, 0, 0 } #define _USBCOREH_USB_DEVICE_INFO(cl,sc,pr) \ { USB_DEVICE_ID_MATCH_DEV_INFO, 0, 0, 0, 0, cl, sc, pr, 0, 0, 0, 0 } #define _USBCOREH_USB_INTERFACE_INFO(cl,sc,pr) \ { USB_DEVICE_ID_MATCH_INT_INFO, 0, 0, 0, 0, 0, 0, 0, cl, sc, pr, 0 } struct usb_devmap { unsigned char devicemap[16]; }; /* * declaring data structures presented before their definition met */ struct usb_device; struct urb; typedef struct list_head { struct list_head *next, *prev; } S_USBCOREH_USB_LIST; typedef struct { unsigned char requesttype; unsigned char request; unsigned short value; unsigned short index; unsigned short length; } __attribute__ ((__packed__)) S_USBCOREH_DEV_REQ; /* Device descriptor */ typedef struct usb_device_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short bcdUSB; unsigned char bDeviceClass; unsigned char bDeviceSubClass; unsigned char bDeviceProtocol; unsigned char bMaxPacketSize0; unsigned short idVendor; unsigned short idProduct; unsigned short bcdDevice; unsigned char iManufacturer; unsigned char iProduct; unsigned char iSerialNumber; unsigned char bNumConfigurations; } __attribute__ ((__packed__)) S_USBCOREH_USB_DEV_DESC; /* Endpoint descriptor */ typedef struct usb_endpoint_descriptor { unsigned char bLength __attribute__ ((__packed__)); unsigned char bDescriptorType __attribute__ ((__packed__)); unsigned char bEndpointAddress __attribute__ ((__packed__)); unsigned char bmAttributes __attribute__ ((__packed__)); unsigned short wMaxPacketSize __attribute__ ((__packed__)); unsigned char bInterval __attribute__ ((__packed__)); unsigned char bRefresh __attribute__ ((__packed__)); unsigned char bSynchAddress __attribute__ ((__packed__)); unsigned char *extra; /* Extra descriptors */ int extralen; } S_USBCOREH_USB_EP_DESC; /* Interface descriptor */ typedef struct usb_interface_descriptor { unsigned char bLength __attribute__ ((__packed__)); unsigned char bDescriptorType __attribute__ ((__packed__)); unsigned char bInterfaceNumber __attribute__ ((__packed__)); unsigned char bAlternateSetting __attribute__ ((__packed__)); unsigned char bNumEndpoints __attribute__ ((__packed__)); unsigned char bInterfaceClass __attribute__ ((__packed__)); unsigned char bInterfaceSubClass __attribute__ ((__packed__)); unsigned char bInterfaceProtocol __attribute__ ((__packed__)); unsigned char iInterface; S_USBCOREH_USB_EP_DESC *endpoint; unsigned char *extra; /* Extra descriptors */ int extralen; } S_USBCOREH_USB_IF_DESC; typedef struct usb_interface { S_USBCOREH_USB_IF_DESC *altsetting; int act_altsetting; /* active alternate setting */ int num_altsetting; /* number of alternate settings */ int max_altsetting; /* total memory allocated */ struct usb_driver *driver; /* driver */ void *private_data; } S_USBCOREH_USB_IF; /* Configuration descriptor information.. */ typedef struct usb_config_descriptor { unsigned char bLength __attribute__ ((__packed__)); unsigned char bDescriptorType __attribute__ ((__packed__)); unsigned short wTotalLength __attribute__ ((__packed__)); unsigned char bNumInterfaces __attribute__ ((__packed__)); unsigned char bConfigurationValue __attribute__ ((__packed__)); unsigned char iConfiguration __attribute__ ((__packed__)); unsigned char bmAttributes __attribute__ ((__packed__)); unsigned char MaxPower __attribute__ ((__packed__)); S_USBCOREH_USB_IF *interface; unsigned char *extra; /* Extra descriptors */ int extralen; } S_USBCOREH_USB_CONFIG_DESC; /* String descriptor */ typedef struct usb_string_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short wData[1]; } __attribute__ ((__packed__)) USB_STR_DESC_T; typedef struct usb_device_id { /* This bitmask is used to determine which of the following fields * are to be used for matching. */ unsigned short match_flags; /* * vendor/product codes are checked, if vendor is nonzero * Range is for device revision (bcdDevice), inclusive; * zero values here mean range isn't considered */ unsigned short idVendor; unsigned short idProduct; unsigned short bcdDevice_lo; unsigned short bcdDevice_hi; /* * if device class != 0, these can be match criteria; * but only if this bDeviceClass value is nonzero */ unsigned char bDeviceClass; unsigned char bDeviceSubClass; unsigned char bDeviceProtocol; /* * if interface class != 0, these can be match criteria; * but only if this bInterfaceClass value is nonzero */ unsigned char bInterfaceClass; unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; /* * for driver's use; not involved in driver matching. */ unsigned long driver_info; } S_USBCOREH_USB_DEV_ID; typedef struct usb_driver { const char *name; void *(*probe)(struct usb_device *dev, unsigned long intf, const S_USBCOREH_USB_DEV_ID *id); void (*disconnect)(struct usb_device *, void *); S_USBCOREH_USB_LIST driver_list; #ifdef NUCLEUS NU_SEMAPHORE serialize; #endif /* ioctl -- userspace apps can talk to drivers through usbdevfs */ int (*ioctl)(struct usb_device *dev, unsigned long code, void *buf); /* * support for "new-style" USB hotplugging * binding policy can be driven from user mode too */ const S_USBCOREH_USB_DEV_ID *id_table; /* suspend before the bus suspends; * disconnect or resume when the bus resumes */ void (*suspend)(struct usb_device *dev); void (*resume)(struct usb_device *dev); } S_USBCOREH_USB_DRIVER; typedef struct { unsigned long offset; unsigned long length; /* expected length */ unsigned long actual_length; unsigned long status; } S_USBCOREH_ISO_PACKET_DESCRIPTOR_T, *PS_USBCOREH_ISO_PACKET_DESCRIPTOR_T; typedef struct urb { void *hcpriv; /* private data for host controller */ S_USBCOREH_USB_LIST urb_list; /* list pointer to all active urbs */ struct urb *next; /* pointer to next URB */ struct usb_device *dev; /* pointer to associated USB device */ unsigned long pipe; /* pipe information */ int status; /* returned status */ unsigned long transfer_flags; /* USB_DISABLE_SPD | USB_ISO_ASAP | etc. */ void *transfer_buffer; /* associated data buffer */ //void *transfer_dma; /* ??? */ int transfer_buffer_length; /* data buffer length */ int actual_length; /* actual data buffer length */ int bandwidth; /* bandwidth for this transfer request (int or ISO) */ unsigned char *setup_packet; /* setup packet (control only) */ //unsigned char *setup_dma; /* ??? */ int start_frame; /* start frame (iso/irq only) */ int number_of_packets; /* number of packets in this request (iso) */ int interval; /* polling interval (irq only) */ int error_count; /* number of errors in this transfer (iso only) */ int timeout; /* timeout (in jiffies) */ void *context; #ifdef NUCLEUS NU_TASK *task; NU_EVENT_GROUP events; #endif void (*complete)(struct urb *); S_USBCOREH_ISO_PACKET_DESCRIPTOR_T iso_frame_desc[32]; } S_USBCOREH_URB, *PS_USBCOREH_URB; typedef struct usb_operations { int (*allocate)(struct usb_device *); int (*deallocate)(struct usb_device *); int (*get_frame_number) (struct usb_device *usb_dev); int (*submit_urb)(PS_USBCOREH_URB purb); int (*unlink_urb)(PS_USBCOREH_URB purb); } S_USBCOREH_USB_OP; /* * Allocated per bus we have */ typedef struct usb_bus { int busnum; /* Bus number (in order of reg) */ struct usb_devmap devmap; /* Device map */ S_USBCOREH_USB_OP *op; /* Operations (specific to the HC) */ struct usb_device *root_hub; /* Root hub */ S_USBCOREH_USB_LIST bus_list; void *hcpriv; /* Host Controller private data */ int bandwidth_allocated; /* on this Host Controller; */ /* applies to Int. and Isoc. pipes; */ /* measured in microseconds/frame; */ /* range is 0..900, where 900 = */ /* 90% of a 1-millisecond frame */ int bandwidth_int_reqs; /* number of Interrupt requesters */ int bandwidth_isoc_reqs; /* number of Isoc. requesters */ } S_USBCOREH_USB_BUS; #define USB_MAXCHILDREN (16) /* This is arbitrary */ typedef struct usb_device { int devnum; /* Device number on USB bus */ int slow; /* Slow device? */ enum { USB_SPEED_UNKNOWN = 0, /* enumerating */ USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */ USB_SPEED_HIGH /* usb 2.0 */ } speed; // struct usb_tt *tt; /* low/full speed dev, highspeed hub */ // int ttport; /* device port on that tt hub */ int refcnt; /* atomic_t, Reference count */ unsigned long toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ unsigned long halted[2]; /* endpoint halts; one bit per endpoint # & direction; */ /* [0] = IN, [1] = OUT */ int epmaxpacketin[16]; /* INput endpoint specific maximums */ int epmaxpacketout[16]; /* OUTput endpoint specific maximums */ struct usb_device *parent; int hub_port; S_USBCOREH_USB_BUS *bus; /* Bus we're part of */ S_USBCOREH_USB_DEV_DESC descriptor; /* Descriptor */ S_USBCOREH_USB_CONFIG_DESC *config; /* All of the configs */ S_USBCOREH_USB_CONFIG_DESC *actconfig; /* the active configuration */ char **rawdescriptors; /* Raw descriptors for each config */ int have_langid; /* whether string_langid is valid yet */ int string_langid; /* language ID for strings */ void *hcpriv; /* Host Controller private data */ /* * Child devices - these can be either new devices * (if this is a hub device), or different instances * of this same device. * * Each instance needs its own set of data structures. */ int maxchild; /* Number of ports if hub */ struct usb_device *children[USB_MAXCHILDREN]; } S_USBCOREH_USB_DEV; /* * Calling this entity a "pipe" is glorifying it. A USB pipe * is something embarrassingly simple: it basically consists * of the following information: * - device number (7 bits) * - endpoint number (4 bits) * - current Data0/1 state (1 bit) * - direction (1 bit) * - speed (1 bit) * - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.] * - pipe type (2 bits: control, interrupt, bulk, isochronous) * * That's 18 bits. Really. Nothing more. And the USB people have * documented these eighteen bits as some kind of glorious * virtual data structure. * * Let's not fall in that trap. We'll just encode it as a simple * unsigned long. The encoding is: * * - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64) [Historical; now gone.] * - direction: bit 7 (0 = Host-to-Device [Out], 1 = Device-to-Host [In]) * - device: bits 8-14 * - endpoint: bits 15-18 * - Data0/1: bit 19 * - speed: bit 26 (0 = Full, 1 = Low Speed) * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk) * * Why? Because it's arbitrary, and whatever encoding we select is really * up to us. This one happens to share a lot of bit positions with the UHCI * specification, so that much of the uhci driver can just mask the bits * appropriately. */ #define PIPE_ISOCHRONOUS 0 #define PIPE_INTERRUPT 1 #define PIPE_CONTROL 2 #define PIPE_BULK 3 #define _USBCOREH_USB_MAXPACKET(dev, pipe, out) (out \ ? (dev)->epmaxpacketout[_USBCOREH_USB_PIPEENDPOINT(pipe)] \ : (dev)->epmaxpacketin [_USBCOREH_USB_PIPEENDPOINT(pipe)] ) #define _USBCOREH_USB_PACKETID(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT) #define _USBCOREH_USB_PIPEOUT(pipe) ((((pipe) >> 7) & 1) ^ 1) #define _USBCOREH_USB_PIPEIN(pipe) (((pipe) >> 7) & 1) #define _USBCOREH_USB_PIPEDEVICE(pipe) (((pipe) >> 8) & 0x7f) #define _USBCOREH_USB_PIPE_ENDPDEV(pipe) (((pipe) >> 8) & 0x7ff) #define _USBCOREH_USB_PIPEENDPOINT(pipe) (((pipe) >> 15) & 0xf) #define _USBCOREH_USB_PIPEDATA(pipe) (((pipe) >> 19) & 1) #define _USBCOREH_USB_PIPESLOW(pipe) (((pipe) >> 26) & 1) #define _USBCOREH_USB_PIPETYPE(pipe) (((pipe) >> 30) & 3) #define _USBCOREH_USB_PIPEISOC(pipe) (_USBCOREH_USB_PIPETYPE((pipe)) == PIPE_ISOCHRONOUS) #define _USBCOREH_USB_PIPEINT(pipe) (_USBCOREH_USB_PIPETYPE((pipe)) == PIPE_INTERRUPT) #define _USBCOREH_USB_PIPECONTROL(pipe) (_USBCOREH_USB_PIPETYPE((pipe)) == PIPE_CONTROL) #define _USBCOREH_USB_PIPEBULK(pipe) (_USBCOREH_USB_PIPETYPE((pipe)) == PIPE_BULK) #define PIPE_DEVEP_MASK 0x0007ff00 /* The D0/D1 toggle bits */ #define _USBCOREH_USB_GETTOGGLE(dev, ep, out) (((dev)->toggle[out] >> ep) & 1) #define _USBCOREH_USB_DOTOGGLE(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep)) #define _USBCOREH_USB_SETTOGGLE(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << ep)) | ((bit) << ep)) /* Endpoint halt control/status */ #define _USBCOREH_USB_ENDPOINT_OUT(ep_dir) (((ep_dir >> 7) & 1) ^ 1) #define _USBCOREH_USB_ENDPOINT_HALT(dev, ep, out) ((dev)->halted[out] |= (1 << (ep))) #define _USBCOREH_USB_ENDPOINT_RUNNING(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep))) #define _USBCOREH_USB_ENDPOINT_HALTED(dev, ep, out) ((dev)->halted[out] & (1 << (ep))) static __inline unsigned long _USBCOREH_CREAT_PIPE(S_USBCOREH_USB_DEV *dev, unsigned long endpoint) { return (dev->devnum << 8) | (endpoint << 15) | (dev->slow << 26); } static __inline unsigned long _USBCOREH_DEFAULT_PIPE(S_USBCOREH_USB_DEV *dev) { return (dev->slow << 26); } //////////////////////////////////////////////////////////// /* USB System */ unsigned long NAPI_USBH_GetVersion(void); ERRCODE NAPI_USBH_Open(void); void NAPI_USBH_Close(void); unsigned long NAPI_USBH_Hub_CheckIrqEvent(void); void NAPI_USBH_OHCI_suspend(void); void NAPI_USBH_OHCI_Resume(void); /* USB Device Driver */ ERRCODE NAPI_USBH_RegisterDriver(S_USBCOREH_USB_DRIVER *); void NAPI_USBH_DeregisterDriver(S_USBCOREH_USB_DRIVER *); /* URB */ S_USBCOREH_URB *NAPI_USBH_AllocateUrb(int iso_packets); void NAPI_USBH_FreeUrb(S_USBCOREH_URB *urb); ERRCODE NAPI_USBH_SubmitUrb(S_USBCOREH_URB *urb); ERRCODE NAPI_USBH_UnlinkUrb(S_USBCOREH_URB *urb); /* Blocking Mode Transfer */ ERRCODE NAPI_USBH_SendControlMessage (S_USBCOREH_USB_DEV *dev, unsigned long pipe, unsigned char request, unsigned char requesttype, unsigned short value, unsigned short index, void *pdata, unsigned short size, int timeout); ERRCODE NAPI_USBH_SendBulkMessage (S_USBCOREH_USB_DEV *usb_dev, unsigned long pipe, void *pdata, int len, int *actual_length, int timeout); /* Standard Device Request Commands */ ERRCODE NAPI_USBH_GetDescriptor(S_USBCOREH_USB_DEV *dev, unsigned char desctype, unsigned char descindex, void *buf, int size); ERRCODE NAPI_USBH_GetClassDescriptor(S_USBCOREH_USB_DEV *dev, int ifnum, unsigned char desctype, unsigned char descindex, void *buf, int size); ERRCODE NAPI_USBH_GetDeviceDescriptor(S_USBCOREH_USB_DEV *dev); ERRCODE NAPI_USBH_GetExtraDescriptor(char *buffer, unsigned long size, unsigned char type, void **ptr); ERRCODE NAPI_USBH_GetStringDescriptor(S_USBCOREH_USB_DEV *dev, unsigned short langid, unsigned char index, void *buf, int size); ERRCODE NAPI_USBH_SetAddress(S_USBCOREH_USB_DEV *dev); ERRCODE NAPI_USBH_SetInterface(S_USBCOREH_USB_DEV *dev, int ifnum, int alternate); ERRCODE NAPI_USBH_GetConfiguration(S_USBCOREH_USB_DEV *dev); ERRCODE NAPI_USBH_SetConfiguration(S_USBCOREH_USB_DEV *dev, int configuration); ERRCODE NAPI_USBH_GetStatus(S_USBCOREH_USB_DEV *dev, int type, int target, void *pdata); /* Miscellaneous */ int NAPI_USBH_GetCurrentFrameNumber(S_USBCOREH_USB_DEV *usb_dev); void NAPI_USBH_DestroyConfiguration(S_USBCOREH_USB_DEV *dev); S_USBCOREH_USB_IF *NAPI_USBH_GetInterfaceData(S_USBCOREH_USB_DEV *dev, int ifnum); S_USBCOREH_USB_EP_DESC *NAPI_USBH_GetEndpointDescriptor(S_USBCOREH_USB_DEV *dev, int epnum); ERRCODE NAPI_USBH_ClearHalt(S_USBCOREH_USB_DEV *dev, int pipe); void NAPI_USBH_SetMaximumPacketSize(S_USBCOREH_USB_DEV *dev); ERRCODE NAPI_USBH_TranslateString(S_USBCOREH_USB_DEV *dev, int index, char *buf, int size); /* USB Device */ void NAPI_USBH_freeDevice(S_USBCOREH_USB_DEV *); void NAPI_USBH_IncreaseDeviceUser(S_USBCOREH_USB_DEV *); #define NAPI_USBH_DecreaseDeviceUser NAPI_USBH_freeDevice /* HID Class Request Commands */ int NAPI_USBH_GetProtocol(S_USBCOREH_USB_DEV *dev, int ifnum); // if success, return data, else return err code ERRCODE NAPI_USBH_SetProtocol(S_USBCOREH_USB_DEV *dev, int ifnum, int protocol); ERRCODE NAPI_USBH_GetReport(S_USBCOREH_USB_DEV *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size); ERRCODE NAPI_USBH_SetReport(S_USBCOREH_USB_DEV *dev, int ifnum, unsigned char type, unsigned char id, void *buf, int size); ERRCODE NAPI_USBH_SetIdle(S_USBCOREH_USB_DEV *dev, int ifnum, int duration, int report_id); /* Bandwidth */ int NAPI_USBH_CheckBandwidth(S_USBCOREH_USB_DEV *dev, S_USBCOREH_URB *urb); // if success, return allocated bandwidth, else return err code void NAPI_USBH_ClaimBandwidth(S_USBCOREH_USB_DEV *dev, S_USBCOREH_URB *urb, int bustime, int isoc); void NAPI_USBH_ReleaseBandwidth(S_USBCOREH_USB_DEV *dev, S_USBCOREH_URB *urb, int isoc); void *NAPI_USBH_malloc(int wanted_size, int boundary); void NAPI_USBH_free(void *); /* #define NON_CACHE_MASK 0x80000000 #ifndef _NUCLUES_ #define NU_Create_Semaphore(a,b,c,d) #define NU_Obtain_Semaphore(x,y) #define NU_Release_Semaphore(x) #define NU_Delete_Semaphore(x) #define NU_Delete_Event_Group(x) #endif */ /*--- CPU clock speed ---*/ //#define HZ (160000) #endif