xref: /netbsd-src/sys/arch/amiga/dev/zbusvar.h (revision 96c3e7714584b2bc308adb0055d0b6c7c0d65a43)
1*96c3e771Schristos /*	$NetBSD: zbusvar.h,v 1.10 2011/09/21 12:48:57 christos Exp $	*/
24726ce28Schopps 
34726ce28Schopps /*
44726ce28Schopps  * Copyright (c) 1994 Christian E. Hopps
54726ce28Schopps  * All rights reserved.
64726ce28Schopps  *
74726ce28Schopps  * Redistribution and use in source and binary forms, with or without
84726ce28Schopps  * modification, are permitted provided that the following conditions
94726ce28Schopps  * are met:
104726ce28Schopps  * 1. Redistributions of source code must retain the above copyright
114726ce28Schopps  *    notice, this list of conditions and the following disclaimer.
124726ce28Schopps  * 2. Redistributions in binary form must reproduce the above copyright
134726ce28Schopps  *    notice, this list of conditions and the following disclaimer in the
144726ce28Schopps  *    documentation and/or other materials provided with the distribution.
154726ce28Schopps  * 3. All advertising materials mentioning features or use of this software
164726ce28Schopps  *    must display the following acknowledgement:
174726ce28Schopps  *      This product includes software developed by Christian E. Hopps.
184726ce28Schopps  * 4. The name of the author may not be used to endorse or promote products
194726ce28Schopps  *    derived from this software without specific prior written permission
204726ce28Schopps  *
214726ce28Schopps  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
224726ce28Schopps  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
234726ce28Schopps  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
244726ce28Schopps  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
254726ce28Schopps  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
264726ce28Schopps  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
274726ce28Schopps  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
284726ce28Schopps  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
294726ce28Schopps  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
304726ce28Schopps  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
314726ce28Schopps  */
324726ce28Schopps #ifndef _ZBUSVAR_H_
334726ce28Schopps #define _ZBUSVAR_H_
344726ce28Schopps 
354726ce28Schopps struct zbus_args {
364726ce28Schopps 	void *pa;
374726ce28Schopps 	void *va;
384726ce28Schopps 	int size;
394726ce28Schopps 	int slot;
404726ce28Schopps 	int manid;
414726ce28Schopps 	int prodid;
424726ce28Schopps 	int serno;
434726ce28Schopps };
4490d26c88Saymeric 
4590d26c88Saymeric extern vaddr_t		ZTWOROMADDR;
4690d26c88Saymeric extern vaddr_t		ZTWOMEMADDR;
4790d26c88Saymeric extern u_int		NZTWOMEMPG;
4890d26c88Saymeric extern vaddr_t		ZBUSADDR;	/* kva of Zorro bus I/O pages */
4990d26c88Saymeric extern u_int		ZBUSAVAIL;	/* bytes of Zorro bus I/O space left */
5090d26c88Saymeric 
514726ce28Schopps #define ZTWOROMBASE	(0x00D80000)
524726ce28Schopps #define ZTWOROMTOP	(0x00F80000)
534726ce28Schopps #define NZTWOROMPG	btoc(ZTWOROMTOP-ZTWOROMBASE)
544726ce28Schopps 
55*96c3e771Schristos void *zbusmap(void *, u_int);
563e2616d8Srkujawa 
574726ce28Schopps /*
584726ce28Schopps  * maps a ztwo and/or A3000 builtin address into the mapped kva address
594726ce28Schopps  */
60ff3689f8Sis #if defined(__m68k__)
614726ce28Schopps #define ztwomap(pa) \
624726ce28Schopps     ((volatile void *)((u_int)ZTWOROMADDR - ZTWOROMBASE + (u_int)(pa)))
6353524e44Schristos #define ztwopa(va) ((void *)(ZTWOROMBASE + (u_int)(va) - (u_int)ZTWOROMADDR))
64ff3689f8Sis #else
65c2dfc316Sphx #define ztwomap(pa) ((volatile void *)(u_int)(pa))
66c2dfc316Sphx #define ztwopa(va) ((void *)(u_int)(va))
67ff3689f8Sis #endif
684726ce28Schopps 
694726ce28Schopps /*
704726ce28Schopps  * tests whether the address lies in our zorro2 rom space
714726ce28Schopps  */
724726ce28Schopps #define isztwokva(kva) \
734726ce28Schopps     ((u_int)(kva) >= ZTWOROMADDR && \
744726ce28Schopps     (u_int)(kva) < \
754726ce28Schopps     (ZTWOROMADDR + ZTWOROMTOP - ZTWOROMBASE))
764726ce28Schopps #define isztwopa(pa) ((u_int)(pa) >= ZTWOROMBASE && (u_int)(pa) <= ZTWOROMTOP)
774726ce28Schopps #define isztwomem(kva) \
784726ce28Schopps     (ZTWOMEMADDR && (u_int)(kva) >= ZTWOMEMADDR && \
790871fe34Sthorpej     (u_int)(kva) < (ZTWOMEMADDR + NZTWOMEMPG * PAGE_SIZE))
804726ce28Schopps 
814726ce28Schopps #define ZTHREEBASE	(0x40000000)
824726ce28Schopps #define ZTHREETOP	((u_long)0x80000000)
834726ce28Schopps #define NZTHREEPG	btoc(ZTHREETOP - ZTHREEBASE)
844726ce28Schopps 
854726ce28Schopps #define iszthreepa(pa) ((u_int)(pa) >= ZTHREEBASE && (u_int)(pa) <= ZTHREETOP)
864726ce28Schopps #endif /* _ZBUS_H_ */
87