home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / cbm / os-include.lha / os-include / libraries / configregs.h < prev    next >
C/C++ Source or Header  |  1993-10-15  |  10KB  |  283 lines

  1. #ifndef LIBRARIES_CONFIGREGS_H
  2. #define LIBRARIES_CONFIGREGS_H
  3. /*
  4. **    $VER: configregs.h 36.13 (15.2.91)
  5. **    Includes Release 40.15
  6. **
  7. **    AutoConfig (tm) hardware register and bit definitions
  8. **
  9. **    (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13.  
  14. #ifndef EXEC_TYPES_H
  15. #include "exec/types.h"
  16. #endif    /* EXEC_TYPES_H */
  17.  
  18.  
  19. /*
  20. ** AutoConfig (tm) boards each contain a 32 byte "ExpansionRom" area that is
  21. ** read by the system software at configuration time.  Configuration of each
  22. ** board starts when the ConfigIn* signal is passed from the previous board
  23. ** (or from the system for the first board).  Each board will present it's
  24. ** ExpansionRom structure at location $00E80000 to be read by the system.
  25. ** This file defines the appearance of the ExpansionRom area.
  26. **
  27. ** Expansion boards are actually organized such that only one nybble per
  28. ** 16 bit word contains valid information.  The low nybbles of each
  29. ** word are combined to fill the structure below. (This table is structured
  30. ** as LOGICAL information.  This means that it never corresponds exactly
  31. ** with a physical implementation.)
  32. **
  33. ** The ExpansionRom space is further split into two regions:  The first 16
  34. ** bytes are read-only.  Except for the er_type field, this area is inverted
  35. ** by the system software when read in.  The second 16 bytes contain the
  36. ** control portion, where all read/write registers are located.
  37. **
  38. ** The system builds one "ConfigDev" structure for each board found.  The
  39. ** list of boards can be examined using the expansion.library/FindConfigDev
  40. ** function.
  41. **
  42. ** A special "hacker" Manufacturer ID number is reserved for test use:
  43. ** 2011 ($7DB).  When inverted this will look like $F824.
  44. */
  45.  
  46. struct ExpansionRom {        /* -First 16 bytes of the expansion ROM */
  47.     UBYTE    er_Type;    /* Board type, size and flags */
  48.     UBYTE    er_Product;    /* Product number, assigned by manufacturer */
  49.     UBYTE    er_Flags;    /* Flags */
  50.     UBYTE    er_Reserved03;    /* Must be zero ($ff inverted) */
  51.     UWORD    er_Manufacturer; /* Unique ID,ASSIGNED BY COMMODORE-AMIGA! */
  52.     ULONG    er_SerialNumber; /* Available for use by manufacturer */
  53.     UWORD    er_InitDiagVec; /* Offset to optional "DiagArea" structure */
  54.     UBYTE    er_Reserved0c;
  55.     UBYTE    er_Reserved0d;
  56.     UBYTE    er_Reserved0e;
  57.     UBYTE    er_Reserved0f;
  58. };
  59.  
  60.  
  61. /*
  62. ** Note that use of the ec_BaseAddress register is tricky.  The system
  63. ** will actually write twice.  First the low order nybble is written
  64. ** to the ec_BaseAddress register+2 (D15-D12).    Then the entire byte is
  65. ** written to ec_BaseAddress (D15-D8).    This allows writing of a byte-wide
  66. ** address to nybble size registers.
  67. */
  68.  
  69. struct ExpansionControl {    /* -Second 16 bytes of the expansion ROM */
  70.     UBYTE    ec_Interrupt;    /* Optional interrupt control register */
  71.     UBYTE    ec_Z3_HighBase; /* Zorro III   : Config address bits 24-31 */
  72.     UBYTE    ec_BaseAddress; /* Zorro II/III: Config address bits 16-23 */
  73.     UBYTE    ec_Shutup;    /* The system writes here to shut up a board */
  74.     UBYTE    ec_Reserved14;
  75.     UBYTE    ec_Reserved15;
  76.     UBYTE    ec_Reserved16;
  77.     UBYTE    ec_Reserved17;
  78.     UBYTE    ec_Reserved18;
  79.     UBYTE    ec_Reserved19;
  80.     UBYTE    ec_Reserved1a;
  81.     UBYTE    ec_Reserved1b;
  82.     UBYTE    ec_Reserved1c;
  83.     UBYTE    ec_Reserved1d;
  84.     UBYTE    ec_Reserved1e;
  85.     UBYTE    ec_Reserved1f;
  86. };
  87.  
  88. /*
  89. ** many of the constants below consist of a triplet of equivalent
  90. ** definitions: xxMASK is a bit mask of those bits that matter.
  91. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  92. ** number of bits that make up the definition.    This method is
  93. ** used when the field is larger than one bit.
  94. **
  95. ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
  96. ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
  97. */
  98.  
  99. /* manifest constants */
  100. #define E_SLOTSIZE        0x10000
  101. #define E_SLOTMASK        0xffff
  102. #define E_SLOTSHIFT        16
  103.  
  104. /* these define the free regions of Zorro memory space.
  105. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  106. */
  107. #define E_EXPANSIONBASE    0x00e80000    /* Zorro II  config address */
  108. #define EZ3_EXPANSIONBASE    0xff000000    /* Zorro III config address */
  109.  
  110. #define E_EXPANSIONSIZE    0x00080000    /* Zorro II  I/O type cards */
  111. #define E_EXPANSIONSLOTS    8
  112.  
  113. #define E_MEMORYBASE        0x00200000    /* Zorro II  8MB space */
  114. #define E_MEMORYSIZE        0x00800000
  115. #define E_MEMORYSLOTS        128
  116.  
  117. #define EZ3_CONFIGAREA        0x40000000    /* Zorro III space */
  118. #define EZ3_CONFIGAREAEND    0x7FFFFFFF    /* Zorro III space */
  119. #define EZ3_SIZEGRANULARITY    0x00080000    /* 512K increments */
  120.  
  121.  
  122.  
  123. /**** er_Type definitions (ttldcmmm) ***************************************/
  124.  
  125. /* er_Type board type bits -- the OS ignores "old style" boards */
  126. #define ERT_TYPEMASK        0xc0    /* Bits 7-6 */
  127. #define ERT_TYPEBIT        6
  128. #define ERT_TYPESIZE        2
  129. #define ERT_NEWBOARD        0xc0
  130. #define ERT_ZORROII        ERT_NEWBOARD
  131. #define ERT_ZORROIII        0x80
  132.  
  133. /* other bits defined in er_Type */
  134. #define ERTB_MEMLIST        5   /* Link RAM into free memory list */
  135. #define ERTB_DIAGVALID        4   /* ROM vector is valid */
  136. #define ERTB_CHAINEDCONFIG    3   /* Next config is part of the same card */
  137.  
  138. #define ERTF_MEMLIST        (1<<5)
  139. #define ERTF_DIAGVALID        (1<<4)
  140. #define ERTF_CHAINEDCONFIG    (1<<3)
  141.  
  142. /* er_Type field memory size bits */
  143. #define ERT_MEMMASK        0x07    /* Bits 2-0 */
  144. #define ERT_MEMBIT        0
  145. #define ERT_MEMSIZE        3
  146.  
  147.  
  148.  
  149. /**** er_Flags byte -- for those things that didn't fit into the type byte ****/
  150. /**** the hardware stores this byte in inverted form               ****/
  151. #define ERFF_MEMSPACE        (1<<7)    /* Wants to be in 8 meg space. */
  152. #define ERFB_MEMSPACE        7    /* (NOT IMPLEMENTED) */
  153.  
  154. #define ERFF_NOSHUTUP        (1<<6)    /* Board can't be shut up */
  155. #define ERFB_NOSHUTUP        6
  156.  
  157. #define ERFF_EXTENDED        (1<<5)    /* Zorro III: Use extended size table */
  158. #define ERFB_EXTENDED        5    /*          for bits 0-2 of er_Type */
  159.                     /* Zorro II : Must be 0 */
  160.  
  161. #define ERFF_ZORRO_III        (1<<4)    /* Zorro III: must be 1 */
  162. #define ERFB_ZORRO_III        4    /* Zorro II : must be 0 */
  163.  
  164. #define ERT_Z3_SSMASK        0x0F    /* Bits 3-0.  Zorro III Sub-Size.  How */
  165. #define ERT_Z3_SSBIT        0    /* much space the card actually uses   */
  166. #define ERT_Z3_SSSIZE        4    /* (regardless of config granularity)  */
  167.                     /* Zorro II : must be 0           */
  168.  
  169.  
  170. /* ec_Interrupt register (unused) ********************************************/
  171. #define ECIB_INTENA        1
  172. #define ECIB_RESET        3
  173. #define ECIB_INT2PEND        4
  174. #define ECIB_INT6PEND        5
  175. #define ECIB_INT7PEND        6
  176. #define ECIB_INTERRUPTING    7
  177.  
  178. #define ECIF_INTENA        (1<<1)
  179. #define ECIF_RESET        (1<<3)
  180. #define ECIF_INT2PEND        (1<<4)
  181. #define ECIF_INT6PEND        (1<<5)
  182. #define ECIF_INT7PEND        (1<<6)
  183. #define ECIF_INTERRUPTING    (1<<7)
  184.  
  185.  
  186.  
  187. /* figure out amount of memory needed by this box/board */
  188. #define ERT_MEMNEEDED(t)    \
  189.     (((t)&ERT_MEMMASK)? 0x10000 << (((t)&ERT_MEMMASK) -1) : 0x800000 )
  190.  
  191. /* same as ERT_MEMNEEDED, but return number of slots */
  192. #define ERT_SLOTSNEEDED(t)    \
  193.     (((t)&ERT_MEMMASK)? 1 << (((t)&ERT_MEMMASK)-1) : 0x80 )
  194.  
  195.  
  196.  
  197. /* convert a expansion slot number into a memory address */
  198. #define EC_MEMADDR(slot)        ((slot) << (E_SLOTSHIFT) )
  199.  
  200. /* a kludge to get the byte offset of a structure */
  201. #define EROFFSET(er)    ((int)&((struct ExpansionRom *)0)->er)
  202. #define ECOFFSET(ec)    \
  203.  (sizeof(struct ExpansionRom)+((int)&((struct ExpansionControl *)0)->ec))
  204.  
  205.  
  206.  
  207. /***************************************************************************
  208. **
  209. ** these are the specifications for the diagnostic area.  If the Diagnostic
  210. ** Address Valid bit is set in the Board Type byte (the first byte in
  211. ** expansion space) then the Diag Init vector contains a valid offset.
  212. **
  213. ** The Diag Init vector is actually a word offset from the base of the
  214. ** board.  The resulting address points to the base of the DiagArea
  215. ** structure.  The structure may be physically implemented either four,
  216. ** eight, or sixteen bits wide.  The code will be copied out into
  217. ** ram first before being called.
  218. **
  219. ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
  220. ** are offsets from the diag area AFTER it has been copied into ram, and
  221. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  222. ** the actual information, not how much address space is required to
  223. ** store it.)
  224. **
  225. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  226. ** is a logic one).
  227. **
  228. ** If your board is to make use of the boot facility then it must leave
  229. ** its config area available even after it has been configured.  Your
  230. ** boot vector will be called AFTER your board's final address has been
  231. ** set.
  232. **
  233. ****************************************************************************/
  234.  
  235. struct DiagArea {
  236.     UBYTE    da_Config;    /* see below for definitions */
  237.     UBYTE    da_Flags;    /* see below for definitions */
  238.     UWORD    da_Size;    /* the size (in bytes) of the total diag area */
  239.     UWORD    da_DiagPoint;    /* where to start for diagnostics, or zero */
  240.     UWORD    da_BootPoint;    /* where to start for booting */
  241.     UWORD    da_Name;    /* offset in diag area where a string */
  242.                 /*   identifier can be found (or zero if no */
  243.                 /*   identifier is present). */
  244.  
  245.     UWORD    da_Reserved01;    /* two words of reserved data.    must be zero. */
  246.     UWORD    da_Reserved02;
  247. };
  248.  
  249. /* da_Config definitions */
  250. /*
  251. ** DAC_BYTEWIDE can be simulated using DAC_NIBBLEWIDE.
  252. */
  253. #define DAC_BUSWIDTH    0xC0 /* two bits for bus width */
  254. #define DAC_NIBBLEWIDE    0x00
  255. #define DAC_BYTEWIDE    0x40 /* BUG: Will not work under V34 Kickstart! */
  256. #define DAC_WORDWIDE    0x80
  257.  
  258. #define DAC_BOOTTIME    0x30    /* two bits for when to boot */
  259. #define DAC_NEVER    0x00    /* obvious */
  260. #define DAC_CONFIGTIME    0x10    /* call da_BootPoint when first configing */
  261.                 /*   the device */
  262. #define DAC_BINDTIME    0x20    /* run when binding drivers to boards */
  263.  
  264. /*
  265. **
  266. ** These are the calling conventions for the diagnostic callback
  267. ** (from da_DiagPoint):
  268. **
  269. ** A7 -- points to at least 2K of stack
  270. ** A6 -- ExecBase
  271. ** A5 -- ExpansionBase
  272. ** A3 -- your board's ConfigDev structure
  273. ** A2 -- Base of diag/init area that was copied
  274. ** A0 -- Base of your board
  275. **
  276. ** Your board must return a value in D0.  If this value is NULL, then
  277. ** the diag/init area that was copied in will be returned to the free
  278. ** memory pool.
  279. */
  280.  
  281.  
  282. #endif /* LIBRARIES_CONFIGREGS_H */
  283.