⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello_bak.c

📁 Linux 2.6内核版本下的PCI字符驱动开发练习参考代码。
💻 C
字号:
/* *	hello moule practicing...... */// ifndef compile#ifndef __KERNEL__#  define __KERNEL__#endif#ifndef MODULE#  define MODULE#endif#include <linux/init.h>#include <linux/module.h>/*************************************************************************/#include	<kernel.h>	/*printk();*/#include	<linux/fs.h>	/*do everything...*/#include	<linux/types.h>	/*size_t*/#include	<asm/segment.h>	/*asm opt*/#include	"sysdep.h"	/*define header*//**************************************************************************/MODULE_AUTHOR("Mr.DwG");MODULE_LICENSE("GPL");//static char *Version = "$Revision: 1.9 $";MODULE_DESCRIPTION("hello_Driver");MODULE_VERSION("$Revision: 1.9 $");/* MODULE_DEVICE_TABLE(table_info);*//* MODULE_ALIAS(alternate_name);	*///=======================================================/* static char *whom = "world"; * static int howmany = 1; * module_param(howmany, int, S_IRUGO); * module_param(whom, charp, S_IRUGO); *///=======================================================/*  * 头文件, 包含在建立的内核版本信息. * LINUX_VERSION_CODE * 整型宏定义, 对 #ifdef 版本依赖有用. * EXPORT_SYMBOL (symbol); * EXPORT_SYMBOL_GPL (symbol); * 宏定义, 用来输出一个符号给内核. 第 2 种形式输出没有版本信息, 第 3 种限制输出给 GPL 许 * 可的模块. * MODULE_AUTHOR(author); * MODULE_DESCRIPTION(description); * MODULE_VERSION(version_string); * MODULE_DEVICE_TABLE(table_info); * MODULE_ALIAS(alternate_name); * 放置文档在目标文件的模块中. *///========================================================/* #include <linux/moduleparam.h> * module_param(variable, type, perm); * 宏定义, 创建模块参数, 可以被用户在模块加载时调整( 或者在启动时间, 对于内嵌代码). 类 * 型可以是 bool, charp, int, invbool, short, ushort, uint, ulong, 或者 intarray. * #include <linux/kernel.h> * int printk(const char * fmt, ...); * 内核代码的 printf 类似物. *  *///=========================================================static int	__init  hello_init(void){   printk(KERN_ALERT"Hello,word\n");   return 0;}static void  __exit  hello_exit(void){   printk(KERN_ALERT"Goodby,cruelwork\n");  }module_init(hello_init);module_exit(hello_exit);         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -