diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-04-04 09:13:45 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-04-04 09:13:45 +0000 |
commit | e3d945ed15500a4d6948e232558e78f188742b13 (patch) | |
tree | 05b9726746bc1c667c598aec1a2f1f450a66422c /sys/arch/arm | |
parent | e93aecfc5a96a5cc655fc230981e0e46c4df87a5 (diff) |
Store curcpu pointer in TPIDRPRW.
This will especially be helpful in future multiprocessor efforts.
ok jsg@
Diffstat (limited to 'sys/arch/arm')
-rw-r--r-- | sys/arch/arm/arm/bcopyinout.S | 83 | ||||
-rw-r--r-- | sys/arch/arm/arm/copystr.S | 28 | ||||
-rw-r--r-- | sys/arch/arm/arm/cpuswitch7.S | 23 | ||||
-rw-r--r-- | sys/arch/arm/arm/irq_dispatch.S | 6 | ||||
-rw-r--r-- | sys/arch/arm/arm/locore.S | 10 | ||||
-rw-r--r-- | sys/arch/arm/include/cpu.h | 15 |
6 files changed, 70 insertions, 95 deletions
diff --git a/sys/arch/arm/arm/bcopyinout.S b/sys/arch/arm/arm/bcopyinout.S index 4d423e55797..93ef118a1d4 100644 --- a/sys/arch/arm/arm/bcopyinout.S +++ b/sys/arch/arm/arm/bcopyinout.S @@ -1,4 +1,4 @@ -/* $OpenBSD: bcopyinout.S,v 1.3 2013/09/12 11:43:51 patrick Exp $ */ +/* $OpenBSD: bcopyinout.S,v 1.4 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: bcopyinout.S,v 1.13 2003/10/31 16:54:05 scw Exp $ */ /* @@ -82,18 +82,14 @@ ENTRY(copyin) moveq pc, lr SAVE_REGS -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r2, r14} - bl _C_LABEL(cpu_number) - ldr r4, .Lcpu_info - ldr r4, [r4, r0, lsl #2] - ldr r4, [r4, #CI_CURPCB] - ldmfd sp!, {r0-r2, r14} + +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r4, c13, c0, 4 #else ldr r4, .Lcpu_info_primary - ldr r4, [r4, #CI_CURPCB] #endif + ldr r4, [r4, #CI_CURPCB] ldr r5, [r4, #PCB_ONFAULT] adr r3, .Lcopyfault @@ -305,18 +301,14 @@ ENTRY(copyout) moveq pc, lr SAVE_REGS -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r2, r14} - bl _C_LABEL(cpu_number) - ldr r4, .Lcpu_info - ldr r4, [r4, r0, lsl #2] - ldr r4, [r4, #CI_CURPCB] - ldmfd sp!, {r0-r2, r14} + +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r4, c13, c0, 4 #else ldr r4, .Lcpu_info_primary - ldr r4, [r4, #CI_CURPCB] #endif + ldr r4, [r4, #CI_CURPCB] ldr r5, [r4, #PCB_ONFAULT] adr r3, .Lcopyfault @@ -518,18 +510,14 @@ ENTRY(kcopy) moveq pc, lr SAVE_REGS -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r2, r14} - bl _C_LABEL(cpu_number) - ldr r4, .Lcpu_info - ldr r4, [r4, r0, lsl #2] - ldr r4, [r4, #CI_CURPCB] - ldmfd sp!, {r0-r2, r14} + +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r4, c13, c0, 4 #else ldr r4, .Lcpu_info_primary - ldr r4, [r4, #CI_CURPCB] #endif + ldr r4, [r4, #CI_CURPCB] ldr r5, [r4, #PCB_ONFAULT] adr r3, .Lcopyfault @@ -711,18 +699,13 @@ ENTRY(kcopy) * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_1) -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r1, r14} - bl _C_LABEL(cpu_number) - ldr r2, .Lcpu_info - ldr r2, [r2, r0, lsl #2] - ldr r2, [r2, #CI_CURPCB] - ldmfd sp!, {r0-r1, r14} +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r2, c13, c0, 4 #else ldr r2, .Lcpu_info_primary - ldr r2, [r2, #CI_CURPCB] #endif + ldr r2, [r2, #CI_CURPCB] ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f str r3, [r2, #PCB_ONFAULT] @@ -745,18 +728,13 @@ ENTRY(badaddr_read_1) * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_2) -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r1, r14} - bl _C_LABEL(cpu_number) - ldr r2, .Lcpu_info - ldr r2, [r2, r0, lsl #2] - ldr r2, [r2, #CI_CURPCB] - ldmfd sp!, {r0-r1, r14} +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r2, c13, c0, 4 #else ldr r2, .Lcpu_info_primary - ldr r2, [r2, #CI_CURPCB] #endif + ldr r2, [r2, #CI_CURPCB] ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f str r3, [r2, #PCB_ONFAULT] @@ -779,18 +757,13 @@ ENTRY(badaddr_read_2) * else EFAULT if a page fault occurred. */ ENTRY(badaddr_read_4) -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r1, r14} - bl _C_LABEL(cpu_number) - ldr r2, .Lcpu_info - ldr r2, [r2, r0, lsl #2] - ldr r2, [r2, #CI_CURPCB] - ldmfd sp!, {r0-r1, r14} +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r2, c13, c0, 4 #else ldr r2, .Lcpu_info_primary - ldr r2, [r2, #CI_CURPCB] #endif + ldr r2, [r2, #CI_CURPCB] ldr ip, [r2, #PCB_ONFAULT] adr r3, 1f str r3, [r2, #PCB_ONFAULT] diff --git a/sys/arch/arm/arm/copystr.S b/sys/arch/arm/arm/copystr.S index 3723f1860f3..d588c520971 100644 --- a/sys/arch/arm/arm/copystr.S +++ b/sys/arch/arm/arm/copystr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: copystr.S,v 1.4 2013/09/12 11:43:51 patrick Exp $ */ +/* $OpenBSD: copystr.S,v 1.5 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: copystr.S,v 1.8 2002/10/13 14:54:48 bjh21 Exp $ */ /* @@ -104,18 +104,13 @@ ENTRY(copyinstr) moveq r0, #ENAMETOOLONG beq 2f -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r3, r14} - bl _C_LABEL(cpu_number) - ldr r4, .Lcpu_info - ldr r4, [r4, r0, lsl #2] - ldr r4, [r4, #CI_CURPCB] - ldmfd sp!, {r0-r3, r14} +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r4, c13, c0, 4 #else ldr r4, .Lcpu_info_primary - ldr r4, [r4, #CI_CURPCB] #endif + ldr r4, [r4, #CI_CURPCB] #ifdef DEBUG teq r4, #0x00000000 @@ -161,18 +156,13 @@ ENTRY(copyoutstr) moveq r0, #ENAMETOOLONG beq 2f -#ifdef MULTIPROCESSOR - /* XXX Probably not appropriate for non-Hydra SMPs */ - stmfd sp!, {r0-r3, r14} - bl _C_LABEL(cpu_number) - ldr r4, .Lcpu_info - ldr r4, [r4, r0, lsl #2] - ldr r4, [r4, #CI_CURPCB] - ldmfd sp!, {r0-r3, r14} +#ifdef CPU_ARMv7 + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r4, c13, c0, 4 #else ldr r4, .Lcpu_info_primary - ldr r4, [r4, #CI_CURPCB] #endif + ldr r4, [r4, #CI_CURPCB] #ifdef DEBUG teq r4, #0x00000000 diff --git a/sys/arch/arm/arm/cpuswitch7.S b/sys/arch/arm/arm/cpuswitch7.S index 70aeb0959f2..43bf7da5906 100644 --- a/sys/arch/arm/arm/cpuswitch7.S +++ b/sys/arch/arm/arm/cpuswitch7.S @@ -1,4 +1,4 @@ -/* $OpenBSD: cpuswitch7.S,v 1.5 2016/04/03 12:04:59 patrick Exp $ */ +/* $OpenBSD: cpuswitch7.S,v 1.6 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: cpuswitch.S,v 1.41 2003/11/15 08:44:18 scw Exp $ */ /* @@ -105,13 +105,6 @@ .text -.Lcpu_info_primary: - .word _C_LABEL(cpu_info_primary) -.Lcurproc: - .word _C_LABEL(cpu_info_primary) + CI_CURPROC -.Lcurpcb: - .word _C_LABEL(cpu_info_primary) + CI_CURPCB - .Lcpufuncs: .word _C_LABEL(cpufuncs) @@ -166,10 +159,10 @@ ENTRY(cpu_idle_leave) ENTRY(cpu_switchto) stmfd sp!, {r4-r7, lr} + /* Get curcpu from TPIDRPRW. */ + mrc p15, 0, r3, c13, c0, 4 #ifdef MULTIPROCESSOR - /* XXX use curcpu() */ - ldr r2, .Lcpu_info_primary - str r2, [r1, #(P_CPU)] + str r3, [r1, #(P_CPU)] #else /* p->p_cpu initialized in fork1() for single-processor */ #endif @@ -179,14 +172,12 @@ ENTRY(cpu_switchto) strb r2, [r1, #(P_STAT)] /* We have a new curproc now so make a note it */ - ldr r7, .Lcurproc - str r1, [r7] + str r1, [r3, #(CI_CURPROC)] /* Hook in a new pcb */ - ldr r7, .Lcurpcb - ldr r6, [r7] /* Remember the old PCB */ + ldr r6, [r3, #(CI_CURPCB)] /* Remember the old PCB */ ldr r2, [r1, #(P_ADDR)] - str r2, [r7] + str r2, [r3, #(CI_CURPCB)] /* * If the old proc on entry to cpu_switch was zero then the diff --git a/sys/arch/arm/arm/irq_dispatch.S b/sys/arch/arm/arm/irq_dispatch.S index c84b131fecd..2fc274bf391 100644 --- a/sys/arch/arm/arm/irq_dispatch.S +++ b/sys/arch/arm/arm/irq_dispatch.S @@ -1,4 +1,4 @@ -/* $OpenBSD: irq_dispatch.S,v 1.9 2013/09/12 11:42:22 patrick Exp $ */ +/* $OpenBSD: irq_dispatch.S,v 1.10 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: irq_dispatch.S,v 1.5 2003/10/30 08:57:24 scw Exp $ */ /* @@ -105,7 +105,11 @@ ASENTRY_NP(irq_entry) * r5 address of the curcpu struct * r6 old value of curcpu()->ci_idepth */ +#ifdef CPU_ARMv7 + mrc p15, 0, r5, c13, c0, 4 /* Get curcpu from TPIDRPRW. */ +#else ldr r5, .Lcpu_info_primary +#endif mov r0, sp /* arg for dispatcher */ ldr r6, [r5, #CI_IDEPTH] add r1, r6, #1 diff --git a/sys/arch/arm/arm/locore.S b/sys/arch/arm/arm/locore.S index 6fb7b6276d1..b91d060e74e 100644 --- a/sys/arch/arm/arm/locore.S +++ b/sys/arch/arm/arm/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.8 2016/01/31 00:14:50 jsg Exp $ */ +/* $OpenBSD: locore.S,v 1.9 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: locore.S,v 1.14 2003/04/20 16:21:40 thorpej Exp $ */ /* @@ -56,7 +56,12 @@ ASENTRY_NP(start) mov r5, r1 mov r6, r2 adr r1, .Lstart - ldmia r1, {r1, r2, sp} /* Set initial stack and */ + ldmia r1, {r1, r2, r8, sp} /* Set initial stack and */ + +#ifdef CPU_ARMv7 + mcr p15, 0, r8, c13, c0, 4 /* put curcpu into the TPIDRPRW */ +#endif + sub r2, r2, r1 /* get zero init data */ mov r3, #0 @@ -87,6 +92,7 @@ ASENTRY_NP(start) .Lstart: .word _edata .word _end + .word _C_LABEL(cpu_info_primary) .word svcstk + INIT_ARM_STACK_SIZE .Lmainreturned: diff --git a/sys/arch/arm/include/cpu.h b/sys/arch/arm/include/cpu.h index 25879915982..f56c12b7d90 100644 --- a/sys/arch/arm/include/cpu.h +++ b/sys/arch/arm/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.40 2016/01/31 00:14:50 jsg Exp $ */ +/* $OpenBSD: cpu.h,v 1.41 2016/04/04 09:13:44 patrick Exp $ */ /* $NetBSD: cpu.h,v 1.34 2003/06/23 11:01:08 martin Exp $ */ /* @@ -208,8 +208,19 @@ struct cpu_info { extern struct cpu_info cpu_info_primary; extern struct cpu_info *cpu_info_list; -#ifndef MULTIPROCESSOR +#ifdef CPU_ARMv7 +static inline struct cpu_info * +curcpu(void) +{ + struct cpu_info *__ci; + __asm volatile("mrc p15, 0, %0, c13, c0, 4" : "=r" (__ci)); + return (__ci); +} +#else #define curcpu() (&cpu_info_primary) +#endif + +#ifndef MULTIPROCESSOR #define cpu_number() 0 #define CPU_IS_PRIMARY(ci) 1 #define CPU_INFO_ITERATOR int |