summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config
diff options
context:
space:
mode:
authordufault <dufault@FreeBSD.org>1995-03-01 22:34:05 +0000
committerdufault <dufault@FreeBSD.org>1995-03-01 22:34:05 +0000
commite77e1f47174a626361d4397e18fe84509556dfbb (patch)
tree14e946a4bead112719c983dc9ce59802dd734a33 /usr.sbin/config
parent466baaef08335b4fb3b94989861766f7fbe3146f (diff)
downloadFreeBSD-src-e77e1f47174a626361d4397e18fe84509556dfbb.zip
FreeBSD-src-e77e1f47174a626361d4397e18fe84509556dfbb.tar.gz
Added configuration for SCSI devices wired in place. The documentation
is in "man 4 scsi".
Diffstat (limited to 'usr.sbin/config')
-rw-r--r--usr.sbin/config/config.h3
-rw-r--r--usr.sbin/config/config.y10
-rw-r--r--usr.sbin/config/lang.l2
-rw-r--r--usr.sbin/config/mkioconf.c146
4 files changed, 160 insertions, 1 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h
index 80d46bf..15adc3a 100644
--- a/usr.sbin/config/config.h
+++ b/usr.sbin/config/config.h
@@ -114,6 +114,8 @@ struct device {
int d_addr; /* address of csr */
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 */
#define QUES -1 /* -1 means '?' */
#define UNKNOWN -2 /* -2 means not set yet */
@@ -193,6 +195,7 @@ int seen_vba;
#endif
#if MACHINE_I386
int seen_isa;
+int seen_scbus;
#endif
int seen_cd;
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 97257eb..3e1dc9f 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -49,9 +49,11 @@
%token SIZE
%token SLAVE
%token SWAP
+%token TARGET
%token TIMEZONE
%token TTY
%token TRACE
+%token UNIT
%token VECTOR
%token <str> ID
@@ -561,6 +563,8 @@ Dev_name:
seen_vba = 1;
else if (eq($2, "isa"))
seen_isa = 1;
+ else if (eq($2, "scbus"))
+ seen_scbus = 1;
cur.d_unit = $3;
};
@@ -596,6 +600,10 @@ Info_list:
Info:
CSR NUMBER
= { cur.d_addr = $2; } |
+ TARGET NUMBER
+ = { cur.d_target = $2; } |
+ UNIT NUMBER
+ = { cur.d_lun = $2; } |
DRIVE NUMBER
= { cur.d_drive = $2; } |
SLAVE NUMBER
@@ -904,7 +912,7 @@ init_dev(dp)
dp->d_vec = 0;
dp->d_addr = dp->d_flags = dp->d_dk = 0;
dp->d_pri = -1;
- dp->d_slave = dp->d_drive = dp->d_unit = UNKNOWN;
+ dp->d_slave = dp->d_lun = dp->d_target = dp->d_drive = dp->d_unit = UNKNOWN;
dp->d_port = (char *)0;
dp->d_portn = 0;
dp->d_irq = -1;
diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l
index d4052f3..bc18bbf 100644
--- a/usr.sbin/config/lang.l
+++ b/usr.sbin/config/lang.l
@@ -102,11 +102,13 @@ struct kt {
{ "slave", SLAVE },
{ "swap", SWAP },
{ "tape", DEVICE },
+ { "target", TARGET },
#if MACHINE_I386
{ "tty", TTY },
#endif MACHINE_I386
{ "timezone", TIMEZONE },
{ "trace", TRACE },
+ { "unit", UNIT },
{ "vector", VECTOR },
{ 0, 0 },
};
diff --git a/usr.sbin/config/mkioconf.c b/usr.sbin/config/mkioconf.c
index c18628f..c4d6c2b 100644
--- a/usr.sbin/config/mkioconf.c
+++ b/usr.sbin/config/mkioconf.c
@@ -670,6 +670,9 @@ i386_ioconf()
isa_devtab(fp, "net", &dev_id);
isa_devtab(fp, "null", &dev_id);
}
+ if (seen_scbus) {
+ scbus_devtab(fp, &dev_id);
+ }
/* XXX David did this differently!!! */
/* pseudo_ioconf(fp); */
(void) fclose(fp);
@@ -734,6 +737,149 @@ isa_devtab(fp, table, dev_idp)
fprintf(fp, "0\n};\n");
}
+static char *id(int unit)
+{
+ char *s;
+ switch(unit)
+ {
+ case UNKNOWN:
+ s ="SCCONF_UNSPEC";
+ break;
+
+ case QUES:
+ s ="SCCONF_ANY";
+ break;
+
+ default:
+ s = qu(unit);
+ }
+
+ return s;
+}
+
+static void id_put(fp, unit, s)
+ FILE *fp;
+ int unit;
+ char *s;
+{
+ fprintf(fp, "%s%s", id(unit), s);
+}
+
+struct node
+{
+ char *id;
+ struct node *next;
+};
+
+static void
+add_unique(struct node *node, char *id)
+{
+ struct node *prev = node;
+
+ for (prev = node; node; node = node->next)
+ {
+ if (strcmp(node->id, id) == 0) /* Already there */
+ return;
+
+ prev = node;
+ }
+
+ node = (struct node *)malloc(sizeof(node));
+ prev->next = node;
+
+ node->id = id;
+ node->next = 0;
+}
+
+static int
+is_old_scsi_device(char *name)
+{
+ static char *tab[] = {"cd", "ch", "sd", "st", "uk"};
+ int i;
+ for (i = 0; i < sizeof(tab) / sizeof(tab[0]); i++)
+ if (eq(tab[i], name))
+ return 1;
+
+ return 0;
+}
+
+/* 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.
+ */
+scbus_devtab(fp, dev_idp)
+ FILE *fp;
+ int *dev_idp;
+{
+ register struct device *dp, *mp;
+ struct node unique, *node;
+ unique.id = "unique";
+ unique.next = 0;
+
+ fprintf(fp, "#include \"scsi/scsiconf.h\"\n");
+ fprintf(fp, "\nstruct scsi_ctlr_config scsi_cinit[] = {\n");
+ fprintf(fp, "/* unit driver driver unit */\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")) {
+ continue;
+ }
+ fprintf(fp, "{ %s, ", id(dp->d_unit));
+ fprintf(fp, "\"%s\", ", mp->d_name);
+ fprintf(fp, "%s },\n", id(mp->d_unit));
+ }
+ fprintf(fp, "{ 0, 0, 0 }\n};\n");
+
+ fprintf(fp, "\nstruct scsi_device_config scsi_dinit[] = {\n");
+ fprintf(fp, "/* name unit cunit target LUN flags */\n");
+ for (dp = dtab; dp; dp = dp->d_next) {
+ if (dp->d_type == CONTROLLER || dp->d_type == MASTER ||
+ dp->d_type == PSEUDO_DEVICE)
+ continue;
+
+ /* For backward compatability we must add the original
+ * SCSI devices by name even if we don't know it is
+ * connected to a SCSI bus.
+ */
+ if (is_old_scsi_device(dp->d_name))
+ add_unique(&unique, dp->d_name);
+
+ mp = dp->d_conn;
+ if (mp == 0 || !eq(mp->d_name, "scbus")) {
+ continue;
+ }
+ mp = mp->d_conn;
+ if (mp == 0) {
+ printf("%s%s: devices not attached to a SCSI controller\n",
+ dp->d_name, wnum(dp->d_unit));
+ continue;
+ }
+
+ 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, " 0x%x },\n", dp->d_flags);
+ add_unique(&unique, dp->d_name);
+ }
+ fprintf(fp, "{ 0, 0, 0, 0, 0, 0 }\n};\n");
+
+ for (node = unique.next; node; node = node->next)
+ fprintf(fp, "extern void %sinit();\n", node->id);
+ fprintf(fp, "void (*scsi_tinit[])(void) = {\n");
+ for (node = unique.next; node; node = node->next)
+ fprintf(fp, " %sinit,\n", node->id);
+ fprintf(fp, "0,\n};\n");
+}
+
/*
* XXX - there should be a general function to print devtabs instead of these
* little pieces of it.
OpenPOWER on IntegriCloud