📄 gfd_usb_hl.c
字号:
/**************************************************************************************
*
* (c) 2004 ASIC,all rights reserved
*
*
* This source code and any compilation or derivative thereof
*is proprietary information and is confidential in nature.
* Under no circumstance is this software to be exposed or placed
*under an open source License of any type without expressed
*written permission of ASIC.
*
*filename: gfd_usb_hl.c
*history:
*
* Version Date Author Comments
*------------------------------------------------------------------------------------
* 1.0 2004.9.24 lmq Initial Creation
*
**************************************************************************************/
#include "hardware_reg.h"
#include "gfd_usb_irq.h"
#include "HA_TypeDef.h"
#include "hardware.h"
#include "gfd_usb_protocol.h"
#include "gfd_usb_common.h"
#include "gfd_dmac.h"
#include "pcdisk.h"
#include "itron.h"
#include "fs.h"
/*-------------------------------------------------------------------*
* local function declerations
*-------------------------------------------------------------------*/
static void usb_irq_setup(void);
static U8 *get_irq_request_cmd(void);
static U32 pdc_bus_ctrl_pipe_notificaion(unsigned long notif_type, unsigned char *cmd);
static void pdc_bus_get_descriptor(U8 *command);
ER HA_GFDUSB_INTHANDLE(void); //;when there is usb interrupt,the process starts
static ER OUTINTR(void);
static void pdc_bus_SET_CONFIGURATION(void);
static void bulk_commmand(void);
U32 usb_bulk_cbw(void);
static void bulk_commmand(void);
void usb_bulk_csw(void);
U32 usb_bulk(void);
static U32 transcl(unsigned char *head);
U32 transbulk(unsigned char *head);
void usbswap_data(U32 *src, U16 len);
/*-------------------------------------------------------------------*
* global variable definitions
*-------------------------------------------------------------------*/
U32 *head_temp = NULL;
unsigned char *root;
S32 desc_len = 1;
U32 temblklen;
U32 state1 = 1;
U8 analys[120][31];
U32 tlengh;
U32 urb_num = 0;
U8 command_request[8];
U32 setstat;
U8 RX[64];
U8 *R;
U32 stat_des = 0;
U32 stat_add = 0;
U32 stat_conf = 0;
U32 stat_defa = 0;
U32 stat_out1 = 0;
U32 stat_defa1 =0;
U32 stat_ack = 0;
U32 stat_in = 0;
U32 statep1 = 0;
U32 usbstate = USBDEF;
U32 state_in = 0;
U32 tlengh1;
U32 state3 = 0;
U32 stateep1 = 0;
S32 descactu_len = 0;
S32 requlen = 0;
U32 bulkstat = BULKOUTSTAT;
U32 transstat = TRANSBG;
U32 bulkinepstat = BULKINDO;
U32 usbmod = 0;
U32 longpk = SHORTPK;
U8 *longurb;
U32 statempty = NEMPTY;
U32 setconstate = NSETCONFIG;
U32 blkstate = BLKCMD;
U32 blktrasstate;
U32 epstate;
//U32 bulkindatebuf[1024];
//U32 bulkoutdatebuf[1024];
extern U32 *bulkindatebuf;
extern U32 *bulkoutdatebuf;
U32 unsinglepocket = UNSINGLE;
U32 sing = UNSI;
U32 timen = 0;
U32 timres=0;
U32 longblk = SHORTBLK;
U32 lblkaddr;
U16 blktmp;
U32 usbdmapp = NAPP;
U32 blt=0;
U32 lstate=0;
U32 outtime=0;
U32 usbtime = 0;
/*******************************global matrix for CBW & CSW***/
U8 cbw[31], ufi_cmd[11];
U32 csw[4];
U8 cbw_direct; //means the direction of data transfer:: 0x00=host to the device; 0x80=device to the host
U32 cbw_dtl; //cbw Data Transfer Length
/*
* descriptors
*/
#ifdef READCARD
U32 device_desc[] = {
0x01100112, /* length of this desc, DEVICE descriptor, spec rev level (BCD)*/
0x08000000, /* device class,device subclass,device protocol,max packet size */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x66800ed1, /* device vector ID , device product ID */
0x02010100, /* gfd's revision ID,index of manuf. string,index of prod. string */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000103 /* index of ser. # string, number of configs. */
};
U32 conf_desc[] = {
0x00200209, /* length of this desc,PDC_CONFIG_DESC_TYPE,CONFIGURATION descriptor, total length returned */
0xc0000101, /* number of interfaces,number of this config,index of config. string,attr.: self powered */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00040901, /* we take no bus power,length of this desc,INTERFACE descriptor,interface number*/
0x06080200, /* alternate setting,# of (non 0) endpoints,interface class (Mass Storage),interface subclass (SCSI Transparent) */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x05070050, /* interface protocol (BOT Protocol),index of intf. string,length of this desc,ENDPOINT descriptor */
0x00400282, /* address (IN),attributes (BULK),max packet size*/
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x01050700, /* interval (ms),length of this desc,ENDPOINT descriptor,address (OUT) */
0x00004002 /* attributes (BULK),max packet size,interval (ms), */
};
#endif
#ifdef UDISK
U32 device_desc[] = {
0x01100112, /* length of this desc, DEVICE descriptor, spec rev level (BCD)*/
0x08000000, /* device class,device subclass,device protocol,max packet size */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x9382058f, /* device vector ID , device product ID */
0x02010100, /* gfd's revision ID,index of manuf. string,index of prod. string */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000100 /* index of ser. # string, number of configs. */
};
U32 conf_desc[] = {
0x00200209, /* length of this desc,PDC_CONFIG_DESC_TYPE,CONFIGURATION descriptor, total length returned */
0x80000101, /* number of interfaces,number of this config,index of config. string,attr.: self powered */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00040932, /* we take no bus power,length of this desc,INTERFACE descriptor,interface number*/
0x06080200, /* alternate setting,# of (non 0) endpoints,interface class (Mass Storage),interface subclass (SCSI Transparent) */
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x05070050, /* interface protocol (BOT Protocol),index of intf. string,length of this desc,ENDPOINT descriptor */
0x00400282, /* address (IN),attributes (BULK),max packet size*/
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x00000000, //idle
0x01050700, /* interval (ms),length of this desc,ENDPOINT descriptor,address (OUT) */
0x00004002 /* attributes (BULK),max packet size,interval (ms), */
};
#endif
/* Unicode descriptors for our device description */
unsigned char unicode_string[]= {
0x04,0x03,
0x09,0x04 /* We offer only one language: 0409, US English */
};
unsigned char mfg_string[]= {
26,3, 'P',0, 'h',0, 'ti',0, 'l',0, 'ti',0, 'p',0, 's',0,
'-',0, 'A',0, 'P',0, 'ti',0, 'C',0
};
unsigned char product_string[]=
#if 1
gfd_product_string
#else
{
60,3, '1',0, '3',0, '6',0, '2',0, '-',0, 'O',0, 'T',0, 'G',0, ' ',0,
'M',0, 'A',0, 'S',0, 'S',0, ' ',0,
'S',0, 't',0, 'o',0, 'r',0, 'a',0, 'g',0, 'e',0, ' ',0,
#ifdef CONFIG_gfd_PCI
'P',0, 'C',0, 'ti',0,
#else
'ti',0, 'S',0, 'A',0,
#endif /* CONFIG_gfd_PCI */
' ',0, 'K',0, 'ti',0, 't',0
}
#endif
;
unsigned char serial_string[]= {
0x0A, 0x03, '1', 0x00, '.',0x00, '0', 0x00, '0', 0x00
};
unsigned char empty[] = {0x00};
/*******************************UFI command descriptions*******************/
/*
U32 UInquiry[]= {
0x00008000, 0x0000001f, 0x656e6547, 0x20636972, 0x20425355,
0x52204453, 0x65646165, 0x20202072, 0x30302e32
};
*/
U32 UInquiry[]= {
0x00008000, 0x0000001f,'fraG', 'deli',
' VED', 'ssaM','otS ', 'egar','01.1'
};
/*
unsigned char inquiry_data[INQUIRY_DATA_SIZE] = {
0x00, 0x80, 0x02, 0x00, 0x33, 0x00, 0x00, 0x00,
'P', 'h', 'i', 'l', 'i', 'p', 's', ' ',
'O', 'T', 'G', ' ', 'M', 'a', 's', 's',
' ', 'S', 't', 'o', 'r', 'a', 'g', 'e',
'1', '.', '0', '0'
};*/
/*32M*/
#if 0
U32 URead_capacity[]= {
0xffff0000,0x00020000
};
#endif
/*16M*/
#if 0
U32 URead_capacity[]= {
0xff7f0000,0x00020000
};
#endif
/*4M*/
#if 0
U32 URead_capacity[]= {
0xff1f0000,0x00020000
};
#endif
/*5M*/
#if 0
U32 URead_capacity[]= {
0xff270000,0x00020000
};
#endif
/*128M*/
#if 1
U32 URead_capacity[]= {
0xffff0300,0x00020000
};
#endif
/*
U32 URead_format_capacity[]= {
0x10000000, 0x00d40300, 0x00020002,
0x00d40300, 0x00020000
};
*/
/*32M*/
#if 0
U32 URead_format_capacity[]= {
0x10000000, 0x00001000, 0x00020002,
0x00000100, 0x00020000,
};
#endif
/*16M*/
#if 0
U32 URead_format_capacity[]= {
0x10000000, 0x00800000, 0x00020002,
0x00800000, 0x00020000,
};
#endif
/*4M*/
#if 0
U32 URead_format_capacity[]= {
0x10000000, 0x00200000, 0x00020002,
0x00200000,0x00020000,
};
#endif
/*5M*/
#if 0
U32 URead_format_capacity[]= {
0x10000000, 0x00280000, 0x00020002,
0x00280000,0x00020000,
};
#endif
/*128M*/
#if 1
U32 URead_format_capacity[]= {
0x10000000, 0x0000040, 0x00020002,
0x0000040,0x00020000,
};
#endif
U32 URequest_sense[]= {
0X000600f0, 0X0a000000, 0X00000000, 0X00000028,
0x00000000
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -