When to use Interrupt Gate or Trap Gate?

Deadly 提交于 2019-12-06 14:47:57

问题


As the Intel Manual illustrated, both Interrupt Gate and Trap Gate can be used to access a handler routine. And some exceptions even share vector numbers with interrupts. I am wondering when such a shared vector is detected by the CPU, how could CPU know whether it stands for an exception or an interrupt?

I am kind of confused about the logic among the following things:

  • the decision of the gate types in the IDT

  • the judgement of whether the vector stands for an exception or an interrupt

Which decides which?

I hope I made myself clear...

Update 1

Thanks for nos' reply. Do you mean I have to tell CPU which vector stands for an Interrupt or Trap? I know that CPU treat EFLAGS[IF] differently with regards to Interrupt and Trap, how does CPU know how to make this decision? Does CPU make decision based on the type fields of the IDT entry corresponding to the vector? Or rather it depends on how the system is wired up and we must set the type of the IDT entry according to that? i.e. Is the type fileds totally an illustration for us or imperative to the CPU?

and a related question: The difference between Call Gate, Interrupt Gate, Trap Gate?


回答1:


You have to program the CPU as to what is an interrupt gate and what is a trap gate for a given ISR.

This is set by bit 40-43 in an IDT entry. Info here: http://wiki.osdev.org/Interrupt_Descriptor_Table



来源:https://stackoverflow.com/questions/3442193/when-to-use-interrupt-gate-or-trap-gate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!