From c7ae8061117fe895f6175b4bf22b19403d15aaee Mon Sep 17 00:00:00 2001 From: Rostislav Lisovy Date: Thu, 31 Mar 2011 00:51:07 +0200 Subject: [PATCH] Sample 'Hello world' kernel module (used in diploma thesis text). --- .../kernel_module_example/Makefile | 9 +++++++++ .../kernel_module_example/hello.c | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 doc/diploma_thesis/kernel_module_example/Makefile create mode 100644 doc/diploma_thesis/kernel_module_example/hello.c diff --git a/doc/diploma_thesis/kernel_module_example/Makefile b/doc/diploma_thesis/kernel_module_example/Makefile new file mode 100644 index 0000000..909468b --- /dev/null +++ b/doc/diploma_thesis/kernel_module_example/Makefile @@ -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 index 0000000..ffb016c --- /dev/null +++ b/doc/diploma_thesis/kernel_module_example/hello.c @@ -0,0 +1,18 @@ +#include +#include + +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"); -- 2.39.2