summaryrefslogtreecommitdiff
path: root/src/interrupt_stub.s
blob: 3d2ba53e3f32145fda275e0dccca1b227b85005d (plain)
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

.set IRQ_BASE, 0x20

.section .text

.extern handle_int
.global int_ignore


.macro handle_exception num
.global handle_irq\num
handle_irq\num:
	movb $\num, (int_number)
	jmp int_bottom
.endm

.macro handle_irq num
.global handle_irq\num
handle_irq\num:
	movb $\num + IRQ_BASE, (int_number)
	jmp int_bottom
.endm

handle_irq 0x00
handle_irq 0x01
handle_exception 0x0D

int_bottom:
	pop %eax
	push int_bottom
	pusha
	pushl %ds
	pushl %es
	pushl %fs
	pushl %gs
	
	pushl %esp
	pushl %eax
	push (int_number)
	call handle_int  
	movl %eax, %esp // Set the stack pointer to the return value of handle_int

	popl %gs
	popl %fs
	popl %es
	popl %ds
	popa

	iret

int_ignore:
	pop %eax

	iret

.data
	int_number: .byte 0