From d5e7c3b7af60f12ae3214e70da62fbcb72cc3204 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Sun, 2 Feb 2014 23:29:51 +0000 Subject: [PATCH] Only use the CPU ID register if SMP is defined. Some non-MPCore armv6 cpu, such as the one found in the RPi, don't have it, and just hang when we try to access it. --- sys/arm/arm/swtch.S | 5 ++--- sys/arm/include/pcpu.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/arm/arm/swtch.S b/sys/arm/arm/swtch.S index f1371a1f695..133b0d949ef 100644 --- a/sys/arm/arm/swtch.S +++ b/sys/arm/arm/swtch.S @@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$"); #define DOMAIN_CLIENT 0x01 -#ifdef _ARM_ARCH_6 +#if defined(_ARM_ARCH_6) && defined(SMP) #define GET_PCPU(tmp, tmp2) \ mrc p15, 0, tmp, c0, c0, 5; \ and tmp, tmp, #0xf; \ @@ -240,8 +240,7 @@ ENTRY(cpu_switch) /* Process is now on a processor. */ /* We have a new curthread now so make a note it */ GET_PCPU(r7, r2) - add r7, r7, #PC_CURTHREAD - str r1, [r7] + str r1, [r7, #PC_CURTHREAD] #ifndef ARM_TP_ADDRESS mcr p15, 0, r1, c13, c0, 4 #endif diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h index 94ce6b93b16..1771a8e821a 100644 --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -65,11 +65,15 @@ extern struct pcpu *pcpup; #define CPU_MASK (0xf) +#ifndef SMP +#define get_pcpu() (pcpup) +#else #define get_pcpu() __extension__ ({ \ int id; \ __asm __volatile("mrc p15, 0, %0, c0, c0, 5" : "=r" (id)); \ (pcpup + (id & CPU_MASK)); \ }) +#endif static inline struct thread * get_curthread(void)