亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usbbulkdevlib.c

?? SL811 USB接口芯片用于VxWorks系統的驅動源代碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* usbBulkDevLib.c - USB Bulk Only Mass Storage class driver */

/* Copyright 2000-2001 Wind River Systems, Inc. */

/*
modification history
--------------------
01g,08aug01,dat  Removing warnings
01f,25jul01,wef  fixed spr #69285
01e,01may01,wef  fixed incorrect declaration of usbBulkDevDestroy
01d,12apr01,wef  added logic to do READ/WRITE 6 or 10 based on configlette
		 parameter - added a paramter to usbBulBlkDevCreate () 
		 for this purpose.  added support for drives with partition 
		 tables.
01c,02sep00,bri  added support for multiple devices.
01b,04aug00,bri  updated as per review.
01a,22may00,bri  written.
*/

/*
DESCRIPTION

This module implements the USB Mass Storage class driver for the vxWorks 
operating system.  This module presents an interface which is a superset 
of the vxWorks Block Device driver model.  This driver implements external 
APIs which would be expected of a standard block device driver. 

This class driver restricts to Mass Storage class devices that follow bulk-only
transport.  For bulk-only devices transport of command, data and status occurs 
solely via bulk endpoints.  The default control pipe is only used to set 
configuration, clear STALL condition on endpoints and to issue class-specific 
requests. 

The class driver is a client of the Universal Serial Bus Driver (USBD).  All
interaction with the USB buses and devices is handled through the USBD.

INITIALIZATION

The class driver must be initialized with usbBulkDevInit().  It is assumed that
USBD is already initialized and attached to atleast one USB Host Controller.  
usbBulkDevInit() registers the class driver as a client module with USBD.  It 
also registers a callback routine to get notified whenever a USB MSC/SCSI/
BULK-ONLY device is attached or removed from the system.  The callback routine
creates a USB_BULK_DEV structure to represent the USB device attached.  It 
also sets device configuration, interface settings and creates pipes for 
BULK_IN and BULK_OUT transfers. 

OTHER FUNCTIONS

usbBulkBlkDevCreate() is the entry point to define a logical block device.
This routine initializes the fields with in the vxWorks block device structure 
BLK_DEV.  This BLK_DEV structure is part of the USB_BULK_DEV structure.  
Memory is allocated for USB_BULK_DEV by the dynamic attach notification 
callback routine.  So, this create routine just initializes the BLK_DEV 
structure and returns a pointer to it, which is used during file system 
initializtion call.

usbBulkDevIoctl() implements functions which are beyond basic file handling. 
Class-specific requests, Descriptor show, are some of the functions.  Function
code parameter identifies the IO operation requested. 

DATA FLOW

For each USB MSC/SCSI/BULK-ONLY device detected, usbBulkPhysDevCreate() will
create pipes to BULK_IN and a BULK_OUT endpoints of the device.  A pipe is a
channel between USBD client i,e usbBulkDevLib and a specific endpoint.  All 
SCSI commands are encapsulated with in a Command Block Wrapper (CBW) and 
transferred across the BULK_OUT endpoint through the out pipe created.  
This is followed by a data transfer phase.  Depending on the SCSI command 
sent to the device, the direction bit in the CBW will indicate whether data 
is transferred to or from the device.  This bit has no significance if no
data transfer is expected.  Data is transferred to the device through BULK_OUT
endpoint and if the device is required to transfer data, it does through
the BULK_IN endpoint.  The device shall send Command Status Wrapper (CSW) via 
BULK_IN endpoint.  This will indicate the success or failure of the CBW.  The
data to be transferred to device will be pointed by the file system launched 
on the device. 


INCLUDE FILES: usbBulkDevLib.h, blkIo.h

SEE ALSO:
.I "USB Mass Storage Class - Bulk Only Transport Specification Version 1.0,"
.I "SCSI-2 Standard specification 10L - Direct Access device commands"

*/

/* includes */

#include "vxWorks.h"
#include "string.h"
#include "errno.h"
#include "errnoLib.h"
#include "ioLib.h"
#include "blkIo.h"
#include "stdio.h"
#include "logLib.h"
#include "dosFsLib.h"

#include "usb/usbPlatform.h"
#include "usb/ossLib.h"	            /* operations system srvcs */
#include "usb/usb.h"	            /* general USB definitions */
#include "usb/usbListLib.h"         /* linked list functions   */
#include "usb/usbdLib.h"            /* USBD interface          */
#include "usb/usbLib.h"	            /* USB utility functions   */

