diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-17 12:01:12 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-05-17 12:01:12 +0000 |
commit | 8aa578901af2ee933dc5a413d464e25f23b2834d (patch) | |
tree | 220bf431d46472dcff9f689bb32c1b861306048d /sys/arch | |
parent | e6c0f2cf8d995984649d1ae8471d2b2a35785889 (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.h | 8 | ||||
-rw-r--r-- | sys/arch/powerpc64/powerpc64/machdep.c | 5 |
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); |