1: #include <stdio.h>
   2: 
   3: #define CHAR    01
   4: #define BLOCK   02
   5: #define INTR    04
   6: #define EVEN    010
   7: #define KL  020
   8: #define ROOT    040
   9: #define SWAP    0100
  10: #define PIPE    0200
  11: 
  12: char    *btab[] =
  13: {
  14:     "rk",
  15:     "rp",
  16:     "rf",
  17:     "tm",
  18:     "tc",
  19:     "hs",
  20:     "hp",
  21:     "ht",
  22:     "rl",
  23:     0
  24: };
  25: char    *ctab[] =
  26: {
  27:     "console",
  28:     "pc",
  29:     "lp",
  30:     "dc",
  31:     "dh",
  32:     "dp",
  33:     "dj",
  34:     "dn",
  35:     "mem",
  36:     "rk",
  37:     "rf",
  38:     "rp",
  39:     "tm",
  40:     "hs",
  41:     "hp",
  42:     "ht",
  43:     "du",
  44:     "tty",
  45:     "rl",
  46:     0
  47: };
  48: struct tab
  49: {
  50:     char    *name;
  51:     int count;
  52:     int address;
  53:     int key;
  54:     char    *codea;
  55:     char    *codeb;
  56:     char    *codec;
  57:     char    *coded;
  58:     char    *codee;
  59:     char    *codef;
  60:     char    *codeg;
  61: } table[] =
  62: {
  63:     "console",
  64:     -1, 60, CHAR+INTR+KL,
  65:     "	klin; br4\n	klou; br4\n",
  66:     ".globl	_klrint\nklin:	jsr	r0,call; jmp _klrint\n",
  67:     ".globl	_klxint\nklou:	jsr	r0,call; jmp _klxint\n",
  68:     "",
  69:     "	klopen, klclose, klread, klwrite, klioctl, nulldev, 0,",
  70:     "",
  71:     "int	klopen(), klclose(), klread(), klwrite(), klioctl();",
  72: 
  73:     "mem",
  74:     -1, 300, CHAR,
  75:     "",
  76:     "",
  77:     "",
  78:     "",
  79:     "	nulldev, nulldev, mmread, mmwrite, nodev, nulldev, 0, ",
  80:     "",
  81:     "int	mmread(), mmwrite();",
  82: 
  83:     "pc",
  84:     0, 70, CHAR+INTR,
  85:     "	pcin; br4\n	pcou; br4\n",
  86:     ".globl	_pcrint\npcin:	jsr	r0,call; jmp _pcrint\n",
  87:     ".globl	_pcpint\npcou:	jsr	r0,call; jmp _pcpint\n",
  88:     "",
  89:     "	pcopen, pcclose, pcread, pcwrite, nodev, nulldev, 0, ",
  90:     "",
  91:     "int	pcopen(), pcclose(), pcread(), pcwrite();",
  92: 
  93:     "clock",
  94:     -2, 100, INTR,
  95:     "	kwlp; br6\n",
  96:     ".globl	_clock\n",
  97:     "kwlp:	jsr	r0,call; jmp _clock\n",
  98:     "",
  99:     "",
 100:     "",
 101:     "",
 102: 
 103:     "parity",
 104:     -1, 114, INTR,
 105:     "	trap; br7+7.		/ 11/70 parity\n",
 106:     "",
 107:     "",
 108:     "",
 109:     "",
 110:     "",
 111:     "",
 112: 
 113: /*
 114:  * 110 unused
 115:  * 114 memory parity
 116:  * 120 XY plotter
 117:  * 124 DR11-B
 118:  * 130 AD01 & RL01
 119: */
 120: 
 121:     "rl",
 122:     0, 130, BLOCK+CHAR+INTR,
 123:     "	rlio; br5\n",
 124:     ".globl	_rlintr\n",
 125:     "rlio:	jsr	r0,call; jmp _rlintr\n",
 126:     "	nulldev, nulldev, rlstrategy, &rltab,",
 127:     "	rlopen, rlclose, rlread, rlwrite, nodev, nulldev, 0,",
 128:     "int	rlstrategy();\nstruct	buf	rltab;",
 129:     "int	rlopen(), rlclose(), rlread(), rlwrite();",
 130: 
 131: /*
 132:  * 134 AFC11
 133:  * 140 AA11
 134:  * 144 AA11
 135:  * 150-174 unused
 136:  */
 137: 
 138:     "lp",
 139:     0, 200, CHAR+INTR,
 140:     "	lpou; br4\n",
 141:     "",
 142:     ".globl	_lpint\nlpou:	jsr	r0,call; jmp _lpint\n",
 143:     "",
 144:     "	lpopen, lpclose, nodev, lpwrite, nodev, nulldev, 0,",
 145:     "",
 146:     "int	lpopen(), lpclose(), lpwrite();",
 147: 
 148:     "rf",
 149:     0, 204, BLOCK+CHAR+INTR,
 150:     "	rfio; br5\n",
 151:     ".globl	_rfintr\n",
 152:     "rfio:	jsr	r0,call; jmp _rfintr\n",
 153:     "	nulldev, nulldev, rfstrategy, &rftab, ",
 154:     "	nulldev, nulldev, rfread, rfwrite, nodev, nulldev, 0,",
 155:     "int	rfstrategy();\nstruct	buf	rftab;",
 156:     "int	rfread(), rfwrite();",
 157: 
 158:     "hs",
 159:     0, 204, BLOCK+CHAR+INTR,
 160:     "	hsio; br5\n",
 161:     ".globl	_hsintr\n",
 162:     "hsio:	jsr	r0,call; jmp _hsintr\n",
 163:     "	nulldev, nulldev, hsstrategy, &hstab, ",
 164:     "	nulldev, nulldev, hsread, hswrite, nodev, nulldev, 0,",
 165:     "int	hsstrategy();\nstruct	buf	hstab;",
 166:     "int	hsread(), hswrite();",
 167: 
 168: /*
 169:  * 210 RC
 170:  */
 171: 
 172:     "tc",
 173:     0, 214, BLOCK+INTR,
 174:     "	tcio; br6\n",
 175:     ".globl	_tcintr\n",
 176:     "tcio:	jsr	r0,call; jmp _tcintr\n",
 177:     "	nulldev, tcclose, tcstrategy, &tctab,",
 178:     "",
 179:     "int	tcstrategy(), tcclose();\nstruct	buf	tctab;",
 180:     "",
 181: 
 182:     "rk",
 183:     0, 220, BLOCK+CHAR+INTR,
 184:     "	rkio; br5\n",
 185:     ".globl	_rkintr\n",
 186:     "rkio:	jsr	r0,call; jmp _rkintr\n",
 187:     "	nulldev, nulldev, rkstrategy, &rktab,",
 188:     "	nulldev, nulldev, rkread, rkwrite, nodev, nulldev, 0,",
 189:     "int	rkstrategy();\nstruct	buf	rktab;",
 190:     "int	rkread(), rkwrite();",
 191: 
 192:     "tm",
 193:     0, 224, BLOCK+CHAR+INTR,
 194:     "	tmio; br5\n",
 195:     ".globl	_tmintr\n",
 196:     "tmio:	jsr	r0,call; jmp _tmintr\n",
 197:     "	tmopen, tmclose, tmstrategy, &tmtab, ",
 198:     "	tmopen, tmclose, tmread, tmwrite, nodev, nulldev, 0,",
 199:     "int	tmopen(), tmclose(), tmstrategy();\nstruct	buf	tmtab;",
 200:     "int	tmread(), tmwrite();",
 201: 
 202:     "ht",
 203:     0, 224, BLOCK+CHAR+INTR,
 204:     "	htio; br5\n",
 205:     ".globl	_htintr\n",
 206:     "htio:	jsr	r0,call; jmp _htintr\n",
 207:     "	htopen, htclose, htstrategy, &httab,",
 208:     "	htopen, htclose, htread, htwrite, nodev, nulldev, 0,",
 209:     "int	htopen(), htclose(), htstrategy();\nstruct	buf	httab;",
 210:     "int	htread(), htwrite();",
 211: 
 212:     "cr",
 213:     0, 230, CHAR+INTR,
 214:     "	crin; br6\n",
 215:     "",
 216:     ".globl	_crint\ncrin:	jsr	r0,call; jmp _crint\n",
 217:     "",
 218:     "	cropen, crclose, crread, nodev, nodev, nulldev, 0,",
 219:     "",
 220:     "int	cropen(), crclose(), crread();",
 221: 
 222: /*
 223:  * 234 UDC11
 224:  */
 225: 
 226:     "rp",
 227:     0, 254, BLOCK+CHAR+INTR,
 228:     "	rpio; br5\n",
 229:     ".globl	_rpintr\n",
 230:     "rpio:	jsr	r0,call; jmp _rpintr\n",
 231:     "	nulldev, nulldev, rpstrategy, &rptab,",
 232:     "	nulldev, nulldev, rpread, rpwrite, nodev, nulldev, 0,",
 233:     "int	rpstrategy();\nstruct	buf	rptab;",
 234:     "int	rpread(), rpwrite();",
 235: 
 236:     "hp",
 237:     0, 254, BLOCK+CHAR+INTR,
 238:     "	hpio; br5\n",
 239:     ".globl	_hpintr\n",
 240:     "hpio:	jsr	r0,call; jmp _hpintr\n",
 241:     "	nulldev, nulldev, hpstrategy, &hptab,",
 242:     "	nulldev, nulldev, hpread, hpwrite, nodev, nulldev, 0,",
 243:     "int	hpstrategy();\nstruct	buf	hptab;",
 244:     "int	hpread(), hpwrite();",
 245: 
 246: /*
 247:  * 260 TA11
 248:  * 264-274 unused
 249:  */
 250: 
 251:     "dc",
 252:     0, 308, CHAR+INTR,
 253:     "	dcin; br5+%d.\n	dcou; br5+%d.\n",
 254:     ".globl	_dcrint\ndcin:	jsr	r0,call; jmp _dcrint\n",
 255:     ".globl	_dcxint\ndcou:	jsr	r0,call; jmp _dcxint\n",
 256:     "",
 257:     "	dcopen, dcclose, dcread, dcwrite, dcioctl, nulldev, dc11,",
 258:     "",
 259:     "int	dcopen(), dcclose(), dcread(), dcwrite(), dcioctl();\nstruct	tty	dc11[];",
 260: 
 261:     "kl",
 262:     0, 308, INTR+KL,
 263:     "	klin; br4+%d.\n	klou; br4+%d.\n",
 264:     "",
 265:     "",
 266:     "",
 267:     "",
 268:     "",
 269:     "",
 270: 
 271:     "dp",
 272:     0, 308, CHAR+INTR,
 273:     "	dpin; br6+%d.\n	dpou; br6+%d.\n",
 274:     ".globl	_dprint\ndpin:	jsr	r0,call; jmp _dprint\n",
 275:     ".globl	_dpxint\ndpou:	jsr	r0,call; jmp _dpxint\n",
 276:     "",
 277:     "	dpopen, dpclose, dpread, dpwrite, nodev, nulldev, 0,",
 278:     "",
 279:     "int	dpopen(), dpclose(), dpread(), dpwrite();",
 280: 
 281: /*
 282:  * DM11-A
 283:  */
 284: 
 285:     "dn",
 286:     0, 304, CHAR+INTR,
 287:     "	dnou; br5+%d.\n",
 288:     "",
 289:     ".globl	_dnint\ndnou:	jsr	r0,call; jmp _dnint\n",
 290:     "",
 291:     "	dnopen, dnclose, nodev, dnwrite, nodev, nulldev, 0,",
 292:     "",
 293:     "int	dnopen(), dnclose(), dnwrite();",
 294: 
 295:     "dhdm",
 296:     0, 304, INTR,
 297:     "	dmin; br4+%d.\n",
 298:     "",
 299:     ".globl	_dmint\ndmin:	jsr	r0,call; jmp _dmint\n",
 300:     "",
 301:     "",
 302:     "",
 303:     "",
 304: 
 305: /*
 306:  * DR11-A+
 307:  * DR11-C+
 308:  * PA611+
 309:  * PA611+
 310:  * DT11+
 311:  * DX11+
 312:  */
 313: 
 314:     "dl",
 315:     0, 308, INTR+KL,
 316:     "	klin; br4+%d.\n	klou; br4+%d.\n",
 317:     "",
 318:     "",
 319:     "",
 320:     "",
 321:     "",
 322:     "",
 323: 
 324: /*
 325:  * DJ11
 326:  */
 327: 
 328:     "dh",
 329:     0, 308, CHAR+INTR+EVEN,
 330:     "	dhin; br5+%d.\n	dhou; br5+%d.\n",
 331:     ".globl	_dhrint\ndhin:	jsr	r0,call; jmp _dhrint\n",
 332:     ".globl	_dhxint\ndhou:	jsr	r0,call; jmp _dhxint\n",
 333:     "",
 334:     "	dhopen, dhclose, dhread, dhwrite, dhioctl, dhstop, dh11,",
 335:     "",
 336:     "int	dhopen(), dhclose(), dhread(), dhwrite(), dhioctl(), dhstop();\nstruct	tty	dh11[];",
 337: 
 338: /*
 339:  * GT40
 340:  * LPS+
 341:  * DQ11
 342:  * KW11-W
 343:  */
 344: 
 345:     "du",
 346:     0, 308, CHAR+INTR,
 347:     "	duin; br6+%d.\n	duou; br6+%d.\n",
 348:     ".globl	_durint\nduin:	jsr	r0,call; jmp _durint\n",
 349:     ".globl	_duxint\nduou:	jsr	r0,call; jmp _duxint\n",
 350:     "",
 351:     "	duopen, duclose, duread, duwrite, nodev, nulldev, 0,",
 352:     "",
 353:     "int	duopen(), duclose(), duread(), duwrite();",
 354: 
 355:     "tty",
 356:     1, 0, CHAR,
 357:     "",
 358:     "",
 359:     "",
 360:     "",
 361:     "	syopen, nulldev, syread, sywrite, sysioctl, nulldev, 0,",
 362:     "",
 363:     "int	syopen(), syread(), sywrite(), sysioctl();",
 364: 
 365:     0
 366: };
 367: 
 368: char    *stra[] =
 369: {
 370:     "/ low core",
 371:     "",
 372:     ".data",
 373:     "ZERO:",
 374:     "",
 375:     "br4 = 200",
 376:     "br5 = 240",
 377:     "br6 = 300",
 378:     "br7 = 340",
 379:     "",
 380:     ". = ZERO+0",
 381:     "	br	1f",
 382:     "	4",
 383:     "",
 384:     "/ trap vectors",
 385:     "	trap; br7+0.		/ bus error",
 386:     "	trap; br7+1.		/ illegal instruction",
 387:     "	trap; br7+2.		/ bpt-trace trap",
 388:     "	trap; br7+3.		/ iot trap",
 389:     "	trap; br7+4.		/ power fail",
 390:     "	trap; br7+5.		/ emulator trap",
 391:     "	start;br7+6.		/ system  (overlaid by 'trap')",
 392:     "",
 393:     ". = ZERO+40",
 394:     ".globl	start, dump",
 395:     "1:	jmp	start",
 396:     "	jmp	dump",
 397:     "",
 398:     0,
 399: };
 400: 
 401: char    *strb[] =
 402: {
 403:     "",
 404:     ". = ZERO+240",
 405:     "	trap; br7+7.		/ programmed interrupt",
 406:     "	trap; br7+8.		/ floating point",
 407:     "	trap; br7+9.		/ segmentation violation",
 408:     0
 409: };
 410: 
 411: char    *strc[] =
 412: {
 413:     "",
 414:     "/ floating vectors",
 415:     ". = ZERO+300",
 416:     0,
 417: };
 418: 
 419: char    *strd[] =
 420: {
 421:     "",
 422:     "//////////////////////////////////////////////////////",
 423:     "/		interface code to C",
 424:     "//////////////////////////////////////////////////////",
 425:     "",
 426:     ".text",
 427:     ".globl	call, trap",
 428:     0
 429: };
 430: 
 431: char    *stre[] =
 432: {
 433:     "#include \"../h/param.h\"",
 434:     "#include \"../h/systm.h\"",
 435:     "#include \"../h/buf.h\"",
 436:     "#include \"../h/tty.h\"",
 437:     "#include \"../h/conf.h\"",
 438:     "#include \"../h/proc.h\"",
 439:     "#include \"../h/text.h\"",
 440:     "#include \"../h/dir.h\"",
 441:     "#include \"../h/user.h\"",
 442:     "#include \"../h/file.h\"",
 443:     "#include \"../h/inode.h\"",
 444:     "#include \"../h/acct.h\"",
 445:     "",
 446:     "int	nulldev();",
 447:     "int	nodev();",
 448:     0
 449: };
 450: 
 451: char    *stre1[] =
 452: {
 453:     "struct	bdevsw	bdevsw[] =",
 454:     "{",
 455:     0,
 456: };
 457: 
 458: char    *strf[] =
 459: {
 460:     "	0",
 461:     "};",
 462:     "",
 463:     0,
 464: };
 465: 
 466: char    *strf1[] =
 467: {
 468:     "",
 469:     "struct	cdevsw	cdevsw[] =",
 470:     "{",
 471:     0,
 472: };
 473: 
 474: char    strg[] =
 475: {
 476: "	0\n\
 477: };\n\
 478: int	rootdev	= makedev(%d, %d);\n\
 479: int	swapdev	= makedev(%d, %d);\n\
 480: int	pipedev = makedev(%d, %d);\n\
 481: int	nldisp = %d;\n\
 482: daddr_t	swplo	= %ld;\n\
 483: int	nswap	= %l;\n\
 484: "};
 485: 
 486: char    strg1[] =
 487: {
 488: "	\n\
 489: struct	buf	buf[NBUF];\n\
 490: struct	file	file[NFILE];\n\
 491: struct	inode	inode[NINODE];\n"
 492: };
 493: 
 494: char    *strg1a[] =
 495: {
 496:     "int	mpxchan();",
 497:     "int	(*ldmpx)() = mpxchan;",
 498:     0
 499: };
 500: 
 501: char    strg2[] =
 502: {
 503: "struct	proc	proc[NPROC];\n\
 504: struct	text	text[NTEXT];\n\
 505: struct	buf	bfreelist;\n\
 506: struct	acct	acctbuf;\n\
 507: struct	inode	*acctp;\n"
 508: };
 509: 
 510: char    *strh[] =
 511: {
 512:     "	0",
 513:     "};",
 514:     "",
 515:     "int	ttyopen(), ttyclose(), ttread(), ttwrite(), ttyinput(), ttstart();",
 516:     0
 517: };
 518: 
 519: char    *stri[] =
 520: {
 521:     "int	pkopen(), pkclose(), pkread(), pkwrite(), pkioctl(), pkrint(), pkxint();",
 522:     0
 523: };
 524: 
 525: char    *strj[] =
 526: {
 527:     "struct	linesw	linesw[] =",
 528:     "{",
 529:     "	ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput, ttstart, /* 0 */",
 530:     0
 531: };
 532: 
 533: char    *strk[] =
 534: {
 535:     "	pkopen, pkclose, pkread, pkwrite, pkioctl, pkrint, pkxint, /* 1 */",
 536:     0
 537: };
 538: 
 539: int pack;
 540: int mpx;
 541: int rootmaj = -1;
 542: int rootmin;
 543: int swapmaj = -1;
 544: int swapmin;
 545: int pipemaj = -1;
 546: int pipemin;
 547: long    swplo   = 4000;
 548: int nswap = 872;
 549: int pack;
 550: int nldisp = 1;
 551: 
 552: main()
 553: {
 554:     register struct tab *p;
 555:     register char *q;
 556:     int i, n, ev, nkl;
 557:     int flagf, flagb, dumpht;
 558: 
 559:     while(input());
 560: 
 561: /*
 562:  * pass1 -- create interrupt vectors
 563:  */
 564:     nkl = 0;
 565:     flagf = flagb = 1;
 566:     freopen("l.s", "w", stdout);
 567:     puke(stra);
 568:     ev = 0;
 569:     for(p=table; p->name; p++)
 570:     if(p->count != 0 && p->key & INTR) {
 571:         if(p->address>240 && flagb) {
 572:             flagb = 0;
 573:             puke(strb);
 574:         }
 575:         if(p->address >= 300) {
 576:             if(flagf) {
 577:                 ev = 0;
 578:                 flagf = 0;
 579:                 puke(strc);
 580:             }
 581:             if(p->key & EVEN && ev & 07) {
 582:                 printf("	.=.+4\n");
 583:                 ev += 4;
 584:             }
 585:             printf("/%s %o\n", p->name, 0300+ev);
 586:         } else
 587:             printf("\n. = ZERO+%d\n", p->address);
 588:         n = p->count;
 589:         if(n < 0)
 590:             n = -n;
 591:         for(i=0; i<n; i++) {
 592:             if(p->key & KL) {
 593:                 printf(p->codea, nkl, nkl);
 594:                 nkl++;
 595:             } else
 596:                 printf(p->codea, i, i);
 597:             if (p->address<300)
 598:                 fprintf(stderr, "%s at %d\n", p->name, p->address+4*i);
 599:             else
 600:                 fprintf(stderr, "%s at %o\n", p->name, 0300+ev);
 601:             ev += p->address - 300;
 602:         }
 603:     }
 604:     if(flagb)
 605:         puke(strb);
 606:     puke(strd);
 607:     for(p=table; p->name; p++)
 608:     if(p->count != 0 && p->key & INTR)
 609:         printf("\n%s%s", p->codeb, p->codec);
 610: 
 611: /*
 612:  * pass 2 -- create configuration table
 613:  */
 614: 
 615:     freopen("c.c", "w", stdout);
 616:     /*
 617: 	 * declarations
 618: 	 */
 619:     puke(stre);
 620:     for (i=0; q=btab[i]; i++) {
 621:         for (p=table; p->name; p++)
 622:         if (equal(q, p->name) &&
 623:            (p->key&BLOCK) && p->count && *p->codef)
 624:             printf("%s\n", p->codef);
 625:     }
 626:     puke(stre1);
 627:     for(i=0; q=btab[i]; i++) {
 628:         for(p=table; p->name; p++)
 629:         if(equal(q, p->name) &&
 630:            (p->key&BLOCK) && p->count) {
 631:             printf("%s	/* %s = %d */\n", p->coded, q, i);
 632:             if(p->key & ROOT)
 633:                 rootmaj = i;
 634:             if (p->key & SWAP)
 635:                 swapmaj = i;
 636:             if (p->key & PIPE)
 637:                 pipemaj = i;
 638:             goto newb;
 639:         }
 640:         printf("	nodev, nodev, nodev, 0, /* %s = %d */\n", q, i);
 641:     newb:;
 642:     }
 643:     if (swapmaj == -1) {
 644:         swapmaj = rootmaj;
 645:         swapmin = rootmin;
 646:     }
 647:     if (pipemaj == -1) {
 648:         pipemaj = rootmaj;
 649:         pipemin = rootmin;
 650:     }
 651:     puke(strf);
 652:     for (i=0; q=ctab[i]; i++) {
 653:         for (p=table; p->name; p++)
 654:         if (equal(q, p->name) &&
 655:            (p->key&CHAR) && p->count && *p->codeg)
 656:             printf("%s\n", p->codeg);
 657:     }
 658:     puke(strf1);
 659:     for(i=0; q=ctab[i]; i++) {
 660:         for(p=table; p->name; p++)
 661:         if(equal(q, p->name) &&
 662:            (p->key&CHAR) && p->count) {
 663:             printf("%s	/* %s = %d */\n", p->codee, q, i);
 664:             goto newc;
 665:         }
 666:         printf("	nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* %s = %d */\n", q, i);
 667:     newc:;
 668:     }
 669:     puke(strh);
 670:     if (pack) {
 671:         nldisp++;
 672:         puke(stri);
 673:     }
 674:     puke(strj);
 675:     if (pack)
 676:         puke(strk);
 677:     printf(strg, rootmaj, rootmin,
 678:         swapmaj, swapmin,
 679:         pipemaj, pipemin,
 680:         nldisp,
 681:         swplo, nswap);
 682:     printf(strg1);
 683:     if (!mpx)
 684:         puke(strg1a);
 685:     printf(strg2);
 686:     if(rootmaj < 0)
 687:         fprintf(stderr, "No root device given\n");
 688:     freopen("mch0.s", "w", stdout);
 689:     dumpht = 0;
 690:     for (i=0; table[i].name; i++) {
 691:         if (equal(table[i].name, "ht") && table[i].count)
 692:             dumpht = 1;
 693:     }
 694:     if (dumpht) {
 695:         printf("HTDUMP = 1\n");
 696:         printf("TUDUMP = 0\n");
 697:     } else {
 698:         printf("HTDUMP = 0\n");
 699:         printf("TUDUMP = 1\n");
 700:     }
 701: }
 702: 
 703: puke(s, a)
 704: char **s;
 705: {
 706:     char *c;
 707: 
 708:     while(c = *s++) {
 709:         printf(c, a);
 710:         printf("\n");
 711:     }
 712: }
 713: 
 714: input()
 715: {
 716:     char line[100];
 717:     register struct tab *q;
 718:     int count, n;
 719:     long num;
 720:     char keyw[32], dev[32];
 721: 
 722:     if (fgets(line, 100, stdin) == NULL)
 723:         return(0);
 724:     count = -1;
 725:     n = sscanf(line, "%d%s%s%ld", &count, keyw, dev, &num);
 726:     if (count == -1 && n>0) {
 727:         count = 1;
 728:         n++;
 729:     }
 730:     if (n<2)
 731:         goto badl;
 732:     for(q=table; q->name; q++)
 733:     if(equal(q->name, keyw)) {
 734:         if(q->count < 0) {
 735:             fprintf(stderr, "%s: no more, no less\n", keyw);
 736:             return(1);
 737:         }
 738:         q->count += count;
 739:         if(q->address < 300 && q->count > 1) {
 740:             q->count = 1;
 741:             fprintf(stderr, "%s: only one\n", keyw);
 742:         }
 743:         return(1);
 744:     }
 745:     if (equal(keyw, "nswap")) {
 746:         if (n<3)
 747:             goto badl;
 748:         if (sscanf(dev, "%ld", &num) <= 0)
 749:             goto badl;
 750:         nswap = num;
 751:         return(1);
 752:     }
 753:     if (equal(keyw, "swplo")) {
 754:         if (n<3)
 755:             goto badl;
 756:         if (sscanf(dev, "%ld", &num) <= 0)
 757:             goto badl;
 758:         swplo = num;
 759:         return(1);
 760:     }
 761:     if (equal(keyw, "pack")) {
 762:         pack++;
 763:         return(1);
 764:     }
 765:     if (equal(keyw, "mpx")) {
 766:         mpx++;
 767:         return(1);
 768:     }
 769:     if(equal(keyw, "done"))
 770:         return(0);
 771:     if (equal(keyw, "root")) {
 772:         if (n<4)
 773:             goto badl;
 774:         for (q=table; q->name; q++) {
 775:             if (equal(q->name, dev)) {
 776:                 q->key |= ROOT;
 777:                 rootmin = num;
 778:                 return(1);
 779:             }
 780:         }
 781:         fprintf(stderr, "Can't find root\n");
 782:         return(1);
 783:     }
 784:     if (equal(keyw, "swap")) {
 785:         if (n<4)
 786:             goto badl;
 787:         for (q=table; q->name; q++) {
 788:             if (equal(q->name, dev)) {
 789:                 q->key |= SWAP;
 790:                 swapmin = num;
 791:                 return(1);
 792:             }
 793:         }
 794:         fprintf(stderr, "Can't find swap\n");
 795:         return(1);
 796:     }
 797:     if (equal(keyw, "pipe")) {
 798:         if (n<4)
 799:             goto badl;
 800:         for (q=table; q->name; q++) {
 801:             if (equal(q->name, dev)) {
 802:                 q->key |= PIPE;
 803:                 pipemin = num;
 804:                 return(1);
 805:             }
 806:         }
 807:         fprintf(stderr, "Can't find pipe\n");
 808:         return(1);
 809:     }
 810:     fprintf(stderr, "%s: cannot find\n", keyw);
 811:     return(1);
 812: badl:
 813:     fprintf(stderr, "Bad line: %s", line);
 814:     return(1);
 815: }
 816: 
 817: equal(a, b)
 818: char *a, *b;
 819: {
 820:     return(!strcmp(a, b));
 821: }

