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