#include "drv/usb/usbBulkDevLib.h"


/* defines */

#define USB_DEBUG_MSG        0x01
#define USB_DEBUG_ERR        0x02

#define USB_BULK_DEBUG                  \
        if (usbBulkDebug & USB_DEBUG_MSG)   \
            logMsg

#define USB_BULK_ERR                    \
        if (usbBulkDebug & USB_DEBUG_ERR)   \
            logMsg

#define USB_BULK_OFFS  1000

/* typedefs */

/* USB_BULK_DEV Structure - used to describe USB MSC/SCSI/BULK-ONLY device */

typedef struct usbBulkDev
    {
    BLK_DEV           blkDev;         /* Vxworks block device structure */
                                      /* Must be the first one          */
    USBD_NODE_ID      bulkDevId;      /* USBD node ID of the device     */	 
    UINT16            configuration;  /* Configuration value        	*/    
    UINT16            interface;      /* Interface number               */
    UINT16            altSetting;     /* Alternate setting of interface */ 
    UINT16            outEpAddress;   /* Bulk out EP address            */   
    UINT16            inEpAddress;    /* Bulk in EP address             */
    USBD_PIPE_HANDLE  outPipeHandle;  /* Pipe handle for Bulk out EP    */
    USBD_PIPE_HANDLE  inPipeHandle;   /* Pipe handle for Bulk in EP     */
    USB_IRP           inIrp;          /* IRP used for bulk-in data      */
    USB_IRP           outIrp;         /* IRP used for bulk-out data     */
    USB_IRP           statusIrp;      /* IRP used for reading status    */ 
    UINT8             maxLun;         /* Max. number of LUN supported   */
    USB_BULK_CBW      bulkCbw;        /* Structure for Command block    */
    USB_BULK_CSW      bulkCsw;        /* Structure for Command status   */
    UINT8 *           bulkInData;     /* Pointer for bulk-in data       */
    UINT8 *           bulkOutData;    /* Pointer for bulk-out data      */   
    UINT32            numBlks;	      /* Number of blocks on device     */	 
    UINT32            blkOffset;      /* Offset of the starting block   */
    UINT16            lockCount;      /* Count of times structure locked*/
    BOOL              connected;      /* TRUE if USB_BULK device connected */    
    LINK              bulkDevLink;    /* Link to other USB_BULK devices    */  
    BOOL              read10Able;     /* Which read/write command the device  */
				      /* supports.  If TRUE, the device uses  */
				      /* READ10/WRITE10, if FALSE uses READ6 / */
				      /* WRITE6 */
    } USB_BULK_DEV, *pUSB_BULK_DEV;    

/* Attach request for user callback */

typedef struct attach_request
    {
    LINK reqLink;                       /* linked list of requests */
    USB_BULK_ATTACH_CALLBACK callback;  /* client callback routine */
    pVOID callbackArg;                  /* client callback argument*/
    } ATTACH_REQUEST, *pATTACH_REQUEST;

/* globals */

BOOL usbBulkDebug =  0;

/* locals */

LOCAL UINT16 initCount = 0;           /* Count for Bulk device initialisation */

LOCAL USBD_CLIENT_HANDLE usbdHandle;  /* Handle for this class driver */

LOCAL LIST_HEAD bulkDevList;          /* linked list of USB_BULK_DEV */

LOCAL LIST_HEAD    reqList;           /* Attach callback request list */

 MUTEX_HANDLE bulkDevMutex;      /* mutex used to protect internal structs */

SEM_HANDLE   bulkIrpSem;        /* Semaphore for IRP Synchronisation */

LOCAL UINT32 usbBulkIrpTimeOut = USB_BULK_IRP_TIME_OUT; /* Time out for IRP */

/* forward declarations */

LOCAL  STATUS usbBulkDescShow (USBD_NODE_ID nodeId);
LOCAL  STATUS usbBulkConfigDescShow  (USBD_NODE_ID nodeId, UINT8 index);
LOCAL  STATUS usbBulkPhysDevCreate (USBD_NODE_ID nodeId, UINT16 config, 
                                    UINT16 interface);
LOCAL  pUSB_BULK_DEV usbBulkDevFind (USBD_NODE_ID nodeId);
LOCAL  STATUS usbBulkDevBlkRd (BLK_DEV *blkDev, int offset, int num, 
			       char * buf);
LOCAL  STATUS usbBulkDevBlkWrt (BLK_DEV *blkDev, int offset, int num, 
				char * buf);
