Added kmalloc/kfree to Hello World.
[cascardo/kernel/slides/.git] / 02hello / hello
1 %Linux Hello World
2 %Thadeu Cascardo
3
4 # Module Tools
5
6 * lsmod
7 * insmod
8 * rmmod
9 * modprobe
10 * modinfo
11 * depmod
12
13 # Module Files
14
15 * /lib/modules/
16 * /proc/modules
17 * /sys/module/
18
19 # Module parameters
20
21 * modinfo output
22 * modprobe configuration files
23 * /sys/module/*/parameters/
24
25 # Headers
26
27 include/linux/module.h
28 include/linux/init.h
29
30 # Init and Exit Functions
31
32 We use *module\\_init* and *module\\_exit* to declare our init and exit
33 functions.
34
35 The *\\_\\_init* and *\\_\\_exit* marks allow the kernel to remove them when
36 they are not needed, reducing memory consumption.
37
38 # printk
39
40 *printk* is very similar to printf. The messages are usually preceded by a
41 string in the form \<n\>, where *n* is a priority. There are macros, like
42 *KERN\\_ALERT* and *KERN\\_DEBUG* to use for that.
43
44 # License and taint
45
46 *MODULE\\_LICENSE* is highly recommended. A free software license should be
47 used, otherwise the kernel is tainted. This indicates to developers that
48 something has gone wrong, and some bug reports are ignored some times.
49
50 # Building out-of-tree
51
52 Building an out-of-tree linux module is very simple:
53
54 FIX_ME
55         $ make -C /lib/modules/`uname -r`/build M=$PWD modules
56
57 # Module description definitios
58
59 * MODULE\\_AUTHOR
60 * MODULE\\_LICENSE
61 * MODULE\\_DESCRIPTION
62 * MODULE\\_INFO
63 * MODULE\\_ALIAS
64 * MODULE\\_VERSION
65
66 # Module parameters
67
68 Besides *MODULE\\_PARM\\_DESC* to inform user about the parameter, we must use
69 *module\\_param*.
70
71 FIX_ME
72         module_param(name, type, perm);
73
74 # Memory allocation
75
76 * kmalloc
77 * kfree