Index: cpu/74xx_7xx/start.S
===================================================================
RCS file: /cvsroot/u-boot/u-boot/cpu/74xx_7xx/start.S,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 start.S
--- cpu/74xx_7xx/start.S	3 Nov 2002 00:06:45 -0000	1.1.1.1
+++ cpu/74xx_7xx/start.S	29 Nov 2002 11:54:08 -0000
@@ -177,7 +177,14 @@ SystemCall:
 	add	r11,r11,r0
 	lwz	r11,0(r11)
 
-	li	r12,0xd00-4*3		/* save LR & SRRx */
+	li	r20,0xd00-4		/* Get stack pointer */
+	lwz	r12,0(r20)
+	subi	r12,r12,12		/* Adjust stack pointer */
+	li	r0,0xc00+_end_back-SystemCall
+	cmplw	0, r0, r12		/* Check stack overflow */
+	bgt	1f
+	stw	r12,0(r20)
+	
 	mflr	r0
 	stw	r0,0(r12)
 	mfspr	r0,SRR0
@@ -202,7 +209,9 @@ _back:
 	mtmsr	r11
 	SYNC
 
-	li	r12,0xd00-4*3		/* restore regs */
+	li	r12,0xd00-4		/* restore regs */
+	lwz	r12,0(r12)		
+		
 	lwz	r11,0(r12)
 	mtlr	r11
 	lwz	r11,4(r12)
@@ -210,8 +219,13 @@ _back:
 	lwz	r11,8(r12)
 	mtspr	SRR1,r11
 
+	addi	r12,r12,12		/* Adjust stack pointer */
+	li	r20,0xd00-4
+	stw	r12,0(r20)
+	
 	SYNC
 	rfi
+_end_back:
 
 	STD_EXCEPTION(0xd00, SingleStep, UnknownException)
 
Index: cpu/mpc824x/start.S
===================================================================
RCS file: /cvsroot/u-boot/u-boot/cpu/mpc824x/start.S,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 start.S
--- cpu/mpc824x/start.S	3 Nov 2002 00:31:56 -0000	1.1.1.1
+++ cpu/mpc824x/start.S	29 Nov 2002 11:54:08 -0000
@@ -278,7 +278,14 @@ SystemCall:
 	add	r11,r11,r0
 	lwz	r11,0(r11)
 
-	li	r12,0xd00-4*3		/* save LR & SRRx */
+	li	r20,0xd00-4		/* Get stack pointer */
+	lwz	r12,0(r20)
+	subi	r12,r12,12		/* Adjust stack pointer */
+	li	r0,0xc00+_end_back-SystemCall
+	cmplw	0, r0, r12		/* Check stack overflow */
+	bgt	1f
+	stw	r12,0(r20)
+	
 	mflr	r0
 	stw	r0,0(r12)
 	mfspr	r0,SRR0
@@ -303,7 +310,9 @@ _back:
 	mtmsr	r11
 	SYNC
 
-	li	r12,0xd00-4*3		/* restore regs */
+	li	r12,0xd00-4		/* restore regs */
+	lwz	r12,0(r12)		
+		
 	lwz	r11,0(r12)
 	mtlr	r11
 	lwz	r11,4(r12)
@@ -311,8 +320,13 @@ _back:
 	lwz	r11,8(r12)
 	mtspr	SRR1,r11
 
+	addi	r12,r12,12		/* Adjust stack pointer */
+	li	r20,0xd00-4
+	stw	r12,0(r20)
+	
 	SYNC
 	rfi
+_end_back:
 
 	STD_EXCEPTION(EXC_OFF_TRACE, SingleStep, UnknownException)
 
Index: cpu/mpc8260/start.S
===================================================================
RCS file: /cvsroot/u-boot/u-boot/cpu/mpc8260/start.S,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 start.S
--- cpu/mpc8260/start.S	3 Nov 2002 00:06:57 -0000	1.1.1.1
+++ cpu/mpc8260/start.S	29 Nov 2002 11:54:09 -0000
@@ -324,7 +324,14 @@ SystemCall:
 	add	r11,r11,r0
 	lwz	r11,0(r11)
 
