added hello kernel module
authorhackbard <hackbard>
Sun, 14 Apr 2002 16:48:28 +0000 (16:48 +0000)
committerhackbard <hackbard>
Sun, 14 Apr 2002 16:48:28 +0000 (16:48 +0000)
hello/Makefile [new file with mode: 0644]
hello/hello.c [new file with mode: 0644]

diff --git a/hello/Makefile b/hello/Makefile
new file mode 100644 (file)
index 0000000..6339fdd
--- /dev/null
@@ -0,0 +1,26 @@
+# Makefile of hello.o - my first kernel module.
+
+INCLUDEDIR = /usr/include
+
+CFLAGS = -D__KERNEL__ -DMODULE -O -Wall -I$(INCLUDEDIR)
+
+# findout kernel version.
+VER = $(shell awk -F\" '/REL/ {print $$2}' $(INCLUDEDIR)/linux/version.h)
+
+OBJS = hello.o
+
+all: $(OBJS)
+
+#hello.o: hello.o
+#      $(LD) -r $^ -o $@
+
+install:
+       install -d /lib/modules/$(VER)/misc
+       install -c hello.o /lib/modules/$(VER)/misc
+
+clean:
+       rm -f *.o *~ core
+
+uninstall:
+       rm -f /lib/modules/$(VER)/misc/hello.o
+
diff --git a/hello/hello.c b/hello/hello.c
new file mode 100644 (file)
index 0000000..48bcb33
--- /dev/null
@@ -0,0 +1,14 @@
+/* my first kernel driver :-) */
+
+#define MODULE
+#include <linux/module.h>
+
+int init_module(void) {
+       printk("<1>hi hackbard, here is your kernel speaking! :)\n");
+       return 0;
+}
+
+void cleanup_module(void) {
+       printk("<1>bye hackbard ...\n");
+}
+