驱动程序? 好象很难,不知道有些什么鬼. 不,其实不神秘。
首先,我对驱动的理解: 在Linux中,充分利用386保护模式,系统引导后系统包裹起硬件,运用程序仅可访问(调用)操作系统开放出来的函数,而不能直接访问硬体资源(对不对呀???多多斧正啊,我觉得好象又不对!对Linux而言。)驱动程序是作为内核模块加载的,它才有直接访问硬体资源的权限。运用程序通过访问它开放出来的函数访问硬件!
(上面的话对不对呀,扔块砖页好呀)
一个问题:我昨天在 Red Hat 7.0 下写(抄写)了个原形,被告 该模块 for kernal 2.4.0-2.4.XX,but 当前kernal is 4.1.2(Red Hat 6.2??) .
Red Hat 7.1 是 2.4内核。天呀,我又要去当????!!!!
所以,如果不是必要(我是因为810显卡在7.0中被支持才升级的,以前一直用的 PCI -> s3 375外接显卡),就用6.2吧!等到7。1好了。
My First Drive:
//===filename: hello.c
#define MODULE #include <linux/module.h>
int init_module(void) { printk("<1>Hello World!\n I''''m HaoKe!\n\n") ; return 0; }
void cleanup_module(void) { printk("<1> I''''m HaoKe!\n I'''' not here now!\n\n") ; }
//====use like this: root# gcc -c hello.c root# insmode hello.o
Hello World! I''''m HaoKe!\n\n
root# rmmod hello.o
I''''m HaoKe! I'''' not here now!
本程序在 Red Hat 6.2 上通过,但在7.0上 Not OK(由于内核相关性问题) 也许在7.1上可以。
http://go.163.com/~gotolinux
qihaolinux@sina.com.cn
|