-	li	r12,0xd00-4*3		/* save LR & SRRx */
+	li	r20,0xd00-4		/* Get stack pointer */
+	lwz	r12,0(r20)
+	subi	r12,r12,12		/* Adjust stack pointer */
+	li	r0,0xc00+_end_back-SystemCall
+	cmplw	0, r0, r12		/* Check stack overflow */
+	bgt	1f
+	stw	r12,0(r20)
+	
 	mflr	r0
 	stw	r0,0(r12)
 	mfspr	r0,SRR0
@@ -349,7 +356,9 @@ _back:
 	mtmsr	r11
 	SYNC
 
-	li	r12,0xd00-4*3		/* restore regs */
+	li	r12,0xd00-4		/* restore regs */
+	lwz	r12,0(r12)		
+		
 	lwz	r11,0(r12)
 	mtlr	r11
 	lwz	r11,4(r12)
@@ -357,8 +366,13 @@ _back:
 	lwz	r11,8(r12)
 	mtspr	SRR1,r11
 
+	addi	r12,r12,12		/* Adjust stack pointer */
+	li	r20,0xd00-4
+	stw	r12,0(r20)
+	
 	SYNC
 	rfi
+_end_back:
 
 	STD_EXCEPTION(0xd00, SingleStep, UnknownException)
 
Index: cpu/mpc8xx/start.S
===================================================================
RCS file: /cvsroot/u-boot/u-boot/cpu/mpc8xx/start.S,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 start.S
--- cpu/mpc8xx/start.S	3 Nov 2002 00:07:02 -0000	1.1.1.1
+++ cpu/mpc8xx/start.S	29 Nov 2002 11:54:09 -0000
@@ -285,7 +285,14 @@ SystemCall:
 	add	r11,r11,r0
 	lwz	r11,0(r11)
 
-	li	r12,0xd00-4*3		/* save LR & SRRx */
+	li	r20,0xd00-4		/* Get stack pointer */
+	lwz	r12,0(r20)
+	subi	r12,r12,12		/* Adjust stack pointer */
+	li	r0,0xc00+_end_back-SystemCall
+	cmplw	0, r0, r12		/* Check stack overflow */
+	bgt	1f
+	stw	r12,0(r20)
+	
 	mflr	r0
 	stw	r0,0(r12)
 	mfspr	r0,SRR0
@@ -310,7 +317,9 @@ _back:
 	mtmsr	r11
 	SYNC
 
-	li	r12,0xd00-4*3		/* restore regs */
+	li	r12,0xd00-4		/* restore regs */
+	lwz	r12,0(r12)		
+		
 	lwz	r11,0(r12)
 	mtlr	r11
 	lwz	r11,4(r12)
@@ -318,8 +327,13 @@ _back:
 	lwz	r11,8(r12)
 	mtspr	SRR1,r11
 
+	addi	r12,r12,12		/* Adjust stack pointer */
+	li	r20,0xd00-4
+	stw	r12,0(r20)
+	
 	SYNC
 	rfi
+_end_back:
 
 	STD_EXCEPTION(0xd00, SingleStep, UnknownException)
 
Index: cpu/ppc4xx/start.S
===================================================================
RCS file: /cvsroot/u-boot/u-boot/cpu/ppc4xx/start.S,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 start.S
--- cpu/ppc4xx/start.S	3 Nov 2002 10:29:06 -0000	1.1.1.1
+++ cpu/ppc4xx/start.S	29 Nov 2002 11:54:09 -0000
@@ -775,7 +775,14 @@ SystemCall:
 	add	r11,r11,r0
 	lwz	r11,0(r11)
 
