linux驅動編程--幾個重要函數及概念

@cdev is a structure, it is used to record some information about char-device. for add a @cdev, the following steps is necessary:

1.create a @cdev

        cdev_init()        --init a structure about cdev

        cdev_alloc()     --alloc and init a structure

        ps:it is actually helpfull that read a example and the source of the functions.

 2.get a @(device-num)

        register_chrdev_region() -- 向系統請求一個用戶指定的設備號,可能已經被佔用

        unregister_chrdev_region()

        alloc_chrdev_region()     -- 請求系統分配一個設備號,不會出現被佔用的問題

 3.register this cdev

        cdev_add() 

        cdev_del()

關於設備類和設備文件

        class_create()    -- 產生設備類,在參數中指定設備類名稱

        device_create()  -- 產生設備文件,在參數中指定設備文件名稱

        class_destroy()  --

        device_destroy() --

其他未解決問題:

        主次設備號:主設備號--區分驅動程序。次設備號--區分調用程序?不同調用程序間會通過驅動互相影響?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章