Conversation
|
Compare with #15 |
lukflug
left a comment
There was a problem hiding this comment.
There are a couple of grammatical issues with this (which isn't surprising, since it was ripped off the osdev.org wiki, which is why I don't recommend taking stuff from there to build this wiki, even though it is public domain).
In any case, this cites zero sources.
pages/idt.adoc
Outdated
| If CPU was running in 32-bit mode, and the selector is a 16-bit gate, it will switch to 16-bit Protected Mode and jump to the entry point. To return back to 32-bit mode `o32 iret` instruction should be used, otherwise CPU would not know how to perform a 32-bit return (reading 32-bit instead of 16-bit values from the stack). | ||
|
|
||
| ==== Trap Gate | ||
| Trap gate is similar to Interrupt Gate. It is commonly used for syscalls and exceptions. The difference is that for a Trap Gate CPU does not disable hardware interrupts, while upon entering Interrupt Gate CPU automatically disables hardware interrupts and reenables them on return. |
There was a problem hiding this comment.
"The difference is that, for a trap gate, the CPU does not change the interrupt flag, while, upon entering an interrupt gate, the CPU automatically clears the interrupt flag. The CPU automatically restores the previous state of the interrupt flag upon returning from an interrupt for both interrupt gates and task gates."
The claim that it is commonly used for syscalls and exceptions needs more verification.
It might also be a good idea to further specify the concept of "enabling/disabling hardware interrupts", by replacing it by "setting/clearing the interrupt flag".
In addition, the CPU does not set the interrupt flag when returning from an interrupt gate, it restores the previous state of the interrupt flag from the stack for a interrupt gate and task gate.
pages/idt.adoc
Outdated
| In a Task Gate the *Selector* value should refer to a position in the GDT which specifies a Task | ||
| State Segment rather than a code segment, and the *Offset* value is unused and should be set to zero. |
There was a problem hiding this comment.
"selector" and "offset" are probably lower case.
Also, don't make them bold.
Use bold to highlight important terms as they are introduced.
To emphasize something, use italics.
pages/idt.adoc
Outdated
| In a Task Gate the *Selector* value should refer to a position in the GDT which specifies a Task | ||
| State Segment rather than a code segment, and the *Offset* value is unused and should be set to zero. | ||
|
|
||
| When processing this interrupt, the CPU it will perform a hardware task switch to the specified task, rather than jumping to an ISR. A pointer back to the task which was interrupted will be stored in the Task Link field in TSS. No newline at end of file |
There was a problem hiding this comment.
"task link field" is probably lower case
There was a problem hiding this comment.
Link in this case means a field in the TSS. I decided to specifically capitalize it.
| |=== | ||
|
|
||
|
|
||
| // TODO: x86_64 |
lukflug
left a comment
There was a problem hiding this comment.
Why does every sentence in the gate type section start a new paragraph.
This article still cites no sources.
The short description is also wrong.
|
|
||
| // TODO: articles "GDT" and "Interrupts" are not written yet | ||
|
|
||
| Interrupt Descriptor Table is a binary data structure specific to IA-32 (xref:x86[x86]) and x86_64 architectures. |
| // TODO: articles "GDT" and "Interrupts" are not written yet | ||
|
|
||
| Interrupt Descriptor Table is a binary data structure specific to IA-32 (xref:x86[x86]) and x86_64 architectures. | ||
| It is used by the CPU to lookup an interrupt service routines (ISR) when an xref:interrupts[interrupt] is issued. |
There was a problem hiding this comment.
"interrupt service routine" singular
|
|
||
| Interrupt Descriptor Table is a binary data structure specific to IA-32 (xref:x86[x86]) and x86_64 architectures. | ||
| It is used by the CPU to lookup an interrupt service routines (ISR) when an xref:interrupts[interrupt] is issued. | ||
| It is protected mode and long mode counterpart to real mode interrupt vector table (IVT). |
There was a problem hiding this comment.
"the protected mode and long mode counterpart"
| It is used by the CPU to lookup an interrupt service routines (ISR) when an xref:interrupts[interrupt] is issued. | ||
| It is protected mode and long mode counterpart to real mode interrupt vector table (IVT). | ||
|
|
||
| IMPORTANT: IDT requires a working xref:gdt[GDT] |
| |=== | ||
|
|
||
| ==== Things to know | ||
| * IDT can contain up to 256 (0..255) ISR vectors. Entries above this limit will be ignored. |
|
|
||
| IMPORTANT: Usage of 16-bit gates is highly unadvised, as the CPU cannot properly return to 32-bit mode using `iret`. | ||
|
|
||
| If the CPU was running in 32-bit mode, and the specified selector is a 16-bit gate, it will switch to 16-bit Protected Mode and jump to the entry point. |
There was a problem hiding this comment.
"protected mode is lower case"
also, this does not take compatibility mode into account
| @@ -0,0 +1,142 @@ | |||
| --- | |||
| title: Interrupt descriptor table | |||
| |=== | ||
|
|
||
| ==== Interrupt Gate | ||
| An interrupt gate is used to indicate an interrupt service routine (ISR). |
There was a problem hiding this comment.
maybe there is a better verb than "indicate"
| | 32-bit trap gate | ||
| |=== | ||
|
|
||
| ==== Interrupt Gate |
There was a problem hiding this comment.
section headers are sentence case
|
|
||
| If the CPU was running in 32-bit mode, and the specified selector is a 16-bit gate, it will switch to 16-bit Protected Mode and jump to the entry point. | ||
|
|
||
| ==== Trap Gate |
This PR adds the basic explanation and specs of IDT.
It's my first PR, edits from maintainers are welcome.