LOCAL  STATUS usbBulkDevStatusChk (BLK_DEV *blkDev);
LOCAL  STATUS usbBulkDevReset (BLK_DEV *blkDev);
LOCAL  void   usbBulkIrpCallback (pVOID p);
LOCAL  STATUS usbBulkFormScsiCmd (pUSB_BULK_DEV pBulkDev, UINT scsiCmd, 
                                  UINT cmdParam1, UINT cmdParam2);
                                   
LOCAL  USB_COMMAND_STATUS usbBulkCmdExecute (pUSB_BULK_DEV pBulkDev);
LOCAL  void   usbBulkDevDestroy (pUSB_BULK_DEV pBulkDev);
LOCAL  STATUS usbBulkDevResetRecovery (pUSB_BULK_DEV  pBulkDev);
LOCAL  VOID notifyAttach (USBD_NODE_ID nodeId, UINT16 attachCode);


/***************************************************************************
*
* usbBulkDevAttachCallback - called when BULK-ONLY/SCSI device is attached/
* removed
*
* This routine is called by USBD when a mass storage device with SCSI command 
* set as interface sub-class and with bulk-only as interface protocol, is 
* attached/detached.
*
* <nodeId> is the USBD_NODE_ID of the node being attached or removed.	
* <attachAction> is USBD_DYNA_ATTACH or USBD_DYNA_REMOVE.
* <configuration> and <interface> indicate the configuration/interface
* that reports itself as a MSC/SCSI/BULK-ONLY device.  
* <deviceClass>, <deviceSubClass>, and <deviceProtocol> will identify a 
* MSC/SCSI/BULK-ONLY device.
*
* NOTE: The USBD will invoke this function once for each configuration/
* interface which reports itself as a MSC/SCSI/BULK-ONLY.  So, it is possible 
* that a single device insertion/removal may trigger multiple callbacks. 
*
*
* RETURNS: N/A
*/

LOCAL VOID usbBulkDevAttachCallback
    (
    USBD_NODE_ID nodeId,         /* USBD Node ID of the device attached */
    UINT16       attachAction,   /* Whether device attached / detached */
    UINT16       configuration,  /* Configur'n value for  MSC/SCSI/BULK-ONLY */
    UINT16       interface,      /* Interface number for  MSC/SCSI/BULK-ONLY */
    UINT16       deviceClass,    /* Interface class   - 0x8  for MSC */
    UINT16       deviceSubClass, /* Device sub-class  - 0x6  for SCSI 
				  * command 
				  */ 
    UINT16       deviceProtocol  /* Interfaceprotocol - 0x50 for Bulk only */ 
    )
    {
    pUSB_BULK_DEV  pBulkDev;     /* Pointer to bulk device,in case of 
				  * removal 
				  */

    OSS_MUTEX_TAKE (bulkDevMutex, OSS_BLOCK);
 
    switch (attachAction)
        { 
        case USBD_DYNA_ATTACH: 

            /* MSC/SCSI/BULK-ONLY Device attached */

            /* Check out whether we already have a structure for this device */

            if (usbBulkDevFind (nodeId) != NULL)
                break;

            USB_BULK_DEBUG ("usbBulkDevAttachCallback : New Bulk-only device "\
                            "attached\n", 0, 0, 0, 0, 0, 0);

            USB_BULK_DEBUG ("usbBulkDevAttachCallback: Configuration = %d, " \
                            "Interface = %d, Node Id = %d \n", configuration,
                            interface, (UINT)nodeId, 0, 0, 0); 

            /* create a USB_BULK_DEV structure for the device attached */
           
            if ( usbBulkPhysDevCreate (nodeId, configuration,interface) != OK )
                {
                USB_BULK_ERR ("usbBulkDevAttachCallback : Error creating Bulk"\
                              "device\n", 0, 0, 0, 0, 0, 0);
                break; 
                } 

            /* Notify registered callers that a USB_BULK_DEV has been added */

	    notifyAttach (nodeId, USB_BULK_ATTACH); 
 
            break;

        case USBD_DYNA_REMOVE:

            /* MSC/SCSI/BULK-ONLY Device detached */

            if ((pBulkDev = usbBulkDevFind (nodeId)) == NULL)
                break;

            /* Check the connected flag  */

            if (pBulkDev->connected == FALSE)
                break;
            
            pBulkDev->connected = FALSE;

	    /* Notify registered callers that the SCSI/BULK-ONLY device has 
             * been removed 
	     *
	     * NOTE: We temporarily increment the device's lock count
	     * to prevent usbBulkDevUnlock() from destroying the
	     * structure while we're still using it.
	     */

            pBulkDev->lockCount++; 

            notifyAttach (pBulkDev->bulkDevId, USB_BULK_REMOVE); 

            pBulkDev->lockCount--; 
           
            if (pBulkDev->lockCount == 0) 
                usbBulkDevDestroy (pBulkDev); 

            USB_BULK_DEBUG ("usbBulkDevAttachCallback : Bulk only Mass \
			     storage device detached\n", 0, 0, 0, 0, 0, 0);

            break;

        default :
            break; 
        }

    OSS_MUTEX_RELEASE (bulkDevMutex);  
    }


