程序员“隐形”怎么样?寄存器?

发布于 2024-08-25 14:54:28 字数 959 浏览 6 评论 0原文

这些是“程序员可见” x86-64 寄存器:

替代文字
(来源:usenix.org

不可见的寄存器怎么样?刚才我了解到MMU寄存器,中断描述符表(IDT)使用这些不可见的寄存器。我正在艰难地学习这些东西。有没有任何资源(书籍/文档/等)可以立即让我了解完整情况?

我知道程序员可见的寄存器并且可以轻松地使用它们进行编程。我只是想了解隐形寄存器及其功能。我想得到一个完整的图片。我在哪里可以得到这些信息?

编辑:

我想得到一个完整的图片。我从哪里可以获得这些信息?

这两本书帮助我理解了所有这些底层细节。

  1. 计算机组织和设计基础 ~ Sivarama P. Dandamudi - 1 版 (2003< /strong>)
  2. 计算机组织和设计:硬件/软件接口,第四部分版本,〜大卫·A·帕特森,约翰·L·轩尼诗

These are "Programmer Visible" x86-64 registers:

alt text
(source: usenix.org)

What about the invisible registers? Just now I learned that MMU registers, Interrupt Descriptor Table (IDT) uses these invisible registers. I'm learning these things in the hard way. Is there any resource (book/documentation/etc) that gives me the complete picture at once?

I am aware of the programmer visible registers and comfortable in programming with them. I just want to learn about invisible registers and their functionality. I want to get a complete picture. Where can I get this info?

EDIT:

I want to get a complete picture. Where can I get this info?

These are the two books helped me understanding these all low level details.

  1. Fundamentals of Computer Organization and Design ~ Sivarama P. Dandamudi - 1 edition (2003)
  2. Computer Organization and Design : The Hardware/Software Interface, 4th Edition, ~ David A. Patterson, John L. Hennessy

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

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

发布评论

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

评论(2

情绪 2024-09-01 14:54:28

IDT 是一个中断描述符表,从抽象的角度来看,它包含类似这样的内容,前 18 个中断由处理器保留,接下来的 18 个由 Intel 保留,用于未来验证芯片的架构......

Interrupt    Handler
   0         divide_by_zero_handler
   1         debug_handler
   ..           ...
   13        general_exception_handler
   14        page_fault_handler
   ..           ...
   18        machine_check_handler

在这种情况下,处理程序是玩具内核的一部分,并且每个处理程序都是在引导时、在加载用户态代码之前设置的。 (BIOS 是 16 位代码,又名实模式代码),内核设置处理程序,切换到 32 位保护模式,当发出任何中断时,根据中断号执行相应的处理程序。例如,如果生成了中断14,内核将执行page_fault_handler,检查该页面是否脏并驻留在磁盘上,然后将该页面加载到内存中,修复地址并清除脏位,执行 IRET 中断返回指令以继续,清除标志...

这是 IDT 如何工作的抽象视图...幕后正在发生更复杂的事情...取决于关于内存管理的体系结构和类型,例如分页/平面/保护/虚拟模式寻址方案...

请查看 英特尔文档,提供了英特尔编程的出色而全面的视图...

编辑:
回到 DOS 的旧时代(它是 16 位代码,而且不是很好,完全受内存保护),可以将中断处理程序重新路由到您自己的处理程序,从而覆盖原始 IDT,例如此类中断,Interrupt 9 这是使用 getvect(...)setvect(...) 调用的键盘中断(在此上下文中为 BIOS 中断),您还可以处理一些(并非所有处理器中断,特别是 IDT 0 表示除以零)...尽管这些 BIOS 中断在外观上与处理器中断非常相似,但它们具有共同的功能,两者都具有中断向量表(如当时就知道了)。这就是 TSR(终止驻留)程序如何能够在 DOS 中保持重入,因为 BIOS 中断被重新路由到 TSR 的处理程序......

IDT is an Interrupt Descriptor Table, which contains something like this from an abstract view, first eighteen interrupts are reserved by the processor, the next eighteen are reserved by Intel for future proofing the architecture of the chip...

Interrupt    Handler
   0         divide_by_zero_handler
   1         debug_handler
   ..           ...
   13        general_exception_handler
   14        page_fault_handler
   ..           ...
   18        machine_check_handler

In this context, the handlers are part of a toy kernel, and each of the handlers are set up at boot time, prior to user-land code being loaded. (BIOS is 16 bit code aka real mode code), kernel sets up the handlers, switches to 32bit protected mode, when any of the interrupts are issued, the appropriate handler is executed depending on the Interrupt number. For example, if interrupt 14 was generated, the kernel will execute a page_fault_handler, check if the page is dirty and reside on disk, then load that page into memory, fix up the addresses and clear the dirty bit, executes an IRET Interrupt Return instruction to continue, clearing the flags....

That is an abstract view of how IDT works...There is more complex things going on behind the scenes...depending on the architecture and type of memory management such as paged/flat/protected/virtual mode addressing schemes...

Have a look here at the Intel documentation that gives an excellent and thorough view of the Intel programming...

Edit:
Back in the old days of DOS (which was 16bit code and not well, exactly memory protected), it was possible to re-route the interrupt handlers to your own handlers thus overlaying the original IDT, for an example of such an interrupt, Interrupt 9 which is the Keyboard Interrupt (BIOS interrupts in this context) using the getvect(...) and setvect(...) calls, you could also, handle some (not all of the processor interrupts, notably, IDT 0 for divide by zero)...although those BIOS interrupts were quite similar in appearance to the processor interrupts, they shared a common feature, both did have the table of interrupt vectors (as it was known back then). That was how TSR (Terminate Stay Resident) programs were able to keep re-entrant in DOS as a result of the BIOS interrupts re-routed to the TSR's handlers...

隱形的亼 2024-09-01 14:54:28

您需要研究您感兴趣的特定处理器的处理器参考手册。这是 安腾处理器参考手册

You would need to study the processor reference manual for the particular processor you're interested in. Here's the Itanium Processor Reference Manual.

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