Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm In cpu_switch(), stack more registers at the st...
details: https://anonhg.NetBSD.org/src/rev/dbbe6d3eb0c0
branches: trunk
changeset: 538378:dbbe6d3eb0c0
user: bjh21 <bjh21%NetBSD.org@localhost>
date: Fri Oct 18 21:32:57 2002 +0000
description:
In cpu_switch(), stack more registers at the start of the function,
and hence save fewer into the PCB. This should give me enough free
registers in cpu_switch to tidy things up and support MULTIPROCESSOR
properly. While we're here, make the stacked registers into an
APCS stack frame, so that DDB backtraces through cpu_switch() will
work.
This also affects cpu_fork(), which has to fabricate a switchframe and
PCB for the new process.
diffstat:
sys/arch/arm/arm32/cpuswitch.S | 34 +++++++++++++++++++---------------
sys/arch/arm/arm32/genassym.cf | 5 +----
sys/arch/arm/arm32/vm_machdep.c | 5 ++++-
sys/arch/arm/include/arm32/frame.h | 11 +++++++++--
sys/arch/arm/include/pcb.h | 5 +----
5 files changed, 34 insertions(+), 26 deletions(-)
diffs (177 lines):
diff -r c57f40c7aba7 -r dbbe6d3eb0c0 sys/arch/arm/arm32/cpuswitch.S
--- a/sys/arch/arm/arm32/cpuswitch.S Fri Oct 18 21:22:40 2002 +0000
+++ b/sys/arch/arm/arm32/cpuswitch.S Fri Oct 18 21:32:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpuswitch.S,v 1.25 2002/10/15 20:53:38 bjh21 Exp $ */
+/* $NetBSD: cpuswitch.S,v 1.26 2002/10/18 21:32:57 bjh21 Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -179,7 +179,9 @@
* r6 = newproc
* r7 = scratch
*/
- stmfd sp!, {r4-r7, lr}
+ mov ip, sp
+ stmfd sp!, {r4-r10, fp, ip, lr, pc}
+ sub fp, ip, #4
/*
* Get the current process and indicate that there is no longer
@@ -392,9 +394,9 @@
/* Get the user structure for the old process. */
ldr r1, [r0, #(P_ADDR)]
- /* Save all the registers in the old process's pcb */
- add r7, r1, #(PCB_R8)
- stmia r7, {r8-r13}
+ /* Save the remaining registers in the old process's pcb */
+ add r7, r1, #(PCB_R11)
+ stmia r7, {r11-r13}
/*
* This can be optimised... We know we want to go from SVC32
@@ -473,9 +475,9 @@
msr cpsr_c, r3 /* Restore the old mode */
- /* Restore all the save registers */
- add r7, r1, #PCB_R8
- ldmia r7, {r8-r13}
+ /* Restore the saved registers from the PCB */
+ add r7, r1, #PCB_R11
+ ldmia r7, {r11-r13}
mov r7, r1 /* preserve PCB pointer */
@@ -513,7 +515,7 @@
* Pull the registers that got pushed when either savectx() or
* cpu_switch() was called and return.
*/
- ldmfd sp!, {r4-r7, pc}
+ ldmdb fp, {r4-r10, fp, sp, pc}
.Lswitch_do_ras:
ldr r1, [r4, #(TF_PC)] /* second ras_lookup() arg */
@@ -584,8 +586,8 @@
ldr pc, [r4, #CF_CONTEXT_SWITCH]
/* Restore all the save registers */
- add r7, r2, #PCB_R8
- ldmia r7, {r8-r13}
+ add r7, r2, #PCB_R11
+ ldmia r7, {r11-r13}
/* This is not really needed ! */
/* Yes it is for the su and fu routines */
@@ -618,14 +620,16 @@
*/
/* Push registers.*/
- stmfd sp!, {r4-r7, lr}
+ mov ip, sp
+ stmfd sp!, {r4-r10, fp, ip, lr, pc}
+ sub fp, ip, #4
/* Store all the registers in the process's pcb */
- add r2, r0, #(PCB_R8)
- stmia r2, {r8-r13}
+ add r2, r0, #(PCB_R11)
+ stmia r2, {r11-r13}
/* Pull the regs of the stack */
- ldmfd sp!, {r4-r7, pc}
+ ldmdb fp, {r4-r10, fp, sp, pc}
ENTRY(proc_trampoline)
#ifdef MULTIPROCESSOR
diff -r c57f40c7aba7 -r dbbe6d3eb0c0 sys/arch/arm/arm32/genassym.cf
--- a/sys/arch/arm/arm32/genassym.cf Fri Oct 18 21:22:40 2002 +0000
+++ b/sys/arch/arm/arm32/genassym.cf Fri Oct 18 21:32:57 2002 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.17 2002/10/12 12:20:10 bjh21 Exp $
+# $NetBSD: genassym.cf,v 1.18 2002/10/18 21:32:58 bjh21 Exp $
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@@ -85,9 +85,6 @@
define PCB_TF offsetof(struct pcb, pcb_tf)
define PCB_PAGEDIR offsetof(struct pcb, pcb_pagedir)
define PCB_FLAGS offsetof(struct pcb, pcb_flags)
-define PCB_R8 offsetof(struct pcb, pcb_un.un_32.pcb32_r8)
-define PCB_R9 offsetof(struct pcb, pcb_un.un_32.pcb32_r9)
-define PCB_R10 offsetof(struct pcb, pcb_un.un_32.pcb32_r10)
define PCB_R11 offsetof(struct pcb, pcb_un.un_32.pcb32_r11)
define PCB_R12 offsetof(struct pcb, pcb_un.un_32.pcb32_r12)
define PCB_SP offsetof(struct pcb, pcb_un.un_32.pcb32_sp)
diff -r c57f40c7aba7 -r dbbe6d3eb0c0 sys/arch/arm/arm32/vm_machdep.c
--- a/sys/arch/arm/arm32/vm_machdep.c Fri Oct 18 21:22:40 2002 +0000
+++ b/sys/arch/arm/arm32/vm_machdep.c Fri Oct 18 21:32:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.20 2002/08/22 01:13:55 thorpej Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.21 2002/10/18 21:32:58 bjh21 Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@@ -190,7 +190,10 @@
sf->sf_spl = 0; /* always equivalent to spl0() */
sf->sf_r4 = (u_int)func;
sf->sf_r5 = (u_int)arg;
+ sf->sf_fp = 0;
+ sf->sf_sp = (u_int)tf;
sf->sf_pc = (u_int)proc_trampoline;
+ pcb->pcb_un.un_32.pcb32_r11 = sf->sf_sp - 4;
pcb->pcb_un.un_32.pcb32_sp = (u_int)sf;
}
diff -r c57f40c7aba7 -r dbbe6d3eb0c0 sys/arch/arm/include/arm32/frame.h
--- a/sys/arch/arm/include/arm32/frame.h Fri Oct 18 21:22:40 2002 +0000
+++ b/sys/arch/arm/include/arm32/frame.h Fri Oct 18 21:32:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: frame.h,v 1.3 2002/08/14 23:33:11 thorpej Exp $ */
+/* $NetBSD: frame.h,v 1.4 2002/10/18 21:32:59 bjh21 Exp $ */
/*
* Copyright (c) 1994-1997 Mark Brinicombe.
@@ -80,6 +80,7 @@
/*
* Switch frame
+ * Pushed onto the stack at the start of cpu_switch()
*/
struct switchframe {
@@ -88,7 +89,13 @@
u_int sf_r5;
u_int sf_r6;
u_int sf_r7;
- u_int sf_pc;
+ u_int sf_r8;
+ u_int sf_r9;
+ u_int sf_r10;
+ u_int sf_fp;
+ u_int sf_sp;
+ u_int sf_pc; /* return address from cpu_switch() */
+ u_int sf_scp;
};
/*
diff -r c57f40c7aba7 -r dbbe6d3eb0c0 sys/arch/arm/include/pcb.h
--- a/sys/arch/arm/include/pcb.h Fri Oct 18 21:22:40 2002 +0000
+++ b/sys/arch/arm/include/pcb.h Fri Oct 18 21:32:57 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.4 2002/10/12 12:20:11 bjh21 Exp $ */
+/* $NetBSD: pcb.h,v 1.5 2002/10/18 21:32:59 bjh21 Exp $ */
/*
* Copyright (c) 2001 Matt Thomas <matt%3am-software.com@localhost>.
@@ -45,9 +45,6 @@
struct pcb_arm32 {
pd_entry_t *pcb32_pagedir; /* PT hooks */
- u_int pcb32_r8; /* used */
- u_int pcb32_r9; /* used */
- u_int pcb32_r10; /* used */
u_int pcb32_r11; /* used */
u_int pcb32_r12; /* used */
u_int pcb32_sp; /* used */
Home |
Main Index |
Thread Index |
Old Index