1: #define CHAR    01
   2: #define BLOCK   02
   3: #define INTR    04
   4: #define EVEN    010
   5: #define KL  020
   6: #define ROOT    040
   7: char    *btab[]
   8: {
   9:     "rk",
  10:     "rp",
  11:     "rf",
  12:     "tm",
  13:     "tc",
  14:     "hs",
  15:     "hp",
  16:     "ht",
  17:     0
  18: };
  19: char    *ctab[]
  20: {
  21:     "console",
  22:     "pc",
  23:     "lp",
  24:     "dc",
  25:     "dh",
  26:     "dp",
  27:     "dj",
  28:     "dn",
  29:     "mem",
  30:     "rk",
  31:     "rf",
  32:     "rp",
  33:     "tm",
  34:     "hs",
  35:     "hp",
  36:     "ht",
  37:     0
  38: };
  39: struct tab
  40: {
  41:     char    *name;
  42:     int count;
  43:     int address;
  44:     int key;
  45:     char    *codea;
  46:     char    *codeb;
  47:     char    *codec;
  48:     char    *coded;
  49:     char    *codee;
  50: } table[]
  51: {
  52:     "console",
  53:     -1, 60, CHAR+INTR+KL,
  54:     "\tklin; br4\n\tklou; br4\n",
  55:     ".globl\t_klrint\nklin:\tjsr\tr0,call; _klrint\n",
  56:     ".globl\t_klxint\nklou:\tjsr\tr0,call; _klxint\n",
  57:     "",
  58:     "\t&klopen,   &klclose,  &klread,   &klwrite,  &klsgtty,",
  59: 
  60:     "mem",
  61:     -1, 300,    CHAR,
  62:     "",
  63:     "",
  64:     "",
  65:     "",
  66:     "\t&nulldev,  &nulldev,  &mmread,   &mmwrite,  &nodev,",
  67: 
  68:     "pc",
  69:     0,  70, CHAR+INTR,
  70:     "\tpcin; br4\n\tpcou; br4\n",
  71:     ".globl\t_pcrint\npcin:\tjsr\tr0,call; _pcrint\n",
  72:     ".globl\t_pcpint\npcou:\tjsr\tr0,call; _pcpint\n",
  73:     "",
  74:     "\t&pcopen,   &pcclose,  &pcread,   &pcwrite,  &nodev,",
  75: 
  76:     "clock",
  77:     -2, 100,    INTR,
  78:     "\tkwlp; br6\n",
  79:     ".globl\t_clock\n",
  80:     "kwlp:\tjsr\tr0,call; _clock\n",
  81:     "",
  82:     "",
  83: 
  84:     "parity",
  85:     -1, 114,    INTR,
  86:     "\ttrap; br7+7.\t\t/ 11/70 parity\n",
  87:     "",
  88:     "",
  89:     "",
  90:     "",
  91: 
  92: /*
  93:  * 110 unused
  94:  * 114 memory parity
  95:  * 120 XY plotter
  96:  * 124 DR11-B
  97:  * 130 AD01
  98:  * 134 AFC11
  99:  * 140 AA11
 100:  * 144 AA11
 101:  * 150-174 unused
 102:  */
 103: 
 104:     "lp",
 105:     0,  200,    CHAR+INTR,
 106:     "\tlpou; br4\n",
 107:     "",
 108:     ".globl\t_lpint\nlpou:\tjsr\tr0,call; _lpint\n",
 109:     "",
 110:     "\t&lpopen,   &lpclose,  &nodev,    &lpwrite,  &nodev,",
 111: 
 112:     "rf",
 113:     0,  204,    BLOCK+CHAR+INTR,
 114:     "\trfio; br5\n",
 115:     ".globl\t_rfintr\n",
 116:     "rfio:\tjsr\tr0,call; _rfintr\n",
 117:     "\t&nulldev,\t&nulldev,\t&rfstrategy, \t&rftab,",
 118:     "\t&nulldev,  &nulldev,  &rfread,   &rfwrite,  &nodev,",
 119: 
 120:     "hs",
 121:     0,  204,    BLOCK+CHAR+INTR,
 122:     "\thsio; br5\n",
 123:     ".globl\t_hsintr\n",
 124:     "hsio:\tjsr\tr0,call; _hsintr\n",
 125:     "\t&nulldev,\t&nulldev,\t&hsstrategy, \t&hstab,",
 126:     "\t&nulldev,  &nulldev,  &hsread,   &hswrite,  &nodev,",
 127: 
 128: /*
 129:  * 210 RC
 130:  */
 131: 
 132:     "tc",
 133:     0,  214,    BLOCK+INTR,
 134:     "\ttcio; br6\n",
 135:     ".globl\t_tcintr\n",
 136:     "tcio:\tjsr\tr0,call; _tcintr\n",
 137:     "\t&nulldev,\t&tcclose,\t&tcstrategy, \t&tctab,",
 138:     "",
 139: 
 140:     "rk",
 141:     0,  220,    BLOCK+CHAR+INTR,
 142:     "\trkio; br5\n",
 143:     ".globl\t_rkintr\n",
 144:     "rkio:\tjsr\tr0,call; _rkintr\n",
 145:     "\t&nulldev,\t&nulldev,\t&rkstrategy, \t&rktab,",
 146:     "\t&nulldev,  &nulldev,  &rkread,   &rkwrite,  &nodev,",
 147: 
 148:     "tm",
 149:     0,  224,    BLOCK+CHAR+INTR,
 150:     "\ttmio; br5\n",
 151:     ".globl\t_tmintr\n",
 152:     "tmio:\tjsr\tr0,call; _tmintr\n",
 153:     "\t&tmopen,\t&tmclose,\t&tmstrategy, \t&tmtab,",
 154:     "\t&tmopen,   &tmclose,  &tmread,   &tmwrite,  &nodev,",
 155: 
 156:     "ht",
 157:     0,  224,    BLOCK+CHAR+INTR,
 158:     "\thtio; br5\n",
 159:     ".globl\t_htintr\n",
 160:     "htio:\tjsr\tr0,call; _htintr\n",
 161:     "\t&htopen,\t&htclose,\t&htstrategy, \t&httab,",
 162:     "\t&htopen,   &htclose,  &htread,   &htwrite,  &nodev,",
 163: 
 164:     "cr",
 165:     0,  230,    CHAR+INTR,
 166:     "\tcrin; br6\n",
 167:     "",
 168:     ".globl\t_crint\ncrin:\tjsr\tr0,call; _crint\n",
 169:     "",
 170:     "\t&cropen,   &crclose,  &crread,   &nodev,    &nodev,",
 171: 
 172: /*
 173:  * 234 UDC11
 174:  */
 175: 
 176:     "rp",
 177:     0,  254,    BLOCK+CHAR+INTR,
 178:     "\trpio; br5\n",
 179:     ".globl\t_rpintr\n",
 180:     "rpio:\tjsr\tr0,call; _rpintr\n",
 181:     "\t&nulldev,\t&nulldev,\t&rpstrategy, \t&rptab,",
 182:     "\t&nulldev,  &nulldev,  &rpread,   &rpwrite,  &nodev,",
 183: 
 184:     "hp",
 185:     0,  254,    BLOCK+CHAR+INTR,
 186:     "\thpio; br5\n",
 187:     ".globl\t_hpintr\n",
 188:     "hpio:\tjsr\tr0,call; _hpintr\n",
 189:     "\t&hpopen,\t&nulldev,\t&hpstrategy, \t&hptab,",
 190:     "\t&hpopen,   &nulldev,  &hpread,   &hpwrite,  &nodev,",
 191: 
 192: /*
 193:  * 260 TA11
 194:  * 264-274 unused
 195:  */
 196: 
 197:     "dc",
 198:     0,  308,    CHAR+INTR,
 199:     "\tdcin; br5+%d.\n\tdcou; br5+%d.\n",
 200:     ".globl\t_dcrint\ndcin:\tjsr\tr0,call; _dcrint\n",
 201:     ".globl\t_dcxint\ndcou:\tjsr\tr0,call; _dcxint\n",
 202:     "",
 203:     "\t&dcopen,   &dcclose,  &dcread,   &dcwrite,  &dcsgtty,",
 204: 
 205:     "kl",
 206:     0,  308,    INTR+KL,
 207:     "\tklin; br4+%d.\n\tklou; br4+%d.\n",
 208:     "",
 209:     "",
 210:     "",
 211:     "",
 212: 
 213:     "dp",
 214:     0,  308,    CHAR+INTR,
 215:     "\tdpin; br6+%d.\n\tdpou; br6+%d.\n",
 216:     ".globl\t_dprint\ndpin:\tjsr\tr0,call; _dprint\n",
 217:     ".globl\t_dpxint\ndpou:\tjsr\tr0,call; _dpxint\n",
 218:     "",
 219:     "\t&dpopen,   &dpclose,  &dpread,   &dpwrite,  &nodev,",
 220: 
 221: /*
 222:  * DM11-A
 223:  */
 224: 
 225:     "dn",
 226:     0,  304,    CHAR+INTR,
 227:     "\tdnou; br5+%d.\n",
 228:     "",
 229:     ".globl\t_dnint\ndnou:\tjsr\tr0,call; _dnint\n",
 230:     "",
 231:     "\t&dnopen,   &dnclose,  &nodev,    &dnwrite,  &nodev,",
 232: 
 233:     "dhdm",
 234:     0,  304,    INTR,
 235:     "\tdmin; br4+%d.\n",
 236:     "",
 237:     ".globl\t_dmint\ndmin:\tjsr\tr0,call; _dmint\n",
 238:     "",
 239:     "",
 240: 
 241: /*
 242:  * DR11-A+
 243:  * DR11-C+
 244:  * PA611+
 245:  * PA611+
 246:  * DT11+
 247:  * DX11+
 248:  */
 249: 
 250:     "dl",
 251:     0,  308,    INTR+KL,
 252:     "\tklin; br4+%d.\n\tklou; br4+%d.\n",
 253:     "",
 254:     "",
 255:     "",
 256:     "",
 257: 
 258: /*
 259:  * DJ11
 260:  */
 261: 
 262:     "dh",
 263:     0,  308,    CHAR+INTR+EVEN,
 264:     "\tdhin; br5+%d.\n\tdhou; br5+%d.\n",
 265:     ".globl\t_dhrint\ndhin:\tjsr\tr0,call; _dhrint\n",
 266:     ".globl\t_dhxint\ndhou:\tjsr\tr0,call; _dhxint\n",
 267:     "",
 268:     "\t&dhopen,   &dhclose,  &dhread,   &dhwrite,  &dhsgtty,",
 269: 
 270: /*
 271:  * GT40
 272:  * LPS+
 273:  * VT20
 274:  */
 275: 
 276:     0
 277: };
 278: 
 279: char    *stra[]
 280: {
 281:     "/ low core",
 282:     "",
 283:     "br4 = 200",
 284:     "br5 = 240",
 285:     "br6 = 300",
 286:     "br7 = 340",
 287:     "",
 288:     ". = 0^.",
 289:     "\tbr\t1f",
 290:     "\t4",
 291:     "",
 292:     "/ trap vectors",
 293:     "\ttrap; br7+0.\t\t/ bus error",
 294:     "\ttrap; br7+1.\t\t/ illegal instruction",
 295:     "\ttrap; br7+2.\t\t/ bpt-trace trap",
 296:     "\ttrap; br7+3.\t\t/ iot trap",
 297:     "\ttrap; br7+4.\t\t/ power fail",
 298:     "\ttrap; br7+5.\t\t/ emulator trap",
 299:     "\ttrap; br7+6.\t\t/ system entry",
 300:     "",
 301:     ". = 40^.",
 302:     ".globl\tstart, dump",
 303:     "1:\tjmp\tstart",
 304:     "\tjmp\tdump",
 305:     "",
 306:     0,
 307: };
 308: 
 309: char    *strb[]
 310: {
 311:     "",
 312:     ". = 240^.",
 313:     "\ttrap; br7+7.\t\t/ programmed interrupt",
 314:     "\ttrap; br7+8.\t\t/ floating point",
 315:     "\ttrap; br7+9.\t\t/ segmentation violation",
 316:     0
 317: };
 318: 
 319: char    *strc[]
 320: {
 321:     "",
 322:     "/ floating vectors",
 323:     ". = 300^.",
 324:     0,
 325: };
 326: 
 327: char    *strd[]
 328: {
 329:     "",
 330:     "//////////////////////////////////////////////////////",
 331:     "/\t\tinterface code to C",
 332:     "//////////////////////////////////////////////////////",
 333:     "",
 334:     ".globl\tcall, trap",
 335:     0
 336: };
 337: 
 338: char    *stre[]
 339: {
 340:     "/*",
 341:     " */",
 342:     "",
 343:     "int\t(*bdevsw[])()",
 344:     "{",
 345:     0,
 346: };
 347: 
 348: char    *strf[]
 349: {
 350:     "\t0",
 351:     "};",
 352:     "",
 353:     "int\t(*cdevsw[])()",
 354:     "{",
 355:     0,
 356: };
 357: 
 358: char    *strg[]
 359: {
 360:     "\t0",
 361:     "};",
 362:     "",
 363:     "int\trootdev\t{(%d<<8)|0};",
 364:     "int\tswapdev\t{(%d<<8)|0};",
 365:     "int\tswplo\t4000;\t/* cannot be zero */",
 366:     "int\tnswap\t872;",
 367:     0,
 368: };
 369: 
 370: int fout;
 371: int root    -1;
 372: 
 373: main()
 374: {
 375:     register struct tab *p;
 376:     register *q;
 377:     int i, n, ev, nkl;
 378:     int flagf, flagb;
 379: 
 380:     while(input());
 381: 
 382: /*
 383:  * pass1 -- create interrupt vectors
 384:  */
 385:     nkl = 0;
 386:     flagf = flagb = 1;
 387:     fout = creat("l.s", 0666);
 388:     puke(stra);
 389:     for(p=table; p->name; p++)
 390:     if(p->count != 0 && p->key & INTR) {
 391:         if(p->address>240 && flagb) {
 392:             flagb = 0;
 393:             puke(strb);
 394:         }
 395:         if(p->address >= 300) {
 396:             if(flagf) {
 397:                 ev = 0;
 398:                 flagf = 0;
 399:                 puke(strc);
 400:             }
 401:             if(p->key & EVEN && ev & 07) {
 402:                 printf("\t.=.+4\n");
 403:                 ev =+ 4;
 404:             }
 405:             ev =+ p->address - 300;
 406:         } else
 407:             printf("\n. = %d^.\n", p->address);
 408:         n = p->count;
 409:         if(n < 0)
 410:             n = -n;
 411:         for(i=0; i<n; i++)
 412:             if(p->key & KL) {
 413:                 printf(p->codea, nkl, nkl);
 414:                 nkl++;
 415:             } else
 416:             printf(p->codea, i, i);
 417:     }
 418:     if(flagb)
 419:         puke(strb);
 420:     puke(strd);
 421:     for(p=table; p->name; p++)
 422:     if(p->count != 0 && p->key & INTR)
 423:         printf("\n%s%s", p->codeb, p->codec);
 424:     flush();
 425:     close(fout);
 426: 
 427: /*
 428:  * pass 2 -- create configuration table
 429:  */
 430: 
 431:     fout = creat("c.c", 0666);
 432:     puke(stre);
 433:     for(i=0; q=btab[i]; i++) {
 434:         for(p=table; p->name; p++)
 435:         if(equal(q, p->name) &&
 436:            (p->key&BLOCK) && p->count) {
 437:             printf("%s\t/* %s */\n", p->coded, q);
 438:             if(p->key & ROOT)
 439:                 root = i;
 440:             goto newb;
 441:         }
 442:         printf("\t&nodev,\t\t&nodev,\t\t&nodev,\t\t0,\t/* %s */\n", q);
 443:     newb:;
 444:     }
 445:     puke(strf);
 446:     for(i=0; q=ctab[i]; i++) {
 447:         for(p=table; p->name; p++)
 448:         if(equal(q, p->name) &&
 449:            (p->key&CHAR) && p->count) {
 450:             printf("%s\t/* %s */\n", p->codee, q);
 451:             goto newc;
 452:         }
 453:         printf("\t&nodev,    &nodev,    &nodev,    &nodev,    &nodev,\t/* %s */\n", q);
 454:     newc:;
 455:     }
 456:     puke(strg, root);
 457:     flush();
 458:     close(fout);
 459:     if(root < 0)
 460:         write(2, "no block device given\n", 22);
 461: }
 462: 
 463: puke(s, a)
 464: char **s;
 465: {
 466:     char *c;
 467: 
 468:     while(c = *s++) {
 469:         printf(c, a);
 470:         printf("\n");
 471:     }
 472: }
 473: 
 474: input()
 475: {
 476:     char line[100];
 477:     register char *p;
 478:     register struct tab *q;
 479:     register n;
 480: 
 481:     p = line;
 482:     while((n=getchar()) != '\n') {
 483:         if(n == 0)
 484:             return(0);
 485:         if(n == ' ' || n == '\t')
 486:             continue;
 487:         *p++ = n;
 488:     }
 489:     *p++ = 0;
 490:     n = 0;
 491:     p = line;
 492:     while(*p>='0' && *p<='9') {
 493:         n =* 10;
 494:         n =+ *p++ - '0';
 495:     }
 496:     if(n == 0)
 497:         n = 1;
 498:     if(*p == 0)
 499:         return(1);
 500:     for(q=table; q->name; q++)
 501:     if(equal(q->name, p)) {
 502:         if(root < 0 && (q->key&BLOCK)) {
 503:             root = 0;
 504:             q->key =| ROOT;
 505:         }
 506:         if(q->count < 0) {
 507:             printf("%s: no more, no less\n", p);
 508:             return(1);
 509:         }
 510:         q->count =+ n;
 511:         if(q->address < 300 && q->count > 1) {
 512:             q->count = 1;
 513:             printf("%s: only one\n", p);
 514:         }
 515:         return(1);
 516:     }
 517:     if(equal(p, "done"))
 518:         return(0);
 519:     printf("%s: cannot find\n", p);
 520:     return(1);
 521: }
 522: 
 523: equal(a, b)
 524: char *a, *b;
 525: {
 526: 
 527:     while(*a++ == *b)
 528:         if(*b++ == 0)
 529:             return(1);
 530:     return(0);
 531: }
 532: 
 533: getchar()
 534: {
 535:     int c;
 536: 
 537:     c = 0;
 538:     read(0, &c, 1);
 539:     return(c);
 540: }

Defined functions

equal defined in line 523; used 4 times
getchar defined in line 533; used 1 times
input defined in line 474; used 1 times
main defined in line 373; never used
puke defined in line 463; used 8 times

Defined variables

btab defined in line 7; used 1 times
ctab defined in line 19; used 1 times
fout defined in line 370; used 4 times
root defined in line 371; used 5 times
stra defined in line 279; used 1 times
strb defined in line 309; used 2 times
strc defined in line 319; used 1 times
strd defined in line 327; used 1 times
stre defined in line 338; used 1 times
strf defined in line 348; used 1 times
strg defined in line 358; used 1 times
table defined in line 50; used 5 times

Defined struct's

tab defined in line 39; used 4 times

Defined macros

BLOCK defined in line 2; used 10 times
CHAR defined in line 1; used 17 times
EVEN defined in line 4; used 2 times
INTR defined in line 3; used 23 times
KL defined in line 5; used 4 times
ROOT defined in line 6; used 2 times
Last modified: 1975-07-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1158
Valid CSS Valid XHTML 1.0 Strict