$page "MPE Caching Global Defines"                                      00001000
<<************************************************************>>        00002000
<<************ MPE Caching Global Defines ********************>>        00003000
<<************************************************************>>        00004000
                                                                        00005000
<< File INCLSF (System Failures) is required to complete      >>        00006000
<< these defines.                                             >>        00007000
                                                                        00008000
<< SYSGLOB cells >>                                                     00009000
define CACHE'DST     = absolute(%1273)#,<< Cache DST number   >>        00010000
       CACHE'DST'BANK= absolute(%1274)#,<< Cache DST bank #   >>        00011000
       CACHE'DST'OFST= absolute(%1275)#;<< Cache DST bk offset>>        00012000
                                                                        00013000
<< Memory management page size (in words) >>                            00014000
equate MMPAGESIZE = 128;   <<256>> <<512>>                              00015000
                                                                        00016000
<< These are the default minimum fetch size used >>                     00016100
<< for access methods (reads) when caching is    >>                     00016200
<< first enabled on the system.  The value is the>>                     00016300
<< the number of sectors to fetch.               >>                     00016310
equate CACHE'SEQUENTIAL = 96,  << 24K bytes >>                          00016400
       CACHE'RANDOM     = 16;  <<  4K bytes >>                          00016500
                                                                        00016600
<< This array is used to access the CDT with DB pointing to it.  >>     00017000
integer array CDT'ARRAY(*) = DB + 0;                                    00018000
                                                                        00019000
<< This integer will be used wherever CACHING routines access the>>     00020000
<< index register explicitly.                                    >>     00021000
integer CDT'X = X;                                                      00022000
                                                                        00023000
equate CDT'ENTRY'SIZE     = 24;    << CDT Entries are 24 words max>>    00024000
                                                                        00025000
<<************ Cache DST Equates and Defines *****************>>        00026000
                                                                        00027000
<< DST Header Entry >>                                                  00028000
equate CDT'ENTRIES    = 0,                        <<Entries in table  >>00029000
       CDT'SIZE       = CDT'ENTRIES + 1,          <<Entry size        >>00030000
       CDT'FREE'COUNT = CDT'SIZE + 1,             <<# free entries    >>00031000
       CDT'FREE'HEAD  = CDT'FREE'COUNT + 1,       <<First free entry  >>00032000
       CDT'FREE'TAIL  = CDT'FREE'HEAD + 1,        <<Last free entry   >>00033000
       CDT'MAX'USED   = CDT'FREE'TAIL + 1,        <<Max entries used  >>00034000
       CDT'NUM'LDEVS  = CDT'MAX'USED + 1,         <<Num LDEVs cached  >>00035000
       CDT'DISC'HEAD  = CDT'NUM'LDEVS + 1,        <<First cached LDEV >>00036000
       CDT'DST'WORDS  = CDT'DISC'HEAD + 1,        <<Number of DST wds >>00037000
       CDT'STOP'PND   = CDT'DST'WORDS + 1,        <<TRUE if stopcache >>00037100
       CDT'SEQ'MINFTCH= CDT'STOP'PND + 1,         <<# sectors seq ftch>>00037200
       CDT'RND'MINFTCH= CDT'SEQ'MINFTCH + 1,      <<# secs random ftch>>00037300
       CDT'FORCE'POST = CDT'RND'MINFTCH + 1,      <<TRUE-wait wrt comp>>00037400
       CDT'STOP'QUEUE = CDT'FORCE'POST + 1,       <<Head PIN on impede>>00037500
       CDT'END        = CDT'STOP'QUEUE + 1;       <<Len of entry      >>00038000
                                                                        00039000
