summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitsuru IWASAKI <iwasaki@FreeBSD.org>2000-01-26 17:54:00 +0000
committerMitsuru IWASAKI <iwasaki@FreeBSD.org>2000-01-26 17:54:00 +0000
commit41c8853867bb79935280282ee5322c1b7dac016f (patch)
treee4d6188395f42581a65a53912af0b5da4a467a7c
parent4ba5197729ef8fa5660479d98cc7150817c6291a (diff)
Notes
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c60
-rw-r--r--usr.sbin/pccard/pccardd/cardd.h9
-rw-r--r--usr.sbin/pccard/pccardd/file.c25
-rw-r--r--usr.sbin/pccard/pccardd/pccard.conf.55
4 files changed, 92 insertions, 7 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index c64c002d17bb..b817e3c3f591 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -60,9 +60,21 @@ dump_config_file(void)
for (cp = cards; cp; cp = cp->next) {
printf("Card manuf %s, vers %s\n", cp->manuf, cp->version);
printf("Configuration entries:\n");
- for (confp = cp->config; confp; confp = confp->next)
- printf("\tIndex code = 0x%x, driver name = %s\n",
- confp->index, confp->driver->name);
+ for (confp = cp->config; confp; confp = confp->next) {
+ printf("\tIndex code = ");
+ switch (confp->index_type) {
+ case DEFAULT_INDEX:
+ printf("default");
+ break;
+ case AUTO_INDEX:
+ printf("auto");
+ break;
+ default:
+ printf("0x%x", confp->index);
+ break;
+ }
+ printf(", driver name = %s\n", confp->driver->name);
+ }
if (cp->insert) {
printf("Insert commands are:\n");
pr_cmd(cp->insert);
@@ -392,6 +404,30 @@ assign_driver(struct card *cp)
}
/*
+ * Auto select config index
+ */
+static struct cis_config *
+assign_card_index(struct cis * cis)
+{
+ struct cis_config *cp;
+ struct cis_ioblk *cio;
+ int i;
+
+ for (cp = cis->conf; cp; cp = cp->next) {
+ if (!cp->iospace || !cp->io)
+ continue;
+ for (cio = cp->io; cio; cio = cio->next) {
+ for (i = cio->addr; i < cio->addr + cio->size - 1; i++)
+ if (!bit_test(io_avail, i))
+ goto next;
+ }
+ return cp; /* found */
+ next:
+ }
+ return cis->def_config;
+}
+
+/*
* assign_io - Allocate resources to slot matching the
* configuration index selected.
*/
@@ -403,9 +439,21 @@ assign_io(struct slot *sp)
cis = sp->cis;
defconf = cis->def_config;
- for (cisconf = cis->conf; cisconf; cisconf = cisconf->next)
- if (cisconf->id == sp->config->index)
- break;
+ switch (sp->config->index_type) {
+ case DEFAULT_INDEX: /* default */
+ cisconf = defconf;
+ sp->config->index = cisconf->id;
+ break;
+ case AUTO_INDEX: /* auto */
+ cisconf = assign_card_index(cis);
+ sp->config->index = cisconf->id;
+ break;
+ default: /* normal, use index value */
+ for (cisconf = cis->conf; cisconf; cisconf = cisconf->next)
+ if (cisconf->id == sp->config->index)
+ break;
+ }
+
if (cisconf == 0) {
logmsg("Config id %d not present in this card",
sp->config->index);
diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h
index 8f255dba1afe..a0de46813e2a 100644
--- a/usr.sbin/pccard/pccardd/cardd.h
+++ b/usr.sbin/pccard/pccardd/cardd.h
@@ -46,6 +46,7 @@ struct cmd {
struct card_config {
struct card_config *next;
+ unsigned char index_type;
unsigned char index;
struct driver *driver;
int irq;
@@ -172,3 +173,11 @@ void readfile(char *);
#define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
#define MAXINCLUDES 10
+
+/*
+ * Config index types
+ */
+#define NORMAL_INDEX 0
+#define DEFAULT_INDEX 1
+#define AUTO_INDEX 2
+
diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c
index 9d9b6fa5ad54..fcd65b7173d0 100644
--- a/usr.sbin/pccard/pccardd/file.c
+++ b/usr.sbin/pccard/pccardd/file.c
@@ -87,6 +87,7 @@ static int num_tok(void);
static void error(char *);
static int keyword(char *);
static int irq_tok(int);
+static int config_tok(unsigned char *);
static int debuglevel_tok(int);
static struct allocblk *ioblk_tok(int);
static struct allocblk *memblk_tok(int);
@@ -214,6 +215,7 @@ static void
parse_card(void)
{
char *man, *vers, *tmp;
+ unsigned char index_type;
struct card *cp;
int i, iosize;
struct card_config *confp, *lastp;
@@ -232,7 +234,7 @@ parse_card(void)
switch (keyword(next_tok())) {
case KWD_CONFIG:
/* config */
- i = num_tok();
+ i = config_tok(&index_type);
if (i == -1) {
error("illegal card config index");
break;
@@ -251,6 +253,7 @@ parse_card(void)
break;
}
confp->index = i & 0x3F;
+ confp->index_type = index_type;
/*
* If no valid driver for this config, then do not save
@@ -440,6 +443,26 @@ irq_tok(int force)
}
/*
+ * Config index token
+ */
+static int
+config_tok(unsigned char *index_type)
+{
+ if (strcmp("default", next_tok()) == 0) {
+ *index_type = DEFAULT_INDEX;
+ return 0;
+ }
+ pusht = 1;
+ if (strcmp("auto", next_tok()) == 0) {
+ *index_type = AUTO_INDEX;
+ return 0;
+ }
+ pusht = 1;
+ *index_type = NORMAL_INDEX;
+ return num_tok();
+}
+
+/*
* debuglevel token. Must be between 0 and 9.
*/
static int
diff --git a/usr.sbin/pccard/pccardd/pccard.conf.5 b/usr.sbin/pccard/pccardd/pccard.conf.5
index ac3b09790e7e..c10c4d2191c0 100644
--- a/usr.sbin/pccard/pccardd/pccard.conf.5
+++ b/usr.sbin/pccard/pccardd/pccard.conf.5
@@ -147,6 +147,11 @@ from the range available in the card's CIS, the driver that
is to be associated with this configuration, and the interrupt
level (if any) to be assigned. An optional set of flags may
be assigned.
+In
+.Ar index ,
+specify either ``auto'' or ``default'' or the range available in the card's CIS.
+``auto'' allows to allocate resources automatically with information
+from the CIS and status of using I/O resources.
.Pp
The optional
.Em ether