4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain this list of conditions
8 * and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce this list of conditions
10 * and the following disclaimer in the documentation and/or other materials
11 * provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
14 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
15 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
16 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
21 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * Byte write bus space function for 8-bit IO registers mapped on a
27 * 16-bit bus with an A0 address line.
30 #include <machine/asm.h>
31 #include <arm/armreg.h>
33 ENTRY(nobyteacc_bs_w_1)
34 tst r2, #1 /* even or odd byte offset? */
35 bic r2, r2, #1 /* halfword-align offset */
36 add r1, r1, r2 /* halfword address */
37 mrs r2, cpsr /* r2 = old interrupt state */
38 orr r0, r2, #(I32_bit | F32_bit) /* interrupts off */
40 ldrh r0, [r1] /* read the halfword */
41 andeq r0, r0, #0xff00 /* even: preserve existing hi byte */
42 andeq r3, r3, #0x00ff /* even: mask junk in new hi byte */
43 orreq r0, r0, r3 /* even: or in new data in lo byte */
44 andne r0, r0, #0x00ff /* odd: preserve existing lo byte */
45 orrne r0, r0, r3, lsl #8 /* odd: or data shifted to hi byte */
46 strh r0, [r1] /* store back halfword */
47 msr cpsr, r2 /* restore interrupts */