Linux最简单内核模块编写
来源:互联网 发布:淘宝联盟卖家中心在哪 编辑:程序博客网 时间:2024/06/05 15:02
hello.h
/*
* head file of hello.ko
* location of following files : /usr/src/$(uname -r)/include/
*/
#include<linux/init.h> //module_init(),module_exit()
#include<linux/module.h> //MODULE_AUTHOR(),MODULE_LICENSE()
#include<linux/kernel.h> //KERN_EMERG
hello.c
/*
* source file of hello.ko
* location: /usr/src/$(uname -r)/driver/net/hello/
*/
#include "hello.h" //find head file in current dir
/*
* hello_init : initial function, called when module is installed
* return 0 if succeeded
*/
static int hello_init(void)
{
printk(KERN_EMERG"hello.ko is installed!\n");
return 0;
}
/*
* hello_exit : called when module is uninstalled
*/
static void hello_exit(void)
{
printk(KERN_EMERG"hello.ko is uninstalled!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("zhangsk");
Makefile
obj-m := hello.o
all:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(PWD) clean
然后在当前文目录中输入: insmod hello.ko
OK, 可以看到屏幕中输出: hello.ko is installed!
- Linux最简单内核模块编写
- 编写一个简单的linux内核模块
- 最简单的linux内核模块实例
- 最简单的linux内核模块
- 编写Linux内核模块
- linux内核模块编写
- 编写Linux内核模块
- linux 内核模块编写
- Linux内核学习-最简单的内核模块
- 编写简单的内核模块
- linux 最简单的模块的编写和运行
- linux内核模块编译,最简单的hello world
- Linux环境下最简单内核模块的实践
- 初学者编译Linux内核,最简单ko模块
- 一个最简单的Linux 2.6内核驱动模块
- Linux 最简单内核模块 Hello World 示例
- 最简单的内核模块
- 编写自定义Linux内核模块
- 我思故我在系列—数据结构题(题目搜集整理者july,非常感谢!)
- 嵌入式系统设计-测试题3
- WaitableTimer的两种用法
- opencv中cvSetCaptureProperty定位不准的原因及解决
- 从敏捷的业务目标论软件开发
- Linux最简单内核模块编写
- Integrating WorldWind Java with GeoServer WMS
- 一些很有用的 SQL Server DBCC 统计命令
- 分析android的gadge
- 详细解析C语言中的sizeof
- DELPHI7中关于Tnativexml的一点笔记
- Exception loading sessions from persistent storage
- c++常量折叠(常量替换)
- Linux 下的 gcc, g++ 编译器