From 621c0c1ae99e0ecdc85964587e9bd6075928437b Mon Sep 17 00:00:00 2001 From: "Thordur I. Bjornsson" Date: Wed, 14 Nov 2007 20:33:33 +0000 Subject: Turn the spl* macros into functions. Shaves a few bytes of the kernel. No measurable performance loss. ok drahn@, kettenis@ --- sys/arch/powerpc/conf/files.powerpc | 3 +- sys/arch/powerpc/include/intr.h | 52 +++--------------------- sys/arch/powerpc/powerpc/intr.c | 79 +++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 47 deletions(-) create mode 100644 sys/arch/powerpc/powerpc/intr.c (limited to 'sys/arch') diff --git a/sys/arch/powerpc/conf/files.powerpc b/sys/arch/powerpc/conf/files.powerpc index d3effdc83a4..85d51db5a41 100644 --- a/sys/arch/powerpc/conf/files.powerpc +++ b/sys/arch/powerpc/conf/files.powerpc @@ -1,4 +1,4 @@ -# $OpenBSD: files.powerpc,v 1.43 2007/10/10 15:53:52 art Exp $ +# $OpenBSD: files.powerpc,v 1.44 2007/11/14 20:33:32 thib Exp $ # file arch/powerpc/powerpc/setjmp.S ddb @@ -13,6 +13,7 @@ file arch/powerpc/powerpc/sys_machdep.c file arch/powerpc/powerpc/trap.c file arch/powerpc/powerpc/vm_machdep.c file arch/powerpc/powerpc/mutex.S +file arch/powerpc/powerpc/intr.c file arch/powerpc/ddb/db_memrw.c ddb file arch/powerpc/ddb/db_disasm.c ddb diff --git a/sys/arch/powerpc/include/intr.h b/sys/arch/powerpc/include/intr.h index a6999d357b1..3e2c206e9ef 100644 --- a/sys/arch/powerpc/include/intr.h +++ b/sys/arch/powerpc/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.33 2007/05/19 10:20:57 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.34 2007/11/14 20:33:32 thib Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA. @@ -66,6 +66,11 @@ void setsoftnet(void); void clearsoftnet(void); int splsoftnet(void); +int splraise(int); +int spllower(int); +void splx(int); + + void do_pending_int(void); extern int imask[IPL_NUM]; @@ -73,51 +78,6 @@ extern int imask[IPL_NUM]; /* SPL asserts */ #define splassert(wantipl) /* nothing */ -/* - * Reorder protection in the following inline functions is - * achived with an empty asm volatile statement. the compiler - * will not move instructions past asm volatiles. - */ -volatile static __inline int -splraise(int newcpl) -{ - struct cpu_info *ci = curcpu(); - int oldcpl; - - __asm__ volatile("":::"memory"); /* don't reorder.... */ - oldcpl = ci->ci_cpl; - ci->ci_cpl = oldcpl | newcpl; - __asm__ volatile("":::"memory"); /* don't reorder.... */ - return(oldcpl); -} - -volatile static __inline void -splx(int newcpl) -{ - struct cpu_info *ci = curcpu(); - - __asm__ volatile("":::"memory"); /* reorder protect */ - ci->ci_cpl = newcpl; - if(ci->ci_ipending & ~newcpl) - do_pending_int(); - __asm__ volatile("":::"memory"); /* reorder protect */ -} - -volatile static __inline int -spllower(int newcpl) -{ - struct cpu_info *ci = curcpu(); - int oldcpl; - - __asm__ volatile("":::"memory"); /* reorder protect */ - oldcpl = ci->ci_cpl; - ci->ci_cpl = newcpl; - if(ci->ci_ipending & ~newcpl) - do_pending_int(); - __asm__ volatile("":::"memory"); /* reorder protect */ - return(oldcpl); -} - #define set_sint(p) atomic_setbits_int(&curcpu()->ci_ipending, p) #define SINT_CLOCK 0x10000000 diff --git a/sys/arch/powerpc/powerpc/intr.c b/sys/arch/powerpc/powerpc/intr.c new file mode 100644 index 00000000000..501560bba32 --- /dev/null +++ b/sys/arch/powerpc/powerpc/intr.c @@ -0,0 +1,79 @@ +/* $OpenBSD: intr.c,v 1.1 2007/11/14 20:33:32 thib Exp $ */ + +/* + * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed under OpenBSD by + * Per Fogelstrom, Opsycon AB, Sweden for RTMX Inc, North Carolina USA. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + * + */ +#include + +#include +#include + +int +splraise(int newcpl) +{ + struct cpu_info *ci = curcpu(); + int oldcpl; + + __asm__ volatile("":::"memory"); /* reorder protect */ + oldcpl = ci->ci_cpl; + ci->ci_cpl = oldcpl | newcpl; + __asm__ volatile("":::"memory"); + + return (oldcpl); +} + +int +spllower(int newcpl) +{ + struct cpu_info *ci = curcpu(); + int oldcpl; + + __asm__ volatile("":::"memory"); /* reorder protect */ + oldcpl = ci->ci_cpl; + ci->ci_cpl = newcpl; + if (ci->ci_ipending & ~newcpl) + do_pending_int(); + __asm__ volatile("":::"memory"); + + return (oldcpl); +} + +void +splx(int newcpl) +{ + struct cpu_info *ci = curcpu(); + + __asm__ volatile("":::"memory"); /* reorder protect */ + ci->ci_cpl = newcpl; + if (ci->ci_ipending & ~newcpl) + do_pending_int(); + __asm__ volatile("":::"memory"); +} -- cgit v1.2.3