From 4df460fbf4f6de67c0bbcc0e429ca368c4ca9e1b Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 16 May 2010 13:03:49 -0300 Subject: [PATCH] Hello World module. Found many problems with the doc tools. --- 02hello/hello | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 02hello/hello diff --git a/02hello/hello b/02hello/hello new file mode 100644 index 0000000..9fd20b5 --- /dev/null +++ b/02hello/hello @@ -0,0 +1,72 @@ +%Linux Hello World +%Thadeu Cascardo + +# Module Tools + +* lsmod +* insmod +* rmmod +* modprobe +* modinfo +* depmod + +# Module Files + +* /lib/modules/ +* /proc/modules +* /sys/module/ + +# Module parameters + +* modinfo output +* modprobe configuration files +* /sys/module/*/parameters/ + +# Headers + +include/linux/module.h +include/linux/init.h + +# Init and Exit Functions + +We use *module\\_init* and *module\\_exit* to declare our init and exit +functions. + +The *\\_\\_init* and *\\_\\_exit* marks allow the kernel to remove them when +they are not needed, reducing memory consumption. + +# printk + +*printk* is very similar to printf. The messages are usually preceded by a +string in the form \, where *n* is a priority. There are macros, like +*KERN\\_ALERT* and *KERN\\_DEBUG* to use for that. + +# License and taint + +*MODULE\\_LICENSE* is highly recommended. A free software license should be +used, otherwise the kernel is tainted. This indicates to developers that +something has gone wrong, and some bug reports are ignored some times. + +# Building out-of-tree + +Building an out-of-tree linux module is very simple: + +FIX_ME + $ make -C /lib/modules/`uname -r`/build M=$PWD modules + +# Module description definitios + +* MODULE\\_AUTHOR +* MODULE\\_LICENSE +* MODULE\\_DESCRIPTION +* MODULE\\_INFO +* MODULE\\_ALIAS +* MODULE\\_VERSION + +# Module parameters + +Besides *MODULE\\_PARM\\_DESC* to inform user about the parameter, we must use +*module\\_param*. + +FIX_ME + module_param(name, type, perm); -- 2.20.1