⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gfd_usb_hl.c

📁 这时linux下的usb的代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/**************************************************************************************
 *
 *  (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
 *     1.1 	   2005.3.24		 xl			make all the global var in a USBDevice struct
 **************************************************************************************/
#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 "debug.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);  //usb 中断服务程序 
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);
/*-------------------------------------------------------------------*
 *					全局变量定义
 *-------------------------------------------------------------------*/
struct USBDevice MSDevice;//海量存储器类别
struct USBDevice *pMSDevice = &(MSDevice);


/*
 * descriptors,描述符请参看USB1.1协议
 */
 #ifdef READCARD
U32 device_desc[] = {
	0x01100112, /* 描述符长度, 设备描述符, 版本号 (BCD)*/
	0x08000000, /* 设备类,设备子类,设备协议,包的最大长度 */
	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, /* 设备商ID , 厂商ID */
	0x02010100, /* gfd's revision ID,制造商索引. 字符串索引*/
	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  /* 字符串索引, 配置数目. */
};

 U32  conf_desc[] = {
	0x00200209,	/* 描述符长度,配置描述符, 返回的总长度 */ 
	0xc0000101,	/* 接口数目,配置数目,配置索引,字符串索引,属性.: 自供电 */   
  	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, /* 不使用总线供电,描述符长度,接口描述符,接口数目*/
 	0x06080200, /* 可选设置,非0端点,接口类 (Mass Storage),接口子类 (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, /* 接口协议(BOT Protocol),索引值. 字符串描述符长度,端点描述符 */ 
	0x00400282, /* 地址(IN),属性(BULK),包的最大尺寸*/
	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, /* 轮询时间 (ms),端点描述符长度,地址(OUT) */
	0x00004002 /* 属性  (BULK),包的最大尺寸,轮询时间 (ms),	*/
};
 #endif
 
 #ifdef UDISK
U32 device_desc[] = {
	0x01100112, /* 描述符长度, 设备描述符, 版本号 (BCD)*/
	0x08000000,  /* 设备类,设备子类,设备协议,包的最大长度 */
	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, /* 设备商ID , 厂商ID */
	0x02010100, /* gfd's revision ID,制造商索引. 字符串索引*/
	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   /* 字符串索引, 配置数目. */
};
  U32  conf_desc[] = {
	0x00200209,	/* 描述符长度,配置描述符, 返回的总长度 */  
	0x80000101,	/* 接口数目,配置数目,配置索引,字符串索引,属性.: 自供电 */    
  	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, /* 不使用总线供电,描述符长度,接口描述符,接口数目*/
 	0x06080200, /* 可选设置,非0端点,接口类 (Mass Storage),接口子类 (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, /* 接口协议(BOT Protocol),索引值. 字符串描述符长度,端点描述符 */ 
	0x00400282, /* 地址(IN),属性(BULK),包的最大尺寸*/
	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, /* 轮询时间 (ms),端点描述符长度,地址(OUT) */
	0x00004002  /* 属性  (BULK),包的最大尺寸,轮询时间 (ms),	*/
};
 #endif


/* Unicode描述符 */
unsigned char unicode_string[]= { 
	0x04,0x03,
	0x09,0x04 		/*  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,'fraG', 'deli',
	' VED', 'ssaM','otS ', 'egar','01.1'
}; 


/*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

/*64M*/  /*added by xl  on 5.6*/
#ifdef  USBNANDFLASH
U32 URead_capacity[]= {
	0xffff0100,0x00020000
};
#endif

/*128M*/
#if	1//USBMMC
U32 URead_capacity[]= {
	0xffff0300,0x00020000
};
#endif


/*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



/*64M*/
#ifdef USBNANDFLASH
U32	URead_format_capacity[]= {
	0x10000000, 0x00000200,	0x00020002,
	0x00000200,0x00020000,
};
#endif




/*128M*/
#if  1
U32	URead_format_capacity[]= {
	0x10000000, 0x0000040,	0x00020002,
	0x0000040,0x00020000,
};
#endif


U32 URequest_sense[]= {
	0X000600f0,	0X0a000000,	0X00000000,	0X00000028,
	0x00000000
};

unsigned char Ucode_15[]= {
	0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x02, 0x00, 0x1c, 0x0a, 0x80, 0x04,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -