Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.18.6.3
      1  1.18.6.3     skrll /*	$NetBSD: bus.h,v 1.18.6.3 2004/09/21 13:12:46 skrll Exp $	*/
      2       1.1        is 
      3       1.1        is /*
      4       1.1        is  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
      5       1.1        is  *
      6       1.1        is  * Redistribution and use in source and binary forms, with or without
      7       1.1        is  * modification, are permitted provided that the following conditions
      8       1.1        is  * are met:
      9       1.1        is  * 1. Redistributions of source code must retain the above copyright
     10       1.1        is  *    notice, this list of conditions and the following disclaimer.
     11       1.1        is  * 2. Redistributions in binary form must reproduce the above copyright
     12       1.1        is  *    notice, this list of conditions and the following disclaimer in the
     13       1.1        is  *    documentation and/or other materials provided with the distribution.
     14       1.1        is  * 3. All advertising materials mentioning features or use of this software
     15       1.1        is  *    must display the following acknowledgement:
     16       1.1        is  *      This product includes software developed by Leo Weppelman for the
     17       1.1        is  *	NetBSD Project.
     18       1.1        is  * 4. The name of the author may not be used to endorse or promote products
     19       1.1        is  *    derived from this software without specific prior written permission
     20       1.1        is  *
     21       1.1        is  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22       1.1        is  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23       1.1        is  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24       1.1        is  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25       1.1        is  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26       1.1        is  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27       1.1        is  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28       1.1        is  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29       1.1        is  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30       1.1        is  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31       1.1        is  */
     32       1.1        is 
     33       1.1        is #ifndef _AMIGA_BUS_H_
     34       1.1        is #define _AMIGA_BUS_H_
     35       1.1        is 
     36       1.4        is #include <sys/types.h>
     37       1.5        is 
     38      1.12        is /* for public use: */
     39      1.12        is 
     40       1.1        is /*
     41       1.1        is  * Memory addresses (in bus space)
     42       1.1        is  */
     43       1.5        is 
     44       1.4        is typedef u_int32_t bus_addr_t;
     45       1.4        is typedef u_int32_t bus_size_t;
     46       1.1        is 
     47       1.1        is /*
     48       1.1        is  * Access methods for bus resources and address space.
     49       1.1        is  */
     50       1.4        is typedef struct bus_space_tag *bus_space_tag_t;
     51       1.4        is typedef u_long	bus_space_handle_t;
     52       1.4        is 
     53      1.12        is /* unpublic, but needed by method implementors */
     54      1.12        is 
     55       1.5        is /*
     56       1.5        is  * Lazyness macros for function declarations.
     57       1.5        is  */
     58       1.5        is 
     59       1.4        is #define bsr(what, typ) \
     60      1.12        is 	typ (what)(bus_space_handle_t, bus_addr_t)
     61       1.4        is 
     62       1.4        is #define bsw(what, typ) \
     63      1.12        is 	void (what)(bus_space_handle_t, bus_addr_t, unsigned)
     64       1.4        is 
     65       1.4        is #define bsrm(what, typ) \
     66      1.12        is 	void (what)(bus_space_handle_t, bus_size_t, typ *, bus_size_t)
     67       1.4        is 
     68       1.4        is #define bswm(what, typ) \
     69      1.12        is 	void (what)(bus_space_handle_t, bus_size_t, const typ *, bus_size_t)
     70       1.4        is 
     71       1.5        is #define bssr(what, typ) \
     72      1.12        is 	void (what)(bus_space_handle_t, bus_size_t, unsigned, bus_size_t)
     73       1.5        is 
     74       1.5        is #define bscr(what, typ) \
     75      1.12        is 	void (what)(bus_space_handle_t, bus_size_t, \
     76      1.12        is 		    bus_space_handle_t, bus_size_t, bus_size_t)
     77       1.5        is 
     78       1.5        is /*
     79       1.5        is  * Implementation specific structures.
     80       1.5        is  * XXX Don't use outside of bus_space definitions!
     81       1.5        is  * XXX maybe this should be encapsuled in a non-global .h file?
     82       1.5        is  */
     83       1.5        is 
     84       1.5        is struct bus_space_tag {
     85       1.5        is 	bus_addr_t	base;
     86       1.9        is 	const struct amiga_bus_space_methods *absm;
     87       1.5        is };
     88       1.5        is 
     89       1.4        is struct amiga_bus_space_methods {
     90       1.5        is 
     91      1.12        is 	/* map, unmap, etc */
     92      1.12        is 
     93      1.12        is 	int (*bsm)(bus_space_tag_t,
     94      1.12        is 		bus_addr_t, bus_size_t, int, bus_space_handle_t *);
     95      1.12        is 
     96      1.12        is 	int (*bsms)(bus_space_handle_t,
     97      1.12        is 		bus_size_t, bus_size_t, bus_space_handle_t *);
     98      1.12        is 
     99      1.12        is 	void (*bsu)(bus_space_handle_t, bus_size_t);
    100      1.12        is 
    101      1.12        is 	/* placeholders for currently not implemented alloc and free */
    102      1.12        is 
    103      1.12        is 	void *bsa;
    104      1.12        is 	void *bsf;
    105      1.12        is 
    106      1.12        is 	/* 8 bit methods */
    107      1.12        is 
    108      1.12        is 	bsr(*bsr1, u_int8_t);
    109      1.12        is 	bsw(*bsw1, u_int8_t);
    110      1.12        is 	bsrm(*bsrm1, u_int8_t);
    111      1.12        is 	bswm(*bswm1, u_int8_t);
    112      1.12        is 	bsrm(*bsrr1, u_int8_t);
    113      1.12        is 	bswm(*bswr1, u_int8_t);
    114      1.12        is 	bssr(*bssr1, u_int8_t);
    115      1.12        is 	bscr(*bscr1, u_int8_t);
    116      1.12        is 
    117       1.4        is 	/* 16bit methods */
    118       1.5        is 
    119       1.4        is 	bsr(*bsr2, u_int16_t);
    120       1.4        is 	bsw(*bsw2, u_int16_t);
    121      1.12        is 	bsr(*bsrs2, u_int16_t);
    122      1.12        is 	bsw(*bsws2, u_int16_t);
    123       1.4        is 	bsrm(*bsrm2, u_int16_t);
    124       1.4        is 	bswm(*bswm2, u_int16_t);
    125      1.12        is 	bsrm(*bsrms2, u_int16_t);
    126      1.12        is 	bswm(*bswms2, u_int16_t);
    127       1.4        is 	bsrm(*bsrr2, u_int16_t);
    128       1.4        is 	bswm(*bswr2, u_int16_t);
    129       1.7        is 	bsrm(*bsrrs2, u_int16_t);
    130       1.7        is 	bswm(*bswrs2, u_int16_t);
    131       1.5        is 	bssr(*bssr2, u_int16_t);
    132       1.5        is 	bscr(*bscr2, u_int16_t);
    133       1.4        is 
    134       1.5        is 	/* add 32bit methods here */
    135       1.4        is };
    136       1.9        is 
    137       1.5        is /*
    138       1.5        is  * Macro definition of map, unmap, etc.
    139       1.5        is  */
    140       1.1        is 
    141      1.12        is #define bus_space_map(t, o, s, f, hp) \
    142      1.12        is 	((t)->absm->bsm)((t), (o), (s), (f), (hp))
    143       1.2        is 
    144      1.12        is #define bus_space_subregion(t, h, o, s, hp) \
    145      1.12        is 	((t)->absm->bsms)((h), (o), (s), (hp))
    146       1.1        is 
    147      1.12        is #define bus_space_unmap(t, h, s) \
    148      1.12        is 	((t)->absm->bsu)((h), (s))
    149       1.1        is 
    150       1.5        is /*
    151      1.12        is  * Macro definition of _2 functions as indirect method array calls
    152       1.5        is  */
    153       1.5        is 
    154      1.12        is /* 0: Helper macros */
    155      1.12        is 
    156      1.12        is #define dbsdr(n, t, h, o)	((t)->absm->n)((h), (o))
    157      1.12        is #define dbsdw(n, t, h, o, v)	((t)->absm->n)((h), (o), (v))
    158      1.12        is #define dbsm(n, t, h, o, p, c)	((t)->absm->n)((h), (o), (p), (c))
    159      1.12        is #define dbss(n, t, h, o, v, c)	((t)->absm->n)((h), (o), (v), (c))
    160      1.12        is #define dbsc(n, t, h, o, v, c)	((t)->absm->n)((h), (o), (v), (c))
    161       1.1        is 
    162      1.12        is /* 1: byte-wide "functions" */
    163       1.1        is 
    164      1.12        is #define bus_space_read_1(t, h, o)		  dbsdr(bsr1, t, h, o)
    165      1.12        is #define bus_space_write_1(t, h, o, v)		  dbsdw(bsw1, t, h, o, v)
    166      1.12        is 
    167      1.12        is #define bus_space_read_multi_1(t, h, o, p, c)	  dbsm(bsrm1, t, h, o, p, c)
    168      1.12        is #define bus_space_write_multi_1(t, h, o, p, c)	  dbsm(bswm1, t, h, o, p, c)
    169      1.12        is 
    170      1.12        is #define bus_space_read_region_1(t, h, o, p, c)	  dbsm(bsrr1, t, h, o, p, c)
    171      1.12        is #define bus_space_write_region_1(t, h, o, p, c)	  dbsm(bswr1, t, h, o, p, c)
    172      1.12        is 
    173      1.12        is #define bus_space_set_region_1(t, h, o, v, c)	  dbss(bssr1, t, h, o, v, c)
    174      1.12        is #define bus_space_copy_region_1(t, h, o, g, q, c) dbss(bscr1, t, h, o, g, q, c)
    175       1.5        is 
    176       1.5        is 
    177      1.12        is /* 2: word-wide "functions" */
    178       1.5        is 
    179      1.12        is #define bus_space_read_2(t, h, o)		  dbsdr(bsr2, t, h, o)
    180      1.12        is #define bus_space_write_2(t, h, o, v)		  dbsdw(bsw2, t, h, o, v)
    181      1.12        is #define bus_space_read_stream_2(t, h, o)	  dbsdr(bsrs2, t, h, o)
    182      1.12        is #define bus_space_write_stream_2(t, h, o, v)	  dbsdw(bsws2, t, h, o, v)
    183       1.5        is 
    184      1.12        is #define bus_space_read_multi_2(t, h, o, p, c)	  dbsm(bsrm2, t, h, o, p, c)
    185      1.12        is #define bus_space_write_multi_2(t, h, o, p, c)	  dbsm(bswm2, t, h, o, p, c)
    186       1.5        is 
    187      1.12        is #define bus_space_read_multi_stream_2(t, h, o, p, c) \
    188      1.12        is 						  dbsm(bsrms2, t, h, o, p, c)
    189       1.5        is 
    190      1.12        is #define bus_space_write_multi_stream_2(t, h, o, p, c) \
    191      1.12        is 						  dbsm(bswms2, t, h, o, p, c)
    192       1.5        is 
    193      1.12        is #define bus_space_read_region_2(t, h, o, p, c)	  dbsm(bsrr2, t, h, o, p, c)
    194      1.12        is #define bus_space_write_region_2(t, h, o, p, c)	  dbsm(bswr2, t, h, o, p, c)
    195       1.5        is 
    196       1.7        is #define bus_space_read_region_stream_2(t, h, o, p, c) \
    197      1.12        is 						  dbsm(bsrrs2, t, h, o, p, c)
    198       1.5        is 
    199       1.7        is #define bus_space_write_region_stream_2(t, h, o, p, c) \
    200      1.12        is 						  dbsm(bswrs2, t, h, o, p, c)
    201       1.5        is 
    202      1.12        is #define bus_space_set_region_2(t, h, o, v, c)	  dbss(bssr2, t, h, o, v, c)
    203      1.12        is #define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
    204      1.10  drochner 
    205      1.13   aymeric /* 4: Fake 32-bit macros */
    206      1.13   aymeric 
    207      1.13   aymeric #define bus_space_read_4(t, h, o) \
    208      1.15   aymeric 	(panic("bus_space_read_4 not implemented"), 0)
    209      1.13   aymeric 
    210      1.13   aymeric #define bus_space_write_4(t, h, o, v) \
    211      1.14    mhitch 	panic("bus_space_write_4 not implemented")
    212      1.18  jdolecek 
    213      1.18  jdolecek #define bus_space_read_stream_4(t, h, o) \
    214      1.18  jdolecek 	(panic("bus_space_read_stream_4 not implemented"), 0)
    215      1.18  jdolecek 
    216      1.18  jdolecek #define bus_space_write_stream_4(t, h, o, v) \
    217      1.18  jdolecek 	panic("bus_space_read_stream_4 not implemented")
    218      1.13   aymeric 
    219      1.13   aymeric #define bus_space_read_multi_4(t, h, o, p, c) \
    220      1.14    mhitch 	panic("bus_space_read_multi_4 not implemented")
    221      1.13   aymeric 
    222      1.13   aymeric #define bus_space_write_multi_4(t, h, o, p, c) \
    223      1.14    mhitch 	panic("bus_space_write_multi_4 not implemented")
    224      1.13   aymeric 
    225      1.13   aymeric #define bus_space_read_multi_stream_4(t, h, o, p, c) \
    226      1.14    mhitch 	panic("bus_space_read_multi_stream_4 not implemented")
    227      1.13   aymeric 
    228      1.13   aymeric #define bus_space_write_multi_stream_4(t, h, o, p, c) \
    229      1.14    mhitch 	panic("bus_space_write_multi_stream_4 not implemented")
    230      1.13   aymeric 
    231  1.18.6.1     skrll #define bus_space_read_region_stream_4(t, h, o, p, c) \
    232  1.18.6.1     skrll 	panic("bus_space_read_region_stream_4 not implemented")
    233  1.18.6.1     skrll 
    234  1.18.6.1     skrll #define bus_space_write_region_stream_4(t, h, o, p, c) \
    235  1.18.6.1     skrll 	panic("bus_space_write_region_stream_4 not implemented")
    236  1.18.6.1     skrll 
    237      1.11        is /*
    238      1.11        is  * Bus read/write barrier methods.
    239      1.11        is  *
    240      1.11        is  *      void bus_space_barrier __P((bus_space_tag_t tag,
    241      1.11        is  *          bus_space_handle_t bsh, bus_size_t offset,
    242      1.11        is  *          bus_size_t len, int flags));
    243      1.11        is  *
    244      1.11        is  * Note: the 680x0 does not currently require barriers, but we must
    245      1.11        is  * provide the flags to MI code.
    246      1.11        is  */
    247      1.11        is #define bus_space_barrier(t, h, o, l, f)        \
    248      1.11        is         ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
    249      1.11        is #define BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
    250      1.11        is #define BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
    251      1.11        is 
    252      1.10  drochner #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
    253      1.12        is 
    254      1.12        is #define __BUS_SPACE_HAS_STREAM_METHODS
    255      1.12        is 
    256      1.17   aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_1;
    257      1.17   aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_2;
    258      1.17   aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_4;
    259      1.17   aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
    260      1.17   aymeric extern const struct amiga_bus_space_methods amiga_bus_stride_16;
    261      1.12        is 
    262       1.1        is #endif /* _AMIGA_BUS_H_ */
    263