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/arch/arm/xscale | |
parent | 6f5d7c74dcd62f8b14ef5f388edeb24e190788fc (diff) |
Dummy mutex code for arm platforms. ok drahn@ deraadt@
Diffstat (limited to 'sys/arch/arm/xscale')
-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 |
7 files changed, 263 insertions, 5 deletions
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 |