From 46591adfaa53102ab2882bf0cf1a22e168b836de Mon Sep 17 00:00:00 2001 From: dg Date: Thu, 18 Aug 1994 05:11:32 +0000 Subject: Support for Bruce Evans' new dynamic interrupt support. Submitted by: Bruce Evans --- usr.sbin/config/Makefile | 2 +- usr.sbin/config/config.8 | 5 +-- usr.sbin/config/mkglue.c | 108 +++++++++++++++++++++------------------------ usr.sbin/config/mkioconf.c | 61 ++++++++++++++----------- 4 files changed, 90 insertions(+), 86 deletions(-) (limited to 'usr.sbin/config') diff --git a/usr.sbin/config/Makefile b/usr.sbin/config/Makefile index 6ef4311..ec61d25 100644 --- a/usr.sbin/config/Makefile +++ b/usr.sbin/config/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= config -CFLAGS+=-I. -I${.CURDIR} +CFLAGS+=-I. -I${.CURDIR} -DSTATCLOCK SRCS= config.c main.c lang.c mkioconf.c mkmakefile.c mkglue.c mkheaders.c \ mkswapconf.c MAN8= config.8 diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 0e4bae2..798bafc 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -112,9 +112,8 @@ they are: a description of what I/O devices are attached to the system; .Pa vector.h , -a set of interrupt service routines for devices -attached to the bus plus -offsets into a structure used for counting per-device interrupts; +definitions of +macros related to counting interrupts; .Pa Makefile , used by .Xr make 1 diff --git a/usr.sbin/config/mkglue.c b/usr.sbin/config/mkglue.c index 8b35314..e467869 100644 --- a/usr.sbin/config/mkglue.c +++ b/usr.sbin/config/mkglue.c @@ -332,71 +332,65 @@ dump_ctrs(fp) /* * Create the ISA interrupt vector glue file. + * + * The interrupt handlers are hardwired into vector.s and are attached + * at runtime depending on the data in ioconf.c and on the results of + * probing. Here we only need to generate the names of the interrupt + * handlers in an ancient form suitable for vmstat (the _eintrcnt label + * can't be expressed in C). We give the names of all devices to + * simplify the correspondence between devices and interrupt handlers. + * The order must match that in mkioconf.c. */ -vector() { - register FILE *fp, *gp; - register struct device *dp, *mp; - int count; +vector() +{ + int dev_id; + FILE *fp; fp = fopen(path("vector.h"), "w"); - if (fp == 0) { + if (fp == NULL) { perror(path("vector.h")); exit(1); } - fprintf(fp, "\ -/*\n\ - * AT/386\n\ - * Macros for interrupt vector routines\n\ - * Generated by config program\n\ - */\n\ -\n"); - - fprintf(fp, "\ -#define BUILD_VECTORS \\\n\ - BUILD_VECTOR(clk, 0,0,0, _high_imask, _clkintr,1,1, al);\\\n"); - fprintf(fp, - "BUILD_VECTOR(rtc, 0,8,1, _stat_imask, _rtcintr,2,1_AND_2, ah);\\\n"); - - count=2; - for (dp = dtab; dp != 0; dp = dp->d_next) { - mp = dp->d_conn; - if (mp != 0 && /* mp != (struct device *)-1 &&*/ - eq(mp->d_name, "isa")) { - struct idlst *id, *id2; - - for (id = dp->d_vec; id; id = id->id_next) { - for (id2 = dp->d_vec; id2; id2 = id2->id_next) { - if (id2 == id) { - build_vector(fp, dp, id, count); - count++; - if (!strcmp(id->id, id2->id)) - break; - } - } - } - } - } - fprintf(fp, "\n\n#define NR_REAL_INT_HANDLERS %d\n", count); + fprintf(fp, "/*\n"); + fprintf(fp, " * vector.h\n"); + fprintf(fp, " * Macros for interrupt vector routines\n"); + fprintf(fp, " * Generated by config program\n"); + fprintf(fp, " */\n\n"); + fprintf(fp, "#define\tDEVICE_NAMES \"\\\n"); + fprintf(fp, "clk0 irqnn\\0\\\n"); +#ifdef STATCLOCK + /* + * XXX _all_ devices should be configured so that there is no need + * for kludges like this. + */ + fprintf(fp, "rtc0 irqnn\\0\\\n"); + dev_id = 2; +#else + dev_id = 1; +#endif + vector_devtab(fp, "bio", &dev_id); + vector_devtab(fp, "tty", &dev_id); + vector_devtab(fp, "net", &dev_id); + vector_devtab(fp, "null", &dev_id); + fprintf(fp, "\"\n\n"); + fprintf(fp, "#define\tNR_DEVICES\t%d\n", dev_id); (void) fclose(fp); } -build_vector(fp, dp, id, offset) - register FILE *fp; - register struct device *dp; - struct idlst *id; - int offset; +vector_devtab(fp, table, dev_idp) + FILE *fp; + char *table; + int *dev_idp; { - fprintf(fp, "\tBUILD_%sVECTOR(%s%d, %d,%d,%d", - strcmp(dp->d_name, "sio") == 0 ? "FAST_" : "", - dp->d_name, dp->d_unit, dp->d_unit, dp->d_irq, offset); - if (eq(dp->d_mask, "null")) - fprintf(fp, ", _%s%d_imask,", dp->d_name, dp->d_unit); - else - fprintf(fp, ", _%s_imask, ", dp->d_mask); - fprintf(fp, " _%s,%d,1", id->id, 1 + dp->d_irq / 8); - if (dp->d_irq < 8) - fprintf(fp, ", al"); - else - fprintf(fp, "_AND_2, ah"); - fprintf(fp, ");\\\n"); + register struct device *dp, *mp; + + for (dp = dtab; dp != NULL; dp = dp->d_next) { + if (dp->d_unit == QUES || !eq(dp->d_mask, table)) + continue; + mp = dp->d_conn; + if (mp == NULL || mp == TO_NEXUS || !eq(mp->d_name, "isa")) + continue; + fprintf(fp, "%s%d irqnn\\0\\\n", dp->d_name, dp->d_unit); + (*dev_idp)++; + } } diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index 5a0e89b..e92ae57 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -606,6 +606,7 @@ i386_ioconf() { register struct device *dp, *mp, *np; register int uba_n, slave; + int dev_id; FILE *fp; fp = fopen(path("ioconf.c"), "w"); @@ -617,11 +618,8 @@ i386_ioconf() fprintf(fp, " * ioconf.c \n"); fprintf(fp, " * Generated by config program\n"); fprintf(fp, " */\n\n"); - fprintf(fp, "#include \"machine/pte.h\"\n"); fprintf(fp, "#include \"sys/param.h\"\n"); - fprintf(fp, "#include \"sys/buf.h\"\n"); fprintf(fp, "\n"); - fprintf(fp, "#define V(s)\t__CONCAT(V,s)\n"); fprintf(fp, "#define C (caddr_t)\n\n"); /* * First print the isa initialization structures @@ -635,7 +633,9 @@ i386_ioconf() fprintf(fp, "#include \"i386/isa/isa_device.h\"\n"); fprintf(fp, "#include \"i386/isa/isa.h\"\n"); fprintf(fp, "#include \"i386/isa/icu.h\"\n\n"); - + fprintf(fp, "/*\n"); + fprintf(fp, " * XXX misplaced external declarations.\n"); + fprintf(fp, " */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { mp = dp->d_conn; if (mp == 0 || mp == TO_NEXUS || @@ -650,18 +650,23 @@ i386_ioconf() fprintf(stderr, "remapped irq 2 to irq 9, please update your config file\n"); dp->d_irq = 9; } - if (dp->d_irq != -1) - fprintf(fp, " extern void %s();", shandler(dp)); + if (dp->d_vec != NULL && dp->d_vec->id != NULL) + fprintf(fp, " inthand2_t %s;", shandler(dp)); fprintf(fp, "\n"); } - isa_devtab(fp, "bio"); +#ifdef STATCLOCK + dev_id = 2; +#else + dev_id = 1; +#endif + isa_devtab(fp, "bio", &dev_id); if(seen_wdc) isa_biotab(fp, "wdc"); if(seen_fdc) isa_biotab(fp, "fdc"); - isa_devtab(fp, "tty"); - isa_devtab(fp, "net"); - isa_devtab(fp, "null"); + isa_devtab(fp, "tty", &dev_id); + isa_devtab(fp, "net", &dev_id); + isa_devtab(fp, "null", &dev_id); } /* XXX David did this differently!!! */ /* pseudo_ioconf(fp); */ @@ -676,13 +681,13 @@ isa_biotab(fp, table) fprintf(fp, "\n\nstruct isa_device isa_biotab_%s[] = {\n", table); fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit flags drive*/\n"); +/* id driver iobase irq drq maddr msiz intr unit flags drive*/\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, table)) continue; - fprintf(fp, "{ &%3.3sdriver, %8.8s,", + fprintf(fp, "{ -1, &%3.3sdriver, %8.8s,", mp->d_name, mp->d_port); fprintf(fp, "%6.6s, %2d, C 0x%05X, %5d, %8.8s, %2d, 0x%04X, %2d },\n", sirq(mp->d_irq), mp->d_drq, mp->d_maddr, @@ -698,27 +703,27 @@ isa_biotab(fp, table) * * 4/26/93 rgrimes */ -isa_devtab(fp, table) +isa_devtab(fp, table, dev_idp) FILE *fp; char *table; + int *dev_idp; { register struct device *dp, *mp; fprintf(fp, "\n\nstruct isa_device isa_devtab_%s[] = {\n", table); fprintf(fp, "\ -/* driver iobase irq drq maddr msiz intr unit flags */\n"); +/* id driver iobase irq drq maddr msiz intr unit flags */\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { + if (dp->d_unit == QUES || !eq(dp->d_mask, table)) + continue; mp = dp->d_conn; - if (dp->d_unit == QUES || mp == 0 || - mp == TO_NEXUS || !eq(mp->d_name, "isa")) + if (mp == NULL || mp == TO_NEXUS || !eq(mp->d_name, "isa")) continue; - if (strcmp(dp->d_mask, table)) continue; + fprintf(fp, "{ %2d, &%3.3sdriver,", (*dev_idp)++, dp->d_name); if (dp->d_port) - fprintf(fp, "{ &%3.3sdriver, %8.8s,", - dp->d_name, dp->d_port); + fprintf(fp, " %8.8s,", dp->d_port); else - fprintf(fp, "{ &%3.3sdriver, 0x%04x,", - dp->d_name, dp->d_portn); + fprintf(fp, " 0x%04x,", dp->d_portn); fprintf(fp, "%6.6s, %2d, C 0x%05X, %5d, %8.8s, %2d, 0x%04X },\n", sirq(dp->d_irq), dp->d_drq, dp->d_maddr, dp->d_msize, shandler(dp), dp->d_unit, @@ -736,11 +741,17 @@ char * shandler(dp) register struct device *dp; { - static char buf[32 + 20]; + static char buf[32 + 1]; - if (dp->d_irq == -1) - return ("NULL"); - sprintf(buf, "V(%.32s%d)", dp->d_name, dp->d_unit); + if (dp->d_vec == NULL || dp->d_vec->id == NULL) + return "NULL"; + /* + * This is for ISA. We only support one interrupt handler in the + * devtabs. Handlers in the config file after the first for each + * device are ignored. Special handlers may be registered at + * runtime. + */ + sprintf(buf, "%.32s", dp->d_vec->id); return (buf); } -- cgit v1.1