author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Tue, 12 May 2009 12:06:26 +0200 | |
changeset 91 | 1181deef3bd6 |
parent 77 | 49e0babccb23 |
permissions | -rw-r--r-- |
77 | 1 |
/** |
2 |
* khello/khello.c |
|
3 |
* hello-1.c - The simplest kernel module. |
|
50
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
4 |
*/ |
77 | 5 |
|
50
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#include <linux/module.h> /* Needed by all modules */ |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <linux/kernel.h> /* Needed for KERN_INFO */ |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
|
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
int init_module (void) |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
{ |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
printk (KERN_INFO "Hello world 1.\n"); |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
|
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
/* |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
* A non 0 return means init_module failed; module can't be loaded. |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
*/ |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
return 0; |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
} |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
|
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
void cleanup_module (void) |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
{ |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
printk (KERN_INFO "Goodbye world 1.\n"); |
a38f102556e5
khello: a nice kernel module
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
} |