首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

Linux设备驱动程序代码 第2章 建立跟运行模块

2012-12-24 
Linux设备驱动程序代码 第2章 建立和运行模块第2章 建立和运行模块2.2. Hello World 模块2.2.1 代码//hell

Linux设备驱动程序代码 第2章 建立和运行模块
第2章 建立和运行模块2.2. Hello World 模块2.2.1 代码

//hello.c,Makefile同上//运行:insmod hello howmany=10 whom="Mom"                                                #include <linux/init.h>#include <linux/module.h>#include <linux/moduleparam.h>MODULE_LICENSE("Dual BSD/GPL");static char *whom = "world";static int howmany = 1;module_param(howmany, int, S_IRUGO);module_param(whom, charp, S_IRUGO);static int hello_init(void){int i;for (i = 0; i < howmany; i++)printk(KERN_ALERT "(%d) Hello, %s\n", i, whom);return 0;}static void hello_exit(void){printk(KERN_ALERT "Goodbye, cruel world\n");}module_init(hello_init);module_exit(hello_exit);


热点排行