zoukankan      html  css  js  c++  java
  • linux驱动 ioctl()

    first let's look at the struct  file_operation
    {
    .ioctl = fun_name,(if in linux-digilent ti is .unlocked_ioctl = fun_name)
    }

    function declare:
    static int my_ioctl(unsigned int reg_num,unsigned int cmd,struct data *arg);
    now we know, there is a struct named data

    struct data{
    int reg_num;
    int reg_val;
    };

    there also has a function to init the struct data

    struct data makedata(int x,int y)
    {
      struct data temp;
      temp.reg_num = x;
      temp.reg_val = y;
      return temp;
    }




    static int my_ioctl(unsigned int reg_num,unsigned int cmd,struct data *arg){
    struct data * p = arg ;
    int tmp;

    switch(cmd){
         case 0:
              prink("read_reg%d\n",p->reg_num);
              tmp = ioread32(( (p->reg_num)*4 )+ aes_slave_reg0_addr); break;

         case 1:
              prink("write_reg%d\n",p->reg_num);

             tmp =iowrite32(( (p->reg_num)*4 )+ aes_slave_reg0_addr,p->val);break;
        default: return 0xff;
          }

    return tmp;

    }


  • 相关阅读:
    MySQL、Redis 和 MongoDB 的优缺点
    解决数据库高并发
    数据库事务
    Mysql 数据库存储的原理?
    CSRF
    MVC模型和MVT模型
    AJAX
    正则表达式-re模块
    ddt-数据驱动测试
    python-时间格式化
  • 原文地址:https://www.cnblogs.com/puck/p/3009108.html
Copyright © 2011-2022 走看看