<< Cached Disc Device Entry >>                                          00040000
equate CDT'DE'NEXT'LDEV = 0,                      <<Next cached LDEV  >>00041000
       CDT'DE'PREV'LDEV = CDT'DE'NEXT'LDEV+ 1,    <<Prev cached LDEV  >>00042000
       CDT'DE'LDEV = CDT'DE'PREV'LDEV + 1,        <<LDEV of disc      >>00043000
       CDT'DE'MAPD'PAGES= CDT'DE'LDEV     + 1,    <<Number of main mem>>00047000
                                                  <<pages now alloc.  >>00048000
       CDT'DE'MAPD'CNT  = CDT'DE'MAPD'PAGES+1,    <<# mapped CDTs     >>00049000
       CDT'DE'MAPD'HEAD = CDT'DE'MAPD'CNT + 1,    <<Hd mapped CDT     >>00050000
       CDT'DE'MAPD'TAIL = CDT'DE'MAPD'HEAD + 1,   <<Tail mapped CDT   >>00051000
       CDT'DE'REG'HD    = CDT'DE'MAPD'TAIL + 1,   <<Double abs reg hd >>00052000
       CDT'DE'REG'TL    = CDT'DE'REG'HD +2,       <<Double abs reg tl >>00053000
       CDT'DE'REGIONS   = CDT'DE'REG'TL + 2,      <<# of regions      >>00054000
       CDT'DE'RHIT      = CDT'DE'REGIONS + 1,     <<Cache read HIT cnt>>00055000
       CDT'DE'WHIT      = CDT'DE'RHIT + 2,        <<Cache wrt HIT coun>>00055100
       CDT'DE'RMISS     = CDT'DE'WHIT + 2,        <<Cache read misses >>00056000
       CDT'DE'WMISS     = CDT'DE'RMISS + 2,       <<Cache write misses>>00056100
       CDT'DE'STOP      = CDT'DE'WMISS + 2,       <<Cache I/O blocks  >>00056110
       CDT'DE'SCANPT    = CDT'DE'STOP   + 2,      <<Last ref domain pt>>00056200
       CDT'DE'END       = CDT'DE'SCANPT    + 2;   <<Entry length      >>00057000
                                                                        00058000
<< Mapped Disc Domain Entry >>                                          00059000
equate CDT'MD'PREV      = 0,                      <<Prev mapd CDT dom.>>00060000
       CDT'MD'NEXT      = CDT'MD'PREV + 1,        <<Next mapd CDT dom.>>00061000
       CDT'MD'SECTOR    = CDT'MD'NEXT + 1,        <<Sector base       >>00062000
       CDT'MD'END'SECTOR= CDT'MD'SECTOR + 2,      <<Sector limit      >>00063000
       CDT'MD'FLAGS     = CDT'MD'END'SECTOR + 2,  <<Misc flag bits    >>00064000
       CDT'MD'READ'CNT  = CDT'MD'FLAGS + 1,       <<# DISCREQ reading >>00065000
       CDT'MD'WRITE'CNT = CDT'MD'READ'CNT + 1,    <<# DISCREQ writing >>00066000
       CDT'MD'LKD'CDT   = CDT'MD'WRITE'CNT + 1,   <<CDT locked waiting>>00067000
       CDT'MD'IMPED'HD  = CDT'MD'LKD'CDT + 1,     <<Head LDR waited   >>00068000
       CDT'MD'LDR'HEAD  = CDT'MD'IMPED'HD + 1,    <<Head LDR active   >>00069000
       CDT'MD'MEM'ADDR  = CDT'MD'LDR'HEAD + 1,    <<Abs addr of region>>00070000
                                                  <<if present        >>00071000
       CDT'MD'DISCREQ   = CDT'MD'MEM'ADDR + 2,    <<Spare disc req    >>00072000
       CDT'MD'LK'CNT    = CDT'MD'DISCREQ + 1,     <<# of flushing CDTs>>00073000
       CDT'MD'LDEV      = CDT'MD'LK'CNT  + 1,     <<Domain's LDEV     >>00074000
       CDT'MD'IMPEDED   = CDT'MD'LDEV + 1,        <<Head impeded PIN  >>00074100
       CDT'MD'END       = CDT'MD'IMPEDED + 1;     <<Entry length      >>00075000
                                                                        00076000
<< Equates for CDT'MD'STATE - all possible 'states' a CDT can be in   >>00077000
equate CDT'AVAIL'STATE = 0, <<Available, no LDRs attached             >>00078000
       CDT'READ'STATE  = 1, <<Only read LDRs are attached             >>00079000
       CDT'WRITE'STATE = 2, <<Write and read LDRs are attached        >>00080000
       CDT'FLUSH'STATE = 3, <<All LDRs must be completed: purge CDT   >>00081000
       CDT'LOCK'STATE  = 4; <<CDT locked, awaiting other CDT flush(es)>>00082000
                                                                        00083000
