From: Thadeu Lima de Souza Cascardo Date: Sun, 16 May 2010 16:03:49 +0000 (-0300) Subject: Hello World module. X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fkernel%2Fslides%2F.git;a=commitdiff_plain;h=4df460fbf4f6de67c0bbcc0e429ca368c4ca9e1b Hello World module. Found many problems with the doc tools. --- 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);