-	li	r12,0xd00-4*3		/* save LR & SRRx */
+	li	r20,0xd00-4		/* Get stack pointer */
+	lwz	r12,0(r20)
+	subi	r12,r12,12		/* Adjust stack pointer */
+	li	r0,0xc00+_end_back-SystemCall
+	cmplw	0, r0, r12		/* Check stack overflow */
+	bgt	1f
+	stw	r12,0(r20)
+	
 	mflr	r0
 	stw	r0,0(r12)
 	mfspr	r0,SRR0
@@ -800,7 +807,9 @@ _back:
 	mtmsr	r11
 	SYNC
 
-	li	r12,0xd00-4*3		/* restore regs */
+	li	r12,0xd00-4		/* restore regs */
+	lwz	r12,0(r12)		
+		
 	lwz	r11,0(r12)
 	mtlr	r11
 	lwz	r11,4(r12)
@@ -808,8 +817,13 @@ _back:
 	lwz	r11,8(r12)
 	mtspr	SRR1,r11
 
+	addi	r12,r12,12		/* Adjust stack pointer */
+	li	r20,0xd00-4
+	stw	r12,0(r20)
+	
 	SYNC
 	rfi
+_end_back:
 
 	STD_EXCEPTION(0xd00, SingleStep, UnknownException)
 
Index: examples/timer.c
===================================================================
RCS file: /cvsroot/u-boot/u-boot/examples/timer.c,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 timer.c
--- examples/timer.c	7 Oct 2002 16:57:22 -0000	1.1.1.1
+++ examples/timer.c	29 Nov 2002 11:54:09 -0000
@@ -122,6 +122,7 @@ int timer (int argc, char *argv[])
 	tid_8xx_cpmtimer_t hw;
 	tid_8xx_cpmtimer_t *hwp = &hw;
 	int c;
+        int running;
 
 	/* Pointer to CPM Timer structure */
 	cpmtimerp = &((immap_t *) gd->bd->bi_immr_base)->im_cpmtimer;
@@ -185,6 +186,7 @@ int timer (int argc, char *argv[])
 	*hwp->terp = (CPMT_EVENT_CAP | CPMT_EVENT_REF);
 
 	mon_printf (usage);
+        running = 0;
 	while ((c = mon_getc()) != 'q') {
 	    if (c == 'b') {
 
@@ -197,6 +199,7 @@ int timer (int argc, char *argv[])
 
 		/* enable timer */
 		*hwp->tgcrp |= (CPMT_GCR_RST << TID_TIMER_ID);
+                running = 1;
 
 #ifdef	DEBUG
 		mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x,"
@@ -210,6 +213,7 @@ int timer (int argc, char *argv[])
 		mon_printf ("Stopping timer\n");
 
 		*hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID);
+                running = 0;
 
 #ifdef	DEBUG
 		mon_printf ("tgcr=0x%x, tmr=0x%x, trr=0x%x,"
@@ -252,6 +256,12 @@ int timer (int argc, char *argv[])
 	    }
 	    mon_printf (usage);
 	}
+        if (running) {
+		mon_printf ("Stopping timer\n");
+                *hwp->tgcrp &= ~(CPMT_GCR_MASK << TID_TIMER_ID);
+		mon_free_hdlr (hwp->cpm_vec);
+        }
+        
 	return (0);
 }
 
Index: lib_ppc/board.c
===================================================================
RCS file: /cvsroot/u-boot/u-boot/lib_ppc/board.c,v
retrieving revision 1.3
diff -p -u -r1.3 board.c
--- lib_ppc/board.c	19 Nov 2002 11:04:22 -0000	1.3
+++ lib_ppc/board.c	29 Nov 2002 11:54:10 -0000
@@ -161,6 +161,11 @@ static void syscalls_init (void)
 	*addr++ |= NR_SYSCALLS & 0xFFFF;
 
 	flush_cache (0x0C00, 0x10);
+
+        /* Initialize syscalls stack pointer                                 */
+        addr = (ulong *) 0xcfc;
+        *addr = (ulong)addr;
+        flush_cache ((ulong)addr, 0x10);
 }
 
 /*
 
