[BACK]Return to bus.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / news68k / include

Annotation of src/sys/arch/news68k/include/bus.h, Revision 1.10

1.10    ! skrll       1: /*     $NetBSD: bus.h,v 1.9 2012/05/07 18:16:38 tsutsui Exp $  */
1.1       tsutsui     2:
                      3: /*-
                      4:  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
                      5:  * All rights reserved.
                      6:  *
                      7:  * This code is derived from software contributed to The NetBSD Foundation
                      8:  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
                      9:  * NASA Ames Research Center.
                     10:  *
                     11:  * Redistribution and use in source and binary forms, with or without
                     12:  * modification, are permitted provided that the following conditions
                     13:  * are met:
                     14:  * 1. Redistributions of source code must retain the above copyright
                     15:  *    notice, this list of conditions and the following disclaimer.
                     16:  * 2. Redistributions in binary form must reproduce the above copyright
                     17:  *    notice, this list of conditions and the following disclaimer in the
                     18:  *    documentation and/or other materials provided with the distribution.
                     19:  *
                     20:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     21:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     22:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     23:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     24:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     25:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     26:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     27:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     28:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     29:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     30:  * POSSIBILITY OF SUCH DAMAGE.
                     31:  */
                     32:
                     33: /*
                     34:  * Copyright (C) 1997 Scott Reynolds.  All rights reserved.
                     35:  *
                     36:  * Redistribution and use in source and binary forms, with or without
                     37:  * modification, are permitted provided that the following conditions
                     38:  * are met:
                     39:  * 1. Redistributions of source code must retain the above copyright
                     40:  *    notice, this list of conditions and the following disclaimer.
                     41:  * 2. Redistributions in binary form must reproduce the above copyright
                     42:  *    notice, this list of conditions and the following disclaimer in the
                     43:  *    documentation and/or other materials provided with the distribution.
                     44:  * 3. The name of the author may not be used to endorse or promote products
                     45:  *    derived from this software without specific prior written permission
                     46:  *
                     47:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     48:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     49:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     50:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     51:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     52:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     53:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     54:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     55:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     56:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     57:  */
                     58:
                     59: /* bus_space(9) functions for news68k. Just taken from hp300. */
                     60:
                     61: #ifndef _NEWS68K_BUS_H_
                     62: #define _NEWS68K_BUS_H_
                     63:
                     64: /*
                     65:  * Values for the news68k bus space tag, not to be used directly by MI code.
                     66:  */
                     67: #define        NEWS68K_BUS_SPACE_INTIO 0       /* space is intio space */
                     68: #define        NEWS68K_BUS_SPACE_EIO   1       /* space is eio space */
                     69:
                     70: /*
                     71:  * Bus address and size types
                     72:  */
                     73: typedef u_long bus_addr_t;
                     74: typedef u_long bus_size_t;
                     75:
1.10    ! skrll      76: #define PRIxBUSADDR    "lx"
        !            77: #define PRIxBUSSIZE    "lx"
        !            78: #define PRIuBUSSIZE    "lu"
        !            79:
1.1       tsutsui    80: /*
                     81:  * Access methods for bus resources and address space.
                     82:  */
                     83: typedef int    bus_space_tag_t;
                     84: typedef u_long bus_space_handle_t;
                     85:
1.10    ! skrll      86: #define PRIxBSH                "lx"
        !            87:
1.1       tsutsui    88: /*
1.2       tsutsui    89:  *     int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
                     90:  *         bus_size_t size, int flags, bus_space_handle_t *bshp);
1.1       tsutsui    91:  *
                     92:  * Map a region of bus space.
                     93:  */
                     94:
                     95: #define        BUS_SPACE_MAP_CACHEABLE         0x01
                     96: #define        BUS_SPACE_MAP_LINEAR            0x02
                     97: #define        BUS_SPACE_MAP_PREFETCHABLE      0x04
                     98:
1.2       tsutsui    99: int    bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
                    100:            int, bus_space_handle_t *);
1.1       tsutsui   101:
                    102: /*
1.2       tsutsui   103:  *     void bus_space_unmap(bus_space_tag_t t,
                    104:  *         bus_space_handle_t bsh, bus_size_t size);
1.1       tsutsui   105:  *
                    106:  * Unmap a region of bus space.
                    107:  */
                    108:
