Merge from PAO; Add new keywords for pccard.conf, auto and default.

This will help importing pccard entries (and users :) from PAO
into -CURRENT.
This commit is contained in:
Mitsuru IWASAKI 2000-01-26 17:54:00 +00:00
parent 4ba5197729
commit 41c8853867
4 changed files with 92 additions and 7 deletions

View File

@ -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);
@ -391,6 +403,30 @@ assign_driver(struct card *cp)
return (conf);
}
/*
* 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);

View File

@ -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

View File

@ -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
@ -439,6 +442,26 @@ irq_tok(int force)
return (-1);
}
/*
* 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.
*/

View File

@ -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