mmaasm   ident
mmaasm   ALIAS   MMM$CACHE_MANAGEMENT_ROUTINES
*copyc dsa$cpu_pp_communication_block
*copyc mta$boot_control_table
*copyc mta$cpu_state_table
*copyc osa$basic_register_equates
*copyc sya$xp_and_sf_constants
*copyc sya$cybil_interface_procedures
         page
..........................................................................
.   Define A and X register usage
.
.
acst0    areg    5                     .Pointer to CST for processor 0.
acst     areg    6                     .Pointer to CST.
ascr     areg    7                     .Scratch register.
xindex   xreg    6                     .X register used for indexing thru CST
xcstcnt  xreg    7                     .Number of CST entries in use.
xfrc     xreg    8                     .Free running clock.
         page
         USE     CODE
...........................................................................
.  This procedure is called in a multiprocessor environment to purge the
.  map in all active processors in the mainframe.
...........................................................................
.
pmap     ALIAS   MMP$PURGE_ALL_MAP_PROC
pmap     procedur
*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'
.
         ente    x0,40(16)
         callseg bs_log,a3,a0
*ELSE
.
. -------- Code for forcing the use of cache and maps omitted at compile time --------
*IFEND
.
         la      acst0,a_bindin,bs_cst0 .Get pointer to CST0.
.
         la      ascr,a_bindin,bs_work
         lx      x1,ascr,8             .Increment count of map purges.
         incx    x1,1
         sx      x1,ascr,8
         la      ascr,a_bindin,bs_cstct .Get number of CST entries present.
         lbyts,1 xcstcnt,ascr,x0,0
         cpyax   x1,acst0              .Get pointer to current CST.
         entl    x0,47(16)             .Read the base constant register.
         cpysx   x2,x0
         insb    x1,x2,x0,4037(8)
         cpyxa   acst,x1
.
         entl    x0,r_td               .Disable traps for this sequence.
         cpysx   x1,x0
         cpyxs   x0,x0
         cpytx   xfrc,x0               .Purge map for current processor
         purge   x0,15                 .  and update timestamp in CST.
         sx      xfrc,acst,maptim
         cpyxs   x1,x0                 .Re-enable traps.
.
         cpyaa   acst,acst0            .Set loop scanning registers.
         entp    xindex,1
         entp    x0,pur_map
         entp    x2,1
pm2      lx      x1,acst,maptim        .Get time map last purged.
         brxge   x1,xfrc,pm4           .Jump if no purge necessary.
         sbit    x2,acst,ext_int,x0    .Set request bit for map purge.
         lbyts,1 x1,acst,x0,memport    .Send interrupt to processor.
         intrupt x1
pm4      addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pm2    .Jump if more CST entries to check.
.
         ente    x3,2FAF(16)           .Generate 50 seconds (in microseconds).
         shfx    x3,x3,x0,12
         cpyaa   acst,acst0            .Reset loop scanning registers.
         entp    xindex,1
.
pm6      lx      x2,acst,cpwell        .Get the value of the cpu_alive flag.
         addx    x2,x3                 .Check if CPU has been alive recently.
         entl    x0,0                  .Get the current FRC.
         cpytx   x4,x0
         brxge   x2,x4,pm8             .Jump if CPU has been alive recently.
.
                                       .Begin code to process ill CPU case.
         la      ascr,a_bindin,bs_bct  .Fetch pointer to Boot Control Table.
         lbyts,6 x1,ascr,x0,0
         cpyxa   ascr,x1
         lx      x1,ascr,bctflags      .Get the flags word.
         shfx    x1,x1,x0,5            .Check the CPU error processing in
                                       .  progress field.
         brxge   x1,x0,pm10            .Jump if not set.
         shfx    x1,x1,x0,1            .Check the CPU error fatal after
                                       .  having been processed field.
         brxgt   x0,x1,pm10            .Jump if set.
         sx      x4,acst,cpwell        .Update cpu_alive flag to allow for
                                       .  longer CPU error processing.
                                       .End code to process ill CPU case.