1.2       tsutsui   109: void   bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
1.1       tsutsui   110:
                    111: /*
1.2       tsutsui   112:  *     int bus_space_subregion(bus_space_tag_t t,
1.1       tsutsui   113:  *         bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
1.2       tsutsui   114:  *         bus_space_handle_t *nbshp);
1.1       tsutsui   115:  *
                    116:  * Get a new handle for a subregion of an already-mapped area of bus space.
                    117:  */
                    118:
1.2       tsutsui   119: int    bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
                    120:            bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
1.1       tsutsui   121:
                    122: /*
1.2       tsutsui   123:  *     int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart,
1.1       tsutsui   124:  *         bus_addr_t rend, bus_size_t size, bus_size_t align,
                    125:  *         bus_size_t boundary, int flags, bus_addr_t *addrp,
1.2       tsutsui   126:  *         bus_space_handle_t *bshp);
1.1       tsutsui   127:  *
                    128:  * Allocate a region of bus space.
                    129:  */
                    130:
1.2       tsutsui   131: int    bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
1.1       tsutsui   132:            bus_addr_t rend, bus_size_t size, bus_size_t align,
                    133:            bus_size_t boundary, int cacheable, bus_addr_t *addrp,
1.2       tsutsui   134:            bus_space_handle_t *bshp);
1.1       tsutsui   135:
                    136: /*
1.2       tsutsui   137:  *     int bus_space_free(bus_space_tag_t t,
                    138:  *         bus_space_handle_t bsh, bus_size_t size);
1.1       tsutsui   139:  *
                    140:  * Free a region of bus space.
                    141:  */
                    142:
1.2       tsutsui   143: void   bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
                    144:            bus_size_t size);
1.1       tsutsui   145:
                    146: /*
1.2       tsutsui   147:  *     int news68k_bus_space_probe(bus_space_tag_t t,
                    148:  *         bus_space_handle_t bsh, bus_size_t offset, int sz);
1.1       tsutsui   149:  *
                    150:  * Probe the bus at t/bsh/offset, using sz as the size of the load.
                    151:  *
                    152:  * This is a machine-dependent extension, and is not to be used by
                    153:  * machine-independent code.
                    154:  */
                    155:
1.2       tsutsui   156: int    news68k_bus_space_probe(bus_space_tag_t t,
                    157:            bus_space_handle_t bsh, bus_size_t offset, int sz);
1.1       tsutsui   158:
                    159: /*
1.4       tsutsui   160:  *     uintN_t bus_space_read_N(bus_space_tag_t tag,
1.2       tsutsui   161:  *         bus_space_handle_t bsh, bus_size_t offset);
1.1       tsutsui   162:  *
                    163:  * Read a 1, 2, 4, or 8 byte quantity from bus space
                    164:  * described by tag/handle/offset.
                    165:  */
                    166:
                    167: #define        bus_space_read_1(t, h, o)                                       \
1.4       tsutsui   168:     ((void) t, (*(volatile uint8_t *)((h) + (o))))
1.1       tsutsui   169:
                    170: #define        bus_space_read_2(t, h, o)                                       \
1.4       tsutsui   171:     ((void) t, (*(volatile uint16_t *)((h) + (o))))
1.1       tsutsui   172:
                    173: #define        bus_space_read_4(t, h, o)                                       \
1.4       tsutsui   174:     ((void) t, (*(volatile uint32_t *)((h) + (o))))
1.1       tsutsui   175:
                    176: #if 0  /* Cause a link error for bus_space_read_8 */
                    177: #define        bus_space_read_8(t, h, o)       !!! bus_space_read_8 unimplemented !!!
                    178: #endif
                    179:
                    180: /*
1.2       tsutsui   181:  *     void bus_space_read_multi_N(bus_space_tag_t tag,
1.1       tsutsui   182:  *         bus_space_handle_t bsh, bus_size_t offset,
1.4       tsutsui   183:  *         uintN_t *addr, size_t count);
1.1       tsutsui   184:  *
                    185:  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
                    186:  * described by tag/handle/offset and copy into buffer provided.
                    187:  */
                    188:
                    189: #define        bus_space_read_multi_1(t, h, o, a, c) do {                      \
                    190:        (void) t;                                                       \
