Skip to main content.

5.2.2. A first hello_world module

Code:

/*                                                                                                                                               
 * A first simple hello_world kernel module                                                                                                      
 */

#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void)
{
        printk(KERN_ALERT "Hello world!\n");
        return 0;
}

static void hello_exit(void)
{
        printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);

Makefile:

obj-m := hello.o

Build it:

make -C ~/git/linux-2.6-denx/ M=`pwd` modules ARCH=powerpc

loading

Extentions:

5.2.1. Configuring and building the Linux kernel 1. Denx Training Topics 5.2.3. Linux kernel makefiles
Prev Home Next