summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-06-13 01:08:14 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-06-13 01:08:14 +0000
commitf56b5d310eaea3964dcb986eabd245bc0f28187d (patch)
tree3f3ab030dfb9bf27b3ae02f9a599944aae72d00e /sys/arch
parentf3eac78a8e89442898f2f194b4373530ea2726b8 (diff)
rework sparc64 splfoo functions to be more consistent with other archs
this also moves us toward having an MI splraise(). sparc64 (and sparc) are different to the other archs because they have macros that build templates. each spl uses that macro to create an instance of an inline function specific to that spl call. this moves it to having a single splraise inline that the spl api is defined with. eg, #define splfoo() _splraise(IPL_FOO). ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/include/intr.h23
-rw-r--r--sys/arch/sparc64/include/psl.h167
-rw-r--r--sys/arch/sparc64/sparc64/intr.c8
3 files changed, 54 insertions, 144 deletions
diff --git a/sys/arch/sparc64/include/intr.h b/sys/arch/sparc64/include/intr.h
index 16b3913506f..7a784be98c1 100644
--- a/sys/arch/sparc64/include/intr.h
+++ b/sys/arch/sparc64/include/intr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.h,v 1.18 2015/09/27 11:29:20 kettenis Exp $ */
+/* $OpenBSD: intr.h,v 1.19 2016/06/13 01:08:13 dlg Exp $ */
/* $NetBSD: intr.h,v 1.8 2001/01/14 23:50:30 thorpej Exp $ */
/*-
@@ -83,8 +83,29 @@ void intr_establish(int, struct intrhand *);
#define IPL_STATCLOCK PIL_STATCLOCK /* statclock */
#define IPL_HIGH PIL_HIGH /* everything */
+#define spl0() _spl(IPL_NONE)
+#define splsoftint() _splraise(IPL_SOFTINT)
+#define splsoftclock() _splraise(IPL_SOFTCLOCK)
+#define splsoftnet() _splraise(IPL_SOFTNET)
+#define splbio() _splraise(IPL_BIO)
+#define splnet() _splraise(IPL_NET)
+#define splsofttty() _splraise(IPL_SOFTTTY)
+#define spltty() _splraise(IPL_TTY)
+#define splvm() _splraise(IPL_VM)
+#define splaudio() _splraise(IPL_AUDIO)
+#define splclock() _splraise(IPL_CLOCK)
+#define splserial() _splraise(IPL_SERIAL)
+#define splsched() _splraise(IPL_SCHED)
+#define spllock() _splraise(IPL_LOCK)
+#define splstatclock() _splraise(IPL_STATCLOCK)
+#define splhigh() _splraise(IPL_HIGH)
+#define splx(_oldipl) _splx(_oldipl)
+
+#define splzs() splserial()
+
#define IPL_MPSAFE 0x100
+int splraise(int);
void intr_barrier(void *);
void *softintr_establish(int, void (*)(void *), void *);
diff --git a/sys/arch/sparc64/include/psl.h b/sys/arch/sparc64/include/psl.h
index b2397081583..53b2f17cf28 100644
--- a/sys/arch/sparc64/include/psl.h
+++ b/sys/arch/sparc64/include/psl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: psl.h,v 1.30 2016/06/07 06:37:33 dlg Exp $ */
+/* $OpenBSD: psl.h,v 1.31 2016/06/13 01:08:13 dlg Exp $ */
/* $NetBSD: psl.h,v 1.20 2001/04/13 23:30:05 thorpej Exp $ */
/*
@@ -317,156 +317,39 @@ stxa_sync(u_int64_t va, u_int64_t asi, u_int64_t val)
intr_restore(s);
}
-/*
- * GCC pseudo-functions for manipulating PIL
- */
+static inline int
+_spl(int newipl)
+{
+ int oldpil;
-#ifdef SPLDEBUG
-void prom_printf(const char *fmt, ...);
-extern int printspl;
-#define SPLPRINT(x) if(printspl) { int i=10000000; prom_printf x ; while(i--); }
-#define SPL(name, newpil) \
-extern __inline int name##X(const char *, int); \
-extern __inline int name##X(const char *file, int line) \
-{ \
- u_int64_t oldpil = sparc_rdpr(pil); \
- SPLPRINT(("{%s:%d %d=>%d}", file, line, oldpil, newpil)); \
- sparc_wrpr(pil, newpil, 0); \
- return (oldpil); \
-}
-/* A non-priority-decreasing version of SPL */
-#define SPLHOLD(name, newpil) \
-extern __inline int name##X(const char *, int); \
-extern __inline int name##X(const char * file, int line) \
-{ \
- int oldpil = sparc_rdpr(pil); \
- if (__predict_false((u_int64_t)newpil <= oldpil)) \
- return (oldpil); \
- SPLPRINT(("{%s:%d %d->!d}", file, line, oldpil, newpil)); \
- sparc_wrpr(pil, newpil, 0); \
- return (oldpil); \
-}
+ __asm volatile( " rdpr %%pil, %0 \n"
+ " wrpr %%g0, %1, %%pil \n"
+ : "=&r" (oldpil)
+ : "I" (newipl)
+ : "%g0");
+ __asm volatile("" : : : "memory");
-#else
-#define SPLPRINT(x)
-#define SPL(name, newpil) \
-extern __inline int name(void); \
-extern __inline int name() \
-{ \
- int oldpil; \
- __asm volatile(" rdpr %%pil, %0 \n" \
- " wrpr %%g0, %1, %%pil \n" \
- : "=&r" (oldpil) \
- : "n" (newpil) \
- : "%g0"); \
- __asm volatile("" : : : "memory"); \
- return (oldpil); \
-}
-/* A non-priority-decreasing version of SPL */
-#define SPLHOLD(name, newpil) \
-extern __inline int name(void); \
-extern __inline int name() \
-{ \
- int oldpil; \
- \
- if (newpil <= 1) { \
- __asm volatile(" rdpr %%pil, %0 \n" \
- " brnz,pn %0, 1f \n" \
- " nop \n" \
- " wrpr %%g0, %1, %%pil \n" \
- "1: \n" \
- : "=&r" (oldpil) \
- : "I" (newpil) \
- : "%g0"); \
- } else { \
- __asm volatile(" rdpr %%pil, %0 \n" \
- " cmp %0, %1 - 1 \n" \
- " bgu,pn %%xcc, 1f \n" \
- " nop \n" \
- " wrpr %%g0, %1, %%pil \n" \
- "1: \n" \
- : "=&r" (oldpil) \
- : "I" (newpil) \
- : "cc"); \
- } \
- __asm volatile("" : : : "memory"); \
- return (oldpil); \
+ return (oldpil);
}
-#endif
-
-SPL(spl0, 0)
-
-SPLHOLD(splsoftint, 1)
-#define splsoftclock splsoftint
-#define splsoftnet splsoftint
-
-/* Block devices */
-SPLHOLD(splbio, PIL_BIO)
-/* network hardware interrupts are at level 6 */
-SPLHOLD(splnet, PIL_NET)
-
-/* tty input runs at software level 6 */
-SPLHOLD(spltty, PIL_TTY)
-
-/*
- * Memory allocation (must be as high as highest network, tty, or disk device)
- */
-SPLHOLD(splvm, PIL_VM)
-
-SPLHOLD(splclock, PIL_CLOCK)
-
-/* fd hardware interrupts are at level 11 */
-SPLHOLD(splfd, PIL_FD)
-
-/* zs hardware interrupts are at level 12 */
-SPLHOLD(splzs, PIL_SER)
-SPLHOLD(splserial, PIL_SER)
-
-/* audio hardware interrupts are at level 13 */
-SPLHOLD(splaudio, PIL_AUD)
-
-/* second sparc timer interrupts at level 14 */
-SPLHOLD(splstatclock, PIL_STATCLOCK)
-
-SPLHOLD(splsched, PIL_SCHED)
-SPLHOLD(spllock, PIL_LOCK)
-
-SPLHOLD(splhigh, PIL_HIGH)
-
-/* splx does not have a return value */
-#ifdef SPLDEBUG
+/* A non-priority-decreasing version of SPL */
+static inline int
+_splraise(int newpil)
+{
+ int oldpil;
-#define spl0() spl0X(__FILE__, __LINE__)
-#define splsoftint() splsoftintX(__FILE__, __LINE__)
-#define splbio() splbioX(__FILE__, __LINE__)
-#define splnet() splnetX(__FILE__, __LINE__)
-#define spltty() splttyX(__FILE__, __LINE__)
-#define splvm() splvmX(__FILE__, __LINE__)
-#define splclock() splclockX(__FILE__, __LINE__)
-#define splfd() splfdX(__FILE__, __LINE__)
-#define splzs() splzsX(__FILE__, __LINE__)
-#define splserial() splzerialX(__FILE__, __LINE__)
-#define splaudio() splaudioX(__FILE__, __LINE__)
-#define splstatclock() splstatclockX(__FILE__, __LINE__)
-#define splsched() splschedX(__FILE__, __LINE__)
-#define spllock() spllockX(__FILE__, __LINE__)
-#define splhigh() splhighX(__FILE__, __LINE__)
-#define splx(x) splxX((x),__FILE__, __LINE__)
+ oldpil = sparc_rdpr(pil);
+ if (newpil > oldpil)
+ sparc_wrpr(pil, newpil, 0);
+ return (oldpil);
+}
-extern __inline void splxX(u_int64_t, const char *, int);
-extern __inline void
-splxX(u_int64_t newpil, const char *file, int line)
-#else
-extern __inline void splx(int newpil)
-#endif
+static inline void
+_splx(int newpil)
{
-#ifdef SPLDEBUG
- u_int64_t oldpil = sparc_rdpr(pil);
- SPLPRINT(("{%d->%d}", oldpil, newpil));
-#endif
sparc_wrpr(pil, newpil, 0);
}
+
#endif /* KERNEL && !_LOCORE */
#endif /* _SPARC64_PSL_ */
diff --git a/sys/arch/sparc64/sparc64/intr.c b/sys/arch/sparc64/sparc64/intr.c
index ce0affe9906..2947715d45b 100644
--- a/sys/arch/sparc64/sparc64/intr.c
+++ b/sys/arch/sparc64/sparc64/intr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intr.c,v 1.54 2015/09/27 11:29:20 kettenis Exp $ */
+/* $OpenBSD: intr.c,v 1.55 2016/06/13 01:08:13 dlg Exp $ */
/* $NetBSD: intr.c,v 1.39 2001/07/19 23:38:11 eeh Exp $ */
/*
@@ -313,6 +313,12 @@ intr_establish(int level, struct intrhand *ih)
splx(s);
}
+int
+splraise(int ipl)
+{
+ return (_splraise(ipl));
+}
+
void
intr_barrier(void *cookie)
{