sysglobals.imp
上传用户:upcnvip
上传日期:2007-01-06
资源大小:474k
文件大小:13k
源码类别:

编译器/解释器

开发平台:

C/C++

  1. {IncludeFrom=sysglobals <p2c/sysglobals.h>}
  2. {*VarStrings=1} {*ExportSymbol=}
  3. module sysglobals;  
  4. export 
  5. type fsidctype = packed array[1..20] of char; 
  6. const 
  7.   fsidc = fsidctype['Rev.  3.1  18-Jul-85'];   
  8.                              (*20 CHARS: VERSION,DATE,TIME OF FILE SYS*)
  9.   mminint = -32768;          (*MINIMUM SHORT INTEGER VALUE*)
  10.   mmaxint =  32767;          (*MAXIMUM SHORT INTEGER VALUE*)
  11.   maxunit = 50;              (*MAXIMUM PHYSICAL UNIT NUMBER*)
  12.   passleng = 16;             (*NUMBER OF CHARS IN A PASSWORD*)
  13.   vidleng = 16;              (*NUMBER OF CHARS IN A VOLUME NAME*)
  14.   tidleng = 16;              (*NUMBER OF CHARS IN A FILE TITLE*)
  15.   fidleng = 120;             (*NUMBER OF CHARS IN FILE NAME*)
  16.   fblksize = 512;            (*STANDARD FILE BUFFER LENGTH*)
  17.   maxsc=63;                  (*LARGEST SELECT CODE *)
  18.   minlevel=1;                (*LOWEST INTERRUPT LEVEL*)
  19.   maxlevel=6;                (*LARGEST MASKABLE INTERRUPT LEVEL*)
  20.       
  21.   
  22. type  
  23.   byte = 0..255; 
  24.   shortint = mminint..mmaxint;  
  25.   ipointer = ^integer;
  26.   charptr = ^char;
  27.   textpntr = ^text; 
  28.   string80 = string[80];
  29.   string255 = string[255];
  30.   suffixtype = string[5];
  31.   string255ptr = ^string255; 
  32.                                                               
  33.   unitnum = 0..maxunit; 
  34.   vid = string[vidleng]; 
  35.   tid = string[tidleng];
  36.   fid = string[fidleng];
  37.   passtype = string[passleng];
  38.   filekind = (untypedfile,      {directory entry} 
  39.               badfile,          {bad blocks}
  40.               codefile,         {executable or linkable}
  41.               textfile,         {UCSD format text with editor environment}
  42.               asciifile,        {L.I.F. ASCII format text strings}
  43.               datafile,         {file of  <data type, e.g. char, integer,etc.>}
  44.               sysfile,          {system (BOOT) file}
  45.      fkind7,  fkind8,  fkind9,  
  46.      fkind10, fkind11, fkind12, 
  47.      fkind13, fkind14, lastfkind);      {reserved for future expansion}
  48.   
  49.                                                            (*FILE INFORMATION*)
  50. window = packed array [0..maxint] of char;
  51. windowp = ^window;
  52. fibp = ^fib;
  53. amrequesttype = (readbytes, writebytes, flush, writeeol, readtoeol, clearunit, 
  54.           setcursor, getcursor, startread, startwrite, unitstatus, seekeof); 
  55. amtype = procedure (fp: fibp; request: amrequesttype; 
  56.                            anyvar buffer: window; bufsize, position: integer); 
  57. eotproc = procedure(fp: fibp); 
  58. fib = packed record 
  59.            fwindow: windowp;                         (*BUFFER VARIABLE...F^ *)
  60.            flistptr: fibp;                            (* LIST OF OPEN FILES *)
  61.        {declaration and type information}
  62.            frecsize: integer;                 (* SIZE OF ONE LOGICAL RECORD *)
  63.            feft: shortint;                            (* EXTERNAL FILE TYPE *)
  64.            fkind: filekind;                                    (* FILE KIND *)
  65.            fistextvar:  boolean;                  (* FILE IS LINE FORMATTED *)
  66.            fbuffered:   boolean;               (* HAS 512 BYTE BLOCK BUFFER *)
  67.            fanonymous: boolean;                         (* FILE HAS NO NAME *)
  68.            fisnew:  boolean;                (* WAS CREATED THIS ASSOCIATION *)
  69.            freadable, fwriteable: boolean;            (* FILE ACCESS RIGHTS *)
  70.        {state information}
  71.            freadmode, fbufvalid: boolean;         (*F^ AND LOOKAHEAD STATES *)
  72.            feoln: boolean;                          (* F^ IS AN END OF LINE *) 
  73.            feof: boolean;                 (* TRIED TO READ PAST END OF FILE *)
  74.            fmodified: boolean;                     (* FILE HAS CHANGED SIZE *)
  75.            fbufchanged: boolean;              (* BUFFER NEEDS TO BE WRITTEN *)
  76.        {file size and position}
  77.            fpos:  integer;           (* FILE POINTER, CURRENT FILE POSITION *)
  78.            fleof: integer;         (*LOGICAL END OF FILE, CURRENT FILE SIZE *)
  79.            fpeof: integer;        (*PHYSICAL END OF FILE, MAXIMUM FILE SIZE *)
  80.        {buffering and low level formatting information}
  81.            flastpos:  integer;                   (* FILE POSITION OF BUFFER *)
  82.            freptcnt:  shortint;                  (* SPACE COMPRESSION COUNT *)
  83.            am:  amtype;                              (*BUFFER METHOD MODULE *)
  84.        {file association info}
  85.            fstartaddress: integer;         (*EXECUTION ADDRESS IN BOOT FILE *)
  86.            fvid: vid;                                        (* VOLUME NAME *)
  87.            ffpw: passtype;                                 (* FILE PASSWORD *)
  88.            ftid: tid;                                          (* FILE NAME *)
  89.            pathid:  integer;     (* ADDITIONAL SYSTEM DEPENDENT INFORMATION *)
  90.            fanonctr: shortint;                      (* TEMP FILE IDENTIFIER *)
  91.            foptstring: string255ptr;               (* OPTIONAL STRING PARAM *)
  92.        {byte block transfer information}
  93.            fileid:  integer; (* START BYTE OF FILE, OR OTHER IDENTIFICATION *)
  94.            fb0,fb1,                                 (* FOR FUTURE EXPANSION *)
  95.            fnosrmtemp,                   (*TRUE IF NO SRM TEMP FILE CREATED *)
  96.            fwaitonlock,                  (*TRUE IF SRM SHOULD WAIT FOR LOCK *)
  97.            fpurgeoldlink,            (*TRUE IF OLD SRM LINK IS TO BE PURGED *)
  98.            foverwritten,                    (*TRUE IF OPENED WITH OVERWRITE *)
  99.            fsavepathid,               (*TRUE IF PATHID NOT UNIQUE TO FILEID *)
  100.            flockable,                     (*TRUE IF FILE OPENED AS LOCKABLE *)
  101.            flocked,                                (*TRUE IF FILE IS LOCKED *)
  102.            fbusy        : boolean;               (*TRUE IF DRIVER IS ACTIVE *)
  103.            funit        : unitnum;                   (*PHYSICAL UNIT NUMBER *)
  104.            feot         : eotproc;         (*CALLED WHEN TRANSFER COMPLETES *)
  105.            fxpos        : integer;                (* X POSITION FOR  GOTOXY *)
  106.            fypos        : integer;                (* Y POSITION FOR  GOTOXY *)
  107.            foldfileid   : integer;    (* FILEID FOR OLD SRM FILE ON REWRITE *)
  108.        {for future expansion}
  109.            fextra:  array[0..2] of integer;
  110.            fextra2: shortint;
  111.        {large miscellaneous fields sometimes present}
  112.            case integer of 
  113.              0: ( {minimal FIB ends here} );
  114.              1: (ftitle:  fid);        (* FILE NAME, EXCEPT VOLUME AND SIZE *)
  115.              2: (fbuffer: packed array [0..fblksize-1] of char); 
  116.         end (*FIB*) ;
  117. damrequesttype = (getvolumename, setvolumename, getvolumedate, setvolumedate,  
  118.  changename, purgename, 
  119.  openfile, createfile, overwritefile, closefile, purgefile,
  120.  stretchit, makedirectory, crunch, opendirectory, closedirectory, catalog,
  121.  stripname, setunitprefix, openvolume, duplicatelink, openparentdir,
  122.  catpasswords,setpasswords,lockfile,unlockfile,openunit); 
  123.   
  124. damtype = procedure (anyvar f: fib; unum:unitnum; request: damrequesttype); 
  125.   
  126. unitentry =  {unitable entry definition}
  127.     packed record
  128.       dam: damtype;                     {directory access method}
  129.       tm:  amtype;                      {byte block transfer method}
  130.       sc: byte;                         {select code}
  131.       ba: byte;                         {bus address} 
  132.       du: byte;                         {disc unit}  
  133.       dv: byte;                         {disc volume}
  134.       byteoffset: integer;              {physical starting byte of volume} 
  135.       devid: integer;                   {identifier (Amigo identify sequence)} 
  136.       uvid: vid;                        {volume id}
  137.       dvrtemp: integer;                 {temp for driver use only; init to 0!}
  138.       dvrtemp2: shortint;               {temp for driver use only; init to 0!}
  139.       letter: char;                     {device specifier letter}
  140.       offline,                          {unit absent or down flag}
  141.       uisinteractive,                   {user can edit input}
  142.       umediavalid,                      {medium not changed since last access}
  143.       uuppercase:   boolean;            {volume name must be uppercased}
  144.       uisfixed: boolean;                {fixed/removeable media flag}
  145.       ureportchange: boolean;           {driver mode: report/ignore media change}
  146.       pad: 0..1;                        {   (bit not used yet)  }
  147.       case uisblkd: boolean of          {blocked volume flag}
  148.         true: (umaxbytes: integer)      {volume size in bytes }
  149.     end;  {unitentry}
  150.     
  151. unitabletype = array [unitnum] of unitentry;                   (*0 NOT USED*)
  152. amtabletype  = array[filekind] of amtype; 
  153. suftabletype = array[filekind] of suffixtype; 
  154. efttabletype = array[filekind] of shortint; 
  155. unitableptr     = ^unitabletype;
  156. amtableptrtype  = ^amtabletype; 
  157. suftableptrtype = ^suftabletype; 
  158. efttableptrtype = ^efttabletype; 
  159.   
  160.   
  161. iorsltwd = 
  162.             { *note* the ioresult enumerations have been partitioned into two
  163.               mutually-exclusive groups: those beginning with 'z' are reserved
  164.               for the low-level drivers , and those beginning
  165.               with 'i' are reserved for the higher-level routines.}
  166.              
  167.              (inoerror,zbadblock,ibadunit,zbadmode,ztimeout,
  168.               ilostunit,ilostfile,ibadtitle,inoroom,inounit,
  169.               inofile,idupfile,inotclosed,inotopen,ibadformat,
  170.               znosuchblk,znodevice,zinitfail,zprotected,
  171.               zstrangei,zbadhardware,zcatchall,zbaddma,
  172.               inotvalidsize,inotreadable,inotwriteable,inotdirect,
  173.               idirfull,istrovfl,ibadclose,ieof,
  174.               zuninitialized,znoblock,znotready,znomedium,
  175.               inodirectory,ibadfiletype,ibadvalue,icantstretch,
  176.               ibadrequest, inotlockable, ifilelocked, ifileunlocked, 
  177.               idirnotempty, itoomanyopen, inoaccess, ibadpass, ifilenotdir, 
  178.               inotondir, ineedtempdir, isrmcatchall, zmediumchanged,
  179.               {end marker} endioerrs);
  180.   
  181. proctype=procedure;
  182. sctype=0..maxsc;
  183. leveltype=minlevel..maxlevel;
  184. pisrib = ^isrib;
  185. isrproctype = procedure(isribptr: pisrib);
  186. isrib = {isr information block}
  187.    packed record
  188.      intregaddr: charptr;       {interrupt register address}
  189.      intregmask: byte;          {interrupt register mask}
  190.      intregvalue: byte;         {interrupt register target value after masking}
  191.      chainflag: boolean;        {chaining flag}
  192.      proc: isrproctype;         {isr}
  193.      link: pisrib;              {pointer to next isrib in linked list}
  194.    end;
  195.  
  196. inttabletype = array [1..7] of pisrib;
  197. action = procedure; 
  198. daterec         = packed record
  199.                     year        : 0..100;       (*100 IS TEMP DISK FLAG*)
  200.                     day         : 0..31;        (*DAY OF MONTH*)
  201.                     month       : 0..12;        (*0 ==> DATE NOT MEANINGFUL*)
  202.                   end; 
  203. timerec         = packed record
  204.                     hour        : 0..23;
  205.                     minute      : 0..59;
  206.                     centisecond : 0..5999;
  207.                   end; 
  208.   
  209. datetimerec     = packed record
  210.                     date        : daterec;
  211.                     time        : timerec;
  212.                   end;
  213. var
  214. (*========= MANY OF THE FOLLOWING HAVE HARDCODED
  215.             ADDRESSES IN COMPILER AND ELSEWHERE  =====*)
  216.        
  217. (*** ERROR RECOVERY  ***)
  218.   sysescapecode:        shortint; 
  219.   openfileptr:  anyptr; 
  220.   recoverblock: anyptr; 
  221.   
  222. (*** MEMORY MANAGEMENT ***)
  223.   heapmax:      anyptr; 
  224.   heapbase:     anyptr; 
  225.   
  226. (*** I/O DRIVERS ***)
  227.   sysioresult:          integer; 
  228.   hardwarestatus:       integer;
  229.   locklevel:      integer; 
  230.   unitable: unitableptr;
  231.   interrupttable: inttabletype;
  232.   endisrhook:  integer;
  233.   actionspending: integer; 
  234.   
  235. (*** FILE SYSTEM ***)
  236.   gfiles: array[0..5] of textpntr;    
  237.   {  [0] INPUT          [3] (unused)
  238.      [1] OUTPUT         [4] LISTING 
  239.      [2] KEYBOARD       [5] (unused)   }
  240.   
  241.   amtable:     amtableptrtype;                  {pointer to access methods }
  242.   suffixtable: suftableptrtype;                 {pointer to list of suffixes}
  243.   efttable:    efttableptrtype;                 {pointer to LIF file types}
  244.   sysunit: integer;
  245.   syvid,dkvid: vid;                           (*SYSUNIT VOLID & DEFAULT VOLID*)
  246.   syslibrary: fid; 
  247.   
  248.   (*** DEBUGGER HOOK ***)
  249.   debugger: procedure(p1, p2, p3: integer); 
  250.   
  251.   (*** CLEAR I/O HOOK ***)
  252.   cleariohook : procedure;    
  253.   
  254.   perminttable: inttabletype;
  255.   
  256.   deferredaction: array[1..10] of action; 
  257.   
  258.   serialtextamhook: amtype;             {access method for serial devices}
  259.   
  260.   sysname[-574]: packed array[1..10] of char; 
  261.   
  262.   sysflag[-302]: packed record
  263.     reserved1, reserved2, nointhpib, crtconfigreg, 
  264.     nokeyboard, highlightsxorbiggraphics, biggraphics,
  265.     alpha50: boolean; 
  266.     end; 
  267.   sysflag2[hex('FFFFFEDA')]: packed record    {extend to 8 digits SFB 4/26/85}
  268.                              pad7to1    : 0..127;
  269.                              prompresent: boolean;
  270.                            end;
  271.                            
  272.   endsysvars : shortint;   {must be last thing
  273.                             in SYSGLOBALS}
  274.   
  275. end.