<< Add equates for bit positions in CDT'MD'FLAGS word   >>              00084000
equate CDT'ABS'BIT         = 0,  << Absent bit          >>              00085000
       CDT'IMI'BIT         = 1,  << In-motion in        >>              00086000
       CDT'IMO'BIT         = 2,  << In-motion out ???   >>              00087000
       CDT'MISS'BIT        = 3,  << Miss on cache       >>              00088000
       CDT'LOCKED'BIT      = 4,  << Locked bit set      >>              00089000
       CDT'FWIP'BIT        = 5,  << Forced-write in prog>>              00090000
       CDT'ROC'BIT         = 6,  << Rec. overlay canidat>>              00091000
       CDT'VIRGIN'BIT      = 7,  << Region is virgin    >>              00092000
       CDT'WAIT'ON'NOPOST  = 8,  << Waiting on NOPOST wt>>              00093000
       CDT'SEQ'BIT         = 9,  << SEQ access to CDT   >>              00093100
       CDT'STATE'BITS      =13;  << (13:3) - state bits >>              00094000
                                                                        00095000
<< Defines for bits in FLAGS word of a mapped CDT entry >>              00096000
define CDT'ABSENT     = (CDT'ABS'BIT:1)#, <<Region is absent        >>  00097000
       CDT'IMI        = (CDT'IMI'BIT:1)#, <<In-motion in            >>  00098000
       CDT'IMO        = (CDT'IMO'BIT:1)#, <<ASK JOHN B!!!!!!        >>  00099000
       CDT'LOCKREQ'PND= (CDT'LKREQ'BIT:1)#, <<Lock request pending  >>  00100000
       CDT'LOCKED     = (CDT'LOCKED'BIT:1)#, <<Entry is locked      >>  00101000
       CDT'FWIP       = (CDT'FWIP'BIT:1)#, <<Forced write in-prog.  >>  00102000
       CDT'ROC        = (CDT'ROC'BIT:1)#, <<Recoverable overlay can.>>  00103000
       CDT'VIRGIN     = (CDT'VIRGIN'BIT:1)#,<<Region is VIRGIN      >>  00104000
       CDT'NOPOST     = (CDT'WAIT'ON'NOPOST:1)#,<<Wait NOPOST compl.>>  00105000
       CDT'MD'STATE   = (CDT'STATE'BITS:3)#;<<CDT state bits        >>  00106000
                                                                        00107000
