而每個Driver會對 Kernel註冊,藉由Kernel來Handle Program 2 Driver / Driver 2 Program.
Kernel 指的是一個提供硬體抽象層, 磁碟及檔案系統控制, 多工等功能的系統軟體,包含了驅動主機各項硬體的偵測程式與驅動模組.
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