Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 1999 23:49:54 -0600
From:      Warner Losh <imp@village.org>
To:        NAKAGAWA Yoshihisa <y-nakaga@nwsl.mesh.ad.jp>
Cc:        mobile@FreeBSD.ORG
Subject:   Re: Oooppsss 
Message-ID:  <199907150549.XAA68558@harmony.village.org>
In-Reply-To: Your message of "Thu, 15 Jul 1999 12:53:45 %2B0900." <199907150353.DAA22017@chandra.eatell.msr.prug.or.jp> 
References:  <199907150353.DAA22017@chandra.eatell.msr.prug.or.jp>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <199907150353.DAA22017@chandra.eatell.msr.prug.or.jp> NAKAGAWA Yoshihisa writes:
: I don't like many start-up argument. New config-file's entry is
: better for me.

I've added this and debuglevel, fixed the dodebug abuse and documented
it all.

Warner

Index: cardd.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/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/15 05:46:22
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include "cardd.h"
@@ -114,7 +115,8 @@
 			if (mem == 0) {
 				mem = alloc_memory(4 * 1024);
 				if (mem == 0)
-					die("can't allocate memory for controller access");
+					die("can't allocate memory for "
+					    "controller access");
 				if (ioctl(fd, PIOCRWMEM, &mem))
 					logerr("ioctl (PIOCRWMEM)");
 			}
@@ -198,7 +200,7 @@
 {
 	struct card *cp;
 
-	sleep(5);
+	usleep(pccard_init_sleep);
 	sp->cis = readcis(sp->fd);
 	if (sp->cis == 0) {
 		logmsg("Error reading CIS on %s\n", sp->name);
@@ -281,10 +283,10 @@
 		if (conf->inuse == 0 && conf->driver->card == cp &&
 		    conf->driver->config == conf &&
 		    conf->driver->inuse == 0) {
-#ifdef	DEBUG
-			logmsg("Found existing driver (%s) for %s\n",
-			    conf->driver->name, cp->manuf);
-#endif
+			if (debug_level > 0) {
+				logmsg("Found existing driver (%s) for %s\n",
+				    conf->driver->name, cp->manuf);
+			}
 			conf->driver->inuse = 1;
 			conf->inuse = 1;
 			return (conf);
@@ -348,8 +350,11 @@
 	for (cisconf = cis->conf; cisconf; cisconf = cisconf->next)
 		if (cisconf->id == sp->config->index)
 			break;
-	if (cisconf == 0)
+	if (cisconf == 0) {
+		logmsg("Config id %d not present in this card",
+		    sp->config->index);
 		return (-1);
+	}
 	sp->card_config = cisconf;
 
 	/*
@@ -378,10 +383,10 @@
 			sp->config->driver->mem = sp->mem.addr;
 		}
 		sp->mem.cardaddr = 0x4000;
-#ifdef	DEBUG
-		logmsg("Using mem addr 0x%x, size %d, card addr 0x%x\n",
-			sp->mem.addr, sp->mem.size, sp->mem.cardaddr);
-#endif
+		if (debug_level > 0) {
+			logmsg("Using mem addr 0x%x, size %d, card addr 0x%x\n",
+			    sp->mem.addr, sp->mem.size, sp->mem.cardaddr);
+		}
 	}
 
 	/* Now look at I/O. */
@@ -435,10 +440,10 @@
 			sp->io.flags = IODF_WS | IODF_CS16 | IODF_16BIT;
 			break;
 		}
-#ifdef	DEBUG
-		logmsg("Using I/O addr 0x%x, size %d\n",
-		    sp->io.addr, sp->io.size);
-#endif
+		if (debug_level > 0) {
+			logmsg("Using I/O addr 0x%x, size %d\n",
+			    sp->io.addr, sp->io.size);
+		}
 	}
 	sp->irq = sp->config->irq;
 	return (0);
@@ -476,11 +481,12 @@
 	c = sp->config->index;
 	c |= 0x40;
 	write(sp->fd, &c, sizeof(c));
-#ifdef	DEBUG
-	logmsg("Setting config reg at offs 0x%lx to 0x%x, Reset time = %d ms\n",
-		(unsigned long)offs, c, sp->card->reset_time);
-#endif
-	sleep(5);
+	if (debug_level > 0) {
+		logmsg("Setting config reg at offs 0x%lx to 0x%x, "
+		    "Reset time = %d ms\n", (unsigned long)offs, c,
+		    sp->card->reset_time);
+	}
+	usleep(pccard_init_sleep);
 	usleep(sp->card->reset_time * 1000);
 
 	/* If other config registers exist, set them up. */
@@ -520,10 +526,11 @@
 			io.size = 0x300;
 		}
 #endif
