linux下hello world驱动模块
来源:互联网 发布:日本漫画哪个软件最好 编辑:程序博客网 时间:2024/05/16 05:36
以后想在linux驱动和嵌入式上发展,就学点这些东西,但是第一个hello world 模块就让我弄了半天!还是理解太浅。
下面贴一下源代码:
////hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
/* the init function*/
static int hello_init(void)
{
printk(KERN_INFO "Hello world !/n");
return 0;
}
/* the distory function*/
static void hello_exit(void)
{
printk(KERN_INFO "Goodbye!/n");
}
module_init(hello_init);
module_exit(hello_exit);
//makefile很简单
obj-m:=hello.o
编译:
1.系统必须安装kernel-headers
2.注意下源程序中头文件路径
make -C /lib/modules/2.6.36-ARCH/build D=/PATH/
第一个路径是你的kerneldir
第二个路径是你的源文件路径
最后加载和删除模块:
insmod ./hello.ko
rmmod hello
当执行这两个命令时,未出现我们预期的字符串。有可能被输入到log文件里了。我的输入到 /var/log/messages.log
- linux下hello world驱动模块
- Linux内核驱动模块编写(Hello,World)
- Linux内核驱动模块编写(Hello,World)
- Linux驱动:动态加载hello world模块
- Linux驱动:动态加载hello world模块
- linux驱动学习1---Hello World模块
- Linux设备驱动--Hello World模块
- hello world!(驱动模块)
- linux内核驱动模块编程框架---(hello world模块)
- linux内核模块编程----ubuntu下我的第一个Hello World驱动
- Linux hello world 驱动
- linux 驱动 hello world
- 编写 Hello world 模块驱动
- 驱动学习,hello world模块
- 编写 Hello world 模块驱动
- TQ2440驱动-hello world 模块
- TQ2440驱动-hello world 模块
- TQ2440驱动-hello world 模块
- VMware虚拟机三种网络连接模式(bridged、NAT、host-only)
- 『phphot』【SD2.0大会】头脑风暴,不够了!要从细节上提升技能
- java 实现链表向集合转化使用toArray()
- 『phphot』【SD2.0大会】未来手机用户将彻底摆脱死机烦恼
- java 使用hashset产生不重复的随机数
- linux下hello world驱动模块
- 『phphot』【SD2.0大会】吴剑南:手机上的Web2.0应用其乐无穷
- 浅谈NT下Ring3无驱进入Ring0的方法
- 『phphot』【SD2.0大会】现代软件开发之父Ivar 解读语言与架构
- global.asax介绍
- ExtJs:el与contentEl区别
- WebOffice 插入表格!
- 『phphot』【SD2.0大会】徐晨:VC要投什么样的项目?不投什么项目?
- 用sort()方法对值类型进行排序