/***************************************************************************
*
* usbBulkDevShutDown - shuts down the USB bulk-only class driver.
*
* This routine unregisters the driver from USBD and releases any resources 
* allocated for the devices.
*
* RETURNS: OK or ERROR.
*/

STATUS usbBulkDevShutDown 
    (
    int   errCode                /* Error code - reason for shutdown */
    )
    {

    pUSB_BULK_DEV pBulkDev;      /* Pointer to bulk device */
    pATTACH_REQUEST  pRequest;

    if (initCount == 0)
        return ossStatus (S_usbBulkDevLib_NOT_INITIALIZED);

    /* release any bulk devices */

    while ((pBulkDev = usbListFirst (&bulkDevList)) != NULL)
        usbBulkDevDestroy (pBulkDev); 

    /* Dispose of any outstanding notification requests */

    while ((pRequest = usbListFirst (&reqList)) != NULL)
        {
      	usbListUnlink (&pRequest->reqLink);
        OSS_FREE (pRequest); 
        }

    /* 
     * Unregister with the USBD. USBD will automatically release any pending
     * IRPs or attach requests.
     */

    if (usbdHandle != NULL)
        {
        usbdClientUnregister (usbdHandle);
        usbdHandle = NULL;
        USB_BULK_DEBUG ("usbBulkDevShutDown : Bulk Only class driver "\
                        "unregistered \n", 0, 0, 0, 0, 0, 0);
        }

    /* release resources */

    if (bulkDevMutex != NULL)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜臀av性久久久久蜜臀aⅴ流畅| 欧美精品乱人伦久久久久久| 美女www一区二区| 亚洲一级二级在线| 一区二区三区资源| 亚洲一区二区美女| 午夜精品久久久久久不卡8050| 亚洲高清视频中文字幕| 亚洲精品国产精华液| 一区二区三区日韩精品视频| 一区二区三区高清在线| 中文字幕亚洲电影| 亚洲伦理在线免费看| 亚洲精品亚洲人成人网在线播放| 亚洲免费观看在线视频| 亚洲激情欧美激情| 午夜欧美在线一二页| 日本不卡的三区四区五区| 青椒成人免费视频| 国产乱子伦视频一区二区三区| 狠狠色伊人亚洲综合成人| 成人黄色777网| 色久综合一二码| 777xxx欧美| 久久色在线视频| 一区二区三区资源| 久久成人精品无人区| 国产91丝袜在线播放九色| 在线成人av网站| 精品国产伦一区二区三区免费| 欧美国产在线观看| 亚洲国产成人高清精品| 美日韩一区二区三区| 国产黑丝在线一区二区三区| 99久久伊人网影院| 欧美日韩黄视频| 久久久久久久久久久久久久久99| 亚洲精品亚洲人成人网| 国内外成人在线| 色成年激情久久综合| 久久久亚洲综合| 天天综合天天综合色| 成人理论电影网| 欧美一二三区在线| 亚洲精品成人在线| 国产不卡免费视频| 欧美xxx久久| 性做久久久久久久免费看| 福利一区福利二区| 精品电影一区二区三区| 亚洲在线中文字幕| 国产.欧美.日韩| 精品国产乱码久久久久久夜甘婷婷| 国产精品女上位| 国产精品白丝jk白祙喷水网站 | 春色校园综合激情亚洲| 欧美日韩1区2区| 亚洲欧美国产77777| av在线一区二区三区| 久久精品这里都是精品| 久久国产福利国产秒拍| 91精品久久久久久久99蜜桃| 亚洲国产va精品久久久不卡综合| 99国产一区二区三精品乱码| 亚洲国产高清在线观看视频| 国产乱码一区二区三区| 精品国产乱码久久| 久久精品国产一区二区| 91精品国产91综合久久蜜臀| 午夜日韩在线电影| 欧美日韩欧美一区二区| 亚洲成人黄色影院| 欧美日韩一级二级| 午夜精品久久久久久不卡8050| 欧美性欧美巨大黑白大战| 亚洲视频在线观看三级| 95精品视频在线| 亚洲精品视频在线| 欧美性大战xxxxx久久久| 一区二区三区 在线观看视频| 一本大道综合伊人精品热热| 亚洲国产欧美日韩另类综合| 欧美群妇大交群中文字幕| 午夜一区二区三区在线观看| 欧美一区二区免费视频| 精品无人码麻豆乱码1区2区| 久久精品免费在线观看| 成人免费福利片| 亚洲一线二线三线久久久| 欧美精品第一页| 黑人精品欧美一区二区蜜桃| 中文文精品字幕一区二区| 972aa.com艺术欧美| 亚洲成人777| 精品福利视频一区二区三区| www.99精品| 视频在线观看一区二区三区| 精品国产乱码久久久久久蜜臀| 国产精品系列在线观看| 亚洲一区中文日韩| 2024国产精品视频| 一本一道综合狠狠老| 久久精品av麻豆的观看方式| 国产精品女上位| 在线播放日韩导航| 国产福利一区二区三区在线视频| 自拍偷拍亚洲综合| 日韩你懂的在线观看| 成人激情午夜影院| 午夜在线电影亚洲一区| 中文字幕 久热精品 视频在线| 欧美视频三区在线播放| 国产精品自拍av| 午夜精品一区二区三区免费视频| 久久综合色之久久综合| 在线一区二区三区四区| 国产乱码字幕精品高清av| 亚洲综合一二区| 欧美国产综合色视频| 91精品国产综合久久久久| 色哟哟在线观看一区二区三区| 九色综合国产一区二区三区| 亚洲精品国产第一综合99久久 | 中文字幕不卡在线观看| 欧美色图免费看| 岛国av在线一区| 久久激五月天综合精品| 亚洲国产毛片aaaaa无费看| 欧美激情综合五月色丁香小说| 欧美精品 国产精品| 色狠狠一区二区三区香蕉| eeuss鲁片一区二区三区在线观看| 日本美女视频一区二区| 亚洲影院免费观看| 亚洲视频一区在线| 国产精品狼人久久影院观看方式| 日韩欧美不卡在线观看视频| 337p亚洲精品色噜噜| 欧美性生交片4| 欧美在线看片a免费观看| 99久久夜色精品国产网站| av电影在线不卡| 成人一区在线看| 成人精品小蝌蚪| 国产 日韩 欧美大片| 春色校园综合激情亚洲| 成人a级免费电影| 成人精品视频一区二区三区| 国产成人在线视频网站| 国产91精品在线观看| 国产高清不卡二三区| 福利电影一区二区| 成人综合在线视频| av色综合久久天堂av综合| 色综合中文字幕| 日本韩国一区二区三区| 欧美日韩在线一区二区| 欧美日韩aaaaaa| 欧美sm美女调教| 亚洲国产精品av| 亚洲日本在线视频观看| 亚洲影院在线观看| 日韩和的一区二区| 老司机午夜精品| 经典三级视频一区| voyeur盗摄精品| 欧美精品视频www在线观看| 91麻豆精品国产91久久久使用方法 | 亚洲地区一二三色| 日本在线播放一区二区三区| 国产一区二区三区| a级精品国产片在线观看| 欧美在线一区二区| 日韩精品一区二区三区四区| 国产校园另类小说区| 亚洲精品高清在线观看| 免费观看一级特黄欧美大片| 国产91精品入口| 一本色道久久综合亚洲aⅴ蜜桃| 制服.丝袜.亚洲.中文.综合| 国产欧美一区二区在线观看| 夜色激情一区二区| 国内久久精品视频| 99re在线视频这里只有精品| 在线电影欧美成精品| 国产精品灌醉下药二区| 无码av中文一区二区三区桃花岛| 国产真实乱对白精彩久久| 欧美性淫爽ww久久久久无| 久久综合九色综合97婷婷| 一区二区免费在线播放| 国内精品伊人久久久久av一坑| 一本大道久久a久久综合婷婷| 精品入口麻豆88视频| 亚洲精选一二三| 国产v综合v亚洲欧| 3751色影院一区二区三区| 亚洲免费视频中文字幕| 国产成人av电影免费在线观看| 欧美日韩二区三区|