#include /* all kernel modules need this */ #include /* provides initialization routines */ #include static char __initdata hellomsg[] = KERN_NOTICE "Hello, Kernel, I'm in\n"; static char __exitdata byemsg[] = KERN_NOTICE "Bye, I'm out\n"; static int print_hello(void) { unsigned long i; char *symbol_name; printk(hellomsg); symbol_name = "free_pages"; printk("looking up '%s'\n", symbol_name); i = kallsyms_lookup_name(symbol_name); printk("%s 0x%lx\n", symbol_name, i); return 0; } int fib(int times, int n1, int n2) { int i = 0; int prev = n1; int curr = n2; int next = 0; while (i < times) { next = (prev + curr); prev = curr; curr = next; i++; } return next; } static int __init start_hello_world(void) { int f_int; MODULE_LICENSE("GPL"); MODULE_AUTHOR("Vincent Batts "); MODULE_DESCRIPTION("i am just reading headers"); MODULE_VERSION("1.0"); print_hello(); f_int = fib(10000000, 0, 1); return 0; } static void __exit go_away(void) { printk(byemsg); } module_init(start_hello_world); module_exit(go_away); // vim:set shiftwidth=4 softtabstop=4 expandtab: