1*28d09237Sjsg /* $OpenBSD: isa_machdep.h,v 1.11 2024/05/22 05:51:49 jsg Exp $ */ 2f5df1827Smickey /* $NetBSD: isa_machdep.h,v 1.2 2003/05/09 23:51:28 fvdl Exp $ */ 3f5df1827Smickey 4f5df1827Smickey /*- 5f5df1827Smickey * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 6f5df1827Smickey * All rights reserved. 7f5df1827Smickey * 8f5df1827Smickey * This code is derived from software contributed to The NetBSD Foundation 9f5df1827Smickey * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 10f5df1827Smickey * NASA Ames Research Center. 11f5df1827Smickey * 12f5df1827Smickey * Redistribution and use in source and binary forms, with or without 13f5df1827Smickey * modification, are permitted provided that the following conditions 14f5df1827Smickey * are met: 15f5df1827Smickey * 1. Redistributions of source code must retain the above copyright 16f5df1827Smickey * notice, this list of conditions and the following disclaimer. 17f5df1827Smickey * 2. Redistributions in binary form must reproduce the above copyright 18f5df1827Smickey * notice, this list of conditions and the following disclaimer in the 19f5df1827Smickey * documentation and/or other materials provided with the distribution. 20f5df1827Smickey * 21f5df1827Smickey * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22f5df1827Smickey * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23f5df1827Smickey * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24f5df1827Smickey * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25f5df1827Smickey * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26f5df1827Smickey * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27f5df1827Smickey * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28f5df1827Smickey * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29f5df1827Smickey * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30f5df1827Smickey * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31f5df1827Smickey * POSSIBILITY OF SUCH DAMAGE. 32f5df1827Smickey */ 33f5df1827Smickey 34f5df1827Smickey /*- 35f5df1827Smickey * Copyright (c) 1990 The Regents of the University of California. 36f5df1827Smickey * All rights reserved. 37f5df1827Smickey * 38f5df1827Smickey * This code is derived from software contributed to Berkeley by 39f5df1827Smickey * William Jolitz. 40f5df1827Smickey * 41f5df1827Smickey * Redistribution and use in source and binary forms, with or without 42f5df1827Smickey * modification, are permitted provided that the following conditions 43f5df1827Smickey * are met: 44f5df1827Smickey * 1. Redistributions of source code must retain the above copyright 45f5df1827Smickey * notice, this list of conditions and the following disclaimer. 46f5df1827Smickey * 2. Redistributions in binary form must reproduce the above copyright 47f5df1827Smickey * notice, this list of conditions and the following disclaimer in the 48f5df1827Smickey * documentation and/or other materials provided with the distribution. 49c5217b0aSjsg * 3. Neither the name of the University nor the names of its contributors 50f5df1827Smickey * may be used to endorse or promote products derived from this software 51f5df1827Smickey * without specific prior written permission. 52f5df1827Smickey * 53f5df1827Smickey * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 54f5df1827Smickey * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 55f5df1827Smickey * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 56f5df1827Smickey * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 57f5df1827Smickey * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58f5df1827Smickey * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59f5df1827Smickey * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60f5df1827Smickey * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61f5df1827Smickey * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62f5df1827Smickey * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63f5df1827Smickey * SUCH DAMAGE. 64f5df1827Smickey * 65f5df1827Smickey * @(#)isa.h 5.7 (Berkeley) 5/9/91 66f5df1827Smickey */ 67f5df1827Smickey 68f5df1827Smickey /* 69f5df1827Smickey * Various pieces of the i386 port want to include this file without 70f5df1827Smickey * or in spite of using isavar.h, and should be fixed. 71f5df1827Smickey */ 72f5df1827Smickey 73f5df1827Smickey #ifndef _I386_ISA_MACHDEP_H_ /* XXX */ 74f5df1827Smickey #define _I386_ISA_MACHDEP_H_ /* XXX */ 75f5df1827Smickey 76f5df1827Smickey #include <machine/bus.h> 77f5df1827Smickey #include <dev/isa/isadmavar.h> 78f5df1827Smickey 79f5df1827Smickey /* 80378d465bSderaadt * ISA can only DMA to 0-16M. 81378d465bSderaadt */ 82378d465bSderaadt #define ISA_DMA_BOUNCE_THRESHOLD 0x00ffffff 83378d465bSderaadt 84378d465bSderaadt /* 85f5df1827Smickey * XXX THIS FILE IS A MESS. copyright: berkeley's probably. 86f5df1827Smickey * contents from isavar.h and isareg.h, mostly the latter. 87f5df1827Smickey * perhaps charles's? 88f5df1827Smickey * 89f5df1827Smickey * copyright from berkeley's isa.h which is now dev/isa/isareg.h. 90f5df1827Smickey */ 91f5df1827Smickey 92f5df1827Smickey /* 93f5df1827Smickey * Types provided to machine-independent ISA code. 94f5df1827Smickey */ 95f5df1827Smickey 96f5df1827Smickey typedef void *isa_chipset_tag_t; 97f5df1827Smickey 98f5df1827Smickey struct device; /* XXX */ 99f5df1827Smickey struct isabus_attach_args; /* XXX */ 100f5df1827Smickey 101f5df1827Smickey /* 102f5df1827Smickey * Functions provided to machine-independent ISA code. 103f5df1827Smickey */ 104f5df1827Smickey void isa_attach_hook(struct device *, struct device *, 105f5df1827Smickey struct isabus_attach_args *); 106f5df1827Smickey int isa_intr_alloc(isa_chipset_tag_t, int, int, int *); 107f5df1827Smickey void *isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, 108f5df1827Smickey int level, int (*ih_fun)(void *), void *ih_arg, char *); 109f5df1827Smickey void isa_intr_disestablish(isa_chipset_tag_t ic, void *handler); 110f5df1827Smickey 111f5df1827Smickey int isa_intr_check(isa_chipset_tag_t, int, int); 112f5df1827Smickey 113f5df1827Smickey /* 114f5df1827Smickey * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED 115f5df1827Smickey * BY PORTABLE CODE. 116f5df1827Smickey */ 117f5df1827Smickey 11813fad3d0Soga extern struct bus_dma_tag isa_bus_dma_tag; 119f5df1827Smickey 120f5df1827Smickey /* 121aff9e93dSderaadt * Cookie used by ISA dma. A pointer to one of these it stashed in 122aff9e93dSderaadt * the DMA map. 123aff9e93dSderaadt */ 1248074ca3eSoga struct isa_dma_cookie { 125aff9e93dSderaadt int id_flags; /* flags; see below */ 126aff9e93dSderaadt 127aff9e93dSderaadt void *id_origbuf; /* pointer to orig buffer if 128aff9e93dSderaadt bouncing */ 129aff9e93dSderaadt bus_size_t id_origbuflen; /* ...and size */ 130aff9e93dSderaadt 131aff9e93dSderaadt void *id_bouncebuf; /* pointer to the bounce buffer */ 132aff9e93dSderaadt bus_size_t id_bouncebuflen; /* ...and size */ 133aff9e93dSderaadt int id_nbouncesegs; /* number of valid bounce segs */ 134aff9e93dSderaadt bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer 135aff9e93dSderaadt physical memory segments */ 136aff9e93dSderaadt }; 137aff9e93dSderaadt 138aff9e93dSderaadt /* id_flags */ 139aff9e93dSderaadt #define ID_MIGHT_NEED_BOUNCE 0x01 /* map could need bounce buffers */ 140aff9e93dSderaadt #define ID_HAS_BOUNCE 0x02 /* map currently has bounce buffers */ 141aff9e93dSderaadt #define ID_IS_BOUNCING 0x04 /* map is bouncing current xfer */ 142aff9e93dSderaadt 143f5df1827Smickey /* 144f5df1827Smickey * Variables and macros to deal with the ISA I/O hole. 145f5df1827Smickey * XXX These should be converted to machine- and bus-mapping-independent 146f5df1827Smickey * function definitions, invoked through the softc. 147f5df1827Smickey */ 148f5df1827Smickey 149f5df1827Smickey extern u_long atdevbase; /* kernel virtual address of "hole" */ 150f5df1827Smickey 151f5df1827Smickey /* 152f5df1827Smickey * Given a kernel virtual address for some location 153f5df1827Smickey * in the "hole" I/O space, return a physical address. 154f5df1827Smickey */ 155f5df1827Smickey #define ISA_PHYSADDR(v) ((void *) ((u_long)(v) - atdevbase + IOM_BEGIN)) 156f5df1827Smickey 157f5df1827Smickey /* 158f5df1827Smickey * Given a physical address in the "hole", 159f5df1827Smickey * return a kernel virtual address. 160f5df1827Smickey */ 161f5df1827Smickey #define ISA_HOLE_VADDR(p) ((void *) ((u_long)(p) - IOM_BEGIN + atdevbase)) 162f5df1827Smickey 163f5df1827Smickey #endif /* _I386_ISA_MACHDEP_H_ XXX */ 164