Defined functions

equal defined in line 817; used 17 times
input defined in line 714; used 1 times
main defined in line 552; used 4 times
puke defined in line 703; used 14 times

Defined variables

btab defined in line 12; used 2 times
ctab defined in line 25; used 2 times
mpx defined in line 540; used 2 times
nldisp defined in line 550; used 2 times
nswap defined in line 548; used 2 times
pack defined in line 549; used 3 times
pipemaj defined in line 545; used 4 times
pipemin defined in line 546; used 3 times
rootmaj defined in line 541; used 5 times
rootmin defined in line 542; used 4 times
stra defined in line 368; used 1 times
strb defined in line 401; used 2 times
strc defined in line 411; used 1 times
strd defined in line 419; used 1 times
stre defined in line 431; used 1 times
stre1 defined in line 451; used 1 times
strf defined in line 458; used 1 times
strf1 defined in line 466; used 1 times
strg defined in line 474; used 1 times
strg1 defined in line 486; used 1 times
strg1a defined in line 494; used 1 times
strg2 defined in line 501; used 1 times
strh defined in line 510; used 1 times
stri defined in line 519; used 1 times
strj defined in line 525; used 1 times
strk defined in line 533; used 1 times
swapmaj defined in line 543; used 4 times
swapmin defined in line 544; used 3 times
swplo defined in line 547; used 2 times
table defined in line 61; used 13 times

Defined struct's

tab defined in line 48; used 4 times

Defined macros

BLOCK defined in line 4; used 11 times
CHAR defined in line 3; used 21 times
EVEN defined in line 6; used 2 times
INTR defined in line 5; used 25 times
KL defined in line 7; used 4 times
PIPE defined in line 10; used 2 times
ROOT defined in line 8; used 2 times
SWAP defined in line 9; used 2 times
Last modified: 1979-05-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1474
Valid CSS Valid XHTML 1.0 Strict