o Add "debuglevel" keyword to config file.
o Document debug level keyword o Implement debug level: o For most of the diagnostic messages, change them from #ifdef DEBUG to if (debuglevel > 0). o Add a couple more diagnostic messages that weren't present before o Fix a couple of excessively long lines. Reviewed by: hosokawa-san o Start to implement the stopgap kludge for -current's pccard code by passing the length of the i/o range. If DEV_DESC_HAS_SIZE is defined, we'll set the size. This is done as an ifdef so that I can generate patches against the kernel more easily. o Add preliminary support for tweaking sleep times, but leave it disabled until a good range of values can be established. Didn't fix: logmsg problem noted by Nate.
This commit is contained in:
parent
d848a791d1
commit
564b182ca1
@ -26,13 +26,14 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: cardd.c,v 1.38 1999/07/23 08:53:20 hosokawa Exp $";
|
||||
"$Id: cardd.c,v 1.39 1999/07/23 14:58:33 hosokawa Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#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 @@ readslots(void)
|
||||
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)");
|
||||
}
|
||||
@ -201,7 +203,7 @@ card_inserted(struct slot *sp)
|
||||
{
|
||||
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);
|
||||
@ -284,10 +286,10 @@ assign_driver(struct card *cp)
|
||||
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);
|
||||
@ -351,8 +353,11 @@ assign_io(struct slot *sp)
|
||||
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;
|
||||
|
||||
/*
|
||||
@ -381,10 +386,10 @@ assign_io(struct slot *sp)
|
||||
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. */
|
||||
@ -455,10 +460,10 @@ assign_io(struct slot *sp)
|
||||
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;
|
||||
sp->flags |= IRQ_ASSIGNED;
|
||||
@ -497,11 +502,12 @@ setup_slot(struct slot *sp)
|
||||
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. */
|
||||
@ -540,10 +546,11 @@ setup_slot(struct slot *sp)
|
||||
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)");
|
||||
@ -565,10 +572,15 @@ setup_slot(struct slot *sp)
|
||||
drv.iobase = sp->io.addr;
|
||||
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);
|
||||
#ifdef DEV_DESC_HAS_SIZE
|
||||
drv.iosize = sp->io.size;
|
||||
#endif
|
||||
if (debug_level > 0) {
|
||||
logmsg("Assign %s%d, io 0x%x-0x%x, mem 0x%lx, %d bytes, "
|
||||
"irq %d, flags %x\n", drv.name, drv.unit, drv.iobase,
|
||||
drv.iobase + sp->io.size - 1, drv.mem, drv.memsize,
|
||||
sp->irq, drv.flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the driver fails to be connected to the device,
|
||||
@ -576,7 +588,8 @@ setup_slot(struct slot *sp)
|
||||
*/
|
||||
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);
|
||||
|
@ -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.12 1998/03/09 05:18:55 hosokawa Exp $
|
||||
* $Id: cardd.h,v 1.13 1999/07/23 01:33:34 hosokawa Exp $
|
||||
*
|
||||
* Common include file for PCMCIA daemon
|
||||
*/
|
||||
@ -131,6 +131,8 @@ EXTERN struct driver *drivers; /* List of drivers */
|
||||
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);
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: file.c,v 1.18 1999/07/15 03:04:31 imp Exp $";
|
||||
"$Id: file.c,v 1.19 1999/07/23 01:33:34 hosokawa Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -53,6 +53,7 @@ static char *keys[] = {
|
||||
"insert", /* 10 */
|
||||
"remove", /* 11 */
|
||||
"iosize", /* 12 */
|
||||
"debuglevel", /* 13 */
|
||||
0
|
||||
};
|
||||
|
||||
@ -68,6 +69,7 @@ static char *keys[] = {
|
||||
#define KWD_INSERT 10
|
||||
#define KWD_REMOVE 11
|
||||
#define KWD_IOSIZE 12
|
||||
#define KWD_DEBUGLEVEL 13
|
||||
|
||||
struct flags {
|
||||
char *name;
|
||||
@ -81,6 +83,7 @@ static int num_tok(void);
|
||||
static void error(char *);
|
||||
static int keyword(char *);
|
||||
static int irq_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 *);
|
||||
@ -169,6 +172,11 @@ parsefile(void)
|
||||
/* Card definition. */
|
||||
parse_card();
|
||||
break;
|
||||
case KWD_DEBUGLEVEL:
|
||||
i = debuglevel_tok(0);
|
||||
if (i > 0)
|
||||
debug_level = i;
|
||||
break;
|
||||
default:
|
||||
error("syntax error");
|
||||
pusht = 0;
|
||||
@ -396,6 +404,20 @@ irq_tok(int force)
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* iosize token
|
||||
* iosize {<size>|auto}
|
||||
|
@ -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$
|
||||
.\" $Id: pccard.conf.5,v 1.8 1999/07/12 20:12:16 nik Exp $
|
||||
.\"
|
||||
.Dd November 2, 1994
|
||||
.Dt PCCARD.CONF 5
|
||||
@ -116,6 +116,10 @@ Each of the statements define I/O, memory or IRQ
|
||||
blocks that can be used to allocate to drivers when
|
||||
they are initialized.
|
||||
.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.
|
||||
|
@ -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: pccardd.8,v 1.13 1999/06/29 23:59:15 hosokawa Exp $
|
||||
.\" $Id: pccardd.8,v 1.14 1999/06/30 03:49:30 hosokawa Exp $
|
||||
.\"
|
||||
.Dd November 1, 1994
|
||||
.Dt PCCARDD 8
|
||||
@ -122,7 +122,7 @@ display error messages.
|
||||
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 .
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: pccardd.c,v 1.3 1999/06/17 21:07:59 markm Exp $";
|
||||
"$Id: pccardd.c,v 1.4 1999/07/23 01:46:47 hosokawa Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -51,6 +51,8 @@ main(int argc, char *argv[])
|
||||
int delay = 0;
|
||||
int i;
|
||||
|
||||
debug_level = 0;
|
||||
pccard_init_sleep = 5000000;
|
||||
while ((count = getopt(argc, argv, ":dvf:i:z")) != -1) {
|
||||
switch (count) {
|
||||
case 'd':
|
||||
|
Loading…
Reference in New Issue
Block a user