home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / sys / conf / new_mkconf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-17  |  32.0 KB  |  1,657 lines

  1. /*
  2.  * UNIX/v7m make configuration program (mkconf.c).
  3.  * Creates the files l.s, locore vectors and c.c, 
  4.  * configuration table.
  5.  * Vector addreses are assigned according to the fixed
  6.  * and floating vector rules, if non standard
  7.  * vectors exist the l.s file must be edited after the
  8.  * mkconf program has been run.
  9.  *
  10.  * Added rk06 & rk07 support.
  11.  * Added rm02/3 & ts11 support.
  12.  * Added A. P. Stettner's rl11 modificatons.
  13.  * Added dz11 support.
  14.  * Added improved core dump code,
  15.  * uses unibus map (if requried) to
  16.  * insure that all of memory is dumpped.
  17.  * Added "ov" declaration for overlay kernel.
  18.  * Added "nsid" declaration for no separate I/D space CPU.
  19.  * Added "nfp" declaration for excluding floating point support code.
  20.  * Added "|" for rx|rx2 and hs|ml.
  21.  * Added automatic configuration of the text
  22.  * overlay segments for the overlay kernel.
  23.  * Added "dump" declaration to select core dump tape
  24.  * and optionally specify dump tape CSR address.
  25.  *
  26.  * Fred Canter 8/20/81
  27.  *
  28.  ********************************************************
  29.  *                            *
  30.  * The TS11 vector is assigned to location 050, in      *
  31.  * order that the TS11 can function on a system which   *
  32.  * also has a TM11, see comments at the head of the     *
  33.  * TS11 driver "/sys/dev/ts.c" for an explaination.     *
  34.  *                            *
  35.  * The startup code copies the TS11 vector from 050 to  *
  36.  * 0224 or 0260 depending on the configuration.         *
  37.  *                            *
  38.  ********************************************************
  39.  */
  40.  
  41. #include <stdio.h>
  42.  
  43. #define    HT    01
  44. #define    TM    02
  45. #define    TS    03
  46. #define CHAR    01
  47. #define BLOCK    02
  48. #define INTR    04
  49. #define EVEN    010
  50. #define KL    020
  51. #define ROOT    040
  52. #define    SWAP    0100
  53. #define    PIPE    0200
  54.  
  55. char    *btab[] =
  56. {
  57.     "rk",
  58.     "rp",
  59.     "rf",
  60.     "tm",
  61.     "tc",
  62.     "hs|ml",
  63.     "hp",
  64.     "ht",
  65.     "rl",
  66.     "hk",
  67.     "ts",
  68.     "rx|rx2",
  69.     "hm",
  70.     0
  71. };
  72. char    *ctab[] =
  73. {
  74.     "console",
  75.     "pc",
  76.     "lp",
  77.     "dc",
  78.     "dh",
  79.     "dp",
  80.     "dj",
  81.     "dn",
  82.     "mem",
  83.     "rk",
  84.     "rf",
  85.     "rp",
  86.     "tm",
  87.     "hs|ml",
  88.     "hp",
  89.     "ht",
  90.     "du",
  91.     "tty",
  92.     "rl",
  93.     "hk",
  94.     "ts",
  95.     "dz",
  96.     "rx2",
  97.     "hm",
  98.     0
  99. };
  100. struct tab
  101. {
  102.     char    *name;
  103.     int    count;
  104.     int    address;
  105.     int    key;
  106.     char    *codea;
  107.     char    *codeb;
  108.     char    *codec;
  109.     char    *coded;
  110.     char    *codee;
  111.     char    *codef;
  112.     char    *codeg;
  113. } table[] =
  114. {
  115.     "ts",
  116.     0, 50, BLOCK+CHAR+INTR,
  117.     "    tsio; br5\n",
  118.     ".globl    _tsintr\n",
  119.     "tsio:    jsr    r0,call; jmp _tsintr\n",
  120.     "    tsopen, tsclose, tsstrategy, &tstab,",
  121.     "    tsopen, tsclose, tsread, tswrite, nodev, nulldev, 0,",
  122.     "int    tsopen(), tsclose(), tsstrategy();\nstruct    buf    tstab;",
  123.     "int    tsread(), tswrite();",
  124.  
  125.     "console",
  126.     -1, 60, CHAR+INTR+KL,
  127.     "    klin; br4\n    klou; br4\n",
  128.     ".globl    _klrint\nklin:    jsr    r0,call; jmp _klrint\n",
  129.     ".globl    _klxint\nklou:    jsr    r0,call; jmp _klxint\n",
  130.     "",
  131.     "    klopen, klclose, klread, klwrite, klioctl, nulldev, 0,",
  132.     "",
  133.     "int    klopen(), klclose(), klread(), klwrite(), klioctl();",
  134.  
  135.     "mem",
  136.     -1, 300, CHAR,
  137.     "",
  138.     "",
  139.     "",
  140.     "",
  141.     "    nulldev, nulldev, mmread, mmwrite, nodev, nulldev, 0, ",
  142.     "",
  143.     "int    mmread(), mmwrite();",
  144.  
  145.     "pc",
  146.     0, 70, CHAR+INTR,
  147.     "    pcin; br4\n    pcou; br4\n",
  148.     ".globl    _pcrint\npcin:    jsr    r0,call; jmp _pcrint\n",
  149.     ".globl    _pcpint\npcou:    jsr    r0,call; jmp _pcpint\n",
  150.     "",
  151.     "    pcopen, pcclose, pcread, pcwrite, nodev, nulldev, 0, ",
  152.     "",
  153.     "int    pcopen(), pcclose(), pcread(), pcwrite();",
  154.  
  155.     "clock",
  156.     -2, 100, INTR,
  157.     "    kwlp; br6\n",
  158.     ".globl    _clock\n",
  159.     "kwlp:    jsr    r0,call; jmp _clock\n",
  160.     "",
  161.     "",
  162.     "",
  163.     "",
  164.  
  165.     "parity",
  166.     -1, 114, INTR,
  167.     "    trap; br7+10.        / 11/70 parity\n",
  168.     "",
  169.     "",
  170.     "",
  171.     "",
  172.     "",
  173.     "",
  174.  
  175. /*
  176.  * 110 unused
  177.  * 114 memory parity
  178.  * 120 XY plotter
  179.  * 124 DR11-B
  180.  * 130 AD01
  181.  * 134 AFC11
  182.  * 140 AA11
  183.  * 144 AA11
  184.  */
  185.  
  186.     "hm",
  187.     0, 150, BLOCK+CHAR+INTR,
  188.     "    hmio; br5\n",
  189.     ".globl    _hmintr\n",
  190.     "hmio:    jsr    r0,call; jmp _hmintr\n",
  191.     "    nulldev, nulldev, hmstrategy, &hmtab,",
  192.     "    nulldev, nulldev, hmread, hmwrite, nodev, nulldev, 0,",
  193.     "int    hmstrategy();\nstruct    buf    hmtab;",
  194.     "int    hmread(), hmwrite();",
  195.  
  196. /*
  197.  * 154 unused
  198.  */
  199.  
  200.     "rl",
  201.     0, 160, BLOCK+CHAR+INTR,
  202.     "    rlio; br5\n",
  203.     ".globl    _rlintr\n",
  204.     "rlio:    jsr    r0,call; jmp _rlintr\n",
  205.     "    nulldev, nulldev, rlstrategy, &rltab,",
  206.     "    nulldev, nulldev, rlread, rlwrite, nodev, nulldev, 0,",
  207.     "int    rlstrategy();\nstruct    buf    rltab;",
  208.     "int    rlread(), rlwrite();",
  209.  
  210. /*
  211.  * 164-174 unused
  212.  */
  213.  
  214.     "lp",
  215.     0, 200, CHAR+INTR,
  216.     "    lpou; br4\n",
  217.     "",
  218.     ".globl    _lpintr\nlpou:    jsr    r0,call; jmp _lpintr\n",
  219.     "",
  220.     "    lpopen, lpclose, nodev, lpwrite, nodev, nulldev, 0,",
  221.     "",
  222.     "int    lpopen(), lpclose(), lpwrite();",
  223.  
  224.     "rf",
  225.     0, 204, BLOCK+CHAR+INTR,
  226.     "    rfio; br5\n",
  227.     ".globl    _rfintr\n",
  228.     "rfio:    jsr    r0,call; jmp _rfintr\n",
  229.     "    nulldev, nulldev, rfstrategy, &rftab, ",
  230.     "    nulldev, nulldev, rfread, rfwrite, nodev, nulldev, 0,",
  231.     "int    rfstrategy();\nstruct    buf    rftab;",
  232.     "int    rfread(), rfwrite();",
  233.  
  234.     "hs",
  235.     0, 204, BLOCK+CHAR+INTR,
  236.     "    hsio; br5\n",
  237.     ".globl    _hsintr\n",
  238.     "hsio:    jsr    r0,call; jmp _hsintr\n",
  239.     "    nulldev, nulldev, hsstrategy, &hstab, ",
  240.     "    nulldev, nulldev, hsread, hswrite, nodev, nulldev, 0,",
  241.     "int    hsstrategy();\nstruct    buf    hstab;",
  242.     "int    hsread(), hswrite();",
  243.  
  244.     "ml",
  245.     0, 204, BLOCK+CHAR+INTR,
  246.     "    mlio; br5\n",
  247.     ".globl    _mlintr\n",
  248.     "mlio:    jsr    r0,call; jmp _mlintr\n",
  249.     "    nulldev, nulldev, mlstrategy, &mltab, ",
  250.     "    nulldev, nulldev, mlread, mlwrite, nodev, nulldev, 0,",
  251.     "int    mlstrategy();\nstruct    buf    mltab;",
  252.     "int    mlread(), mlwrite();",
  253.  
  254. /*
  255.  * 210 RC
  256.  */
  257.  
  258.     "hk",
  259.     0, 210, BLOCK+CHAR+INTR,
  260.     "    hkio; br5\n",
  261.     ".globl    _hkintr\n",
  262.     "hkio:    jsr    r0,call; jmp _hkintr\n",
  263.     "    nulldev, nulldev, hkstrategy, &hktab,",
  264.     "    nulldev, nulldev, hkread, hkwrite, nodev, nulldev, 0,",
  265.     "int    hkstrategy();\nstruct    buf    hktab;",
  266.     "int    hkread(), hkwrite();",
  267.  
  268.     "tc",
  269.     0, 214, BLOCK+INTR,
  270.     "    tcio; br6\n",
  271.     ".globl    _tcintr\n",
  272.     "tcio:    jsr    r0,call; jmp _tcintr\n",
  273.     "    nulldev, tcclose, tcstrategy, &tctab,",
  274.     "",
  275.     "int    tcstrategy(), tcclose();\nstruct    buf    tctab;",
  276.     "",
  277.  
  278.     "rk",
  279.     0, 220, BLOCK+CHAR+INTR,
  280.     "    rkio; br5\n",
  281.     ".globl    _rkintr\n",
  282.     "rkio:    jsr    r0,call; jmp _rkintr\n",
  283.     "    nulldev, nulldev, rkstrategy, &rktab,",
  284.     "    nulldev, nulldev, rkread, rkwrite, nodev, nulldev, 0,",
  285.     "int    rkstrategy();\nstruct    buf    rktab;",
  286.     "int    rkread(), rkwrite();",
  287.  
  288.     "tm",
  289.     0, 224, BLOCK+CHAR+INTR,
  290.     "    tmio; br5\n",
  291.     ".globl    _tmintr\n",
  292.     "tmio:    jsr    r0,call; jmp _tmintr\n",
  293.     "    tmopen, tmclose, tmstrategy, &tmtab, ",
  294.     "    tmopen, tmclose, tmread, tmwrite, nodev, nulldev, 0,",
  295.     "int    tmopen(), tmclose(), tmstrategy();\nstruct    buf    tmtab;",
  296.     "int    tmread(), tmwrite();",
  297.  
  298.     "ht",
  299.     0, 224, BLOCK+CHAR+INTR,
  300.     "    htio; br5\n",
  301.     ".globl    _htintr\n",
  302.     "htio:    jsr    r0,call; jmp _htintr\n",
  303.     "    htopen, htclose, htstrategy, &httab,",
  304.     "    htopen, htclose, htread, htwrite, nodev, nulldev, 0,",
  305.     "int    htopen(), htclose(), htstrategy();\nstruct    buf    httab;",
  306.     "int    htread(), htwrite();",
  307.  
  308.     "cr",
  309.     0, 230, CHAR+INTR,
  310.     "    crin; br6\n",
  311.     "",
  312.     ".globl    _crint\ncrin:    jsr    r0,call; jmp _crint\n",
  313.     "",
  314.     "    cropen, crclose, crread, nodev, nodev, nulldev, 0,",
  315.     "",
  316.     "int    cropen(), crclose(), crread();",
  317.  
  318. /*
  319.  * 234 UDC11
  320.  */
  321.  
  322.     "rp",
  323.     0, 254, BLOCK+CHAR+INTR,
  324.     "    rpio; br5\n",
  325.     ".globl    _rpintr\n",
  326.     "rpio:    jsr    r0,call; jmp _rpintr\n",
  327.     "    nulldev, nulldev, rpstrategy, &rptab,",
  328.     "    nulldev, nulldev, rpread, rpwrite, nodev, nulldev, 0,",
  329.     "int    rpstrategy();\nstruct    buf    rptab;",
  330.     "int    rpread(), rpwrite();",
  331.  
  332.     "hp",
  333.     0, 254, BLOCK+CHAR+INTR,
  334.     "    hpio; br5\n",
  335.     ".globl    _hpintr\n",
  336.     "hpio:    jsr    r0,call; jmp _hpintr\n",
  337.     "    nulldev, nulldev, hpstrategy, &hptab,",
  338.     "    nulldev, nulldev, hpread, hpwrite, nodev, nulldev, 0,",
  339.     "int    hpstrategy();\nstruct    buf    hptab;",
  340.     "int    hpread(), hpwrite();",
  341.  
  342. /*
  343.  * 260 TA11 (alt TS11)
  344.  */
  345.  
  346.     "rx",
  347.     0, 264, BLOCK+INTR,
  348.     "    rxio; br5\n",
  349.     ".globl    _rxintr\n",
  350.     "rxio:    jsr    r0,call; jmp _rxintr\n",
  351.     "    rxopen, nulldev, rxstrategy, &rxtab,",
  352.     "",
  353.     "int    rxopen(), rxstrategy();\nstruct buf    rxtab;",
  354.     "",
  355.  
  356.     "rx2",
  357.     0, 264, BLOCK+CHAR+INTR,
  358.     "    rx2io; br5\n",
  359.     ".globl    _rx2intr\n",
  360.     "rx2io:    jsr    r0,call; jmp _rx2intr\n",
  361.     "    rx2open, nulldev, rx2strategy, &rx2tab,",
  362.     "    rx2open, nulldev, rx2read, rx2write, nodev, nulldev, 0,",
  363.     "int    rx2open(), rx2strategy();\nstruct    buf    rx2tab;",
  364.     "int    rx2read(), rx2write();",
  365.  
  366.     "dc",
  367.     0, 308, CHAR+INTR,
  368.     "    dcin; br5+%d.\n    dcou; br5+%d.\n",
  369.     ".globl    _dcrint\ndcin:    jsr    r0,call; jmp _dcrint\n",
  370.     ".globl    _dcxint\ndcou:    jsr    r0,call; jmp _dcxint\n",
  371.     "",
  372.     "    dcopen, dcclose, dcread, dcwrite, dcioctl, nulldev, dc11,",
  373.     "",
  374.     "int    dcopen(), dcclose(), dcread(), dcwrite(), dcioctl();\nstruct    tty    dc11[];",
  375.  
  376.     "kl",
  377.     0, 308, INTR+KL,
  378.     "    klin; br4+%d.\n    klou; br4+%d.\n",
  379.     "",
  380.     "",
  381.     "",
  382.     "",
  383.     "",
  384.     "",
  385.  
  386.     "dp",
  387.     0, 308, CHAR+INTR,
  388.     "    dpin; br6+%d.\n    dpou; br6+%d.\n",
  389.     ".globl    _dprint\ndpin:    jsr    r0,call; jmp _dprint\n",
  390.     ".globl    _dpxint\ndpou:    jsr    r0,call; jmp _dpxint\n",
  391.     "",
  392.     "    dpopen, dpclose, dpread, dpwrite, nodev, nulldev, 0,",
  393.     "",
  394.     "int    dpopen(), dpclose(), dpread(), dpwrite();",
  395.  
  396. /*
  397.  * DM11-A
  398.  */
  399.  
  400.     "dn",
  401.     0, 304, CHAR+INTR,
  402.     "    dnou; br5+%d.\n",
  403.     "",
  404.     ".globl    _dnint\ndnou:    jsr    r0,call; jmp _dnint\n",
  405.     "",
  406.     "    dnopen, dnclose, nodev, dnwrite, nodev, nulldev, 0,",
  407.     "",
  408.     "int    dnopen(), dnclose(), dnwrite();",
  409.  
  410.     "dhdm",
  411.     0, 304, INTR,
  412.     "    dmin; br4+%d.\n",
  413.     "",
  414.     ".globl    _dmint\ndmin:    jsr    r0,call; jmp _dmint\n",
  415.     "",
  416.     "",
  417.     "",
  418.     "",
  419.  
  420. /*
  421.  * DR11-A+
  422.  * DR11-C+
  423.  * PA611+
  424.  * PA611+
  425.  * DT11+
  426.  * DX11+
  427.  */
  428.  
  429.     "dl",
  430.     0, 308, INTR+KL,
  431.     "    klin; br4+%d.\n    klou; br4+%d.\n",
  432.     "",
  433.     "",
  434.     "",
  435.     "",
  436.     "",
  437.     "",
  438.  
  439. /*
  440.  * DJ11
  441.  */
  442.  
  443.     "dh",
  444.     0, 308, CHAR+INTR+EVEN,
  445.     "    dhin; br5+%d.\n    dhou; br5+%d.\n",
  446.     ".globl    _dhrint\ndhin:    jsr    r0,call; jmp _dhrint\n",
  447.     ".globl    _dhxint\ndhou:    jsr    r0,call; jmp _dhxint\n",
  448.     "",
  449.     "    dhopen, dhclose, dhread, dhwrite, dhioctl, dhstop, dh11,",
  450.     "",
  451.     "int    dhopen(), dhclose(), dhread(), dhwrite(), dhioctl(), dhstop();\nstruct    tty    dh11[];",
  452.  
  453. /*
  454.  * GT40
  455.  * LPS+
  456.  * DQ11
  457.  * KW11-W
  458.  */
  459.  
  460.     "du",
  461.     0, 308, CHAR+INTR,
  462.     "    duin; br6+%d.\n    duou; br6+%d.\n",
  463.     ".globl    _durint\nduin:    jsr    r0,call; jmp _durint\n",
  464.     ".globl    _duxint\nduou:    jsr    r0,call; jmp _duxint\n",
  465.     "",
  466.     "    duopen, duclose, duread, duwrite, nodev, nulldev, 0,",
  467.     "",
  468.     "int    duopen(), duclose(), duread(), duwrite();",
  469.  
  470. /*
  471.  * DUP11
  472.  * DV11
  473.  * LK11-A
  474.  * DMC11
  475.  */
  476.  
  477.     "dz",
  478.     0, 308, CHAR+INTR+EVEN,
  479.     "    dzin; br5+%d.\n    dzou; br5+%d.\n",
  480.     ".globl _dzrint\ndzin:    jsr    r0,call; jmp _dzrint\n",
  481.     ".globl _dzxint\ndzou:    jsr    r0,call; jmp _dzxint\n",
  482.     "",
  483.     "    dzopen, dzclose, dzread, dzwrite, dzioctl, nulldev, dz_tty,",
  484.     "",
  485.     "int    dzopen(), dzclose(), dzread(), dzwrite(), dzioctl();\nstruct    tty    dz_tty[];",
  486.  
  487.     "tty",
  488.     1, 0, CHAR,
  489.     "",
  490.     "",
  491.     "",
  492.     "",
  493.     "    syopen, nulldev, syread, sywrite, sysioctl, nulldev, 0,",
  494.     "",
  495.     "int    syopen(), syread(), sywrite(), sysioctl();",
  496.  
  497.     0
  498. };
  499.  
  500. /*
  501.  * The ovtab structure describes each of the modules
  502.  * used to make the overlay text segments of the
  503.  * overlay kernel.
  504.  * The order of appearance of the modules in this
  505.  * structure is critical and must not be changed.
  506.  */
  507.  
  508. struct    ovtab
  509. {
  510.     char    *mn;        /* object module name */
  511.     int    mc;        /* non-zero if module is configured */
  512.                 /* some modules are always configured, */
  513.                 /* others are keyed from COUNT */
  514.                 /* field of structure "table" above */
  515.     int    ovno;        /* initial overlay number, */
  516.                 /* may be changed later */
  517.     int    mts;        /* module text size in bytes */
  518.     char    *mpn;        /* module full path name */
  519. } ovt [] =
  520. {
  521. /*
  522.  *    overlay 1
  523.  * Mostly system calls, will be added to later.
  524.  * Mem driver is about the only thing that
  525.  * will fit.
  526.  * This overlay should be as full as possible,
  527.  * so as not to waste memory space.
  528.  */
  529.     "pipe",
  530.     1, 1, -1,
  531.     "\t../ovsys/pipe.o \\",
  532.     "sys1",
  533.     1, 1, -1,
  534.     "\t../ovsys/sys1.o \\",
  535.     "sys2",
  536.     1, 1, -1,
  537.     "\t../ovsys/sys2.o \\",
  538.     "sys3",
  539.     1, 1, -1,
  540.     "\t../ovsys/sys3.o \\",
  541.     "sys4",
  542.     1, 1, -1,
  543.     "\t../ovsys/sys4.o \\",
  544.     "text",
  545.     1, 1, -1,
  546.     "\t../ovsys/text.o \\",
  547. /*
  548.  *    overlay 2
  549.  * This overlay contains some system stuff
  550.  * plus bio, will be filled in with tape drivers
  551.  * and what ever else will fit.
  552.  */
  553.     "acct",
  554.     1, 2, -1,
  555.     "\t../ovsys/acct.o \\",
  556.     "main",
  557.     1, 2, -1,
  558.     "\t../ovsys/main.o \\",
  559.     "machdep",
  560.     1, 2, -1,
  561.     "\t../ovsys/machdep.o \\",
  562.     "sig",
  563.     1, 2, -1,
  564.     "\t../ovsys/sig.o \\",
  565.     "bio",
  566.     1, 2, -1,
  567.     "\t../ovdev/bio.o \\",
  568. /*
  569.  *    overlay 3
  570.  * This overlay has the big disk drivers and the
  571.  * disk sort routines. These drivers may not be
  572.  * configured, but in any case this overlay will
  573.  * get as much as possible of the overflow from
  574.  * overlays 1 & 2.
  575.  *
  576.  * If all three disk drivers are configured (hp, hk, & hm)
  577.  * this overlay would overflow, in that case "hm" is
  578.  * changed to overlay 8 on the fly and loaded where ever it
  579.  * will fit on the next pass.
  580.  */
  581.     "hp",
  582.     0, 3, -1,
  583.     "\t../ovdev/hp.o \\",
  584.     "hk",
  585.     0, 3, -1,
  586.     "\t../ovdev/hk.o \\",
  587.     "hm",
  588.     0, 3, -1,
  589.     "\t../ovdev/hm.o \\",
  590.     "dsort",
  591.     0, 3, -1,
  592.     "\t../ovdev/dsort.o \\",
  593.     "dkleave",
  594.     0, 3, -1,
  595.     "\t../ovdev/dkleave.o \\",
  596.  
  597. /*
  598.  *    overlay 4
  599.  * Initially empty, will be filled in with
  600.  * overflow from previous overlays.
  601.  */
  602.  
  603. /*
  604.  *    overlay 5
  605.  * The overlay holds most of the tty drivers and
  606.  * associated routines, not much room for fill.
  607.  */
  608.     "tty",
  609.     1, 5, -1,
  610.     "\t../ovdev/tty.o \\",
  611.     "sys",
  612.     1, 5, -1,
  613.     "\t../ovdev/sys.o \\",
  614.     "kl",
  615.     1, 5, -1,
  616.     "\t../ovdev/kl.o \\",
  617.     "dz",
  618.     0, 5, -1,
  619.     "\t../ovdev/dz.o \\",
  620.     "dhdm",
  621.     0, 5, -1,
  622.     "\t../ovdev/dhdm.o \\",
  623.     "dh",
  624.     0, 5, -1,
  625.     "\t../ovdev/dh.o \\",
  626.     "dhfdm",
  627.     0, 5, -1,
  628.     "\t../ovdev/dhfdm.o \\",
  629.     "partab",
  630.     1, 5, -1,
  631.     "\t../ovdev/partab.o \\",
  632.     "prim",
  633.     1, 5, -1,
  634.     "\t../ovsys/prim.o \\",
  635. /*
  636.  *    overlay 6
  637.  * Contains the packet driver stuff.
  638.  * It could hold overflow from previous
  639.  * overlays if necessary.
  640.  */
  641.     "pk0",
  642.     0, 6, -1,
  643.     "\t../ovdev/pk0.o \\",
  644.     "pk1",
  645.     0, 6, -1,
  646.     "\t../ovdev/pk1.o \\",
  647.     "pk2",
  648.     0, 6, -1,
  649.     "\t../ovdev/pk2.o \\",
  650.     "pk3",
  651.     0, 6, -1,
  652.     "\t../ovdev/pk3.o \\",
  653. /*
  654.  *    overlay 7
  655.  * Contains the multiplexed files stuff.
  656.  * could also hold overflow.
  657.  */
  658.     "mx1",
  659.     0, 7, -1,
  660.     "\t../ovdev/mx1.o \\",
  661.     "mx2",
  662.     0, 7, -1,
  663.     "\t../ovdev/mx2.o \\",
  664. /*
  665.  *    overlay 8
  666.  * This is not a real overlay, all of the
  667.  * modules here will be used to fill out
  668.  * overlays 1 thru 7.
  669.  * Contains the mem driver, the HM disk driver,
  670.  * and the magtape drivers.
  671.  */
  672.     "mem",
  673.     1, 8, -1,
  674.     "\t../ovdev/mem.o \\",
  675.     "ts",
  676.     0, 8, -1,
  677.     "\t../ovdev/ts.o \\",
  678.     "ht",
  679.     0, 8, -1,
  680.     "\t../ovdev/ht.o \\",
  681.     "tm",
  682.     0, 8, -1,
  683.     "\t../ovdev/tm.o \\",
  684.     "tc",
  685.     0, 8, -1,
  686.     "\t../ovdev/tc.o \\",
  687. /*
  688.  *    overlay 9
  689.  * Again not a real overlay, used to fill others.
  690.  * Contains all smaller disk drivers.
  691.  */
  692.     "ml",
  693.     0, 9, -1,
  694.     "\t../ovdev/ml.o \\",
  695.     "hs",
  696.     0, 9, -1,
  697.     "\t../ovdev/hs.o \\",
  698.     "rp",
  699.     0, 9, -1,
  700.     "\t../ovdev/rp.o \\",
  701.     "rx2",
  702.     0, 9, -1,
  703.     "\t../ovdev/rx2.o \\",
  704.     "rl",
  705.     0, 9, -1,
  706.     "\t../ovdev/rl.o \\",
  707.     "rk",
  708.     0, 9, -1,
  709.     "\t../ovdev/rk.o \\",
  710.     "rf",
  711.     0, 9, -1,
  712.     "\t../ovdev/rf.o \\",
  713. /*
  714.  *    overlay 10
  715.  * Also not a real overlay, used to fill others.
  716.  * Contains LP driver and misc. comm. device drivers.
  717.  */
  718.     "lp",
  719.     0, 10, -1,
  720.     "\t../ovdev/lp.o \\",
  721.     "du",
  722.     0, 10, -1,
  723.     "\t../ovdev/du.o \\",
  724.     "dn",
  725.     0, 10, -1,
  726.     "\t../ovdev/dn.o \\",
  727.     "dc",
  728.     0, 10, -1,
  729.     "\t../ovdev/dc.o \\",
  730.     "cat",
  731.     0, 10, -1,
  732.     "\t../ovdev/cat.o \\",
  733.     "vp",
  734.     0, 10, -1,
  735.     "\t../ovdev/vp.o \\",
  736.     "vs",
  737.     0, 10, -1,
  738.     "\t../ovdev/vs.o \\",
  739.     0
  740. };
  741.  
  742. /*
  743.  * The ovdtab is an array of structures which
  744.  * describe the actual overlays as they will
  745.  * appear in the "ovload" overlay load file.
  746.  * The first structure (overlay 0) is never used.
  747.  */
  748.  
  749. struct    ovdes
  750. {
  751.     int    nentry;        /* number of modules in this overlay */
  752.     int    size;        /* total size of this overlay in bytes */
  753.     char    *omns[12];    /* pointers to module pathname strings */
  754. } ovdtab [8];
  755.  
  756. char    *stra40[] =
  757. {
  758.     "/ low core",
  759.     "",
  760.     0
  761. };
  762.  
  763. char    *stra70[] =
  764. {
  765.     "/ low core",
  766.     "",
  767.     ".data",
  768.     0
  769. };
  770.  
  771. char    *stra[] =
  772. {
  773.     "ZERO:",
  774.     "",
  775.     "br4 = 200",
  776.     "br5 = 240",
  777.     "br6 = 300",
  778.     "br7 = 340",
  779.     "",
  780.     ". = ZERO+0",
  781.     "    br    1f",
  782.     "    4",
  783.     "",
  784.     "/ trap vectors",
  785.     "    trap; br7+0.        / bus error",
  786.     "    trap; br7+1.        / illegal instruction",
  787.     "    trap; br7+2.        / bpt-trace trap",
  788.     "    trap; br7+3.        / iot trap",
  789.     "    trap; br7+4.        / power fail",
  790.     "    trap; br7+5.        / emulator trap",
  791.     "    start;br7+6.        / system  (overlaid by 'trap')",
  792.     "",
  793.     ". = ZERO+40",
  794.     ".globl    start, dump",
  795.     "1:    jmp    start",
  796.     "",
  797.     0,
  798. };
  799.  
  800. char    *strb[] =
  801. {
  802.     "",
  803.     ". = ZERO+240",
  804.     "    trap; br7+7.        / programmed interrupt",
  805.     "    trap; br7+8.        / floating point",
  806.     "    trap; br7+9.        / segmentation violation",
  807.     0
  808. };
  809.  
  810. char    *strc[] =
  811. {
  812.     "",
  813.     "/ floating vectors",
  814.     ". = ZERO+300",
  815.     0,
  816. };
  817.  
  818. char    *strov[] =
  819. {
  820.     "",
  821.     "/ overlay descriptor tables",
  822.     "",
  823.     ".globl ova, ovd, ovend",
  824.     "ova:\t.=.+16.\t/ overlay addresses",
  825.     "ovd:\t.=.+16.\t/ overlay sizes",
  826.     "ovend:\t.=.+2\t/ end of overlays",
  827.     0
  828. };
  829.  
  830. char    *sizcmd = {"size ../ovsys/*.o ../ovdev/*.o > text.sizes"};
  831. char    *cmcmd = {"chmod 744 ovload"};
  832.  
  833. char    *strovh[] =
  834. {
  835.     "covld -X -n -o unix_ov l.o mch_ov.o c_ov.o \\",
  836.     0,
  837. };
  838.  
  839. char    *strovl[] =
  840. {
  841.     "-L \\",
  842.     "\t../ovsys/LIB1_ov",
  843.     0,
  844. };
  845.  
  846. char    *strovz[] =
  847. {
  848.     "-Z \\",
  849.     0,
  850. };
  851.  
  852. char    *strd[] =
  853. {
  854.     "",
  855.     "//////////////////////////////////////////////////////",
  856.     "/        interface code to C",
  857.     "//////////////////////////////////////////////////////",
  858.     "",
  859.     ".text",
  860.     ".globl    call, trap",
  861.     0
  862. };
  863.  
  864. char    *stre[] =
  865. {
  866.     "#include \"../h/param.h\"",
  867.     "#include \"../h/systm.h\"",
  868.     "#include \"../h/buf.h\"",
  869.     "#include \"../h/tty.h\"",
  870.     "#include \"../h/conf.h\"",
  871.     "#include \"../h/proc.h\"",
  872.     "#include \"../h/text.h\"",
  873.     "#include \"../h/dir.h\"",
  874.     "#include \"../h/user.h\"",
  875.     "#include \"../h/file.h\"",
  876.     "#include \"../h/inode.h\"",
  877.     "#include \"../h/acct.h\"",
  878.     "",
  879.     "int    nulldev();",
  880.     "int    nodev();",
  881.     0
  882. };
  883.  
  884. char    *stre1[] =
  885. {
  886.     "struct    bdevsw    bdevsw[] =",
  887.     "{",
  888.     0,
  889. };
  890.  
  891. char    *strf[] =
  892. {
  893.     "    0",
  894.     "};",
  895.     "",
  896.     0,
  897. };
  898.  
  899. char    *strf1[] =
  900. {
  901.     "",
  902.     "struct    cdevsw    cdevsw[] =",
  903.     "{",
  904.     0,
  905. };
  906.  
  907. char    strg[] =
  908. {
  909. "    0\n\
  910. };\n\
  911. int    rootdev    = makedev(%d, %d);\n\
  912. int    swapdev    = makedev(%d, %d);\n\
  913. int    pipedev = makedev(%d, %d);\n\
  914. int    nldisp = %d;\n\
  915. daddr_t    swplo    = %ld;\n\
  916. int    nswap    = %l;\n\
  917. "};
  918.  
  919. char    strg1[] =
  920. {
  921. "    \n\
  922. struct    buf    buf[NBUF];\n\
  923. struct    file    file[NFILE];\n\
  924. struct    inode    inode[NINODE];\n"
  925. };
  926.  
  927. char    *strg1a[] =
  928. {
  929.     "#ifdef\tMX",
  930.     "int    mpxchan();",
  931.     "int    (*ldmpx)() = mpxchan;",
  932.     "#endif\tMX",
  933.     0
  934. };
  935.  
  936. char    strg2[] =
  937. {
  938. "struct    proc    proc[NPROC];\n\
  939. struct    text    text[NTEXT];\n\
  940. struct    buf    bfreelist;\n\
  941. struct    acct    acctbuf;\n\
  942. struct    inode    *acctp;\n"
  943. };
  944.  
  945. char    *strg3[] =
  946. {
  947.     "",
  948.     "/*",
  949.     " * The following locations are used by commands",
  950.     " * like ps & pstat to free them from param.h",
  951.     " */",
  952.     "",
  953.     "int    nproc    NPROC;",
  954.     "int    ninode    NINODE;",
  955.     "int    ntext    NTEXT;",
  956.     "int    nofile    NOFILE;",
  957.     "int    nsig    NSIG;",
  958.     "int    nfile    NFILE;",
  959.     0
  960. };
  961.  
  962. char    *strh[] =
  963. {
  964.     "    0",
  965.     "};",
  966.     "",
  967.     "int    ttyopen(), ttyclose(), ttread(), ttwrite(), ttyinput(), ttstart();",
  968.     0
  969. };
  970.  
  971. char    *stri[] =
  972. {
  973.     "int    pkopen(), pkclose(), pkread(), pkwrite(), pkioctl(), pkrint(), pkxint();",
  974.     0
  975. };
  976.  
  977. char    *strj[] =
  978. {
  979.     "struct    linesw    linesw[] =",
  980.     "{",
  981.     "    ttyopen, nulldev, ttread, ttwrite, nodev, ttyinput, ttstart, /* 0 */",
  982.     0
  983. };
  984.  
  985. char    *strk[] =
  986. {
  987.     "    pkopen, pkclose, pkread, pkwrite, pkioctl, pkrint, pkxint, /* 1 */",
  988.     0
  989. };
  990.  
  991. int    mpx;
  992. int    ov;
  993. int    nsid;
  994. int    nfp;
  995. int    dump;
  996. int    cdcsr;
  997. int    rootmaj = -1;
  998. int    rootmin;
  999. int    swapmaj = -1;
  1000. int    swapmin;
  1001. int    pipemaj = -1;
  1002. int    pipemin;
  1003. long    swplo    = 4000;
  1004. int    nswap = 872;
  1005. int    pack;
  1006. int    nldisp = 1;
  1007.  
  1008. char    trash[100];
  1009. char    omn[20];
  1010. char    mtsize[20];
  1011.  
  1012. main()
  1013. {
  1014.     register struct tab *p;
  1015.     struct    ovtab    *otp;
  1016.     struct    ovdes    *ovdp;
  1017.     register char *q;
  1018.     char    *c;
  1019.     int i, n, ev, nkl;
  1020.     int flagf, flagb;
  1021.     int dumpht, dumptm, dumpts;
  1022.     int fi, ovcnt;
  1023.  
  1024.     while(input());
  1025.  
  1026. /*
  1027.  * pass1 -- create interrupt vectors
  1028.  */
  1029.     fprintf(stderr, "\n");
  1030.     if(ov)
  1031.         fprintf(stderr, "(overlay kernel specified)\n");
  1032.     if(ov && nsid)
  1033.         fprintf(stderr, "(ov & nsid specified, nsid ignored)\n");
  1034.     else if(nsid)
  1035.         fprintf(stderr, "(non-separate I/D space CPU specified)\n");
  1036.     if(nfp)
  1037.         fprintf(stderr, "(floating point support excluded)\n");
  1038.     nkl = 0;
  1039.     flagf = flagb = 1;
  1040.     freopen("l.s", "w", stdout);
  1041.     if(!ov && !nsid)
  1042.         puke(stra70);
  1043.     else
  1044.         puke(stra40);
  1045.     puke(stra);
  1046.     ev = 0;
  1047.     for(p=table; p->name; p++)
  1048.     if(p->count != 0 && p->key & INTR) {
  1049.         if(p->address>240 && flagb) {
  1050.             flagb = 0;
  1051.             puke(strb);
  1052.         }
  1053.         if(p->address >= 300) {
  1054.             if(flagf) {
  1055.                 ev = 0;
  1056.                 flagf = 0;
  1057.                 puke(strc);
  1058.             }
  1059.             if(p->key & EVEN && ev & 07) {
  1060.                 printf("    .=.+4\n");
  1061.                 ev += 4;
  1062.             }
  1063.             printf("/%s %o\n", p->name, 0300+ev);
  1064.         } else
  1065.             printf("\n. = ZERO+%d\n", p->address);
  1066.         n = p->count;
  1067.         if(n < 0)
  1068.             n = -n;
  1069.         for(i=0; i<n; i++) {
  1070.             if(p->key & KL) {
  1071.                 printf(p->codea, nkl, nkl);
  1072.                 nkl++;
  1073.             } else
  1074.                 printf(p->codea, i, i);
  1075.             if (p->address<300) {
  1076.                 fprintf(stderr, "%s at %d", p->name, p->address+4*i);
  1077.                 if (equal(p->name, "ts"))
  1078.                     fprintf(stderr, "   (TS auto-config)");
  1079.                 fprintf(stderr, "\n");
  1080.             } else
  1081.                 fprintf(stderr, "%s at %o\n", p->name, 0300+ev);
  1082.             ev += p->address - 300;
  1083.         }
  1084.     }
  1085.     if(flagb)
  1086.         puke(strb);
  1087. /*
  1088.  * TS11 auto vector select
  1089.  *
  1090.  * Text must not be allowed to start at
  1091.  * an address that is less than 0300.
  1092.  * The vector at 0260 must be initialized to
  1093.  * zero for the TS11 auto vector
  1094.  * select to function.
  1095.  * With the advent of v7m 2.0, text does not
  1096.  * ever start before 1000.
  1097.  */
  1098.  
  1099.     printf("\n. = ZERO+1000\n");
  1100.     printf("\n\tjmp\tdump\t/ jump to core dump code\n");
  1101.     if(ov)
  1102.         puke(strov);
  1103.     puke(strd);
  1104.     for(p=table; p->name; p++)
  1105.     if(p->count != 0 && p->key & INTR)
  1106.         printf("\n%s%s", p->codeb, p->codec);
  1107.  
  1108. /*
  1109.  * pass 2 -- create configuration table
  1110.  */
  1111.  
  1112.     freopen("c.c", "w", stdout);
  1113.     /*
  1114.      * declarations
  1115.      */
  1116.     puke(stre);
  1117.     for (i=0; q=btab[i]; i++) {
  1118.         for (p=table; p->name; p++)
  1119.         if (match(q, p->name) &&
  1120.            (p->key&BLOCK) && p->count && *p->codef)
  1121.             printf("%s\n", p->codef);
  1122.     }
  1123.     puke(stre1);
  1124.     for(i=0; q=btab[i]; i++) {
  1125.         for(p=table; p->name; p++)
  1126.         if(match(q, p->name) &&
  1127.            (p->key&BLOCK) && p->count) {
  1128.             printf("%s    /* %s = %d */\n", p->coded, p->name, i);
  1129.             if(p->key & ROOT)
  1130.                 rootmaj = i;
  1131.             if (p->key & SWAP)
  1132.                 swapmaj = i;
  1133.             if (p->key & PIPE)
  1134.                 pipemaj = i;
  1135.             goto newb;
  1136.         }
  1137.         printf("    nodev, nodev, nodev, 0, /* %s = %d */\n", q, i);
  1138.     newb:;
  1139.     }
  1140.     if (swapmaj == -1) {
  1141.         swapmaj = rootmaj;
  1142.         swapmin = rootmin;
  1143.     }
  1144.     if (pipemaj == -1) {
  1145.         pipemaj = rootmaj;
  1146.         pipemin = rootmin;
  1147.     }
  1148.     puke(strf);
  1149.     for (i=0; q=ctab[i]; i++) {
  1150.         for (p=table; p->name; p++)
  1151.         if (match(q, p->name) &&
  1152.            (p->key&CHAR) && p->count && *p->codeg)
  1153.             printf("%s\n", p->codeg);
  1154.     }
  1155.     puke(strf1);
  1156.     for(i=0; q=ctab[i]; i++) {
  1157.         for(p=table; p->name; p++)
  1158.         if(match(q, p->name) &&
  1159.            (p->key&CHAR) && p->count) {
  1160.             printf("%s    /* %s = %d */\n", p->codee, p->name, i);
  1161.             goto newc;
  1162.         }
  1163.         printf("    nodev, nodev, nodev, nodev, nodev, nulldev, 0, /* %s = %d */\n", q, i);
  1164.     newc:;
  1165.     }
  1166.     puke(strh);
  1167.     if (pack) {
  1168.         nldisp++;
  1169.         puke(stri);
  1170.     }
  1171.     puke(strj);
  1172.     if (pack)
  1173.         puke(strk);
  1174.     printf(strg, rootmaj, rootmin,
  1175.         swapmaj, swapmin,
  1176.         pipemaj, pipemin,
  1177.         nldisp,
  1178.         swplo, nswap);
  1179.     printf(strg1);
  1180.     if (!mpx)
  1181.         puke(strg1a);
  1182.     printf(strg2);
  1183.     puke(strg3);
  1184.     if(rootmaj < 0)
  1185.         fprintf(stderr, "No root device given\n");
  1186.     freopen("mch0.s", "w", stdout);
  1187.     dumpht = 0;
  1188.     dumptm = 0;
  1189.     dumpts = 0;
  1190.     for (i=0; table[i].name; i++) {
  1191.         if (equal(table[i].name, "ht") && table[i].count)
  1192.             dumpht = 1;
  1193.         if (equal(table[i].name, "tm") && table[i].count)
  1194.             dumptm = 1;
  1195.         if (equal(table[i].name, "ts") && table[i].count)
  1196.             dumpts = 1;
  1197.     }
  1198.     if((dump == HT) && dumpht) {
  1199.         dumptm = 0;
  1200.         dumpts = 0;
  1201.         }
  1202.     if((dump == TM) && dumptm) {
  1203.         dumpht = 0;
  1204.         dumpts = 0;
  1205.         }
  1206.     if((dump == TS) && dumpts) {
  1207.         dumpht = 0;
  1208.         dumptm = 0;
  1209.         }
  1210.     if (dumpht) {
  1211.         printf("HTDUMP = 1\n");
  1212.         printf("TUDUMP = 0\n");
  1213.         printf("TSDUMP = 0\n");
  1214.         if(cdcsr)
  1215.             printf("\nHTCS1    = %o\n", cdcsr);
  1216.         else
  1217.             printf("\nHTCS1    = 172440\n");
  1218.     } else if (dumptm) {
  1219.         printf("HTDUMP = 0\n");
  1220.         printf("TUDUMP = 1\n");
  1221.         printf("TSDUMP = 0\n");
  1222.         if(cdcsr)
  1223.             printf("\nMTS    = %o\n", cdcsr);
  1224.         else
  1225.             printf("\nMTS    = 172520\n");
  1226.         printf("MTC    = MTS+2\n");
  1227.     } else if (dumpts) {
  1228.         printf("HTDUMP = 0\n");
  1229.         printf("TUDUMP = 0\n");
  1230.         printf("TSDUMP = 1\n");
  1231.         if(cdcsr)
  1232.             printf("\nTSDB    = %o\n", cdcsr);
  1233.         else
  1234.             printf("\nTSDB    = 172520\n");
  1235.         printf("TSSR    = TSDB+2\n");
  1236.     } else {
  1237.         fprintf(stderr, "\n(No tape, so no core dump included)\n");
  1238.         printf("HTDUMP = 0\n");
  1239.         printf("TUDUMP = 0\n");
  1240.         printf("TSDUMP = 0\n");
  1241.         }
  1242.     if(nfp)
  1243.         printf("\n.fpp\t= 0\n");
  1244.     else
  1245.         printf("\n.fpp\t= 1\n");
  1246. /*
  1247.  * pass3 - create "ovload" file
  1248.  *
  1249.  * "ovload" is a shell file used by /sys/conf/makefile
  1250.  * to invoke the covld command to link the overlay
  1251.  * kernel and produce the executable file unix_ov.
  1252.  *
  1253.  * The method to this madness is as follows:
  1254.  *
  1255.  * 1.    If the "ov" specification was not present in
  1256.  *    the conf file, then skip this pass !
  1257.  *
  1258.  * 2.    Use the size command to create the file text.sizes
  1259.  *    containing the text sizes of each object module.
  1260.  *    ../ovdev/bio.o 2086+30+0 = 2116b = 04104b, etc.
  1261.  *
  1262.  * 3.    Transfer the text size of each object module from the
  1263.  *    text.sizes file to that module's slot in the ovtab structure.
  1264.  *
  1265.  * 4.    Check each module in the ovtab structure to insure that it's
  1266.  *    size was found and initialize the ovdes (overlay descriptor)
  1267.  *    array to all zeroes (all overlays empty).
  1268.  *
  1269.  * 5.    Scan the ovtab structure and load all of the modules that
  1270.  *    are always configured into their designated overlays.
  1271.  *
  1272.  * 6.    Search the mkconf "table" to find all configured devices
  1273.  *    (count > 0) and mark them as optional configured devices in
  1274.  *    the ovtab structure, one exception is "tty" which always included.
  1275.  *    If the "hp", "hk", or "hm" disks are configured,
  1276.  *    then the "dsort" and "dkleave" modules must be included
  1277.  *    in overlay 3.
  1278.  *    If the "dh" driver is configured and the "dhdm" module
  1279.  *    is not included, then the "dhfdm" module must be included
  1280.  *    in overlay 5.
  1281.  *    If the "rx" specification is included, it's name is changed
  1282.  *    to "rx2" because the rx2.o module supports both rx01 & rx02.
  1283.  *
  1284.  * 7.    Check for "mpx" and "pack", if specified mark their object
  1285.  *    modules as optional configured devices in the ovtab structure.
  1286.  *
  1287.  * 8.    Scan the ovtab and load all optionaly configured modules
  1288.  *    that have fixed overlay assignments into their designated overlays.
  1289.  *    Except for the following special case any module with a
  1290.  *    fixed overlay assignment, which causes that overlay to
  1291.  *    overflow will cause a fatal error, i.e., overlay
  1292.  *    3 could overflow if all three big disk drivers (hp, hm, & hk)
  1293.  *    are configured. If this occurs the "hm" driver will be
  1294.  *    loaded into the first overlay with sufficient free space.
  1295.  *
  1296.  * 9.    Scan the ovtab and transfer any configured modules from
  1297.  *    pseudo overlays 8 thru 10 to real overlays 1 thru 7.
  1298.  *    The modules are placed into the overlays starting at one
  1299.  *    on a first fit basis. Actually this is done in two passes,
  1300.  *    first the existing overlays are scanned to locate a
  1301.  *    slot for the module, if the module will not fit into
  1302.  *    any existing overlay, then a new overlay is created and
  1303.  *    the module is loaded into it.
  1304.  *
  1305.  * 10.    Create the "ovload" shell file by scanning the overlay
  1306.  *    descriptor array and writing the pathnames of the
  1307.  *    modules to be loaded into the file.
  1308.  */
  1309.  
  1310. /* 1. */
  1311.     if(!ov)
  1312.         exit(0);
  1313. /* 2. */
  1314.     system(sizcmd);
  1315.     if((fi = fopen("text.sizes", "r")) == 0) {
  1316.         fprintf(stderr, "\nCan't open text.sizes file\n");
  1317.         exit();
  1318.         }
  1319. /* 3. */
  1320. scanlp:
  1321.     ovcnt = fscanf(fi, "%9s%[^\.]%s%[^+]%[^\n]",trash,omn,trash,mtsize,trash);
  1322.     if(ovcnt == EOF)
  1323.         goto endovs;
  1324.     if(ovcnt != 5) {
  1325.         fprintf(stderr, "\ntext.sizes file format error\n");
  1326.         exit();
  1327.         }
  1328.     for(otp = ovt; otp->mn; otp++) {
  1329.         q = &omn;
  1330.         if(equal(otp->mn, q)) {
  1331.             otp->mts = atoi(mtsize);
  1332.             break;
  1333.             }
  1334.         }
  1335.     goto scanlp;
  1336. endovs:
  1337.     fclose(fi);
  1338. /* 4. */
  1339.     for(otp = ovt; otp->mn; otp++)
  1340.         if(otp->mts < 0)
  1341.         fprintf(stderr, "\n%s.o object file size not found\n", otp->mn);
  1342.     for(i=0; i<8; i++) {
  1343.         ovdtab[i].nentry = 0;
  1344.         ovdtab[i].size = 0;
  1345.         }
  1346. /* 5. */
  1347.     for(otp = ovt; otp->mn; otp++)
  1348.         if((otp->mc == 1) && (otp->ovno < 6)) {
  1349.             if(ovload(otp, otp->ovno) < 0)
  1350.                 goto ovlerr;
  1351.             }
  1352. /* 6. */
  1353.     for(p=table; p->name; p++)
  1354.         if(p->count > 0) {
  1355.             if(equal(p->name, "rx"))
  1356.                 c = ctab[22];    /* rx2 */
  1357.             else
  1358.                 c = p->name;
  1359.             n = 0;
  1360.             for(otp=ovt; otp->mn; otp++)
  1361.                 if(equal(c, q=otp->mn)) {
  1362.                     if(otp->mc == 0)
  1363.                         otp->mc = 2;
  1364.                     n++;
  1365.                     break;
  1366.                     }
  1367.                 if(!n) {
  1368.             fprintf(stderr, "\n%s not in overlay table\n", c);
  1369.                     exit();
  1370.                     }
  1371.             }
  1372.  
  1373.     /* if hp, hm or hk configured, must include dsort and dkleave */
  1374.  
  1375.     n = 0;
  1376.     for(otp=ovt; otp->mn; otp++) {
  1377.         if((equal(otp->mn, "hp") ||
  1378.         equal(otp->mn, "hm") ||
  1379.         equal(otp->mn, "hk")) &&
  1380.         (otp->mc == 2))
  1381.             n++;
  1382.         if(equal(otp->mn, "dsort") && n)
  1383.             otp->mc = 2;
  1384.         if(equal(otp->mn, "dkleave") && n) {
  1385.             otp->mc = 2;
  1386.             break;
  1387.             }
  1388.         }
  1389.  
  1390.     /* if dh configured without dhdm, must include dhfdm */
  1391.  
  1392.     n = 0;
  1393.     for(otp=ovt; otp->mn; otp++)
  1394.         if(equal(otp->mn, "dhdm"))
  1395.             break;
  1396.     if(otp->mc == 0)
  1397.         n++;
  1398.     otp++;
  1399.     if((otp->mc == 2) && n) {
  1400.         otp++;
  1401.         otp->mc = 2;
  1402.         }
  1403. /* 7. */
  1404.     for(otp=ovt; otp->mn; otp++) {
  1405.         if((otp->ovno == 6) && pack)
  1406.             otp->mc = 2;
  1407.         if((otp->ovno == 7) && mpx)
  1408.             otp->mc = 2;
  1409.         }
  1410. /* 8. */
  1411.     for(otp=ovt; otp->mn; otp++)
  1412.         if((otp->mc == 2) && (otp->ovno < 8))
  1413.             if(ovload(otp, otp->ovno) < 0) {
  1414.                 if(otp->ovno == 3)
  1415.                     otp->ovno = 8;
  1416.                 else
  1417.                     goto ovlerr;
  1418.                 }
  1419. /* 9. */
  1420.     for(otp=ovt; otp->mn; otp++) {
  1421.         if(otp->ovno < 8)
  1422. ovldok:
  1423.         continue;
  1424.         if(otp->mc) {
  1425.             for(i=1; i<8; i++) {
  1426.                 if(ovdtab[i].size)
  1427.                     if(ovload(otp, i) >= 0)
  1428.                         goto ovldok;
  1429.                 }
  1430.             for(i=1; i<8; i++) {
  1431.                 if(ovload(otp, i) >= 0)
  1432.                     goto ovldok;
  1433.                 }
  1434.         fprintf(stderr,"%s will not fit in overlay %d\n",otp->mn,i);
  1435.             exit();
  1436.             }
  1437.         }
  1438. /* 10. */
  1439.     freopen("ovload", "w", stdout);
  1440.     puke(strovh);
  1441.     for(i=1; i<8; i++) {
  1442.         ovdp = &ovdtab[i];
  1443.         if(ovdp->nentry) {
  1444.             puke(strovz);
  1445.             for(n=0; n < ovdp->nentry; n++) {
  1446.                 printf("%s", ovdp->omns[n]);
  1447.                 printf("\n");
  1448.                 }
  1449.             }
  1450.         }
  1451.     puke(strovl);
  1452.     printf("\n");
  1453.     fclose(stdout);
  1454.     system(cmcmd);
  1455.     exit();
  1456. ovlerr:
  1457.     fprintf(stderr, "\noverlay %d size overflow\n",otp->ovno);
  1458.     exit();
  1459. }
  1460.  
  1461. /*
  1462.  * ovload checks to see if the module will fit
  1463.  * into the overlay and then loads it if possible
  1464.  * or returns -1 if it can't be loaded.
  1465.  */
  1466.  
  1467. ovload(tp, ovn)
  1468. struct ovtab *tp;
  1469. {
  1470.     register struct ovdes *dp;
  1471.  
  1472.     dp = &ovdtab[ovn];
  1473.     if((dp->nentry >= 12) ||
  1474.     (dp->size >= 8192) ||
  1475.     ((dp->size + tp->mts) > 8192))
  1476.         return(-1);
  1477.     dp->omns[dp->nentry] = tp->mpn;
  1478.     dp->size += tp->mts;
  1479.     dp->nentry++;
  1480.     return(1);
  1481. }
  1482.  
  1483. puke(s)
  1484. char **s;
  1485. {
  1486.     char *c;
  1487.  
  1488.     while(c = *s++) {
  1489.         printf(c);
  1490.         printf("\n");
  1491.     }
  1492. }
  1493.  
  1494. input()
  1495. {
  1496.     char line[100];
  1497.     register struct tab *q;
  1498.     int count, n;
  1499.     long num;
  1500.     unsigned int onum;
  1501.     char keyw[32], dev[32];
  1502.  
  1503.     if (fgets(line, 100, stdin) == NULL)
  1504.         return(0);
  1505.     count = -1;
  1506.      sscanf(line, "%d%s%s%o", &count, keyw, dev, &onum);
  1507.     n = sscanf(line, "%d%s%s%ld", &count, keyw, dev, &num);
  1508.     if (count == -1 && n>0) {
  1509.         count = 1;
  1510.         n++;
  1511.     }
  1512.     if (n<2)
  1513.         goto badl;
  1514.     for(q=table; q->name; q++)
  1515.     if(equal(q->name, keyw)) {
  1516.         if(q->count < 0) {
  1517.             fprintf(stderr, "%s: no more, no less\n", keyw);
  1518.             return(1);
  1519.         }
  1520.         q->count += count;
  1521.         if(q->address < 300 && q->count > 1) {
  1522.             q->count = 1;
  1523.             fprintf(stderr, "%s: only one\n", keyw);
  1524.         }
  1525.         return(1);
  1526.     }
  1527.     if (equal(keyw, "nswap")) {
  1528.         if (n<3)
  1529.             goto badl;
  1530.         if (sscanf(dev, "%ld", &num) <= 0)
  1531.             goto badl;
  1532.         nswap = num;
  1533.         return(1);
  1534.     }
  1535.     if (equal(keyw, "swplo")) {
  1536.         if (n<3)
  1537.             goto badl;
  1538.         if (sscanf(dev, "%ld", &num) <= 0)
  1539.             goto badl;
  1540.         swplo = num;
  1541.         return(1);
  1542.     }
  1543.     if (equal(keyw, "pack")) {
  1544.         pack++;
  1545.         return(1);
  1546.     }
  1547.     if (equal(keyw, "mpx")) {
  1548.         mpx++;
  1549.         return(1);
  1550.     }
  1551.     if (equal(keyw, "ov")) {
  1552.         ov++;
  1553.         return;
  1554.     }
  1555.     if (equal(keyw, "nsid")) {
  1556.         nsid++;
  1557.         return(1);
  1558.     }
  1559.     if (equal(keyw, "nfp")) {
  1560.         nfp++;
  1561.         return(1);
  1562.     }
  1563.     dump = 0;
  1564.     if (equal(keyw, "dump")) {
  1565.         if (n<3)
  1566.             goto badl;
  1567.         if (equal(dev, "ht"))
  1568.             dump = HT;
  1569.         else if(equal(dev, "tm"))
  1570.             dump = TM;
  1571.         else if(equal(dev, "ts"))
  1572.             dump = TS;
  1573.         else
  1574.             goto badl;
  1575.         cdcsr = 0;
  1576.         if (n == 4) {
  1577.             if ((onum > 0160006) && (onum < 0177514))
  1578.                 cdcsr = onum & 0177776;
  1579.             else
  1580.                 goto badl;
  1581.             }
  1582.         return(1);
  1583.         }
  1584.     if (equal(keyw, "done"))
  1585.         return(0);
  1586.     if (equal(keyw, "root")) {
  1587.         if (n<4)
  1588.             goto badl;
  1589.         for (q=table; q->name; q++) {
  1590.             if (equal(q->name, dev)) {
  1591.                 q->key |= ROOT;
  1592.                 rootmin = num;
  1593.                 return(1);
  1594.             }
  1595.         }
  1596.         fprintf(stderr, "Can't find root\n");
  1597.         return(1);
  1598.     }
  1599.     if (equal(keyw, "swap")) {
  1600.         if (n<4)
  1601.             goto badl;
  1602.         for (q=table; q->name; q++) {
  1603.             if (equal(q->name, dev)) {
  1604.                 q->key |= SWAP;
  1605.                 swapmin = num;
  1606.                 return(1);
  1607.             }
  1608.         }
  1609.         fprintf(stderr, "Can't find swap\n");
  1610.         return(1);
  1611.     }
  1612.     if (equal(keyw, "pipe")) {
  1613.         if (n<4)
  1614.             goto badl;
  1615.         for (q=table; q->name; q++) {
  1616.             if (equal(q->name, dev)) {
  1617.                 q->key |= PIPE;
  1618.                 pipemin = num;
  1619.                 return(1);
  1620.             }
  1621.         }
  1622.         fprintf(stderr, "Can't find pipe\n");
  1623.         return(1);
  1624.     }
  1625.     fprintf(stderr, "%s: cannot find\n", keyw);
  1626.     return(1);
  1627. badl:
  1628.     fprintf(stderr, "Bad line: %s", line);
  1629.     return(1);
  1630. }
  1631.  
  1632. equal(a, b)
  1633. char *a, *b;
  1634. {
  1635.     return(!strcmp(a, b));
  1636. }
  1637.  
  1638. match(a, b)
  1639. register char *a, *b;
  1640. {
  1641.     register char *t;
  1642.  
  1643.     for (t = b; *a && *t; a++) {
  1644.         if (*a != *t) {
  1645.             while (*a && *a != '|')
  1646.                 a++;
  1647.             if (*a == '\0')
  1648.                 return(0);
  1649.             t = b;
  1650.         } else
  1651.             t++;
  1652.     }
  1653.     if (*a == '\0' || *a == '|')
  1654.         return(1);
  1655.     return(0);
  1656. }
  1657.