1.6       perry     191:        __asm volatile ("                                               \
1.1       tsutsui   192:                movl    %0,%%a0                                 ;       \
                    193:                movl    %1,%%a1                                 ;       \
                    194:                movl    %2,%%d0                                 ;       \
                    195:        1:      movb    %%a0@,%%a1@+                            ;       \
                    196:                subql   #1,%%d0                                 ;       \
                    197:                jne     1b"                                     :       \
                    198:                                                                :       \
                    199:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    200:                    "%a0","%a1","%d0");                                 \
                    201: } while (0)
                    202:
                    203: #define        bus_space_read_multi_2(t, h, o, a, c) do {                      \
                    204:        (void) t;                                                       \
1.6       perry     205:        __asm volatile ("                                               \
1.1       tsutsui   206:                movl    %0,%%a0                                 ;       \
                    207:                movl    %1,%%a1                                 ;       \
                    208:                movl    %2,%%d0                                 ;       \
                    209:        1:      movw    %%a0@,%%a1@+                            ;       \
                    210:                subql   #1,%%d0                                 ;       \
                    211:                jne     1b"                                     :       \
                    212:                                                                :       \
                    213:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    214:                    "%a0","%a1","%d0");                                 \
                    215: } while (0)
                    216:
                    217: #define        bus_space_read_multi_4(t, h, o, a, c) do {                      \
                    218:        (void) t;                                                       \
1.6       perry     219:        __asm volatile ("                                               \
1.1       tsutsui   220:                movl    %0,%%a0                                 ;       \
                    221:                movl    %1,%%a1                                 ;       \
                    222:                movl    %2,%%d0                                 ;       \
                    223:        1:      movl    %%a0@,%%a1@+                            ;       \
                    224:                subql   #1,%%d0                                 ;       \
                    225:                jne     1b"                                     :       \
                    226:                                                                :       \
                    227:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    228:                    "%a0","%a1","%d0");                                 \
                    229: } while (0)
                    230:
                    231: #if 0  /* Cause a link error for bus_space_read_multi_8 */
                    232: #define        bus_space_read_multi_8  !!! bus_space_read_multi_8 unimplemented !!!
                    233: #endif
                    234:
                    235: /*
1.2       tsutsui   236:  *     void bus_space_read_region_N(bus_space_tag_t tag,
1.1       tsutsui   237:  *         bus_space_handle_t bsh, bus_size_t offset,
1.4       tsutsui   238:  *         uintN_t *addr, size_t count);
1.1       tsutsui   239:  *
                    240:  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
                    241:  * described by tag/handle and starting at `offset' and copy into
                    242:  * buffer provided.
                    243:  */
                    244:
                    245: #define        bus_space_read_region_1(t, h, o, a, c) do {                     \
                    246:        (void) t;                                                       \
1.6       perry     247:        __asm volatile ("                                               \
1.1       tsutsui   248:                movl    %0,%%a0                                 ;       \
                    249:                movl    %1,%%a1                                 ;       \
                    250:                movl    %2,%%d0                                 ;       \
                    251:        1:      movb    %%a0@+,%%a1@+                           ;       \
                    252:                subql   #1,%%d0                                 ;       \
                    253:                jne     1b"                                     :       \
                    254:                                                                :       \
                    255:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    256:                    "%a0","%a1","%d0");                                 \
                    257: } while (0)
                    258:
                    259: #define        bus_space_read_region_2(t, h, o, a, c) do {                     \
                    260:        (void) t;                                                       \
1.6       perry     261:        __asm volatile ("                                               \
1.1       tsutsui   262:                movl    %0,%%a0                                 ;       \
                    263:                movl    %1,%%a1                                 ;       \
                    264:                movl    %2,%%d0                                 ;       \
                    265:        1:      movw    %%a0@+,%%a1@+                           ;       \
                    266:                subql   #1,%%d0                                 ;       \
                    267:                jne     1b"                                     :       \
                    268:                                                                :       \
                    269:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    270:                    "%a0","%a1","%d0");                                 \
                    271: } while (0)
                    272:
                    273: #define        bus_space_read_region_4(t, h, o, a, c) do {                     \
                    274:        (void) t;                                                       \
