summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/hppa/dev/cpu.c10
-rw-r--r--sys/arch/hppa/hppa/locore.S55
-rw-r--r--sys/arch/hppa/hppa/machdep.c4
-rw-r--r--sys/arch/hppa/include/cpu.h42
-rw-r--r--sys/lib/libkern/arch/hppa/spcopy.S8
5 files changed, 73 insertions, 46 deletions
diff --git a/sys/arch/hppa/dev/cpu.c b/sys/arch/hppa/dev/cpu.c
index e86108ea2bd..e829707bb69 100644
--- a/sys/arch/hppa/dev/cpu.c
+++ b/sys/arch/hppa/dev/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.31 2010/03/28 16:26:47 jsing Exp $ */
+/* $OpenBSD: cpu.c,v 1.32 2010/04/01 12:30:38 jsing Exp $ */
/*
* Copyright (c) 1998-2003 Michael Shalayeff
@@ -93,9 +93,17 @@ cpuattach(parent, self, aux)
extern int cpu_hardclock(void *);
struct cpu_softc *sc = (struct cpu_softc *)self;
+ struct confargs *ca = (struct confargs *)aux;
+ struct cpu_info *ci;
u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom;
+ int cpuno = self->dv_unit;
const char *p;
+ ci = &cpu_info[cpuno];
+ ci->ci_dev = self;
+ ci->ci_cpuid = cpuno;
+ ci->ci_hpa = ca->ca_hpa;
+
printf (": %s ", cpu_typename);
if (pdc_model.hvers) {
static const char lvls[4][4] = { "0", "1", "1.5", "2" };
diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S
index 3eaf475ff93..47f76baa2f1 100644
--- a/sys/arch/hppa/hppa/locore.S
+++ b/sys/arch/hppa/hppa/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.165 2010/03/27 17:46:59 deraadt Exp $ */
+/* $OpenBSD: locore.S,v 1.166 2010/04/01 12:30:38 jsing Exp $ */
/*
* Copyright (c) 1998-2004 Michael Shalayeff
@@ -92,17 +92,13 @@
.import boothowto, data
.import bootdev, data
.import esym, data
- .import curproc, data
- .import cpu_info_primary, data
+ .import cpu_info, data
.import virtual_avail, data
.import proc0, data
.import proc0paddr, data
.import kpsw, data
.import panic, code
-#define curproc (cpu_info_primary + CI_CURPROC)
-#define cpl (cpu_info_primary + CI_CPL)
-
#define EMRG_STACKSIZE (1*NBPG)
#define FPEMU_STACKSIZE (1*NBPG)
@@ -217,6 +213,11 @@ $start_zero_tf
*/
mtctl r0, ccr
+ /* Store pointer to cpu_info in CR29. */
+ ldil L%cpu_info, r1
+ ldo R%cpu_info(r1), r1
+ mtctl r1, cr29
+
copy sp, arg1
ldil L%$qisnowon, rp
ldo R%$qisnowon(rp), rp
@@ -561,8 +562,8 @@ $syscall
* t4: user stack
*
*/
- ldil L%curproc, t2
- ldw R%curproc(sr1, t2), t2
+ mfctl cr29, t2
+ ldw CI_CURPROC(sr1, t2), t2
ldw P_ADDR(sr1, t2), t3 /* XXX can use ,sl */
/* calculate kernel sp, load, create kernel stack frame */
@@ -697,8 +698,8 @@ $syscall
bv,n 0(r1)
nop
- ldil L%curproc, r1
- ldw R%curproc(r1), r1
+ mfctl cr29, r1
+ ldw CI_CURPROC(r1), r1
ldw P_MD_REGS(r1), t3
.exit
@@ -1628,8 +1629,8 @@ ENTRY(TLABEL(all),0)
comb,<> t1, t2, $trap_from_kernel
dep r0, 31, 6, sp
- ldil L%curproc, t2
- ldw R%curproc(t2), t2
+ mfctl cr29, t2
+ ldw CI_CURPROC(t2), t2
depi 1, T_USER_POS, 1, r1
depi 1, TFF_LAST_POS, 1, r1
ldw P_ADDR(t2), sp
@@ -1816,8 +1817,8 @@ $trapnowvirt
b $syscall_return
/* see if curproc have really changed */
- ldil L%curproc, t1
- ldw R%curproc(t1), t2
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t2
sub,<> r0, t2, r0
ldw P_MD_REGS(t2), t3
@@ -2146,8 +2147,8 @@ $intr_cont
ldil L%ipending, r25
stw r24, R%ipending(r25)
- ldil L%cpl, r17
- ldw R%cpl(r17), r17
+ mfctl cr29, r17
+ ldw CI_CPL(r17), r17
ldil L%imask, r16
ldo R%imask(r16), r16
ldwx,s r17(r16), r25
@@ -2269,10 +2270,10 @@ $ibrk_spllower
ldw R%ipending(r8), r8
ldil L%imask, r9
ldo R%imask(r9), r9
- ldil L%cpl, r17
- ldw R%cpl(r17), ret0
+ mfctl cr29, r17
+ ldw CI_CPL(r17), ret0
ldwx,s arg0(r9), r16
- stw arg0, R%cpl(r17)
+ stw arg0, CI_CPL(r17)
ldi T_INTERRUPT, r1
andcm,= r8, r16, r0
b TLABEL(all)
@@ -2716,8 +2717,8 @@ LEAF_ENTRY(spstrcpy)
add t2, arg1, t2
stw rp, HPPA_FRAME_CRP(sp)
/* setup fault handler */
- ldil L%curproc, t1
- ldw R%curproc(t1), t3
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t3
ldil L%copy_on_fault, t4
ldw P_ADDR(t3), r2
ldo R%copy_on_fault(t4), t4
@@ -2805,8 +2806,8 @@ kstack_ok
/* Record new proc. */
ldi SONPROC, t1
stb t1, P_STAT(arg1)
- ldil L%curproc, t1
- stw arg1, R%curproc(t1)
+ mfctl cr29, t1
+ stw arg1, CI_CURPROC(t1)
/* If old process exited, don't bother. */
comb,=,n r0, arg0, switch_exited
@@ -2906,14 +2907,14 @@ ENTRY(switch_trampoline,0)
copy r4, arg0
copy r3, t4
#endif
- ldil L%cpl, t1
- stw r0, R%cpl(t1)
+ mfctl cr29, t1
+ stw r0, CI_CPL(t1)
.call
blr r0, rp
bv,n r0(t4)
nop
- ldil L%curproc, t1
- ldw R%curproc(t1), t2
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t2
.call
b $syscall_return
ldw P_MD_REGS(t2), t3
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 8da55d1e8c4..4dc7b7a890a 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.179 2009/12/31 12:52:35 jsing Exp $ */
+/* $OpenBSD: machdep.c,v 1.180 2010/04/01 12:30:38 jsing Exp $ */
/*
* Copyright (c) 1999-2003 Michael Shalayeff
@@ -116,7 +116,7 @@ int dcache_stride, dcache_line_mask;
*/
volatile u_int8_t *machine_ledaddr;
int machine_ledword, machine_leds;
-struct cpu_info cpu_info_primary;
+struct cpu_info cpu_info[HPPA_MAXCPUS];
/*
* CPU params (should be the same for all cpus in the system)
diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h
index c853e9dd93b..09d8a862d07 100644
--- a/sys/arch/hppa/include/cpu.h
+++ b/sys/arch/hppa/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.64 2010/03/28 16:26:47 jsing Exp $ */
+/* $OpenBSD: cpu.h,v 1.65 2010/04/01 12:30:38 jsing Exp $ */
/*
* Copyright (c) 2000-2004 Michael Shalayeff
@@ -64,10 +64,15 @@
#ifndef _LOCORE
#ifdef _KERNEL
+#include <sys/device.h>
#include <sys/queue.h>
#include <sys/sched.h>
struct cpu_info {
+ struct device *ci_dev;
+ int ci_cpuid;
+ hppa_hpa_t ci_hpa;
+
struct proc *ci_curproc;
volatile int ci_cpl;
@@ -78,17 +83,34 @@ struct cpu_info {
u_int32_t ci_randseed;
};
-extern struct cpu_info cpu_info_primary;
+#ifdef MULTIPROCESSOR
+#define HPPA_MAXCPUS 1
+#else
+#define HPPA_MAXCPUS 4
+#endif
+
+extern struct cpu_info cpu_info[HPPA_MAXCPUS];
+
+#define MAXCPUS HPPA_MAXCPUS
+
+static __inline struct cpu_info *
+curcpu(void)
+{
+ struct cpu_info *ci;
+
+ asm volatile ("mfctl %%cr29, %0" : "=r"(ci));
+
+ return ci;
+}
+
+#define cpu_number() (curcpu()->ci_cpuid)
-#define curcpu() (&cpu_info_primary)
+#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0)
+#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
+#define CPU_INFO_ITERATOR int
+#define CPU_INFO_FOREACH(cii, ci) \
+ for (cii = 0, ci = &cpu_info[0]; cii < ncpus; cii++, ci++)
-#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_number() 0
#define cpu_unidle(ci)
/* types */
diff --git a/sys/lib/libkern/arch/hppa/spcopy.S b/sys/lib/libkern/arch/hppa/spcopy.S
index f84960757bc..c7621663ad4 100644
--- a/sys/lib/libkern/arch/hppa/spcopy.S
+++ b/sys/lib/libkern/arch/hppa/spcopy.S
@@ -48,12 +48,8 @@
*
* assumes that spaces do not clash, otherwise we lose
*/
- .import curproc, data
- .import cpu_info_primary, data
.import copy_on_fault, code
-#define curproc (cpu_info_primary + CI_CURPROC)
-
LEAF_ENTRY(spcopy)
ldw HPPA_FRAME_ARG(4)(sp), ret0
sub,<> r0, ret0, r0
@@ -63,8 +59,8 @@ LEAF_ENTRY(spcopy)
ldo 64(sp), sp
stw rp, HPPA_FRAME_CRP(sp)
/* setup fault handler */
- ldil L%curproc, t1
- ldw R%curproc(t1), t3
+ mfctl cr29, t1
+ ldw CI_CURPROC(t1), t3
ldil L%copy_on_fault, t2
ldw P_ADDR(t3), r2
ldo R%copy_on_fault(t2), t2