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

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

?? usr_blk_dev.c

?? 包含MMC協議,驅動源碼. 在LINUX操作系統下通過.
?? C
?? 第 1 頁 / 共 5 頁
字號:
/* * Copyright 2005 Motorola, Inc. All Rights Reserved. * * 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 * *//*! * @file usr_blk_dev.c * * @ingroup usr_blk_dev * * @brief This is the main file for the user block driver. * * <B>Overview:</B><BR> *    The user block driver is a removable media block driver intended to allow * for user space drivers for the media. * *    This driver operates by creating an entry on /proc and using the entry * to communicate commands to user space.  See ::USR_BLK_DEV_CMD_ID_T for a list * of these commands.  Commands are sent from a kernel thread through /proc * to user space.  Once the user space process has completed the command it * responds with a write to the proc entry.  Only one command can be processed * at a time by a user space process and a kernel thread.  A thread is used * for the commands in order to keep the request queue from blocking which is * not allowed. * *    At this time a single thread is used for all devices attached.  This * is not intended to be the final design, but was done to speed up development. * This will be acceptable for systems which implement only one device.  If * more than one device is to be supported, then multiple threads should be * used, one per /proc entry.  This will speed up throughput, since one part * will not block the others. * * There are two different levels of command processing within this driver. * Commands from interrupts, the request queue and general file operations * (open, revalidate, check_media) are placed in the command structure * (usr_blk_dev_cmd_s) within the information structure (::USR_BLK_DEV_INFO_T) * for the device.  These commands are then processed by the kernel thread * (usr_blk_dev_thread()) and sent to user space.  Once they are processed by * user space, the kernel thread copies any return data and informs the source * of the command that it has been completed. * *   Part detection is done via a switch in the socket which is connected to * GPIO on the part.  An interrupt is generated on both the rising edge and the * falling edge of the signal.  Once an interrupt is detected a timer is used * do debounce the signal.  After the signal has achieved a steady state the * interrupt is re-enabled and the timer stopped. * * <B>Devices Created:</B><BR> *    -# /proc/usr_blk_dev0: The read/write interface to the user space driver *       for device 0. *    -# /proc/usr_blk_devn: The read/write interface to the user space driver *       for device n. * <B>Devices Used:</B><BR> *    -# /dev/mmca0: The root for the first detected card in the first slot. *    -# /dev/mmca\<n\>: The partitions of the detected card (up to 8 partitions *       are supported). *    -# /dev/mmcb0: The root for the card in the second slot if detected. *       Additional cards continue to increment the letter (c, d, e, ...). *    -# /dev/mmcb\<n\>: The partitions of the card in the second slot. *       Additional cards continue to increment the letter (c, d, e, ...). * * <B>Command Lifecycle:</B><BR> *    When a command is sent to the user block thread it transitions through * the states described in ::USR_BLK_DEV_CMD_STATE_T.  As they enter a new * state they may wait on a wait queue or wake up another queue as they * complete.  It is necessary for commands to cycle through the states or * they can hold up all subsequent commands. * *    The following describes the states and the wait queues used within them. * The state for the commands are stored in * usr_blk_dev_info[dev_num].cmd[cmd_src].state * * <B>#USR_BLK_DEV_CMD_STATE_NONE:</B><BR> *   This state can be considered the idle state of the driver.  This value sits * in the state variable when the no command is active.  A transition to the * ::USR_BLK_DEV_CMD_STATE_NEW state starts a command executing in the user block * thread.<BR> * * <B>#USR_BLK_DEV_CMD_STATE_NEW:</B><BR> *   This is the state a requester must put in the state value in order to start * a command executing.  In the case of commands which come from locations which * can block the wait queue usr_blk_dev_info[dev_num].cmd[cmd_src].wait_for_completion * must be used before the new command can be added. * * <B>#USR_BLK_DEV_CMD_STATE_THREAD:</B><BR> *   This value is placed in the state control variable as soon as the user block * thread detects the command is new.  It does not wait on any queues. * * <B>#USR_BLK_DEV_CMD_STATE_USR_READ</B><BR> *   When a command is in this state it has woken up the * usr_blk_dev_info[dev_num].wait_for_usr_read queue which controls when user * reads of the /proc entry happen. * * <B>#USR_BLK_DEV_CMD_STATE_USR_WAIT:</B><BR> *   This state is transitioned to as soon as the user process reads the command * from the /proc entry.  The command will remain in this state until the * response is written to the /proc entry from the user driver.  Commands in * this state (as well as the ::USR_BLK_DEV_CMD_STATE_USR_READ) are waiting on * the usr_blk_dev_info[dev_num].wait_for_usr_write queue. * * <B>#USR_BLK_DEV_CMD_STATE_USR_DONE:</B><BR> *   This state is entered as soon as the usr_blk_dev_info[dev_num].wait_for_usr_write * queue is awakened.  At this point the user block thread continues by processing * any necessary data.  If the data was from the request queue * (::USR_BLK_DEV_CMD_SRC_REQ) or an interrupt (::USR_BLK_DEV_CMD_SRC_IRQ) the command * is transitioned to ::USR_BLK_DEV_CMD_STATE_NONE since no more processing is * necessary. If it is not from one of these sources it will wake up the * usr_blk_dev_info[dev_num].cmd[cmd_src].wait_for_thread queue to allow the * requester to process the data. * * <B>#USR_BLK_DEV_CMD_STATE_THREAD_DONE:</B><BR> *   Once the user block thread is done executing a command the * usr_blk_dev_info[dev_num].cmd[cmd_src].wait_for_thread will be awakened and the * requester of the command will transition to this state.  Within this state * the requester will act upon the date returned and set the state back to * #USR_BLK_DEV_CMD_STATE_NONE. * * For more data on the individual commands see the ::USR_BLK_DEV_CMD_ID_T. */#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <stdbool.h>#include <asm/arch/hardware.h>#include <linux/blk.h>#include <linux/blkdev.h>#include <linux/blkpg.h>#include <linux/fs.h>#include <linux/genhd.h>#include <linux/hdreg.h>#include <linux/init.h>#include <asm/irq.h>#include <linux/proc_fs.h>#include <linux/sched.h>#include <linux/poll.h>#include <linux/timer.h>#include <asm/uaccess.h>#include <linux/wait.h>#include <linux/usr_blk_dev.h>/******************************************************************************* Local constants and macros******************************************************************************//*! * @brief The number of successive times the sample of the device attach signal must * match before the device state is changed. */#define USR_BLK_DEV_DEBOUNCE_CNT 4#ifndef CONFIG_ARCH_SCMA11/*! @brief Port to which the media card detect switch is attached. */#define USR_BLK_DEV_DEV1_INT_GPIO 11 /*! @brief Returns non zero if the media card is attached. */# define USR_BLK_DEV_IS_DEV1_ATTACHED ((GPLR(USR_BLK_DEV_DEV1_INT_GPIO) & GPIO_bit(USR_BLK_DEV_DEV1_INT_GPIO)) != 0)#endif/*! @brief The name of the /proc entry as it will appear in the directory /proc. */#define USR_BLK_DEV_PROC_ENTRY_STR  "usr_blk_dev"/*! @brief The number of characters in USR_BLK_DEV_PROC_ENTRY_STR. */#define USR_BLK_DEV_PROC_ENTRY_LEN  11/*! * @brief The number of times the proc entry for a device can be opened. * * The number of times the proc entry for a device can be opened.  This is set * to one since only one user driver is needed to drive a device and if more * than one user process opens the entry, bad things would happen. */#define USR_BLK_DEV_MAX_PROC_OPENS 1/*! @brief Name of the user block device. */#define USR_BLK_DEV_DEVICE_NAME_STR "usr_blk_dev"/*! @brief Support 8 partitions per card. */#define USR_BLK_DEV_SHIFT   3/* @brief The maximum number of sectors which can be included in a single request. */#define USR_BLK_DEV_MAX_SECTORS_PER_REQ 128/*! @brief Used to enable debugging messages to be sent out the system log. *//* #define USR_BLK_DEV_DEBUG *//*! @brief Macro used to send debug messages to the system log. */#ifdef USR_BLK_DEV_DEBUG# define tracemsg(fmt,args...)  printk(__FILE__": %s: "fmt,__func__,##args)#else# define tracemsg(fmt,args...)#endif/*! * @brief Macro to extract the device number from the device node. *  * Each device has 8 minor numbers since* USR_BLK_DEV_SHIFT is currently 3. * This results in the device number being stored in upper bits. */#define USR_BLK_DEV_DEVICE_NR(i_rdev) (MINOR(i_rdev)>>USR_BLK_DEV_SHIFT)/*!  * @brief Timer used to debounce the insertion of a card. * * Only one timer is used for all of the devices. */static struct timer_list usr_blk_dev_timer;/*! * @brief The possible states of the media detection state machine. * * A list of the possible states of the card detection state machine which is * implemented in usr_blk_dev_poll_card_attach(). * * @note Removal is not debounced since a media card may have its power removed * at the point at which it is detected as removed only once.  In this case the * safest thing to do is to reinitialize the card. */typedef enum{    /*! @brief The media is currently not connected. */    USR_BLK_DEV_DEBOUNCE_STATE_REMOVED,    /*!     * @brief The media card has been detected as inserted and is being debounced.     *     * The media card has been detected as inserted at least once.  The number of     * states determines the number of times the card must be detected as inserted     * before it will be reported as such.     */    /* @{ */    USR_BLK_DEV_DEBOUNCE_STATE_INSERTING,    USR_BLK_DEV_DEBOUNCE_STATE_INSERTING1,    USR_BLK_DEV_DEBOUNCE_STATE_INSERTING2,    USR_BLK_DEV_DEBOUNCE_STATE_INSERTING3,    USR_BLK_DEV_DEBOUNCE_STATE_INSERTING4,    /* @} */    /*!     * @brief The card has been debounced as inserted, the driver must be informed.     *     * Once the card is detected as inserted the rest of the driver must be informed.     * However, this may take several iterations if the thread still has not received     * the previous state change.  This state will wait until the thread is ready to     * receive the indication before sending it.     */    USR_BLK_DEV_DEBOUNCE_STATE_UPDATE_INSERT,    /* @brief The media is currently inserted. */    USR_BLK_DEV_DEBOUNCE_STATE_INSERTED,    /* Removal is not debounced, so no REMOVING state exists. */    /*!     * @brief The card has been debounced as removed, the driver must be informed.     *     * Once the card is detected as removed the rest of the driver must be informed.     * However, this may take several iterations if the thread still has not received     * the previous state change.  This state will wait until the thread is ready to     * receive the indication before sending it.     */    USR_BLK_DEV_DEBOUNCE_STATE_UPDATE_REMOVAL} USR_BLK_DEV_DEBOUNCE_STATE_T;/*! * @brief The possible sources of commands for the kernel thread to send. * * There are three different sources of a command from the kernel: *   - The detect interrupt, *   - The request queue, *   - A user process calling open, close, read, write etc. */typedef enum{    USR_BLK_DEV_CMD_SRC_IRQ,  /*!< The command came from the detect interrupt. */    USR_BLK_DEV_CMD_SRC_REQ,  /*!< The command came from the request queue. */    USR_BLK_DEV_CMD_SRC_GEN,  /*!< The command came from a general source which can block. */    USR_BLK_DEV_CMD_SRC__END} USR_BLK_DEV_CMD_SRC_T;/*! * @brief The state of the command being processed. * * A typical command will have the following states.  If the command originated * in an interrupt or from the request queue, it will not progress though the * final states, since there is no need to respond to the calling layer.  Please * note there is a difference between a command which came from the kernel * request queue and once which is being handled by the RW code from within the * thread.  The thread based read write commands progress through all of the * states. */typedef enum{    /*! No command is active. */     USR_BLK_DEV_CMD_STATE_NONE    /*! A command request has been made by one of the three sources. */,    USR_BLK_DEV_CMD_STATE_NEW,    /*! The thread has received the command and has begun to act upon it. */    USR_BLK_DEV_CMD_STATE_THREAD,    /*! The thread is waiting for the user space driver to read the command. */    USR_BLK_DEV_CMD_STATE_USR_READ,    /*!     * The command has been read by the user space process and the kernel thread     * is waiting on the response.     */    USR_BLK_DEV_CMD_STATE_USR_WAIT,    /*!     * The user space process has acted upon the command and written a response     * to the /proc entry.     */    USR_BLK_DEV_CMD_STATE_USR_DONE,     /*!      * The thread has completed operating on the command, and passed the data      * back to the originator of the command.      */    USR_BLK_DEV_CMD_STATE_THREAD_DONE} USR_BLK_DEV_CMD_STATE_T;/*! * @brief Structure which holds information on the devices attached. * * The following is used as an array indexed by the device number to store any * data needed by the driver.  Please see the individual entries for details on * what is stored. */typedef struct{    /*!     * @brief The current state of debouncing for the device.     *      * A simple state machine is used for debouncing the insertion and removal     * of the card.  This is the state counter for that machine.  It can also     * be used to determine the status of the card at any time while running.     */    USR_BLK_DEV_DEBOUNCE_STATE_T debounce_state;    /*!     * @brief Used to track the connection state of the media.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩久久一区| 在线电影一区二区三区| 欧美色老头old∨ideo| 久久久久一区二区三区四区| 亚洲激情六月丁香| 国产盗摄一区二区| 欧美一级片在线观看| 亚洲精品乱码久久久久久久久 | 亚洲欧美日韩国产另类专区| 国产剧情一区二区| 91精品国产欧美日韩| 亚洲自拍偷拍麻豆| jiyouzz国产精品久久| 久久一区二区视频| 蜜臀久久99精品久久久画质超高清 | 日韩视频在线永久播放| 亚洲少妇30p| 精品国精品国产尤物美女| 粉嫩嫩av羞羞动漫久久久| 91浏览器打开| 国产成人av一区二区| 日韩一区二区电影网| 一个色妞综合视频在线观看| 91小宝寻花一区二区三区| 国产欧美精品一区二区色综合| 激情文学综合丁香| 日韩欧美一级特黄在线播放| 日韩在线观看一区二区| 欧美精品自拍偷拍| 亚洲最新在线观看| 欧美在线不卡视频| 午夜久久福利影院| 5566中文字幕一区二区电影| 午夜伦理一区二区| 欧美精品在线视频| 美脚の诱脚舐め脚责91| 欧美成人三级在线| 精品一区二区精品| 亚洲精品在线网站| 国产一区二区免费看| 国产精品视频一二三| 97se亚洲国产综合自在线不卡| 亚洲天堂中文字幕| 91玉足脚交白嫩脚丫在线播放| 亚洲精品一二三| 欧美日本国产视频| 另类人妖一区二区av| 日韩视频中午一区| 国产精品自拍在线| 欧美国产成人在线| 日本久久一区二区| 日产欧产美韩系列久久99| 欧美成人三级在线| 成人h动漫精品一区二| 亚洲美女少妇撒尿| 欧美一区二区三区色| 国产一区二区三区av电影| 中文字幕日韩av资源站| 欧美日韩精品免费观看视频| 韩国一区二区三区| 国产精品传媒视频| 欧美色网站导航| 久久精品99久久久| 《视频一区视频二区| 欧美一区中文字幕| 成人av电影免费观看| 日韩精品视频网站| 国产精品成人免费在线| 欧美一区二区在线免费观看| 丰满放荡岳乱妇91ww| 亚洲成在线观看| 中文一区在线播放| 欧美一区二区精品| 97精品国产露脸对白| 久久国产免费看| 一区二区三区美女视频| 国产亚洲欧洲一区高清在线观看| 色狠狠综合天天综合综合| 毛片av一区二区三区| 亚洲美女在线国产| 久久精品无码一区二区三区| 3751色影院一区二区三区| 高清不卡在线观看| 日本va欧美va精品| 一区二区久久久| 国产精品欧美一区喷水| 精品久久人人做人人爽| 色94色欧美sute亚洲线路一ni | 日韩三级中文字幕| 色婷婷综合久久久中文一区二区 | 久久久久久久久久看片| 欧美午夜一区二区| 成人黄色小视频| 国产精品正在播放| 久久av资源网| 日韩和的一区二区| 亚洲美女偷拍久久| 国产精品女上位| 日本一区二区三区在线观看| 日韩午夜电影av| 91精品国产色综合久久不卡蜜臀| 91老师片黄在线观看| 成人午夜在线免费| 激情欧美一区二区| 另类小说综合欧美亚洲| 午夜精品福利视频网站| 亚洲一区中文日韩| 一区二区三区在线免费| 中文字幕亚洲欧美在线不卡| 国产三级一区二区| 久久久久久久久久久电影| 在线不卡a资源高清| 欧美美女直播网站| 欧美日韩综合不卡| 欧美无砖砖区免费| 欧洲国产伦久久久久久久| 成人动漫视频在线| 91亚洲国产成人精品一区二三| 成人中文字幕电影| 成人动漫在线一区| 99久久精品国产观看| 99久久国产免费看| 91丨九色丨尤物| 欧美一a一片一级一片| 欧美亚洲一区三区| 欧美亚洲日本国产| 欧美一级国产精品| 久久久不卡网国产精品一区| 国产免费观看久久| 亚洲欧洲精品天堂一级| 《视频一区视频二区| 性欧美疯狂xxxxbbbb| 日韩成人一级大片| 国产一区欧美一区| 成人免费高清在线观看| 99re热视频这里只精品| 欧美在线免费播放| 91精品国产美女浴室洗澡无遮挡| 久久日一线二线三线suv| 成人免费在线观看入口| 午夜精品久久久久久久蜜桃app| 免费在线欧美视频| 国产精品77777竹菊影视小说| av午夜一区麻豆| 欧美日韩在线精品一区二区三区激情| 在线91免费看| 欧美激情综合在线| 亚洲免费看黄网站| 久久99久国产精品黄毛片色诱| 成人精品免费网站| 欧美日韩亚洲综合在线| 久久―日本道色综合久久| 日韩一区在线看| 九九热在线视频观看这里只有精品| 国产一区二区不卡老阿姨| 在线亚洲+欧美+日本专区| 欧美一区二区三区视频免费 | 欧美精品一区二区三区蜜桃| 亚洲欧洲日韩在线| 日本中文字幕一区二区视频| 国产电影精品久久禁18| 欧美在线制服丝袜| 久久婷婷国产综合精品青草| 亚洲国产精品久久艾草纯爱| 国产高清成人在线| 欧美日韩你懂得| 综合自拍亚洲综合图不卡区| 日韩电影免费在线| 91麻豆免费在线观看| 欧美tk丨vk视频| 性欧美疯狂xxxxbbbb| a在线欧美一区| 日韩视频国产视频| 亚洲国产日日夜夜| 成人av免费在线观看| 日韩欧美一区二区免费| 日日骚欧美日韩| 97精品超碰一区二区三区| 久久先锋影音av| 美女脱光内衣内裤视频久久网站| 色婷婷av一区二区三区软件| 国产精品三级视频| 免费看欧美女人艹b| 欧美在线免费观看视频| 国产精品福利一区| 国产黑丝在线一区二区三区| 欧美日韩亚洲综合一区二区三区| 亚洲男人的天堂av| 成人久久久精品乱码一区二区三区| 精品对白一区国产伦| 免费在线观看视频一区| 欧美日韩国产综合视频在线观看| 亚洲欧美日韩国产手机在线| 成人激情开心网| 亚洲国产精品99久久久久久久久| 日本美女一区二区三区视频| 欧美精选在线播放| 亚洲夂夂婷婷色拍ww47| 欧美色手机在线观看| 午夜久久福利影院|