1.6       perry     275:        __asm volatile ("                                               \
1.1       tsutsui   276:                movl    %0,%%a0                                 ;       \
                    277:                movl    %1,%%a1                                 ;       \
                    278:                movl    %2,%%d0                                 ;       \
                    279:        1:      movl    %%a0@+,%%a1@+                           ;       \
                    280:                subql   #1,%%d0                                 ;       \
                    281:                jne     1b"                                     :       \
                    282:                                                                :       \
                    283:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    284:                    "%a0","%a1","%d0");                                 \
                    285: } while (0)
                    286:
                    287: #if 0  /* Cause a link error for bus_space_read_region_8 */
                    288: #define        bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
                    289: #endif
                    290:
                    291: /*
1.2       tsutsui   292:  *     void bus_space_write_N(bus_space_tag_t tag,
1.1       tsutsui   293:  *         bus_space_handle_t bsh, bus_size_t offset,
1.4       tsutsui   294:  *         uintN_t value);
1.1       tsutsui   295:  *
                    296:  * Write the 1, 2, 4, or 8 byte value `value' to bus space
                    297:  * described by tag/handle/offset.
                    298:  */
                    299:
                    300: #define        bus_space_write_1(t, h, o, v)                                   \
1.4       tsutsui   301:     ((void) t, ((void)(*(volatile uint8_t *)((h) + (o)) = (v))))
1.1       tsutsui   302:
                    303: #define        bus_space_write_2(t, h, o, v)                                   \
1.4       tsutsui   304:     ((void) t, ((void)(*(volatile uint16_t *)((h) + (o)) = (v))))
1.1       tsutsui   305:
                    306: #define        bus_space_write_4(t, h, o, v)                                   \
1.4       tsutsui   307:     ((void) t, ((void)(*(volatile uint32_t *)((h) + (o)) = (v))))
1.1       tsutsui   308:
                    309: #if 0  /* Cause a link error for bus_space_write_8 */
                    310: #define        bus_space_write_8       !!! bus_space_write_8 not implemented !!!
                    311: #endif
                    312:
                    313: /*
1.2       tsutsui   314:  *     void bus_space_write_multi_N(bus_space_tag_t tag,
1.1       tsutsui   315:  *         bus_space_handle_t bsh, bus_size_t offset,
1.4       tsutsui   316:  *         const uintN_t *addr, size_t count);
1.1       tsutsui   317:  *
                    318:  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
                    319:  * provided to bus space described by tag/handle/offset.
                    320:  */
                    321:
                    322: #define        bus_space_write_multi_1(t, h, o, a, c) do {                     \
                    323:        (void) t;                                                       \
1.6       perry     324:        __asm volatile ("                                               \
1.1       tsutsui   325:                movl    %0,%%a0                                 ;       \
                    326:                movl    %1,%%a1                                 ;       \
                    327:                movl    %2,%%d0                                 ;       \
                    328:        1:      movb    %%a1@+,%%a0@                            ;       \
                    329:                subql   #1,%%d0                                 ;       \
                    330:                jne     1b"                                     :       \
                    331:                                                                :       \
                    332:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    333:                    "%a0","%a1","%d0");                                 \
                    334: } while (0)
                    335:
                    336: #define        bus_space_write_multi_2(t, h, o, a, c) do {                     \
                    337:        (void) t;                                                       \
1.6       perry     338:        __asm volatile ("                                               \
1.1       tsutsui   339:                movl    %0,%%a0                                 ;       \
                    340:                movl    %1,%%a1                                 ;       \
                    341:                movl    %2,%%d0                                 ;       \
                    342:        1:      movw    %%a1@+,%%a0@                            ;       \
                    343:                subql   #1,%%d0                                 ;       \
                    344:                jne     1b"                                     :       \
                    345:                                                                :       \
                    346:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    347:                    "%a0","%a1","%d0");                                 \
                    348: } while (0)
                    349:
                    350: #define        bus_space_write_multi_4(t, h, o, a, c) do {                     \
                    351:        (void) t;                                                       \
