Skip to main content.
Navigation:
DENX
>
Training2
>
LddFirstModule
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
Training2
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
Training2 Home
Changes
Index
Search
Go
List of pages in Training2
Search
%SECTION0{name=LddFirstModule}% A first hello_world module *Code:* <verbatim> /* * 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); </verbatim> *Makefile:* <verbatim> obj-m := hello.o </verbatim> *Build it:* <verbatim> make -C ~/git/linux-denx/ M=`pwd` modules ARCH=powerpc </verbatim> *loading* * insmod * modprobe *Extentions:* * =__init, __initdata, __exit, __exitdata= (=include/linux/init.h=) * =__devinit= / =__devexit= (normal function if =!CONFIG_HOTPLUG=, else equal =__init= / =__exit= * =MODULE_AUTHOR, MODULE_LICENSE, MODULE_DESCRIPTION= * Kernel symbol visibility: =static=, =EXPORT_SYMBOL[_GPL[_FUTURE]](a)= * check out kernel symbols: =/proc/kallsyms= (=nm(1)=)
5.2.1. Configuring and building the Linux kernel
1. Denx Training Topics
5.2.3. Linux kernel makefiles
Prev
Home
Next