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