summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard
diff options
context:
space:
mode:
authoriwasaki <iwasaki@FreeBSD.org>2000-01-26 17:54:00 +0000
committeriwasaki <iwasaki@FreeBSD.org>2000-01-26 17:54:00 +0000
commit6d698ef3f564b74b3fa4f506de9189e506ce562c (patch)
tree2669e661705d7bc1a93d9e1bc9b5bfd044ec7511 /usr.sbin/pccard
parent36c90d4614149a3d24b5b8bbc3e8eaea79cedb3b (diff)
downloadFreeBSD-src-6d698ef3f564b74b3fa4f506de9189e506ce562c.zip
FreeBSD-src-6d698ef3f564b74b3fa4f506de9189e506ce562c.tar.gz
Merge from PAO; Add new keywords for pccard.conf, auto and default.
This will help importing pccard entries (and users :) from PAO into -CURRENT.
Diffstat (limited to 'usr.sbin/pccard')
-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 c64c002..b817e3c 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 8f255db..a0de468 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 9d9b6fa..fcd65b7 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 ac3b097..c10c4d2 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
OpenPOWER on IntegriCloud