.
pm8      la      ascr,a_bindin,bs_cpcb .Get ptr to CPU_PP_communications_block.
         sx      x4,ascr,mon_time      .Update timestamp for DFT handshaking.
         lx      x1,acst,maptim        .Get time map last purged.
         brxgt   xfrc,x1,pm6           .Jump if map not yet purged.
         brxeq   x0,x0,pm12
pm10     ente    x2,-2153(16)          .Flag noting dead CPU (DEAD):
         isob    x2,x2,x0,0176(8)      .  looks like 7FFFFFFFFFFFDEAD.
         sx      x2,acst,maptim        .Store it in the Dead CPU's CST.
         sx      x2,acst,cachtim       .Store it in the Dead CPU's CST.
pm12     addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pm6    .Jump if more CST entries to check.
         la      ascr,a_bindin,bs_mapt
         entp    x0,0
         cpytx   x0,x0
         sx      x0,ascr,0
.
         return
         page
         USE     CODE
...........................................................................
.  This procedure is called in a multiprocessor environment to purge the
.  cache in all active processors in the mainframe.
...........................................................................
.
pcache   ALIAS   MMP$PURGE_ALL_CACHE_PROC
pcache   procedur
.
*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'
         ente    x0,40(16)
         callseg bs_log,a3,a0
*ELSE
. -------- Code for forcing the use of cache and maps omitted at compile time --------
*IFEND
.
         la      acst0,a_bindin,bs_cst0 .Get pointer to CST0.
.
         la      ascr,a_bindin,bs_work
         lx      x1,ascr,0             .Increment count of cache purges
         incx    x1,1
         sx      x1,ascr,0
         la      ascr,a_bindin,bs_cstct .Get number of CST entries present.
         lbyts,1 xcstcnt,ascr,x0,0
         cpyax   x1,acst0              .Get pointer to current CST.
         entl    x0,47(16)             .Read the base constant register.
         cpysx   x2,x0
         insb    x1,x2,x0,4037(8)
         cpyxa   acst,x1
.
         entl    x0,r_td               .Disable traps for this sequence.
         cpysx   x1,x0
         cpyxs   x0,x0
         cpytx   xfrc,x0               .Purge cache for current processor
         purge   x0,2                  .  and update timestamp in CST.
         sx      xfrc,acst,cachtim
         cpyxs   x1,x0                 .Re-enable traps.
.
         cpyaa   acst,acst0            .Set loop scanning registers.
         entp    xindex,1
         entp    x0,pur_ca
         entp    x2,1
pc2      lx      x1,acst,cachtim       .Get time cache last purged.
         brxge   x1,xfrc,pc4           .Jump if no purge necessary.
         sbit    x2,acst,ext_int,x0    .Set request bit for cache purge.
         lbyts,1 x1,acst,x0,memport    .Send interrupt to processor.
         intrupt x1
pc4      addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pc2    .Jump if more CST entries to check.
.
         ente    x3,2FAF(16)           .Generate 50 seconds (in microseconds).
         shfx    x3,x3,x0,12
         cpyaa   acst,acst0            .Reset loop scanning registers.
         entp    xindex,1
.
pc6      lx      x2,acst,cpwell        .Get the value of the cpu_alive flag.
         addx    x2,x3                 .Check if CPU has been alive recently.
         entl    x0,0                  .Get the current FRC.
         cpytx   x4,x0
         brxge   x2,x4,pc8             .Jump if CPU has been alive recently.
.
                                       .Begin code to process ill CPU case.
         la      ascr,a_bindin,bs_bct  .Fetch pointer to Boot Control Table.
         lbyts,6 x1,ascr,x0,0
         cpyxa   ascr,x1
         lx      x1,ascr,bctflags      .Get the flags word.
         shfx    x1,x1,x0,5            .Check the CPU error processing in
                                       .  progress field.
         brxge   x1,x0,pc10            .Jump if not set.
         shfx    x1,x1,x0,1            .Check the CPU error fatal after
                                       .  having been processed field.
         brxgt   x0,x1,pc10            .Jump if set.
         sx      x4,acst,cpwell        .Update cpu_alive flag to allow for
                                       .  longer CPU error processing.
                                       .End code to process ill CPU case.
