From: hackbard Date: Sun, 14 Apr 2002 16:48:28 +0000 (+0000) Subject: added hello kernel module X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=395fd5f8ac9b98dac953183fa3d8ccb38c3a86c1;p=my-code%2Fkernel.git added hello kernel module --- 395fd5f8ac9b98dac953183fa3d8ccb38c3a86c1 diff --git a/hello/Makefile b/hello/Makefile new file mode 100644 index 0000000..6339fdd --- /dev/null +++ b/hello/Makefile @@ -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 index 0000000..48bcb33 --- /dev/null +++ b/hello/hello.c @@ -0,0 +1,14 @@ +/* my first kernel driver :-) */ + +#define MODULE +#include + +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"); +} +