home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / oberon-a-1.4ß.lha / Oberon-A / source / amiga / Expansion.mod < prev    next >
Text File  |  1994-08-08  |  8KB  |  278 lines

  1. (***************************************************************************
  2.  
  3.      $RCSfile: Expansion.mod $
  4.   Description: Interface to expansion.library
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.2 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 00:57:27 $
  10.  
  11.   Includes Release 40.15
  12.  
  13.   (C) Copyright 1985-1993 Commodore-Amiga, Inc.
  14.       All Rights Reserved
  15.  
  16.   Oberon-A interface Copyright © 1994, Frank Copeland.
  17.   This file is part of the Oberon-A Interface.
  18.   See Oberon-A.doc for conditions of use and distribution.
  19.  
  20. ***************************************************************************)
  21.  
  22. MODULE Expansion;
  23.  
  24. (*
  25. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  26. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  27. ** $V- OvflChk       $Z- ZeroVars
  28. *)
  29.  
  30. IMPORT E := Exec, D := Dos, C := Config, SYS := SYSTEM;
  31.  
  32.  
  33. (*
  34. **      $VER: expansion.h 36.7 (28.5.90)
  35. **
  36. **      External definitions for expansion.library
  37. *)
  38.  
  39. CONST
  40.  
  41.   name *   = "expansion.library";
  42.  
  43. (* flags for the AddDosNode() call *)
  44.  
  45.   adnStartProc *  = 0;
  46.  
  47. (*
  48. **      $VER: expansionbase.h 36.15 (21.10.91)
  49. **
  50. **      Definitions for the expansion library base
  51. *)
  52.  
  53.  
  54. (* BootNodes are scanned by dos.library at startup.  Items found on the
  55.    list are started by dos. BootNodes are added with the AddDosNode() or
  56.    the V36 AddBootNode() calls. *)
  57.  
  58. TYPE
  59.  
  60.   BootNodePtr * = CPOINTER TO BootNode;
  61.   BootNode * = RECORD (E.Node)
  62.     flags *      : E.WSET;
  63.     deviceNode * : E.APTR;
  64.   END; (* BootNode *)
  65.  
  66.  
  67. (* expansion.library has functions to manipulate most of the information in
  68.    ExpansionBase.  Direct access is not permitted.  Use FindConfigDev()
  69.    to scan the board list. *)
  70.  
  71. TYPE
  72.  
  73.   ExpansionBasePtr * = CPOINTER TO ExpansionBase;
  74.   ExpansionBase * = RECORD (E.Library)
  75.     ebFlags -   : E.BSET;         (* read only (see below) *)
  76.     private01   : E.UBYTE;        (* private *)
  77.     private02   : E.ULONG;        (* private *)
  78.     private03   : E.ULONG;        (* private *)
  79.     private04   : C.CurrentBinding; (* private *)
  80.     private05   : E.List;         (* private *)
  81.     mountList * : E.List;         (* contains $truct BootNode entries *)
  82.     (* private *)
  83.   END; (* ExpansionBase *)
  84.  
  85. CONST
  86.  
  87. (* error codes *)
  88.   eeOk *           = 0;
  89.   eeLastBoard *    = 40;  (* could not shut him up *)
  90.   eeNoExpansion *  = 41;  (* not enough expansion mem; board shut up *)
  91.   eeNoMemory *     = 42;  (* not enough normal memory *)
  92.   eeNoBoard *      = 43;  (* no board at that address *)
  93.   eeBadMem *       = 44;  (* tried to add bad memory card *)
  94.  
  95. (* Flags *)
  96.  
  97.   ebClogged *     = 0;       (* someone could not be shutup *)
  98.   ebShortMem *    = 1;       (* ran out of expansion mem *)
  99.   ebBadMem *      = 2;       (* tried to add bad memory card *)
  100.   ebDosFlag *     = 3;       (* reserved for use by AmigaDOS *)
  101.   ebKickBack33 *  = 4;       (* reserved for use by AmigaDOS *)
  102.   ebKickBack36 *  = 5;       (* reserved for use by AmigaDOS *)
  103.  
  104. (* If the following flag is set by a floppy's bootblock code, the initial
  105.    open of the initial shell window will be delayed until the first output
  106.    to that shell.  Otherwise the 1.3 compatible behavior applies. *)
  107.  
  108.   ebSilentStart * = 6;
  109.  
  110. (* Magic kludge for CC0 use *)
  111.   ebStartCC0 * = 7;
  112.  
  113. (**-- Library Base variable --------------------------------------------*)
  114.  
  115. VAR
  116.  
  117.   base *  : ExpansionBasePtr;
  118.  
  119.  
  120. (**-- Library Functions ------------------------------------------------*)
  121.  
  122. (*
  123. **      $VER: expansion_protos.h 39.0 (31.10.91)
  124. *)
  125.  
  126. (* --- functions in V33 or higher (distributed as Release 1.2) ---*)
  127.  
  128. LIBCALL (base : ExpansionBasePtr) AddConfigDev*
  129.   ( configDev [8] : C.ConfigDevPtr );
  130.   -30;
  131.  
  132. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  133.  
  134. LIBCALL (base : ExpansionBasePtr) AddBootNode*
  135.   ( bootPri    [0] : LONGINT;
  136.     flags      [1] : SET;
  137.     deviceNode [8] : D.DeviceNodePtr;
  138.     configDev  [9] : C.ConfigDevPtr )
  139.   : BOOLEAN;
  140.   -36;
  141.  
  142. (* --- functions in V33 or higher (distributed as Release 1.2) ---*)
  143.  
  144. LIBCALL (base : ExpansionBasePtr) AllocBoardMem*
  145.   ( slotSpec [0] : E.ULONG );
  146.   -42;
  147. LIBCALL (base : ExpansionBasePtr) AllocConfigDev* ()
  148.   : C.ConfigDevPtr;
  149.   -48;
  150. LIBCALL (base : ExpansionBasePtr) AllocExpansionMem*
  151.   ( numSlots  [0] : E.ULONG;
  152.     slotAlign [1] : E.ULONG )
  153.   : E.APTR;
  154.   -54;
  155. LIBCALL (base : ExpansionBasePtr) ConfigBoard*
  156.   ( board     [8] : E.APTR;
  157.     configDev [9] : C.ConfigDevPtr );
  158.   -60;
  159. LIBCALL (base : ExpansionBasePtr) ConfigChain*
  160.   ( baseAddr [8] : E.APTR );
  161.   -66;
  162. LIBCALL (base : ExpansionBasePtr) FindConfigDev*
  163.   ( oldConfigDev [8] : C.ConfigDevPtr;
  164.     manufacturer [0] : LONGINT;
  165.     product      [1] : LONGINT )
  166.   : C.ConfigDevPtr;
  167.   -72;
  168. LIBCALL (base : ExpansionBasePtr) FreeBoardMem*
  169.   ( startSlot [0] : E.ULONG;
  170.     slotSpec  [1] : E.ULONG );
  171.   -78;
  172. LIBCALL (base : ExpansionBasePtr) FreeConfigDev*
  173.   ( configDev [8] : C.ConfigDevPtr );
  174.   -84;
  175. LIBCALL (base : ExpansionBasePtr) FreeExpansionMem*
  176.   ( startSlot [0] : E.ULONG;
  177.     numSlots  [1] : E.ULONG );
  178.   -90;
  179. LIBCALL (base : ExpansionBasePtr) ReadExpansionByte*
  180.   ( board  [8] : E.APTR;
  181.     offset [0] : E.ULONG )
  182.   : E.UBYTE;
  183.   -96;
  184. LIBCALL (base : ExpansionBasePtr) ReadExpansionRom*
  185.   ( board     [8] : E.APTR;
  186.     configDev [9] : C.ConfigDevPtr );
  187.   -102;
  188. LIBCALL (base : ExpansionBasePtr) RemConfigDev*
  189.   ( configDev [8] : C.ConfigDevPtr );
  190.   -108;
  191. LIBCALL (base : ExpansionBasePtr) WriteExpansionByte*
  192.   ( board  [8] : E.APTR;
  193.     offset [0] : E.ULONG;
  194.     byte   [1] : E.UBYTE );
  195.   -114;
  196. LIBCALL (base : ExpansionBasePtr) ObtainConfigBinding* ();
  197.   -120;
  198. LIBCALL (base : ExpansionBasePtr) ReleaseConfigBinding* ();
  199.   -126;
  200. LIBCALL (base : ExpansionBasePtr) SetCurrentBinding*
  201.   ( currentBinding [8] : C.CurrentBindingPtr;
  202.     bindingSize    [0] : E.UWORD );
  203.   -132;
  204. LIBCALL (base : ExpansionBasePtr) GetCurrentBinding*
  205.   ( currentBinding [8] : C.CurrentBindingPtr;
  206.     bindingSize    [0] : E.UWORD )
  207.   : E.ULONG;
  208.   -138;
  209. LIBCALL (base : ExpansionBasePtr) MakeDosNode*
  210.   ( parmPacket [8] : E.APTR )
  211.   : D.DeviceNodePtr;
  212.   -144;
  213. LIBCALL (base : ExpansionBasePtr) AddDosNode*
  214.   ( bootPri    [0] : LONGINT;
  215.     flags      [1] : SET;
  216.     deviceNode [8] : D.DeviceNodePtr )
  217.   : BOOLEAN;
  218.   -150;
  219.  
  220. (* --- functions in V36 or higher (distributed as Release 2.0) ---*)
  221.  
  222.  
  223. (**-- C Macros defined as procedures -----------------------------------*)
  224. (** $L+ Absolute long addressing for globals *)
  225.  
  226.  
  227. (*
  228. (* figure out amount of memory needed by this box/board *)
  229. define ertMEMNEEDED(t)        \
  230.         (((t)&ErtMEMMASK)? 10000H << (((t)&ErtMEMMASK) -1) : 800000H )
  231.  
  232. (* same as ertMEMNEEDED, but return number of slots *)
  233. define ertSLOTSNEEDED(t)      \
  234.         (((t)&ErtMEMMASK)? 1 << (((t)&ErtMEMMASK)-1) : 80H )
  235.  
  236.  
  237.  
  238. (* convert a expansion slot number into a memory address *)
  239. define ecMEMADDR(slot)                ((slot) << (ESLOTSHIFT) )
  240.  
  241. (* a kludge to get the byte offset of a $tructure *)
  242. define EROFFSET(er)    ((int)&(($truct ExpansionRom * )0)->er)
  243. define ECOFFSET(ec)    \
  244.  (sizeof($truct ExpansionRom)+((int)&(($truct ExpansionControl * )0)->ec))
  245. *)
  246.  
  247.  
  248. (**-- Library Base variable --------------------------------------------*)
  249. (** $L- Address globals through A4 *)
  250.  
  251.  
  252. (**-----------------------------------*)
  253. PROCEDURE* CloseLib ();
  254.  
  255. BEGIN (* CloseLib *)
  256.   IF base # NIL THEN E.base.CloseLibrary (base) END
  257. END CloseLib;
  258.  
  259. (**-----------------------------------*)
  260. PROCEDURE OpenLib * (mustOpen : BOOLEAN);
  261.  
  262. BEGIN (* OpenLib *)
  263.   IF base = NIL THEN
  264.     base :=
  265.       SYS.VAL
  266.         ( ExpansionBasePtr,
  267.           E.base.OpenLibrary (name, E.libraryMinimum) );
  268.     IF base # NIL THEN SYS.SETCLEANUP (CloseLib)
  269.     ELSIF mustOpen THEN HALT (100)
  270.     END;
  271.   END;
  272. END OpenLib;
  273.  
  274.  
  275. BEGIN
  276.   base := NIL
  277. END Expansion.
  278.