diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2013-05-09 20:41:48 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2013-05-09 20:41:48 +0000 |
commit | 6bc70803872b4e2ea37eae6700e2ab6df4de214a (patch) | |
tree | 357c95bcf09c3b9cc05cf7417b5b850849ba8488 /sys/arch/arm | |
parent | 89307efdeee699ce5deeb8e6f7c527e1328869e3 (diff) |
Drain the bufs after or before we do a bus space operation on ARMv7.
ok miod@
Diffstat (limited to 'sys/arch/arm')
-rw-r--r-- | sys/arch/arm/armv7/armv7_space.c | 55 | ||||
-rw-r--r-- | sys/arch/arm/armv7/bus_space_asm_armv7.S | 364 | ||||
-rw-r--r-- | sys/arch/arm/conf/files.arm | 3 |
3 files changed, 393 insertions, 29 deletions
diff --git a/sys/arch/arm/armv7/armv7_space.c b/sys/arch/arm/armv7/armv7_space.c index df0aede80e1..2103bc11540 100644 --- a/sys/arch/arm/armv7/armv7_space.c +++ b/sys/arch/arm/armv7/armv7_space.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7_space.c,v 1.2 2012/12/05 23:20:11 deraadt Exp $ */ +/* $OpenBSD: armv7_space.c,v 1.3 2013/05/09 20:41:47 patrick Exp $ */ /* * Copyright (c) 2001, 2002 Wasabi Systems, Inc. @@ -85,7 +85,6 @@ /* Prototypes for all the bus_space structure functions */ bs_protos(armv7); bs_protos(generic); -bs_protos(generic_armv4); bs_protos(bs_notimpl); struct bus_space armv7_bs_tag = { @@ -98,7 +97,7 @@ struct bus_space armv7_bs_tag = { armv7_bs_subregion, /* allocation/deallocation */ - armv7_bs_alloc, /* not implemented */ + armv7_bs_alloc, /* not implemented */ armv7_bs_free, /* not implemented */ /* get kernel virtual address */ @@ -111,39 +110,39 @@ struct bus_space armv7_bs_tag = { armv7_bs_barrier, /* read (single) */ - generic_bs_r_1, - generic_armv4_bs_r_2, - generic_bs_r_4, + armv7_bs_r_1, + armv7_bs_r_2, + armv7_bs_r_4, bs_notimpl_bs_r_8, /* read multiple */ - generic_bs_rm_1, - generic_armv4_bs_rm_2, - generic_bs_rm_4, + armv7_bs_rm_1, + armv7_bs_rm_2, + armv7_bs_rm_4, bs_notimpl_bs_rm_8, /* read region */ - generic_bs_rr_1, - generic_armv4_bs_rr_2, - generic_bs_rr_4, + armv7_bs_rr_1, + armv7_bs_rr_2, + armv7_bs_rr_4, bs_notimpl_bs_rr_8, /* write (single) */ - generic_bs_w_1, - generic_armv4_bs_w_2, - generic_bs_w_4, + armv7_bs_w_1, + armv7_bs_w_2, + armv7_bs_w_4, bs_notimpl_bs_w_8, /* write multiple */ - generic_bs_wm_1, - generic_armv4_bs_wm_2, - generic_bs_wm_4, + armv7_bs_wm_1, + armv7_bs_wm_2, + armv7_bs_wm_4, bs_notimpl_bs_wm_8, /* write region */ - generic_bs_wr_1, - generic_armv4_bs_wr_2, - generic_bs_wr_4, + armv7_bs_wr_1, + armv7_bs_wr_2, + armv7_bs_wr_4, bs_notimpl_bs_wr_8, /* set multiple */ @@ -153,14 +152,14 @@ struct bus_space armv7_bs_tag = { bs_notimpl_bs_sm_8, /* set region */ - generic_bs_sr_1, - generic_armv4_bs_sr_2, + armv7_bs_sr_1, + armv7_bs_sr_2, bs_notimpl_bs_sr_4, bs_notimpl_bs_sr_8, /* copy */ bs_notimpl_bs_c_1, - generic_armv4_bs_c_2, + armv7_bs_c_2, bs_notimpl_bs_c_4, bs_notimpl_bs_c_8, }; @@ -197,6 +196,7 @@ armv7_bs_map(void *t, bus_addr_t bpa, bus_size_t size, if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) { pte = vtopte(va); *pte &= ~L2_S_CACHE_MASK; + *pte |= L2_B; PTE_SYNC(pte); /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of * waste. @@ -212,7 +212,7 @@ void armv7_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) { - if (bsh > (u_long)KERNEL_BASE) + if (bsh > (u_long)KERNEL_BASE) return; uvm_km_free(kernel_map, bsh, size); @@ -232,8 +232,7 @@ void armv7_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, bus_size_t len, int flags) { - - /* Nothing to do. */ + cpu_drain_writebuf(); } void * @@ -253,7 +252,7 @@ armv7_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, panic("armv7_io_bs_alloc(): not implemented"); } -void +void armv7_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) { diff --git a/sys/arch/arm/armv7/bus_space_asm_armv7.S b/sys/arch/arm/armv7/bus_space_asm_armv7.S new file mode 100644 index 00000000000..445539d6dd5 --- /dev/null +++ b/sys/arch/arm/armv7/bus_space_asm_armv7.S @@ -0,0 +1,364 @@ +/* $OpenBSD: bus_space_asm_armv7.S,v 1.1 2013/05/09 20:41:47 patrick Exp $ */ +/* $NetBSD: bus_space_asm_armv7.S,v 1.3 2003/03/27 19:46:14 mycroft Exp $ */ + +/* + * Copyright (c) 1997 Causality Limited. + * Copyright (c) 1997 Mark Brinicombe. + * 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. 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 by Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may 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 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. + */ + +#include <arm/asm.h> +#include <arm/cpuconf.h> + +#define DSB .long 0xf57ff040 +#define ISB .long 0xf57ff060 +#define WFI .long 0xe320f003 + +/* + * Generic bus_space functions. + */ + +/* + * read single + */ + +ENTRY(armv7_bs_r_1) + DSB + ldrb r0, [r1, r2] + mov pc, lr + +#if (ARM_ARCH_4 + ARM_ARCH_5 + ARM_ARCH_6 + ARM_ARCH_7) > 0 +ENTRY(armv7_bs_r_2) + DSB + ldrh r0, [r1, r2] + mov pc, lr +#endif + +ENTRY(armv7_bs_r_4) + DSB + ldr r0, [r1, r2] + mov pc, lr + +/* + * write single + */ + +ENTRY(armv7_bs_w_1) + strb r3, [r1, r2] + DSB + mov pc, lr + +ENTRY(armv7_bs_w_2) + strh r3, [r1, r2] + DSB + mov pc, lr + +ENTRY(armv7_bs_w_4) + str r3, [r1, r2] + DSB + mov pc, lr + +/* + * read multiple + */ + +ENTRY(armv7_bs_rm_1) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrb r3, [r0] + strb r3, [r1], #1 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_rm_2) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrh r3, [r0] + strh r3, [r1], #2 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_rm_4) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldr r3, [r0] + str r3, [r1], #4 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +/* + * write multiple + */ + +ENTRY(armv7_bs_wm_1) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrb r3, [r1], #1 + strb r3, [r0] + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_wm_2) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrh r3, [r1], #2 + strh r3, [r0] + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_wm_4) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldr r3, [r1], #4 + str r3, [r0] + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +/* + * read region + */ + +ENTRY(armv7_bs_rr_1) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrb r3, [r0], #1 + strb r3, [r1], #1 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_rr_2) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrh r3, [r0], #2 + strh r3, [r1], #2 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_rr_4) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldr r3, [r0], #4 + str r3, [r1], #4 + subs r2, r2, #1 + bne 1b + + mov pc, lr + +/* + * write region. + */ + +ENTRY(armv7_bs_wr_1) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrb r3, [r1], #1 + strb r3, [r0], #1 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_wr_2) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldrh r3, [r1], #2 + strh r3, [r0], #2 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_wr_4) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: ldr r3, [r1], #4 + str r3, [r0], #4 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +/* + * set region + */ + +ENTRY(armv7_bs_sr_1) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: strb r1, [r0], #1 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_sr_2) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: strh r1, [r0], #2 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +ENTRY(armv7_bs_sr_4) + add r0, r1, r2 + mov r1, r3 + ldr r2, [sp, #0] + teq r2, #0 + moveq pc, lr + +1: str r1, [r0], #4 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +/* + * copy region + */ + +ENTRY(armv7_bs_c_2) + add r0, r1, r2 + ldr r2, [sp, #0] + add r1, r2, r3 + ldr r2, [sp, #4] + teq r2, #0 + moveq pc, lr + + cmp r0, r1 + blt 2f + +1: ldrh r3, [r0], #2 + strh r3, [r1], #2 + subs r2, r2, #1 + bne 1b + DSB + + mov pc, lr + +2: add r0, r0, r2, lsl #1 + add r1, r1, r2, lsl #1 + sub r0, r0, #2 + sub r1, r1, #2 + +3: ldrh r3, [r0], #-2 + strh r3, [r1], #-2 + subs r2, r2, #1 + bne 3b + DSB + + mov pc, lr diff --git a/sys/arch/arm/conf/files.arm b/sys/arch/arm/conf/files.arm index e358311f16e..91c0f1a8f5c 100644 --- a/sys/arch/arm/conf/files.arm +++ b/sys/arch/arm/conf/files.arm @@ -1,4 +1,4 @@ -# $OpenBSD: files.arm,v 1.24 2013/05/01 00:16:26 patrick Exp $ +# $OpenBSD: files.arm,v 1.25 2013/05/09 20:41:47 patrick Exp $ # $NetBSD: files.arm,v 1.76 2003/11/05 12:53:15 scw Exp $ # generic networking files @@ -92,6 +92,7 @@ file arch/arm/armv7/armv7_space.c cpu_armv7 file arch/arm/armv7/armv7_a4x_space.c cpu_armv7 file arch/arm/armv7/armv7_a4x_io.S cpu_armv7 file arch/arm/armv7/armv7_mutex.c cpu_armv7 +file arch/arm/armv7/bus_space_asm_armv7.S cpu_armv7 # arm library functions file arch/arm/arm/bcopy_page.S |