summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-05-17 12:01:12 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-05-17 12:01:12 +0000
commit8aa578901af2ee933dc5a413d464e25f23b2834d (patch)
tree220bf431d46472dcff9f689bb32c1b861306048d /sys/arch
parente6c0f2cf8d995984649d1ae8471d2b2a35785889 (diff)
The 64-bit Power ABI reserves r13 for the thread pointer, so use that
to hold a pointer to our struct cpu_info.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/powerpc64/include/cpu.h8
-rw-r--r--sys/arch/powerpc64/powerpc64/machdep.c5
2 files changed, 11 insertions, 2 deletions
diff --git a/sys/arch/powerpc64/include/cpu.h b/sys/arch/powerpc64/include/cpu.h
index ceeabbe510c..52dcc54d301 100644
--- a/sys/arch/powerpc64/include/cpu.h
+++ b/sys/arch/powerpc64/include/cpu.h
@@ -25,7 +25,13 @@ struct cpu_info {
extern struct cpu_info cpu_info_primary;
-#define curcpu() (&cpu_info_primary)
+static inline struct cpu_info *
+curcpu(void)
+{
+ struct cpu_info *ci;
+ __asm volatile("mr %0, %%r13" : "=r"(ci));
+ return ci;
+}
#define MAXCPUS 1
#define CPU_IS_PRIMARY(ci) 1
diff --git a/sys/arch/powerpc64/powerpc64/machdep.c b/sys/arch/powerpc64/powerpc64/machdep.c
index 7ae41387f3e..d3e8e4ef845 100644
--- a/sys/arch/powerpc64/powerpc64/machdep.c
+++ b/sys/arch/powerpc64/powerpc64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.2 2020/05/16 23:06:27 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.3 2020/05/17 12:01:11 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
@@ -68,6 +68,9 @@ init_powernv(void *fdt)
int len;
int i;
+ /* Store pointer to our struct cpu_info. */
+ __asm volatile("mr %%r13, %0" :: "r"(&cpu_info_primary));
+
/* Clear BSS. */
memset(__bss_start, 0, _end - __bss_start);