随笔分类 - linux设备驱动
摘要:1. block_read_full_page(struct page *page, get_block_t *get_block)其中page是读操作的数据存放的位置, 即OS从硬盘上读取数据将会存放到page中.2. 为这个page分配buffer_head, head = alloc_page_buffers(page); 每个bh对应文件系统的block.3. 调用submit_bh(READ, bh); 此时的动作为:分配BIO. 即: if (buffer_page(bh)) bio->bi_io_vec[0].bv_buffer = bh_page_data(bh); el
阅读全文
摘要:USB驱动与设备1. 在嵌入式设备中使用platform总线#define PLATFORM_DRIVER platform_driver_rtl8672struct platform_driver platform_driver_rtl8672 = { .probe = ehci_rtl8672_drv_probe,#ifdef CONFIG_HOTPLUG .remove = ehci_rtl8672_drv_remove,#endif .shutdown = usb_hcd_platform_shutdown, .driver = {...
阅读全文
摘要:http://files.cnblogs.com/codestub/Linux%E9%82%A3%E4%BA%9B%E4%BA%8B%E5%84%BF.7z
阅读全文
摘要:打开字符设备文件,还是通过 sys_open() 系统调用。在经过一连串的调用后,nameidata_to_filp, 内核会走到 __dentry_open() 函数。在这个函数中,执行了以下代码片段: f->f_mapping = inode->i_mapping; f->f_path.dentry = dentry; f->f_path.mnt = mnt; f->f_pos = 0; f->f_op = fops_get(inode->i_fop); file_move(f, &inode->i_sb->s_files);
阅读全文
摘要:#include <linux/wait.h> typedef int (*wait_queue_func_t)(wait_queue_t *wait, unsigned mode, int flags, void *key);int default_wake_function(wait_queue_t *wait, unsigned mode, int flags, void *key);struct __wait_queue_head { spinlock_t lock; struct list_head task_list;};typedef struct __wait_qu
阅读全文
摘要:lsmod实际上读取并分析/proc/modules文件 cat /proc/modules 内核中已加载的模块的信息存在于/sys/modules. /sys/module 是一个 sysfs 目录层次, 包含当前加载模块的信息. /proc/moudles 是旧式的, 那种信息的单个文件版本. 其中的条目包含了模块名, 每个模块占用的内存数量, 以及使用计数. 另外的字串追加到每行的末尾来指定标志, 对这个模块当前是活动的.linux内核模块程序结构 1) 加载函数(一般需要) 当通过insmod或modprobe加载内核模块时, 模块的加载函数会自动被内核执行. static int _
阅读全文