Difference between revisions of "ECE497 Listings for Embedded Linux Primer Chapter 8"
(Added Listing 8-4) |
(Added Listing 8-5) |
||
Line 101: | Line 101: | ||
| 8-4 | | 8-4 | ||
| 8-7 | | 8-7 | ||
− | | Module | + | | Loading and Unloading a Module |
+ | | <pre> | ||
+ | # /sbin/modprobe hello1 | ||
+ | # dmesg | tail -4 | ||
+ | [ 47.095764] OMAPFB: ioctl QUERY_PLANE | ||
+ | [ 47.095794] OMAPFB: ioctl GET_CAPS | ||
+ | [ 49.005889] eth0: no IPv6 routers present | ||
+ | [ 651.947784] Hello Example Init | ||
+ | # /sbin/modprobe -r hello1 | ||
+ | # dmesg | tail -4 | ||
+ | [ 47.095794] OMAPFB: ioctl GET_CAPS | ||
+ | [ 49.005889] eth0: no IPv6 routers present | ||
+ | [ 651.947784] Hello Example Init | ||
+ | [ 677.682769] Hello Example Exit | ||
+ | </pre> | ||
+ | |- | ||
+ | | 8-5 | ||
+ | | 8-7 | ||
+ | | Loading and Unloading a Module | ||
| <pre> | | <pre> | ||
Revision as of 09:56, 26 March 2010
Number | Page | Caption | Listing |
---|---|---|---|
8-1 | 8-3 | Minimal Device Driver | /* Example Minimal Character Device Driver */ #include <linux/module.h> static int __init hello_init(void) { printk(KERN_INFO "Hello Example Init\n"); return 0; } static void __exit hello_exit(void) { printk("Hello Example Exit\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_AUTHOR("Chris Hallinan"); MODULE_DESCRIPTION("Hello World Example"); MODULE_LICENSE("GPL"); |
8-2 | 8-5 | Kconfig Patch for Examples | diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 6f31c94..0805290 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -4,6 +4,13 @@ menu "Character devices" +config EXAMPLES + tristate "Enable Examples" + default M + ---help--- + Enable compilation option for Embedded Linux Primer + driver examples + config VT bool "Virtual terminal" if EMBEDDED depends on !S390 |
8-3 | 8-7 | Makefile Patch for Examples | diff --git a/drivers/char/Makefile b/drivers/char/Makefile index f957edf..f1b373d 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -102,6 +102,7 @@ obj-$(CONFIG_MWAVE) += mwave/ obj-$(CONFIG_AGP) += agp/ obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_IPMI_HANDLER) += ipmi/ +obj-$(CONFIG_EXAMPLES) += examples/ obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o obj-$(CONFIG_TCG_TPM) += tpm/ |
8-4 | 8-7 | Module Build Output | $ time make modules CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h SYMLINK include/asm -> include/asm-arm CALL scripts/checksyscalls.sh <stdin>:1097:2: warning: #warning syscall fadvise64 not implemented <stdin>:1265:2: warning: #warning syscall migrate_pages not implemented CC [M] drivers/char/examples/hello1.o Building modules, stage 2. MODPOST 691 modules CC drivers/char/examples/hello1.mod.o LD [M] drivers/char/examples/hello1.ko real 0m41.559s user 0m10.905s sys 0m23.877s |
8-4 | 8-7 | Loading and Unloading a Module | # /sbin/modprobe hello1 # dmesg | tail -4 [ 47.095764] OMAPFB: ioctl QUERY_PLANE [ 47.095794] OMAPFB: ioctl GET_CAPS [ 49.005889] eth0: no IPv6 routers present [ 651.947784] Hello Example Init # /sbin/modprobe -r hello1 # dmesg | tail -4 [ 47.095794] OMAPFB: ioctl GET_CAPS [ 49.005889] eth0: no IPv6 routers present [ 651.947784] Hello Example Init [ 677.682769] Hello Example Exit |
8-5 | 8-7 | Loading and Unloading a Module |