forked from cirosantilli/x86-bare-metal-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interrupt.S
80 lines (50 loc) · 1.74 KB
/
interrupt.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
# Interrupt
Minimal interrupt example.
Expected outcome: 'ab' gets printed to the screen.
TODO: is STI not needed because this interrupt is not maskable?
## int
What it does:
- long jumps to the CS : IP found in the corresponding interrupt vector.
- also pushes EFLAGS. Why? To let them be restored by iret?
## iret
Returns to the next instruction to be executed
before the interrupt came in.
I think this is mandatory, e.g. a `jmp` wouldn't be enough because:
- we may have far jumped
- iret also pops EFLAGS restoring. TODO more things also seem restored: CS, EIP, EFLAGS, SS, and ESP
http://stackoverflow.com/questions/10462884/must-iret-be-used-when-returning-from-an-interrupt
## ISR
## Interrupt service routines
Fancy name for the handler.
http://wiki.osdev.org/Interrupt_Service_Routines
## Interrupt descriptor table
## IDTR
## Interrupt descriptor table register
IDTR points to the IDT.
The IDT contains the list of callbacks for each interrupt.
This name seems to be reserved to 32-bit protected mode, IVT is the 16-bit term.
## IVT
http://wiki.osdev.org/IVT
osdev says that the default address is 0:0, and that it shouldn't be changed by LIDT,
as it is incompatible with older CPUs.
## Interrupt priority
Volume 3 6.9 "PRIORITY AMONG SIMULTANEOUS EXCEPTIONS AND INTERRUPTS"
says that interrupts have different priorities that arrive
at the same cycle have different priorities.
TODO make a minimal example.
## Fault vs interrupt vs trap vs abort
Volume 3 Table 6-1. "Protected-Mode Exceptions and Interrupts"
classifies interrupts into multiple types. What is the difference between them?
*/
#include "common.h"
BEGIN
CLEAR
movw $handler, 0x00
mov %cs, 0x02
int $0
PUTC $'b
hlt
handler:
PUTC $'a
iret