-#ifdef	DEBUG
-		logmsg("Assigning I/O window %d, start 0x%x, size 0x%x flags 0x%x\n",
-			io.window, io.start, io.size, io.flags);
-#endif
+		if (debug_level > 0) {
+			logmsg("Assigning I/O window %d, start 0x%x, "
+			    "size 0x%x flags 0x%x\n", io.window, io.start,
+			    io.size, io.flags);
+		}
 		io.flags |= IODF_ACTIVE;
 		if (ioctl(sp->fd, PIOCSIO, &io)) {
 			logerr("ioctl (PIOCSIO)");
@@ -541,14 +548,16 @@
 		drv.mem = 0;
 		drv.memsize = 0;
 	}
-	if (sp->io.size)
+	if (sp->io.size) {
 		drv.iobase = sp->io.addr;
-	else
+	} else {
 		drv.iobase = 0;
-#ifdef	DEBUG
-	logmsg("Assign %s%d, io 0x%x, mem 0x%lx, %d bytes, irq %d, flags %x\n",
-	    drv.name, drv.unit, drv.iobase, drv.mem, drv.memsize, sp->irq, drv.flags);
-#endif
+	}
+	if (debug_level > 0) {
+		logmsg("Assign %s%d, io 0x%x, mem 0x%lx, %d bytes, irq %d, "
+		    "flags %x\n", drv.name, drv.unit, drv.iobase, drv.mem,
+		    drv.memsize, sp->irq, drv.flags);
+	}
 
 	/*
 	 * If the driver fails to be connected to the device,
@@ -556,7 +565,8 @@
 	 */
 	memcpy(drv.misc, sp->eaddr, 6);
 	if (ioctl(sp->fd, PIOCSDRV, &drv)) {
-		logmsg("driver allocation failed for %s", sp->card->manuf);
+		logmsg("driver allocation failed for %s(%s): %s",
+		    sp->card->manuf, sp->card->version, strerror(errno));
 		return (0);
 	}
 	return (1);
Index: cardd.h
===================================================================
RCS file: /home/imp/FreeBSD/CVS/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/15 05:45:38
@@ -118,6 +118,8 @@
 EXTERN struct card *cards;
 EXTERN bitstr_t *mem_avail;
 EXTERN bitstr_t *io_avail;
+EXTERN int pccard_init_sleep;			/* Time to sleep on init */
+EXTERN int debug_level;
 
 /* cardd.c functions */
 void		 dump_config_file(void);
Index: file.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/file.c,v
retrieving revision 1.17
diff -u -r1.17 file.c
--- file.c	1999/06/17 21:07:58	1.17
+++ file.c	1999/07/15 05:45:14
@@ -52,6 +52,8 @@
 	"ether",		/* 9 */
 	"insert",		/* 10 */
 	"remove",		/* 11 */
+	"initsleep",		/* 12 */
+	"debuglevel",		/* 13 */
 	0
 };
 
@@ -66,6 +68,8 @@
 #define KWD_ETHER		9
 #define KWD_INSERT		10
 #define KWD_REMOVE		11
