关于设备驱动模型的一个问题,谢谢
我们知道cdev表示的是字符设备,而block_device表示的是块设备,但似乎都没看见他们内嵌device结构,2.6里面不是利用device结构来使得这些设备被包含在各种各样的subsystem里面的吗?似乎gendisk 结构里面还有一个device的指针,但是为什么不内嵌在里面,而使用指针呢?在cdev里面就找不到device的影子了:
struct block_device {
dev_t bd_dev; /* not a kdev_t - it's a search key */
struct inode * bd_inode; /* will die */
int bd_openers;
struct semaphore bd_sem; /* open/close mutex */
struct semaphore bd_mount_sem; /* mount mutex */
struct list_head bd_inodes;
void * bd_holder;
int bd_holders;
struct block_device * bd_contains;
unsigned bd_block_size;
struct hd_struct * bd_part;
unsigned bd_part_count;
int bd_invalidated;
struct gendisk * bd_disk;
struct list_head bd_list;
/*
* Private data. You must have bd_claim'ed the block_device
* to use this. NOTE: bd_claim allows an owner to claim
* the same device multiple times, the owner must take special
* care to not mess up bd_private for that case.
*/
unsigned long bd_private;
};
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};
struct device {
int dev_type; // PCICA, PCICC, or PCIXCC
enum devstat dev_stat; // current device status
int dev_self_x; // Index in array
int disabled; // Set when device is in error
int user_disabled; // Set when device is disabled by user
int dev_q_depth; // q depth
unsigned char * dev_resp_p; // Response buffer address
int dev_resp_l; // Response Buffer length
int dev_caller_count; // Number of callers
int dev_total_req_cnt; // # requests for device since load
struct list_head dev_caller_list; // List of callers
};
那么像device这样的通用设备结构和具体的设备结构到底是个什么关系呢?谢谢。
struct block_device {
dev_t bd_dev; /* not a kdev_t - it's a search key */
struct inode * bd_inode; /* will die */
int bd_openers;
struct semaphore bd_sem; /* open/close mutex */
struct semaphore bd_mount_sem; /* mount mutex */
struct list_head bd_inodes;
void * bd_holder;
int bd_holders;
struct block_device * bd_contains;
unsigned bd_block_size;
struct hd_struct * bd_part;
unsigned bd_part_count;
int bd_invalidated;
struct gendisk * bd_disk;
struct list_head bd_list;
/*
* Private data. You must have bd_claim'ed the block_device
* to use this. NOTE: bd_claim allows an owner to claim
* the same device multiple times, the owner must take special
* care to not mess up bd_private for that case.
*/
unsigned long bd_private;
};
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};
struct device {
int dev_type; // PCICA, PCICC, or PCIXCC
enum devstat dev_stat; // current device status
int dev_self_x; // Index in array
int disabled; // Set when device is in error
int user_disabled; // Set when device is disabled by user
int dev_q_depth; // q depth
unsigned char * dev_resp_p; // Response buffer address
int dev_resp_l; // Response Buffer length
int dev_caller_count; // Number of callers
int dev_total_req_cnt; // # requests for device since load
struct list_head dev_caller_list; // List of callers
};
那么像device这样的通用设备结构和具体的设备结构到底是个什么关系呢?谢谢。
...全文
相关推荐
Linux内核分析与应用课件第9章(三)设备驱动模型.pdf
Linux内核分析与应用课件
linux设备驱动程序(中文第三版)+源码
linux设备驱动程序(中文第三版)+源码,linux设备驱动程序(中文第三版)+源码,转载别人的,共同学习
Linux设备驱动(LDD) 中文第三版.pdf
Linux内核设备驱动工程师的圣经-《 Linux设备驱动(LDD) 中文第三版.pdf 》,该书系统地讲解内核设备驱动框架及Linux设备驱动的分类及开发Linux设备驱动程序的内功心法,是Linux内核设备驱动开发工程师的葵花宝典!其他经典内核驱动学习书籍请参考楼主其他资源!
基于嵌入式Linux的设备驱动程序开发.pdf
基于嵌入式Linux的设备驱动程序开发.pdf
深入Linux设备驱动程序内核机制.pdf
深入Linux设备驱动程序内核机制.pdf



