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

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

?? usr_blk_dev.c

?? 包含MMC協議,驅動源碼. 在LINUX操作系統下通過.
?? C
?? 第 1 頁 / 共 5 頁
字號:
        return;    }    wake_up(&cmd_p->wait_for_thread);}/* * @brief Sends a command to user space and waits for the user mode driver to *        complete processing of the command. * * Sends a command from the user block device thread to user space and waits for * the user space driver to respond.  This function will block until the response * is received from user space. * * @param info_p  Pointer to the information structure for the device the *                command must be sent to. * @param id      The command which must be sent. * @param dev_num The device number to which the command must be sent. */static void usr_blk_dev_send_cmd_to_usr_and_wait(    USR_BLK_DEV_INFO_T *info_p,    USR_BLK_DEV_CMD_ID_T id,    unsigned int dev_num){    struct usr_blk_dev_cmd_s *cmd_p;        tracemsg("id: %d cmd_src: %d\n", id, info_p->cmd_src);    /*     * Set up to send the command.     */    cmd_p = &info_p->cmd[info_p->cmd_src];    cmd_p->data.id = id;    cmd_p->data.media_state = info_p->media_state;    cmd_p->data.device_num = dev_num;    cmd_p->state = USR_BLK_DEV_CMD_STATE_USR_READ;    wake_up(&info_p->wait_for_usr_read);    /* Wait for the user space driver to respond to the command. */    wait_event(info_p->wait_for_usr_write,               ((cmd_p->state == USR_BLK_DEV_CMD_STATE_USR_DONE) ||                (info_p->media_state == USR_BLK_DEV_MEDIA_STATE_ERROR)));    tracemsg("User command response received.\n");}/*! * @brief Handles reads from the /proc entry from the user mode process. * * Called when a user space application attempts to read from the /proc * entry for the usr_blk_dev.  When read is called the currently active * command is copied into the callers buffer. * * @param file  Pointer to the file structure for the operation. * @param buf   Pointer to the user space buffer in which to place the data read. * @param count The maximum number of bytes which can be placed in buf. * @param pos   The user file position. */static ssize_t usr_blk_dev_proc_read(struct file *file, char *buf, size_t count, loff_t *pos){    struct usr_blk_dev_cmd_s *cmd_p;    USR_BLK_DEV_INFO_T *info_p;    /* Send the current thread command to the usr driver. */    info_p = (USR_BLK_DEV_INFO_T *)file->private_data;    cmd_p = &info_p->cmd[info_p->cmd_src];    tracemsg("cmd_src: %d\n", info_p->cmd_src);    if (count < sizeof(cmd_p->data))    {        tracemsg("Warning: Size requested (%d) is too small.\n", count);        usr_blk_dev_abort_cmd(info_p);        return -EINVAL;    }    if (copy_to_user(buf, &cmd_p->data, sizeof(cmd_p->data)))    {        usr_blk_dev_abort_cmd(info_p);        return -EFAULT;    }    cmd_p->state = USR_BLK_DEV_CMD_STATE_USR_WAIT;    return sizeof(cmd_p->data);}/*! * @brief Handles writes to the /proc entry from the user mode process. * * Once the user space driver has completed a command it calls write to send * the data back to the kernel driver.  This routine handles the call to write. * As a result of the call the data is copied from the user space process, and * the routine waiting on the data is woken up. * * @param file  Pointer to the file structure for the operation. * @param buf   Pointer to the user space buffer which the data must be taken from. * @param count The maximum number of bytes which can be read from buf. * @param pos   The user file position. */static ssize_t usr_blk_dev_proc_write(struct file *file, const char *buf, size_t count, loff_t *pos){    struct usr_blk_dev_cmd_s *cmd_p;    USR_BLK_DEV_INFO_T *info_p;    info_p = (USR_BLK_DEV_INFO_T *)file->private_data;    cmd_p = &info_p->cmd[info_p->cmd_src];    tracemsg("count %d cmd_src: %d\n", count, info_p->cmd_src);    if (count > sizeof(USR_BLK_DEV_CMD_T))    {        tracemsg("Warning: count (%d) is too large.\n", count);        count = sizeof(USR_BLK_DEV_CMD_T);    }    if (cmd_p->state != USR_BLK_DEV_CMD_STATE_USR_WAIT)    {        tracemsg("Warning: Command write done in an invalid state (%d).\n", cmd_p->state);        return 0;    }    if (count == sizeof(USR_BLK_DEV_CMD_T))    {        if (copy_from_user(&cmd_p->data, buf, count))        {            printk(KERN_ERR "usr_blk_dev: Error copying data from user space.\n");            usr_blk_dev_abort_cmd(info_p);            return -EFAULT;        }        cmd_p->state = USR_BLK_DEV_CMD_STATE_USR_DONE;        wake_up(&info_p->wait_for_usr_write);        return count;    }    else    {        tracemsg("Warning: Not enough data %d bytes.\n", count);    }    return 0;}/*! * @brief Handles calls to poll or select on the /proc entry from the user mode *        driver. * * Called when the user mode application polls on the /proc entry.  It must * return 0 when the wait must happen and a positive value when data is * available. * * @param file  Pointer to the file structure for the operation. * @param wait  Points to the kernel wait table for poll. * * @return Returns 0 when no data is available or valid POLL flags when data is *         available for reading. */static unsigned int usr_blk_dev_proc_poll(struct file *file, poll_table *wait){    USR_BLK_DEV_INFO_T *info_p;    info_p = (USR_BLK_DEV_INFO_T *)file->private_data;    tracemsg("info_p: %p usr_blk_dev_info: %p wait: %p\n",             info_p, usr_blk_dev_info, wait);    poll_wait(file, &info_p->wait_for_usr_read, wait);    if ((info_p->cmd[info_p->cmd_src].data.id != USR_BLK_DEV_CMD_ID_NONE) &&        (info_p->cmd[info_p->cmd_src].state == USR_BLK_DEV_CMD_STATE_USR_READ))    {        return (POLLIN | POLLRDNORM);    }    /*     * In the case of an error or sporadic wakeup the user code is required to     * do nothing, since reading the data makes no sense.  If it does read it     * will see the error state in the media state field.     */    return 0;}/*! * @brief Handles calls to open on the /proc entry from the user mode process. * * Called when the user process attempts to open the /proc entry.  The function * sets up a pointer to the proc data, and increments the use count. * * @param inode A pointer to the files inode. * @param file  Pointer to the file structure for the operation. * * @return 0 upon success.<BR> *         -EBUSY if too many instances are already open. */static int usr_blk_dev_proc_open(struct inode *inode, struct file *file){    const struct proc_dir_entry *proc_p = inode->u.generic_ip;    USR_BLK_DEV_INFO_T *info_p;    USR_BLK_DEV_CMD_ID_T cmd;    unsigned int dev_num;    unsigned long irq_flags;    info_p = (USR_BLK_DEV_INFO_T *)proc_p->data;    if (info_p == NULL)    {        return -ENODEV;    }    tracemsg("proc_opens: %d data: %p\n", info_p->proc_opens, proc_p->data);    if (info_p->proc_opens >= USR_BLK_DEV_MAX_PROC_OPENS)    {        return -EBUSY;    }    file->private_data = proc_p->data;    /*     * If this is the first open and the device is not initialized, send     * the init command.     */    if (info_p->proc_opens == 0)    {        /* Find the device number. */        dev_num = 0;        while ((info_p != &usr_blk_dev_info[dev_num]) && (dev_num < USR_BLK_DEV_NUM_DEVICES))        {            dev_num++;        }        if (dev_num < USR_BLK_DEV_NUM_DEVICES)        {            local_irq_save(irq_flags);                        cmd = USR_BLK_DEV_CMD_ID_REMOVE;            if (info_p->media_state > USR_BLK_DEV_MEDIA_STATE_ERROR)            {                cmd = USR_BLK_DEV_CMD_ID_INIT;            }            /*             * The code cannot wait here, since the user process which opened /proc must respond             * to the command.  For this reason the IRQ source is used which will emulate the insert             * or remove command coming from the interrupt.  It would have come from the interrupt             * normally, but when the card was detected no proc entry was open, so the command             * could not be sent.             */            usr_blk_dev_send_cmd_to_thread(cmd, dev_num, USR_BLK_DEV_CMD_SRC_IRQ);        }        else        {            printk(KERN_ERR "usr_blk_dev: Unable to determine device number in usr_blk_dev_proc_open.\n");            return -ENODEV;        }    }    info_p->proc_opens++;    return 0;}/*! * @brief Handles calls to close on the /proc entry from the user mode process. * * Called when the user process attempts to close the /proc entry.  It simply * decrements the use counter. * * @param inode A pointer to the files inode. * @param file  Pointer to the file structure for the operation. * * @return 0 upon success.<BR> *         -ENODEV if the device is not currently open. */static int usr_blk_dev_proc_release(struct inode *inode, struct file *file){    USR_BLK_DEV_INFO_T *info_p;    info_p = (USR_BLK_DEV_INFO_T *)file->private_data;    tracemsg("proc_opens: %d", info_p->proc_opens);    if (info_p->proc_opens > 0)    {        info_p->proc_opens--;        return 0;    }    return -ENODEV;}/*! * @brief Handles opening the media device * * Called by the kernel block code when a user attempts to mount/open the block * device. * * @param inode_p A pointer to the files inode. * @param file_p  Pointer to the file structure for the operation. * * @return 0 upon success.<BR> *         -ENODEV upon failure. * * @note Only the i_rdev record of the inode_p is valid when called to mount *       the device.  For file_p only f_mode and f_flags are valid when mounting. */static int usr_blk_dev_open(struct inode *inode_p, struct file *file_p){    USR_BLK_DEV_INFO_T *info_p;        tracemsg("dev: %d minor: %d\n", USR_BLK_DEV_DEVICE_NR(inode_p->i_rdev), MINOR(inode_p->i_rdev));    info_p = &usr_blk_dev_info[USR_BLK_DEV_DEVICE_NR(inode_p->i_rdev)];    if ((info_p->media_state > USR_BLK_DEV_MEDIA_STATE_REMOVED) &&        (info_p->params.device_size != 0))    {        /* Make sure the disk has been validated before the first open. */        if (info_p->media_state != USR_BLK_DEV_MEDIA_STATE_VALIDATED)        {            check_disk_change(inode_p->i_rdev);        }        MOD_INC_USE_COUNT;        tracemsg("Open successful.\n");        return 0;    }    return -ENODEV;}/*! * @brief Handles closing device. * * Called when the kernel block code or the user wishes to close the media * device.   The file system is resynced to handle the umount command. * * @param inode_p A pointer to the files inode. * @param file_p  Pointer to the file structure for the operation. * * @return Always returns 0. */static int usr_blk_dev_release(struct inode *inode_p, struct file *file_p){    tracemsg("\n");    tracemsg("blksize: %d\n", usr_blk_dev_blksizes[1]);    MOD_DEC_USE_COUNT;    return 0;}/*! * @brief Handles checking for a media change for the device. * * Called by the kernel to determine if a media changes has happened.  This * determination is passed up to user space since it handles communication * with the part.  This allows for the case where a part is removed, but * then re-inserted.  In this case it will be reinitialized when the part is * detected as inserted, so we have no reason to re-initialize.  If it is * the same part there is no reason to inform the file system, since nothing * in the block cache needs to change. * * @param i_rdev A pointer to the kernel device information * * @return Returns 0 when the device has not changed, or 1 when it has. */static int usr_blk_dev_check_media_change(kdev_t i_rdev){    USR_BLK_DEV_INFO_T *info_p;    unsigned int dev_num;    int changed;    tracemsg("\n");    dev_num = USR_BLK_DEV_DEVICE_NR(i_rdev);    info_p = &usr_blk_dev_info[dev_num];    usr_blk_dev_send_cmd_to_thread_and_wait(info_p, USR_BLK_DEV_CMD_ID_MEDIA_CHANGE,                                            dev_num, USR_BLK_DEV_CMD_SRC_GEN);    changed = (int)(info_p->cmd[USR_BLK_DEV_CMD_SRC_GEN].data.cmd_data_from_usr.media_changed);    if (changed)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜亚洲福利老司机| 亚洲精品成人精品456| 久久久精品免费免费| 中文字幕第一区二区| 亚洲女厕所小便bbb| 亚洲福利视频三区| 国产一区二区美女诱惑| www.亚洲精品| 欧美一区二区三区四区五区| 久久久久久免费网| 一区二区久久久久久| 精品在线一区二区| 91麻豆视频网站| 欧美一级欧美一级在线播放| 国产精品视频你懂的| 亚洲成人www| 成人av在线资源| 日韩限制级电影在线观看| 中文字幕欧美日韩一区| 亚洲r级在线视频| 国产成人在线电影| 欧美电影一区二区| 1区2区3区欧美| 精东粉嫩av免费一区二区三区| 99久久精品免费观看| 精品久久久久久久人人人人传媒 | 亚洲综合在线观看视频| 国产精品一线二线三线精华| 4hu四虎永久在线影院成人| 国产精品久久久久久久久果冻传媒 | 日韩欧美美女一区二区三区| 亚洲男同性恋视频| 国产成人av自拍| 精品福利av导航| 日本强好片久久久久久aaa| 97se亚洲国产综合自在线不卡 | 久久综合狠狠综合久久综合88| 亚洲图片激情小说| 蜜桃视频免费观看一区| 色综合久久六月婷婷中文字幕| 日韩视频一区二区| 一区二区三区国产精华| 久久99国产精品成人| 欧美影院一区二区| 国产精品国模大尺度视频| 久久精品99久久久| 成人国产精品免费观看动漫| 日韩三级在线观看| 一区二区三区波多野结衣在线观看 | 成人激情动漫在线观看| 欧美日韩一区二区在线观看视频| 欧美国产日韩在线观看| 日本亚洲一区二区| 欧美三级视频在线播放| 亚洲欧美日韩成人高清在线一区| 国产一区二区三区久久悠悠色av| 欧美另类变人与禽xxxxx| 久久精品亚洲一区二区三区浴池| 性做久久久久久久久| 91免费看`日韩一区二区| 精品国产乱码久久久久久老虎 | 欧美自拍丝袜亚洲| ...av二区三区久久精品| 国模冰冰炮一区二区| 91精品国产黑色紧身裤美女| 一区二区三区 在线观看视频| 不卡欧美aaaaa| 国产精品素人一区二区| 精品一区二区三区视频在线观看| 色婷婷精品久久二区二区蜜臂av| 国产亚洲一区二区在线观看| 男女男精品网站| 欧美日韩第一区日日骚| 亚洲图片一区二区| 91精彩视频在线| 亚洲另类在线一区| 色狠狠一区二区三区香蕉| 亚洲欧洲综合另类| 欧美中文字幕一区二区三区| 亚洲免费观看高清在线观看| 99精品热视频| 51精品国自产在线| 亚洲品质自拍视频| 欧美日韩一区三区| 裸体在线国模精品偷拍| 亚洲精品一区二区三区蜜桃下载| 国产一区美女在线| 久久久精品国产99久久精品芒果| 国产麻豆精品theporn| 日韩欧美在线不卡| 精品亚洲国产成人av制服丝袜| 日韩你懂的在线播放| 国产一区在线观看麻豆| 久久―日本道色综合久久| 国产一区三区三区| 国产欧美一区二区三区网站| 成人av午夜电影| 亚洲一区二区视频| 精品欧美一区二区久久 | 欧美图片一区二区三区| 午夜精彩视频在线观看不卡| 欧美一区二区三区爱爱| 美女精品一区二区| 国产精品天干天干在观线| 色综合视频在线观看| 亚洲成人av一区| 精品电影一区二区| av电影在线观看一区| 日韩电影在线观看一区| 欧美不卡在线视频| av影院午夜一区| 亚洲午夜精品在线| 日韩欧美国产综合一区| 成人永久免费视频| 性感美女极品91精品| 久久网站最新地址| 91国偷自产一区二区三区观看| 国产精品一区二区三区四区| 亚洲女同一区二区| 国产精品对白交换视频| 91免费版在线| 免费精品视频在线| 日韩一区有码在线| 欧美一级在线视频| 色噜噜狠狠成人中文综合| 久久av中文字幕片| 亚洲人成亚洲人成在线观看图片| 欧美无砖砖区免费| 成人免费视频免费观看| 日韩国产在线观看一区| 国产精品久线观看视频| 欧美一区二区视频网站| 91免费国产在线观看| 国产精品自拍网站| 日韩成人av影视| 亚洲影视在线播放| 国产日韩欧美综合在线| 69久久99精品久久久久婷婷| a美女胸又www黄视频久久| 久久精品国产一区二区三区免费看 | 91免费看`日韩一区二区| 国产精品一区二区三区乱码| 日本sm残虐另类| 亚洲一区二区视频在线观看| 欧美国产乱子伦 | 国产99久久久久| 日韩av在线免费观看不卡| 亚洲欧美日韩电影| 国产精品国产三级国产| 国产午夜亚洲精品午夜鲁丝片 | 一本大道久久a久久精二百| 国产一区二区影院| 婷婷国产在线综合| 亚洲一区二区av在线| 亚洲美女屁股眼交| 国产精品丝袜一区| 日本一区二区成人| 国产日韩欧美精品综合| 欧美不卡一区二区三区| 欧美一级国产精品| 欧美一区二区三区四区五区| 欧美性xxxxxx少妇| 欧美日韩午夜影院| 欧美亚洲国产一区二区三区va| 91麻豆文化传媒在线观看| 播五月开心婷婷综合| 国产宾馆实践打屁股91| 国产福利一区二区三区视频在线 | 亚洲日本免费电影| 中文字幕一区二区三区色视频| 欧美激情一二三区| 26uuu国产电影一区二区| 日韩午夜在线观看视频| 欧美大片顶级少妇| 欧美不卡一二三| 久久精品亚洲精品国产欧美| 久久精品人人做人人综合| 久久久久久久性| 国产无人区一区二区三区| 国产亚洲欧美中文| 国产精品视频麻豆| 亚洲欧美激情插| 婷婷国产v国产偷v亚洲高清| 青草国产精品久久久久久| 另类小说图片综合网| 国产很黄免费观看久久| 99re热这里只有精品视频| 在线精品亚洲一区二区不卡| 欧美嫩在线观看| 欧美日韩一区高清| 日韩一区二区三区在线视频| 欧美伦理视频网站| 欧美一区二区三区四区五区| 久久久久久久久久久久久夜| 1000部国产精品成人观看| 亚洲福利视频导航| 国产一区二区不卡| 91免费在线视频观看| 欧美一区二区在线播放| 久久久综合激的五月天|