+#define KWD_INITSLEEP		12
+#define KWD_DEBUGLEVEL		13
 
 struct flags {
 	char   *name;
@@ -79,6 +83,8 @@
 static void    error(char *);
 static int     keyword(char *);
 static int     irq_tok(int);
+static int     initsleep_tok(int);
+static int     debuglevel_tok(int);
 static struct allocblk *ioblk_tok(int);
 static struct allocblk *memblk_tok(int);
 static struct driver *new_driver(char *);
@@ -166,6 +172,16 @@
 			/* Card definition. */
 			parse_card();
 			break;
+		case KWD_INITSLEEP:
+			i = initsleep_tok(0);
+			if (i > 0)
+				pccard_init_sleep = i;
+			break;
+		case KWD_DEBUGLEVEL:
+			i = debuglevel_tok(0);
+			if (i > 0)
+				debug_level = i;
+			break;
 		default:
 			error("syntax error");
 			pusht = 0;
@@ -375,6 +391,34 @@
 		return (i);
 	if (force)
 		error("illegal IRQ value");
+	return (-1);
+}
+
+/*
+ *	initsleep token. Must be number > 500 && < 10 * 1000 * 1000.
+ */
+static int
+initsleep_tok(int force)
+{
+	int     i;
+
+	i = num_tok();
+	if (i > 500 && i < 10 * 1000 * 1000)
+		return (i);
+	return (-1);
+}
+
+/*
+ *	debuglevel token. Must be between 0 and 9.
+ */
+static int
+debuglevel_tok(int force)
+{
+	int     i;
+
+	i = num_tok();
+	if (i >= 0 && i <= 9)
+		return (i);
 	return (-1);
 }
 
Index: pccard.conf.5
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/pccard.conf.5,v
retrieving revision 1.8
diff -u -r1.8 pccard.conf.5
--- pccard.conf.5	1999/07/12 20:12:16	1.8
+++ pccard.conf.5	1999/07/15 05:42:28
@@ -116,6 +116,22 @@
 blocks that can be used to allocate to drivers when
 they are initialized.
 .Pp
+The syntax of the initsleep parameter:
+.Pp
+.Dl initsleep Ar time
+.Pp
+Configures the amount of time to sleep at two different points in the
+initialization process.
+The time is in microseconds.
+The default value is 5000000 microseconds, as that works on nearly all
+pccards.
+Newer pc cards may only need as little as 500 microseconds.
+When set too low, the your machine may freeze.
+.Pp
+The syntax of the debuglevel parameter:
+.Pp
+.Dl debuglevel Ar level
+.Pp
 Multiple lines of any of the above statements may be
 present to allow separate blocks of each resource to be
 defined.
Index: pccardd.8
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/pccardd.8,v
retrieving revision 1.14
diff -u -r1.14 pccardd.8
--- pccardd.8	1999/06/30 03:49:30	1.14
+++ pccardd.8	1999/07/15 05:40:07
@@ -122,7 +122,7 @@
 After reading the configuration file, print out a summary
 of it.
 .It Fl z
-Delays running as a daemon slightly.
+Delays running as a daemon until after the cards have been probed and attached.
 .It Fl i Ar IRQ
 Configures an available IRQ.  It overrides the "irq" line in
 .Pa /etc/pccard.conf .
Index: pccardd.c
===================================================================
RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pccard/pccardd/pccardd.c,v
retrieving revision 1.3
diff -u -r1.3 pccardd.c
--- pccardd.c	1999/06/17 21:07:59	1.3
+++ pccardd.c	1999/07/15 05:48:45
@@ -51,6 +51,8 @@
 	int delay = 0;
 	int i;
 
+	pccard_init_sleep = 5000000;
+	debug_level = 0;
 	while ((count = getopt(argc, argv, ":dvf:i:z")) != -1) {
 		switch (count) {
 		case 'd':


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907150549.XAA68558>