1: #include "defs.h"
   2: 
   3:     MSG ODDADR;
   4:     MSG BADDAT;
   5:     MSG BADTXT;
   6:     MAP txtmap;
   7:     MAP datmap;
   8:     int wtflag;
   9:     char    *errflg;
  10:     int pid;
  11:     struct  ovlhdr  ovlseg;
  12:     long    ovloff[];
  13:     char    curov;
  14:     int overlay;
  15:     long    var[];
  16:     static  within();
  17: 
  18: /* file handling and access routines */
  19: 
  20: put(adr,space,value)
  21:     long   adr;
  22: {
  23:     acces(WT,adr,space,value);
  24: }
  25: 
  26: u_int
  27: get(adr, space)
  28: long    adr;
  29: {
  30:     return(acces(RD,adr,space,0));
  31: }
  32: 
  33: u_int
  34: chkget(n, space)
  35:     long    n;
  36: {
  37:     register int w;
  38: 
  39:     w = get(n, space);
  40:     chkerr();
  41:     return(w);
  42: }
  43: 
  44: acces(mode,adr,space,value)
  45:     long    adr;
  46: {
  47:     int w, w1, pmode, rd, file;
  48:     BKPTR   bkptr, scanbkpt();
  49: 
  50:     rd = mode==RD;
  51:     IF space == NSP THEN return(0); FI
  52: 
  53:     IF pid          /* tracing on? */
  54:     THEN IF (adr&01) ANDF !rd THEN error(ODDADR); FI
  55:          pmode = (space&DSP?(rd?PT_READ_D:PT_WRITE_D):(rd?PT_READ_I:PT_WRITE_I));
  56:          if (bkptr=scanbkpt((u_int)adr)) {
  57:         if (rd) {
  58:             return(bkptr->ins);
  59:         } else {
  60:             bkptr->ins = value;
  61:             return(0);
  62:         }
  63:          }
  64:          w = ptrace(pmode, pid, shorten(adr&~01), value);
  65:          IF adr&01
  66:          THEN w1 = ptrace(pmode, pid, shorten(adr+1), value);
  67:           w = (w>>8)&LOBYTE | (w1<<8);
  68:          FI
  69:          IF errno
  70:          THEN errflg = (space&DSP ? BADDAT : BADTXT);
  71:          FI
  72:          return(w);
  73:     FI
  74:     w = 0;
  75:     IF mode==WT ANDF wtflag==0
  76:     THEN    error("not in write mode");
  77:     FI
  78:     IF !chkmap(&adr,space)
  79:     THEN return(0);
  80:     FI
  81: 
  82:     file = (space&DSP ? datmap.ufd : txtmap.ufd);
  83:     if  (lseek(file,adr, 0) == -1L ||
  84:             (rd ? read(file,&w,2) : write(file,&value,2)) < 1)
  85:         errflg = (space & DSP ? BADDAT : BADTXT);
  86:     return(w);
  87: }
  88: 
  89: chkmap(adr,space)
  90:     register long       *adr;
  91:     register int    space;
  92: {
  93:     register MAPPTR amap;
  94: 
  95:     amap=((space&DSP?&datmap:&txtmap));
  96:     switch(space&(ISP|DSP|STAR)) {
  97: 
  98:         case ISP:
  99:             IF within(*adr, amap->b1, amap->e1)
 100:             THEN *adr += (amap->f1) - (amap->b1);
 101:                 break;
 102:             ELIF within(*adr, amap->bo, amap->eo)
 103:             THEN *adr += (amap->fo) - (amap->bo);
 104:                 break;
 105:             FI
 106:             /* falls through */
 107: 
 108:         case ISP+STAR:
 109:             IF within(*adr, amap->b2, amap->e2)
 110:             THEN *adr += (amap->f2) - (amap->b2);
 111:                 break;
 112:             ELSE goto err;
 113:             FI
 114: 
 115:         case DSP:
 116:             IF within(*adr, amap->b1, amap->e1)
 117:             THEN *adr += (amap->f1) - (amap->b1);
 118:                 break;
 119:             FI
 120:             /* falls through */
 121: 
 122:         case DSP+STAR:
 123:             IF within(*adr, amap->b2, amap->e2)
 124:             THEN *adr += (amap->f2) - (amap->b2);
 125:                 break;
 126:             FI
 127:             /* falls through */
 128: 
 129:         default:
 130:         err:
 131:             errflg = (space&DSP ? BADDAT: BADTXT);
 132:             return(0);
 133:     }
 134:     return(1);
 135: }
 136: 
 137: setovmap(ovno)
 138:     char    ovno;
 139:     {
 140:     register MAPPTR amap;
 141: 
 142:     if ((!overlay) || (ovno < 0) || (ovno > NOVL))
 143:         return;
 144:     amap = &txtmap;
 145:     IF ovno == 0
 146:     THEN    amap->eo = amap->bo;
 147:         amap->fo = 0;
 148:     ELSE    amap->eo = amap->bo + ovlseg.ov_siz[ovno-1];
 149:         amap->fo = ovloff[ovno-1];
 150:     FI
 151:     var[VARC] = curov = ovno;
 152:     if (pid)
 153:         choverlay(ovno);
 154: }
 155: 
 156: static
 157: within(adr,lbd,ubd)
 158:     long    adr, lbd, ubd;
 159: {
 160:     return(adr>=lbd && adr<ubd);
 161: }

Defined functions

acces defined in line 44; used 2 times
chkmap defined in line 89; used 1 times
  • in line 78
get defined in line 26; used 31 times
put defined in line 20; used 2 times
within defined in line 156; used 6 times

Defined variables

BADDAT defined in line 4; used 3 times
BADTXT defined in line 5; used 3 times
ODDADR defined in line 3; used 1 times
  • in line 54
curov defined in line 13; used 1 times
datmap defined in line 7; used 2 times
errflg defined in line 9; used 3 times
overlay defined in line 14; used 1 times
ovloff defined in line 12; used 1 times
ovlseg defined in line 11; used 1 times
pid defined in line 10; used 4 times
txtmap defined in line 6; used 3 times
var defined in line 15; used 1 times
wtflag defined in line 8; used 1 times
  • in line 75
Last modified: 1998-04-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2939
Valid CSS Valid XHTML 1.0 Strict