[BACK]Return to bus.h CVS log [TXT][DIR] Up to [local] / sys / arch / hp300 / include

Annotation of sys/arch/hp300/include/bus.h, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: bus.h,v 1.5 2007/04/10 18:02:48 miod Exp $    */
                      2: /*     $NetBSD: bus.h,v 1.9 1998/01/13 18:32:15 scottr Exp $   */
                      3:
                      4: /*-
                      5:  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * This code is derived from software contributed to The NetBSD Foundation
                      9:  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
                     10:  * NASA Ames Research Center.
                     11:  *
                     12:  * Redistribution and use in source and binary forms, with or without
                     13:  * modification, are permitted provided that the following conditions
                     14:  * are met:
                     15:  * 1. Redistributions of source code must retain the above copyright
                     16:  *    notice, this list of conditions and the following disclaimer.
                     17:  * 2. Redistributions in binary form must reproduce the above copyright
                     18:  *    notice, this list of conditions and the following disclaimer in the
                     19:  *    documentation and/or other materials provided with the distribution.
                     20:  * 3. All advertising materials mentioning features or use of this software
                     21:  *    must display the following acknowledgement:
                     22:  *     This product includes software developed by the NetBSD
                     23:  *     Foundation, Inc. and its contributors.
                     24:  * 4. Neither the name of The NetBSD Foundation nor the names of its
                     25:  *    contributors may be used to endorse or promote products derived
                     26:  *    from this software without specific prior written permission.
                     27:  *
                     28:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
                     29:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
                     30:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                     31:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
                     32:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                     33:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
                     34:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
                     35:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
                     36:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
                     37:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
                     38:  * POSSIBILITY OF SUCH DAMAGE.
                     39:  */
                     40:
                     41: /*
                     42:  * Copyright (C) 1997 Scott Reynolds.  All rights reserved.
                     43:  *
                     44:  * Redistribution and use in source and binary forms, with or without
                     45:  * modification, are permitted provided that the following conditions
                     46:  * are met:
                     47:  * 1. Redistributions of source code must retain the above copyright
                     48:  *    notice, this list of conditions and the following disclaimer.
                     49:  * 2. Redistributions in binary form must reproduce the above copyright
                     50:  *    notice, this list of conditions and the following disclaimer in the
                     51:  *    documentation and/or other materials provided with the distribution.
                     52:  * 3. The name of the author may not be used to endorse or promote products
                     53:  *    derived from this software without specific prior written permission
                     54:  *
                     55:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
                     56:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     57:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
                     58:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
                     59:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
                     60:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
                     61:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
                     62:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
                     63:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
                     64:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
                     65:  */
                     66:
                     67: #ifndef _HP300_BUS_H_
                     68: #define _HP300_BUS_H_
                     69:
                     70: /*
                     71:  * Bus address and size types
                     72:  */
                     73: typedef u_long bus_addr_t;
                     74: typedef u_long bus_size_t;
                     75:
                     76: /*
                     77:  * Access methods for bus resources and address space.
                     78:  */
                     79: typedef u_long bus_space_handle_t;
                     80:
                     81: struct hp300_bus_space_tag {
                     82:        int     (*bs_map)(bus_addr_t, bus_size_t, int, bus_space_handle_t *);
                     83:        void    (*bs_unmap)(bus_space_handle_t, bus_size_t);
                     84:        int     (*bs_subregion)(bus_space_handle_t, bus_size_t, bus_size_t,
                     85:                    bus_space_handle_t *);
                     86:        void *  (*bs_vaddr)(bus_space_handle_t);
                     87:
                     88:        u_int8_t        (*bsr1)(bus_space_handle_t, bus_size_t);
                     89:        u_int16_t       (*bsr2)(bus_space_handle_t, bus_size_t);
                     90:        u_int32_t       (*bsr4)(bus_space_handle_t, bus_size_t);
                     91:        void            (*bsrm1)(bus_space_handle_t, bus_size_t,
                     92:                                u_int8_t *, size_t);
                     93:        void            (*bsrm2)(bus_space_handle_t, bus_size_t,
                     94:                                u_int16_t *, size_t);
                     95:        void            (*bsrm4)(bus_space_handle_t, bus_size_t,
                     96:                                u_int32_t *, size_t);
                     97:        void            (*bsrrm2)(bus_space_handle_t, bus_size_t,
                     98:                                u_int8_t *, size_t);
                     99:        void            (*bsrrm4)(bus_space_handle_t, bus_size_t,
                    100:                                u_int8_t *, size_t);
                    101:        void            (*bsrr1)(bus_space_handle_t, bus_size_t,
                    102:                                u_int8_t *, size_t);
                    103:        void            (*bsrr2)(bus_space_handle_t, bus_size_t,
                    104:                                u_int16_t *, size_t);
                    105:        void            (*bsrr4)(bus_space_handle_t, bus_size_t,
                    106:                                u_int32_t *, size_t);
                    107:        void            (*bsrrr2)(bus_space_handle_t, bus_size_t,
                    108:                                u_int8_t *, size_t);
                    109:        void            (*bsrrr4)(bus_space_handle_t, bus_size_t,
                    110:                                u_int8_t *, size_t);
                    111:        void            (*bsw1)(bus_space_handle_t, bus_size_t, u_int8_t);
                    112:        void            (*bsw2)(bus_space_handle_t, bus_size_t,
                    113:                                u_int16_t);
                    114:        void            (*bsw4)(bus_space_handle_t, bus_size_t,
                    115:                                u_int32_t);
                    116:        void            (*bswm1)(bus_space_handle_t, bus_size_t,
                    117:                                const u_int8_t *, size_t);
                    118:        void            (*bswm2)(bus_space_handle_t, bus_size_t,
                    119:                                const u_int16_t *, size_t);
                    120:        void            (*bswm4)(bus_space_handle_t, bus_size_t,
                    121:                                const u_int32_t *, size_t);
                    122:        void            (*bswrm2)(bus_space_handle_t, bus_size_t,
                    123:                                const u_int8_t *, size_t);
                    124:        void            (*bswrm4)(bus_space_handle_t, bus_size_t,
                    125:                                const u_int8_t *, size_t);
                    126:        void            (*bswr1)(bus_space_handle_t, bus_size_t,
                    127:                                const u_int8_t *, size_t);
                    128:        void            (*bswr2)(bus_space_handle_t, bus_size_t,
                    129:                                const u_int16_t *, size_t);
                    130:        void            (*bswr4)(bus_space_handle_t, bus_size_t,
                    131:                                const u_int32_t *, size_t);
                    132:        void            (*bswrr2)(bus_space_handle_t, bus_size_t,
                    133:                                const u_int8_t *, size_t);
                    134:        void            (*bswrr4)(bus_space_handle_t, bus_size_t,
                    135:                                const u_int8_t *, size_t);
                    136:        void            (*bssm1)(bus_space_handle_t, bus_size_t,
                    137:                                u_int8_t v, size_t);
                    138:        void            (*bssm2)(bus_space_handle_t, bus_size_t,
                    139:                                u_int16_t v, size_t);
                    140:        void            (*bssm4)(bus_space_handle_t, bus_size_t,
                    141:                                u_int32_t v, size_t);
                    142:        void            (*bssr1)(bus_space_handle_t, bus_size_t,
                    143:                                u_int8_t v, size_t);
                    144:        void            (*bssr2)(bus_space_handle_t, bus_size_t,
                    145:                                u_int16_t v, size_t);
                    146:        void            (*bssr4)(bus_space_handle_t, bus_size_t,
                    147:                                u_int32_t v, size_t);
                    148: };
                    149:
                    150: typedef const struct hp300_bus_space_tag *bus_space_tag_t;
                    151:
                    152: #define        BUS_SPACE_MAP_CACHEABLE         0x01
                    153: #define        BUS_SPACE_MAP_LINEAR            0x02
                    154: #define        BUS_SPACE_MAP_PREFETCHABLE      0x04
                    155:
                    156: #define bus_space_map(t,a,s,f,r)       ((t)->bs_map(a,s,f,r))
                    157: #define bus_space_unmap(t,h,s)         ((t)->bs_unmap(h,s))
                    158: #define bus_space_subregion(t,h,o,s,r) ((t)->bs_subregion(h,o,s,r))
                    159: #define bus_space_vaddr(t,h)           ((t)->bs_vaddr(h))
                    160:
                    161: /*
                    162:  *     u_intN_t bus_space_read_N(bus_space_tag_t tag,
                    163:  *         bus_space_handle_t bsh, bus_size_t offset);
                    164:  *
                    165:  * Read a 1, 2, 4, or 8 byte quantity from bus space
                    166:  * described by tag/handle/offset.
                    167:  */
                    168:
                    169: #define        bus_space_read_1(t,h,o) (t)->bsr1(h, o)
                    170: #define        bus_space_read_2(t,h,o) (t)->bsr2(h, o)
                    171: #define        bus_space_read_4(t,h,o) (t)->bsr4(h, o)
                    172:
                    173: /*
                    174:  *     void bus_space_read_multi_N(bus_space_tag_t tag,
                    175:  *         bus_space_handle_t bsh, bus_size_t offset,
                    176:  *         u_intN_t *addr, size_t count);
                    177:  *
                    178:  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
                    179:  * described by tag/handle/offset and copy into buffer provided.
                    180:  */
                    181:
                    182: #define bus_space_read_multi_1(t, h, o, a, c) (t)->bsrm1(h, o, a, c)
                    183: #define bus_space_read_multi_2(t, h, o, a, c) (t)->bsrm2(h, o, a, c)
                    184: #define bus_space_read_multi_4(t, h, o, a, c) (t)->bsrm4(h, o, a, c)
                    185: #define bus_space_read_raw_multi_2(t, h, o, a, c) (t)->bsrrm2(h, o, a, c)
                    186: #define bus_space_read_raw_multi_4(t, h, o, a, c) (t)->bsrrm4(h, o, a, c)
                    187:
                    188: /*
                    189:  *     void bus_space_read_region_N(bus_space_tag_t tag,
                    190:  *         bus_space_handle_t bsh, bus_size_t offset,
                    191:  *         u_intN_t *addr, size_t count);
                    192:  *
                    193:  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
                    194:  * described by tag/handle and starting at `offset' and copy into
                    195:  * buffer provided.
                    196:  */
                    197:
                    198: #define bus_space_read_region_1(t, h, o, a, c) (t)->bsrr1(h,o,a,c)
                    199: #define bus_space_read_region_2(t, h, o, a, c) (t)->bsrr2(h,o,a,c)
                    200: #define bus_space_read_region_4(t, h, o, a, c) (t)->bsrr4(h,o,a,c)
                    201: #define bus_space_read_raw_region_2(t, h, o, a, c) (t)->bsrrr2(h,o,a,c)
                    202: #define bus_space_read_raw_region_4(t, h, o, a, c) (t)->bsrrr4(h,o,a,c)
                    203:
                    204: /*
                    205:  *     void bus_space_write_N(bus_space_tag_t tag,
                    206:  *         bus_space_handle_t bsh, bus_size_t offset,
                    207:  *         u_intN_t value);
                    208:  *
                    209:  * Write the 1, 2, 4, or 8 byte value `value' to bus space
                    210:  * described by tag/handle/offset.
                    211:  */
                    212:
                    213: #define bus_space_write_1(t, h, o, v) (t)->bsw1(h, o, v)
                    214: #define bus_space_write_2(t, h, o, v) (t)->bsw2(h, o, v)
                    215: #define bus_space_write_4(t, h, o, v) (t)->bsw4(h, o, v)
                    216:
                    217: /*
                    218:  *     void bus_space_write_multi_N(bus_space_tag_t tag,
                    219:  *         bus_space_handle_t bsh, bus_size_t offset,
                    220:  *         const u_intN_t *addr, size_t count);
                    221:  *
                    222:  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
                    223:  * provided to bus space described by tag/handle/offset.
                    224:  */
                    225:
                    226: #define bus_space_write_multi_1(t, h, o, a, c) (t)->bswm1(h, o, a, c)
                    227: #define bus_space_write_multi_2(t, h, o, a, c) (t)->bswm2(h, o, a, c)
                    228: #define bus_space_write_multi_4(t, h, o, a, c) (t)->bswm4(h, o, a, c)
                    229: #define bus_space_write_raw_multi_2(t, h, o, a, c) (t)->bswrm2(h, o, a, c)
                    230: #define bus_space_write_raw_multi_4(t, h, o, a, c) (t)->bswrm4(h, o, a, c)
                    231:
                    232: /*
                    233:  *     void bus_space_write_region_N(bus_space_tag_t tag,
                    234:  *         bus_space_handle_t bsh, bus_size_t offset,
                    235:  *         const u_intN_t *addr, size_t count);
                    236:  *
                    237:  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
                    238:  * to bus space described by tag/handle starting at `offset'.
                    239:  */
                    240:
                    241: #define bus_space_write_region_1(t, h, o, a, c) (t)->bswr1(h, o, a, c)
                    242: #define bus_space_write_region_2(t, h, o, a, c) (t)->bswr2(h, o, a, c)
                    243: #define bus_space_write_region_4(t, h, o, a, c) (t)->bswr4(h, o, a, c)
                    244: #define bus_space_write_raw_region_2(t, h, o, a, c) (t)->bswrr2(h, o, a, c)
                    245: #define bus_space_write_raw_region_4(t, h, o, a, c) (t)->bswrr4(h, o, a, c)
                    246:
                    247: /*
                    248:  *     void bus_space_set_multi_N(bus_space_tag_t tag,
                    249:  *         bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
                    250:  *         size_t count);
                    251:  *
                    252:  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
                    253:  * by tag/handle/offset `count' times.
                    254:  */
                    255:
                    256: #define bus_space_set_multi_1(t, h, o, val, c) (t)->bssm1(h, o, val, c)
                    257: #define bus_space_set_multi_2(t, h, o, val, c) (t)->bssm2(h, o, val, c)
                    258: #define bus_space_set_multi_4(t, h, o, val, c) (t)->bssm4(h, o, val, c)
                    259:
                    260: /*
                    261:  *     void bus_space_set_region_N(bus_space_tag_t tag,
                    262:  *         bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
                    263:  *         size_t count);
                    264:  *
                    265:  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
                    266:  * by tag/handle starting at `offset'.
                    267:  */
                    268:
                    269: #define bus_space_set_region_1(t, h, o, val, c) (t)->bssr1(h, o, val, c)
                    270: #define bus_space_set_region_2(t, h, o, val, c) (t)->bssr2(h, o, val, c)
                    271: #define bus_space_set_region_4(t, h, o, val, c) (t)->bssr4(h, o, val, c)
                    272:
                    273: /*
                    274:  * Bus read/write barrier methods.
                    275:  *
                    276:  *     void bus_space_barrier(bus_space_tag_t tag,
                    277:  *         bus_space_handle_t bsh, bus_size_t offset,
                    278:  *         bus_size_t len, int flags);
                    279:  *
                    280:  * Note: the 680x0 does not currently require barriers, but we must
                    281:  * provide the flags to MI code.
                    282:  */
                    283: #define        bus_space_barrier(t, h, o, l, f)        \
                    284:        ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
                    285: #define        BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
                    286: #define        BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
                    287:
                    288: #endif /* _HP300_BUS_H_ */

CVSweb