1.6       perry     352:        __asm volatile ("                                               \
1.1       tsutsui   353:                movl    %0,%%a0                                 ;       \
                    354:                movl    %1,%%a1                                 ;       \
                    355:                movl    %2,%%d0                                 ;       \
                    356:        1:      movl    %%a1@+,%%a0@                            ;       \
                    357:                subql   #1,%%d0                                 ;       \
                    358:                jne     1b"                                     :       \
                    359:                                                                :       \
                    360:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    361:                    "%a0","%a1","%d0");                                 \
                    362: } while (0)
                    363:
                    364: #if 0  /* Cause a link error for bus_space_write_8 */
                    365: #define        bus_space_write_multi_8(t, h, o, a, c)                          \
                    366:                        !!! bus_space_write_multi_8 unimplimented !!!
                    367: #endif
                    368:
                    369: /*
1.2       tsutsui   370:  *     void bus_space_write_region_N(bus_space_tag_t tag,
1.1       tsutsui   371:  *         bus_space_handle_t bsh, bus_size_t offset,
1.4       tsutsui   372:  *         const uintN_t *addr, size_t count);
1.1       tsutsui   373:  *
                    374:  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
                    375:  * to bus space described by tag/handle starting at `offset'.
                    376:  */
                    377:
                    378: #define        bus_space_write_region_1(t, h, o, a, c) do {                    \
                    379:        (void) t;                                                       \
1.6       perry     380:        __asm volatile ("                                               \
1.1       tsutsui   381:                movl    %0,%%a0                                 ;       \
                    382:                movl    %1,%%a1                                 ;       \
                    383:                movl    %2,%%d0                                 ;       \
                    384:        1:      movb    %%a1@+,%%a0@+                           ;       \
                    385:                subql   #1,%%d0                                 ;       \
                    386:                jne     1b"                                     :       \
                    387:                                                                :       \
                    388:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    389:                    "%a0","%a1","%d0");                                 \
                    390: } while (0)
                    391:
                    392: #define        bus_space_write_region_2(t, h, o, a, c) do {                    \
                    393:        (void) t;                                                       \
1.6       perry     394:        __asm volatile ("                                               \
1.1       tsutsui   395:                movl    %0,%%a0                                 ;       \
                    396:                movl    %1,%%a1                                 ;       \
                    397:                movl    %2,%%d0                                 ;       \
                    398:        1:      movw    %%a1@+,%%a0@+                           ;       \
                    399:                subql   #1,%%d0                                 ;       \
                    400:                jne     1b"                                     :       \
                    401:                                                                :       \
                    402:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    403:                    "%a0","%a1","%d0");                                 \
                    404: } while (0)
                    405:
                    406: #define        bus_space_write_region_4(t, h, o, a, c) do {                    \
                    407:        (void) t;                                                       \
1.6       perry     408:        __asm volatile ("                                               \
1.1       tsutsui   409:                movl    %0,%%a0                                 ;       \
                    410:                movl    %1,%%a1                                 ;       \
                    411:                movl    %2,%%d0                                 ;       \
                    412:        1:      movl    %%a1@+,%%a0@+                           ;       \
                    413:                subql   #1,%%d0                                 ;       \
                    414:                jne     1b"                                     :       \
                    415:                                                                :       \
                    416:                    "r" ((h) + (o)), "g" (a), "g" (c)           :       \
                    417:                    "%a0","%a1","%d0");                                 \
                    418: } while (0)
                    419:
                    420: #if 0  /* Cause a link error for bus_space_write_region_8 */
                    421: #define        bus_space_write_region_8                                        \
                    422:                        !!! bus_space_write_region_8 unimplemented !!!
                    423: #endif
                    424:
                    425: /*
1.2       tsutsui   426:  *     void bus_space_set_multi_N(bus_space_tag_t tag,
1.4       tsutsui   427:  *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
1.2       tsutsui   428:  *         size_t count);
1.1       tsutsui   429:  *
                    430:  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
                    431:  * by tag/handle/offset `count' times.
                    432:  */
                    433:
                    434: #define        bus_space_set_multi_1(t, h, o, val, c) do {                     \
                    435:        (void) t;                                                       \