<< Check that index passed is valid >>                                  00108000
<< DB must be pointing to the CDT and integer CDT'ENTRY is   >>         00109000
<< used to perform a validity check against.                 >>         00110000
define CDT'CHECK'INDEX =                                                00111000
if (CDT'ENTRY mod CDT'ENTRY'SIZE) <> 0 or                               00112000
   not (0 <= CDT'ENTRY <=                                               00113000
        (CDT'ARRAY(CDT'DST'WORDS) - 1)) then                            00114000
  SUDDENDEATH(CDT'BAD'INDEX)                                            00115000
else                                                                    00115100
  if CDT'ARRAY(CDT'ENTRY) < 0 then                                      00115200
    SUDDENDEATH(CDT'UNASSIGNED)#;                                       00115300
                                                                        00116000
<< Check that entry passed is valid >>                                  00117000
<< DB must be pointing to the CDT and integer CDT'ENTRY is   >>         00118000
<< used to perform a validity check against.                 >>         00119000
define CDT'CHECK'ENTRY =                                                00120000
if not (0 <= CDT'ENTRY <= CDT'ARRAY(CDT'ENTRIES)) then                  00121000
  SUDDENDEATH(CDT'BAD'INDEX)                                            00122000
else                                                                    00122100
  if CDT'ARRAY(CDT'ENTRY*CDT'ENTRY'SIZE) = -1 then                      00122200
    SUDDENDEATH(CDT'BAD'INDEX)#;                                        00122300
                                                                        00123000
<< The cache control sir is used to protect the ldev string (of ldevs>> 00124000
<< cached).  It is used when caching is enabled or disabled against  >> 00125000
<< a disc, or when a command executor wishes to display information  >> 00126000
<< about a specific device under caching control.                    >> 00127000
                                                                        00127100
equate CACHE'CONTROL'SIR = 2;                                           00128000
                                                                        00129000
<< This SHIFT instruction is used in KERNELC and in CACHESEG  >>        00129100
<< to optimize LLSH searching of disc addresses in caching.   >>        00129200
<< Since the high-order nibble of a double-word disc address  >>        00129300
<< is reserved for LDEV, we can always shift-over the disc    >>        00129400
<< address to overlay this field to increase the resolution of>>        00129500
<< the LLSH instruction.  Worse case, this instruction will be>>        00129600
<< DLSL(8), which merely overlays the LDEV portion of the HODA>>        00129700
<< Since the HP7933 is currently our largest capacity disc,   >>        00129800
<< and uses only the lower 5 bits of the HODA to represent the>>        00129900
<< highest possible sector address, we will assume DLSL(11).  >>        00129910
<< This will increase our resolution by 2**3.  IF ANY LARGER  >>        00129920
<< DISCS ARE ADDED TO THE 3000, THIS CONSTANT MUST BE CHANGED!>>        00129930
define CDT'SHIFT'DA = assemble(DLSL 11)#;                               00129940
                                                                        00129950
<< These subroutine defines are used in lieu of the procedures >>       00130000
<< in CACHESEG for performance reasons.  Note that no error    >>       00131000
<< checking is performed by these subroutines, and they will   >>       00132000
<< add to the procedure-local code size.                       >>       00133000
                                                                        00134000
integer CDT'SM3 = s-3,                                                  00135000
        CDT'SM4 = s-4,                                                  00136000
        CDT'SM5 = s-5,                                                  00137000
        CDT'SM6 = s-6,                                                  00138000
        CDT'SM7 = s-7,                                                  00139000
        CDT'SM8 = s-8;                                                  00140000
                                                                        00141000
double CDT'DSM4 = s-4,                                                  00142000
       CDT'DSM6 = s-6,                                                  00143000
       CDT'DSM10= s-10,                                                 00144000
       CDT'DSM12= s-12;                                                 00145000
                                                                        00146000
define DEF'OFST =                                                       00147000
                                                                        00148000
tos := CACHE'DST'BANK;                                                  00149000
tos := absolute(CDT'X:=CDT'X+1)+(CDT'SM4<<CD>>*CDT'ENTRY'SIZE)          00150000
                +CDT'SM3<<OFST>>#,                                      00151000
                                                                        00152000
DEF'DOFST =                                                             00153000
                                                                        00154000
tos := CACHE'DST'BANK;                                                  00155000
tos := absolute(CDT'X:=CDT'X+1)+(CDT'SM5<<CD>>*CDT'ENTRY'SIZE)          00156000
                +CDT'SM4<<OFST>>#,                                      00157000
                                                                        00158000
DEF'FOFST =                                                             00159000
                                                                        00160000
tos := CACHE'DST'BANK;                                                  00161000
tos := absolute(CDT'X:=CDT'X+1)+(CDT'SM4<<CD>>*CDT'ENTRY'SIZE)          00162000
                +CDT'MD'FLAGS#,                                         00163000
                                                                        00164000
DEF'FSOFST =                                                            00164100
                                                                        00164200
tos := CACHE'DST'BANK;                                                  00164300
tos := absolute(CDT'X:=CDT'X+1)+(CDT'SM5<<CD>>*CDT'ENTRY'SIZE)          00164400
                +CDT'MD'FLAGS#,                                         00164500
                                                                        00164600
DEF'GET'WORD =                                                          00165000
                                                                        00166000
integer subroutine CDT'GET'WORD(CD,OFST,VAL);                           00167000
value CD,OFST,VAL;                                                      00168000
integer CD,OFST,VAL;                                                    00169000
begin                                                                   00170000
                                                                        00171000
<< Load bank/offset on tos >>                                           00172000
DEF'OFST;                                                               00173000
                                                                        00174000
<< Load value on tos >>                                                 00175000
assemble(lsea);                                                         00176000
                                                                        00177000
<< Store in return value >>                                             00178000
CDT'SM7 := tos;                                                         00179000
                                                                        00180000
<< Remove stacked address >>                                            00181000
assemble(ddel);                                                         00182000
                                                                        00183000
end#,                                                                   00184000
                                                                        00185000
DEF'SET'WORD =                                                          00186000
                                                                        00187000
integer subroutine CDT'SET'WORD(CD,OFST,VAL);                           00188000
value CD,OFST,VAL;                                                      00189000
integer CD,OFST,VAL;                                                    00190000
begin                                                                   00191000
                                                                        00192000
<< Load bank/offset on tos >>                                           00193000
DEF'OFST;                                                               00194000
                                                                        00195000
<< Load value on tos >>                                                 00196000
assemble(lsea);                                                         00197000
                                                                        00198000
<< Store in return value >>                                             00199000
CDT'SM7 := tos;                                                         00200000
                                                                        00201000
<< Store new value >>                                                   00202000
tos := CDT'SM3; <<VAL>>                                                 00203000
assemble(ssea);                                                         00204000
                                                                        00205000
<< Remove stacked address >>                                            00206000
assemble(ddel);                                                         00207000
                                                                        00208000
end#,                                                                   00209000
                                                                        00210000
DEF'GET'DOUBLE =                                                        00211000
                                                                        00212000
double subroutine CDT'GET'DOUBLE(CD,OFST,VAL);                          00213000
value CD,OFST,VAL;                                                      00214000
integer CD,OFST;                                                        00215000
double VAL;                                                             00216000
begin                                                                   00217000
                                                                        00218000
<< Load bank/offset on tos >>                                           00219000
DEF'DOFST;                                                              00220000
                                                                        00221000
<< Load value on tos >>                                                 00222000
assemble(ldea);                                                         00223000
                                                                        00224000
<< Store in return value >>                                             00225000
CDT'DSM10 := tos;                                                       00226000
                                                                        00227000
<< Remove stacked address >>                                            00228000
assemble(ddel);                                                         00229000
                                                                        00230000
end#,                                                                   00231000
                                                                        00232000
DEF'SET'DOUBLE =                                                        00233000
                                                                        00234000
double subroutine CDT'SET'DOUBLE(CD,OFST,VAL);                          00235000
value CD,OFST,VAL;                                                      00236000
integer CD,OFST;                                                        00237000
double VAL;                                                             00238000
begin                                                                   00239000
                                                                        00240000
<< Load bank/offset on tos >>                                           00241000
DEF'DOFST;                                                              00242000
                                                                        00243000
<< Load value on tos >>                                                 00244000
assemble(ldea);                                                         00245000
                                                                        00246000
<< Store in return value >>                                             00247000
CDT'DSM10 := tos;                                                       00248000
                                                                        00249000
<< Store new value >>                                                   00250000
tos := CDT'DSM4; <<VAL>>                                                00251000
assemble(sdea);                                                         00252000
                                                                        00253000
<< Remove stacked address >>                                            00254000
assemble(ddel);                                                         00255000
                                                                        00256000
end#,                                                                   00257000
                                                                        00258000
DEF'ADD'DOUBLE =                                                        00259000
                                                                        00260000
double subroutine CDT'ADD'DOUBLE(CD,OFST,VAL);                          00261000
value CD,OFST,VAL;                                                      00262000
integer CD,OFST;                                                        00263000
double VAL;                                                             00264000
begin                                                                   00265000
                                                                        00266000
<< Load bank/offset on tos >>                                           00267000
DEF'DOFST;                                                              00268000
                                                                        00269000
<< Load value on tos >>                                                 00270000
assemble(ldea);                                                         00271000
                                                                        00272000
<< Add VAL to old value >>                                              00273000
tos := tos + CDT'DSM6;                                                  00274000
assemble(ddup);                                                         00275000
                                                                        00276000
<< Store in return value >>                                             00277000
CDT'DSM12 := tos;                                                       00278000
                                                                        00279000
<< Store new value >>                                                   00280000
assemble(sdea);                                                         00281000
                                                                        00282000
<< Remove stacked address >>                                            00283000
assemble(ddel);                                                         00284000
                                                                        00285000
end#,                                                                   00286000
                                                                        00287000
DEF'GET'BIT =                                                           00288000
                                                                        00289000
logical subroutine CDT'GET'BIT(CD,BIT'NO,VAL);                          00290000
value CD,BIT'NO,VAL;                                                    00291000
integer CD,BIT'NO,VAL;                                                  00292000
begin                                                                   00293000
                                                                        00294000
<< Load bank/offset on tos >>                                           00295000
DEF'FOFST;                                                              00296000
                                                                        00297000
<< Load value on tos >>                                                 00298000
assemble(lsea);                                                         00299000
                                                                        00300000
<< Store in return value >>                                             00301000
CDT'X := CDT'SM5;  <<BIT'NO>>                                           00302000
assemble(tbc 0,X);  << Test the corresponding bit >>                    00303000
if = then                                                               00304000
  CDT'SM7 := 0                                                          00305000
else                                                                    00306000
  CDT'SM7 := 1;                                                         00307000
                                                                        00308000
<< Remove stacked address >>                                            00309000
assemble(ddel,del);                                                     00310000
                                                                        00311000
end#,                                                                   00312000
                                                                        00313000
DEF'SET'BIT =                                                           00314000
                                                                        00315000
logical subroutine CDT'SET'BIT(CD,BIT'NO,VAL);                          00316000
value CD,BIT'NO,VAL;                                                    00317000
integer CD,BIT'NO,VAL;                                                  00318000
begin                                                                   00319000
                                                                        00320000
push(status);                                                           00320200
                                                                        00320300
DEF'FSOFST;                                                             00322000
                                                                        00323000
<< Load value on tos >>                                                 00324000
DISABLE;                                                                00324100
assemble(lsea);                                                         00325000
                                                                        00326000
CDT'X := CDT'SM6;  <<BIT'NO>>                                           00328000
if logical(CDT'SM5<<VAL>>) then                                         00329000
  assemble(tsbc 0,X)    << Turn on bit >>                               00330000
else                                                                    00331000
  assemble(trbc 0,X);   << Turn off bit >>                              00332000
                                                                        00333000
if = then                                                               00334000
  CDT'SM8 := 0         << Bit was off >>                                00335000
else                                                                    00336000
  CDT'SM8 := 1;        << Bit was on >>                                 00337000
                                                                        00338000
<< Store new value >>                                                   00339000
assemble(ssea);                                                         00340000
                                                                        00341000
assemble(ddel);                                                         00343000
                                                                        00344000
if tos.(1:1) = 1 then                                                   00344200
  ENABLE;                                                               00344300
                                                                        00344400
end#,                                                                   00345000
                                                                        00346000
DEF'ADD'WORD =                                                          00347000
                                                                        00348000
integer subroutine CDT'ADD'WORD(CD,OFST,VAL);                           00349000
value CD,OFST,VAL;                                                      00350000
integer CD,OFST,VAL;                                                    00351000
begin                                                                   00352000
                                                                        00353000
<< Load bank/offset on tos >>                                           00354000
DEF'OFST;                                                               00355000
                                                                        00356000
<< Load value on tos >>                                                 00357000
assemble(lsea);                                                         00358000
                                                                        00359000
<< Add VAL to value on tos >>                                           00360000
tos:=tos+CDT'SM4;                                                       00361000
assemble(dup);                                                          00362000
                                                                        00363000
<< Store in return value >>                                             00364000
CDT'SM8 := tos;                                                         00365000
                                                                        00366000
<< Store new value >>                                                   00367000
assemble(ssea);                                                         00368000
                                                                        00369000
<< Remove stacked address >>                                            00370000
assemble(ddel);                                                         00371000
                                                                        00372000
end#;                                                                   00373000
<<***********************************************************>>         00374000
<<***********************************************************>>         00375000
<<***********************************************************>>         00376000
