设备驱动程序和中断服务例程

发布于 2024-11-09 12:58:25 字数 203 浏览 0 评论 0原文

一个非常基本的问题。我了解到设备驱动程序和中断服务例程只是一些程序或代码。每当需要时,他们都会被要求执行。 执行意味着CPU正在执行其指令集ISA之外的一些指令。那么这是否意味着设备驱动程序和 ISR 也是生成所需结果的机器指令呢?

设备驱动程序和中断例程等程序到底由什么组成?这样的程序也有数据段、代码段和堆栈段吗?

我正在学习 x86 汇编语言和 C 。

A very basic question. I have learnt that device drivers and interrupt service routines are some program or codes only. whenever required they are made to execute.
Execution means CPU is executing some instructions out of its instruction set ISA. So does it mean that device drivers and ISRs are also machine instructions to generate the required result?

what exactly such programs likes device driver and interrupt routines made up of? do such programs also have a data segment, code segment and stack segment?

I am learning x86 assembly language and C .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

森末i 2024-11-16 12:58:25

这是一个准确的评估。一个足够复杂的设备驱动程序有数据段、代码段和堆栈段。

That is an accurate assessment. A complex enough device driver has a data segment, code segment and a stack segment.

风吹雨成花 2024-11-16 12:58:25

考虑如何从设备获取数据。有两种方法:

  • 投票:我们到了吗?我们到了吗? 程序、操作系统内核、设备驱动程序等等......不断询问设备是否有任何新数据。
  • 中断:设备告诉 CPU 它有重要的事情,并中断 CPU。 CPU 执行一个称为中断服务例程的例程来服务请求,然后继续执行中断之前正在执行的操作。

根据您的操作系统(或无操作系统,只是裸机),设备驱动程序可以是一个程序,也可以是操作系统内核的一个组成部分,...

典型的设备驱动程序将执行几件事:识别设备、初始化设备、处理来自设备的中断、处理写入/读取/配置设备的请求……

当然,现代 CPU 倾向于提供保护功能,并且不允许任意进程访问设备。因此,设备驱动程序要么以高权限级别运行,通常作为操作系统内核的一部分,要么在用户空间设备驱动程序的情况下,它将使用内核提供的一些定义良好的接口。

Consider how to get data from a device. There are two ways:

  • Polling: Are we there yet? Are we there yet? A program, OS kernel, device driver, whatever... keeps asking the device whether it has any new data.
  • Interrupts: The device tells the CPU that it has something important, and interrupts the CPU. The CPU executes a routine called an Interrupt Service Routine to service the request, and then continues with whatever it was doing before it was interrupted.

Depending on your OS (or no-OS, just bare metal) a device driver can be a program, or it can be an integral part of your OS kernel, ...

A typical device driver will do several things: identifying devices, initializing devices, handling interrupts from the device, handling requests to write/read/configure the device, ...

Of course, modern CPUs tend to provide protection features, and don't allow arbitrary processes access to devices. So the device driver will either run at a high privilege level, normally as a part of the OS kernel, or in the case if userspace device-drivers it will use some well-defined interfaces provided by the kernel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文