home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / OB3.2D3.DMS / in.adf / Interfaces / Config.mod < prev    next >
Encoding:
Text File  |  1992-11-02  |  11.9 KB  |  317 lines

  1. (*-------------------------------------------------------------------------*)
  2. (*                                                                         *)
  3. (*  Amiga Oberon Interface Module:                    Date: 02-Nov-92      *)
  4. (*                                                                         *)
  5. (*   © 1992 by Fridtjof Siebert                                            *)
  6. (*                                                                         *)
  7. (*-------------------------------------------------------------------------*)
  8.  
  9. MODULE Config;  (* $Implementation- *)
  10.  
  11. IMPORT e * := Exec;
  12.  
  13. TYPE
  14.  
  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 00E80000H 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 (7DBH).  When inverted this will look like 0F824H.
  40. *)
  41.  
  42.   ExpansionRomPtr * = UNTRACED POINTER TO ExpansionRom;
  43.   ExpansionRom * = STRUCT      (* -First 16 bytes of the expansion ROM *)
  44.     type * : SHORTINT;         (* Board type, size and flags *)
  45.     product * : SHORTINT;      (* Product number, assigned by manufacturer *)
  46.     flags * : SHORTSET;        (* Flags *)
  47.     reserved03 * : SHORTINT;   (* Must be zero (0FFH inverted) *)
  48.     manufacturer * : INTEGER;  (* Unique ID,ASSIGNED BY COMMODORE-AMIGA! *)
  49.     serialNumber * : LONGINT;  (* Available for use by manufacturer *)
  50.     initDiagVec * : INTEGER;   (* Offset to optional "DiagArea" structure *)
  51.     reserved0c * : SHORTINT;
  52.     reserved0d * : SHORTINT;
  53.     reserved0e * : SHORTINT;
  54.     reserved0f * : SHORTINT;
  55.   END;
  56.  
  57.  
  58. (*
  59. ** Note that use of the ec_BaseAddress register is tricky.  The system
  60. ** will actually write twice.  First the low order nybble is written
  61. ** to the ec_BaseAddress register+2 (D15-D12).  Then the entire byte is
  62. ** written to ec_BaseAddress (D15-D8).  This allows writing of a byte-wide
  63. ** address to nybble size registers.
  64. *)
  65.  
  66.   ExpansionControlPtr * = UNTRACED POINTER TO ExpansionControl;
  67.   ExpansionControl * = STRUCT   (* -Second 16 bytes of the expansion ROM *)
  68.     interrupt  * : SHORTINT; (* Optional interrupt control register *)
  69.     z3HighBase * : SHORTINT; (* Zorro III   : Config address bits 24-31 *)
  70.     baseAddress* : SHORTINT; (* Zorro II/III: Config address bits 16-23 *)
  71.     shutup     * : SHORTINT; (* The system writes here to shut up a board *)
  72.     reserved14 * : SHORTINT;
  73.     reserved15 * : SHORTINT;
  74.     reserved16 * : SHORTINT;
  75.     reserved17 * : SHORTINT;
  76.     reserved18 * : SHORTINT;
  77.     reserved19 * : SHORTINT;
  78.     reserved1a * : SHORTINT;
  79.     reserved1b * : SHORTINT;
  80.     reserved1c * : SHORTINT;
  81.     reserved1d * : SHORTINT;
  82.     reserved1e * : SHORTINT;
  83.     reserved1f * : SHORTINT;
  84.   END;
  85.  
  86. (*
  87. ** many of the constants below consist of a triplet of equivalent
  88. ** definitions: xxMASK is a bit mask of those bits that matter.
  89. ** xxBIT is the starting bit number of the field.  xxSIZE is the
  90. ** number of bits that make up the definition.  This method is
  91. ** used when the field is larger than one bit.
  92. **
  93. ** If the field is only one bit wide then the xxB_xx and xxF_xx convention
  94. ** is used (xxB_xx is the bit number, and xxF_xx is mask of the bit).
  95. *)
  96.  
  97. CONST
  98.  
  99. (* manifest constants *)
  100.   slotSize    * = 10000H;
  101.   slotMask    * = 0FFFFH;
  102.   slotShift   * = 16;
  103.  
  104. (* these define the free regions of Zorro memory space.
  105. ** THESE MAY WELL CHANGE FOR FUTURE PRODUCTS!
  106. *)
  107.   eExpansionBase      * = 000E80000H;    (* Zorro II  config address *)
  108.   eZ3ExpansionBase    * = 0FF000000H;    (* Zorro III config address *)
  109.  
  110.   eExpansionSize      * = 000080000H;    (* Zorro II  I/O type cards *)
  111.   eExpansionSlots     * = 8;
  112.  
  113.   eMemoryBase         * = 000200000H;    (* Zorro II  8MB space *)
  114.   eMemorySize         * = 000800000H;
  115.   eMemorySlotrs       * = 128;
  116.  
  117.   eZ3ConfigArea       * = 040000000H;    (* Zorro III space *)
  118.   eZ3ConfigAreaEnd    * = 07FFFFFFFH;    (* Zorro III space *)
  119.   eZ3SizeGranularity  * = 000080000H;    (* 512K increments *)
  120.  
  121.  
  122.  
  123. (**** er_Type definitions (ttldcmmm) ***************************************)
  124.  
  125. (* er_Type board type bits -- the OS ignores "old style" boards *)
  126.   ertTypeMask         * = -64;   (* Bits 7-6 *)
  127.   ertTypeBit          * = 6;
  128.   ertTypeSize         * = 2;
  129.   ertNewBoard         * = -64;
  130.   ertZorroII          * = ertNewBoard;
  131.   ertZorroIII         * = -128;
  132.  
  133. (* other bits defined in er_Type *)
  134.   ertbMemList        * = 5;  (* Link RAM into free memory list *)
  135.   ertbDiagValid      * = 4;  (* ROM vector is valid *)
  136.   ertbChainedConfig  * = 3;  (* Next config is part of the same card *)
  137.  
  138.   ertfMemList        * = 20H;
  139.   ertfDiagValid      * = 10H;
  140.   ertfChainedConfig  * = 08H;
  141.  
  142. (* er_Type field memory size bits *)
  143.   ertMemMask         * = 07H;  (* Bits 2-0 *)
  144.   ertMemBit          * = 0;
  145.   ertMemSize         * = 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.   erffMemSpace       * = -128;   (* Wants to be in 8 meg space. *)
  152.   erfbMemSpace       * = 7;      (* (NOT IMPLEMENTED) *)
  153.  
  154.   erffNoShutUp       * = 64;     (* Board can't be shut up *)
  155.   erfbNOShutUP       * = 6;
  156.  
  157.   erffExtended       * = 32;     (* Zorro III: Use extended size table *)
  158.   erfbExtended       * = 5;      (*            for bits 0-2 of er_Type *)
  159.                                   (* Zorro II : Must be 0 *)
  160.  
  161.   erffZorroIII       * = 16;     (* Zorro III: must be 1 *)
  162.   erfbZorroIII       * = 4;      (* Zorro II : must be 0 *)
  163.  
  164.   ertZ3SSMask        * = 0FH;    (* Bits 3-0.  Zorro III Sub-Size.  How *)
  165.   ertZ3SSBit         * = 0;      (* much space the card actually uses   *)
  166.   ertZ3SSSize        * = 4;      (* (regardless of config granularity)  *)
  167.                                  (* Zorro II : must be 0        *)
  168.  
  169.  
  170. (* ec_Interrupt register (unused) ********************************************)
  171.   ecibINTENA         * = 1;
  172.   ecibRESET          * = 3;
  173.   ecibINT2PEND       * = 4;
  174.   ecibINT6PEND       * = 5;
  175.   ecibINT7PEND       * = 6;
  176.   ecibINTERRUPTING   * = 7;
  177.  
  178.   ecifINTENA         * = 2;
  179.   ecifRESET          * = 8;
  180.   ecifINT2PEND       * = 16;
  181.   ecifINT6PEND       * = 32;
  182.   ecifINT7PEND       * = 64;
  183.   ecifINTERRUPTING   * = -128;
  184.  
  185.  
  186.  
  187. (***************************************************************************
  188. **
  189. ** these are the specifications for the diagnostic area.  If the Diagnostic
  190. ** Address Valid bit is set in the Board Type byte (the first byte in
  191. ** expansion space) then the Diag Init vector contains a valid offset.
  192. **
  193. ** The Diag Init vector is actually a word offset from the base of the
  194. ** board.  The resulting address points to the base of the DiagArea
  195. ** structure.  The structure may be physically implemented either four,
  196. ** eight, or sixteen bits wide.  The code will be copied out into
  197. ** ram first before being called.
  198. **
  199. ** The da_Size field, and both code offsets (da_DiagPoint and da_BootPoint)
  200. ** are offsets from the diag area AFTER it has been copied into ram, and
  201. ** "de-nibbleized" (if needed).  (In other words, the size is the size of
  202. ** the actual information, not how much address space is required to
  203. ** store it.)
  204. **
  205. ** All bits are encoded with uninverted logic (e.g. 5 volts on the bus
  206. ** is a logic one).
  207. **
  208. ** If your board is to make use of the boot facility then it must leave
  209. ** its config area available even after it has been configured.  Your
  210. ** boot vector will be called AFTER your board's final address has been
  211. ** set.
  212. **
  213. ****************************************************************************)
  214.  
  215. TYPE
  216.  
  217.   DiagAreaPtr * = UNTRACED POINTER TO DiagArea;
  218.   DiagArea * = STRUCT
  219.     config * : e.BYTE;       (* see below for definitions *)
  220.     flags * : SHORTSET;      (* see below for definitions *)
  221.     size * : INTEGER;        (* the size (in bytes) of the total diag area *)
  222.     diagPoint * : INTEGER;   (* where to start for diagnostics, or zero *)
  223.     bootPoint * : INTEGER;   (* where to start for booting *)
  224.     name * : INTEGER;        (* offset in diag area where a string *)
  225.                              (*   identifier can be found (or zero if no *)
  226.                              (*   identifier is present). *)
  227.  
  228.     reserved01 * : INTEGER;  (* two words of reserved data.  must be zero. *)
  229.     reserved02 * : INTEGER;
  230.   END;
  231.  
  232. CONST
  233.  
  234. (* da_Config definitions *)
  235. (*
  236. ** dacBYTEWIDE can be simulated using dacNIBBLEWIDE.
  237. *)
  238.   dacBusWidth    * = 0C0X;    (* two bits for bus width *)
  239.   dacNibbleWide  * = 000X;
  240.   dacByteWide    * = 040X;    (* BUG: Will not work under V34 Kickstart! *)
  241.   dacWordWide    * = 080X;
  242.  
  243.   dacBootTime    * = 030X;    (* two bits for when to boot *)
  244.   dacNever       * = 000X;    (* obvious *)
  245.   dacConfigTime  * = 010X;    (* call da_BootPoint when first configing *)
  246.                               (*   the device *)
  247.   dacBindTime    * = 020X;    (* run when binding drivers to boards *)
  248.  
  249. (*
  250. **
  251. ** These are the calling conventions for the diagnostic callback
  252. ** (from da_DiagPoint):
  253. **
  254. ** A7 -- points to at least 2K of stack
  255. ** A6 -- ExecBase
  256. ** A5 -- ExpansionBase
  257. ** A3 -- your board's ConfigDev structure
  258. ** A2 -- Base of diag/init area that was copied
  259. ** A0 -- Base of your board
  260. **
  261. ** Your board must return a value in D0.  If this value is NULL, then
  262. ** the diag/init area that was copied in will be returned to the free
  263. ** memory pool.
  264. *)
  265.  
  266.  
  267. TYPE
  268.  
  269. (*
  270. ** At early system startup time, one ConfigDev structure is created for
  271. ** each board found in the system.  Software may seach for ConfigDev
  272. ** structures by vendor & product ID number.  For debugging and diagnostic
  273. ** use, the entire list can be accessed.  See the expansion.library document
  274. ** for more information.
  275. *)
  276.  
  277.   ConfigDevPtr * = UNTRACED POINTER TO ConfigDev;
  278.   ConfigDev * = STRUCT (node * : e.Node)
  279.     flags * : SHORTSET;      (* (read/write) *)
  280.     pad * : SHORTINT;        (* reserved *)
  281.     rom * : ExpansionRom;    (* copy of board's expansion ROM *)
  282.     boardAddr * : e.APTR;    (* where in memory the board was placed *)
  283.     boardSize * : LONGINT;   (* size of board in bytes *)
  284.     slotAddr * : INTEGER;    (* which slot number (PRIVATE) *)
  285.     slotSize * : INTEGER;    (* number of slots (PRIVATE) *)
  286.     driver * : e.APTR;       (* pointer to node of driver *)
  287.     nextCD * : ConfigDevPtr; (* linked list of drivers to config *)
  288.     unused * : ARRAY 4 OF LONGINT;   (* for whatever the driver wants *)
  289.  END;
  290.  
  291. CONST
  292.  
  293. (* cd_Flags *)
  294.   cdshutUp     * = 0;   (* this board has been shut up *)
  295.   cdconfigMe   * = 1;   (* this board needs a driver to claim it *)
  296.   cdBadMemory  * = 2;   (* this board contains bad memory *)
  297.  
  298. TYPE
  299.  
  300. (*
  301. ** Boards are usually "bound" to software drivers.
  302. ** This structure is used by GetCurrentBinding() and SetCurrentBinding()
  303. *)
  304.  
  305.   CurrentBindingPtr * = UNTRACED POINTER TO CurrentBinding;
  306.   CurrentBinding * = STRUCT
  307.     configDev * : ConfigDevPtr;       (* first configdev in chain *)
  308.     fileName * : e.STRPTR;            (* file name of driver *)
  309.     productString * : e.STRPTR;       (* product # string *)
  310.     toolTypes * : e.APTR;             (* tooltypes from disk object *)
  311.   END;
  312.  
  313.  
  314. END Config.
  315.  
  316.  
  317.