1.6       perry     436:        __asm volatile ("                                               \
1.1       tsutsui   437:                movl    %0,%%a0                                 ;       \
                    438:                movl    %1,%%d1                                 ;       \
                    439:                movl    %2,%%d0                                 ;       \
                    440:        1:      movb    %%d1,%%a0@                              ;       \
                    441:                subql   #1,%%d0                                 ;       \
                    442:                jne     1b"                                     :       \
                    443:                                                                :       \
                    444:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    445:                    "%a0","%d0","%d1");                                 \
                    446: } while (0)
                    447:
                    448: #define        bus_space_set_multi_2(t, h, o, val, c) do {                     \
                    449:        (void) t;                                                       \
1.6       perry     450:        __asm volatile ("                                               \
1.1       tsutsui   451:                movl    %0,%%a0                                 ;       \
                    452:                movl    %1,%%d1                                 ;       \
                    453:                movl    %2,%%d0                                 ;       \
                    454:        1:      movw    %%d1,%%a0@                              ;       \
                    455:                subql   #1,%%d0                                 ;       \
                    456:                jne     1b"                                     :       \
                    457:                                                                :       \
                    458:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    459:                    "%a0","%d0","%d1");                                 \
                    460: } while (0)
                    461:
                    462: #define        bus_space_set_multi_4(t, h, o, val, c) do {                     \
                    463:        (void) t;                                                       \
1.6       perry     464:        __asm volatile ("                                               \
1.1       tsutsui   465:                movl    %0,%%a0                                 ;       \
                    466:                movl    %1,%%d1                                 ;       \
                    467:                movl    %2,%%d0                                 ;       \
                    468:        1:      movl    %%d1,%%a0@                              ;       \
                    469:                subql   #1,%%d0                                 ;       \
                    470:                jne     1b"                                     :       \
                    471:                                                                :       \
                    472:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    473:                    "%a0","%d0","%d1");                                 \
                    474: } while (0)
                    475:
                    476: #if 0  /* Cause a link error for bus_space_set_multi_8 */
                    477: #define        bus_space_set_multi_8                                           \
                    478:                        !!! bus_space_set_multi_8 unimplemented !!!
                    479: #endif
                    480:
                    481: /*
1.2       tsutsui   482:  *     void bus_space_set_region_N(bus_space_tag_t tag,
1.4       tsutsui   483:  *         bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
1.2       tsutsui   484:  *         size_t count);
1.1       tsutsui   485:  *
                    486:  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
                    487:  * by tag/handle starting at `offset'.
                    488:  */
                    489:
                    490: #define        bus_space_set_region_1(t, h, o, val, c) do {                    \
                    491:        (void) t;                                                       \
1.6       perry     492:        __asm volatile ("                                               \
1.1       tsutsui   493:                movl    %0,%%a0                                 ;       \
                    494:                movl    %1,%%d1                                 ;       \
                    495:                movl    %2,%%d0                                 ;       \
                    496:        1:      movb    %%d1,%%a0@+                             ;       \
                    497:                subql   #1,%%d0                                 ;       \
                    498:                jne     1b"                                     :       \
                    499:                                                                :       \
                    500:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    501:                    "%a0","%d0","%d1");                                 \
                    502: } while (0)
                    503:
                    504: #define        bus_space_set_region_2(t, h, o, val, c) do {                    \
                    505:        (void) t;                                                       \
1.6       perry     506:        __asm volatile ("                                               \
1.1       tsutsui   507:                movl    %0,%%a0                                 ;       \
                    508:                movl    %1,%%d1                                 ;       \
                    509:                movl    %2,%%d0                                 ;       \
                    510:        1:      movw    %%d1,%%a0@+                             ;       \
                    511:                subql   #1,%%d0                                 ;       \
                    512:                jne     1b"                                     :       \
                    513:                                                                :       \
                    514:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    515:                    "%a0","%d0","%d1");                                 \
                    516: } while (0)
                    517:
                    518: #define        bus_space_set_region_4(t, h, o, val, c) do {                    \
                    519:        (void) t;                                                       \
