module_param()函数】的更多相关文章

在读TCP cubic源码中,遇到了module_param(),网上查到的资料如下: 在用户态下编程可以通过main()来传递命令行参数,而编写一个内核模块则可通过module_param()来传递命令行参数. 它的具体实现方式为:module_param_named( name, type, perm),具体为变量名,它的类型,以及一个权限掩码用来做一个辅助的sysfs入口. 给出一个cubic的例子: module_param(fast_convergence, );…
1.定义模块参数的方法: module_param(name, type, perm); 其中,name:表示参数的名字;     type:表示参数的类型;     perm:表示参数的访问权限; 2. 数组类型模块参数的定义: 用逗号间隔的列表提供的值;声明一个数组参数:module_param_array(name, type, num, perm);其中,name:表示数组的名字;     type:表示参数的类型;     num :表示数组中元素数量;     perm:表示参数的访…
在驱动的模块中声明一下你要传递的参数名称,类型和权限 module_param(变量的名称,类型,权限); 先上例子 #include <linux/init.h> #include <linux/module.h> static char *p_name = "Usr"; module_param(p_name, charp, S_IRUGO); MODULE_PARM_DESC(p_name, "This is a char * string.&q…
本文转载自:http://blog.chinaunix.net/uid-25014876-id-59415.html linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10.04 开发平台:S3C2440开发板 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 一.初探linux内核模块 内核模块:内核本身是很庞大的一个结构,需要的组件很多.编译…
linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10.04 开发平台:S3C2440开发板 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 一.初探linux内核模块 内核模块:内核本身是很庞大的一个结构,需要的组件很多.编译内核时,用户 可以把所有的代码编译进内核,但是这样会引起两个问题:一是内核过大:二是 当需要添加或者删除内核时,需要重…
静态编译,动态加载应用想访问内核需要通过系统调用 驱动:1.模块(打包,加入内核)2.内核机制3.操作硬件 在Kconfig里面配置menuconfig的时候,不同的类型会在图形化界面的终端显示不用的配置选项:bool CONFIG_HELLO []hello_driver 两态tristate CONFIG_HELLO <>hello_driver 三态的 空 * Mstring/int CONFIG_HELLO ()hello_driver 相当于宏替换 (dest)hello_drive…
模块参数 引导模块时,可以向它传递参数.要使用模块参数加载模块,这样写: insmod module.ko [param1=value param2=value ...] 为了使用这些参数的值,要在模块中声明变量来保存它们,并在所有函数之外的某个地方使用宏MODULE_PARM(variable, type) 和 MODULE_PARM_DESC(variable, description) 来接收它们.type参数应该是一个格式为 [min[-max]]{b,h,i,l,s} 字符串,其中 m…
在用户态下编程可以通过main()的来传递命令行参数,而编写一个内核模块则通过module_param () module_param宏是Linux 2.6内核中新增的,该宏被定义在include/linux/moduleparam.h文件中,具体定义如下: #define module_param(name, type, perm) \module_param_named(name, name, type, perm) 其中使用了 3 个参数:要传递的参数变量名, 变量的数据类型, 以及访问参…
该宏定义在include/linux/moduleparam.h中 #define ___module_cat(a,b) __mod_ ## a ## b #define __module_cat(a,b) ___module_cat(a,b) #define __MODULE_INFO(tag, name, info) \ static const char __module_cat(name,__LINE__)[] \ __used \ __attribute__((section(".mo…
python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) Return True if any element of the iterable is true. If the iterable is empty, return False 如果序列中任何一个元素为True,那么any返回True.该函数可以让我们少些一个for循环.有两点需要注意 (1)如…