isa_machdep.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* $OpenBSD: isa_machdep.h,v 1.25 2009/08/22 02:54:50 mk Exp $ */
  2. /* $NetBSD: isa_machdep.h,v 1.7 1997/06/06 23:28:42 thorpej Exp $ */
  3. /*-
  4. * Copyright (c) 1996, 1997 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. *
  20. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  21. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  22. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  24. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30. * POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. /*-
  33. * Copyright (c) 1990 The Regents of the University of California.
  34. * All rights reserved.
  35. *
  36. * This code is derived from software contributed to Berkeley by
  37. * William Jolitz.
  38. *
  39. * Redistribution and use in source and binary forms, with or without
  40. * modification, are permitted provided that the following conditions
  41. * are met:
  42. * 1. Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * 2. Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in the
  46. * documentation and/or other materials provided with the distribution.
  47. * 3. Neither the name of the University nor the names of its contributors
  48. * may be used to endorse or promote products derived from this software
  49. * without specific prior written permission.
  50. *
  51. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  52. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  53. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  54. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  55. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  56. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  57. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  58. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  59. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  60. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  61. * SUCH DAMAGE.
  62. *
  63. * @(#)isa.h 5.7 (Berkeley) 5/9/91
  64. */
  65. /*
  66. * Various pieces of the i386 port want to include this file without
  67. * or in spite of using isavar.h, and should be fixed.
  68. */
  69. #ifndef _I386_ISA_MACHDEP_H_ /* XXX */
  70. #define _I386_ISA_MACHDEP_H_ /* XXX */
  71. #include <machine/bus.h>
  72. /*
  73. * ISA can only DMA to 0-16M.
  74. */
  75. #define ISA_DMA_BOUNCE_THRESHOLD 0x00ffffff
  76. /*
  77. * XXX THIS FILE IS A MESS. copyright: berkeley's probably.
  78. * contents from isavar.h and isareg.h, mostly the latter.
  79. * perhaps charles's?
  80. *
  81. * copyright from berkeley's isa.h which is now dev/isa/isareg.h.
  82. */
  83. /*
  84. * Types provided to machine-independent ISA code.
  85. */
  86. typedef void *isa_chipset_tag_t;
  87. struct device; /* XXX */
  88. struct isabus_attach_args; /* XXX */
  89. /*
  90. * Functions provided to machine-independent ISA code.
  91. */
  92. void isa_attach_hook(struct device *, struct device *,
  93. struct isabus_attach_args *);
  94. int isa_intr_alloc(isa_chipset_tag_t, int, int, int *);
  95. int isa_intr_check(isa_chipset_tag_t, int, int);
  96. void *isa_intr_establish(isa_chipset_tag_t ic, int irq, int type,
  97. int level, int (*ih_fun)(void *), void *ih_arg,
  98. const char *ih_what);
  99. void isa_intr_disestablish(isa_chipset_tag_t ic, void *handler);
  100. /*
  101. * ALL OF THE FOLLOWING ARE MACHINE-DEPENDENT, AND SHOULD NOT BE USED
  102. * BY PORTABLE CODE.
  103. */
  104. extern struct bus_dma_tag isa_bus_dma_tag;
  105. /*
  106. * Cookie used by ISA dma. A pointer to one of these it stashed in
  107. * the DMA map.
  108. */
  109. struct isa_dma_cookie {
  110. int id_flags; /* flags; see below */
  111. void *id_origbuf; /* pointer to orig buffer if
  112. bouncing */
  113. bus_size_t id_origbuflen; /* ...and size */
  114. void *id_bouncebuf; /* pointer to the bounce buffer */
  115. bus_size_t id_bouncebuflen; /* ...and size */
  116. int id_nbouncesegs; /* number of valid bounce segs */
  117. bus_dma_segment_t id_bouncesegs[0]; /* array of bounce buffer
  118. physical memory segments */
  119. };
  120. /* id_flags */
  121. #define ID_MIGHT_NEED_BOUNCE 0x01 /* map could need bounce buffers */
  122. #define ID_HAS_BOUNCE 0x02 /* map currently has bounce buffers */
  123. #define ID_IS_BOUNCING 0x04 /* map is bouncing current xfer */
  124. /*
  125. * XXX Various seemingly PC-specific constants, some of which may be
  126. * unnecessary anyway.
  127. */
  128. /*
  129. * RAM Physical Address Space (ignoring the above mentioned "hole")
  130. */
  131. #define RAM_BEGIN 0x0000000 /* Start of RAM Memory */
  132. #define RAM_END 0x1000000 /* End of RAM Memory */
  133. #define RAM_SIZE (RAM_END - RAM_BEGIN)
  134. /*
  135. * Oddball Physical Memory Addresses
  136. */
  137. #define COMPAQ_RAMRELOC 0x80c00000 /* Compaq RAM relocation/diag */
  138. #define COMPAQ_RAMSETUP 0x80c00002 /* Compaq RAM setup */
  139. #define WEITEK_FPU 0xC0000000 /* WTL 2167 */
  140. #define CYRIX_EMC 0xC0000000 /* Cyrix EMC */
  141. /*
  142. * stuff that used to be in pccons.c
  143. */
  144. #define MONO_BUF 0xB0000
  145. #define CGA_BUF 0xB8000
  146. #define IOPHYSMEM 0xA0000
  147. /*
  148. * ISA DMA bounce buffers.
  149. * XXX should be made partially machine- and bus-mapping-independent.
  150. *
  151. * DMA_BOUNCE is the number of pages of low-addressed physical memory
  152. * to acquire for ISA bounce buffers. If physical memory below 16 MB
  153. * then DMA_BOUNCE_LOW will be used.
  154. *
  155. * isaphysmem is the address of this physical contiguous low memory.
  156. * isaphysmempgs is the number of pages allocated.
  157. */
  158. #ifndef DMA_BOUNCE
  159. #define DMA_BOUNCE 48 /* number of pages if memory > 16M */
  160. #endif
  161. #ifndef DMA_BOUNCE_LOW
  162. #define DMA_BOUNCE_LOW 16 /* number of pages if memory <= 16M */
  163. #endif
  164. extern vaddr_t isaphysmem;
  165. extern int isaphysmempgs;
  166. /*
  167. * Variables and macros to deal with the ISA I/O hole.
  168. * XXX These should be converted to machine- and bus-mapping-independent
  169. * function definitions, invoked through the softc.
  170. */
  171. extern u_long atdevbase; /* kernel virtual address of "hole" */
  172. /*
  173. * Given a kernel virtual address for some location
  174. * in the "hole" I/O space, return a physical address.
  175. */
  176. #define ISA_PHYSADDR(v) ((void *) ((u_long)(v) - atdevbase + IOM_BEGIN))
  177. /*
  178. * Given a physical address in the "hole",
  179. * return a kernel virtual address.
  180. */
  181. #define ISA_HOLE_VADDR(p) ((void *) ((u_long)(p) - IOM_BEGIN + atdevbase))
  182. #endif /* _I386_ISA_MACHDEP_H_ XXX */