diff options
-rw-r--r-- | usr.sbin/config/config.8 | 9 | ||||
-rw-r--r-- | usr.sbin/config/config.h | 8 | ||||
-rw-r--r-- | usr.sbin/config/config.y | 120 | ||||
-rw-r--r-- | usr.sbin/config/mkheaders.c | 29 | ||||
-rw-r--r-- | usr.sbin/config/mkioconf.c | 105 |
5 files changed, 78 insertions, 193 deletions
diff --git a/usr.sbin/config/config.8 b/usr.sbin/config/config.8 index 85da1a6..918e878 100644 --- a/usr.sbin/config/config.8 +++ b/usr.sbin/config/config.8 @@ -127,20 +127,13 @@ they are: .Pa ioconf.c , a description of what I/O devices are attached to the system; -.Pa vector.h , -definitions of -macros related to counting interrupts; .Pa Makefile , used by .Xr make 1 in building the system; header files, definitions of -the number of various devices that will be compiled into the system; -so-called swap configuration files, -definitions for -the disk areas to be used for the root file system -and system dumps. +the number of various devices that will be compiled into the system. .Pp After running .Nm config , diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 3e0c8a2..762e787 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -73,14 +73,15 @@ struct file_list { #define BEFORE_DEPEND 8 struct device { - int d_type; /* CONTROLLER, DEVICE, bus adaptor */ - struct device *d_conn; /* what it is connected to */ + int d_type; /* DEVICE, bus adaptor */ + char *d_conn; /* what it is connected to */ + int d_connunit; /* unit of connection */ char *d_name; /* name of device (e.g. rk11) */ int d_unit; /* unit number */ int d_drive; /* drive number */ int d_target; /* target number */ int d_lun; /* unit number */ - int d_slave; /* slave number */ + int d_bus; /* controller bus number */ int d_count; /* pseudo-device count */ #define QUES -1 /* -1 means '?' */ #define UNKNOWN -2 /* -2 means not set yet */ @@ -95,7 +96,6 @@ struct device { int d_irq; /* interrupt request */ struct device *d_next; /* Next one in list */ }; -#define TO_NEXUS (struct device *)-1 struct config { char *s_sysname; diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 2217b59..bc894b4 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -103,11 +103,11 @@ char errbuf[80]; int maxusers; int seen_scbus; +int warned_controller; #define ns(s) strdup(s) -static struct device *connect __P((char *, int)); -static struct device *huhcon __P((char *)); +static int connect __P((char *, int)); static void yyerror __P((char *s)); @@ -320,7 +320,12 @@ Device_spec: cur.d_type = DEVICE; } | CONTROLLER Dev_name Dev_info - = { cur.d_type = CONTROLLER; } | + = { + if (warned_controller < 3) + warnx("line %d: Obsolete keyword 'controller' found - use 'device'", yyline); + warned_controller++; + cur.d_type = DEVICE; + } | PSEUDO_DEVICE Init_dev Dev = { cur.d_name = $3; @@ -337,9 +342,9 @@ Dev_name: Init_dev Dev NUMBER = { cur.d_name = $2; + cur.d_unit = $3; if (eq($2, "scbus")) seen_scbus = 1; - cur.d_unit = $3; }; Init_dev: @@ -355,15 +360,15 @@ Dev_info: Con_info: AT Dev NUMBER = { - if (eq(cur.d_name, "mba") || eq(cur.d_name, "uba")) { - (void) snprintf(errbuf, sizeof(errbuf), - "%s must be connected to a nexus", cur.d_name); - yyerror(errbuf); - } - cur.d_conn = connect($2, $3); + connect($2, $3); + cur.d_conn = $2; + cur.d_connunit = $3; } | AT NEXUS NUMBER - = { cur.d_conn = TO_NEXUS; }; + = { + cur.d_conn = "nexus"; + cur.d_connunit = 0; + }; Info_list: Info_list Info @@ -373,13 +378,7 @@ Info_list: Info: BUS NUMBER /* controller scbus1 at ahc0 bus 1 - twin channel */ - = { - if (cur.d_conn != 0 && cur.d_conn->d_type == CONTROLLER) - cur.d_slave = $2; - else - yyerror("can't specify a bus to something " - "other than a controller"); - } | + = { cur.d_bus = $2; } | TARGET NUMBER = { cur.d_target = $2; } | UNIT NUMBER @@ -449,92 +448,41 @@ newdev(dp) * find the pointer to connect to the given device and number. * returns 0 if no such device and prints an error message */ -static struct device * +static int connect(dev, num) register char *dev; register int num; { register struct device *dp; - if (num == QUES) - return (huhcon(dev)); + if (num == QUES) { + for (dp = dtab; dp != 0; dp = dp->d_next) + if (eq(dp->d_name, dev)) + break; + if (dp == 0) { + (void) snprintf(errbuf, sizeof(errbuf), + "no %s's to wildcard", dev); + yyerror(errbuf); + return (0); + } + return (1); + } for (dp = dtab; dp != 0; dp = dp->d_next) { if ((num != dp->d_unit) || !eq(dev, dp->d_name)) continue; - if (dp->d_type != CONTROLLER) { + if (dp->d_type != DEVICE) { (void) snprintf(errbuf, sizeof(errbuf), - "%s connected to non-controller", dev); + "%s connected to non-device", dev); yyerror(errbuf); return (0); } - return (dp); + return (1); } (void) snprintf(errbuf, sizeof(errbuf), "%s %d not defined", dev, num); yyerror(errbuf); return (0); } -/* - * connect to an unspecific thing - */ -static struct device * -huhcon(dev) - register char *dev; -{ - register struct device *dp, *dcp; - struct device rdev; - int oldtype; - - /* - * First make certain that there are some of these to wildcard on - */ - for (dp = dtab; dp != 0; dp = dp->d_next) - if (eq(dp->d_name, dev)) - break; - if (dp == 0) { - (void) snprintf(errbuf, sizeof(errbuf), "no %s's to wildcard", - dev); - yyerror(errbuf); - return (0); - } - oldtype = dp->d_type; - dcp = dp->d_conn; - /* - * Now see if there is already a wildcard entry for this device - * (e.g. Search for a "uba ?") - */ - for (; dp != 0; dp = dp->d_next) - if (eq(dev, dp->d_name) && dp->d_unit == -1) - break; - /* - * If there isn't, make one because everything needs to be connected - * to something. - */ - if (dp == 0) { - dp = &rdev; - init_dev(dp); - dp->d_unit = QUES; - dp->d_name = ns(dev); - dp->d_type = oldtype; - newdev(dp); - dp = curp; - /* - * Connect it to the same thing that other similar things are - * connected to, but make sure it is a wildcard unit - * (e.g. up connected to sc ?, here we make connect sc? to a - * uba?). If other things like this are on the NEXUS or - * if they aren't connected to anything, then make the same - * connection, else call ourself to connect to another - * unspecific device. - */ - if (dcp == TO_NEXUS || dcp == 0) - dp->d_conn = dcp; - else - dp->d_conn = connect(dcp->d_name, QUES); - } - return (dp); -} - void init_dev(dp) register struct device *dp; @@ -546,7 +494,7 @@ init_dev(dp) dp->d_conflicts = 0; dp->d_disabled = 0; dp->d_flags = 0; - dp->d_slave = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = \ + dp->d_bus = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = \ dp->d_count = UNKNOWN; dp->d_port = (char *)0; dp->d_portn = -1; diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 636cce7..8bbcfbf 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -69,22 +69,11 @@ headers() if (!(dp->d_type & DEVDONE)) printf("Warning: pseudo-device \"%s\" is unknown\n", dp->d_name); - else - dp->d_type &= TYPEMASK; } if ((dp->d_type & TYPEMASK) == DEVICE) { if (!(dp->d_type & DEVDONE)) printf("Warning: device \"%s\" is unknown\n", dp->d_name); - else - dp->d_type &= TYPEMASK; - } - if ((dp->d_type & TYPEMASK) == CONTROLLER) { - if (!(dp->d_type & DEVDONE)) - printf("Warning: controller \"%s\" is unknown\n", - dp->d_name); - else - dp->d_type &= TYPEMASK; } } } @@ -98,23 +87,24 @@ do_count(dev, hname, search) register char *dev, *hname; int search; { - register struct device *dp, *mp; + register struct device *dp; register int count, hicount; + char *mp; /* * After this loop, "count" will be the actual number of units, * and "hicount" will be the highest unit declared. do_header() * must use this higher of these values. */ - for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) { + for (dp = dtab; dp != 0; dp = dp->d_next) { if (eq(dp->d_name, dev)) { if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) dp->d_type |= DEVDONE; else if ((dp->d_type & TYPEMASK) == DEVICE) dp->d_type |= DEVDONE; - else if ((dp->d_type & TYPEMASK) == CONTROLLER) - dp->d_type |= DEVDONE; } + } + for (hicount = count = 0, dp = dtab; dp != 0; dp = dp->d_next) { if (dp->d_unit != -1 && eq(dp->d_name, dev)) { if ((dp->d_type & TYPEMASK) == PSEUDO_DEVICE) { count = @@ -131,9 +121,12 @@ do_count(dev, hname, search) hicount = dp->d_unit + 1; if (search) { mp = dp->d_conn; - if (mp != 0 && mp != TO_NEXUS && - mp->d_conn != 0 && mp->d_conn != TO_NEXUS) { - do_count(mp->d_name, hname, 0); + if (mp != 0 && dp->d_connunit < 0) + mp = 0; + if (mp != 0 && eq(mp, "nexus")) + mp = 0; + if (mp != 0) { + do_count(mp, hname, 0); search = 0; } } diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c index db08c43..320fd3a 100644 --- a/usr.sbin/config/mkioconf.c +++ b/usr.sbin/config/mkioconf.c @@ -47,8 +47,6 @@ static const char rcsid[] = /* * build the ioconf.c file */ -static char *qu __P((int)); -static char *wnum __P((int)); static void scbus_devtab __P((FILE *)); static char * @@ -56,9 +54,6 @@ devstr(struct device *dp) { static char buf[100]; - if (dp == TO_NEXUS) - return "nexus0"; - if (dp->d_unit >= 0) { snprintf(buf, sizeof(buf), "%s%d", dp->d_name, dp->d_unit); return buf; @@ -70,11 +65,15 @@ static void write_device_resources(FILE *fp, struct device *dp) { int count = 0; + char buf[80]; fprintf(fp, "struct config_resource %s_resources[] = {\n", devstr(dp)); if (dp->d_conn) { - fprintf(fp, "\t{ \"at\",\tRES_STRING,\t{ (long)\"%s\" }},\n", - devstr(dp->d_conn)); + if (dp->d_connunit >= 0) + snprintf(buf, sizeof(buf), "%s%d", dp->d_conn, dp->d_connunit); + else + snprintf(buf, sizeof(buf), "%s", dp->d_conn); + fprintf(fp, "\t{ \"at\",\tRES_STRING,\t{ (long)\"%s\" }},\n", buf); count++; } if (dp->d_drive != -2) { @@ -89,6 +88,10 @@ write_device_resources(FILE *fp, struct device *dp) fprintf(fp, "\t{ \"lun\",\tRES_INT,\t{ %d }},\n", dp->d_lun); count++; } + if (dp->d_bus != -2) { + fprintf(fp, "\t{ \"bus\",\tRES_INT,\t{ %d }},\n", dp->d_bus); + count++; + } if (dp->d_flags) { fprintf(fp, "\t{ \"flags\",\tRES_INT,\t{ 0x%x }},\n", dp->d_flags); count++; @@ -135,7 +138,7 @@ write_all_device_resources(FILE *fp) struct device *dp; for (dp = dtab; dp != 0; dp = dp->d_next) { - if (dp->d_type != CONTROLLER && dp->d_type != DEVICE) + if (dp->d_type != DEVICE) continue; write_device_resources(fp, dp); } @@ -153,7 +156,7 @@ write_devtab(FILE *fp) fprintf(fp, "struct config_device config_devtab[] = {\n"); for (dp = dtab; dp != 0; dp = dp->d_next) { char* n = devstr(dp); - if (dp->d_type != CONTROLLER && dp->d_type != DEVICE) + if (dp->d_type != DEVICE) continue; fprintf(fp, "\t{ \"%s\",\t%d,\t%s_count,\t%s_resources },\n", dp->d_name, dp->d_unit, n, n); @@ -204,6 +207,8 @@ newbus_ioconf() static char * id(int unit) { + static char buf[32]; + char *s; switch(unit) { @@ -216,21 +221,13 @@ id(int unit) break; default: - s = qu(unit); + (void) snprintf(buf, sizeof(buf), "%d", unit); + s = buf; } return s; } -static void -id_put(fp, unit, s) - FILE *fp; - int unit; - char *s; -{ - fprintf(fp, "%s%s", id(unit), s); -} - /* XXX: dufault@hda.com: wiped out mkioconf.c locally: * All that nice "conflicting SCSI ID checking" is now * lost and should be put back in. @@ -239,7 +236,7 @@ static void scbus_devtab(fp) FILE *fp; { - register struct device *dp, *mp; + register struct device *dp; fprintf(fp, "\n"); fprintf(fp, "/*\n"); @@ -251,20 +248,14 @@ scbus_devtab(fp) fprintf(fp, "struct cam_sim_config cam_sinit[] = {\n"); fprintf(fp, "/* pathid, sim name, sim unit, sim bus */\n"); - /* XXX: Why do we always get an entry such as: - * { '?', "ncr", '?', '?' }, - */ - for (dp = dtab; dp; dp = dp->d_next) { - mp = dp->d_conn; - if (dp->d_type != CONTROLLER || mp == TO_NEXUS || mp == 0 || - !eq(dp->d_name, "scbus")) { + if (dp->d_type != DEVICE || dp->d_conn == 0 || + !eq(dp->d_name, "scbus")) continue; - } fprintf(fp, "{ %s, ", id(dp->d_unit)); - fprintf(fp, "\"%s\", ", mp->d_name); - fprintf(fp, "%s, ", id(mp->d_unit)); - fprintf(fp, "%s },\n", id(dp->d_slave)); + fprintf(fp, "\"%s\", ", dp->d_conn); + fprintf(fp, "%s, ", id(dp->d_connunit)); + fprintf(fp, "%s },\n", id(dp->d_bus)); } fprintf(fp, "{ 0, 0, 0, 0 }\n"); fprintf(fp, "};\n"); @@ -275,58 +266,18 @@ scbus_devtab(fp) fprintf(fp, "/* periph name, periph unit, pathid, target, LUN, flags */\n"); for (dp = dtab; dp; dp = dp->d_next) { - if (dp->d_type == CONTROLLER || dp->d_type == PSEUDO_DEVICE || - dp->d_conn == TO_NEXUS) - continue; - - mp = dp->d_conn; - if (mp == 0 || !eq(mp->d_name, "scbus")) { + if (dp->d_type != DEVICE || dp->d_conn == 0 || + !eq(dp->d_conn, "scbus")) continue; - } - - if (mp->d_conn == 0 && - (dp->d_target != UNKNOWN && dp->d_target != QUES)) { - fprintf(stderr, - "Warning: %s%s is configured at ", - dp->d_name, wnum(dp->d_unit)); - - fprintf(stderr, - "%s%s which is not fixed at a single adapter.\n", - mp->d_name, wnum(mp->d_unit)); - } fprintf(fp, "{ "); fprintf(fp, "\"%s\", ", dp->d_name); - id_put(fp, dp->d_unit, ", "); - id_put(fp, mp->d_unit, ", "); - id_put(fp, dp->d_target, ", "); - id_put(fp, dp->d_lun, ", "); + fprintf(fp, "%d, ", dp->d_unit); + fprintf(fp, "%d, ", dp->d_connunit); + fprintf(fp, "%d, ", dp->d_target); + fprintf(fp, "%d, ", dp->d_lun); fprintf(fp, " 0x%x },\n", dp->d_flags); } fprintf(fp, "{ 0, 0, 0, 0, 0, 0 }\n"); fprintf(fp, "};\n"); } - -static char * -qu(num) - int num; -{ - - if (num == QUES) - return ("'?'"); - if (num == UNKNOWN) - return (" -1"); - (void) snprintf(errbuf, sizeof(errbuf), "%3d", num); - return (errbuf); -} - -static char * -wnum(num) - int num; -{ - - if (num == QUES || num == UNKNOWN) - return ("?"); - (void) snprintf(errbuf, sizeof(errbuf), "%d", num); - return (errbuf); -} |