configregs.pas 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit configregs;
  13. INTERFACE
  14. uses exec;
  15. {
  16. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  17. ** read by the system software at configuration time. Configuration of each
  18. ** board starts when the ConfigIn* signal is passed from the previous board
  19. ** (or from the system for the first board). Each board will present it's
  20. ** ExpansionRom structure at location $00E80000 to be read by the system.
  21. ** This file defines the appearance of the ExpansionRom area.
  22. **
  23. ** Expansion boards are actually organized such that only one nybble per
  24. ** 16 bit word contains valid information. The low nybbles of each
  25. ** word are combined to fill the structure below. (This table is structured
  26. ** as LOGICAL information. This means that it never corresponds exactly
  27. ** with a physical implementation.)
  28. **
  29. ** The ExpansionRom space is further split into two regions: The first 16
  30. ** bytes are read-only. Except for the er_type field, this area is inverted
  31. ** by the system software when read in. The second 16 bytes contain the
  32. ** control portion, where all read/write registers are located.
  33. **
  34. ** The system builds one "ConfigDev" structure for each board found. The
  35. ** list of boards can be examined using the expansion.library/FindConfigDev
  36. ** function.
  37. **
  38. ** A special "hacker" Manufacturer ID number is reserved for test use:
  39. ** 2011 ($7DB). When inverted this will look like $F824.
  40. }
  41. Type
  42. pExpansionRom = ^tExpansionRom;
  43. tExpansionRom = record
  44. er_Type : Byte;
  45. er_Product : Byte;
  46. er_Flags : Byte;
  47. er_Reserved03 : Byte;
  48. er_Manufacturer : Word;
  49. er_SerialNumber : ULONG;
  50. er_InitDiagVec : Word;
  51. er_Reserved0c : Byte;
  52. er_Reserved0d : Byte;
  53. er_Reserved0e : Byte;
  54. er_Reserved0f : Byte;
  55. end;
  56. {
  57. ** Note that use of the ec_BaseAddress register is tricky. The system
  58. ** will actually write twice. First the low order nybble is written
  59. ** to the ec_BaseAddress register+2 (D15-D12). Then the entire byte is
  60. ** written to ec_BaseAddress (D15-D8). This allows writing of a byte-wide
  61. ** address to nybble size registers.
  62. }
  63. pExpansionControl = ^tExpansionControl;
  64. tExpansionControl = record
  65. ec_Interrupt : Byte; { interrupt control register }
  66. ec_Reserved11 : Byte;
  67. ec_BaseAddress : Byte; { set new config address }
  68. ec_Shutup : Byte; { don't respond, pass config out }
  69. ec_Reserved14 : Byte;
  70. ec_Reserved15 : Byte;
  71. ec_Reserved16 : Byte;
  72. ec_Reserved17 : Byte;
  73. ec_Reserved18 : Byte;
  74. ec_Reserved19 : Byte;
  75. ec_Reserved1a : Byte;
  76. ec_Reserved1b : Byte;
  77. ec_Reserved1c : Byte;
  78. ec_Reserved1d : Byte;
  79. ec_Reserved1e : Byte;
  80. ec_Reserved1f : Byte;
  81. end;
  82. {
  83. ** many of the constants below consist of a triplet of equivalent
  84. ** definitions: xxMASK is a bit mask of those bits that matter.
  85. ** xxBIT is the starting bit number of the field. xxSIZE is the
  86. ** number of bits that make up the definition. This method is
  87. ** used when the field is larger than one bit.
  88. **
  89. ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
  90. ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
  91. }
  92. Const
  93. { manifest constants }
  94. E_SLOTSIZE = $10000;
  95. E_SLOTMASK = -1;
  96. E_SLOTSHIFT = 16;
  97. { these define the two free regions of Zorro memory space.
  98. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  99. }
  100. E_EXPANSIONBASE = $e80000;
  101. EZ3_EXPANSIONBASE = $ff000000; { Zorro III config address }
  102. E_EXPANSIONSIZE = $080000;
  103. E_EXPANSIONSLOTS = 8;
  104. E_MEMORYBASE = $200000;
  105. E_MEMORYSIZE = $800000;
  106. E_MEMORYSLOTS = 128;
  107. EZ3_CONFIGAREA = $40000000; { Zorro III space }
  108. EZ3_CONFIGAREAEND = $7FFFFFFF; { Zorro III space }
  109. EZ3_SIZEGRANULARITY = $00080000; { 512K increments }
  110. { *** er_Type definitions (ttldcmmm) **************************************}
  111. { er_Type board type bits -- the OS ignores "old style" boards }
  112. ERT_TYPEMASK = $c0; {Bits 7-6 }
  113. ERT_TYPEBIT = 6 ;
  114. ERT_TYPESIZE = 2 ;
  115. ERT_NEWBOARD = $c0;
  116. ERT_ZORROII = ERT_NEWBOARD;
  117. ERT_ZORROIII = $80;
  118. { other bits defined in er_Type }
  119. ERTB_MEMLIST = 5; { Link RAM into free memory list }
  120. ERTB_DIAGVALID = 4; { ROM vector is valid }
  121. ERTB_CHAINEDCONFIG = 3; { Next config is part of the same card }
  122. ERTF_MEMLIST = 32;
  123. ERTF_DIAGVALID = 16;
  124. ERTF_CHAINEDCONFIG = 8;
  125. { er_Type field memory size bits }
  126. ERT_MEMMASK = $07; {Bits 2-0 }
  127. ERT_MEMBIT = 0 ;
  128. ERT_MEMSIZE = 3 ;
  129. { *** er_Flags byte -- for those things that didn't fit into the type byte ***}
  130. { *** the hardware stores this byte in inverted form ***}
  131. ERFF_MEMSPACE = 128; { Wants to be in 8 meg space. }
  132. ERFB_MEMSPACE = 7; { (NOT IMPLEMENTED) }
  133. ERFF_NOSHUTUP = 64; { Board can't be shut up }
  134. ERFB_NOSHUTUP = 6;
  135. ERFF_EXTENDED = 32; { Zorro III: Use extended size table }
  136. ERFB_EXTENDED = 5; { for bits 0-2 of er_Type }
  137. { Zorro II : Must be 0 }
  138. ERFF_ZORRO_III = 16; { Zorro III: must be 1 }
  139. ERFB_ZORRO_III = 4; { Zorro II : must be 0 }
  140. ERT_Z3_SSMASK = $0F; { Bits 3-0. Zorro III Sub-Size. How }
  141. ERT_Z3_SSBIT = 0; { much space the card actually uses }
  142. ERT_Z3_SSSIZE = 4; { (regardless of config granularity) }
  143. { Zorro II : must be 0 }
  144. { ec_Interrupt register (unused) *******************************************}
  145. ECIB_INTENA = 1;
  146. ECIB_RESET = 3;
  147. ECIB_INT2PEND = 4;
  148. ECIB_INT6PEND = 5;
  149. ECIB_INT7PEND = 6;
  150. ECIB_INTERRUPTING = 7;
  151. ECIF_INTENA = 2;
  152. ECIF_RESET = 8;
  153. ECIF_INT2PEND = 16;
  154. ECIF_INT6PEND = 32;
  155. ECIF_INT7PEND = 64;
  156. ECIF_INTERRUPTING = 128;
  157. {**************************************************************************
  158. **
  159. ** these are the specifications for the diagnostic area. If the Diagnostic
  160. ** Address Valid bit is set in the Board Type byte (the first byte in
  161. ** expansion space) then the Diag Init vector contains a valid offset.
  162. **
  163. ** The Diag Init vector is actually a word offset from the base of the
  164. ** board. The resulting address points to the base of the DiagArea
  165. ** structure. The structure may be physically implemented either four,
  166. ** eight, or sixteen bits wide. The code will be copied out into
  167. ** ram first before being called.
  168. **
  169. ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
  170. ** are offsets from the diag area AFTER it has been copied into ram, and
  171. ** "de-nibbleized" (if needed). Inotherwords, the size is the size of
  172. ** the actual information, not how much address space is required to
  173. ** store it.
  174. **
  175. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  176. ** is a logic one).
  177. **
  178. ** If your board is to make use of the boot facility then it must leave
  179. ** its config area available even after it has been configured. Your
  180. ** boot vector will be called AFTER your board's final address has been
  181. ** set.
  182. **
  183. ***************************************************************************}
  184. Type
  185. pDiagArea = ^tDiagArea;
  186. tDiagArea = record
  187. da_Config : Byte; { see below for definitions }
  188. da_Flags : Byte; { see below for definitions }
  189. da_Size : Word; { the size (in bytes) of the total diag area }
  190. da_DiagPoint : Word; { where to start for diagnostics, or zero }
  191. da_BootPoint : Word; { where to start for booting }
  192. da_Name : Word; { offset in diag area where a string }
  193. { identifier can be found (or zero if no }
  194. { identifier is present). }
  195. da_Reserved01 : Word; { two words of reserved data. must be zero. }
  196. da_Reserved02 : Word;
  197. end;
  198. Const
  199. { da_Config definitions }
  200. DAC_BUSWIDTH = $C0; { two bits for bus width }
  201. DAC_NIBBLEWIDE = $00;
  202. DAC_BYTEWIDE = $40;
  203. DAC_WORDWIDE = $80;
  204. DAC_BOOTTIME = $30; { two bits for when to boot }
  205. DAC_NEVER = $00; { obvious }
  206. DAC_CONFIGTIME = $10; { call da_BootPoint when first configing the }
  207. { the device }
  208. DAC_BINDTIME = $20; { run when binding drivers to boards }
  209. {
  210. ** These are the calling conventions for Diag or Boot area
  211. **
  212. ** A7 -- points to at least 2K of stack
  213. ** A6 -- ExecBase
  214. ** A5 -- ExpansionBase
  215. ** A3 -- your board's ConfigDev structure
  216. ** A2 -- Base of diag/init area that was copied
  217. ** A0 -- Base of your board
  218. **
  219. ** Your board should return a value in D0. If this value is NULL, then
  220. ** the diag/init area that was copied in will be returned to the free
  221. ** memory pool.
  222. }
  223. IMPLEMENTATION
  224. end.