.
pc8      la      ascr,a_bindin,bs_cpcb .Get ptr to CPU_PP_communications_block.
         sx      x4,ascr,mon_time      .Update timestamp for DFT handshaking.
         lx      x1,acst,cachtim       .Get time cache last purged.
         brxgt   xfrc,x1,pc6           .Jump if cache not yet purged.
         brxeq   x0,x0,pc12
pc10     ente    x2,-2153(16)          .Flag noting dead CPU (DEAD):
         isob    x2,x2,x0,0176(8)      .  looks like 7FFFFFFFFFFFDEAD.
         sx      x2,acst,maptim        .Store it in the Dead CPU's CST.
         sx      x2,acst,cachtim       .Store it in the Dead CPU's CST.
pc12     addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pc6    .Jump if more CST entries to check.
.
         return
         page
         USE     CODE
...........................................................................
.  This procedure is called in a multiprocessor environment to purge the
.  cache and map in all active processors in the mainframe.
...........................................................................
.
pall     ALIAS   MMP$PURGE_ALL_CACHE_MAP_PROC
pall     procedur
.
*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'
         ente    x0,40(16)
         callseg bs_log,a3,a0
*ELSE
. -------- Code for forcing the use of cache and maps omitted at compile time --------
*IFEND
.
         la      acst0,a_bindin,bs_cst0 .Get pointer to CST0.
.
         la      ascr,a_bindin,bs_work
         lx      x1,ascr,0             .Increment count of cache purges.
         incx    x1,1
         sx      x1,ascr,0
         lx      x1,ascr,8             .Increment count of map purges.
         incx    x1,1
         sx      x1,ascr,8
         la      ascr,a_bindin,bs_cstct .Get number of CST entries present.
         lbyts,1 xcstcnt,ascr,x0,0
         cpyax   x1,acst0              .Get pointer to current CST.
         entl    x0,47(16)             .Read the base constant register.
         cpysx   x2,x0
         insb    x1,x2,x0,4037(8)
         cpyxa   acst,x1
.
         entl    x0,r_td               .Disable traps for this sequence.
         cpysx   x1,x0
         cpyxs   x0,x0
         cpytx   xfrc,x0               .Purge cache/maps for current processor
         purge   x0,2                  .  and update timestamp in CST.
         purge   x0,15
         sx      xfrc,acst,cachtim
         sx      xfrc,acst,maptim
         cpyxs   x1,x0                 .Re-enable traps.
.
         cpyaa   acst,acst0            .Set loop scanning registers.
         entp    xindex,1
         entp    x2,1
pa2      lx      x1,acst,cachtim       .Get time cache last purged.
         brxgt   xfrc,x1,pa4           .Jump if purge is necessary.
         lx      x1,acst,maptim        .Get time map last purged.
         brxge   x1,xfrc,pa6           .Jump if no purge necessary.
pa4      entp    x0,pur_ca
         sbit    x2,acst,ext_int,x0    .Set request bit for cache purge.
         entp    x0,pur_map
         sbit    x2,acst,ext_int,x0    .Set request bit for map purge.
         lbyts,1 x1,acst,x0,memport    .Send interrupt to processor.
         intrupt x1
pa6      addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pa2    .Jump if more CST entries to check.
.
         ente    x3,2FAF(16)           .Generate 50 seconds (in microseconds).
         shfx    x3,x3,x0,12
         cpyaa   acst,acst0            .Reset loop scanning registers.
         entp    xindex,1
.
pa8      lx      x2,acst,cpwell        .Get the value of the cpu_alive flag.
         addx    x2,x3                 .Check if CPU has been alive recently.
         entl    x0,0                  .Get the current FRC.
         cpytx   x4,x0
         brxge   x2,x4,pa10            .Jump if CPU has been alive recently.
