diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-05-15 05:26:46 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-05-15 05:26:46 +0000 |
commit | b3082faac71e0bbf79eed5f503d8906326fe1084 (patch) | |
tree | 2b27d6df0df1bdd90add99e191ddf5a5b7db79d6 /sys | |
parent | 6f5d7c74dcd62f8b14ef5f388edeb24e190788fc (diff) |
Dummy mutex code for arm platforms. ok drahn@ deraadt@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/arm/conf/files.footbridge | 3 | ||||
-rw-r--r-- | sys/arch/arm/footbridge/footbridge_intr.h | 4 | ||||
-rw-r--r-- | sys/arch/arm/footbridge/footbridge_mutex.c | 67 | ||||
-rw-r--r-- | sys/arch/arm/footbridge/footbridge_mutex.h | 61 | ||||
-rw-r--r-- | sys/arch/arm/xscale/files.i80321 | 3 | ||||
-rw-r--r-- | sys/arch/arm/xscale/files.pxa2x0 | 3 | ||||
-rw-r--r-- | sys/arch/arm/xscale/i80321_mutex.c | 67 | ||||
-rw-r--r-- | sys/arch/arm/xscale/i80321_mutex.h | 61 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_intr.h | 6 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_mutex.c | 67 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_mutex.h | 61 | ||||
-rw-r--r-- | sys/arch/armish/include/_types.h | 3 | ||||
-rw-r--r-- | sys/arch/armish/include/armish_intr.h | 6 | ||||
-rw-r--r-- | sys/arch/armish/include/intr.h | 51 | ||||
-rw-r--r-- | sys/arch/armish/include/mutex.h | 3 | ||||
-rw-r--r-- | sys/arch/cats/include/_types.h | 3 | ||||
-rw-r--r-- | sys/arch/cats/include/intr.h | 4 | ||||
-rw-r--r-- | sys/arch/cats/include/mutex.h | 3 | ||||
-rw-r--r-- | sys/arch/zaurus/include/_types.h | 3 | ||||
-rw-r--r-- | sys/arch/zaurus/include/intr.h | 51 | ||||
-rw-r--r-- | sys/arch/zaurus/include/mutex.h | 3 |
21 files changed, 417 insertions, 116 deletions
diff --git a/sys/arch/arm/conf/files.footbridge b/sys/arch/arm/conf/files.footbridge index 01671454bf5..6ebf6f45f0e 100644 --- a/sys/arch/arm/conf/files.footbridge +++ b/sys/arch/arm/conf/files.footbridge @@ -1,4 +1,4 @@ -# $OpenBSD: files.footbridge,v 1.1 2004/02/01 05:09:48 drahn Exp $ +# $OpenBSD: files.footbridge,v 1.2 2007/05/15 05:26:42 miod Exp $ # $NetBSD: files.footbridge,v 1.11 2003/01/03 01:06:40 thorpej Exp $ # # Shared footbridge files information @@ -14,6 +14,7 @@ file arch/arm/arm/irq_dispatch.S file arch/arm/footbridge/footbridge_irqhandler.c footbridge file arch/arm/footbridge/footbridge_clock.c footbridge file arch/arm/arm/softintr.c footbridge +file arch/arm/footbridge/footbridge_mutex.c footbridge # DC21285 "Footbridge" serial port device fcom: tty, bus_space_generic diff --git a/sys/arch/arm/footbridge/footbridge_intr.h b/sys/arch/arm/footbridge/footbridge_intr.h index b2121dc0d71..8df63b4f863 100644 --- a/sys/arch/arm/footbridge/footbridge_intr.h +++ b/sys/arch/arm/footbridge/footbridge_intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: footbridge_intr.h,v 1.6 2006/03/12 03:14:36 brad Exp $ */ +/* $OpenBSD: footbridge_intr.h,v 1.7 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: footbridge_intr.h,v 1.4 2003/01/03 00:56:00 thorpej Exp $ */ /* @@ -208,4 +208,6 @@ struct intrq { #endif /* _LOCORE */ +#define splassert(wantipl) do { /* nada */ } while (0) + #endif /* _FOOTBRIDGE_INTR_H */ diff --git a/sys/arch/arm/footbridge/footbridge_mutex.c b/sys/arch/arm/footbridge/footbridge_mutex.c new file mode 100644 index 00000000000..978514a536f --- /dev/null +++ b/sys/arch/arm/footbridge/footbridge_mutex.c @@ -0,0 +1,67 @@ +/* $OpenBSD: footbridge_mutex.c,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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 <sys/param.h> +#include <sys/mutex.h> +#include <sys/systm.h> + +#include <machine/intr.h> + +#ifdef MULTIPROCESSOR +#error This code needs more work +#endif + +/* + * Single processor systems don't need any mutexes, but they need the spl + * raising semantics of the mutexes. + */ +void +mtx_init(struct mutex *mtx, int wantipl) +{ + mtx->mtx_lock = 0; + mtx->mtx_wantipl = wantipl; + mtx->mtx_oldcpl = 0; +} + +void +mtx_enter(struct mutex *mtx) +{ + if (mtx->mtx_wantipl != IPL_NONE) + mtx->mtx_oldcpl = _splraise(mtx->mtx_wantipl); + + MUTEX_ASSERT_UNLOCKED(mtx); + mtx->mtx_lock = 1; +} + +void +mtx_leave(struct mutex *mtx) +{ + MUTEX_ASSERT_LOCKED(mtx); + mtx->mtx_lock = 0; + if (mtx->mtx_wantipl != IPL_NONE) + splx(mtx->mtx_oldcpl); +} diff --git a/sys/arch/arm/footbridge/footbridge_mutex.h b/sys/arch/arm/footbridge/footbridge_mutex.h new file mode 100644 index 00000000000..60492ed737d --- /dev/null +++ b/sys/arch/arm/footbridge/footbridge_mutex.h @@ -0,0 +1,61 @@ +/* $OpenBSD: footbridge_mutex.h,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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. + */ + +#ifndef _MACHINE_MUTEX_H_ +#define _MACHINE_MUTEX_H_ + +/* + * Simple non-mp implementation. + */ +struct mutex { + int mtx_lock; + int mtx_wantipl; + int mtx_oldcpl; +}; + +void mtx_init(struct mutex *, int); + +#define MUTEX_INITIALIZER(ipl) { 0, (ipl), 0 } + +#ifdef DIAGNOSTIC +#define MUTEX_ASSERT_LOCKED(mtx) do { \ + if ((mtx)->mtx_lock == 0) \ + panic("mutex %p not held in %s", (mtx), __func__); \ +} while (0) + +#define MUTEX_ASSERT_UNLOCKED(mtx) do { \ + if ((mtx)->mtx_lock != 0) \ + panic("mutex %p held in %s", (mtx), __func__); \ +} while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif + +#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldcpl + +#endif diff --git a/sys/arch/arm/xscale/files.i80321 b/sys/arch/arm/xscale/files.i80321 index 90d2d6d69f0..86b6ca05f1e 100644 --- a/sys/arch/arm/xscale/files.i80321 +++ b/sys/arch/arm/xscale/files.i80321 @@ -1,4 +1,4 @@ -# $OpenBSD: files.i80321,v 1.3 2006/06/27 05:18:25 drahn Exp $ +# $OpenBSD: files.i80321,v 1.4 2007/05/15 05:26:44 miod Exp $ device iopxs {}: pcibus, bus_space_generic, gpiobus file arch/arm/xscale/i80321_space.c iopxs file arch/arm/xscale/i80321_mcu.c iopxs @@ -7,6 +7,7 @@ file arch/arm/xscale/i80321_pci.c iopxs file arch/arm/xscale/i80321_intr.c iopxs file arch/arm/xscale/i80321_clock.c iopxs +file arch/arm/xscale/i80321_mutex.c iopxs # I2C controller unit device iopiic: i2cbus diff --git a/sys/arch/arm/xscale/files.pxa2x0 b/sys/arch/arm/xscale/files.pxa2x0 index 64a50c32aff..1439e545514 100644 --- a/sys/arch/arm/xscale/files.pxa2x0 +++ b/sys/arch/arm/xscale/files.pxa2x0 @@ -1,4 +1,4 @@ -# $OpenBSD: files.pxa2x0,v 1.20 2007/03/18 20:53:10 uwe Exp $ +# $OpenBSD: files.pxa2x0,v 1.21 2007/05/15 05:26:44 miod Exp $ # $NetBSD: files.pxa2x0,v 1.6 2004/05/01 19:09:14 thorpej Exp $ # # Configuration info for Intel PXA2[51]0 CPU support @@ -22,6 +22,7 @@ file arch/arm/xscale/pxa2x0_dma.c device pxaintc attach pxaintc at pxaip file arch/arm/xscale/pxa2x0_intr.c pxaintc needs-flag +file arch/arm/xscale/pxa2x0_mutex.c pxaintc #defflag opt_pxa2x0_gpio.h PXAGPIO_HAS_GPION_INTRS # GPIO controller diff --git a/sys/arch/arm/xscale/i80321_mutex.c b/sys/arch/arm/xscale/i80321_mutex.c new file mode 100644 index 00000000000..c19da126124 --- /dev/null +++ b/sys/arch/arm/xscale/i80321_mutex.c @@ -0,0 +1,67 @@ +/* $OpenBSD: i80321_mutex.c,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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 <sys/param.h> +#include <sys/mutex.h> +#include <sys/systm.h> + +#include <machine/intr.h> + +#ifdef MULTIPROCESSOR +#error This code needs work +#endif + +/* + * Single processor systems don't need any mutexes, but they need the spl + * raising semantics of the mutexes. + */ +void +mtx_init(struct mutex *mtx, int wantipl) +{ + mtx->mtx_oldipl = 0; + mtx->mtx_wantipl = wantipl; + mtx->mtx_lock = 0; +} + +void +mtx_enter(struct mutex *mtx) +{ + if (mtx->mtx_wantipl != IPL_NONE) + mtx->mtx_oldipl = _splraise(mtx->mtx_wantipl); + + MUTEX_ASSERT_UNLOCKED(mtx); + mtx->mtx_lock = 1; +} + +void +mtx_leave(struct mutex *mtx) +{ + MUTEX_ASSERT_LOCKED(mtx); + mtx->mtx_lock = 0; + if (mtx->mtx_wantipl != IPL_NONE) + splx(mtx->mtx_oldipl); +} diff --git a/sys/arch/arm/xscale/i80321_mutex.h b/sys/arch/arm/xscale/i80321_mutex.h new file mode 100644 index 00000000000..2334d61d39f --- /dev/null +++ b/sys/arch/arm/xscale/i80321_mutex.h @@ -0,0 +1,61 @@ +/* $OpenBSD: i80321_mutex.h,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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. + */ + +#ifndef _MACHINE_MUTEX_H_ +#define _MACHINE_MUTEX_H_ + +/* + * Simple non-mp implementation. + */ +struct mutex { + int mtx_lock; + int mtx_wantipl; + int mtx_oldipl; +}; + +void mtx_init(struct mutex *, int); + +#define MUTEX_INITIALIZER(ipl) { 0, ipl, 0 } + +#ifdef DIAGNOSTIC +#define MUTEX_ASSERT_LOCKED(mtx) do { \ + if ((mtx)->mtx_lock == 0) \ + panic("mutex %p not held in %s", (mtx), __func__); \ +} while (0) + +#define MUTEX_ASSERT_UNLOCKED(mtx) do { \ + if ((mtx)->mtx_lock != 0) \ + panic("mutex %p held in %s", (mtx), __func__); \ +} while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif + +#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl + +#endif diff --git a/sys/arch/arm/xscale/pxa2x0_intr.h b/sys/arch/arm/xscale/pxa2x0_intr.h index c12651ad38a..28285b796b4 100644 --- a/sys/arch/arm/xscale/pxa2x0_intr.h +++ b/sys/arch/arm/xscale/pxa2x0_intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pxa2x0_intr.h,v 1.9 2005/09/22 04:14:44 drahn Exp $ */ +/* $OpenBSD: pxa2x0_intr.h,v 1.10 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: pxa2x0_intr.h,v 1.4 2003/07/05 06:53:08 dogcow Exp $ */ /* Derived from i80321_intr.h */ @@ -47,7 +47,6 @@ #include <arm/armreg.h> #include <arm/cpufunc.h> -#include <machine/intr.h> #include <arm/softintr.h> extern vaddr_t pxaic_base; /* Shared with pxa2x0_irq.S */ @@ -106,5 +105,6 @@ const char *pxa2x0_intr_string(void *cookie); #endif /* ! _LOCORE */ -#endif /* _PXA2X0_INTR_H_ */ +#define splassert(wantipl) do { /* nada */ } while (0) +#endif /* _PXA2X0_INTR_H_ */ diff --git a/sys/arch/arm/xscale/pxa2x0_mutex.c b/sys/arch/arm/xscale/pxa2x0_mutex.c new file mode 100644 index 00000000000..605f9b02b56 --- /dev/null +++ b/sys/arch/arm/xscale/pxa2x0_mutex.c @@ -0,0 +1,67 @@ +/* $OpenBSD: pxa2x0_mutex.c,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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 <sys/param.h> +#include <sys/mutex.h> +#include <sys/systm.h> + +#include <machine/intr.h> + +#ifdef MULTIPROCESSOR +#error This code needs work +#endif + +/* + * Single processor systems don't need any mutexes, but they need the spl + * raising semantics of the mutexes. + */ +void +mtx_init(struct mutex *mtx, int wantipl) +{ + mtx->mtx_oldipl = 0; + mtx->mtx_wantipl = wantipl; + mtx->mtx_lock = 0; +} + +void +mtx_enter(struct mutex *mtx) +{ + if (mtx->mtx_wantipl != IPL_NONE) + mtx->mtx_oldipl = _splraise(mtx->mtx_wantipl); + + MUTEX_ASSERT_UNLOCKED(mtx); + mtx->mtx_lock = 1; +} + +void +mtx_leave(struct mutex *mtx) +{ + MUTEX_ASSERT_LOCKED(mtx); + mtx->mtx_lock = 0; + if (mtx->mtx_wantipl != IPL_NONE) + splx(mtx->mtx_oldipl); +} diff --git a/sys/arch/arm/xscale/pxa2x0_mutex.h b/sys/arch/arm/xscale/pxa2x0_mutex.h new file mode 100644 index 00000000000..afe348dd86a --- /dev/null +++ b/sys/arch/arm/xscale/pxa2x0_mutex.h @@ -0,0 +1,61 @@ +/* $OpenBSD: pxa2x0_mutex.h,v 1.1 2007/05/15 05:26:44 miod Exp $ */ + +/* + * Copyright (c) 2004 Artur Grabowski <art@openbsd.org> + * All rights reserved. + * + * 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. 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 ``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. + */ + +#ifndef _MACHINE_MUTEX_H_ +#define _MACHINE_MUTEX_H_ + +/* + * Simple non-mp implementation. + */ +struct mutex { + int mtx_lock; + int mtx_wantipl; + int mtx_oldipl; +}; + +void mtx_init(struct mutex *, int); + +#define MUTEX_INITIALIZER(ipl) { 0, ipl, 0 } + +#ifdef DIAGNOSTIC +#define MUTEX_ASSERT_LOCKED(mtx) do { \ + if ((mtx)->mtx_lock == 0) \ + panic("mutex %p not held in %s", (mtx), __func__); \ +} while (0) + +#define MUTEX_ASSERT_UNLOCKED(mtx) do { \ + if ((mtx)->mtx_lock != 0) \ + panic("mutex %p held in %s", (mtx), __func__); \ +} while (0) +#else +#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) +#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) +#endif + +#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl + +#endif diff --git a/sys/arch/armish/include/_types.h b/sys/arch/armish/include/_types.h index 99f5e8b4784..a9eaa5821c7 100644 --- a/sys/arch/armish/include/_types.h +++ b/sys/arch/armish/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.1 2006/05/29 17:13:19 drahn Exp $ */ +/* $OpenBSD: _types.h,v 1.2 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: types.h,v 1.4 2002/02/28 03:17:26 simonb Exp $ */ #ifndef _ARMISH__TYPES_H_ @@ -6,5 +6,6 @@ #include <arm/_types.h> #define __HAVE_GENERIC_SOFT_INTERRUPTS +#define __HAVE_MUTEX #endif /* _ARMISH__TYPES_H_ */ diff --git a/sys/arch/armish/include/armish_intr.h b/sys/arch/armish/include/armish_intr.h index 13d1c78d879..2bc4f4da2a8 100644 --- a/sys/arch/armish/include/armish_intr.h +++ b/sys/arch/armish/include/armish_intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armish_intr.h,v 1.2 2006/06/15 21:35:30 drahn Exp $ */ +/* $OpenBSD: armish_intr.h,v 1.3 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: i80321_intr.h,v 1.4 2003/07/05 06:53:08 dogcow Exp $ */ /* @@ -45,7 +45,6 @@ #include <arm/armreg.h> #include <arm/cpufunc.h> -#include <machine/intr.h> #include <arm/softintr.h> extern __volatile int current_ipl_level; @@ -59,7 +58,6 @@ int i80321_splraise(int ipl); int i80321_spllower(int ipl); void i80321_setsoftintr(int si); - /* * An useful function for interrupt handlers. * XXX: This shouldn't be here. @@ -97,6 +95,8 @@ void *i80321_intr_establish(int irqno, int level, int (*func)(void *), void i80321_intr_disestablish(void *cookie); const char *i80321_intr_string(void *cookie); +#define splassert(wantipl) do { /* nada */ } while (0) + #endif /* ! _LOCORE */ #endif /* _I80321_INTR_H_ */ diff --git a/sys/arch/armish/include/intr.h b/sys/arch/armish/include/intr.h index 32b059024a4..0baf01aec68 100644 --- a/sys/arch/armish/include/intr.h +++ b/sys/arch/armish/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.3 2006/06/15 21:35:30 drahn Exp $ */ +/* $OpenBSD: intr.h,v 1.4 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: intr.h,v 1.12 2003/06/16 20:00:59 thorpej Exp $ */ /* @@ -76,50 +76,6 @@ #include <sys/device.h> #include <sys/queue.h> -#if defined(_LKM) - -int _splraise(int); -int _spllower(int); -void splx(int); -void _setsoftintr(int); - -#else /* _LKM */ - -/* - * Each board needs to define the following functions: - * - * int _splraise(int); - * int _spllower(int); - * void splx(int); - * void _setsoftintr(int); - * - * These may be defined as functions, static __inline functions, or macros, - * but there must be a _spllower() and splx() defined as functions callable - * from assembly language (for cpu_switch()). However, since it's quite - * useful to be able to inline splx(), you could do something like the - * following: - * - * in <boardtype>_intr.h: - * static __inline int - * boardtype_splx(int spl) - * {...} - * - * #define splx(nspl) boardtype_splx(nspl) - * ... - * and in boardtype's machdep code: - * - * ... - * #undef splx - * int - * splx(int spl) - * { - * return boardtype_splx(spl); - * } - */ - - -#endif /* _LKM */ - #define splhigh() _splraise(IPL_HIGH) #define splsoft() _splraise(IPL_SOFT) #define splsoftclock() _splraise(IPL_SOFTCLOCK) @@ -137,15 +93,10 @@ void _setsoftintr(int); #define splsched() splhigh() #define spllock() splhigh() -/* Use generic software interrupt support. */ -#include <arm/softintr.h> - #endif /* ! _LOCORE */ #include <machine/armish_intr.h> -#define splassert(wantipl) do { /* nada */ } while (0) - #endif /* _KERNEL */ #endif /* _ARMISH_INTR_H_ */ diff --git a/sys/arch/armish/include/mutex.h b/sys/arch/armish/include/mutex.h new file mode 100644 index 00000000000..11c58b359af --- /dev/null +++ b/sys/arch/armish/include/mutex.h @@ -0,0 +1,3 @@ +/* $OpenBSD: mutex.h,v 1.1 2007/05/15 05:26:44 miod Exp $ */ +/* public domain */ +#include <arm/xscale/i80321_mutex.h> diff --git a/sys/arch/cats/include/_types.h b/sys/arch/cats/include/_types.h index dfed4853d90..fba2772bd00 100644 --- a/sys/arch/cats/include/_types.h +++ b/sys/arch/cats/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.1 2006/01/06 18:50:08 millert Exp $ */ +/* $OpenBSD: _types.h,v 1.2 2007/05/15 05:26:44 miod Exp $ */ /* public domain */ @@ -8,5 +8,6 @@ #include <arm/_types.h> #define __HAVE_GENERIC_SOFT_INTERRUPTS +#define __HAVE_MUTEX #endif /* _CATS__TYPES */ diff --git a/sys/arch/cats/include/intr.h b/sys/arch/cats/include/intr.h index 973e06580e5..5110f79f21a 100644 --- a/sys/arch/cats/include/intr.h +++ b/sys/arch/cats/include/intr.h @@ -1,6 +1,4 @@ -/* $OpenBSD: intr.h,v 1.1 2004/02/01 05:12:54 drahn Exp $ */ +/* $OpenBSD: intr.h,v 1.2 2007/05/15 05:26:44 miod Exp $ */ /* $NetBSD: intr.h,v 1.4 2002/09/28 15:44:29 chris Exp $ */ #include <arm/footbridge/footbridge_intr.h> - -#define splassert(wantipl) do { /* nada */ } while (0) diff --git a/sys/arch/cats/include/mutex.h b/sys/arch/cats/include/mutex.h new file mode 100644 index 00000000000..03d7fd1ffd0 --- /dev/null +++ b/sys/arch/cats/include/mutex.h @@ -0,0 +1,3 @@ +/* $OpenBSD: mutex.h,v 1.1 2007/05/15 05:26:44 miod Exp $ */ +/* public domain */ +#include <arm/footbridge/footbridge_mutex.h> diff --git a/sys/arch/zaurus/include/_types.h b/sys/arch/zaurus/include/_types.h index 5e10865c9ae..7cf8cf0a351 100644 --- a/sys/arch/zaurus/include/_types.h +++ b/sys/arch/zaurus/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.1 2006/01/06 18:50:10 millert Exp $ */ +/* $OpenBSD: _types.h,v 1.2 2007/05/15 05:26:44 miod Exp $ */ #ifndef _ZAURUS__TYPES_H_ #define _ZAURUS__TYPES_H_ @@ -6,5 +6,6 @@ #include <arm/_types.h> #define __HAVE_GENERIC_SOFT_INTERRUPTS +#define __HAVE_MUTEX #endif diff --git a/sys/arch/zaurus/include/intr.h b/sys/arch/zaurus/include/intr.h index 9a2f1322ff8..24fe0fb3e11 100644 --- a/sys/arch/zaurus/include/intr.h +++ b/sys/arch/zaurus/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.6 2006/05/31 18:01:07 miod Exp $ */ +/* $OpenBSD: intr.h,v 1.7 2007/05/15 05:26:45 miod Exp $ */ /* $NetBSD: intr.h,v 1.12 2003/06/16 20:00:59 thorpej Exp $ */ /* @@ -77,50 +77,6 @@ #include <sys/device.h> #include <sys/queue.h> -#if defined(_LKM) - -int _splraise(int); -int _spllower(int); -void splx(int); -void _setsoftintr(int); - -#else /* _LKM */ - -/* - * Each board needs to define the following functions: - * - * int _splraise(int); - * int _spllower(int); - * void splx(int); - * void _setsoftintr(int); - * - * These may be defined as functions, static __inline functions, or macros, - * but there must be a _spllower() and splx() defined as functions callable - * from assembly language (for cpu_switch()). However, since it's quite - * useful to be able to inline splx(), you could do something like the - * following: - * - * in <boardtype>_intr.h: - * static __inline int - * boardtype_splx(int spl) - * {...} - * - * #define splx(nspl) boardtype_splx(nspl) - * ... - * and in boardtype's machdep code: - * - * ... - * #undef splx - * int - * splx(int spl) - * { - * return boardtype_splx(spl); - * } - */ - - -#endif /* _LKM */ - #define splhigh() _splraise(IPL_HIGH) #define splsoft() _splraise(IPL_SOFT) #define splsoftclock() _splraise(IPL_SOFTCLOCK) @@ -139,15 +95,10 @@ void _setsoftintr(int); #define splsched() splhigh() #define spllock() splhigh() -/* Use generic software interrupt support. */ -#include <arm/softintr.h> - #endif /* ! _LOCORE */ #include <arm/xscale/pxa2x0_intr.h> -#define splassert(wantipl) do { /* nada */ } while (0) - #endif /* _KERNEL */ #endif /* _EVBARM_INTR_H_ */ diff --git a/sys/arch/zaurus/include/mutex.h b/sys/arch/zaurus/include/mutex.h new file mode 100644 index 00000000000..ee9afd9e522 --- /dev/null +++ b/sys/arch/zaurus/include/mutex.h @@ -0,0 +1,3 @@ +/* $OpenBSD: mutex.h,v 1.1 2007/05/15 05:26:45 miod Exp $ */ +/* public domain */ +#include <arm/xscale/pxa2x0_mutex.h> |