Home | History | Annotate | Line # | Download | only in isa
isa_io.c revision 1.2
      1  1.2   provos /*	$NetBSD: isa_io.c,v 1.2 2002/09/27 15:36:42 provos Exp $	*/
      2  1.1  thorpej 
      3  1.1  thorpej /*
      4  1.1  thorpej  * Copyright 1997
      5  1.1  thorpej  * Digital Equipment Corporation. All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * This software is furnished under license and may be used and
      8  1.1  thorpej  * copied only in accordance with the following terms and conditions.
      9  1.1  thorpej  * Subject to these conditions, you may download, copy, install,
     10  1.1  thorpej  * use, modify and distribute this software in source and/or binary
     11  1.1  thorpej  * form. No title or ownership is transferred hereby.
     12  1.1  thorpej  *
     13  1.1  thorpej  * 1) Any source code used, modified or distributed must reproduce
     14  1.1  thorpej  *    and retain this copyright notice and list of conditions as
     15  1.1  thorpej  *    they appear in the source file.
     16  1.1  thorpej  *
     17  1.1  thorpej  * 2) No right is granted to use any trade name, trademark, or logo of
     18  1.1  thorpej  *    Digital Equipment Corporation. Neither the "Digital Equipment
     19  1.1  thorpej  *    Corporation" name nor any trademark or logo of Digital Equipment
     20  1.1  thorpej  *    Corporation may be used to endorse or promote products derived
     21  1.1  thorpej  *    from this software without the prior written permission of
     22  1.1  thorpej  *    Digital Equipment Corporation.
     23  1.1  thorpej  *
     24  1.1  thorpej  * 3) This software is provided "AS-IS" and any express or implied
     25  1.1  thorpej  *    warranties, including but not limited to, any implied warranties
     26  1.1  thorpej  *    of merchantability, fitness for a particular purpose, or
     27  1.1  thorpej  *    non-infringement are disclaimed. In no event shall DIGITAL be
     28  1.1  thorpej  *    liable for any damages whatsoever, and in particular, DIGITAL
     29  1.1  thorpej  *    shall not be liable for special, indirect, consequential, or
     30  1.1  thorpej  *    incidental damages or damages for lost profits, loss of
     31  1.1  thorpej  *    revenue or loss of use, whether such damages arise in contract,
     32  1.1  thorpej  *    negligence, tort, under statute, in equity, at law or otherwise,
     33  1.1  thorpej  *    even if advised of the possibility of such damage.
     34  1.1  thorpej  */
     35  1.1  thorpej 
     36  1.1  thorpej /*
     37  1.1  thorpej  * bus_space I/O functions for isa
     38  1.1  thorpej  */
     39  1.1  thorpej 
     40  1.1  thorpej #include <sys/param.h>
     41  1.1  thorpej #include <sys/systm.h>
     42  1.1  thorpej #include <machine/bus.h>
     43  1.1  thorpej #include <machine/pio.h>
     44  1.1  thorpej #include <machine/isa_machdep.h>
     45  1.1  thorpej 
     46  1.1  thorpej /* Proto types for all the bus_space structure functions */
     47  1.1  thorpej 
     48  1.1  thorpej bs_protos(isa);
     49  1.1  thorpej bs_protos(bs_notimpl);
     50  1.1  thorpej 
     51  1.1  thorpej /*
     52  1.1  thorpej  * Declare the isa bus space tags
     53  1.1  thorpej  * The IO and MEM structs are identical, except for the cookies,
     54  1.1  thorpej  * which contain the address space bases.
     55  1.1  thorpej  */
     56  1.1  thorpej 
     57  1.1  thorpej /*
     58  1.1  thorpej  * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
     59  1.1  thorpej  *       THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/IO!
     60  1.1  thorpej  */
     61  1.1  thorpej struct bus_space isa_io_bs_tag = {
     62  1.1  thorpej 	/* cookie */
     63  1.1  thorpej 	NULL, /* initialized below */
     64  1.1  thorpej 
     65  1.1  thorpej 	/* mapping/unmapping */
     66  1.1  thorpej 	isa_bs_map,
     67  1.1  thorpej 	isa_bs_unmap,
     68  1.1  thorpej 	isa_bs_subregion,
     69  1.1  thorpej 
     70  1.1  thorpej 	/* allocation/deallocation */
     71  1.1  thorpej 	isa_bs_alloc,
     72  1.1  thorpej 	isa_bs_free,
     73  1.1  thorpej 
     74  1.1  thorpej 	/* get kernel virtual address */
     75  1.1  thorpej 	isa_bs_vaddr,
     76  1.1  thorpej 
     77  1.1  thorpej 	/* mmap bus space for userland */
     78  1.1  thorpej 	bs_notimpl_bs_mmap,		/* XXX possible even? XXX */
     79  1.1  thorpej 
     80  1.1  thorpej 	/* barrier */
     81  1.1  thorpej 	isa_bs_barrier,
     82  1.1  thorpej 
     83  1.1  thorpej 	/* read (single) */
     84  1.1  thorpej 	isa_bs_r_1,
     85  1.1  thorpej 	isa_bs_r_2,
     86  1.1  thorpej 	isa_bs_r_4,
     87  1.1  thorpej 	bs_notimpl_bs_r_8,
     88  1.1  thorpej 
     89  1.1  thorpej 	/* read multiple */
     90  1.1  thorpej 	isa_bs_rm_1,
     91  1.1  thorpej 	isa_bs_rm_2,
     92  1.1  thorpej 	isa_bs_rm_4,
     93  1.1  thorpej 	bs_notimpl_bs_rm_8,
     94  1.1  thorpej 
     95  1.1  thorpej 	/* read region */
     96  1.1  thorpej 	isa_bs_rr_1,
     97  1.1  thorpej 	isa_bs_rr_2,
     98  1.1  thorpej 	isa_bs_rr_4,
     99  1.1  thorpej 	bs_notimpl_bs_rr_8,
    100  1.1  thorpej 
    101  1.1  thorpej 	/* write (single) */
    102  1.1  thorpej 	isa_bs_w_1,
    103  1.1  thorpej 	isa_bs_w_2,
    104  1.1  thorpej 	isa_bs_w_4,
    105  1.1  thorpej 	bs_notimpl_bs_w_8,
    106  1.1  thorpej 
    107  1.1  thorpej 	/* write multiple */
    108  1.1  thorpej 	isa_bs_wm_1,
    109  1.1  thorpej 	isa_bs_wm_2,
    110  1.1  thorpej 	isa_bs_wm_4,
    111  1.1  thorpej 	bs_notimpl_bs_wm_8,
    112  1.1  thorpej 
    113  1.1  thorpej 	/* write region */
    114  1.1  thorpej 	isa_bs_wr_1,
    115  1.1  thorpej 	isa_bs_wr_2,
    116  1.1  thorpej 	isa_bs_wr_4,
    117  1.1  thorpej 	bs_notimpl_bs_wr_8,
    118  1.1  thorpej 
    119  1.1  thorpej 	/* set multiple */
    120  1.1  thorpej 	bs_notimpl_bs_sm_1,
    121  1.1  thorpej 	bs_notimpl_bs_sm_2,
    122  1.1  thorpej 	bs_notimpl_bs_sm_4,
    123  1.1  thorpej 	bs_notimpl_bs_sm_8,
    124  1.1  thorpej 
    125  1.1  thorpej 	/* set region */
    126  1.1  thorpej 	bs_notimpl_bs_sr_1,
    127  1.1  thorpej 	isa_bs_sr_2,
    128  1.1  thorpej 	bs_notimpl_bs_sr_4,
    129  1.1  thorpej 	bs_notimpl_bs_sr_8,
    130  1.1  thorpej 
    131  1.1  thorpej 	/* copy */
    132  1.1  thorpej 	bs_notimpl_bs_c_1,
    133  1.1  thorpej 	bs_notimpl_bs_c_2,
    134  1.1  thorpej 	bs_notimpl_bs_c_4,
    135  1.1  thorpej 	bs_notimpl_bs_c_8,
    136  1.1  thorpej };
    137  1.1  thorpej 
    138  1.1  thorpej /*
    139  1.1  thorpej  * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
    140  1.1  thorpej  *       THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/MEMORY!
    141  1.1  thorpej  */
    142  1.1  thorpej struct bus_space isa_mem_bs_tag = {
    143  1.1  thorpej 	/* cookie */
    144  1.1  thorpej         NULL, /* initialized below */
    145  1.1  thorpej 
    146  1.1  thorpej 	/* mapping/unmapping */
    147  1.1  thorpej 	isa_bs_map,
    148  1.1  thorpej 	isa_bs_unmap,
    149  1.1  thorpej 	isa_bs_subregion,
    150  1.1  thorpej 
    151  1.1  thorpej 	/* allocation/deallocation */
    152  1.1  thorpej 	isa_bs_alloc,
    153  1.1  thorpej 	isa_bs_free,
    154  1.1  thorpej 
    155  1.1  thorpej 	/* get kernel virtual address */
    156  1.1  thorpej 	isa_bs_vaddr,
    157  1.1  thorpej 
    158  1.1  thorpej 	/* mmap bus space for userland */
    159  1.1  thorpej 	bs_notimpl_bs_mmap,		/* XXX open for now ... XXX */
    160  1.1  thorpej 
    161  1.1  thorpej 	/* barrier */
    162  1.1  thorpej 	isa_bs_barrier,
    163  1.1  thorpej 
    164  1.1  thorpej 	/* read (single) */
    165  1.1  thorpej 	isa_bs_r_1,
    166  1.1  thorpej 	isa_bs_r_2,
    167  1.1  thorpej 	isa_bs_r_4,
    168  1.1  thorpej 	bs_notimpl_bs_r_8,
    169  1.1  thorpej 
    170  1.1  thorpej 	/* read multiple */
    171  1.1  thorpej 	isa_bs_rm_1,
    172  1.1  thorpej 	isa_bs_rm_2,
    173  1.1  thorpej 	isa_bs_rm_4,
    174  1.1  thorpej 	bs_notimpl_bs_rm_8,
    175  1.1  thorpej 
    176  1.1  thorpej 	/* read region */
    177  1.1  thorpej 	isa_bs_rr_1,
    178  1.1  thorpej 	isa_bs_rr_2,
    179  1.1  thorpej 	isa_bs_rr_4,
    180  1.1  thorpej 	bs_notimpl_bs_rr_8,
    181  1.1  thorpej 
    182  1.1  thorpej 	/* write (single) */
    183  1.1  thorpej 	isa_bs_w_1,
    184  1.1  thorpej 	isa_bs_w_2,
    185  1.1  thorpej 	isa_bs_w_4,
    186  1.1  thorpej 	bs_notimpl_bs_w_8,
    187  1.1  thorpej 
    188  1.1  thorpej 	/* write multiple */
    189  1.1  thorpej 	isa_bs_wm_1,
    190  1.1  thorpej 	isa_bs_wm_2,
    191  1.1  thorpej 	isa_bs_wm_4,
    192  1.1  thorpej 	bs_notimpl_bs_wm_8,
    193  1.1  thorpej 
    194  1.1  thorpej 	/* write region */
    195  1.1  thorpej 	isa_bs_wr_1,
    196  1.1  thorpej 	isa_bs_wr_2,
    197  1.1  thorpej 	isa_bs_wr_4,
    198  1.1  thorpej 	bs_notimpl_bs_wr_8,
    199  1.1  thorpej 
    200  1.1  thorpej 	/* set multiple */
    201  1.1  thorpej 	bs_notimpl_bs_sm_1,
    202  1.1  thorpej 	bs_notimpl_bs_sm_2,
    203  1.1  thorpej 	bs_notimpl_bs_sm_4,
    204  1.1  thorpej 	bs_notimpl_bs_sm_8,
    205  1.1  thorpej 
    206  1.1  thorpej 	/* set region */
    207  1.1  thorpej 	bs_notimpl_bs_sr_1,
    208  1.1  thorpej 	isa_bs_sr_2,
    209  1.1  thorpej 	bs_notimpl_bs_sr_4,
    210  1.1  thorpej 	bs_notimpl_bs_sr_8,
    211  1.1  thorpej 
    212  1.1  thorpej 	/* copy */
    213  1.1  thorpej 	bs_notimpl_bs_c_1,
    214  1.1  thorpej 	bs_notimpl_bs_c_2,
    215  1.1  thorpej 	bs_notimpl_bs_c_4,
    216  1.1  thorpej 	bs_notimpl_bs_c_8,
    217  1.1  thorpej };
    218  1.1  thorpej 
    219  1.1  thorpej /* bus space functions */
    220  1.1  thorpej 
    221  1.1  thorpej void
    222  1.1  thorpej isa_io_init(isa_io_addr, isa_mem_addr)
    223  1.1  thorpej 	vm_offset_t isa_io_addr;
    224  1.1  thorpej 	vm_offset_t isa_mem_addr;
    225  1.1  thorpej {
    226  1.1  thorpej 	isa_io_bs_tag.bs_cookie = (void *)isa_io_addr;
    227  1.1  thorpej 	isa_mem_bs_tag.bs_cookie = (void *)isa_mem_addr;
    228  1.1  thorpej }
    229  1.1  thorpej 
    230  1.1  thorpej /*
    231  1.1  thorpej  * break the abstraction: sometimes, other parts of the system
    232  1.1  thorpej  * (e.g. X servers) need to map ISA space directly.  use these
    233  1.1  thorpej  * functions sparingly!
    234  1.1  thorpej  */
    235  1.1  thorpej vm_offset_t
    236  1.1  thorpej isa_io_data_vaddr(void)
    237  1.1  thorpej {
    238  1.1  thorpej 	return (vm_offset_t)isa_io_bs_tag.bs_cookie;
    239  1.1  thorpej }
    240  1.1  thorpej 
    241  1.1  thorpej vm_offset_t
    242  1.1  thorpej isa_mem_data_vaddr(void)
    243  1.1  thorpej {
    244  1.1  thorpej 	return (vm_offset_t)isa_mem_bs_tag.bs_cookie;
    245  1.1  thorpej }
    246  1.1  thorpej 
    247  1.1  thorpej int
    248  1.1  thorpej isa_bs_map(t, bpa, size, cacheable, bshp)
    249  1.1  thorpej 	void *t;
    250  1.1  thorpej 	bus_addr_t bpa;
    251  1.1  thorpej 	bus_size_t size;
    252  1.1  thorpej 	int cacheable;
    253  1.1  thorpej 	bus_space_handle_t *bshp;
    254  1.1  thorpej {
    255  1.1  thorpej 	*bshp = bpa + (bus_addr_t)t;
    256  1.1  thorpej 	return(0);
    257  1.1  thorpej }
    258  1.1  thorpej 
    259  1.1  thorpej void
    260  1.1  thorpej isa_bs_unmap(t, bsh, size)
    261  1.1  thorpej 	void *t;
    262  1.1  thorpej 	bus_space_handle_t bsh;
    263  1.1  thorpej 	bus_size_t size;
    264  1.1  thorpej {
    265  1.1  thorpej 	/* Nothing to do. */
    266  1.1  thorpej }
    267  1.1  thorpej 
    268  1.1  thorpej int
    269  1.1  thorpej isa_bs_subregion(t, bsh, offset, size, nbshp)
    270  1.1  thorpej 	void *t;
    271  1.1  thorpej 	bus_space_handle_t bsh;
    272  1.1  thorpej 	bus_size_t offset, size;
    273  1.1  thorpej 	bus_space_handle_t *nbshp;
    274  1.1  thorpej {
    275  1.1  thorpej /*	printf("isa_subregion(tag=%p, bsh=%lx, off=%lx, sz=%lx)\n",
    276  1.1  thorpej 	    t, bsh, offset, size);*/
    277  1.1  thorpej 	*nbshp = bsh + offset;
    278  1.1  thorpej 	return(0);
    279  1.1  thorpej }
    280  1.1  thorpej 
    281  1.1  thorpej int
    282  1.1  thorpej isa_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
    283  1.1  thorpej     bpap, bshp)
    284  1.1  thorpej 	void *t;
    285  1.1  thorpej 	bus_addr_t rstart, rend;
    286  1.1  thorpej 	bus_size_t size, alignment, boundary;
    287  1.1  thorpej 	int cacheable;
    288  1.1  thorpej 	bus_addr_t *bpap;
    289  1.1  thorpej 	bus_space_handle_t *bshp;
    290  1.1  thorpej {
    291  1.2   provos 	panic("isa_alloc(): Help!");
    292  1.1  thorpej }
    293  1.1  thorpej 
    294  1.1  thorpej void
    295  1.1  thorpej isa_bs_free(t, bsh, size)
    296  1.1  thorpej 	void *t;
    297  1.1  thorpej 	bus_space_handle_t bsh;
    298  1.1  thorpej 	bus_size_t size;
    299  1.1  thorpej {
    300  1.2   provos 	panic("isa_free(): Help!");
    301  1.1  thorpej }
    302  1.1  thorpej 
    303  1.1  thorpej void *
    304  1.1  thorpej isa_bs_vaddr(t, bsh)
    305  1.1  thorpej 	void *t;
    306  1.1  thorpej 	bus_space_handle_t bsh;
    307  1.1  thorpej {
    308  1.1  thorpej 
    309  1.1  thorpej 	return ((void *)bsh);
    310  1.1  thorpej }
    311  1.1  thorpej 
    312  1.1  thorpej void
    313  1.1  thorpej isa_bs_barrier(t, bsh, offset, len, flags)
    314  1.1  thorpej 	void *t;
    315  1.1  thorpej 	bus_space_handle_t bsh;
    316  1.1  thorpej 	bus_size_t offset, len;
    317  1.1  thorpej 	int flags;
    318  1.1  thorpej {
    319  1.1  thorpej 	/* just return */
    320  1.1  thorpej }
    321