The main features of a driver are:
It performs input/output (I/O) management.
It provides transparent device management, avoiding low-level programming (ports).
It increases I/O speed, because usually it has been optimized.
It includes software and hardware error management.
It allows concurrent access to the hardware by several processes
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static int hello_init(void) { printk("<1> Hello world!\n"); return 0; } static void hello_exit(void) { printk("<1> Bye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);Makefile
obj-m += hello.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) cleancommand line %make %modinfo hello*.ko result filename: hello.ko srcversion: C5BB518CD1B8222581499DF depends: vermagic: 2.6.31-20-generic SMP mod_unload modversions 586 Ref: http://www.tldp.org/LDP/lkmpg/2.6/html/
useful Linux command line
回覆刪除http://www.pixelbeat.org/cmdline.html
vim ref
回覆刪除http://man.chinaunix.net/newsoft/vi/doc/quickref.html#quickref
Linux driver 詳述
回覆刪除http://blogimg.chinaunix.net/blog/upfile2/080624202201.pdf