📄 mkioconf.c
字号:
#ifndef lintstatic char *sccsid = "@(#)mkioconf.c 4.1 (ULTRIX) 7/2/90";#endif lint/************************************************************************ * * * Copyright (c) 1986,87,88, 89, 90 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//*----------------------------------------------------------------------- * * Modification History * * 06-Jun-90 Pete Keilty * Added ci support into dump_vec_adapt and dump_dispatch routines. * * 20-Dec-89 Paul Grist * Added VMEbus support - vba adapters. * * 10-17-89 Randall Brown * added the function is_cpu_declared to determine if a particular * cpu type was defined. * * 07-19-98 robin * added support for vax devices on mips systems * * 06-14-89 jaw * add support for xmi as an I/O bus and for the kdm xmi driver. * * 05-17-89 Tim Burke * Change mscp unit wildcard from '?' to -1. * * 04-14-88 robin * added ibus support * * 1-25-88 Ricky Palmer * Added MSI support. * * 12-20-87 * Add two field to the end of config_adpt structure and init to 0. * The fields are the bus number and nexus number respectively. * * 12-11-87 Robin L. and Larry C. * Added portclass support to the system. * * 27-Aug-86 -- jmartin * Fix segmentation fault caused here by missing or misplaced * "controller" statement (SMU-307). * * 15-Apr-86 -- afd * Removed reference to MACHINE_MVAX * * 8 Apr 86 -- lp * Added bvp support * * 06-Mar-86 -- jrs * Fix problem when both bi and massbus devices exist * * 05-Mar-86 -- jrs * Add support for configuring native bi devices * *----------------------------------------------------------------------- */#include <stdio.h>#include "y.tab.h"#include "config.h"/* * build the ioconf.c file */char *qu();char *qumscp();char *intv();/* * no driver routines for these devices */char *tbl_nodriver[] = { "dssc", "hsc", "mscp", 0 } ; dec_ioconf(){ register struct device *dp, *mp, *np; int i; register int uba_n, slave; int fatal_error = 0; int directconn; FILE *fp,*fpb; extern int isconfigured(); fp = fopen(path("ioconf.c"), "w"); if (fp == 0) { perror(path("ioconf.c")); exit(1); } fpb = fopen(path("iobus.c"), "w"); if (fpb == 0) { perror(path("iobus.c")); exit(1); } fprintf(fp, "#include \"../machine/pte.h\"\n"); fprintf(fp, "#include \"../h/param.h\"\n"); fprintf(fp, "#include \"../h/buf.h\"\n"); fprintf(fp, "#include \"../h/map.h\"\n"); fprintf(fp, "#include \"../h/vm.h\"\n"); fprintf(fp, "#include \"../h/config.h\"\n"); fprintf(fp, "\n"); switch (machine) { case MACHINE_VAX: fprintf(fp, "#include \"../io/mba/vax/mbavar.h\"\n"); break; case MACHINE_MIPS: break; } fprintf(fp, "#include \"../io/uba/ubavar.h\"\n\n"); fprintf(fp, "\n"); fprintf(fp, "#define C (caddr_t)\n\n"); fprintf(fp, "int nulldev();\n"); /* * set up null routines for devices that do not have a * driver associated with them. */ { register char **ptr = tbl_nodriver; while(*ptr) { if (!isconfigured(*ptr)) { ptr++; continue; } for (dp = dtab; dp != 0; dp = dp->d_next) if(eq(dp->d_name, *ptr)) { fprintf(fp, "struct uba_driver %sdriver; ", *ptr); fprintf(fp, "int (*%sint%d[])() = { nulldev, 0 }; ", *ptr, dp->d_unit); fprintf(fp, " /* no %sdriver */\n", *ptr); } ptr++; } } fprintf(fp, "\n"); /* * First print the mba initialization structures */ if (seen_mba) { for (dp = dtab; dp != 0; dp = dp->d_next) { mp = dp->d_conn; if(mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "mba")) continue; fprintf(fp, "extern struct mba_driver %sdriver;\n", dp->d_name); } fprintf(fp, "\nstruct mba_device mbdinit[] = {\n"); fprintf(fp, "\t/* Device, Unit, Mba, Drive, Dk */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { mp = dp->d_conn; if (dp->d_unit == QUES || mp == 0 || mp == TO_NEXUS || !eq(mp->d_name, "mba")) continue; if (dp->d_addr) { printf("can't specify csr address on mba for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_vec != 0) { printf("can't specify vector for %s%d on mba\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_drive == UNKNOWN) { printf("drive not specified for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_slave != UNKNOWN) { printf("can't specify slave number for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } fprintf(fp, "\t{ &%sdriver, %d, %s,", dp->d_name, dp->d_unit, qu(mp->d_unit)); fprintf(fp, " %s, %d },\n", qu(dp->d_drive), dp->d_dk); } fprintf(fp, "\t0\n};\n\n"); /* * Print the mbsinit structure * Driver Controller Unit Slave */ fprintf(fp, "struct mba_slave mbsinit [] = {\n"); fprintf(fp, "\t/* Driver, Ctlr, Unit, Slave */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { /* * All slaves are connected to something which * is connected to the massbus. */ if ((mp = dp->d_conn) == 0 || mp == TO_NEXUS) continue; np = mp->d_conn; if (np == 0 || np == TO_NEXUS ||!eq(np->d_name, "mba")) continue; fprintf(fp, "\t{ &%sdriver, %s", mp->d_name, qu(mp->d_unit)); fprintf(fp, ", %2d, %s },\n", dp->d_unit, qu(dp->d_slave)); } fprintf(fp, "\t0\n};\n\n"); } /* * Now generate interrupt vectors for the unibus */ for (dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_vec != 0) { struct idlst *ip; mp = dp->d_conn; if (mp == 0 || mp == TO_NEXUS||can_connect(dp->d_name)) continue; if( (mp->d_conn != 0 && mp->d_conn != TO_NEXUS && eq(mp->d_conn->d_name,"mba")) ) continue; if(!can_connect(mp->d_name)) continue; fprintf(fp, "extern struct uba_driver %sdriver;\n",dp->d_name); if(ip = dp->d_vec) { fprintf(fp, "extern "); for (;;) { fprintf(fp,"X%s%d()", ip->id, dp->d_unit); ip = ip->id_next; if (ip == 0) break; fprintf(fp, ", "); } fprintf(fp, ";\n"); fprintf(fp, "int\t (*%sint%d[])() = { ", dp->d_name, dp->d_unit); ip = dp->d_vec; for (;;) { fprintf(fp, "X%s%d", ip->id, dp->d_unit); ip = ip->id_next; if (ip == 0) break; fprintf(fp, ", "); } fprintf(fp, ", 0 } ;\n"); } } } fprintf(fp, "\nstruct uba_ctlr ubminit[] = {\n"); fprintf(fp, "/*driver,\tctlrname,\tctlr,\tpar,\tadpt,\tnexus,\trcntl,\tubanum,\talive,\tintr,\taddr,\taddr2,\tbuspri,\tivnum*/\n\n"); fprintf(fpb, "\nstruct config_adpt config_adpt[] = {\n"); dump_adapt("vba", fpb,&vba_bus); dump_adapt("vaxbi", fpb,&vaxbi_bus); dump_adapt("ci", fpb,&ci_bus); dump_adapt("uba", fpb,&uba_bus); dump_adapt("xmi", fpb,&xmi_bus); dump_adapt("msi", fpb,&msi_bus); dump_adapt("ibus", fpb,&ibus_bus); for (dp = dtab; dp != 0; dp = dp->d_next) { mp = dp->d_conn; if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || dp->d_unit == QUES) continue; if(can_connect(dp->d_name)) continue; if (needs_vector(mp->d_name)) { if (dp->d_vec == 0) { printf("must specify vector for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_addr == 0 && needs_csr(mp->d_name)) { printf("must specify csr address for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } } if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { printf("drives need their own entries; dont "); printf("specify drive or slave for %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_flags) { printf("controllers (e.g. %s%d) ", dp->d_name, dp->d_unit); printf("don't have flags, only devices do\n"); fatal_error++; continue; } if ((mp->d_name) && needs_pseudo_uba(mp->d_name)|| (eq(mp->d_name,"vaxbi")&&needs_pseudo_uba(dp->d_name)) || (eq(mp->d_name,"vba")&&needs_pseudo_uba(dp->d_name)) || (eq(mp->d_name,"xmi")&&needs_pseudo_uba(dp->d_name))){ if (dp->d_extranum == UNKNOWN) { uba_n = UNKNOWN; } else { uba_n = highuba + dp->d_extranum + 1; } } else { uba_n = uba_num(mp); } fprintf(fp, "{ &%sdriver,\t\"%s\",\t\t%d,\t0, \t%s,", dp->d_name, dp->d_name, dp->d_unit, qu(dp->d_adaptor)); fprintf(fp,"\t%s,", qu(dp->d_nexus)); fprintf(fp,"\t%s,", qu(dp->d_rcntl)); fprintf(fp,"\t%s,", qu(uba_n)); fprintf(fp, "\t0,\t%sint%d, C 0%o, C 0%o,", dp->d_name, dp->d_unit, dp->d_addr,dp->d_addr2); fprintf(fp,"\t%d,\t0x%x",dp->d_pri,dp->d_ivnum); fprintf(fp, "},\n\n"); if(can_connect(mp->d_name)) { /* dump out a bus structure for the unmentioned * parent */ print_tree(dp->d_conn,fpb); fprintf(fpb,"\t{\"%s\", %s,C &%sdriver, %d, 'C', 0, -1, -1},\n", mp->d_name, qu(mp->d_unit), dp->d_name, dp->d_unit); } } fprintf(fp, "\t0\n};\n");/* unibus devices */ fprintf(fp, "\nstruct uba_device ubdinit[] = {\n"); fprintf(fp,"/* driver, name, unit, par, adpt, nex, rcntl, ubanum, ctlr, slave, intr, addr, addr2, dk, flags, buspri, ivnum*/\n\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { mp = dp->d_conn; if (dp->d_unit == QUES || dp->d_type != DEVICE || mp == 0 || mp == TO_NEXUS || (mp->d_type == MASTER || eq(mp->d_name, "mba"))) continue; np = mp->d_conn; if (np != 0 && np != TO_NEXUS && eq(np->d_name, "mba")) continue; np = 0; directconn = (can_connect(mp->d_name)); if (directconn) { if (dp->d_vec == 0) { printf("must specify vector for device %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (needs_csr(mp->d_name) && dp->d_addr == 0) { printf("must specify csr for device %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if (dp->d_drive != UNKNOWN || dp->d_slave != UNKNOWN) { printf("drives/slaves can be specified "); printf("only for controllers, "); printf("not for device %s%d\n", dp->d_name, dp->d_unit); fatal_error++; continue; } if ((dp->d_conn) && needs_pseudo_uba(dp->d_conn)) { if (dp->d_extranum == UNKNOWN) { uba_n = UNKNOWN; } else { uba_n = highuba + dp->d_extranum + 1; } } else { if(eq("uba",mp->d_name)) uba_n = mp->d_unit; else uba_n = UNKNOWN; } slave = QUES; } else { if ((np = mp->d_conn) == 0) { printf("%s%d isn't connected to anything ", mp->d_name, mp->d_unit); printf(", so %s%d is unattached\n",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -