]> rtime.felk.cvut.cz Git - mf6xx.git/commitdiff
Sample 'Hello world' kernel module (used in diploma thesis text).
authorRostislav Lisovy <lisovy@gmail.com>
Wed, 30 Mar 2011 22:51:07 +0000 (00:51 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Wed, 30 Mar 2011 22:51:07 +0000 (00:51 +0200)
doc/diploma_thesis/kernel_module_example/Makefile [new file with mode: 0644]
doc/diploma_thesis/kernel_module_example/hello.c [new file with mode: 0644]

diff --git a/doc/diploma_thesis/kernel_module_example/Makefile b/doc/diploma_thesis/kernel_module_example/Makefile
new file mode 100644 (file)
index 0000000..909468b
--- /dev/null
@@ -0,0 +1,9 @@
+KERNEL_VER=`uname -r`
+
+obj-m += hello.o
+
+all:
+       make -C /lib/modules/$(KERNEL_VER)/build M=$(PWD) modules
+
+clean:
+       make -C /lib/modules/$(KERNEL_VER)/build M=$(PWD) clean
diff --git a/doc/diploma_thesis/kernel_module_example/hello.c b/doc/diploma_thesis/kernel_module_example/hello.c
new file mode 100644 (file)
index 0000000..ffb016c
--- /dev/null
@@ -0,0 +1,18 @@
+#include <linux/init.h>
+#include <linux/module.h>
+
+static int hello_init(void)
+{
+       printk("Hello, world!\n");
+       return 0;
+}
+
+static void hello_exit(void)
+{
+       printk("Goodbye, cruel world!\n");
+}
+
+module_init(hello_init);
+module_exit(hello_exit);
+MODULE_LICENSE("Dual BSD/GPL");