Annotation of 43BSD/etc/config/mkioconf.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)mkioconf.c 5.1 (Berkeley) 5/8/85";
                      9: #endif not lint
                     10: 
                     11: #include <stdio.h>
                     12: #include "y.tab.h"
                     13: #include "config.h"
                     14: 
                     15: /*
                     16:  * build the ioconf.c file
                     17:  */
                     18: char   *qu();
                     19: char   *intv();
                     20: 
                     21: #if MACHINE_VAX
                     22: vax_ioconf()
                     23: {
                     24:        register struct device *dp, *mp, *np;
                     25:        register int uba_n, slave;
                     26:        FILE *fp;
                     27: 
                     28:        fp = fopen(path("ioconf.c"), "w");
                     29:        if (fp == 0) {
                     30:                perror(path("ioconf.c"));
                     31:                exit(1);
                     32:        }
                     33:        fprintf(fp, "#include \"../machine/pte.h\"\n");
                     34:        fprintf(fp, "#include \"../h/param.h\"\n");
                     35:        fprintf(fp, "#include \"../h/buf.h\"\n");
                     36:        fprintf(fp, "#include \"../h/map.h\"\n");
                     37:        fprintf(fp, "#include \"../h/vm.h\"\n");
                     38:        fprintf(fp, "\n");
                     39:        fprintf(fp, "#include \"../vaxmba/mbavar.h\"\n");
                     40:        fprintf(fp, "#include \"../vaxuba/ubavar.h\"\n\n");
                     41:        fprintf(fp, "\n");
                     42:        fprintf(fp, "#define C (caddr_t)\n\n");
                     43:        /*
                     44:         * First print the mba initialization structures
                     45:         */
                     46:        if (seen_mba) {
                     47:                for (dp = dtab; dp != 0; dp = dp->d_next) {
                     48:                        mp = dp->d_conn;
                     49:                        if (mp == 0 || mp == TO_NEXUS ||
                     50:                            !eq(mp->d_name, "mba"))
                     51:                                continue;
                     52:                        fprintf(fp, "extern struct mba_driver %sdriver;\n",
                     53:                            dp->d_name);
                     54:                }
                     55:                fprintf(fp, "\nstruct mba_device mbdinit[] = {\n");
                     56:                fprintf(fp, "\t/* Device,  Unit, Mba, Drive, Dk */\n");
                     57:                for (dp = dtab; dp != 0; dp = dp->d_next) {
                     58:                        mp = dp->d_conn;
                     59:                        if (dp->d_unit == QUES || mp == 0 ||
                     60:                            mp == TO_NEXUS || !eq(mp->d_name, "mba"))
                     61:                                continue;
                     62:                        if (dp->d_addr) {
                     63:                                printf("can't specify csr address on mba for %s%d\n",
                     64:                                    dp->d_name, dp->d_unit);
                     65:                                continue;
                     66:                        }
                     67:                        if (dp->d_vec != 0) {
                     68:                                printf("can't specify vector for %s%d on mba\n",
                     69:                                    dp->d_name, dp->d_unit);
                     70:                                continue;
                     71:                        }
                     72:                        if (dp->d_drive == UNKNOWN) {
                     73:                                printf("drive not specified for %s%d\n",
                     74:                                    dp->d_name, dp->d_unit);
                     75:                                continue;
                     76:                        }
                     77:                        if (dp->d_slave != UNKNOWN) {
                     78:                                printf("can't specify slave number for %s%d\n", 
                     79:                                    dp->d_name, dp->d_unit);
                     80:                                continue;
                     81:                        }
                     82:                        fprintf(fp, "\t{ &%sdriver, %d,   %s,",
                     83:                                dp->d_name, dp->d_unit, qu(mp->d_unit));
                     84:                        fprintf(fp, "  %s,  %d },\n",
                     85:                                qu(dp->d_drive), dp->d_dk);
                     86:                }
                     87:                fprintf(fp, "\t0\n};\n\n");
                     88:                /*
                     89:                 * Print the mbsinit structure
                     90:                 * Driver Controller Unit Slave
                     91:                 */
                     92:                fprintf(fp, "struct mba_slave mbsinit [] = {\n");
                     93:                fprintf(fp, "\t/* Driver,  Ctlr, Unit, Slave */\n");
                     94:                for (dp = dtab; dp != 0; dp = dp->d_next) {
                     95:                        /*
                     96:                         * All slaves are connected to something which
                     97:                         * is connected to the massbus.
                     98:                         */
                     99:                        if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS)
                    100:                                continue;
                    101:                        np = mp->d_conn;
                    102:                        if (np == 0 || np == TO_NEXUS ||
                    103:                            !eq(np->d_name, "mba"))
                    104:                                continue;
                    105:                        fprintf(fp, "\t{ &%sdriver, %s",
                    106:                            mp->d_name, qu(mp->d_unit));
                    107:                        fprintf(fp, ",  %2d,    %s },\n",
                    108:                            dp->d_unit, qu(dp->d_slave));
                    109:                }
                    110:                fprintf(fp, "\t0\n};\n\n");
                    111:        }
                    112:        /*
                    113:         * Now generate interrupt vectors for the unibus
                    114:         */
                    115:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    116:                if (dp->d_vec != 0) {
                    117:                        struct idlst *ip;
                    118:                        mp = dp->d_conn;
                    119:                        if (mp == 0 || mp == TO_NEXUS ||
                    120:                            !eq(mp->d_name, "uba"))
                    121:                                continue;
                    122:                        fprintf(fp,
                    123:                            "extern struct uba_driver %sdriver;\n",
                    124:                            dp->d_name);
                    125:                        fprintf(fp, "extern ");
                    126:                        ip = dp->d_vec;
                    127:                        for (;;) {
                    128:                                fprintf(fp, "X%s%d()", ip->id, dp->d_unit);
                    129:                                ip = ip->id_next;
                    130:                                if (ip == 0)
                    131:                                        break;
                    132:                                fprintf(fp, ", ");
                    133:                        }
                    134:                        fprintf(fp, ";\n");
                    135:                        fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name,
                    136:                            dp->d_unit, dp->d_unit);
                    137:                        ip = dp->d_vec;
                    138:                        for (;;) {
                    139:                                fprintf(fp, "X%s%d", ip->id, dp->d_unit);
                    140:                                ip = ip->id_next;
                    141:                                if (ip == 0)
                    142:                                        break;
                    143:                                fprintf(fp, ", ");
                    144:                        }
                    145:                        fprintf(fp, ", 0 } ;\n");
                    146:                }
                    147:        }
                    148:        fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n");
                    149:        fprintf(fp, "/*\t driver,\tctlr,\tubanum,\talive,\tintr,\taddr */\n");
                    150:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    151:                mp = dp->d_conn;
                    152:                if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
                    153:                    !eq(mp->d_name, "uba"))
                    154:                        continue;
                    155:                if (dp->d_vec == 0) {
                    156:                        printf("must specify vector for %s%d\n",
                    157:                            dp->d_name, dp->d_unit);
                    158:                        continue;
                    159:                }
                    160:                if (dp->d_addr == 0) {
                    161:                        printf("must specify csr address for %s%d\n",
                    162:                            dp->d_name, dp->d_unit);
                    163:                        continue;
                    164:                }
                    165:                if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
                    166:                        printf("drives need their own entries; dont ");
                    167:                        printf("specify drive or slave for %s%d\n",
                    168:                            dp->d_name, dp->d_unit);
                    169:                        continue;
                    170:                }
                    171:                if (dp->d_flags) {
                    172:                        printf("controllers (e.g. %s%d) ",
                    173:                            dp->d_name, dp->d_unit);
                    174:                        printf("don't have flags, only devices do\n");
                    175:                        continue;
                    176:                }
                    177:                fprintf(fp,
                    178:                    "\t{ &%sdriver,\t%d,\t%s,\t0,\t%sint%d, C 0%o },\n",
                    179:                    dp->d_name, dp->d_unit, qu(mp->d_unit),
                    180:                    dp->d_name, dp->d_unit, dp->d_addr);
                    181:        }
                    182:        fprintf(fp, "\t0\n};\n");
                    183: /* unibus devices */
                    184:        fprintf(fp, "\nstruct uba_device ubdinit[] = {\n");
                    185:        fprintf(fp,
                    186: "\t/* driver,  unit, ctlr,  ubanum, slave,   intr,    addr,    dk, flags*/\n");
                    187:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    188:                mp = dp->d_conn;
                    189:                if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
                    190:                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    191:                    eq(mp->d_name, "mba"))
                    192:                        continue;
                    193:                np = mp->d_conn;
                    194:                if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba"))
                    195:                        continue;
                    196:                np = 0;
                    197:                if (eq(mp->d_name, "uba")) {
                    198:                        if (dp->d_vec == 0) {
                    199:                                printf("must specify vector for device %s%d\n",
                    200:                                    dp->d_name, dp->d_unit);
                    201:                                continue;
                    202:                        }
                    203:                        if (dp->d_addr == 0) {
                    204:                                printf("must specify csr for device %s%d\n",
                    205:                                    dp->d_name, dp->d_unit);
                    206:                                continue;
                    207:                        }
                    208:                        if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
                    209:                                printf("drives/slaves can be specified ");
                    210:                                printf("only for controllers, ");
                    211:                                printf("not for device %s%d\n",
                    212:                                    dp->d_name, dp->d_unit);
                    213:                                continue;
                    214:                        }
                    215:                        uba_n = mp->d_unit;
                    216:                        slave = QUES;
                    217:                } else {
                    218:                        if ((np = mp->d_conn) == 0) {
                    219:                                printf("%s%d isn't connected to anything ",
                    220:                                    mp->d_name, mp->d_unit);
                    221:                                printf(", so %s%d is unattached\n",
                    222:                                    dp->d_name, dp->d_unit);
                    223:                                continue;
                    224:                        }
                    225:                        uba_n = np->d_unit;
                    226:                        if (dp->d_drive == UNKNOWN) {
                    227:                                printf("must specify ``drive number'' ");
                    228:                                printf("for %s%d\n", dp->d_name, dp->d_unit);
                    229:                                continue;
                    230:                        }
                    231:                        /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
                    232:                        /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
                    233:                        if (dp->d_slave != UNKNOWN) {
                    234:                                printf("slave numbers should be given only ");
                    235:                                printf("for massbus tapes, not for %s%d\n",
                    236:                                    dp->d_name, dp->d_unit);
                    237:                                continue;
                    238:                        }
                    239:                        if (dp->d_vec != 0) {
                    240:                                printf("interrupt vectors should not be ");
                    241:                                printf("given for drive %s%d\n",
                    242:                                    dp->d_name, dp->d_unit);
                    243:                                continue;
                    244:                        }
                    245:                        if (dp->d_addr != 0) {
                    246:                                printf("csr addresses should be given only ");
                    247:                                printf("on controllers, not on %s%d\n",
                    248:                                    dp->d_name, dp->d_unit);
                    249:                                continue;
                    250:                        }
                    251:                        slave = dp->d_drive;
                    252:                }
                    253:                fprintf(fp, "\t{ &%sdriver,  %2d,   %s,",
                    254:                    eq(mp->d_name, "uba") ? dp->d_name : mp->d_name, dp->d_unit,
                    255:                    eq(mp->d_name, "uba") ? " -1" : qu(mp->d_unit));
                    256:                fprintf(fp, "  %s,    %2d,   %s, C 0%-6o,  %d,  0x%x },\n",
                    257:                    qu(uba_n), slave, intv(dp), dp->d_addr, dp->d_dk,
                    258:                    dp->d_flags);
                    259:        }
                    260:        fprintf(fp, "\t0\n};\n");
                    261:        (void) fclose(fp);
                    262: }
                    263: #endif
                    264: 
                    265: #if MACHINE_SUN
                    266: sun_ioconf()
                    267: {
                    268:        register struct device *dp, *mp;
                    269:        register int slave;
                    270:        FILE *fp;
                    271: 
                    272:        fp = fopen(path("ioconf.c"), "w");
                    273:        if (fp == 0) {
                    274:                perror(path("ioconf.c"));
                    275:                exit(1);
                    276:        }
                    277:        fprintf(fp, "#include \"../h/param.h\"\n");
                    278:        fprintf(fp, "#include \"../h/buf.h\"\n");
                    279:        fprintf(fp, "#include \"../h/map.h\"\n");
                    280:        fprintf(fp, "#include \"../h/vm.h\"\n");
                    281:        fprintf(fp, "\n");
                    282:        fprintf(fp, "#include \"../sundev/mbvar.h\"\n");
                    283:        fprintf(fp, "\n");
                    284:        fprintf(fp, "#define C (caddr_t)\n\n");
                    285:        fprintf(fp, "\n");
                    286:        /*
                    287:         * Now generate interrupt vectors for the Multibus
                    288:         */
                    289:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    290:                if (dp->d_pri != 0) {
                    291:                        mp = dp->d_conn;
                    292:                        if (mp == 0 || mp == TO_NEXUS ||
                    293:                            !eq(mp->d_name, "mb"))
                    294:                                continue;
                    295:                        fprintf(fp, "extern struct mb_driver %sdriver;\n",
                    296:                            dp->d_name);
                    297:                }
                    298:        }
                    299:        /*
                    300:         * Now spew forth the mb_cinfo structure
                    301:         */
                    302:        fprintf(fp, "\nstruct mb_ctlr mbcinit[] = {\n");
                    303:        fprintf(fp, "/*\t driver,\tctlr,\talive,\taddr,\tintpri */\n");
                    304:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    305:                mp = dp->d_conn;
                    306:                if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 ||
                    307:                    !eq(mp->d_name, "mb"))
                    308:                        continue;
                    309:                if (dp->d_pri == 0) {
                    310:                        printf("must specify priority for %s%d\n",
                    311:                            dp->d_name, dp->d_unit);
                    312:                        continue;
                    313:                }
                    314:                if (dp->d_addr == 0) {
                    315:                        printf("must specify csr address for %s%d\n",
                    316:                            dp->d_name, dp->d_unit);
                    317:                        continue;
                    318:                }
                    319:                if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
                    320:                        printf("drives need their own entries; ");
                    321:                        printf("dont specify drive or slave for %s%d\n",
                    322:                            dp->d_name, dp->d_unit);
                    323:                        continue;
                    324:                }
                    325:                if (dp->d_flags) {
                    326:                        printf("controllers (e.g. %s%d) don't have flags, ");
                    327:                        printf("only devices do\n",
                    328:                            dp->d_name, dp->d_unit);
                    329:                        continue;
                    330:                }
                    331:                fprintf(fp, "\t{ &%sdriver,\t%d,\t0,\tC 0x%x,\t%d },\n",
                    332:                    dp->d_name, dp->d_unit, dp->d_addr, dp->d_pri);
                    333:        }
                    334:        fprintf(fp, "\t0\n};\n");
                    335:        /*
                    336:         * Now we go for the mb_device stuff
                    337:         */
                    338:        fprintf(fp, "\nstruct mb_device mbdinit[] = {\n");
                    339:        fprintf(fp,
                    340: "\t/* driver,  unit, ctlr,  slave,   addr,    pri,    dk, flags*/\n");
                    341:        for (dp = dtab; dp != 0; dp = dp->d_next) {
                    342:                mp = dp->d_conn;
                    343:                if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 ||
                    344:                    mp == TO_NEXUS || mp->d_type == MASTER ||
                    345:                    eq(mp->d_name, "mba"))
                    346:                        continue;
                    347:                if (eq(mp->d_name, "mb")) {
                    348:                        if (dp->d_pri == 0) {
                    349:                                printf("must specify vector for device %s%d\n",
                    350:                                    dp->d_name, dp->d_unit);
                    351:                                continue;
                    352:                        }
                    353:                        if (dp->d_addr == 0) {
                    354:                                printf("must specify csr for device %s%d\n",
                    355:                                    dp->d_name, dp->d_unit);
                    356:                                continue;
                    357:                        }
                    358:                        if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) {
                    359:                                printf("drives/slaves can be specified only ");
                    360:                                printf("for controllers, not for device %s%d\n",
                    361:                                    dp->d_name, dp->d_unit);
                    362:                                continue;
                    363:                        }
                    364:                        slave = QUES;
                    365:                } else {
                    366:                        if (mp->d_conn == 0) {
                    367:                                printf("%s%d isn't connected to anything, ",
                    368:                                    mp->d_name, mp->d_unit);
                    369:                                printf("so %s%d is unattached\n",
                    370:                                    dp->d_name, dp->d_unit);
                    371:                                continue;
                    372:                        }
                    373:                        if (dp->d_drive == UNKNOWN) {
                    374:                                printf("must specify ``drive number'' for %s%d\n",
                    375:                                   dp->d_name, dp->d_unit);
                    376:                                continue;
                    377:                        }
                    378:                        /* NOTE THAT ON THE UNIBUS ``drive'' IS STORED IN */
                    379:                        /* ``SLAVE'' AND WE DON'T WANT A SLAVE SPECIFIED */
                    380:                        if (dp->d_slave != UNKNOWN) {
                    381:                                printf("slave numbers should be given only ");
                    382:                                printf("for massbus tapes, not for %s%d\n",
                    383:                                    dp->d_name, dp->d_unit);
                    384:                                continue;
                    385:                        }
                    386:                        if (dp->d_pri != 0) {
                    387:                                printf("interrupt priority should not be ");
                    388:                                printf("given for drive %s%d\n",
                    389:                                    dp->d_name, dp->d_unit);
                    390:                                continue;
                    391:                        }
                    392:                        if (dp->d_addr != 0) {
                    393:                                printf("csr addresses should be given only");
                    394:                                printf("on controllers, not on %s%d\n",
                    395:                                    dp->d_name, dp->d_unit);
                    396:                                continue;
                    397:                        }
                    398:                        slave = dp->d_drive;
                    399:                }
                    400:                fprintf(fp,
                    401: "\t{ &%sdriver,  %2d,   %s,    %2d,   C 0x%x, %d,  %d,  0x%x },\n",
                    402:                    eq(mp->d_name, "mb") ? dp->d_name : mp->d_name, dp->d_unit,
                    403:                    eq(mp->d_name, "mb") ? " -1" : qu(mp->d_unit),
                    404:                    slave, dp->d_addr, dp->d_pri, dp->d_dk, dp->d_flags);
                    405:        }
                    406:        fprintf(fp, "\t0\n};\n");
                    407:        (void) fclose(fp);
                    408: }
                    409: #endif
                    410: 
                    411: char *intv(dev)
                    412:        register struct device *dev;
                    413: {
                    414:        static char buf[20];
                    415: 
                    416:        if (dev->d_vec == 0)
                    417:                return ("     0");
                    418:        return (sprintf(buf, "%sint%d", dev->d_name, dev->d_unit));
                    419: }
                    420: 
                    421: char *
                    422: qu(num)
                    423: {
                    424: 
                    425:        if (num == QUES)
                    426:                return ("'?'");
                    427:        if (num == UNKNOWN)
                    428:                return (" -1");
                    429:        return (sprintf(errbuf, "%3d", num));
                    430: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.