1: static  char sccsid[] = "@(#)setup.c 4.3 8/17/82";
   2: #
   3: /*
   4:  *
   5:  *	UNIX debugger
   6:  *
   7:  */
   8: 
   9: #include "head.h"
  10: 
  11: MSG     BADMAG;
  12: 
  13: INT     wtflag;
  14: INT     fcor;
  15: INT     fsym;
  16: L_INT       maxfile;
  17: L_INT       maxstor;
  18: L_INT       txtsiz;
  19: L_INT       datsiz;
  20: L_INT       datbas;
  21: L_INT       stksiz;
  22: STRING      errflg;
  23: INT     magic;
  24: L_INT       symbas;
  25: L_INT       symnum;
  26: L_INT       entrypt;
  27: 
  28: INT     argcount;
  29: INT     signo;
  30: struct user u;
  31: 
  32: #define TXTHDRSIZ   (sizeof(txthdr))
  33: 
  34: #ifndef EDDT
  35: readl(f,p,n) int f,n; long * p;{
  36: #ifndef vax
  37:     int t=0;
  38:     do {t += read(f,&(p->loword),2); t += read(f,&(p->hiword),2); p++;} while (--n);
  39:     return(t);
  40: #else
  41:     return(read(f,p,n*sizeof(long)));
  42: #endif
  43: }
  44: #endif
  45: 
  46: setsym()
  47: {
  48: #ifndef EDDT
  49:     TXTHDR      txthdr;
  50: 
  51:     fsym=getfile(symfil,1);
  52:     txtmap.ufd=fsym;
  53:     IF readl(fsym, txthdr, TXTHDRSIZ/sizeof(txthdr[0]))==TXTHDRSIZ
  54:     THEN    magic=txthdr[0];
  55:         IF magic!=0410 ANDF magic!=0407 ANDF magic!=0412 ANDF magic!=0413
  56:         THEN    magic=0;
  57:         ELSE
  58:             symnum=txthdr[4]/SYMTABSIZ;
  59:             txtsiz=txthdr[1];
  60:             datsiz=txthdr[2];
  61:             symbas=txtsiz+datsiz;
  62:             txtmap.f1=txtmap.f2=TXTHDRSIZ;
  63:             switch (magic) {
  64: 
  65:             case 0407:
  66:                 txtmap.b1=0;
  67:                 txtmap.e1=0;
  68:                 txtmap.b2=datbas=0;
  69:                 txtmap.e2=symbas;
  70:                 break;
  71: 
  72:             case 0413:
  73:                 txtmap.f1=txtmap.f2=(CLSIZE*NBPG);
  74:             case 0410:
  75:                 txtmap.b1=0;
  76:                 txtmap.e1=txtsiz;
  77:                 txtmap.b2=datbas=round(txtsiz,TXTRNDSIZ);
  78:                 txtmap.e2=datbas+datsiz;
  79:                 txtmap.f2+=txtmap.e1;
  80:             }
  81:             entrypt=txthdr[5];
  82:             symbas += txthdr[6]+txthdr[7];
  83:             symbas += magic==0412||magic==0413 ? (CLSIZE*NBPG) : TXTHDRSIZ;
  84:             ststart = symbas;
  85: #ifdef FLEXNAMES
  86:             gstart = ststart+txthdr[4];
  87: #endif
  88:             /* set up symvec */
  89:         FI
  90:     FI
  91:     IF magic==0 THEN txtmap.e1=maxfile; FI
  92: #endif
  93: }
  94: 
  95: setcor()
  96: {
  97:     fcor=getfile(corfil,2);
  98:     datmap.ufd=fcor;
  99:     IF read(fcor, &u, ctob(UPAGES))==ctob(UPAGES)
 100: #ifndef STD
 101:        ANDF (u.u_pcb.pcb_ksp & 0xF0000000L)==0x70000000L
 102: #else
 103:        ANDF (u.u_pcb.pcb_ksp & 0xF0000000L)==0x80000000L
 104: #endif
 105:        ANDF (u.u_pcb.pcb_usp & 0xF0000000L)==0x70000000L
 106:     THEN
 107:         signo = u.u_arg[0]&017;
 108:         txtsiz = ctob(u.u_tsize);
 109:         datsiz = ctob(u.u_dsize);
 110:         stksiz = ctob(u.u_ssize);
 111:         datmap.b1 = datbas = (magic==0410?round(txtsiz,TXTRNDSIZ):0);
 112:         if (magic == 0413)
 113:             datmap.b1 = datbas = txtsiz;
 114:         datmap.e1=(magic==0407?txtsiz:datmap.b1)+datsiz;
 115: #ifdef STD
 116:         datmap.f1 = ctob(USIZE);
 117: #else
 118:         datmap.f1 = ctob(UPAGES);
 119: #endif
 120:         datmap.b2 = maxstor-stksiz;
 121:         datmap.e2 = maxstor;
 122: #ifdef STD
 123:         datmap.f2 = ctob(USIZE)+(magic==0410?datsiz:datmap.e1);
 124: #else
 125:         datmap.f2 = ctob(UPAGES)+((magic==0410 || magic == 0413)
 126:                          ? datsiz : datmap.e1);
 127: #endif
 128:         signo = *(ADDR *)(((ADDR)&u)+ctob(UPAGES)-4*sizeof(int));
 129:         IF magic ANDF magic!=u.u_exdata.ux_mag
 130:         THEN    printf("%s\n",BADMAG);
 131:         FI
 132:     ELSE    datmap.e1 = maxfile;
 133:     FI
 134: }
 135: 
 136: create(f)
 137: STRING  f;
 138: {   int fd;
 139:     IF (fd=creat(f,0644))>=0
 140:     THEN close(fd); return(open(f,wtflag));
 141:     ELSE return(-1);
 142:     FI
 143: }
 144: 
 145: getfile(filnam,cnt)
 146: STRING  filnam;
 147: {
 148:     REG INT     fsym;
 149: 
 150:     IF !eqstr("-",filnam)
 151:     THEN    fsym=open(filnam,wtflag);
 152:         IF fsym<0 ANDF argcount>cnt
 153:         THEN    IF wtflag
 154:             THEN    fsym=create(filnam);
 155:             FI
 156:             IF fsym<0
 157:             THEN printf("cannot open `%s'\n", filnam);
 158:             FI
 159:         FI
 160:     ELSE    fsym = -1;
 161:     FI
 162:     return(fsym);
 163: }

Defined functions

create defined in line 136; used 1 times
getfile defined in line 145; used 2 times
readl defined in line 35; used 1 times
  • in line 53
setcor defined in line 95; used 2 times
setsym defined in line 46; used 1 times

Defined variables

sccsid defined in line 1; never used
u defined in line 30; used 10 times

Defined macros

TXTHDRSIZ defined in line 32; used 4 times
Last modified: 1982-10-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1133
Valid CSS Valid XHTML 1.0 Strict