Date: Wed, 14 Jul 1999 21:39:19 -0600 From: Warner Losh <imp@village.org> To: mobile@freebsd.org Subject: Oooppsss Message-ID: <199907150339.VAA60917@harmony.village.org>
next in thread | raw e-mail | index | archive | help
to comment on my patches, alluded to in the last message, you'll need to see the patches. 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 02:47:12 @@ -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 (dodebug) { + 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 (dodebug) { + 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 (dodebug) { + 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 (dodebug) { + 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 (dodebug) { + 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 (dodebug) { + 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 02:38:59 @@ -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 dodebug; /* cardd.c functions */ void dump_config_file(void); 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 02:54:58 @@ -38,6 +38,7 @@ .Op Fl z .Op Fl i Ar IRQ .Op Fl f Ar configfile +.Op Fl s Ar initsleeptime .Sh DESCRIPTION .Nm Pccardd is normally started at boot time, and manages the insertion @@ -121,8 +122,16 @@ .It Fl v After reading the configuration file, print out a summary of it. +.It Fl s Ar initsleep +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. .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 02:39:28 @@ -46,12 +46,14 @@ main(int argc, char *argv[]) { struct slot *slots, *sp; - int count, dodebug = 0; + int count; int doverbose = 0; int delay = 0; int i; - while ((count = getopt(argc, argv, ":dvf:i:z")) != -1) { + pccard_init_sleep = 5000000; + dodebug = 0; + while ((count = getopt(argc, argv, ":dvf:i:s:z")) != -1) { switch (count) { case 'd': setbuf(stdout, 0); @@ -71,6 +73,9 @@ exit(1); } pool_irq[i] = 1; + break; + case 's': + pccard_init_sleep = atoi(optarg); break; case 'z': delay = 1; 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?199907150339.VAA60917>