summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard/pccardd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pccard/pccardd')
-rw-r--r--usr.sbin/pccard/pccardd/cardd.c23
-rw-r--r--usr.sbin/pccard/pccardd/cardd.h2
-rw-r--r--usr.sbin/pccard/pccardd/file.c16
-rw-r--r--usr.sbin/pccard/pccardd/readcis.c114
-rw-r--r--usr.sbin/pccard/pccardd/util.c7
5 files changed, 84 insertions, 78 deletions
diff --git a/usr.sbin/pccard/pccardd/cardd.c b/usr.sbin/pccard/pccardd/cardd.c
index ce97520..ecebdaa 100644
--- a/usr.sbin/pccard/pccardd/cardd.c
+++ b/usr.sbin/pccard/pccardd/cardd.c
@@ -6,8 +6,10 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <syslog.h>
#include <varargs.h>
#include "cardd.h"
@@ -24,14 +26,16 @@ void readslots();
void slot_change(struct slot *);
void card_removed(struct slot *);
void card_inserted(struct slot *);
+int assign_io(struct slot *sp);
/*
* mainline code for cardd
*/
+int
main(int argc, char *argv[])
{
struct slot *sp;
-int mask, count, debug = 0, err = 0;
+int count, debug = 0;
int verbose = 0;
extern char *optarg;
extern int optind, optopt;
@@ -82,11 +86,13 @@ extern int optind, optopt;
die("No PC-CARD slots");
for (;;)
{
- mask = 0;
+ fd_set mask;
+ FD_ZERO(&mask);
for (sp = slots; sp; sp = sp->next)
- mask |= sp->mask;
+ FD_SET(sp->fd,&mask);
printf("Doing select\n");
count = select(32, 0, 0, &mask, 0);
+printf("select=%d\n",count);
if (count == -1)
{
perror("Select");
@@ -94,7 +100,7 @@ printf("Doing select\n");
}
if (count)
for (sp = slots; sp; sp = sp->next)
- if (mask & sp->mask)
+ if (FD_ISSET(sp->fd,&mask))
slot_change(sp);
}
}
@@ -104,8 +110,6 @@ printf("Doing select\n");
void
dump_config_file()
{
-struct driver *drvp;
-struct device *devp;
struct card *cp;
struct card_config *confp;
@@ -172,7 +176,6 @@ struct slot *sp;
printf("opened %s\n",name);
sp = xmalloc(sizeof(*sp));
sp->fd = fd;
- sp->mask = 1 << fd;
sp->name = newstr(name);
sp->slot = i;
sp->state = empty;
@@ -253,7 +256,6 @@ HERE();
void
card_removed(struct slot *sp)
{
-struct driver *drvp;
struct card *cp;
HERE();
@@ -265,7 +267,7 @@ HERE();
sp->config->driver->inuse = 0;
}
HERE();
- if (cp = sp->card)
+ if ((cp = sp->card) != 0)
execute(cp->remove);
HERE();
sp->cis = 0;
@@ -339,7 +341,7 @@ struct card *cp;
void
read_ether(struct slot *sp)
{
-unsigned char net_addr[12], *p;
+unsigned char net_addr[12];
lseek(sp->fd, (off_t)sp->card->ether, SEEK_SET);
if (read(sp->fd, net_addr, sizeof(net_addr)) != sizeof(net_addr))
@@ -582,7 +584,6 @@ setup_slot(struct slot *sp)
struct mem_desc mem;
struct io_desc io;
struct drv_desc drv;
-struct allocblk *ap;
struct driver *drvp = sp->config->driver;
char c;
off_t offs;
diff --git a/usr.sbin/pccard/pccardd/cardd.h b/usr.sbin/pccard/pccardd/cardd.h
index 88561f5..4700d15 100644
--- a/usr.sbin/pccard/pccardd/cardd.h
+++ b/usr.sbin/pccard/pccardd/cardd.h
@@ -119,6 +119,8 @@ void logerr(char *);
void reset_slot(struct slot *);
void execute(struct cmd *);
unsigned long alloc_memory(int size);
+int bit_fns(bitstr_t *nm, int nbits, int count);
+void readfile(char *name);
#define IOPORTS 0x400
#define MEMUNIT 0x1000
diff --git a/usr.sbin/pccard/pccardd/file.c b/usr.sbin/pccard/pccardd/file.c
index 769fafc..5841b12 100644
--- a/usr.sbin/pccard/pccardd/file.c
+++ b/usr.sbin/pccard/pccardd/file.c
@@ -49,14 +49,17 @@ int irq_tok(int);
void setflags(struct flags *, int *);
struct driver *new_driver(char *);
+void addcmd(struct cmd **cp);
+void parse_card();
+
/*
* Read a file and parse the pcmcia configuration data.
* After parsing, verify the links.
*/
+void
readfile(char *name)
{
struct card *cp;
-struct driver *drvp;
in = fopen(name, "r");
if (in == 0)
@@ -76,7 +79,6 @@ void
parsefile()
{
int i;
-char *s;
struct allocblk *bp;
pushc = 0;
@@ -94,7 +96,7 @@ struct allocblk *bp;
* reserved I/O blocks
*/
case 1:
- while (bp = ioblk_tok(0))
+ while ((bp = ioblk_tok(0)) != 0)
{
if (bp->size == 0 || bp->addr == 0)
{
@@ -119,7 +121,7 @@ struct allocblk *bp;
* reserved memory blocks.
*/
case 3:
- while (bp = memblk_tok(0))
+ while ((bp = memblk_tok(0)) != 0)
{
if (bp->size == 0 || bp->addr == 0)
{
@@ -152,6 +154,7 @@ struct allocblk *bp;
/*
* Parse a card definition.
*/
+void
parse_card()
{
char *man, *vers;
@@ -626,6 +629,7 @@ int set = 1;
* addcmd - Append the command line to the list of
* commands.
*/
+void
addcmd(struct cmd **cp)
{
char *s = getline();
@@ -698,7 +702,7 @@ int
num_tok()
{
char *s = next_tok(), c;
-int val=0, base, term=0;
+int val=0, base;
base = 10;
c = *s++;
@@ -752,7 +756,7 @@ int val=0, base, term=0;
return(-1);
break;
}
- } while (c = *s++);
+ } while ((c = *s++) != 0);
return(val);
}
char *_next_tok();
diff --git a/usr.sbin/pccard/pccardd/readcis.c b/usr.sbin/pccard/pccardd/readcis.c
index 880a4aa..b25f0ee 100644
--- a/usr.sbin/pccard/pccardd/readcis.c
+++ b/usr.sbin/pccard/pccardd/readcis.c
@@ -15,41 +15,45 @@
static int read_attr(int fd, char *bp, int len);
struct tuple_list *read_one_tuplelist(int, int, off_t);
int ck_linktarget(int, off_t, int);
+void cis_info(struct cis *cp, unsigned char *p, int len);
+void device_desc(unsigned char *p, int len, struct dev_mem *dp);
+void config_map(struct cis *cp, unsigned char *p, int len);
+void cis_config(struct cis *cp, unsigned char *p, int len);
struct tuple_info tuple_info[] =
{
- "Null tuple", 0x00, 0,
- "Common memory descriptor", 0x01, 255,
- "Checksum", 0x10, 5,
- "Long link to attribute memory", 0x11, 4,
- "Long link to common memory", 0x12, 4,
- "Link target", 0x13, 3,
- "No link", 0x14, 0,
- "Version 1 info", 0x15, 255,
- "Alternate language string", 0x16, 255,
- "Attribute memory descriptor", 0x17, 255,
- "JEDEC descr for common memory", 0x18, 255,
- "JEDEC descr for attribute memory", 0x19, 255,
- "Configuration map", 0x1A, 255,
- "Configuration entry", 0x1B, 255,
- "Other conditions for common memory", 0x1C, 255,
- "Other conditions for attribute memory", 0x1D, 255,
- "Geometry info for common memory", 0x1E, 255,
- "Geometry info for attribute memory", 0x1F, 255,
- "Manufacturer ID", 0x20, 4,
- "Functional ID", 0x21, 255,
- "Functional EXT", 0x22, 255,
- "Software interleave", 0x23, 2,
- "Version 2 Info", 0x40, 255,
- "Data format", 0x41, 255,
- "Geometry", 0x42, 4,
- "Byte order", 0x43, 2,
- "Card init date", 0x44, 4,
- "Battery replacement", 0x45, 4,
- "Organisation", 0x46, 255,
- "Terminator", 0xFF, 255,
- 0, 0, 0
- };
+ { "Null tuple", 0x00, 0 },
+ { "Common memory descriptor", 0x01, 255 },
+ { "Checksum", 0x10, 5 },
+ { "Long link to attribute memory", 0x11, 4 },
+ { "Long link to common memory", 0x12, 4 },
+ { "Link target", 0x13, 3 },
+ { "No link", 0x14, 0 },
+ { "Version 1 info", 0x15, 255 },
+ { "Alternate language string", 0x16, 255 },
+ { "Attribute memory descriptor", 0x17, 255 },
+ { "JEDEC descr for common memory", 0x18, 255 },
+ { "JEDEC descr for attribute memory", 0x19, 255 },
+ { "Configuration map", 0x1A, 255 },
+ { "Configuration entry", 0x1B, 255 },
+ { "Other conditions for common memory", 0x1C, 255 },
+ { "Other conditions for attribute memory", 0x1D, 255 },
+ { "Geometry info for common memory", 0x1E, 255 },
+ { "Geometry info for attribute memory", 0x1F, 255 },
+ { "Manufacturer ID", 0x20, 4 },
+ { "Functional ID", 0x21, 255 },
+ { "Functional EXT", 0x22, 255 },
+ { "Software interleave", 0x23, 2 },
+ { "Version 2 Info", 0x40, 255 },
+ { "Data format", 0x41, 255 },
+ { "Geometry", 0x42, 4 },
+ { "Byte order", 0x43, 2 },
+ { "Card init date", 0x44, 4 },
+ { "Battery replacement", 0x45, 4 },
+ { "Organisation", 0x46, 255 },
+ { "Terminator", 0xFF, 255 },
+ { 0, 0, 0 }
+ };
/*
* After reading the tuples, decode the relevant ones.
@@ -106,10 +110,10 @@ struct cis_config *conf;
struct tuple *tp;
struct tuple_list *tl;
- while (tl = cp->tlist)
+ while ((tl = cp->tlist) != 0)
{
cp->tlist = tl->next;
- while (tp = tl->tuples)
+ while ((tp = tl->tuples) != 0)
{
tl->tuples = tp->next;
if (tp->data)
@@ -117,15 +121,15 @@ struct tuple_list *tl;
}
}
- while (conf = cp->conf)
+ while ((conf = cp->conf) != 0)
{
cp->conf = conf->next;
- while (io = conf->io)
+ while ((io = conf->io) != 0)
{
conf->io = io->next;
free(io);
}
- while (mem = conf->mem)
+ while ((mem = conf->mem) != 0)
{
conf->mem = mem->next;
free(mem);
@@ -137,6 +141,7 @@ struct tuple_list *tl;
/*
* Fills in CIS version data.
*/
+void
cis_info(struct cis *cp, unsigned char *p, int len)
{
cp->maj_v = *p++;
@@ -155,10 +160,8 @@ cis_info(struct cis *cp, unsigned char *p, int len)
/*
* device_desc - decode device descriptor.
*/
-device_desc(p, len, dp)
-unsigned char *p;
-int len;
-struct dev_mem *dp;
+void
+device_desc(unsigned char *p, int len, struct dev_mem *dp)
{
while (len > 0 && *p != 0xFF)
{
@@ -179,10 +182,8 @@ struct dev_mem *dp;
/*
* configuration map of card control register.
*/
-config_map(cp, p, len)
-struct cis *cp;
-unsigned char *p;
-int len;
+void
+config_map(struct cis *cp, unsigned char *p, int len)
{
unsigned char *p1;
int i;
@@ -202,12 +203,10 @@ union {
/*
* CIS config entry - Decode and build configuration entry.
*/
-cis_config(cp, p, len)
-struct cis *cp;
-unsigned char *p;
-int len;
+void
+cis_config(struct cis *cp, unsigned char *p, int len)
{
-int blks, x;
+int x;
int i, j;
union {
unsigned long l;
@@ -216,9 +215,10 @@ union {
struct cis_config *conf, *last;
struct cis_memblk *mem;
unsigned char feat;
+struct cis_memblk *lastmem = 0;
conf = xmalloc(sizeof(*conf));
- if (last = cp->conf)
+ if ((last = cp->conf) !=0)
{
while (last->next)
last = last->next;
@@ -351,14 +351,12 @@ unsigned char feat;
conf->memwins = CIS_MEM_WINS(x);
for (i = 0; i < conf->memwins; i++)
{
- struct cis_memblk *last;
-
mem = xmalloc(sizeof(*mem));
if (i == 0)
conf->mem = mem;
else
- last->next = mem;
- last = mem;
+ lastmem->next = mem;
+ lastmem = mem;
u.l = 0;
for (j = 0 ; j < CIS_MEM_LENSZ(x); j++)
u.b[j] = *p++;
@@ -465,10 +463,10 @@ off_t offs;
struct tuple_list *
read_one_tuplelist(int fd, int flags, off_t offs)
{
-struct tuple *tp, *last_tp, *first = 0;
+struct tuple *tp, *last_tp = 0;
struct tuple_list *tl;
struct tuple_info *tinfo;
-int i, total = 0;
+int total = 0;
unsigned char code, length;
/*
@@ -567,7 +565,7 @@ struct tuple_list *tl;
struct tuple *tp;
for (tl = sp->tlist; tl; tl = tl->next)
- if (tp = find_tuple_in_list(tl, code))
+ if ((tp = find_tuple_in_list(tl, code)) != 0)
return(tp);
return(0);
}
diff --git a/usr.sbin/pccard/pccardd/util.c b/usr.sbin/pccard/pccardd/util.c
index 6abacaa..68379e9 100644
--- a/usr.sbin/pccard/pccardd/util.c
+++ b/usr.sbin/pccard/pccardd/util.c
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <syslog.h>
@@ -107,7 +109,6 @@ int i;
void
reset_slot(struct slot *sp)
{
-struct card *cp = sp->card;
char c;
off_t offs;
struct mem_desc mem;
@@ -155,7 +156,7 @@ char *p, *cp, *lp;
lp = cmdp->line;
if (*lp == 0)
continue;
- while (p = strchr(lp, '$'))
+ while ((p = strchr(lp, '$')) != 0)
{
/*
* copy over preceding string.
@@ -199,7 +200,7 @@ char *p, *cp, *lp;
/*
* No more replacements. Copy rest of string.
*/
- while (*cp++ = *lp++)
+ while ((*cp++ = *lp++) != 0)
;
#ifdef DEBUG
fprintf(stderr, "Executing [%s]\n", cmd);
OpenPOWER on IntegriCloud