kern

diff src/intr-asm.S @ 54:4eaecb14fe31

bringing the task switching thing into shape with proper per-process kernel stacks and shit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 14 Aug 2011 16:57:23 +0300
parents 1d8877d12de0
children 88a6c4e192f9
line diff
     1.1 --- a/src/intr-asm.S	Mon Aug 08 09:53:10 2011 +0300
     1.2 +++ b/src/intr-asm.S	Sun Aug 14 16:57:23 2011 +0300
     1.3 @@ -1,3 +1,6 @@
     1.4 +#define ASM
     1.5 +#include "segm.h"
     1.6 +
     1.7  	.data
     1.8  	.align 4
     1.9  	.short 0
    1.10 @@ -68,10 +71,29 @@
    1.11   */
    1.12  	.extern dispatch_intr
    1.13  intr_entry_common:
    1.14 +	/* save the current data segment selectors */
    1.15 +	pushl %gs
    1.16 +	pushl %fs
    1.17 +	pushl %es
    1.18 +	pushl %ds
    1.19 +	/* save general purpose registers */
    1.20  	pusha
    1.21 +	/* if we entered from userspace ss and cs is set correctly, but
    1.22 +     * we must make sure all the other selectors are set to the
    1.23 +     * kernel data segment */
    1.24 +	mov $SEGM_KDATA, %ds
    1.25 +	mov $SEGM_KDATA, %es
    1.26 +	mov $SEGM_KDATA, %fs
    1.27 +	mov $SEGM_KDATA, %gs
    1.28  	call dispatch_intr
    1.29  intr_ret_local:
    1.30 +	/* restore general purpose registers */
    1.31  	popa
    1.32 +	/* restore data segment selectors */
    1.33 +	popl %ds
    1.34 +	popl %es
    1.35 +	popl %fs
    1.36 +	popl %gs
    1.37  	/* remove error code and intr num from stack */
    1.38  	add $8, %esp
    1.39  	iret
    1.40 @@ -93,5 +115,4 @@
    1.41  /* by including interrupts.h with ASM defined, the macros above
    1.42   * are expanded to generate all required interrupt entry points
    1.43   */
    1.44 -#define ASM
    1.45  #include <interrupts.h>