Module Name:    src
Committed By:   matt
Date:           Wed Aug  1 22:46:07 UTC 2012

Modified Files:
        src/sys/arch/arm/include: frame.h
        src/sys/arch/arm/include/arm32: frame.h

Log Message:
Move fill to between spsr and r0 so that the registers will be dword aligned.
Adjust PUSH/PULL macros accordingly.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/include/frame.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/include/arm32/frame.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/include/frame.h
diff -u src/sys/arch/arm/include/frame.h:1.14 src/sys/arch/arm/include/frame.h:1.15
--- src/sys/arch/arm/include/frame.h:1.14	Tue Jul 31 07:23:16 2012
+++ src/sys/arch/arm/include/frame.h	Wed Aug  1 22:46:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.14 2012/07/31 07:23:16 matt Exp $	*/
+/*	$NetBSD: frame.h,v 1.15 2012/08/01 22:46:07 matt Exp $	*/
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -52,6 +52,7 @@
 
 typedef struct trapframe {
 	register_t tf_spsr; /* Zero on arm26 */
+	register_t tf_fill; /* fill here so r0 will dword aligned */
 	register_t tf_r0;
 	register_t tf_r1;
 	register_t tf_r2;
@@ -67,7 +68,6 @@ typedef struct trapframe {
 	register_t tf_r12;
 	register_t tf_usr_sp;
 	register_t tf_usr_lr;
-	register_t tf_fill;
 	register_t tf_svc_sp; /* Not used on arm26 */
 	register_t tf_svc_lr; /* Not used on arm26 */
 	register_t tf_pc;

Index: src/sys/arch/arm/include/arm32/frame.h
diff -u src/sys/arch/arm/include/arm32/frame.h:1.28 src/sys/arch/arm/include/arm32/frame.h:1.29
--- src/sys/arch/arm/include/arm32/frame.h:1.28	Wed Aug  1 05:40:20 2012
+++ src/sys/arch/arm/include/arm32/frame.h	Wed Aug  1 22:46:07 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: frame.h,v 1.28 2012/08/01 05:40:20 matt Exp $	*/
+/*	$NetBSD: frame.h,v 1.29 2012/08/01 22:46:07 matt Exp $	*/
 
 /*
  * Copyright (c) 1994-1997 Mark Brinicombe.
@@ -56,6 +56,7 @@
 
 typedef struct irqframe {
 	unsigned int if_spsr;
+	unsigned int if_fill;	/* fill here so r0 will dword aligned */
 	unsigned int if_r0;
 	unsigned int if_r1;
 	unsigned int if_r2;
@@ -71,7 +72,6 @@ typedef struct irqframe {
 	unsigned int if_r12;
 	unsigned int if_usr_sp;
 	unsigned int if_usr_lr;
-	unsigned int if_fill;
 	unsigned int if_svc_sp;
 	unsigned int if_svc_lr;
 	unsigned int if_pc;
@@ -324,11 +324,11 @@ LOCK_CAS_DEBUG_LOCALS
 
 #define PUSHFRAME							   \
 	str	lr, [sp, #-4]!;		/* Push the return address */	   \
-	sub	sp, sp, #(4*18);	/* Adjust the stack pointer */	   \
+	sub	sp, sp, #(4*17);	/* Adjust the stack pointer */	   \
 	PUSHUSERREGS;			/* Push the user mode registers */ \
 	mov     r0, r0;                 /* NOP for previous instruction */ \
 	mrs	r0, spsr_all;		/* Get the SPSR */		   \
-	str	r0, [sp, #-4]!		/* Push the SPSR on the stack */
+	str	r0, [sp, #-8]!		/* Push the SPSR on the stack */
 
 /*
  * PULLFRAME - macro to pull a trap frame from the stack in the current mode
@@ -336,11 +336,11 @@ LOCK_CAS_DEBUG_LOCALS
  */
 
 #define PULLFRAME							   \
-	ldr     r0, [sp], #0x0004;      /* Pop the SPSR from stack */	   \
+	ldr     r0, [sp], #0x0008;      /* Pop the SPSR from stack */	   \
 	msr     spsr_all, r0;						   \
 	ldmia   sp, {r0-r14}^;		/* Restore registers (usr mode) */ \
 	mov     r0, r0;                 /* NOP for previous instruction */ \
-	add	sp, sp, #(4*18);	/* Adjust the stack pointer */	   \
+	add	sp, sp, #(4*17);	/* Adjust the stack pointer */	   \
  	ldr	lr, [sp], #0x0004	/* Pop the return address */
 
 /*
@@ -374,14 +374,14 @@ LOCK_CAS_DEBUG_LOCALS
 	bic	r2, sp, #7;		/* Align new SVC sp */		   \
 	str	r0, [r2, #-4]!;		/* Push return address */	   \
 	stmdb	r2!, {sp, lr};		/* Push SVC sp, lr */		   \
-	sub	sp, r2, #4;		/* Keep stack aligned */	   \
+	mov	sp, r2;			/* Keep stack aligned */	   \
 	msr     spsr_all, r3;		/* Restore correct spsr */	   \
 	ldmdb	r1, {r0-r3};		/* Restore 4 regs from xxx mode */ \
 	sub	sp, sp, #(4*15);	/* Adjust the stack pointer */	   \
 	PUSHUSERREGS;			/* Push the user mode registers */ \
 	mov     r0, r0;                 /* NOP for previous instruction */ \
 	mrs	r0, spsr_all;		/* Get the SPSR */		   \
-	str	r0, [sp, #-4]!		/* Push the SPSR onto the stack */
+	str	r0, [sp, #-8]!		/* Push the SPSR onto the stack */
 
 /*
  * PULLFRAMEFROMSVCANDEXIT - macro to pull a trap frame from the stack
@@ -391,11 +391,11 @@ LOCK_CAS_DEBUG_LOCALS
  */
 
 #define PULLFRAMEFROMSVCANDEXIT						   \
-	ldr     r0, [sp], #0x0004;	/* Pop the SPSR from stack */	   \
+	ldr     r0, [sp], #0x0008;	/* Pop the SPSR from stack */	   \
 	msr     spsr_all, r0;		/* restore SPSR */		   \
 	ldmia   sp, {r0-r14}^;		/* Restore registers (usr mode) */ \
 	mov     r0, r0;	  		/* NOP for previous instruction */ \
-	add	sp, sp, #(4*16);	/* Adjust the stack pointer */	   \
+	add	sp, sp, #(4*15);	/* Adjust the stack pointer */	   \
 	ldmia	sp, {sp, lr, pc}^	/* Restore lr and exit */
 
 #endif /* _LOCORE */

Reply via email to