summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c37
-rw-r--r--usr.sbin/pccard/pccardd/cardd.h19
-rw-r--r--usr.sbin/pccard/pccardd/file.c45
3 files changed, 86 insertions, 15 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index 2e5a529515e8..3ce1f92b7fd9 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: cardd.c,v 1.33 1999/01/10 13:00:09 guido Exp $";
+ "$Id: cardd.c,v 1.33.2.1 1999/03/03 11:15:33 kuriyama Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -386,12 +386,24 @@ assign_io(struct slot *sp)
/* Now look at I/O. */
bzero(&sp->io, sizeof(sp->io));
- if (cisconf->iospace || (defconf && defconf->iospace)) {
+ if (cisconf->iospace || (defconf && defconf->iospace)
+ || sp->card->iosize) {
struct cis_config *cp;
+ int iosize;
cp = cisconf;
if (!cisconf->iospace)
cp = defconf;
+ iosize = sp->card->iosize;
+
+ /* iosize auto */
+ if (iosize < 0) {
+ if (cp->io)
+ iosize = cp->io->size;
+ else
+ iosize = 1 << cp->io_addr;
+ }
+
/*
* If # of I/O lines decoded == 10, then card does its
* own decoding.
@@ -400,16 +412,20 @@ assign_io(struct slot *sp)
* If no address (but a length) is available, allocate
* from the pool.
*/
- if (cp->io) {
+ if (iosize) {
+ sp->io.addr = 0;
+ sp->io.size = iosize;
+ }
+ else if (cp->io) {
sp->io.addr = cp->io->addr;
sp->io.size = cp->io->size;
- } else
+ } else {
/*
* No I/O block, assume the address lines
* decode gives the size.
*/
sp->io.size = 1 << cp->io_addr;
-
+ }
if (sp->io.addr == 0) {
int i = bit_fns(io_avail, IOPORTS, sp->io.size);
@@ -419,6 +435,7 @@ assign_io(struct slot *sp)
}
bit_nclear(io_avail, sp->io.addr,
sp->io.addr + sp->io.size - 1);
+ sp->flags |= IO_ASSIGNED;
/* Set up the size to take into account the decode lines. */
sp->io.cardaddr = cp->io_addr;
@@ -441,6 +458,7 @@ assign_io(struct slot *sp)
#endif
}
sp->irq = sp->config->irq;
+ sp->flags |= IRQ_ASSIGNED;
return (0);
}
@@ -495,8 +513,7 @@ setup_slot(struct slot *sp)
lseek(sp->fd, offs + 2, SEEK_SET);
write(sp->fd, &c, sizeof(c));
}
- mem.window = 0;
- if (sp->mem.addr) {
+ if (sp->flags & MEM_ASSIGNED) {
mem.window = 0;
mem.flags = sp->mem.flags | MDF_ACTIVE | MDF_16BITS;
mem.start = (caddr_t) sp->mem.addr;
@@ -508,7 +525,7 @@ setup_slot(struct slot *sp)
}
}
io.window = 0;
- if (sp->io.size) {
+ if (sp->flags & IO_ASSIGNED) {
io.flags = sp->io.flags;
io.start = sp->io.addr;
io.size = sp->io.size;
@@ -534,14 +551,14 @@ setup_slot(struct slot *sp)
drv.unit = drvp->unit;
drv.irqmask = 1 << sp->irq;
drv.flags = 0x80;
- if (sp->mem.size) {
+ if (sp->flags & MEM_ASSIGNED) {
drv.mem = sp->mem.addr;
drv.memsize = sp->mem.size;
} else {
drv.mem = 0;
drv.memsize = 0;
}
- if (sp->io.size)
+ if (sp->flags & IO_ASSIGNED)
drv.iobase = sp->io.addr;
else
drv.iobase = 0;
diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h
index ec2ed025bf79..5e1dc7ff3c50 100644
--- a/usr.sbin/pccard/pccardd/cardd.h
+++ b/usr.sbin/pccard/pccardd/cardd.h
@@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: cardd.h,v 1.11 1998/02/27 08:19:24 hosokawa Exp $
+ * $Id: cardd.h,v 1.12 1998/03/09 05:18:55 hosokawa Exp $
*
* Common include file for PCMCIA daemon
*/
@@ -59,6 +59,7 @@ struct card {
char *version;
int ether; /* For net cards, ether at offset */
int reset_time; /* Reset time */
+ int iosize; /* I/O window size (ignore location) */
struct card_config *config; /* List of configs */
struct cmd *insert; /* Insert commands */
struct cmd *remove; /* Remove commands */
@@ -109,10 +110,22 @@ struct slot {
struct allocblk io; /* I/O block spec */
struct allocblk mem; /* Memory block spec */
int irq; /* Irq value */
+ int flags; /* Resource assignment flags */
};
-EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */
-EXTERN struct allocblk *pool_mem; /* Memory in the pool */
+/*
+ * Slot resource assignment/configuration flags
+ */
+#define IO_ASSIGNED 0x1
+#define MEM_ASSIGNED 0x2
+#define IRQ_ASSIGNED 0x4
+#define EADDR_CONFIGED 0x8
+#define WL_CONFIGED 0x10
+#define AFLAGS (IO_ASSIGNED | MEM_ASSIGNED | IRQ_ASSIGNED)
+#define CFLAGS (EADDR_CONFIGED | WL_CONFIGED)
+
+EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */
+EXTERN struct allocblk *pool_mem; /* Memory in the pool */
EXTERN int pool_irq[16]; /* IRQ allocations */
EXTERN struct driver *drivers; /* List of drivers */
EXTERN struct card *cards;
diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c
index caad60c08cf2..0f872f0535a9 100644
--- a/usr.sbin/pccard/pccardd/file.c
+++ b/usr.sbin/pccard/pccardd/file.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: file.c,v 1.17 1999/06/17 21:07:58 markm Exp $";
+ "$Id: file.c,v 1.16.2.1 1999/08/13 15:58:25 kuriyama Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -52,6 +52,7 @@ static char *keys[] = {
"ether", /* 9 */
"insert", /* 10 */
"remove", /* 11 */
+ "iosize", /* 12 */
0
};
@@ -66,6 +67,7 @@ static char *keys[] = {
#define KWD_ETHER 9
#define KWD_INSERT 10
#define KWD_REMOVE 11
+#define KWD_IOSIZE 12
struct flags {
char *name;
@@ -82,6 +84,7 @@ static int irq_tok(int);
static struct allocblk *ioblk_tok(int);
static struct allocblk *memblk_tok(int);
static struct driver *new_driver(char *);
+static int iosize_tok(void);
static void addcmd(struct cmd **);
static void parse_card(void);
@@ -181,9 +184,10 @@ parse_card(void)
{
char *man, *vers;
struct card *cp;
- int i;
+ int i, iosize;
struct card_config *confp, *lastp;
+ confp = 0;
man = newstr(next_tok());
vers = newstr(next_tok());
cp = xmalloc(sizeof(*cp));
@@ -256,6 +260,19 @@ parse_card(void)
/* remove */
addcmd(&cp->remove);
break;
+ case KWD_IOSIZE:
+ /* iosize */
+ iosize = iosize_tok();
+ if (!iosize) {
+ error("Illegal cardio arguments");
+ break;
+ }
+ if (!confp) {
+ error("iosize should be placed after config");
+ break;
+ }
+ cp->iosize = iosize;
+ break;
default:
pusht = 1;
return;
@@ -379,6 +396,30 @@ irq_tok(int force)
}
/*
+ * iosize token
+ * iosize {<size>|auto}
+ */
+static int
+iosize_tok(void)
+{
+ int iosize = 0;
+ if (strcmp("auto", next_tok()) == 0)
+ iosize = -1; /* wildcard */
+ else {
+ pusht = 1;
+ iosize = num_tok();
+ if (iosize == -1)
+ return 0;
+ }
+#ifdef DEBUG
+ if (verbose)
+ printf("iosize: size=%x\n", iosize);
+#endif
+ return iosize;
+}
+
+
+/*
* search the table for a match.
*/
static int