diff options
Diffstat (limited to 'sys/arch/sh')
-rw-r--r-- | sys/arch/sh/include/cpu.h | 7 | ||||
-rw-r--r-- | sys/arch/sh/sh/genassym.cf | 4 | ||||
-rw-r--r-- | sys/arch/sh/sh/locore_c.c | 74 | ||||
-rw-r--r-- | sys/arch/sh/sh/locore_subr.S | 71 | ||||
-rw-r--r-- | sys/arch/sh/sh/sh_machdep.c | 41 |
5 files changed, 31 insertions, 166 deletions
diff --git a/sys/arch/sh/include/cpu.h b/sys/arch/sh/include/cpu.h index b29d7247ce0..8b43e78767b 100644 --- a/sys/arch/sh/include/cpu.h +++ b/sys/arch/sh/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.10 2007/06/06 17:15:12 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.11 2007/10/10 15:53:52 art Exp $ */ /* $NetBSD: cpu.h,v 1.41 2006/01/21 04:24:12 uwe Exp $ */ /*- @@ -125,6 +125,11 @@ extern int want_resched; /* need_resched() was called */ * We need a machine-independent name for this. */ #define DELAY(x) delay(x) + +#define cpu_idle_enter() do { /* nothing */ } while (0) +#define cpu_idle_cycle() __asm volatile("sleep") +#define cpu_idle_leave() do { /* nothing */ } while (0) + #endif /* _KERNEL */ /* diff --git a/sys/arch/sh/sh/genassym.cf b/sys/arch/sh/sh/genassym.cf index 9227338a9a3..d864f1397ec 100644 --- a/sys/arch/sh/sh/genassym.cf +++ b/sys/arch/sh/sh/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.3 2007/05/14 07:05:49 art Exp $ +# $OpenBSD: genassym.cf,v 1.4 2007/10/10 15:53:52 art Exp $ # $NetBSD: genassym.cf,v 1.10 2005/12/11 12:19:00 christos Exp $ #- @@ -54,8 +54,6 @@ member tf_spc struct proc member p_addr -member p_back -member p_forw member p_stat member p_wchan member P_MD_UPTE p_md.md_upte diff --git a/sys/arch/sh/sh/locore_c.c b/sys/arch/sh/sh/locore_c.c index ede226184c7..d1df8aeef7b 100644 --- a/sys/arch/sh/sh/locore_c.c +++ b/sys/arch/sh/sh/locore_c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: locore_c.c,v 1.5 2007/09/09 11:57:55 miod Exp $ */ +/* $OpenBSD: locore_c.c,v 1.6 2007/10/10 15:53:52 art Exp $ */ /* $NetBSD: locore_c.c,v 1.13 2006/03/04 01:13:35 uwe Exp $ */ /*- @@ -127,26 +127,14 @@ #include <sh/ubcreg.h> void (*__sh_switch_resume)(struct proc *); -struct proc *cpu_switch_search(struct proc *); -struct proc *cpu_switch_prepare(struct proc *, struct proc *); -void switch_exit(struct proc *, void (*)(struct proc *)); -void idle(void); +void cpu_switch_prepare(struct proc *, struct proc *); int want_resched; -#ifdef LOCKDEBUG -#define SCHED_LOCK_IDLE() sched_lock_idle() -#define SCHED_UNLOCK_IDLE() sched_unlock_idle() -#else -#define SCHED_LOCK_IDLE() do {} while (/* CONSTCOND */ 0) -#define SCHED_UNLOCK_IDLE() do {} while (/* CONSTCOND */ 0) -#endif - - /* * Prepare context switch from oproc to nproc. - * This code is shared by cpu_switch and cpu_switchto. + * This code is used by cpu_switchto. */ -struct proc * +void cpu_switch_prepare(struct proc *oproc, struct proc *nproc) { nproc->p_stat = SONPROC; @@ -154,10 +142,8 @@ cpu_switch_prepare(struct proc *oproc, struct proc *nproc) if (oproc && (oproc->p_md.md_flags & MDP_STEP)) _reg_write_2(SH_(BBRB), 0); - if (nproc != oproc) { - curpcb = nproc->p_md.md_pcb; - pmap_activate(nproc); - } + curpcb = nproc->p_md.md_pcb; + pmap_activate(nproc); if (nproc->p_md.md_flags & MDP_STEP) { int pm_asid = nproc->p_vmspace->vm_map.pmap->pm_asid; @@ -171,34 +157,6 @@ cpu_switch_prepare(struct proc *oproc, struct proc *nproc) } curproc = nproc; - return (nproc); -} - -/* - * Find the highest priority proc and prepare to switching to it. - */ -struct proc * -cpu_switch_search(struct proc *oproc) -{ - struct prochd *q; - struct proc *p; - - curproc = NULL; - - SCHED_LOCK_IDLE(); - while (sched_is_idle()) { - SCHED_UNLOCK_IDLE(); - idle(); - SCHED_LOCK_IDLE(); - } - - q = &qs[ffs(whichqs) - 1]; - p = q->ph_link; - remrunqueue(p); - want_resched = 0; - SCHED_UNLOCK_IDLE(); - - return (cpu_switch_prepare(oproc, p)); } void @@ -207,24 +165,8 @@ cpu_exit(struct proc *p) if (p->p_md.md_flags & MDP_STEP) _reg_write_2(SH_(BBRB), 0); - switch_exit(p, exit2); -} - -/* - * void idle(void): - * When no processes are on the run queue, wait for something to come - * ready. Separated function for profiling. - */ -void -idle() -{ - spl0(); -#if 0 - if (uvm.page_idle_zero) - uvm_pageidlezero(); -#endif - __asm volatile("sleep"); - splsched(); + pmap_deactivate(p); + sched_exit(p); } #ifndef P1_STACK diff --git a/sys/arch/sh/sh/locore_subr.S b/sys/arch/sh/sh/locore_subr.S index de57709a5d5..5543b4870c6 100644 --- a/sys/arch/sh/sh/locore_subr.S +++ b/sys/arch/sh/sh/locore_subr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore_subr.S,v 1.6 2007/03/02 06:11:54 miod Exp $ */ +/* $OpenBSD: locore_subr.S,v 1.7 2007/10/10 15:53:52 art Exp $ */ /* $NetBSD: locore_subr.S,v 1.28 2006/01/23 22:52:09 uwe Exp $ */ /* @@ -180,27 +180,26 @@ .text .align 5 /* align cache line size (32B) */ /* - * LINTSTUB: Func: void cpu_switch(struct proc *p, struct proc *XXX_IGNORED) - * Find a runnable proc and switch to it. Wait if necessary. + * LINTSTUB: Func: void cpu_switchto(struct proc *old, struct proc *new) + * Switch proc contexts. */ -ENTRY(cpu_switch) - /* Save current proc's context to switchframe */ +ENTRY(cpu_switchto) + mov r4, r0 + cmp/eq #0, r0 + bt 1f + + /* Save old proc's context to switchframe */ mov.l .L_SF, r0 mov.l @(r0, r4), r1 SAVEPCB(r1) add #PCB_FP, r1 SAVEFP(r1, r8, r9) -.L_find_and_switch: - /* Search next proc. cpu_switch_search may or may not sleep. */ - mov.l .L_cpu_switch_search, r0 +1: + mov.l .L_cpu_switch_prepare, r0 jsr @r0 - mov r4, r8 /* save old proc */ - - /* Skip context switch if same proc. */ - cmp/eq r8, r0 - bt/s 1f - mov r0, r4 /* new proc */ + mov r5, r8 /* save new proc */ + mov r8, r4 /* Setup kernel stack */ mov.l .L_SF, r0 @@ -224,7 +223,7 @@ ENTRY(cpu_switch) /* Now OK to use kernel stack. */ /* Restore new proc's context from switchframe */ -1: mov.l .L_SF, r0 + mov.l .L_SF, r0 mov.l @(r0, r4), r1 add #4, r1 /* r15 already restored */ mov.l @r1+, r14 @@ -248,49 +247,9 @@ ENTRY(cpu_switch) nop .align 2 .L_SF: .long (P_MD_PCB) -.L_cpu_switch_search: .long _C_LABEL(cpu_switch_search) +.L_cpu_switch_prepare: .long _C_LABEL(cpu_switch_prepare) FUNC_SYMBOL(switch_resume) - -/* - * LINTSTUB: Func: void switch_exit(struct proc *p, void (*exit_func)(struct proc *)) - * Called only from cpu_exit(p). Before we call exit_func to - * free proc's resources (including kernel stack) we need to - * switch to the proc0's kernel stack. Then we jump into the - * middle of cpu_switch to find and switch to a new proc. - */ -ALTENTRY(switch_exit) - mov.l .L_switch_exit_proc0_pcb, r1 - mov.l .L_switch_exit_curpcb, r0 - mov.l @r1, r1 - mov.l r1, @r0 /* curpcb = proc0.p_md.md_pcb */ - - mov.l @(SF_R7_BANK, r1), r0 /* stack top */ - mov.l @(SF_R6_BANK, r1), r2 /* current frame */ - mov.l @(SF_R15, r1), r3 /* current stack */ - - /* switch to proc0's kernel stack */ - __EXCEPTION_BLOCK(r1, r6) - ldc r0, r7_bank - ldc r2, r6_bank - mov r3, r15 - __EXCEPTION_UNBLOCK(r0, r1) - - /* safe to call (*exit_func)(p); now */ - jsr @r5 - nop /* proc is already in r4 */ - - /* proceed to cpu_switch */ - bra .L_find_and_switch - mov #0, r4 /* no "previous" proc */ - - .align 2 -.L_switch_exit_proc0_pcb: - .long _C_LABEL(proc0) + P_MD_PCB -.L_switch_exit_curpcb: - .long _C_LABEL(curpcb) - - #ifdef SH3 /* * LINTSTUB: Func: void sh3_switch_resume(struct proc *p) diff --git a/sys/arch/sh/sh/sh_machdep.c b/sys/arch/sh/sh/sh_machdep.c index d81017ac0f1..0cfcd801825 100644 --- a/sys/arch/sh/sh/sh_machdep.c +++ b/sys/arch/sh/sh/sh_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sh_machdep.c,v 1.16 2007/06/06 17:15:12 deraadt Exp $ */ +/* $OpenBSD: sh_machdep.c,v 1.17 2007/10/10 15:53:52 art Exp $ */ /* $NetBSD: sh3_machdep.c,v 1.59 2006/03/04 01:13:36 uwe Exp $ */ /* @@ -716,45 +716,6 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack, rval[1] = 0; } -void -setrunqueue(struct proc *p) -{ - int whichq = p->p_priority / PPQ; - struct prochd *q; - struct proc *prev; - -#ifdef DIAGNOSTIC - if (p->p_back != NULL || p->p_wchan != NULL || p->p_stat != SRUN) - panic("setrunqueue"); -#endif - q = &qs[whichq]; - prev = q->ph_rlink; - p->p_forw = (struct proc *)q; - q->ph_rlink = p; - prev->p_forw = p; - p->p_back = prev; - whichqs |= 1 << whichq; -} - -void -remrunqueue(struct proc *p) -{ - struct proc *prev, *next; - int whichq = p->p_priority / PPQ; - -#ifdef DIAGNOSTIC - if (((whichqs & (1 << whichq)) == 0)) - panic("remrunqueue: bit %d not set", whichq); -#endif - prev = p->p_back; - p->p_back = NULL; - next = p->p_forw; - prev->p_forw = next; - next->p_back = prev; - if (prev == next) - whichqs &= ~(1 << whichq); -} - /* * Jump to reset vector. */ |