KernelModulePrograms

KernelModulePrograms - Kernel Module Program Examples Get...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Kernel Module Program Examples Get the file ModulePrograms.zip from the OS web site hello_module. c #include <linux/kernel.h> #include <linux/module.h> int hello_module_init(void) { printk(KERN_EMERG "Hello Module~! I'm in Kernel\n"); return 0; } void hello_module_cleanup(void) { printk("<0>Bye Module~!\n"); } module_init(hello_module_init); module_exit(hello_module_cleanup); MODULE_LICENSE("GPL"); Makefile MY_TARGET := hello_module.ko obj-m := hello_module.o KERNEL_DIR := /lib/modules/$(shell uname -r)/build MODULE_DIR := /lib/modules/$(shell uname -r)/kernel/hello_module PWD := $(shell pwd) default : $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules install : mkdir -p $(MODULE_DIR) cp -f $(MY_TARGET) $(MODULE_DIR) clean : $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) clean
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
You need to use kernel module make mechanism available in your /lib/modules/your_kernel_version/build  directory. The
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

KernelModulePrograms - Kernel Module Program Examples Get...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online