您的位置:首页 > 运维架构 > Linux

linux驱动编程--几个重要函数及概念

2014-02-11 21:29 429 查看
@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() --

其他未解决问题:

        主次设备号:主设备号--区分驱动程序。次设备号--区分调用程序?不同调用程序间会通过驱动互相影响?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息