forked from luke8086/boot2c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintr.s
62 lines (48 loc) · 1.21 KB
/
intr.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
/*
* intr.s - A generic function for triggering software interrupts
*
* author: luke8086
* license: GPL-2
*/
.code16
.global intr
intr:
push %ebp
mov %esp, %ebp
/* Preserve general-purpose registers */
pushal
/* Inject the interrupt number */
mov 0x8(%ebp), %eax
mov %al, 2f + 0x01
/* Just in case, invalidate the pre-fetch queue */
jmp 1f
1:
/* Save ebp, since it's also used as an input for BIOS */
push %ebp
/* Load values from struct regs to the registers */
mov 0xc(%ebp), %esi
mov 0x00(%esi), %eax
mov 0x04(%esi), %ebx
mov 0x08(%esi), %ecx
mov 0x0c(%esi), %edx
mov 0x10(%esi), %ebp
mov 0x14(%esi), %edi
mov 0x18(%esi), %esi
/* Trigger the interrupt */
2: int $0x0
/* Restore ebp of our stack frame */
pop %ebp
/* Save registers back to struct regs */
mov 0xc(%ebp), %esi
mov %eax, 0x00(%esi)
mov %ebx, 0x04(%esi)
mov %ecx, 0x08(%esi)
mov %edx, 0x0c(%esi)
pushfl
popl 0x1c(%esi)
/* Restore general-purpose registers */
popal
/* Just in case, clear the direction flag */
cld
pop %ebp
retl