Homepage Wiki Forum Buy

Eigenes Kernel Modul

Aus GNUBLIN

Rahmen für Treiber

#include <linux/module.h>    // included for all kernel modules
#include <linux/kernel.h>    // included for KERN_INFO
#include <linux/init.h>      // included for __init and __exit macros
 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lakshmanan");
MODULE_DESCRIPTION("A Simple Hello World module");
 
static int __init hello_init(void)
{
      printk(KERN_INFO "Hello world!\n");
          return 0;    // Non-zero return means that the module couldn't be loaded.
}
 
static void __exit hello_cleanup(void)
{
      printk(KERN_INFO "Cleaning up module.\n");
}
 
module_init(hello_init);
module_exit(hello_cleanup);

Passendes Makefile:

obj-m += hello.o
 
CROSS = arm-linux-gnueabi-
KDIR = /home/sauter/GIT/gnublin-lpc3131-2.6.33/linux-2.6.33-lpc313x
 
PWD := $(shell pwd)
 
all:
	make -C $(KDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS) modules
clean:
	make -C $(KDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS) clean