svn commit: r230826 - in projects/armv6/sys/arm: arm include
Grzegorz Bernacki
gber at FreeBSD.org
Tue Jan 31 15:53:12 UTC 2012
Author: gber
Date: Tue Jan 31 15:53:11 2012
New Revision: 230826
URL: http://svn.freebsd.org/changeset/base/230826
Log:
Fix set/get pcpu for pre-armv6 cores.
- bring back old pcpu function for pre-armv6 cores
- move pcpu related functions to common file.
Obtained from: Marvell, Semihalf
Modified:
projects/armv6/sys/arm/arm/cpufunc_asm_armv7.S
projects/armv6/sys/arm/arm/machdep.c
projects/armv6/sys/arm/include/cpufunc.h
projects/armv6/sys/arm/include/pcpu.h
Modified: projects/armv6/sys/arm/arm/cpufunc_asm_armv7.S
==============================================================================
--- projects/armv6/sys/arm/arm/cpufunc_asm_armv7.S Tue Jan 31 15:52:17 2012 (r230825)
+++ projects/armv6/sys/arm/arm/cpufunc_asm_armv7.S Tue Jan 31 15:53:11 2012 (r230826)
@@ -241,20 +241,3 @@ ENTRY(armv7_drain_writebuf)
dsb
RET
-/* Use Privileged Thread Id register as a holder for pcpu pointer */
-ENTRY(get_pcpu)
- mrc p15, 0, r0, c13, c0, 4
- RET
-
-ENTRY(set_pcpu)
- mcr p15, 0, r0, c13, c0, 4
- RET
-
-/* Use Privileged Thread Id register as a holder for tls pointer */
-ENTRY(get_tls)
- mrc p15, 0, r0, c13, c0, 3
- RET
-
-ENTRY(set_tls)
- mcr p15, 0, r0, c13, c0, 3
- RET
Modified: projects/armv6/sys/arm/arm/machdep.c
==============================================================================
--- projects/armv6/sys/arm/arm/machdep.c Tue Jan 31 15:52:17 2012 (r230825)
+++ projects/armv6/sys/arm/arm/machdep.c Tue Jan 31 15:53:11 2012 (r230826)
@@ -729,8 +729,9 @@ fake_preload_metadata(void)
void
pcpu0_init(void)
{
-
+#if ARM_ARCH_7A || defined(CPU_MV_PJ4B)
set_pcpu(pcpup);
+#endif
pcpu_init(pcpup, 0, sizeof(struct pcpu));
PCPU_SET(curthread, &thread0);
}
Modified: projects/armv6/sys/arm/include/cpufunc.h
==============================================================================
--- projects/armv6/sys/arm/include/cpufunc.h Tue Jan 31 15:52:17 2012 (r230825)
+++ projects/armv6/sys/arm/include/cpufunc.h Tue Jan 31 15:53:11 2012 (r230826)
@@ -510,10 +510,7 @@ void pj4bv7_setup (char *string);
void pj4bv6_setup (char *string);
void pj4b_config (void);
-int get_core_id (void);
-void set_pcpu (void *);
-void set_tls (void *);
-void *get_tls (void);
+int get_core_id (void);
void armadaxp_idcache_wbinv_all (void);
Modified: projects/armv6/sys/arm/include/pcpu.h
==============================================================================
--- projects/armv6/sys/arm/include/pcpu.h Tue Jan 31 15:52:17 2012 (r230825)
+++ projects/armv6/sys/arm/include/pcpu.h Tue Jan 31 15:53:11 2012 (r230826)
@@ -32,6 +32,7 @@
#ifdef _KERNEL
+#include <machine/cpuconf.h>
#include <machine/frame.h>
#define ALT_STACK_SIZE 128
@@ -48,14 +49,44 @@ struct pcb;
struct pcpu;
extern struct pcpu *pcpup;
+#if ARM_ARCH_6 || ARM_ARCH_7A
+static inline struct pcpu *
+get_pcpu(void)
+{
+ void *pcpu;
+
+ __asm __volatile("mrc p15, 0, %0, c13, c0, 4" : "=r" (pcpu));
+ return (pcpu);
+}
+
+static inline void
+set_pcpu(void *pcpu)
+{
+
+ __asm __volatile("mcr p15, 0, %0, c13, c0, 4" : : "r" (pcpu));
+}
+
+static inline void *
+get_tls(void)
+{
+ void *tls;
+
+ __asm __volatile("mrc p15, 0, %0, c13, c0, 3" : "=r" (tls));
+ return (tls);
+}
+
+static inline void
+set_tls(void *tls)
+{
+
+ __asm __volatile("mcr p15, 0, %0, c13, c0, 3" : : "r" (tls));
+}
+#else
+#define get_pcpu() pcpup
+#endif
-#define PCPU_GET(member) (pcpup->pc_ ## member)
-
-/*
- * XXX The implementation of this operation should be made atomic
- * with respect to preemption.
- */
-#define PCPU_ADD(member, value) (pcpup->pc_ ## member += (value))
+#define PCPU_GET(member) (get_pcpu()->pc_ ## member)
+#define PCPU_ADD(member, value) (get_pcpu()->pc_ ## member += (value))
#define PCPU_INC(member) PCPU_ADD(member, 1)
#define PCPU_PTR(member) (&pcpup->pc_ ## member)
#define PCPU_SET(member,value) (pcpup->pc_ ## member = (value))
More information about the svn-src-projects
mailing list