linux驱动开发--day1(驱动、内核模块及相关命令、内核模块传参)

#include 
#include 

int a=10;
module_param(a,int,0664);
MODULE_PARM_DESC(a,"this is a value");

char b=97;
module_param(b,byte,0664);
MODULE_PARM_DESC(b,"this is a char");

char *c="hi";
module_param(c,charp,0664);
MODULE_PARM_DESC(c,"this is a character pointer");

short d=13;
module_param(d,short,0664);
MODULE_PARM_DESC(d,"this is a short");
//入口函数 安装内核模块时执行
static int __init mycdev_init(void)
{
	printk("a=%d\n",a);
	printk("b=%c\n",b);
	printk("c=%s\n",c);
	printk("d=%d\n",d);
	printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);
	return 0;
}

//函数出口 卸载内核模块时执行
static void __exit mycdev_exit(void)
{
	printk("%s:%s:%d\n",__FILE__,__func__,__LINE__);

}

module_init(mycdev_init);
module_exit(mycdev_exit);
MODULE_LICENSE("GPL");

现象:

linux驱动开发--day1(驱动、内核模块及相关命令、内核模块传参)_第1张图片

你可能感兴趣的:(linux,驱动开发,c语言)