Reviewed by: mike@smith.net.au
Submitted by: nate@mt.sri.com Removed global variables. (and style(9) fix.)
This commit is contained in:
parent
96ef575882
commit
bc01c37da5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=34367
@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: cardd.c,v 1.28 1998/03/02 19:00:01 guido Exp $";
|
||||
"$Id: cardd.c,v 1.29 1998/03/02 20:51:06 guido Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -38,12 +38,12 @@ static const char rcsid[] =
|
||||
#include "cardd.h"
|
||||
|
||||
static struct card_config *assign_driver(struct card *);
|
||||
static int assign_io(struct slot *);
|
||||
static int setup_slot(struct slot *);
|
||||
static void card_inserted(struct slot *);
|
||||
static void card_removed(struct slot *);
|
||||
static void pr_cmd(struct cmd *);
|
||||
static void read_ether(struct slot *);
|
||||
static int assign_io(struct slot *);
|
||||
static int setup_slot(struct slot *);
|
||||
static void card_inserted(struct slot *);
|
||||
static void card_removed(struct slot *);
|
||||
static void pr_cmd(struct cmd *);
|
||||
static void read_ether(struct slot *);
|
||||
|
||||
/*
|
||||
* Dump configuration file data.
|
||||
@ -84,13 +84,14 @@ pr_cmd(struct cmd *cp)
|
||||
* readslots - read all the PCMCIA slots, and build
|
||||
* a list of the slots.
|
||||
*/
|
||||
void
|
||||
struct slot *
|
||||
readslots(void)
|
||||
{
|
||||
char name[128];
|
||||
int i, fd;
|
||||
struct slot *sp;
|
||||
struct slot *slots, *sp;
|
||||
|
||||
slots = NULL;
|
||||
for (i = 0; i < MAXSLOT; i++) {
|
||||
sprintf(name, CARD_DEVICE, i);
|
||||
fd = open(name, 2);
|
||||
@ -126,6 +127,7 @@ readslots(void)
|
||||
slots = sp;
|
||||
slot_change(sp);
|
||||
}
|
||||
return (slots);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -137,7 +139,6 @@ slot_change(struct slot *sp)
|
||||
{
|
||||
struct slotstate state;
|
||||
|
||||
current_slot = sp;
|
||||
if (ioctl(sp->fd, PIOCGSTATE, &state)) {
|
||||
logerr("ioctl (PIOCGSTATE)");
|
||||
return;
|
||||
@ -192,7 +193,7 @@ card_removed(struct slot *sp)
|
||||
sp->config->driver->inuse = 0;
|
||||
}
|
||||
if ((cp = sp->card) != 0)
|
||||
execute(cp->remove);
|
||||
execute(cp->remove, sp);
|
||||
sp->cis = 0;
|
||||
sp->config = 0;
|
||||
/* release io */
|
||||
@ -240,11 +241,8 @@ card_inserted(struct slot *sp)
|
||||
}
|
||||
if (cp->ether)
|
||||
read_ether(sp);
|
||||
sp->config = assign_driver(cp);
|
||||
if (sp->config == 0) {
|
||||
execute(cp->insert);
|
||||
if ((sp->config = assign_driver(cp)) == NULL)
|
||||
return;
|
||||
}
|
||||
if (assign_io(sp)) {
|
||||
logmsg("Resource allocation failure for %s", sp->cis->manuf);
|
||||
return;
|
||||
@ -256,7 +254,7 @@ card_inserted(struct slot *sp)
|
||||
* windows, and then attach the driver.
|
||||
*/
|
||||
if (setup_slot(sp))
|
||||
execute(cp->insert);
|
||||
execute(cp->insert, sp);
|
||||
#if 0
|
||||
else
|
||||
reset_slot(sp);
|
||||
@ -316,7 +314,7 @@ assign_driver(struct card *cp)
|
||||
break;
|
||||
if (conf == 0) {
|
||||
logmsg("No free configuration for card %s", cp->manuf);
|
||||
return (0);
|
||||
return (NULL);
|
||||
}
|
||||
/*
|
||||
* Now we have a free driver and a matching configuration.
|
||||
@ -328,7 +326,7 @@ assign_driver(struct card *cp)
|
||||
/* If none available, then we can't use this card. */
|
||||
if (drvp->inuse) {
|
||||
logmsg("Driver already being used for %s", cp->manuf);
|
||||
return (0);
|
||||
return (NULL);
|
||||
}
|
||||
/* Allocate a free IRQ if none has been specified */
|
||||
if (conf->irq == 0) {
|
||||
@ -341,7 +339,7 @@ assign_driver(struct card *cp)
|
||||
}
|
||||
if (conf->irq == 0) {
|
||||
logmsg("Failed to allocate IRQ for %s\n", cp->manuf);
|
||||
return (0);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
drvp->card = cp;
|
||||
|
@ -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.10 1997/11/19 02:31:39 nate Exp $
|
||||
* $Id: cardd.h,v 1.11 1998/02/27 08:19:24 hosokawa Exp $
|
||||
*
|
||||
* Common include file for PCMCIA daemon
|
||||
*/
|
||||
@ -111,8 +111,6 @@ struct slot {
|
||||
int irq; /* Irq value */
|
||||
};
|
||||
|
||||
EXTERN struct slot *slots, *current_slot;
|
||||
|
||||
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 */
|
||||
@ -121,27 +119,25 @@ EXTERN struct card *cards;
|
||||
EXTERN bitstr_t *mem_avail;
|
||||
EXTERN bitstr_t *io_avail;
|
||||
|
||||
EXTERN int verbose;
|
||||
|
||||
/* cardd.c functions */
|
||||
void dump_config_file(void);
|
||||
void readslots(void);
|
||||
void slot_change(struct slot *);
|
||||
void dump_config_file(void);
|
||||
struct slot *readslots(void);
|
||||
void slot_change(struct slot *);
|
||||
|
||||
/* util.c functions */
|
||||
unsigned long alloc_memory(int);
|
||||
int bit_fns(bitstr_t *, int, int);
|
||||
void die(char *);
|
||||
void execute(struct cmd *);
|
||||
void logmsg(const char *, ...);
|
||||
void log_setup(void);
|
||||
void logerr(char *);
|
||||
char *newstr();
|
||||
void reset_slot(struct slot *);
|
||||
void *xmalloc(int);
|
||||
unsigned long alloc_memory(int);
|
||||
int bit_fns(bitstr_t *, int, int);
|
||||
void die(char *);
|
||||
void execute(struct cmd *, struct slot *);
|
||||
void logmsg(const char *, ...);
|
||||
void log_setup(void);
|
||||
void logerr(char *);
|
||||
char *newstr();
|
||||
void reset_slot(struct slot *);
|
||||
void *xmalloc(int);
|
||||
|
||||
/* file.c */
|
||||
void readfile(char *);
|
||||
void readfile(char *);
|
||||
|
||||
#define IOPORTS 0x400
|
||||
#define MEMUNIT 0x1000
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: file.c,v 1.12 1997/10/06 11:36:06 charnier Exp $";
|
||||
"$Id: file.c,v 1.13 1997/11/19 02:31:40 nate Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -272,8 +272,7 @@ new_driver(char *name)
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (verbose)
|
||||
printf("Drv %s%d created\n", drvp->kernel, drvp->unit);
|
||||
printf("Drv %s%d created\n", drvp->kernel, drvp->unit);
|
||||
#endif
|
||||
return (drvp);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: cardd.c,v 1.24 1998/02/04 20:19:39 guido Exp $";
|
||||
"$Id: pccardd.c,v 1.1 1998/02/27 08:19:25 hosokawa Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
@ -45,19 +45,19 @@ char *config_file = "/etc/pccard.conf";
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct slot *sp;
|
||||
int count, debug = 0;
|
||||
int verbose = 0;
|
||||
struct slot *slots, *sp;
|
||||
int count, dodebug = 0;
|
||||
int doverbose = 0;
|
||||
|
||||
while ((count = getopt(argc, argv, ":dvf:")) != -1) {
|
||||
switch (count) {
|
||||
case 'd':
|
||||
setbuf(stdout, 0);
|
||||
setbuf(stderr, 0);
|
||||
debug = 1;
|
||||
dodebug = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
doverbose = 1;
|
||||
break;
|
||||
case 'f':
|
||||
config_file = optarg;
|
||||
@ -71,20 +71,20 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
debug = 1;
|
||||
dodebug = 1;
|
||||
#endif
|
||||
io_avail = bit_alloc(IOPORTS); /* Only supports ISA ports */
|
||||
|
||||
/* Mem allocation done in MEMUNIT units. */
|
||||
mem_avail = bit_alloc(MEMBLKS);
|
||||
readfile(config_file);
|
||||
if (verbose)
|
||||
if (doverbose)
|
||||
dump_config_file();
|
||||
log_setup();
|
||||
if (!debug)
|
||||
if (!dodebug)
|
||||
if (daemon(0, 0))
|
||||
die("fork failed");
|
||||
readslots();
|
||||
slots = readslots();
|
||||
if (slots == 0)
|
||||
die("no PC-CARD slots");
|
||||
logmsg("pccardd started", NULL);
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: util.c,v 1.10 1997/10/06 11:36:08 charnier Exp $";
|
||||
"$Id: util.c,v 1.11 1997/11/19 02:31:41 nate Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <err.h>
|
||||
@ -222,7 +222,7 @@ reset_slot(struct slot *sp)
|
||||
* substitutions.
|
||||
*/
|
||||
void
|
||||
execute(struct cmd *cmdp)
|
||||
execute(struct cmd *cmdp, struct slot *sp)
|
||||
{
|
||||
char cmd[1024];
|
||||
char *p, *cp, *lp;
|
||||
@ -239,12 +239,12 @@ execute(struct cmd *cmdp)
|
||||
/* stringify ethernet address and place here. */
|
||||
if (strncmp(p, "$ether", 6) == 0) {
|
||||
sprintf(cp, "%x:%x:%x:%x:%x:%x",
|
||||
current_slot->eaddr[0],
|
||||
current_slot->eaddr[1],
|
||||
current_slot->eaddr[2],
|
||||
current_slot->eaddr[3],
|
||||
current_slot->eaddr[4],
|
||||
current_slot->eaddr[5]);
|
||||
sp->eaddr[0],
|
||||
sp->eaddr[1],
|
||||
sp->eaddr[2],
|
||||
sp->eaddr[3],
|
||||
sp->eaddr[4],
|
||||
sp->eaddr[5]);
|
||||
while (*++cp)
|
||||
continue;
|
||||
lp += 6;
|
||||
@ -252,8 +252,8 @@ execute(struct cmd *cmdp)
|
||||
/* replace device name */
|
||||
if (strncmp(p, "$device", 7) == 0) {
|
||||
sprintf(cp, "%s%d",
|
||||
current_slot->config->driver->kernel,
|
||||
current_slot->config->driver->unit);
|
||||
sp->config->driver->kernel,
|
||||
sp->config->driver->unit);
|
||||
while (*cp)
|
||||
cp++;
|
||||
lp += 7;
|
||||
|
Loading…
Reference in New Issue
Block a user