Date: Fri, 23 Jul 1999 00:34:14 +0900 (JST) From: hosokawa@itc.keio.ac.jp (HOSOKAWA Tatsumi) To: mike@smith.net.au, imp@village.org, nate@mt.sri.com, mobile@FreeBSD.ORG Cc: hosokawa@itc.keio.ac.jp Subject: Re: usr.sbin/pccard/pccardd change for "cardio" and "cardmem" Message-ID: <199907221534.AAA20034@afs.ntc.mita.keio.ac.jp> In-Reply-To: Your message of "Thu, 22 Jul 1999 10:13:06 JST". <199907220113.KAA11511@afs.ntc.mita.keio.ac.jp>
index | next in thread | previous in thread | raw e-mail
In article <199907220113.KAA11511@afs.ntc.mita.keio.ac.jp>
hosokawa@itc.keio.ac.jp writes:
>> I'll rewrite my patch soon.
OK, this is "iosize" patch.
Index: cardd.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/cardd.c,v
retrieving revision 1.34
diff -u -r1.34 cardd.c
--- cardd.c 1999/02/05 16:00:17 1.34
+++ cardd.c 1999/07/22 15:30:01
@@ -179,6 +179,9 @@
sp->config = 0;
/* release io */
bit_nset(io_avail, sp->io.addr, sp->io.addr + sp->io.size - 1);
+ /* release irq */
+ if (sp->irq)
+ pool_irq[sp->irq] = 1;
}
/*
@@ -386,12 +389,15 @@
/* 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;
/*
* If # of I/O lines decoded == 10, then card does its
* own decoding.
@@ -400,16 +406,20 @@
* 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 +429,7 @@
}
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 +452,7 @@
#endif
}
sp->irq = sp->config->irq;
+ sp->flags |= IRQ_ASSIGNED;
return (0);
}
@@ -495,20 +507,31 @@
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;
- mem.card = sp->mem.cardaddr;
- mem.size = sp->mem.size;
- if (ioctl(sp->fd, PIOCSMEM, &mem)) {
- logerr("ioctl (PIOCSMEM)");
- return (0);
+
+ /*
+ * This allows cardmem directives in /etc/pccard.conf
+ * with addr = 0x0 for cards which can tolerate arbitrary
+ * mappings
+ */
+ if (!sp->mem.addr)
+ sp->mem.addr = alloc_memory(sp->mem.size);
+
+ if (sp->mem.addr) {
+ mem.window = 0;
+ mem.flags = sp->mem.flags | MDF_ACTIVE | MDF_16BITS;
+ mem.start = (caddr_t) sp->mem.addr;
+ mem.card = sp->mem.cardaddr;
+ mem.size = sp->mem.size;
+ if (ioctl(sp->fd, PIOCSMEM, &mem)) {
+ logerr("ioctl (PIOCSMEM)");
+ return (0);
+ }
}
}
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 +557,14 @@
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;
Index: cardd.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/cardd.h,v
retrieving revision 1.12
diff -u -r1.12 cardd.h
--- cardd.h 1998/03/09 05:18:55 1.12
+++ cardd.h 1999/07/22 15:30:04
@@ -59,6 +59,7 @@
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 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;
Index: file.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pccard/pccardd/file.c,v
retrieving revision 1.18
diff -u -r1.18 file.c
--- file.c 1999/07/15 03:04:31 1.18
+++ file.c 1999/07/22 15:30:04
@@ -52,6 +52,7 @@
"ether", /* 9 */
"insert", /* 10 */
"remove", /* 11 */
+ "iosize", /* 12 */
0
};
@@ -66,6 +67,7 @@
#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 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 @@
{
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 @@
/* 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;
@@ -378,6 +395,30 @@
error("illegal IRQ value");
return (-1);
}
+
+/*
+ * 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.
--
HOSOKAWA, Tatsumi
Assistant Manager
Information Technology Center, Keio University
<hosokawa@itc.keio.ac.jp>
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907221534.AAA20034>
