Fix presentation build.
[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>Building</title>
65 <para>
66 Building an out-of-tree linux module is very simple:
67 </para>
68 <screen>
69 $ make -C /lib/modules/`uname -r`/build M=$PWD modules
70 </screen>
71 </foil>
72
73 <foil>
74 <title>Module Tools</title>
75 <itemizedlist>
76 <listitem>
77 insmod
78 </listitem>
79 <listitem>
80 rmmod
81 </listitem>
82 <listitem>
83 modprobe
84 </listitem>
85 <listitem>
86 modinfo
87 </listitem>
88 <listitem>
89 depmod
90 </listitem>
91 </itemizedlist>
92 </foil>
93
94 <foil>
95 <title>Module Description Definitions</title>
96 <itemizedlist>
97 <listitem>
98 MODULE\_AUTHOR
99 </listitem>
100 <listitem>
101 MODULE\_DESCRIPTION
102 </listitem>
103 <listitem>
104 MODULE\_VERSION
105 </listitem>
106 <listitem>
107 MODULE\_LICENSE
108 </listitem>
109 <listitem>
110 MODULE\_ALIAS
111 </listitem>
112 </itemizedlist>
113 </foil>
114
115 </slides>