Tell about MODULE_LICENSE and taint.
[cascardo/kernel/old_slides/.git] / 01.hello / 01.hello.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE slides SYSTEM "/usr/share/xml/docbook/custom/slides/3.3.1/schema/dtd/slides-full.dtd">
3
4 <slides>
5
6 <slidesinfo>
7 <title>Hello World Module</title>
8 <author><firstname>Thadeu</firstname><surname>Cascardo</surname></author>
9 </slidesinfo>
10
11 <foil>
12 <title>Introduction</title>
13 <para>
14 Let's take a look at how linux modules work.
15 </para>
16 </foil>
17
18 <foil>
19 <title>Requirements</title>
20 <para>
21 We need the tools to build a module and a building linux tree. Running the built
22 linux kernel is highly recommended so we can test our modules.
23 </para>
24 <para>
25 The tools include GNU make, GCC and GNU binutils. Linux build is highly
26 dependent on the GNU toolchain, since the beginning.
27 </para>
28 </foil>
29
30 <foil>
31 <title>Hands-on</title>
32 <para>
33 We have prepared sample code to build in the samples/ directory. Try them.
34 </para>
35 </foil>
36
37 <foil>
38 <title>Init and Exit Functions</title>
39 <para>
40 We use <emphasis>module\_init</emphasis> and <emphasis>module\_exit</emphasis>
41 to declare our init and exit functions.
42 </para>
43 </foil>
44
45 <foil>
46 <title>Init and Exit Functions</title>
47 <para>
48 The <emphasis>\_\_init</emphasis> and <emphasis>\_\_exit</emphasis> marks allow
49 the kernel to remove them when they are not needed, reducing memory consumption.
50 </para>
51 </foil>
52
53 <foil>
54 <title>printk</title>
55 <para>
56 <emphasis>printk</emphasis> is very similar to printf. The messages are usually
57 preceded by a string in the form &lt;n&gt;, where <emphasis>n</emphasis> is a
58 priority. There are macros, like <emphasis>KERN\_ALERT</emphasis> and
59 <emphasis>KERN\_DEBUG</emphasis> to use for that.
60 </para>
61 </foil>
62
63 <foil>
64 <title>License and taint</title>
65 <para>
66 <emphasis>MODULE\_LICENSE</emphasis> is highly recommended. A free software
67 license should be used, otherwise the kernel is tainted. This indicates to
68 developers that something has gone wrong, and some bug reports are ignored some
69 times.
70 </para>
71 </foil>
72
73 <foil>
74 <title>Building</title>
75 <para>
76 Building an out-of-tree linux module is very simple:
77 </para>
78 <screen>
79 $ make -C /lib/modules/`uname -r`/build M=$PWD modules
80 </screen>
81 </foil>
82
83 <foil>
84 <title>Module Tools</title>
85 <itemizedlist>
86 <listitem>
87 insmod
88 </listitem>
89 <listitem>
90 rmmod
91 </listitem>
92 <listitem>
93 modprobe
94 </listitem>
95 <listitem>
96 modinfo
97 </listitem>
98 <listitem>
99 depmod
100 </listitem>
101 </itemizedlist>
102 </foil>
103
104 <foil>
105 <title>Module Description Definitions</title>
106 <itemizedlist>
107 <listitem>
108 MODULE\_AUTHOR
109 </listitem>
110 <listitem>
111 MODULE\_DESCRIPTION
112 </listitem>
113 <listitem>
114 MODULE\_VERSION
115 </listitem>
116 <listitem>
117 MODULE\_LICENSE
118 </listitem>
119 <listitem>
120 MODULE\_ALIAS
121 </listitem>
122 </itemizedlist>
123 </foil>
124
125 </slides>