From a41de1d388736be0ec4c17a2c2f21cf953633987 Mon Sep 17 00:00:00 2001 From: visa Date: Sun, 18 Feb 2018 14:50:08 +0000 Subject: [PATCH] Inline hw_{get,set}curcpu() to streamline the machine code. --- sys/arch/octeon/include/cpu.h | 19 ++++++++++++++++--- sys/arch/octeon/octeon/locore.S | 14 +------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/sys/arch/octeon/include/cpu.h b/sys/arch/octeon/include/cpu.h index afc9a037a92..6e5b880833c 100644 --- a/sys/arch/octeon/include/cpu.h +++ b/sys/arch/octeon/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.11 2018/01/18 14:02:54 visa Exp $ */ +/* $OpenBSD: cpu.h,v 1.12 2018/02/18 14:50:08 visa Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -51,14 +51,27 @@ #if defined(MULTIPROCESSOR) && !defined(_LOCORE) #define MAXCPUS OCTEON_MAXCPUS struct cpu_info; -struct cpu_info *hw_getcurcpu(void); -void hw_setcurcpu(struct cpu_info *); void hw_cpu_boot_secondary(struct cpu_info *); void hw_cpu_hatch(struct cpu_info *); void hw_cpu_spinup_trampoline(struct cpu_info *); int hw_ipi_intr_establish(int (*)(void *), u_long); void hw_ipi_intr_set(u_long); void hw_ipi_intr_clear(u_long); + +/* Keep in sync with HW_GET_CPU_INFO(). */ +static inline struct cpu_info * +hw_getcurcpu(void) +{ + struct cpu_info *ci; + __asm__ volatile ("dmfc0 %0, $30" /* ErrorEPC */ : "=r" (ci)); + return ci; +} + +static inline void +hw_setcurcpu(struct cpu_info *ci) +{ + __asm__ volatile ("dmtc0 %0, $30" /* ErrorEPC */ : : "r" (ci)); +} #endif /* MULTIPROCESSOR && !_LOCORE */ #define CACHELINESIZE 128 diff --git a/sys/arch/octeon/octeon/locore.S b/sys/arch/octeon/octeon/locore.S index 928839b5d68..ff503c3d86c 100644 --- a/sys/arch/octeon/octeon/locore.S +++ b/sys/arch/octeon/octeon/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.16 2017/06/08 12:11:46 visa Exp $ */ +/* $OpenBSD: locore.S,v 1.17 2018/02/18 14:50:08 visa Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -156,16 +156,4 @@ LEAF(hw_cpu_spinup_trampoline, 0) jal hw_cpu_hatch nop END(hw_cpu_spinup_trampoline) - -LEAF(hw_getcurcpu, 0) - GET_CPU_INFO(v0, v1) - jr ra - nop -END(hw_getcurcpu) - -LEAF(hw_setcurcpu, 0) - dmtc0 a0, COP_0_ERROR_PC - j ra - nop -END(hw_setcurcpu) #endif /* MULTIPROCESSOR */ -- 2.20.1