一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Writing device drivers in Linux: A brief tuto...

 tracyf 2011-10-12

Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers?” Linus Torvalds

Pre-requisites

In order to develop Linux device drivers, it is necessary to have an understanding of the following:

  • C programming. Some in-depth knowledge of C programming is needed, like pointer usage, bit manipulating functions, etc.
  • Microprocessor programming. It is necessary to know how microcomputers work internally: memory addressing, interrupts, etc. All of these concepts should be familiar to an assembler programmer.

There are several different devices in Linux. For simplicity, this brief tutorial will only cover type char devices loaded as modules. Kernel 2.6.x will be used (in particular, kernel 2.6.8 under Debian Sarge, which is now Debian Stable).

User space and kernel space

When you write device drivers, it’s important to make the distinction between “user space” and “kernel space”.

  • Kernel space. Linux (which is a kernel) manages the machine’s hardware in a simple and efficient manner, offering the user a simple and uniform programming interface. In the same way, the kernel, and in particular its device drivers, form a bridge or interface between the end-user/programmer and the hardware. Any subroutines or functions forming part of the kernel (modules and device drivers, for example) are considered to be part of kernel space.
  • User space. End-user programs, like the UNIX shell or other GUI based applications (kpresenter for example), are part of the user space. Obviously, these applications need to interact with the system’s hardware . However, they don’t do so directly, but through the kernel supported functions.

All of this is shown in figure 1.

Figure 1: User space where applications reside, and kernel space where modules or device drivers reside
Figure 1: User space where applications reside, and kernel space where modules or device drivers reside

Interfacing functions between user space and kernel space

The kernel offers several subroutines or functions in user space, which allow the end-user application programmer to interact with the hardware. Usually, in UNIX or Linux systems, this dialogue is performed through functions or subroutines in order to read and write files. The reason for this is that in Unix devices are seen, from the point of view of the user, as files.

On the other hand, in kernel space Linux also offers several functions or subroutines to perform the low level interactions directly with the hardware, and allow the transfer of information from kernel to user space.

Usually, for each function in user space (allowing the use of devices or files), there exists an equivalent in kernel space (allowing the transfer of information from the kernel to the user and vice-versa). This is shown in Table 1, which is, at this point, empty. It will be filled when the different device drivers concepts are introduced.

Events User functions Kernel functions
Load module
Open device
Read device
Write device
Close device
Remove module

Table 1. Device driver events and their associated interfacing functions in kernel space and user space.

Interfacing functions between kernel space and the hardware device

There are also functions in kernel space which control the device or exchange information between the kernel and the hardware. Table 2 illustrates these concepts. This table will also be filled as the concepts are introduced.

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    国产精品内射婷婷一级二级| 丰满人妻熟妇乱又伦精另类视频| 好吊妞视频这里有精品| 91精品视频免费播放| 日韩一区欧美二区国产| 久久国产人妻一区二区免费| 亚洲欧美国产网爆精品| 年轻女房东2中文字幕| 欧美日韩高清不卡在线播放| 偷拍偷窥女厕一区二区视频| 午夜视频成人在线观看| 女生更色还是男生更色| 爱草草在线观看免费视频| 91国自产精品中文字幕亚洲| 91在线国内在线中文字幕| 日韩aa一区二区三区| 好吊色免费在线观看视频| 日本东京热视频一区二区三区| 黄色日韩欧美在线观看| 中文字幕佐山爱一区二区免费| 亚洲综合日韩精品欧美综合区| 久久精品色妇熟妇丰满人妻91| 精品人妻一区二区三区四在线 | 日本高清加勒比免费在线| 国产亚洲系列91精品| 狠狠亚洲丁香综合久久| 国产激情一区二区三区不卡| 国产激情一区二区三区不卡| 日韩熟妇人妻一区二区三区| 中文字幕高清免费日韩视频| 黄色av尤物白丝在线播放网址| 老司机精品在线你懂的| 国产国产精品精品在线| 亚洲第一香蕉视频在线| 久久中文字幕中文字幕中文| 视频一区二区 国产精品| 欧美日韩久久精品一区二区| 国产精品不卡一区二区三区四区 | 免费性欧美重口味黄色| 日本欧美在线一区二区三区| 中文字幕久热精品视频在线|