Index: kernel/arch/mips32/include/context_offset.h
===================================================================
--- kernel/arch/mips32/include/context_offset.h	(revision 0a447abfa2fbd2b5dd35e01f0c0fdd594022ccea)
+++ kernel/arch/mips32/include/context_offset.h	(revision 7b213f2f08f6c49c416d4a73c89e199534692777)
@@ -60,32 +60,4 @@
 # define OFFSET_F30     0x5c
 #endif /* KERNEL */
-
-/* istate_t */
-#define EOFFSET_AT     0x0
-#define EOFFSET_V0     0x4
-#define EOFFSET_V1     0x8
-#define EOFFSET_A0     0xc
-#define EOFFSET_A1     0x10
-#define EOFFSET_A2     0x14
-#define EOFFSET_A3     0x18
-#define EOFFSET_T0     0x1c
-#define EOFFSET_T1     0x20
-#define EOFFSET_T2     0x24
-#define EOFFSET_T3     0x28
-#define EOFFSET_T4     0x2c
-#define EOFFSET_T5     0x30
-#define EOFFSET_T6     0x34
-#define EOFFSET_T7     0x38
-#define EOFFSET_T8     0x3c
-#define EOFFSET_T9     0x40
-#define EOFFSET_GP     0x44
-#define EOFFSET_SP     0x48
-#define EOFFSET_RA     0x4c
-#define EOFFSET_LO     0x50
-#define EOFFSET_HI     0x54
-#define EOFFSET_STATUS 0x58
-#define EOFFSET_EPC    0x5c
-#define EOFFSET_K1     0x60
-#define REGISTER_SPACE 104	/* respect stack alignment */
 
 #ifdef __ASM__
Index: kernel/arch/mips32/include/exception.h
===================================================================
--- kernel/arch/mips32/include/exception.h	(revision 0a447abfa2fbd2b5dd35e01f0c0fdd594022ccea)
+++ kernel/arch/mips32/include/exception.h	(revision 7b213f2f08f6c49c416d4a73c89e199534692777)
@@ -60,13 +60,17 @@
 
 typedef struct istate {
+	/*
+	 * The first seven registers are arranged so that the istate structure
+	 * can be used both for exception handlers and for the syscall handler.
+	 */
+	uint32_t a0;	/* arg1 */
+	uint32_t a1;	/* arg2 */
+	uint32_t a2;	/* arg3 */
+	uint32_t a3;	/* arg4 */
+	uint32_t t0;	/* arg5 */
+	uint32_t t1;	/* arg6 */
+	uint32_t v0;	/* arg7 */
+	uint32_t v1;
 	uint32_t at;
-	uint32_t v0;
-	uint32_t v1;
-	uint32_t a0;
-	uint32_t a1;
-	uint32_t a2;
-	uint32_t a3;
-	uint32_t t0;
-	uint32_t t1;
 	uint32_t t2;
 	uint32_t t3;
@@ -75,8 +79,19 @@
 	uint32_t t6;
 	uint32_t t7;
+	uint32_t s0
+	uint32_t s1
+	uint32_t s2
+	uint32_t s3
+	uint32_t s4
+	uint32_t s5
+	uint32_t s6
+	uint32_t s7
 	uint32_t t8;
 	uint32_t t9;
+	uint32_t kt0;
+	uint32_t kt1;	/* We use it as thread-local pointer */
 	uint32_t gp;
 	uint32_t sp;
+	uint32_t s8;
 	uint32_t ra;
 	
@@ -84,7 +99,8 @@
 	uint32_t hi;
 	
-	uint32_t status;  /* cp0_status */
-	uint32_t epc;     /* cp0_epc */
-	uint32_t k1;      /* We use it as thread-local pointer */
+	uint32_t status;	/* cp0_status */
+	uint32_t epc;		/* cp0_epc */
+
+	uint32_t alignment;	/* to make sizeof(istate_t) a multiple of 8 */
 } istate_t;
 
Index: kernel/arch/mips32/src/start.S
===================================================================
--- kernel/arch/mips32/src/start.S	(revision 0a447abfa2fbd2b5dd35e01f0c0fdd594022ccea)
+++ kernel/arch/mips32/src/start.S	(revision 7b213f2f08f6c49c416d4a73c89e199534692777)
@@ -50,4 +50,43 @@
  */
 #define REG_SAVE_MASK 0x1f
+
+#define ISTATE_OFFSET_A0	0
+#define ISTATE_OFFSET_A1	4
+#define ISTATE_OFFSET_A2	8
+#define ISTATE_OFFSET_A3	12
+#define ISTATE_OFFSET_T0	16
+#define ISTATE_OFFSET_T1	20
+#define ISTATE_OFFSET_V0	24
+#define ISTATE_OFFSET_V1	28
+#define ISTATE_OFFSET_AT	32
+#define ISTATE_OFFSET_T2	36
+#define ISTATE_OFFSET_T3	40
+#define ISTATE_OFFSET_T4	44
+#define ISTATE_OFFSET_T5	48
+#define ISTATE_OFFSET_T6	52
+#define ISTATE_OFFSET_T7	56
+#define ISTATE_OFFSET_S0	60
+#define ISTATE_OFFSET_S1	64
+#define ISTATE_OFFSET_S2	68
+#define ISTATE_OFFSET_S3	72
+#define ISTATE_OFFSET_S4	76
+#define ISTATE_OFFSET_S5	80
+#define ISTATE_OFFSET_S6	84
+#define ISTATE_OFFSET_S7	88
+#define ISTATE_OFFSET_T8	92
+#define ISTATE_OFFSET_T9	96
+#define ISTATE_OFFSET_KT0	100
+#define ISTATE_OFFSET_KT1	104
+#define ISTATE_OFFSET_GP	108
+#define ISTATE_OFFSET_SP	112
+#define ISTATE_OFFSET_S8	116
+#define ISTATE_OFFSET_RA	120
+#define ISTATE_OFFSET_LO	124
+#define ISTATE_OFFSET_HI	128
+#define ISTATE_OFFSET_STATUS	132
+#define ISTATE_OFFSET_EPC	136
+#define ISTATE_OFFSET_ALIGNMENT	140
+
+#define ISTATE_SOFT_SIZE	144
 
 /*
@@ -205,6 +244,6 @@
 	KERNEL_STACK_TO_K0
 	
-	sub $k0, REGISTER_SPACE
-	sw $sp, EOFFSET_SP($k0)
+	sub $k0, ISTATE_SOFT_SIZE
+	sw $sp, ISTATE_OFFSET_SP($k0)
 	move $sp, $k0
 	
