Home | History | Annotate | Line # | Download | only in g2
g2bus_bus_mem.c revision 1.6
      1  1.6  tsutsui /*	$NetBSD: g2bus_bus_mem.c,v 1.6 2002/12/27 11:34:05 tsutsui Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*-
      4  1.1  thorpej  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  thorpej  * by Jason R. Thorpe.
      9  1.1  thorpej  *
     10  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11  1.1  thorpej  * modification, are permitted provided that the following conditions
     12  1.1  thorpej  * are met:
     13  1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14  1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15  1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18  1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     19  1.1  thorpej  *    must display the following acknowledgement:
     20  1.1  thorpej  *	This product includes software developed by the NetBSD
     21  1.1  thorpej  *	Foundation, Inc. and its contributors.
     22  1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1  thorpej  *    contributors may be used to endorse or promote products derived
     24  1.1  thorpej  *    from this software without specific prior written permission.
     25  1.1  thorpej  *
     26  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1  thorpej  */
     38  1.1  thorpej 
     39  1.1  thorpej /*
     40  1.1  thorpej  * Bus space implementation for the SEGA G2 bus.
     41  1.1  thorpej  *
     42  1.1  thorpej  * NOTE: We only implement a small subset of what the bus_space(9)
     43  1.1  thorpej  * API specifies.  Right now, the GAPS PCI bridge is only used for
     44  1.1  thorpej  * the Dreamcast Broadband Adatper, so we only provide what the
     45  1.1  thorpej  * pci(4) and rtk(4) drivers need.
     46  1.1  thorpej  */
     47  1.1  thorpej 
     48  1.1  thorpej #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     49  1.1  thorpej 
     50  1.1  thorpej #include <sys/param.h>
     51  1.1  thorpej #include <sys/systm.h>
     52  1.1  thorpej #include <sys/device.h>
     53  1.1  thorpej 
     54  1.1  thorpej #include <machine/cpu.h>
     55  1.1  thorpej #include <machine/bus.h>
     56  1.1  thorpej 
     57  1.1  thorpej #include <dreamcast/dev/g2/g2busvar.h>
     58  1.1  thorpej 
     59  1.1  thorpej int	g2bus_bus_mem_map(void *, bus_addr_t, bus_size_t, int,
     60  1.1  thorpej 	    bus_space_handle_t *);
     61  1.1  thorpej void	g2bus_bus_mem_unmap(void *, bus_space_handle_t, bus_size_t);
     62  1.1  thorpej 
     63  1.1  thorpej u_int8_t g2bus_bus_mem_read_1(void *, bus_space_handle_t, bus_size_t);
     64  1.1  thorpej u_int16_t g2bus_bus_mem_read_2(void *, bus_space_handle_t, bus_size_t);
     65  1.1  thorpej u_int32_t g2bus_bus_mem_read_4(void *, bus_space_handle_t, bus_size_t);
     66  1.1  thorpej 
     67  1.1  thorpej void	g2bus_bus_mem_write_1(void *, bus_space_handle_t, bus_size_t,
     68  1.1  thorpej 	    u_int8_t);
     69  1.1  thorpej void	g2bus_bus_mem_write_2(void *, bus_space_handle_t, bus_size_t,
     70  1.1  thorpej 	    u_int16_t);
     71  1.1  thorpej void	g2bus_bus_mem_write_4(void *, bus_space_handle_t, bus_size_t,
     72  1.1  thorpej 	    u_int32_t);
     73  1.1  thorpej 
     74  1.3  thorpej void	g2bus_bus_mem_read_region_1(void *, bus_space_handle_t, bus_size_t,
     75  1.3  thorpej 	    u_int8_t *, bus_size_t);
     76  1.3  thorpej 
     77  1.3  thorpej void	g2bus_bus_mem_write_region_1(void *, bus_space_handle_t, bus_size_t,
     78  1.3  thorpej 	    const u_int8_t *, bus_size_t);
     79  1.3  thorpej 
     80  1.6  tsutsui u_int8_t g2bus_sparse_bus_mem_read_1(void *, bus_space_handle_t, bus_size_t);
     81  1.6  tsutsui u_int16_t g2bus_sparse_bus_mem_read_2(void *, bus_space_handle_t, bus_size_t);
     82  1.6  tsutsui u_int32_t g2bus_sparse_bus_mem_read_4(void *, bus_space_handle_t, bus_size_t);
     83  1.6  tsutsui 
     84  1.6  tsutsui void	g2bus_sparse_bus_mem_write_1(void *, bus_space_handle_t, bus_size_t,
     85  1.6  tsutsui 	    u_int8_t);
     86  1.6  tsutsui void	g2bus_sparse_bus_mem_write_2(void *, bus_space_handle_t, bus_size_t,
     87  1.6  tsutsui 	    u_int16_t);
     88  1.6  tsutsui void	g2bus_sparse_bus_mem_write_4(void *, bus_space_handle_t, bus_size_t,
     89  1.6  tsutsui 	    u_int32_t);
     90  1.6  tsutsui 
     91  1.6  tsutsui void	g2bus_sparse_bus_mem_read_region_1(void *, bus_space_handle_t,
     92  1.6  tsutsui 	    bus_size_t, u_int8_t *, bus_size_t);
     93  1.6  tsutsui 
     94  1.6  tsutsui void	g2bus_sparse_bus_mem_write_region_1(void *, bus_space_handle_t,
     95  1.6  tsutsui 	    bus_size_t, const u_int8_t *, bus_size_t);
     96  1.6  tsutsui 
     97  1.6  tsutsui void	g2bus_sparse_bus_mem_read_multi_1(void *, bus_space_handle_t,
     98  1.6  tsutsui 	    bus_size_t, u_int8_t *, bus_size_t);
     99  1.6  tsutsui 
    100  1.6  tsutsui void	g2bus_sparse_bus_mem_write_multi_1(void *, bus_space_handle_t,
    101  1.6  tsutsui 	    bus_size_t, const u_int8_t *, bus_size_t);
    102  1.6  tsutsui 
    103  1.1  thorpej void
    104  1.1  thorpej g2bus_bus_mem_init(struct g2bus_softc *sc)
    105  1.1  thorpej {
    106  1.1  thorpej 	bus_space_tag_t t = &sc->sc_memt;
    107  1.1  thorpej 
    108  1.1  thorpej 	memset(t, 0, sizeof(*t));
    109  1.1  thorpej 
    110  1.1  thorpej 	t->dbs_map = g2bus_bus_mem_map;
    111  1.1  thorpej 	t->dbs_unmap = g2bus_bus_mem_unmap;
    112  1.1  thorpej 
    113  1.1  thorpej 	t->dbs_r_1 = g2bus_bus_mem_read_1;
    114  1.1  thorpej 	t->dbs_r_2 = g2bus_bus_mem_read_2;
    115  1.1  thorpej 	t->dbs_r_4 = g2bus_bus_mem_read_4;
    116  1.1  thorpej 
    117  1.1  thorpej 	t->dbs_w_1 = g2bus_bus_mem_write_1;
    118  1.1  thorpej 	t->dbs_w_2 = g2bus_bus_mem_write_2;
    119  1.1  thorpej 	t->dbs_w_4 = g2bus_bus_mem_write_4;
    120  1.3  thorpej 
    121  1.3  thorpej 	t->dbs_rr_1 = g2bus_bus_mem_read_region_1;
    122  1.3  thorpej 
    123  1.3  thorpej 	t->dbs_wr_1 = g2bus_bus_mem_write_region_1;
    124  1.1  thorpej }
    125  1.1  thorpej 
    126  1.1  thorpej int
    127  1.1  thorpej g2bus_bus_mem_map(void *v, bus_addr_t addr, bus_size_t size, int flags,
    128  1.1  thorpej     bus_space_handle_t *shp)
    129  1.1  thorpej {
    130  1.1  thorpej 
    131  1.1  thorpej 	KASSERT((addr & SH3_PHYS_MASK) == addr);
    132  1.1  thorpej 	*shp = SH3_PHYS_TO_P2SEG(addr);
    133  1.1  thorpej 
    134  1.1  thorpej 	return (0);
    135  1.1  thorpej }
    136  1.1  thorpej 
    137  1.1  thorpej void
    138  1.1  thorpej g2bus_bus_mem_unmap(void *v, bus_space_handle_t sh, bus_size_t size)
    139  1.1  thorpej {
    140  1.1  thorpej 
    141  1.1  thorpej 	KASSERT(sh >= SH3_P2SEG_BASE && sh <= SH3_P2SEG_END);
    142  1.1  thorpej 	/* Nothing to do. */
    143  1.1  thorpej }
    144  1.1  thorpej 
    145  1.1  thorpej /*
    146  1.2   marcus  * G2 bus cycles must not be interrupted by IRQs or G2 DMA.
    147  1.2   marcus  * The following paired macros will take the necessary precautions.
    148  1.1  thorpej  */
    149  1.1  thorpej 
    150  1.2   marcus #define G2_LOCK								\
    151  1.2   marcus 	do {								\
    152  1.4      uch 		_cpu_exception_suspend();				\
    153  1.2   marcus 		/* suspend any G2 DMA here... */			\
    154  1.2   marcus 		while((*(volatile unsigned int *)0xa05f688c) & 32);	\
    155  1.4      uch 	} while(/*CONSTCOND*/0)
    156  1.2   marcus 
    157  1.2   marcus #define G2_UNLOCK							\
    158  1.2   marcus 	do {								\
    159  1.2   marcus 		/* resume any G2 DMA here... */				\
    160  1.4      uch 		_cpu_exception_resume(0);				\
    161  1.4      uch 	} while(/*CONSTCOND*/0)
    162  1.2   marcus 
    163  1.2   marcus 
    164  1.1  thorpej u_int8_t
    165  1.1  thorpej g2bus_bus_mem_read_1(void *v, bus_space_handle_t sh, bus_size_t off)
    166  1.1  thorpej {
    167  1.1  thorpej 	u_int8_t rv;
    168  1.1  thorpej 
    169  1.2   marcus 	G2_LOCK;
    170  1.2   marcus 
    171  1.3  thorpej 	rv = *(__volatile u_int8_t *)(sh + off);
    172  1.1  thorpej 
    173  1.2   marcus 	G2_UNLOCK;
    174  1.2   marcus 
    175  1.1  thorpej 	return (rv);
    176  1.1  thorpej }
    177  1.1  thorpej 
    178  1.1  thorpej u_int16_t
    179  1.1  thorpej g2bus_bus_mem_read_2(void *v, bus_space_handle_t sh, bus_size_t off)
    180  1.1  thorpej {
    181  1.1  thorpej 	u_int16_t rv;
    182  1.1  thorpej 
    183  1.2   marcus 	G2_LOCK;
    184  1.2   marcus 
    185  1.3  thorpej 	rv = *(__volatile u_int16_t *)(sh + off);
    186  1.1  thorpej 
    187  1.2   marcus 	G2_UNLOCK;
    188  1.2   marcus 
    189  1.1  thorpej 	return (rv);
    190  1.1  thorpej }
    191  1.1  thorpej 
    192  1.1  thorpej u_int32_t
    193  1.1  thorpej g2bus_bus_mem_read_4(void *v, bus_space_handle_t sh, bus_size_t off)
    194  1.1  thorpej {
    195  1.1  thorpej 	u_int32_t rv;
    196  1.1  thorpej 
    197  1.2   marcus 	G2_LOCK;
    198  1.2   marcus 
    199  1.3  thorpej 	rv = *(__volatile u_int32_t *)(sh + off);
    200  1.1  thorpej 
    201  1.2   marcus 	G2_UNLOCK;
    202  1.2   marcus 
    203  1.1  thorpej 	return (rv);
    204  1.1  thorpej }
    205  1.1  thorpej 
    206  1.1  thorpej void
    207  1.1  thorpej g2bus_bus_mem_write_1(void *v, bus_space_handle_t sh, bus_size_t off,
    208  1.1  thorpej     u_int8_t val)
    209  1.1  thorpej {
    210  1.1  thorpej 
    211  1.2   marcus 	G2_LOCK;
    212  1.2   marcus 
    213  1.3  thorpej 	*(__volatile u_int8_t *)(sh + off) = val;
    214  1.2   marcus 
    215  1.2   marcus 	G2_UNLOCK;
    216  1.1  thorpej }
    217  1.1  thorpej 
    218  1.1  thorpej void
    219  1.1  thorpej g2bus_bus_mem_write_2(void *v, bus_space_handle_t sh, bus_size_t off,
    220  1.1  thorpej     u_int16_t val)
    221  1.1  thorpej {
    222  1.1  thorpej 
    223  1.2   marcus 	G2_LOCK;
    224  1.2   marcus 
    225  1.3  thorpej 	*(__volatile u_int16_t *)(sh + off) = val;
    226  1.2   marcus 
    227  1.2   marcus 	G2_UNLOCK;
    228  1.1  thorpej }
    229  1.1  thorpej 
    230  1.1  thorpej void
    231  1.1  thorpej g2bus_bus_mem_write_4(void *v, bus_space_handle_t sh, bus_size_t off,
    232  1.1  thorpej     u_int32_t val)
    233  1.1  thorpej {
    234  1.1  thorpej 
    235  1.2   marcus 	G2_LOCK;
    236  1.2   marcus 
    237  1.3  thorpej 	*(__volatile u_int32_t *)(sh + off) = val;
    238  1.3  thorpej 
    239  1.3  thorpej 	G2_UNLOCK;
    240  1.3  thorpej }
    241  1.3  thorpej 
    242  1.3  thorpej void
    243  1.3  thorpej g2bus_bus_mem_read_region_1(void *v, bus_space_handle_t sh, bus_size_t off,
    244  1.3  thorpej     u_int8_t *addr, bus_size_t len)
    245  1.3  thorpej {
    246  1.3  thorpej 	__volatile const u_int8_t *baddr = (u_int8_t *)(sh + off);
    247  1.3  thorpej 
    248  1.3  thorpej 	G2_LOCK;
    249  1.3  thorpej 
    250  1.3  thorpej 	while (len--)
    251  1.3  thorpej 		*addr++ = *baddr++;
    252  1.3  thorpej 
    253  1.3  thorpej 	G2_UNLOCK;
    254  1.3  thorpej }
    255  1.3  thorpej 
    256  1.3  thorpej void
    257  1.3  thorpej g2bus_bus_mem_write_region_1(void *v, bus_space_handle_t sh, bus_size_t off,
    258  1.3  thorpej     const u_int8_t *addr, bus_size_t len)
    259  1.3  thorpej {
    260  1.3  thorpej 	__volatile u_int8_t *baddr = (u_int8_t *)(sh + off);
    261  1.3  thorpej 
    262  1.3  thorpej 	G2_LOCK;
    263  1.3  thorpej 
    264  1.3  thorpej 	while (len--)
    265  1.3  thorpej 		*baddr++ = *addr++;
    266  1.6  tsutsui 
    267  1.6  tsutsui 	G2_UNLOCK;
    268  1.6  tsutsui }
    269  1.6  tsutsui 
    270  1.6  tsutsui void
    271  1.6  tsutsui g2bus_set_bus_mem_sparse(bus_space_tag_t memt)
    272  1.6  tsutsui {
    273  1.6  tsutsui 
    274  1.6  tsutsui 	memt->dbs_r_1 = g2bus_sparse_bus_mem_read_1;
    275  1.6  tsutsui 	memt->dbs_r_2 = g2bus_sparse_bus_mem_read_2;
    276  1.6  tsutsui 	memt->dbs_r_4 = g2bus_sparse_bus_mem_read_4;
    277  1.6  tsutsui 
    278  1.6  tsutsui 	memt->dbs_w_1 = g2bus_sparse_bus_mem_write_1;
    279  1.6  tsutsui 	memt->dbs_w_2 = g2bus_sparse_bus_mem_write_2;
    280  1.6  tsutsui 	memt->dbs_w_4 = g2bus_sparse_bus_mem_write_4;
    281  1.6  tsutsui 
    282  1.6  tsutsui 	memt->dbs_rr_1 = g2bus_sparse_bus_mem_read_region_1;
    283  1.6  tsutsui 
    284  1.6  tsutsui 	memt->dbs_wr_1 = g2bus_sparse_bus_mem_write_region_1;
    285  1.6  tsutsui 
    286  1.6  tsutsui 	memt->dbs_rm_1 = g2bus_sparse_bus_mem_read_multi_1;
    287  1.6  tsutsui 
    288  1.6  tsutsui 	memt->dbs_wm_1 = g2bus_sparse_bus_mem_write_multi_1;
    289  1.6  tsutsui }
    290  1.6  tsutsui 
    291  1.6  tsutsui u_int8_t
    292  1.6  tsutsui g2bus_sparse_bus_mem_read_1(void *v, bus_space_handle_t sh, bus_size_t off)
    293  1.6  tsutsui {
    294  1.6  tsutsui 	u_int8_t rv;
    295  1.6  tsutsui 
    296  1.6  tsutsui 	G2_LOCK;
    297  1.6  tsutsui 
    298  1.6  tsutsui 	rv = *(__volatile u_int8_t *)(sh + (off * 4));
    299  1.6  tsutsui 
    300  1.6  tsutsui 	G2_UNLOCK;
    301  1.6  tsutsui 
    302  1.6  tsutsui 	return (rv);
    303  1.6  tsutsui }
    304  1.6  tsutsui 
    305  1.6  tsutsui u_int16_t
    306  1.6  tsutsui g2bus_sparse_bus_mem_read_2(void *v, bus_space_handle_t sh, bus_size_t off)
    307  1.6  tsutsui {
    308  1.6  tsutsui 	u_int16_t rv;
    309  1.6  tsutsui 
    310  1.6  tsutsui 	G2_LOCK;
    311  1.6  tsutsui 
    312  1.6  tsutsui 	rv = *(__volatile u_int16_t *)(sh + (off * 4));
    313  1.6  tsutsui 
    314  1.6  tsutsui 	G2_UNLOCK;
    315  1.6  tsutsui 
    316  1.6  tsutsui 	return (rv);
    317  1.6  tsutsui }
    318  1.6  tsutsui 
    319  1.6  tsutsui u_int32_t
    320  1.6  tsutsui g2bus_sparse_bus_mem_read_4(void *v, bus_space_handle_t sh, bus_size_t off)
    321  1.6  tsutsui {
    322  1.6  tsutsui 	u_int32_t rv;
    323  1.6  tsutsui 
    324  1.6  tsutsui 	G2_LOCK;
    325  1.6  tsutsui 
    326  1.6  tsutsui 	rv = *(__volatile u_int32_t *)(sh + (off * 4));
    327  1.6  tsutsui 
    328  1.6  tsutsui 	G2_UNLOCK;
    329  1.6  tsutsui 
    330  1.6  tsutsui 	return (rv);
    331  1.6  tsutsui }
    332  1.6  tsutsui 
    333  1.6  tsutsui void
    334  1.6  tsutsui g2bus_sparse_bus_mem_write_1(void *v, bus_space_handle_t sh, bus_size_t off,
    335  1.6  tsutsui     u_int8_t val)
    336  1.6  tsutsui {
    337  1.6  tsutsui 
    338  1.6  tsutsui 	G2_LOCK;
    339  1.6  tsutsui 
    340  1.6  tsutsui 	*(__volatile u_int8_t *)(sh + (off * 4)) = val;
    341  1.6  tsutsui 
    342  1.6  tsutsui 	G2_UNLOCK;
    343  1.6  tsutsui }
    344  1.6  tsutsui 
    345  1.6  tsutsui void
    346  1.6  tsutsui g2bus_sparse_bus_mem_write_2(void *v, bus_space_handle_t sh, bus_size_t off,
    347  1.6  tsutsui     u_int16_t val)
    348  1.6  tsutsui {
    349  1.6  tsutsui 
    350  1.6  tsutsui 	G2_LOCK;
    351  1.6  tsutsui 
    352  1.6  tsutsui 	*(__volatile u_int16_t *)(sh + (off * 4)) = val;
    353  1.6  tsutsui 
    354  1.6  tsutsui 	G2_UNLOCK;
    355  1.6  tsutsui }
    356  1.6  tsutsui 
    357  1.6  tsutsui void
    358  1.6  tsutsui g2bus_sparse_bus_mem_write_4(void *v, bus_space_handle_t sh, bus_size_t off,
    359  1.6  tsutsui     u_int32_t val)
    360  1.6  tsutsui {
    361  1.6  tsutsui 
    362  1.6  tsutsui 	G2_LOCK;
    363  1.6  tsutsui 
    364  1.6  tsutsui 	*(__volatile u_int32_t *)(sh + (off * 4)) = val;
    365  1.6  tsutsui 
    366  1.6  tsutsui 	G2_UNLOCK;
    367  1.6  tsutsui }
    368  1.6  tsutsui 
    369  1.6  tsutsui void
    370  1.6  tsutsui g2bus_sparse_bus_mem_read_region_1(void *v, bus_space_handle_t sh,
    371  1.6  tsutsui     bus_size_t off, u_int8_t *addr, bus_size_t len)
    372  1.6  tsutsui {
    373  1.6  tsutsui 	__volatile const u_int8_t *baddr = (u_int8_t *)(sh + (off * 4));
    374  1.6  tsutsui 
    375  1.6  tsutsui 	G2_LOCK;
    376  1.6  tsutsui 
    377  1.6  tsutsui 	while (len--) {
    378  1.6  tsutsui 		*addr++ = *baddr;
    379  1.6  tsutsui 		baddr += 4;
    380  1.6  tsutsui 	}
    381  1.6  tsutsui 
    382  1.6  tsutsui 	G2_UNLOCK;
    383  1.6  tsutsui }
    384  1.6  tsutsui 
    385  1.6  tsutsui void
    386  1.6  tsutsui g2bus_sparse_bus_mem_write_region_1(void *v, bus_space_handle_t sh,
    387  1.6  tsutsui     bus_size_t off, const u_int8_t *addr, bus_size_t len)
    388  1.6  tsutsui {
    389  1.6  tsutsui 	__volatile u_int8_t *baddr = (u_int8_t *)(sh + (off * 4));
    390  1.6  tsutsui 
    391  1.6  tsutsui 	G2_LOCK;
    392  1.6  tsutsui 
    393  1.6  tsutsui 	while (len--) {
    394  1.6  tsutsui 		*baddr = *addr++;
    395  1.6  tsutsui 		baddr += 4;
    396  1.6  tsutsui 	}
    397  1.6  tsutsui 
    398  1.6  tsutsui 	G2_UNLOCK;
    399  1.6  tsutsui }
    400  1.6  tsutsui 
    401  1.6  tsutsui void
    402  1.6  tsutsui g2bus_sparse_bus_mem_read_multi_1(void *v, bus_space_handle_t sh,
    403  1.6  tsutsui     bus_size_t off, u_int8_t *addr, bus_size_t len)
    404  1.6  tsutsui {
    405  1.6  tsutsui 	__volatile const u_int8_t *baddr = (u_int8_t *)(sh + (off * 4));
    406  1.6  tsutsui 
    407  1.6  tsutsui 	G2_LOCK;
    408  1.6  tsutsui 
    409  1.6  tsutsui 	while (len--)
    410  1.6  tsutsui 		*addr++ = *baddr;
    411  1.6  tsutsui 
    412  1.6  tsutsui 	G2_UNLOCK;
    413  1.6  tsutsui }
    414  1.6  tsutsui 
    415  1.6  tsutsui void
    416  1.6  tsutsui g2bus_sparse_bus_mem_write_multi_1(void *v, bus_space_handle_t sh,
    417  1.6  tsutsui     bus_size_t off, const u_int8_t *addr, bus_size_t len)
    418  1.6  tsutsui {
    419  1.6  tsutsui 	__volatile u_int8_t *baddr = (u_int8_t *)(sh + (off * 4));
    420  1.6  tsutsui 
    421  1.6  tsutsui 	G2_LOCK;
    422  1.6  tsutsui 
    423  1.6  tsutsui 	while (len--)
    424  1.6  tsutsui 		*baddr = *addr++;
    425  1.2   marcus 
    426  1.2   marcus 	G2_UNLOCK;
    427  1.1  thorpej }
    428