1.6       perry     520:        __asm volatile ("                                               \
1.1       tsutsui   521:                movl    %0,%%a0                                 ;       \
                    522:                movl    %1,%%d1                                 ;       \
                    523:                movl    %2,%%d0                                 ;       \
                    524:        1:      movl    %%d1,%%a0@+                             ;       \
                    525:                subql   #1,%%d0                                 ;       \
                    526:                jne     1b"                                     :       \
                    527:                                                                :       \
                    528:                    "r" ((h) + (o)), "g" (val), "g" (c)         :       \
                    529:                    "%a0","%d0","%d1");                                 \
                    530: } while (0)
                    531:
                    532: #if 0  /* Cause a link error for bus_space_set_region_8 */
                    533: #define        bus_space_set_region_8                                          \
                    534:                        !!! bus_space_set_region_8 unimplemented !!!
                    535: #endif
                    536:
                    537: /*
1.2       tsutsui   538:  *     void bus_space_copy_region_N(bus_space_tag_t tag,
1.1       tsutsui   539:  *         bus_space_handle_t bsh1, bus_size_t off1,
                    540:  *         bus_space_handle_t bsh2, bus_size_t off2,
1.2       tsutsui   541:  *         bus_size_t count);
1.1       tsutsui   542:  *
                    543:  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
                    544:  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
                    545:  */
                    546:
                    547: #define        __NEWS68K_copy_region_N(BYTES)                                  \
1.7       perry     548: static __inline void __CONCAT(bus_space_copy_region_,BYTES)            \
1.2       tsutsui   549:        (bus_space_tag_t,                                               \
                    550:         bus_space_handle_t bsh1, bus_size_t off1,                      \
                    551:         bus_space_handle_t bsh2, bus_size_t off2,                      \
                    552:         bus_size_t count);                                             \
1.1       tsutsui   553:                                                                        \
1.7       perry     554: static __inline void                                                   \
1.3       tsutsui   555: __CONCAT(bus_space_copy_region_,BYTES)(bus_space_tag_t t,              \
                    556:     bus_space_handle_t h1, bus_space_handle_t h2,                      \
                    557:     bus_size_t o1, bus_size_t o2, bus_size_t c)                                \
1.1       tsutsui   558: {                                                                      \
                    559:        bus_size_t o;                                                   \
                    560:                                                                        \
                    561:        if ((h1 + o1) >= (h2 + o2)) {                                   \
                    562:                /* src after dest: copy forward */                      \
                    563:                for (o = 0; c != 0; c--, o += BYTES)                    \
                    564:                        __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
                    565:                            __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
                    566:        } else {                                                        \
                    567:                /* dest after src: copy backwards */                    \
                    568:                for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)      \
                    569:                        __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
                    570:                            __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
                    571:        }                                                               \
                    572: }
                    573: __NEWS68K_copy_region_N(1)
                    574: __NEWS68K_copy_region_N(2)
                    575: __NEWS68K_copy_region_N(4)
                    576: #if 0  /* Cause a link error for bus_space_copy_region_8 */
                    577: #define        bus_space_copy_region_8                                         \
                    578:                        !!! bus_space_copy_region_8 unimplemented !!!
                    579: #endif
                    580:
                    581: #undef __NEWS68K_copy_region_N
                    582:
                    583: /*
                    584:  * Bus read/write barrier methods.
                    585:  *
1.2       tsutsui   586:  *     void bus_space_barrier(bus_space_tag_t tag,
1.1       tsutsui   587:  *         bus_space_handle_t bsh, bus_size_t offset,
1.2       tsutsui   588:  *         bus_size_t len, int flags);
1.1       tsutsui   589:  *
                    590:  * Note: the 680x0 does not currently require barriers, but we must
                    591:  * provide the flags to MI code.
                    592:  */
                    593: #define        bus_space_barrier(t, h, o, l, f)        \
                    594:        ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
                    595: #define        BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
                    596: #define        BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
                    597:
                    598: #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
                    599:
1.9       tsutsui   600: /*
                    601:  * There is no bus_dma(9)'fied bus drivers on this port.
                    602:  */
                    603: #define __HAVE_NO_BUS_DMA
                    604:
1.1       tsutsui   605: #endif /* _NEWS68K_BUS_H_ */

CVSweb <webmaster@jp.NetBSD.org>