BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / blob / master / kernel / isr.S

// Related

Nucleus

Barry Per-CPU Scheduler bb0cb77 (3 years, 2 months ago)
/*
 * This file contains the interrupt service routine stubs.  For the most part
 * they just call into the generic handler after setting up the stack for it.
 * It pushes the interrupt number and saved registers onto the stack for the
 * handler to access.
 */

.extern isr_handler

/* Exception with an error */
.macro exc_err num
.globl exc\num
exc\num:
	push $\num
	jmp isr_stub
.endm
/* Exception without an error */
.macro exc_noerr num
.globl exc\num
exc\num:
	push $0
	push $\num
	jmp isr_stub
.endm

/* Exceptions */
EXC_NOERR 0
EXC_NOERR 1
EXC_NOERR 2
EXC_NOERR 3
EXC_NOERR 4
EXC_NOERR 5
EXC_NOERR 6
EXC_NOERR 7
EXC_ERR   8
EXC_NOERR 9
EXC_ERR   10
EXC_ERR   11
EXC_ERR   12
EXC_ERR   13
EXC_ERR   14
EXC_NOERR 15
EXC_NOERR 16
EXC_ERR   17
EXC_NOERR 18
EXC_NOERR 19
EXC_NOERR 20
EXC_NOERR 30
/* Interrupts */
EXC_NOERR 32
EXC_NOERR 33
EXC_NOERR 34
EXC_NOERR 35
EXC_NOERR 36
EXC_NOERR 37
EXC_NOERR 38
EXC_NOERR 39
EXC_NOERR 40
EXC_NOERR 41
EXC_NOERR 42
EXC_NOERR 43
EXC_NOERR 44
EXC_NOERR 45
EXC_NOERR 46
EXC_NOERR 47
/* IPIs */
EXC_NOERR 48
EXC_NOERR 49
EXC_NOERR 50
EXC_NOERR 51
EXC_NOERR 52
EXC_NOERR 53
EXC_NOERR 54
EXC_NOERR 55
EXC_NOERR 56
EXC_NOERR 57
EXC_NOERR 58
EXC_NOERR 59
EXC_NOERR 60
EXC_NOERR 61
EXC_NOERR 62
EXC_NOERR 63
/* System Call */
EXC_NOERR 128

/* Generic ISR stub */
isr_stub:
	pusha
	mov %ds, %ax
	pushl %eax

	/* Switch to kernel segments */
	mov $0x10, %ax
	mov %ax, %ds
	mov %ax, %es
	mov $0x28, %ax
	mov %ax, %fs
	mov $0x30, %ax
	mov %ax, %gs

	call isr_handler

	/* Restore original segments */
	popl %ebx
	mov %bx, %ds
	mov %bx, %es
	mov $0x28, %bx
	mov %bx, %fs
	mov $0x30, %bx
	mov %bx, %gs

	popa
	addl $8, %esp
	iret