aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/include
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-08-29 07:25:27 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-08-29 07:25:27 +0000
commita2a0f90654eeca563cf47f043d6c1a14e6a7e289 (patch)
tree0f0f88ea65718314696b068de30da60a01a3fdb8 /sys/amd64/include
parent4b4d1b818e84c6eee3c06f60315510bf34729aba (diff)
Notes
Diffstat (limited to 'sys/amd64/include')
-rw-r--r--sys/amd64/include/counter.h3
-rw-r--r--sys/amd64/include/pcpu.h29
-rw-r--r--sys/amd64/include/pcpu_aux.h72
3 files changed, 72 insertions, 32 deletions
diff --git a/sys/amd64/include/counter.h b/sys/amd64/include/counter.h
index 77bfa942036bc..cc68da61928d5 100644
--- a/sys/amd64/include/counter.h
+++ b/sys/amd64/include/counter.h
@@ -33,9 +33,6 @@
#include <sys/pcpu.h>
-extern struct pcpu *__pcpu;
-extern struct pcpu temp_bsp_pcpu;
-
#define EARLY_COUNTER &temp_bsp_pcpu.pc_early_dummy_counter
#define counter_enter() do {} while (0)
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
index 435b04d77e6a5..d79ef067a9789 100644
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -233,35 +233,6 @@ _Static_assert(sizeof(struct monitorbuf) == 128, "2x cache line");
#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member)
#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val)
-#define OFFSETOF_CURTHREAD 0
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnull-dereference"
-#endif
-static __inline __pure2 struct thread *
-__curthread(void)
-{
- struct thread *td;
-
- __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (OFFSETOF_CURTHREAD));
- return (td);
-}
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-#define curthread (__curthread())
-
-#define OFFSETOF_CURPCB 32
-static __inline __pure2 struct pcb *
-__curpcb(void)
-{
- struct pcb *pcb;
-
- __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (OFFSETOF_CURPCB));
- return (pcb);
-}
-#define curpcb (__curpcb())
-
#define IS_BSP() (PCPU_GET(cpuid) == 0)
#else /* !__GNUCLIKE_ASM || !__GNUCLIKE___TYPEOF */
diff --git a/sys/amd64/include/pcpu_aux.h b/sys/amd64/include/pcpu_aux.h
new file mode 100644
index 0000000000000..7db51e83d0396
--- /dev/null
+++ b/sys/amd64/include/pcpu_aux.h
@@ -0,0 +1,72 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _MACHINE_PCPU_AUX_H_
+#define _MACHINE_PCPU_AUX_H_
+
+#ifndef _KERNEL
+#error "Not for userspace"
+#endif
+
+#ifndef _SYS_PCPU_H_
+#error "Do not include machine/pcpu_aux.h directly"
+#endif
+
+/* Required for counters(9) to work on x86. */
+_Static_assert(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE, "fix pcpu size");
+
+extern struct pcpu *__pcpu;
+extern struct pcpu temp_bsp_pcpu;
+
+static __inline __pure2 struct thread *
+__curthread(void)
+{
+ struct thread *td;
+
+ __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu,
+ pc_curthread)));
+ return (td);
+}
+#define curthread (__curthread())
+
+static __inline __pure2 struct pcb *
+__curpcb(void)
+{
+ struct pcb *pcb;
+
+ __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (offsetof(struct pcpu,
+ pc_curpcb)));
+ return (pcb);
+}
+#define curpcb (__curpcb())
+
+#endif /* _MACHINE_PCPU_AUX_H_ */