summaryrefslogtreecommitdiff
path: root/sys/arch/mips64
diff options
context:
space:
mode:
authorTakuya ASADA <syuu@cvs.openbsd.org>2009-09-15 04:54:32 +0000
committerTakuya ASADA <syuu@cvs.openbsd.org>2009-09-15 04:54:32 +0000
commit420c66102dff0eb493dc933d0e433b49fdc40e05 (patch)
treec98e189cec3bb4b92d0334be689d7adc1ab53085 /sys/arch/mips64
parentfb4d0ae558e48da59c8660b0547bfe00cf9ca436 (diff)
cpu status flag, cpuid added to cpu_info.
cpu_info pointer array, cpu_info iterator, cpu_number() implementation added. constraint modifier fixed in lock.h to output correct assembly. calling proc_trampoline_mp in exception.S.
Diffstat (limited to 'sys/arch/mips64')
-rw-r--r--sys/arch/mips64/include/cpu.h52
-rw-r--r--sys/arch/mips64/include/lock.h6
-rw-r--r--sys/arch/mips64/mips64/cpu.c50
-rw-r--r--sys/arch/mips64/mips64/exception.S6
4 files changed, 95 insertions, 19 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index 0de6f4cc98a..cf133a71d95 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.35 2009/08/06 21:54:27 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.36 2009/09/15 04:54:31 syuu Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -356,38 +356,64 @@ extern vaddr_t uncached_base;
#ifndef _LOCORE
+#include <sys/device.h>
+#include <sys/lock.h>
#include <sys/sched.h>
+#include <machine/intr.h>
+
struct cpu_info {
+ struct device ci_dev; /* our device */
+ struct cpu_info *ci_self; /* pointer to this structure */
+ struct cpu_info *ci_next; /* next cpu */
struct proc *ci_curproc;
struct schedstate_percpu
ci_schedstate;
int ci_want_resched; /* need_resched() invoked */
-
+ cpuid_t ci_cpuid; /* our CPU ID */
u_int32_t ci_randseed; /* per cpu random seed */
+#ifdef MULTIPROCESSOR
+ u_long ci_flags; /* flags; see below */
+#endif
};
+#define CPUF_PRIMARY 0x01 /* CPU is primary CPU */
+#define CPUF_PRESENT 0x02 /* CPU is present */
+#define CPUF_RUNNING 0x04 /* CPU is running */
+
extern struct cpu_info cpu_info_primary;
+extern struct cpu_info *cpu_info_list;
+#define CPU_INFO_ITERATOR int
+#define CPU_INFO_FOREACH(cii, ci) for (cii = 0, ci = cpu_info_list; \
+ ci != NULL; ci = ci->ci_next)
-#define curcpu() (&cpu_info_primary)
+#define CPU_INFO_UNIT(ci) ((ci)->ci_dev.dv_unit)
-#define CPU_IS_PRIMARY(ci) 1
-#define CPU_INFO_ITERATOR int
-#define CPU_INFO_FOREACH(cii, ci) \
- for (cii = 0, ci = curcpu(); ci != NULL; ci = NULL)
-#define CPU_INFO_UNIT(ci) 0
-#define MAXCPUS 1
-#define cpu_unidle(ci)
+#ifdef MULTIPROCESSOR
+#define MAXCPUS 4
+#define curcpu() (cpu_info[cpu_number()])
+#define CPU_IS_PRIMARY(ci) ((ci)->ci_flags & CPUF_PRIMARY)
+#define cpu_number() hw_cpu_number()
-#define cpu_number() 0
+extern struct cpuset cpus_running;
+extern struct cpu_info *cpu_info[];
+void cpu_unidle(struct cpu_info *);
+void cpu_boot_secondary_processors(void);
+
+#include <sys/mplock.h>
+#else
+#define MAXCPUS 1
+#define curcpu() (&cpu_info_primary)
+#define CPU_IS_PRIMARY(ci) 1
+#define cpu_number() 0
+#define cpu_unidle(ci)
+#endif
#include <machine/frame.h>
#endif /* _LOCORE */
-#include <machine/intr.h>
-
#ifndef _LOCORE
/*
diff --git a/sys/arch/mips64/include/lock.h b/sys/arch/mips64/include/lock.h
index be9b39b8e4c..7bd7cc71727 100644
--- a/sys/arch/mips64/include/lock.h
+++ b/sys/arch/mips64/include/lock.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock.h,v 1.1 2007/05/01 18:56:30 miod Exp $ */
+/* $OpenBSD: lock.h,v 1.2 2009/09/15 04:54:31 syuu Exp $ */
/* public domain */
@@ -27,7 +27,7 @@ __cpu_simple_lock(__cpu_simple_lock_t *l)
("1:\tll\t%0, %1\n"
"\tsc\t%2, %1\n"
"\tbeqz\t%2, 1b\n"
- "\t nop" : "=r" (old) : "m" (*l), "r" (new));
+ "\t nop" : "=&r" (old) : "m" (*l), "r" (new));
} while (old != __SIMPLELOCK_UNLOCKED);
}
@@ -40,7 +40,7 @@ __cpu_simple_lock_try(__cpu_simple_lock_t *l)
("1:\tll\t%0, %1\n"
"\tsc\t%2, %1\n"
"\tbeqz\t%2, 1b\n"
- "\t nop" : "=r" (old) : "m" (*l), "r" (new));
+ "\t nop" : "=&r" (old) : "m" (*l), "r" (new));
return (old == __SIMPLELOCK_UNLOCKED);
}
diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c
index 1fe040d6e13..747b7a6ed00 100644
--- a/sys/arch/mips64/mips64/cpu.c
+++ b/sys/arch/mips64/mips64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.13 2009/08/06 21:11:39 miod Exp $ */
+/* $OpenBSD: cpu.c,v 1.14 2009/09/15 04:54:31 syuu Exp $ */
/*
* Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se)
@@ -39,6 +39,17 @@ int cpumatch(struct device *, void *, void *);
void cpuattach(struct device *, struct device *, void *);
struct cpu_info cpu_info_primary;
+struct cpu_info *cpu_info_list = &cpu_info_primary;
+#ifdef MULTIPROCESSOR
+struct cpuset cpus_running;
+
+/*
+ * Array of CPU info structures. Must be statically-allocated because
+ * curproc, etc. are used early.
+ */
+
+struct cpu_info *cpu_info[MAXCPUS] = { &cpu_info_primary };
+#endif
u_int CpuPrimaryInstCacheSize;
u_int CpuPrimaryInstCacheLSize;
@@ -59,7 +70,7 @@ u_int CpuOnboardCacheOn; /* RM7K */
int cpu_is_rm7k = 0;
struct cfattach cpu_ca = {
- sizeof(struct device), cpumatch, cpuattach
+ sizeof(struct cpu_info), cpumatch, cpuattach
};
struct cfdriver cpu_cd = {
NULL, "cpu", DV_DULL, NULL, 0
@@ -83,10 +94,33 @@ cpumatch(struct device *parent, void *match, void *aux)
void
cpuattach(struct device *parent, struct device *dev, void *aux)
{
+ struct cpu_info *ci = (struct cpu_info *)dev;
int cpuno = dev->dv_unit;
int isr16k = 0;
int displayver;
+#ifdef MULTIPROCESSOR
+ cpuset_add(&cpus_running, ci);
+#endif
+ if(cpuno == 0) {
+ ci = &cpu_info_primary;
+#ifdef MULTIPROCESSOR
+ ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
+#endif
+ bcopy(dev, &ci->ci_dev, sizeof *dev);
+ }
+#ifdef MULTIPROCESSOR
+ else {
+ ci->ci_next = cpu_info_list->ci_next;
+ cpu_info_list->ci_next = ci;
+ ci->ci_flags |= CPUF_PRESENT;
+ }
+ cpu_info[cpuno] = ci;
+ ncpus++;
+#endif
+ ci->ci_self = ci;
+ ci->ci_cpuid = cpuno;
+
printf(": ");
displayver = 1;
@@ -276,3 +310,15 @@ cpuattach(struct device *parent, struct device *dev, void *aux)
printf("cpu%d: Status Register %x\n", cpuno, CpuStatusRegister);
#endif
}
+
+#ifdef MULTIPROCESSOR
+void
+cpu_boot_secondary_processors(void)
+{
+}
+
+void
+cpu_unidle(struct cpu_info *ci)
+{
+}
+#endif
diff --git a/sys/arch/mips64/mips64/exception.S b/sys/arch/mips64/mips64/exception.S
index 9f59cef068b..6f3c8dccfec 100644
--- a/sys/arch/mips64/mips64/exception.S
+++ b/sys/arch/mips64/mips64/exception.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: exception.S,v 1.20 2009/06/10 18:05:31 miod Exp $ */
+/* $OpenBSD: exception.S,v 1.21 2009/09/15 04:54:31 syuu Exp $ */
/*
* Copyright (c) 2002-2003 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -505,6 +505,10 @@ END(u_general)
* Setup for and return to user.
*/
LEAF(proc_trampoline, 0)
+#ifdef MULTIPROCESSOR
+ jal _C_LABEL(proc_trampoline_mp)
+ nop
+#endif
/*
* Enable interrupts, since we want kernel threads to
* start at spl0 and with interrupts enabled, and these