Home | History | Annotate | Line # | Download | only in isa
isa_io.c revision 1.4
      1 /*	$NetBSD: isa_io.c,v 1.4 2005/01/05 10:25:43 tsutsui 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/cdefs.h>
     41 __KERNEL_RCSID(0, "$NetBSD: isa_io.c,v 1.4 2005/01/05 10:25:43 tsutsui Exp $");
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <machine/bus.h>
     46 #include <machine/pio.h>
     47 #include <machine/isa_machdep.h>
     48 
     49 /* Proto types for all the bus_space structure functions */
     50 
     51 bs_protos(isa);
     52 bs_protos(bs_notimpl);
     53 
     54 /*
     55  * Declare the isa bus space tags
     56  * The IO and MEM structs are identical, except for the cookies,
     57  * which contain the address space bases.
     58  */
     59 
     60 /*
     61  * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
     62  *       THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/IO!
     63  */
     64 struct bus_space isa_io_bs_tag = {
     65 	/* cookie */
     66 	NULL, /* initialized below */
     67 
     68 	/* mapping/unmapping */
     69 	isa_bs_map,
     70 	isa_bs_unmap,
     71 	isa_bs_subregion,
     72 
     73 	/* allocation/deallocation */
     74 	isa_bs_alloc,
     75 	isa_bs_free,
     76 
     77 	/* get kernel virtual address */
     78 	isa_bs_vaddr,
     79 
     80 	/* mmap bus space for userland */
     81 	bs_notimpl_bs_mmap,		/* XXX possible even? XXX */
     82 
     83 	/* barrier */
     84 	isa_bs_barrier,
     85 
     86 	/* read (single) */
     87 	isa_bs_r_1,
     88 	isa_bs_r_2,
     89 	isa_bs_r_4,
     90 	bs_notimpl_bs_r_8,
     91 
     92 	/* read multiple */
     93 	isa_bs_rm_1,
     94 	isa_bs_rm_2,
     95 	isa_bs_rm_4,
     96 	bs_notimpl_bs_rm_8,
     97 
     98 	/* read region */
     99 	isa_bs_rr_1,
    100 	isa_bs_rr_2,
    101 	isa_bs_rr_4,
    102 	bs_notimpl_bs_rr_8,
    103 
    104 	/* write (single) */
    105 	isa_bs_w_1,
    106 	isa_bs_w_2,
    107 	isa_bs_w_4,
    108 	bs_notimpl_bs_w_8,
    109 
    110 	/* write multiple */
    111 	isa_bs_wm_1,
    112 	isa_bs_wm_2,
    113 	isa_bs_wm_4,
    114 	bs_notimpl_bs_wm_8,
    115 
    116 	/* write region */
    117 	isa_bs_wr_1,
    118 	isa_bs_wr_2,
    119 	isa_bs_wr_4,
    120 	bs_notimpl_bs_wr_8,
    121 
    122 	/* set multiple */
    123 	bs_notimpl_bs_sm_1,
    124 	bs_notimpl_bs_sm_2,
    125 	bs_notimpl_bs_sm_4,
    126 	bs_notimpl_bs_sm_8,
    127 
    128 	/* set region */
    129 	bs_notimpl_bs_sr_1,
    130 	isa_bs_sr_2,
    131 	bs_notimpl_bs_sr_4,
    132 	bs_notimpl_bs_sr_8,
    133 
    134 	/* copy */
    135 	bs_notimpl_bs_c_1,
    136 	bs_notimpl_bs_c_2,
    137 	bs_notimpl_bs_c_4,
    138 	bs_notimpl_bs_c_8,
    139 };
    140 
    141 /*
    142  * NOTE: ASSEMBLY LANGUAGE RELIES ON THE COOKIE -- THE FIRST MEMBER OF
    143  *       THIS STRUCTURE -- TO BE THE VIRTUAL ADDRESS OF ISA/MEMORY!
    144  */
    145 struct bus_space isa_mem_bs_tag = {
    146 	/* cookie */
    147         NULL, /* initialized below */
    148 
    149 	/* mapping/unmapping */
    150 	isa_bs_map,
    151 	isa_bs_unmap,
    152 	isa_bs_subregion,
    153 
    154 	/* allocation/deallocation */
    155 	isa_bs_alloc,
    156 	isa_bs_free,
    157 
    158 	/* get kernel virtual address */
    159 	isa_bs_vaddr,
    160 
    161 	/* mmap bus space for userland */
    162 	bs_notimpl_bs_mmap,		/* XXX open for now ... XXX */
    163 
    164 	/* barrier */
    165 	isa_bs_barrier,
    166 
    167 	/* read (single) */
    168 	isa_bs_r_1,
    169 	isa_bs_r_2,
    170 	isa_bs_r_4,
    171 	bs_notimpl_bs_r_8,
    172 
    173 	/* read multiple */
    174 	isa_bs_rm_1,
    175 	isa_bs_rm_2,
    176 	isa_bs_rm_4,
    177 	bs_notimpl_bs_rm_8,
    178 
    179 	/* read region */
    180 	isa_bs_rr_1,
    181 	isa_bs_rr_2,
    182 	isa_bs_rr_4,
    183 	bs_notimpl_bs_rr_8,
    184 
    185 	/* write (single) */
    186 	isa_bs_w_1,
    187 	isa_bs_w_2,
    188 	isa_bs_w_4,
    189 	bs_notimpl_bs_w_8,
    190 
    191 	/* write multiple */
    192 	isa_bs_wm_1,
    193 	isa_bs_wm_2,
    194 	isa_bs_wm_4,
    195 	bs_notimpl_bs_wm_8,
    196 
    197 	/* write region */
    198 	isa_bs_wr_1,
    199 	isa_bs_wr_2,
    200 	isa_bs_wr_4,
    201 	bs_notimpl_bs_wr_8,
    202 
    203 	/* set multiple */
    204 	bs_notimpl_bs_sm_1,
    205 	bs_notimpl_bs_sm_2,
    206 	bs_notimpl_bs_sm_4,
    207 	bs_notimpl_bs_sm_8,
    208 
    209 	/* set region */
    210 	bs_notimpl_bs_sr_1,
    211 	isa_bs_sr_2,
    212 	bs_notimpl_bs_sr_4,
    213 	bs_notimpl_bs_sr_8,
    214 
    215 	/* copy */
    216 	bs_notimpl_bs_c_1,
    217 	bs_notimpl_bs_c_2,
    218 	bs_notimpl_bs_c_4,
    219 	bs_notimpl_bs_c_8,
    220 };
    221 
    222 /* bus space functions */
    223 
    224 void
    225 isa_io_init(isa_io_addr, isa_mem_addr)
    226 	vaddr_t isa_io_addr;
    227 	vaddr_t isa_mem_addr;
    228 {
    229 	isa_io_bs_tag.bs_cookie = (void *)isa_io_addr;
    230 	isa_mem_bs_tag.bs_cookie = (void *)isa_mem_addr;
    231 }
    232 
    233 /*
    234  * break the abstraction: sometimes, other parts of the system
    235  * (e.g. X servers) need to map ISA space directly.  use these
    236  * functions sparingly!
    237  */
    238 vaddr_t
    239 isa_io_data_vaddr(void)
    240 {
    241 	return (vaddr_t)isa_io_bs_tag.bs_cookie;
    242 }
    243 
    244 vaddr_t
    245 isa_mem_data_vaddr(void)
    246 {
    247 	return (vaddr_t)isa_mem_bs_tag.bs_cookie;
    248 }
    249 
    250 int
    251 isa_bs_map(t, bpa, size, cacheable, bshp)
    252 	void *t;
    253 	bus_addr_t bpa;
    254 	bus_size_t size;
    255 	int cacheable;
    256 	bus_space_handle_t *bshp;
    257 {
    258 	*bshp = bpa + (bus_addr_t)t;
    259 	return(0);
    260 }
    261 
    262 void
    263 isa_bs_unmap(t, bsh, size)
    264 	void *t;
    265 	bus_space_handle_t bsh;
    266 	bus_size_t size;
    267 {
    268 	/* Nothing to do. */
    269 }
    270 
    271 int
    272 isa_bs_subregion(t, bsh, offset, size, nbshp)
    273 	void *t;
    274 	bus_space_handle_t bsh;
    275 	bus_size_t offset, size;
    276 	bus_space_handle_t *nbshp;
    277 {
    278 /*	printf("isa_subregion(tag=%p, bsh=%lx, off=%lx, sz=%lx)\n",
    279 	    t, bsh, offset, size);*/
    280 	*nbshp = bsh + offset;
    281 	return(0);
    282 }
    283 
    284 int
    285 isa_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
    286     bpap, bshp)
    287 	void *t;
    288 	bus_addr_t rstart, rend;
    289 	bus_size_t size, alignment, boundary;
    290 	int cacheable;
    291 	bus_addr_t *bpap;
    292 	bus_space_handle_t *bshp;
    293 {
    294 	panic("isa_alloc(): Help!");
    295 }
    296 
    297 void
    298 isa_bs_free(t, bsh, size)
    299 	void *t;
    300 	bus_space_handle_t bsh;
    301 	bus_size_t size;
    302 {
    303 	panic("isa_free(): Help!");
    304 }
    305 
    306 void *
    307 isa_bs_vaddr(t, bsh)
    308 	void *t;
    309 	bus_space_handle_t bsh;
    310 {
    311 
    312 	return ((void *)bsh);
    313 }
    314 
    315 void
    316 isa_bs_barrier(t, bsh, offset, len, flags)
    317 	void *t;
    318 	bus_space_handle_t bsh;
    319 	bus_size_t offset, len;
    320 	int flags;
    321 {
    322 	/* just return */
    323 }
    324