1 /* $NetBSD: isa_machdep.h,v 1.4 2003/05/09 23:51:26 fvdl Exp $ */ 2 3 /*- 4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 * NASA Ames Research Center. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. All advertising materials mentioning features or use of this software 20 * must display the following acknowledgement: 21 * This product includes software developed by the NetBSD 22 * Foundation, Inc. and its contributors. 23 * 4. Neither the name of The NetBSD Foundation nor the names of its 24 * contributors may be used to endorse or promote products derived 25 * from this software without specific prior written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 * POSSIBILITY OF SUCH DAMAGE. 38 */ 39 40 #ifndef _ARM32_ISA_MACHDEP_H_ 41 #define _ARM32_ISA_MACHDEP_H_ 42 43 #include <machine/bus.h> 44 #include <dev/isa/isadmavar.h> 45 46 /* 47 * Types provided to machine-independent ISA code. 48 */ 49 struct arm32_isa_chipset { 50 struct isa_dma_state ic_dmastate; 51 }; 52 53 typedef struct arm32_isa_chipset *isa_chipset_tag_t; 54 55 struct device; /* XXX */ 56 struct isabus_attach_args; /* XXX */ 57 58 /* 59 * Functions provided to machine-independent ISA code. 60 */ 61 void isa_attach_hook(struct device *, struct device *, 62 struct isabus_attach_args *); 63 const struct evcnt *isa_intr_evcnt(isa_chipset_tag_t ic, int irq); 64 void *isa_intr_establish(isa_chipset_tag_t ic, int irq, int type, 65 int level, int (*ih_fun)(void *), void *ih_arg); 66 void isa_intr_disestablish(isa_chipset_tag_t ic, void *handler); 67 68 #define isa_dmainit(ic, bst, dmat, d) \ 69 _isa_dmainit(&(ic)->ic_dmastate, (bst), (dmat), (d)) 70 #define isa_dmacascade(ic, c) \ 71 _isa_dmacascade(&(ic)->ic_dmastate, (c)) 72 #define isa_dmamaxsize(ic, c) \ 73 _isa_dmamaxsize(&(ic)->ic_dmastate, (c)) 74 #define isa_dmamap_create(ic, c, s, f) \ 75 _isa_dmamap_create(&(ic)->ic_dmastate, (c), (s), (f)) 76 #define isa_dmamap_destroy(ic, c) \ 77 _isa_dmamap_destroy(&(ic)->ic_dmastate, (c)) 78 #define isa_dmastart(ic, c, a, n, p, f, bf) \ 79 _isa_dmastart(&(ic)->ic_dmastate, (c), (a), (n), (p), (f), (bf)) 80 #define isa_dmaabort(ic, c) \ 81 _isa_dmaabort(&(ic)->ic_dmastate, (c)) 82 #define isa_dmacount(ic, c) \ 83 _isa_dmacount(&(ic)->ic_dmastate, (c)) 84 #define isa_dmafinished(ic, c) \ 85 _isa_dmafinished(&(ic)->ic_dmastate, (c)) 86 #define isa_dmadone(ic, c) \ 87 _isa_dmadone(&(ic)->ic_dmastate, (c)) 88 #define isa_dmafreeze(ic) \ 89 _isa_dmafreeze(&(ic)->ic_dmastate) 90 #define isa_dmathaw(ic) \ 91 _isa_dmathaw(&(ic)->ic_dmastate) 92 #define isa_dmamem_alloc(ic, c, s, ap, f) \ 93 _isa_dmamem_alloc(&(ic)->ic_dmastate, (c), (s), (ap), (f)) 94 #define isa_dmamem_free(ic, c, a, s) \ 95 _isa_dmamem_free(&(ic)->ic_dmastate, (c), (a), (s)) 96 #define isa_dmamem_map(ic, c, a, s, kp, f) \ 97 _isa_dmamem_map(&(ic)->ic_dmastate, (c), (a), (s), (kp), (f)) 98 #define isa_dmamem_unmap(ic, c, k, s) \ 99 _isa_dmamem_unmap(&(ic)->ic_dmastate, (c), (k), (s)) 100 #define isa_dmamem_mmap(ic, c, a, s, o, p, f) \ 101 _isa_dmamem_mmap(&(ic)->ic_dmastate, (c), (a), (s), (o), (p), (f)) 102 #define isa_drq_alloc(ic, c) \ 103 _isa_drq_alloc(&(ic)->ic_dmastate, c) 104 #define isa_drq_free(ic, c) \ 105 _isa_drq_free(&(ic)->ic_dmastate, c) 106 #define isa_drq_isfree(ic, c) \ 107 _isa_drq_isfree(&(ic)->ic_dmastate, (c)) 108 #define isa_malloc(ic, c, s, p, f) \ 109 _isa_malloc(&(ic)->ic_dmastate, (c), (s), (p), (f)) 110 #define isa_free(a, p) \ 111 _isa_free((a), (p)) 112 #define isa_mappage(m, o, p) \ 113 _isa_mappage((m), (o), (p)) 114 115 /* 116 * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED 117 * BY PORTABLE CODE. 118 */ 119 120 extern struct arm32_bus_dma_tag isa_bus_dma_tag; 121 122 /* 123 * Cookie used by ISA DMA. A pointer to one of these is stashed in 124 * the DMA map. 125 */ 126 struct arm32_isa_dma_cookie { 127 int id_flags; /* flags; see below */ 128 129 /* 130 * Information about the original buffer used during 131 * DMA map syncs. Note that origbuflen is only used 132 * for ID_BUFTYPE_LINEAR. 133 */ 134 void *id_origbuf; /* pointer to orig buffer if 135 bouncing */ 136 bus_size_t id_origbuflen; /* ...and size */ 137 int id_buftype; /* type of buffer */ 138 139 void *id_bouncebuf; /* pointer to the bounce buffer */ 140 bus_size_t id_bouncebuflen; /* ...and size */ 141 int id_nbouncesegs; /* number of valid bounce segs */ 142 bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer 143 physical memory segments */ 144 }; 145 146 /* id_flags */ 147 #define ID_MIGHT_NEED_BOUNCE 0x01 /* map could need bounce buffers */ 148 #define ID_HAS_BOUNCE 0x02 /* map currently has bounce buffers */ 149 #define ID_IS_BOUNCING 0x04 /* map is bouncing current xfer */ 150 151 /* id_buftype */ 152 #define ID_BUFTYPE_INVALID 0 153 #define ID_BUFTYPE_LINEAR 1 154 #define ID_BUFTYPE_MBUF 2 155 #define ID_BUFTYPE_UIO 3 156 #define ID_BUFTYPE_RAW 4 157 158 /* bus space tags */ 159 extern struct bus_space isa_io_bs_tag; 160 extern struct bus_space isa_mem_bs_tag; 161 162 /* ISA chipset */ 163 extern struct arm32_isa_chipset isa_chipset_tag; 164 165 /* for pccons.c */ 166 #define MONO_BASE 0x3B4 167 #define MONO_BUF 0x000B0000 168 #define CGA_BASE 0x3D4 169 #define CGA_BUF 0x000B8000 170 #define VGA_BUF 0xA0000 171 #define VGA_BUF_LEN (0xBFFFF - 0xA0000) 172 173 void isa_init(vaddr_t, vaddr_t); 174 void isa_io_init(vaddr_t, vaddr_t); 175 void isa_dma_init(void); 176 vaddr_t isa_io_data_vaddr(void); 177 vaddr_t isa_mem_data_vaddr(void); 178 int isa_intr_alloc(isa_chipset_tag_t ic, int mask, int type, int *irq); 179 void isa_intr_init(void); 180 181 /* 182 * Miscellanous functions. 183 */ 184 void sysbeep(int, int); /* beep with the system speaker */ 185 void isa_fillw(u_int val, void *addr, size_t len); 186 187 #endif /* _ARM32_ISA_MACHDEP_H_ XXX */ 188