Linux device driver

zhaozj2021-02-11  217

Driver? It's hard, I don't know what ghosts. No, it is not mysterious.

First of all, I understand the driver: In Linux, take full use of 386 protection mode, system boot system package, hardware, use only the program that can be accessed (call) Operating system, and cannot directly access hardware resources ( Not right ??? Amick, I think it is not right! For Linux.) The driver is loaded as a kernel module, which is directly accessible to hardware resources. Use the program to access the hardware by accessing its open function!

(The words above are right, throw a brick page is good)

A question: I wrote a prototype on Red Hat 7.0 (copy) yesterday, the defendant of the module for kernal 2.4.0-2.4.xx, but the current kernal IS 4.1.2 (Red Hat 6.2 ??) .red Hat 7.1 is 2.4 kernel. God, I am going to be when I am? ? ? ? ! ! ! ! So, if it is not necessary (I am because the 810 graphics card is supported in 7.0, it has been used in the previous PCI -> S3 375 external graphics card), use 6.2! Wait until 7.1.

My First Drive:

// === filename: hello.c

#define module # include 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.croot # insmode hello.o

Hello World! I'm Haoke! / N / N

root # rmmod hello.o

I'm Haoke! I 'Not here now!

This program is passed on Red Hat 6.2, but at 7.0 NOT OK (due to kernel-related issues) may be on 7.1.

http://go.163.com/~gotolinux

Qihaolinux@sina.com.cn

转载请注明原文地址:https://www.9cbs.com/read-5978.html

New Post(0)