summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/interrupts/isr_stub.s
blob: 9a903f6aa14c6e99cdb53c7424288b0dfd3ad3e8 (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
.section .text.early

.global _isr_stubs
_isr_stubs:
.rept 256
	pushal
	call _isr_stage2
	.align 8
.endr

_isr_stage2:
	cli

	// convert the return address into the vector nr
	pop %eax
	add $-_isr_stubs, %eax
	shr $3, %eax

	// disable paging, if present
	mov %cr0, %ebx
	push %ebx // push original cr0
	and $0x7FFFFFFF, %ebx
	mov %ebx, %cr0

	mov %esp, %ebp
	mov $_bss_end, %esp // switch to kernel stack
	push %eax // push the vector nr
	call isr_stage3

	mov %ebp, %esp // switch back to isr_stack
	pop %eax // restore old cr0
	mov %eax, %cr0

	popal
	iret

.align 8
_ist_stack_btm:
// TODO overflow check
.skip 64 // seems to be enough
.global _isr_stack_top
_isr_stack_top: