<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 3.9.?快速參考 本章介紹了下面符號和頭文件. struct file_operations 和 struct file 中的成員的列表這里不重復了. ~~~ #include <linux/types.h> dev_t ~~~ dev_t 是用來在內核里代表設備號的類型. ~~~ int MAJOR(dev_t dev); int MINOR(dev_t dev); ~~~ 從設備編號中抽取主次編號的宏. ~~~ dev_t MKDEV(unsigned int major, unsigned int minor); ~~~ 從主次編號來建立 dev_t 數據項的宏定義. ~~~ #include <linux/fs.h> ~~~ "文件系統"頭文件是編寫設備驅動需要的頭文件. 許多重要的函數和數據結構在此定義. ~~~ int register_chrdev_region(dev_t first, unsigned int count, char *name) int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name) void unregister_chrdev_region(dev_t first, unsigned int count); ~~~ 允許驅動分配和釋放設備編號的范圍的函數. register_chrdev_region 應當用在事先知道需要的主編號時; 對于動態分配, 使用 alloc_chrdev_region 代替. ~~~ int register_chrdev(unsigned int major, const char *name, struct file_operations *fops); ~~~ 老的( 2.6 之前) 字符設備注冊函數. 它在 2.6 內核中被模擬, 但是不應當給新代碼使用. 如果主編號不是 0, 可以不變地用它; 否則一個動態編號被分配給這個設備. int unregister_chrdev(unsigned int major, const char *name); 恢復一個由 register_chrdev 所作的注冊的函數. major 和 name 字符串必須包含之前用來注冊設備時同樣的值. ~~~ struct file_operations; struct file; struct inode; ~~~ 大部分設備驅動使用的 3 個重要數據結構. file_operations 結構持有一個字符驅動的方法; struct file 代表一個打開的文件, struct inode 代表磁盤上的一個文件. ~~~ #include <linux/cdev.h> struct cdev *cdev_alloc(void); void cdev_init(struct cdev *dev, struct file_operations *fops); int cdev_add(struct cdev *dev, dev_t num, unsigned int count); void cdev_del(struct cdev *dev); ~~~ cdev 結構管理的函數, 它代表內核中的字符設備. ~~~ #include <linux/kernel.h> container_of(pointer, type, field); ~~~ 一個傳統宏定義, 可用來獲取一個結構指針, 從它里面包含的某個其他結構的指針. ~~~ #include <asm/uaccess.h> ~~~ 這個包含文件聲明內核代碼使用的函數來移動數據到和從用戶空間. ~~~ unsigned long copy_from_user (void *to, const void *from, unsigned long count); unsigned long copy_to_user (void *to, const void *from, unsigned long count); ~~~ 在用戶空間和內核空間拷貝數據.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看