从hello world的升级来一步一步学linux驱动
文章平均质量分 83
Doublenian
我的目标是:以简练,诙谐易懂的语言方式来理解高深技术!
展开
-
hello_world-1.0之原始的内核模块编程
hello_world-1.0之原始的内核模块编程编译环境:Ubuntu11.10kernel版本:3.2.0-17-generic-pae (ubuntu的内核,而且已经属于官方的3.2系的内核)1.hello_world-1.0的源码#include#include#include/*设置模块参数*/static int counts ;modul原创 2012-12-15 14:46:55 · 466 阅读 · 0 评论 -
hello_world-3.1之增加操作函数fops(二)源码解析
hello_world-3.1之增加操作函数fops(二)源码解析1.helloworldmem.c#include#include#include#include#include //-EFAULT#include //copy_to_user and copy_from_user#include "helloworld_ioctl.h"#def原创 2012-12-15 14:49:44 · 617 阅读 · 1 评论 -
hello_world-3.1之增加操作函数fops(一)概念介绍
hello_world-3.1之增加操作函数fops(一)概念介绍1.我们对常见的file_operations 进行讨论,下面是file_operations的结构体struct file_operations { struct module *owner; loff_t (*llseek) (struct file *, loff_t, int); ssize_t原创 2012-12-15 14:49:31 · 3053 阅读 · 0 评论 -
hello_world-3.0之简单字符设备
hello_world-3.0之简单字符设备1.helloworldmem.c#include#include#include#include#define HELLOWORLDMEM_SIZE 0x1000#define HELLOWORLDMEM_MAJOR 250static int helloworldmem_major = HELLOWORLDMEM_MA原创 2012-12-15 14:49:15 · 541 阅读 · 0 评论 -
hello_world-2.3之简单设备驱动模型(三)---添加设备属性文件
hello_world-2.3之简单设备驱动模型(三)结合前面的hello_world-2.0之sys文件系统kobj,要想在设备下增加设备的属性文件,以及给device一个父设备。1.helloworld-bus.c#include#include#include#include#includestatic char *author = "doub原创 2012-12-15 14:48:58 · 452 阅读 · 0 评论 -
hello_world-2.2之简单设备驱动模型(一)
hello_world-2.2之简单设备驱动模型(一)写一个最简单的driver,bus,device 来演示驱动模型1.helloworld-bus.c#include#include#include#include#includestatic int virtual_bus_match(struct device *dev,struct device_driver *d原创 2012-12-15 14:48:41 · 453 阅读 · 0 评论 -
hello_world-2.2之简单设备驱动模型(二)---device,bus,driver结构介绍
hello_world-2.2之简单设备驱动模型(二)---device,bus,driver结构介绍1.device结构体1.1定义一个device/** * struct device - The basic device structure * @parent: The device's "parent" device, the device to which it is a原创 2012-12-15 14:48:23 · 817 阅读 · 0 评论 -
linux/Documentation/kobject.txt的翻译
linux/Documentation/kobject.txt的翻译1.初始化kobjects1.1 要初始化一个kobject,则调用函数kobject_init(): void kobject_init(struct kobject *kobj, struct kobj_type *ktype);ktype 要求kobject必须先创建后,因为每一个kobject翻译 2012-12-15 14:47:43 · 519 阅读 · 0 评论 -
hello_world-2.0之sys文件系统kobj
hello_world-2.0之sys文件系统kobj1.helloworld.c的源码#include#include#include#include#includestatic int hello_value;static ssize_t hello_show(struct kobject *kobj, struct kobj_attribute *at原创 2012-12-15 14:47:19 · 1534 阅读 · 0 评论