📄 usbd_mass.h
字号:
/* * A EEEE SSSS OOO PPPP * A A E S O O P P * AAAAA EEEE SSSS O O PPPP * A A E S O O P * A A EEEE SSSS OOO P * * An Entertainment Solution On a Platform (AESOP) is a completely Open Source * based graphical user environment and suite of applications for PDAs and other * devices running Linux. It is included in various embedded Linux distributions * such as OpenZaurus - http://www.aesop-embedded.org * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Title : usbd_mass.h * Author : * Created date : 2005. 06. 26. 23:11:16 KST * Description : * * $Revision: 1.1.1.1 $ * $Log: usbd_mass.h,v $ * Revision 1.1.1.1 2005/06/27 17:04:30 linuxpark * Initial import. * * * */ #ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/usbd_mass.h,v 1.1.1.1 2005/06/27 17:04:30 linuxpark Exp $"/* * Copyright (c) 2005 * Junyoung Song, kernelproject.org <jun0song@kornet.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */#ifndef __USBD_MASS_H__#define __USBD_MASS_H__/* * 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)#define USB_TYPE_MASK (0x03 << 5)/* * USB recipients */#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#define USBD_DEVICE_REQUESTS(x) (((unsigned int)x <= USB_REQ_SYNCH_FRAME) ? usbd_device_requests[x] : "UNKNOWN")/* * 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/* * USB Spec Release number */#define USB_BCD_VERSION 0x0110/* * Device Requests (c.f Table 9-2) */#define USB_REQ_DIRECTION_MASK 0x80#define USB_REQ_TYPE_MASK 0x60#define USB_REQ_RECIPIENT_MASK 0x1f#define USB_REQ_DEVICE2HOST 0x80#define USB_REQ_HOST2DEVICE 0x00#define USB_REQ_TYPE_STANDARD 0x00#define USB_REQ_TYPE_CLASS 0x20#define USB_REQ_TYPE_VENDOR 0x40#define USB_REQ_RECIPIENT_DEVICE 0x00#define USB_REQ_RECIPIENT_INTERFACE 0x01#define USB_REQ_RECIPIENT_ENDPOINT 0x02#define USB_REQ_RECIPIENT_OTHER 0x03/* * get status bits */#define USB_STATUS_SELFPOWERED 0x01#define USB_STATUS_REMOTEWAKEUP 0x02#define USB_STATUS_HALT 0x01/* * descriptor types */#define USB_DESCRIPTOR_TYPE_DEVICE 0x01#define USB_DESCRIPTOR_TYPE_CONFIGURATION 0x02#define USB_DESCRIPTOR_TYPE_STRING 0x03#define USB_DESCRIPTOR_TYPE_INTERFACE 0x04#define USB_DESCRIPTOR_TYPE_ENDPOINT 0x05#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION 0x07#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 0x08#define USB_DESCRIPTOR_TYPE_HID 0x21#define USB_DESCRIPTOR_TYPE_REPORT 0x22#define USBD_DEVICE_DESCRIPTORS(x) (((unsigned int)x <= USB_DESCRIPTOR_TYPE_INTERFACE_POWER) ? \ usbd_device_descriptors[x] : "UNKNOWN")/* * standard feature selectors */#define USB_ENDPOINT_HALT 0x00#define USB_DEVICE_REMOTE_WAKEUP 0x01#define USB_TEST_MODE 0x02#define OUT 0x00#define IN 0x80#define CONTROL 0x00#define ISOCHRONOUS 0x01#define BULK 0x02#define INTERRUPT 0x03/* configuration modifiers */#define BMATTRIBUTE_RESERVED 0x80#define BMATTRIBUTE_SELF_POWERED 0x40/* USBD_MASS configuration */#define NUM_CONFIGS 1#define NUM_INTERFACES 1#define NUM_ENDPOINTS 2 /* 1 for BULK_IN, 2 for BULK_OUT */#define BULK_IN_ENDPOINT 1#define BULK_OUT_ENDPOINT 2#define EP0_MAX_PACKET_SIZE 8#define CONFIG_USBD_CONFIGURATION_STR "Default"#define CONFIG_USBD_INTERFACE_STR "Mass Storage Bulk only"#define CONFIG_USBD_VENDORID 0x0892#define CONFIG_USBD_PRODUCTID 0x8000#define CONFIG_USBD_MANUFACTURER "KernelProject"#define CONFIG_USBD_PRODUCT_NAME "aESOP2440X1"#define CONFIG_USBD_SERIAL_STR "000000000000"#define CONFIG_USBD_MASS_OUT_ENDPOINT 2#define CONFIG_USBD_MASS_OUT_PKTSIZE 64#define CONFIG_USBD_MASS_IN_ENDPOINT 1#define CONFIG_USBD_MASS_IN_PKTSIZE 64#define SPECIFIED_IN_INTERFACE_DESC 0#define USBDMASS_DEVICE_CLASS SPECIFIED_IN_INTERFACE_DESC#define USBDMASS_DEVICE_SUBCLASS SPECIFIED_IN_INTERFACE_DESC#define USBDMASS_DEVICE_PROTOCOL SPECIFIED_IN_INTERFACE_DESC#define USBDMASS_INTERFACE_CLASS USB_CLASS_MASS_STORAGE#define USBDMASS_INTERFACE_SUBCLASS 6 /* SCSI */#define USBDMASS_INTERFACE_PROTOCOL 0x50 /* Bulk only protocol */#define USBDMASS_BCD_DEVICE 0x0110#define USBDMASS_MAXPOWER 0x0#define USB_REQ_CLASS_RESET 0xff#define USB_REQ_CLASS_GETMAXLUN 0xfe#define STR_MANUFACTURER 1#define STR_PRODUCT 2#define STR_CONFIG 3#define STR_INTERFACE 4#define STR_SERIAL 5/* String descriptor */typedef struct usb_string_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short wData[1];} __attribute__ ((packed)) usb_string_descriptor;/* 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)) usb_device_descriptor;/* Endpoint descriptor */typedef struct usb_endpoint_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bEndpointAddress; unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval;} __attribute__ ((packed)) usb_endpoint_descriptor;/* Interface descriptor */typedef struct usb_interface_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bInterfaceNumber; unsigned char bAlternateSetting; unsigned char bNumEndpoints; unsigned char bInterfaceClass; unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface;} __attribute__ ((packed)) usb_interface_descriptor;/* Configuration descriptor information.. */typedef struct usb_config_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short wTotalLength; unsigned char bNumInterfaces; unsigned char bConfigurationValue; unsigned char iConfiguration; unsigned char bmAttributes; unsigned char bMaxPower;} __attribute__ ((packed)) usb_config_descriptor;/* Configuration descriptor information.. */typedef struct usb_config_descriptor_all { usb_config_descriptor config_descriptor; usb_interface_descriptor interface_descriptor; usb_endpoint_descriptor endpoint_descriptor[NUM_ENDPOINTS];} __attribute__ ((packed)) usb_config_descriptor_all;/* device request (setup) */typedef struct devrequest { unsigned char requesttype; unsigned char request; unsigned short value; unsigned short index; unsigned short length;} __attribute__ ((packed)) devrequest;typedef struct devrequest_b { unsigned char requesttype; unsigned char request; unsigned char value_l; unsigned char value_h; unsigned char index_l; unsigned char index_h; unsigned char length_l; unsigned char length_h;} __attribute__ ((packed)) devrequest_b;/* Function Prototypes */int usbdmass (char *);void usbdmass_isr_reset(void);void usbdmass_init_strings (void);void usbdmass_class_init(void);void usbdmass_isr_ep0(void);void usbdmass_ep0_setup_standard(void);void usbdmass_ep0_setup_get_status(void);void usbdmass_ep0_setup_clear_feature(void);void usbdmass_ep0_setup_set_address(void);void usbdmass_ep0_setup_get_descriptor(void);void usbdmass_ep0_setup_default(void);void usbdmass_ep0_setup_class(void);void usbdmass_ep0_setup_class_reset(void);void usbdmass_ep0_setup_class_getmaxlun(void);void usbdmass_ep0_setup_sendend(unsigned char *, unsigned char, unsigned char);void usbdmass_isr_ep1(void);void usbdmass_isr_ep2(void);int usbdmass_process_cbw(void);void usbdmass_process_cbw_error(void);void usbdmass_process_send_csw(char);int usbdmass_check_control_int(void);void str2wide (char *, u16 *);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -