# 2.11BSD#431 - /usr/src/bin/adb/access.c

##### Functions

    acces             X
    chkget            X
    chkmap            X
    get               X
    put               X
    setovmap          X

##### Variables

    BADDAT            X
    BADTXT            X
    ODDADR            X
    curov             X
    datmap            X
    errflg            X
    overlay           X
    ovloff            X
    ovlseg            X
    pid               X
    txtmap            X
    var               X
    wtflag            X

       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

- in line 23, 30

chkget defined in line 33; used 7 times

- in /usr/src/bin/adb/defs.h line 191
- in /usr/src/bin/adb/expr.c line 87-90(2)
- in /usr/src/bin/adb/opset.c line 398, 404, 449
- in /usr/src/bin/adb/print.c line 408

chkmap defined in line 89; used 1 times

- in line 78

get defined in line 26; used 31 times

- in line 39
- in /usr/src/bin/adb/command.c line 126-128(2)
- in /usr/src/bin/adb/defs.h line 191
- in /usr/src/bin/adb/expr.c line 139
- in /usr/src/bin/adb/findfn.c line 29-33(4), 51-54(2)
- in /usr/src/bin/adb/format.c line 91-99(4), 145
- in /usr/src/bin/adb/print.c line 194, 202-206(2), 225, 232, 248, 258(3), 265-266(2), 272-275(3), 283

put defined in line 20; used 2 times

- in /usr/src/bin/adb/command.c line 147-149(2)

setovmap defined in line 137; used 15 times

- in /usr/src/bin/adb/command.c line 164, 182-185(2)
- in /usr/src/bin/adb/expr.c line 131, 151, 189
- in /usr/src/bin/adb/findfn.c line 30, 43, 50
- in /usr/src/bin/adb/pcs.c line 40, 51
- in /usr/src/bin/adb/print.c line 238, 376
- in /usr/src/bin/adb/runpcs.c line 283
- in /usr/src/bin/adb/setup.c line 191

within defined in line 156; used 6 times

- in line 16, 99-102(2), 109, 116, 123

#### Defined variables

BADDAT defined in line 4; used 3 times

- in line 70, 85, 131

BADTXT defined in line 5; used 3 times

- in line 70, 85, 131

ODDADR defined in line 3; used 1 times

- in line 54

curov defined in line 13; used 1 times

- in line 151

datmap defined in line 7; used 2 times

- in line 82, 95

errflg defined in line 9; used 3 times

- in line 70, 85, 131

overlay defined in line 14; used 1 times

- in line 142

ovloff defined in line 12; used 1 times

- in line 149

ovlseg defined in line 11; used 1 times

- in line 148

pid defined in line 10; used 4 times

- in line 53, 64-66(2), 152

txtmap defined in line 6; used 3 times

- in line 82, 95, 144

var defined in line 15; used 1 times

- in line 151

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: 714 |