Home | History | Annotate | Line # | Download | only in include
bus_defs.h revision 1.6.30.1
      1 /*	$NetBSD: bus_defs.h,v 1.6.30.1 2020/04/08 14:07:27 martin Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #ifndef _AMIGAPPC_BUS_DEFS_H_
     28 #define _AMIGAPPC_BUS_DEFS_H_
     29 
     30 /*
     31  * Memory addresses (in bus space)
     32  */
     33 
     34 typedef uint32_t bus_addr_t;
     35 typedef uint32_t bus_size_t;
     36 
     37 /*
     38  * Access methods for bus resources and address space.
     39  */
     40 typedef struct bus_space_tag *bus_space_tag_t;
     41 typedef u_long	bus_space_handle_t;
     42 
     43 struct amigappc_bus_dma_segment;
     44 struct amigappc_bus_dma_tag;
     45 struct amigappc_bus_dmamap;
     46 typedef struct amigappc_bus_dma_segment bus_dma_segment_t;
     47 typedef struct amigappc_bus_dma_tag bus_dma_tag_t;
     48 typedef struct amigappc_bus_dmamap bus_dmamap_t;
     49 
     50 struct amigappc_bus_dma_tag {
     51 	int dummy;
     52 };
     53 
     54 struct amigappc_bus_dma_segment {
     55 	bus_addr_t	ds_addr;
     56 	bus_size_t	ds_len;
     57 };
     58 
     59 struct amigappc_bus_dmamap {
     60 	bus_size_t		dm_maxsegsz;
     61 	bus_size_t		dm_mapsize;
     62 	int			dm_nsegs;
     63 	bus_dma_segment_t	*dm_segs;
     64 	/* TBD */
     65 };
     66 
     67 /* unpublic, but needed by method implementors */
     68 
     69 /*
     70  * Lazyness macros for function declarations.
     71  */
     72 
     73 #define bsr(what, typ) \
     74 	typ (what)(bus_space_handle_t, bus_addr_t)
     75 
     76 #define bsw(what, typ) \
     77 	void (what)(bus_space_handle_t, bus_addr_t, unsigned)
     78 
     79 #define bsrm(what, typ) \
     80 	void (what)(bus_space_handle_t, bus_size_t, typ *, bus_size_t)
     81 
     82 #define bswm(what, typ) \
     83 	void (what)(bus_space_handle_t, bus_size_t, const typ *, bus_size_t)
     84 
     85 #define bssr(what, typ) \
     86 	void (what)(bus_space_handle_t, bus_size_t, unsigned, bus_size_t)
     87 
     88 #define bscr(what, typ) \
     89 	void (what)(bus_space_handle_t, bus_size_t, \
     90 		    bus_space_handle_t, bus_size_t, bus_size_t)
     91 
     92 /*
     93  * Implementation specific structures.
     94  * XXX Don't use outside of bus_space definitions!
     95  * XXX maybe this should be encapsuled in a non-global .h file?
     96  */
     97 
     98 struct bus_space_tag {
     99 	bus_addr_t	base;
    100 	const struct amiga_bus_space_methods *absm;
    101 };
    102 
    103 struct amiga_bus_space_methods {
    104 
    105 	/* map, unmap, etc */
    106 
    107 	int (*bsm)(bus_space_tag_t,
    108 		bus_addr_t, bus_size_t, int, bus_space_handle_t *);
    109 
    110 	int (*bsms)(bus_space_handle_t,
    111 		bus_size_t, bus_size_t, bus_space_handle_t *);
    112 
    113 	void (*bsu)(bus_space_handle_t, bus_size_t);
    114 
    115 	/* placeholders for currently not implemented alloc and free */
    116 
    117 	void *bsa;
    118 	void *bsf;
    119 
    120 	/* 8 bit methods */
    121 
    122 	bsr(*bsr1, uint8_t);
    123 	bsw(*bsw1, uint8_t);
    124 	bsrm(*bsrm1, uint8_t);
    125 	bswm(*bswm1, uint8_t);
    126 	bsrm(*bsrr1, uint8_t);
    127 	bswm(*bswr1, uint8_t);
    128 	bssr(*bssr1, uint8_t);
    129 	bscr(*bscr1, uint8_t);
    130 
    131 	/* 16bit methods */
    132 
    133 	bsr(*bsr2, uint16_t);
    134 	bsw(*bsw2, uint16_t);
    135 	bsr(*bsrs2, uint16_t);
    136 	bsw(*bsws2, uint16_t);
    137 	bsrm(*bsrm2, uint16_t);
    138 	bswm(*bswm2, uint16_t);
    139 	bsrm(*bsrms2, uint16_t);
    140 	bswm(*bswms2, uint16_t);
    141 	bsrm(*bsrr2, uint16_t);
    142 	bswm(*bswr2, uint16_t);
    143 	bsrm(*bsrrs2, uint16_t);
    144 	bswm(*bswrs2, uint16_t);
    145 	bssr(*bssr2, uint16_t);
    146 	bscr(*bscr2, uint16_t);
    147 
    148 	/* 32bit methods */
    149 
    150 	bsr(*bsr4, uint32_t);
    151 	bsw(*bsw4, uint32_t);
    152 	bsr(*bsrs4, uint32_t);
    153 	bsw(*bsws4, uint32_t);
    154 	bsrm(*bsrm4, uint32_t);
    155 	bswm(*bswm4, uint32_t);
    156 	bsrm(*bsrms4, uint32_t);
    157 	bswm(*bswms4, uint32_t);
    158 	bsrm(*bsrr4, uint32_t);
    159 	bswm(*bswr4, uint32_t);
    160 	bsrm(*bsrrs4, uint32_t);
    161 	bswm(*bswrs4, uint32_t);
    162 	bssr(*bssr4, uint32_t);
    163 	bscr(*bscr4, uint32_t);
    164 };
    165 
    166 #define BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
    167 #define BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
    168 
    169 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
    170 
    171 #define __BUS_SPACE_HAS_STREAM_METHODS
    172 
    173 extern const struct amiga_bus_space_methods amiga_bus_stride_1;
    174 extern const struct amiga_bus_space_methods amiga_bus_stride_1swap;
    175 extern const struct amiga_bus_space_methods amiga_bus_stride_1swap_abs;
    176 extern const struct amiga_bus_space_methods amiga_bus_stride_2;
    177 extern const struct amiga_bus_space_methods amiga_bus_stride_4;
    178 extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
    179 extern const struct amiga_bus_space_methods amiga_bus_stride_16;
    180 extern const struct amiga_bus_space_methods amiga_bus_stride_0x1000;
    181 extern const struct amiga_bus_space_methods amiga_bus_stride_0x4000;
    182 
    183 #endif /* _AMIGAPPC_BUS_DEFS_H_ */
    184