summaryrefslogtreecommitdiff
path: root/sys/arch/luna88k
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2007-10-10 15:53:54 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2007-10-10 15:53:54 +0000
commite51062c8cca21a333603b567563e3b84f74ddac0 (patch)
treedccf12b7d5ef806260203fe60b2bcaf94260c651 /sys/arch/luna88k
parent34c540de32da6090afdcdd6fee481f9a2df345fd (diff)
Make context switching much more MI:
- Move the functionality of choosing a process from cpu_switch into a much simpler function: cpu_switchto. Instead of having the locore code walk the run queues, let the MI code choose the process we want to run and only implement the context switching itself in MD code. - Let MD context switching run without worrying about spls or locks. - Instead of having the idle loop implemented with special contexts in MD code, implement one idle proc for each cpu. make the idle loop MI with MD hooks. - Change the proc lists from the old style vax queues to TAILQs. - Change the sleep queue from vax queues to TAILQs. This makes wakeup() go from O(n^2) to O(n) there will be some MD fallout, but it will be fixed shortly. There's also a few cleanups to be done after this. deraadt@, kettenis@ ok
Diffstat (limited to 'sys/arch/luna88k')
-rw-r--r--sys/arch/luna88k/luna88k/locore.S35
-rw-r--r--sys/arch/luna88k/luna88k/machdep.c28
2 files changed, 24 insertions, 39 deletions
diff --git a/sys/arch/luna88k/luna88k/locore.S b/sys/arch/luna88k/luna88k/locore.S
index 81a5477308a..9f8e0ec9a2e 100644
--- a/sys/arch/luna88k/luna88k/locore.S
+++ b/sys/arch/luna88k/luna88k/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.13 2007/01/12 21:41:53 aoyama Exp $ */
+/* $OpenBSD: locore.S,v 1.14 2007/10/10 15:53:52 art Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -150,8 +150,8 @@ ASLOCAL(main_start)
* Now we will compete with the other processors to see which one
* will be elected as the main one.
*/
- or.u r11, r0, hi16(_ASM_LABEL(cpu_mutex))
- or r11, r11, lo16(_ASM_LABEL(cpu_mutex))
+ or.u r11, r0, hi16(_C_LABEL(cpu_mutex))
+ or r11, r11, lo16(_C_LABEL(cpu_mutex))
1:
FLUSH_PIPELINE
or r22, r0, 1
@@ -282,15 +282,6 @@ ASLOCAL(secondary_init)
bsr.n _C_LABEL(secondary_pre_main) /* set cpu number */
or r31, r31, lo16(_ASM_LABEL(slavestack_end))
- /*
- * Release cpu_mutex; we have a race with other secondary CPUs here
- * because the stack has not been switched yet. However, since our
- * interrupts are disabled, the worst we can get is an NMI, and, oh
- * well, it means we're in deep trouble anyway.
- */
- or.u r10, r0, hi16(_ASM_LABEL(cpu_mutex))
- st r0, r10, lo16(_ASM_LABEL(cpu_mutex))
-
ldcr r2, CPU
1:
ld r3, r2, CI_CURPCB
@@ -299,13 +290,6 @@ ASLOCAL(secondary_init)
br.n _C_LABEL(secondary_main)
add r31, r3, USIZE /* switch to idle stack */
- /*
- * At this point, the CPU has been correctly initialized and has
- * identified itself on the console.
- * All it needs now is to jump to the idle loop and wait for work to
- * be offered.
- */
- br _ASM_LABEL(cpu_switch_search)
#else
/*
@@ -315,15 +299,6 @@ ASLOCAL(secondary_init)
#endif /* MULTIPROCESSOR */
- /*
- * Release the cpu_mutex; secondary processors will now have their
- * chance to initialize.
- */
-GLOBAL(cpu_boot_secondary_processors)
- or.u r2, r0, hi16(_ASM_LABEL(cpu_mutex))
- jmp.n r1
- st r0, r2, lo16(_ASM_LABEL(cpu_mutex))
-
/*
* void delay(int count)
*
@@ -384,10 +359,6 @@ GLOBAL(proc0paddr)
ASLOCAL(master_mpu)
word 0
-/* XMEM spin lock -- controls access to master_mpu */
-ASLOCAL(cpu_mutex)
- word 0
-
#if defined(DDB) || NKSYMS > 0
GLOBAL(esym)
word 0
diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c
index 0a40e973bd7..bc12f69d4fb 100644
--- a/sys/arch/luna88k/luna88k/machdep.c
+++ b/sys/arch/luna88k/luna88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.44 2007/06/06 17:15:12 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.45 2007/10/10 15:53:52 art Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -85,6 +85,7 @@
#include <machine/cmmu.h>
#include <machine/cpu.h>
#include <machine/kcore.h>
+#include <machine/lock.h>
#include <machine/reg.h>
#include <machine/trap.h>
#include <machine/m88100.h>
@@ -105,6 +106,7 @@
caddr_t allocsys(caddr_t);
void consinit(void);
+void cpu_boot_secondary_processors(void);
void dumpconf(void);
void dumpsys(void);
int getcpuspeed(void);
@@ -183,6 +185,8 @@ int physmem; /* available physical memory, in pages */
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
+__cpu_simple_lock_t cpu_mutex = __SIMPLELOCK_UNLOCKED;
+
/*
* Declare these as initialized data so we can patch them.
*/
@@ -756,6 +760,16 @@ abort:
#ifdef MULTIPROCESSOR
/*
+ * Release the cpu_mutex; secondary processors will now have their
+ * chance to initialize.
+ */
+void
+cpu_boot_secondary_processors()
+{
+ __cpu_simple_unlock(&cpu_mutex);
+}
+
+/*
* Secondary CPU early initialization routine.
* Determine CPU number and set it, then allocate the idle pcb (and stack).
*
@@ -793,17 +807,18 @@ void
secondary_main()
{
struct cpu_info *ci = curcpu();
+ int s;
cpu_configuration_print(0);
+ sched_init_cpu(ci);
ncpus++;
+ __cpu_simple_unlock(&cpu_mutex);
microuptime(&ci->ci_schedstate.spc_runtime);
+ ci->ci_curproc = NULL;
- /*
- * Upon return, the secondary cpu bootstrap code in locore will
- * enter the idle loop, waiting for some food to process on this
- * processor.
- */
+ SCHED_LOCK(s);
+ cpu_switchto(NULL, sched_chooseproc());
}
#endif /* MULTIPROCESSOR */
@@ -966,7 +981,6 @@ luna88k_bootstrap()
cpuid_t cpu;
extern void m8820x_initialize_cpu(cpuid_t);
extern void m8820x_set_sapr(cpuid_t, apr_t);
- extern void cpu_boot_secondary_processors(void);
cmmu = &cmmu8820x;