.
                                       .Begin code to process ill CPU case.
         la      ascr,a_bindin,bs_bct  .Fetch pointer to Boot Control Table.
         lbyts,6 x1,ascr,x0,0
         cpyxa   ascr,x1
         lx      x1,ascr,bctflags      .Get the flags word.
         shfx    x1,x1,x0,5            .Check the CPU error processing in
                                       .  progress field.
         brxge   x1,x0,pa16            .Jump if not set.
         shfx    x1,x1,x0,1            .Check the CPU error fatal after
                                       .  having been processed field.
         brxgt   x0,x1,pa16            .Jump if set.
         sx      x4,acst,cpwell        .Update cpu_alive flag to allow for
                                       .  longer CPU error processing.
                                       .End code to process ill CPU case.
.
pa10     la      ascr,a_bindin,bs_cpcb .Get ptr to CPU_PP_communications_block.
         sx      x4,ascr,mon_time      .Update timestamp for DFT handshaking.
         lx      x1,acst,cachtim       .Get time cache last purged.
         brxgt   xfrc,x1,pa8           .Jump if cache not yet purged.
.
pa12     lx      x2,acst,cpwell        .Get the value of the cpu_alive flag.
         addx    x2,x3                 .Check if CPU has been alive recently.
         entl    x0,0                  .Get the current FRC.
         cpytx   x4,x0
         brxge   x2,x4,pa14            .Jump if CPU has been alive recently.
.
                                       .Begin code to process ill CPU case.
         la      ascr,a_bindin,bs_bct  .Fetch pointer to Boot Control Table.
         lbyts,6 x1,ascr,x0,0
         cpyxa   ascr,x1
         lx      x1,ascr,bctflags      .Get the flags word.
         shfx    x1,x1,x0,5            .Check the CPU error processing in
                                       .  progress field.
         brxge   x1,x0,pa16            .Jump if not set.
         shfx    x1,x1,x0,1            .Check the CPU error fatal after
                                       .  having been processed field.
         brxgt   x0,x1,pa16            .Jump if set.
         sx      x4,acst,cpwell        .Update cpu_alive flag to allow for
                                       .  longer CPU error processing.
                                       .End code to process ill CPU case.
.
pa14     la      ascr,a_bindin,bs_cpcb .Get ptr to CPU_PP_communications_block.
         sx      x4,ascr,mon_time      .Update timestamp for DFT handshaking.
         lx      x1,acst,maptim        .Get time map last purged.
         brxgt   xfrc,x1,pa12          .Jump if map not yet purged.
         brxeq   x0,x0,pa18
pa16     ente    x2,-2153(16)          .Flag noting dead CPU (DEAD):
         isob    x2,x2,x0,0176(8)      .  looks like 7FFFFFFFFFFFDEAD.
         sx      x2,acst,maptim        .Store it in the Dead CPU's CST.
         sx      x2,acst,cachtim       .Store it in the Dead CPU's CST.
pa18     addaq   acst,acst,cstsize     .Set pointer to next CST entry.
         brinc   xcstcnt,xindex,pa8    .Jump if more CST entries to check.
         la      ascr,a_bindin,bs_mapt
         entp    x0,0
         cpytx   x0,x0
         sx      x0,ascr,0
.
         return
         page
...........................................................................
.  Define binding section
.
         USE     BINDING
         ref     pr_cstct,pr_cst0,pr_cpcb,pr_bct
pr_bct   ALIAS   dsv$boot_control_table_p
pr_cstct ALIAS   osv$cpus_physically_configured
bs_bct   address p,pr_bct
bs_cstct address p,pr_cstct
pr_cst0  ALIAS   mtv$cst0
pr_cpcb  ALIAS   dsv$cpu_pp_communication_block
bs_cst0  address p,pr_cst0
bs_work  address p,pcount
bs_cpcb  address p,pr_cpcb
bs_mapt  address p,mapt
*IF $variable(mmv$test_forced_use_cache_maps, declared) <> 'UNKNOWN'
.
. Binding declarations for logging callers of procedures above.
.        ref     MMP$LOG_CALLER_MONITOR
.bs_log   address ce,mmp$log_caller_monitor
*ELSE
.
. -------- Binding declarations for forcing the use of cache and maps omitted at compile time --------
*IFEND
.
         USE     WORKING
         def     pcount,mapt
         align   0,8
pcount   ALIAS   mmv$purge_counts
mapt     ALIAS   mmv$time_map_last_purged
pcount   bssz    24
mapt     bssz    8
         end
