1995-08-24 09:03:04 +00:00
|
|
|
/*
|
1996-04-18 04:25:17 +00:00
|
|
|
* Copyright (c) 1995 Andrew McRae. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
1997-02-22 16:15:28 +00:00
|
|
|
* $Id$
|
1996-04-18 04:25:17 +00:00
|
|
|
*
|
1995-08-24 09:03:04 +00:00
|
|
|
* Common include file for PCMCIA daemon
|
|
|
|
*/
|
|
|
|
#include <bitstring.h>
|
|
|
|
|
|
|
|
#include <pccard/card.h>
|
|
|
|
#include <pccard/cis.h>
|
|
|
|
|
|
|
|
#include "readcis.h"
|
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
#ifndef EXTERN
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
1996-04-10 06:49:32 +00:00
|
|
|
struct cmd {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct cmd *next;
|
1996-04-10 06:49:32 +00:00
|
|
|
char *line; /* Command line */
|
|
|
|
int macro; /* Contains macros */
|
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1996-04-10 06:49:32 +00:00
|
|
|
struct card_config {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct card_config *next;
|
|
|
|
unsigned char index;
|
|
|
|
struct driver *driver;
|
1996-04-10 06:49:32 +00:00
|
|
|
int irq;
|
|
|
|
int flags;
|
|
|
|
char inuse;
|
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1996-04-10 06:49:32 +00:00
|
|
|
struct card {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct card *next;
|
1996-04-10 06:49:32 +00:00
|
|
|
char *manuf;
|
|
|
|
char *version;
|
|
|
|
int ether; /* For net cards, ether at offset */
|
|
|
|
int reset_time; /* Reset time */
|
1995-08-24 09:03:04 +00:00
|
|
|
struct card_config *config; /* List of configs */
|
|
|
|
struct cmd *insert; /* Insert commands */
|
|
|
|
struct cmd *remove; /* Remove commands */
|
1996-04-10 06:49:32 +00:00
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1996-04-10 06:49:32 +00:00
|
|
|
struct driver {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct driver *next;
|
1996-04-10 06:49:32 +00:00
|
|
|
char *name;
|
|
|
|
char *kernel; /* Kernel driver base name */
|
|
|
|
int unit; /* Unit of driver */
|
|
|
|
/*
|
|
|
|
* The rest of the structure is allocated dynamically.
|
|
|
|
* Once allocated, it stays allocated.
|
|
|
|
*/
|
1995-08-24 09:03:04 +00:00
|
|
|
struct card *card; /* Current card, if any */
|
|
|
|
struct card_config *config; /* Config back ptr */
|
|
|
|
unsigned int mem; /* Allocated host address (if any) */
|
1996-04-10 06:49:32 +00:00
|
|
|
int inuse;
|
|
|
|
};
|
|
|
|
|
1995-08-24 09:03:04 +00:00
|
|
|
/*
|
|
|
|
* Defines one allocation block i.e a starting address
|
|
|
|
* and size. Used for either memory or I/O ports
|
|
|
|
*/
|
1996-04-10 06:49:32 +00:00
|
|
|
struct allocblk {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct allocblk *next;
|
1996-04-10 06:49:32 +00:00
|
|
|
int addr; /* Address */
|
|
|
|
int size; /* Size */
|
|
|
|
int flags; /* Flags for block */
|
|
|
|
int cardaddr; /* Card address */
|
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
/*
|
|
|
|
* Slot structure - data held for each slot.
|
|
|
|
*/
|
1996-04-10 06:49:32 +00:00
|
|
|
struct slot {
|
1995-08-24 09:03:04 +00:00
|
|
|
struct slot *next;
|
1996-04-10 06:49:32 +00:00
|
|
|
int fd;
|
|
|
|
int mask;
|
|
|
|
int slot;
|
|
|
|
char *name;
|
1995-08-24 09:03:04 +00:00
|
|
|
enum cardstate state;
|
|
|
|
struct cis *cis;
|
|
|
|
struct card *card; /* Current card */
|
|
|
|
struct card_config *config; /* Current configuration */
|
|
|
|
struct cis_config *card_config;
|
1996-04-10 06:49:32 +00:00
|
|
|
char devname[16];
|
1995-08-24 09:03:04 +00:00
|
|
|
unsigned char eaddr[6]; /* If any */
|
|
|
|
struct allocblk io; /* I/O block spec */
|
|
|
|
struct allocblk mem; /* Memory block spec */
|
1996-04-10 06:49:32 +00:00
|
|
|
int irq; /* Irq value */
|
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN struct slot *slots, *current_slot;
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
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 */
|
|
|
|
EXTERN struct driver *drivers; /* List of drivers */
|
|
|
|
EXTERN struct card *cards;
|
|
|
|
EXTERN bitstr_t *mem_avail;
|
|
|
|
EXTERN bitstr_t *io_avail;
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN int verbose;
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
/* util.c functions */
|
|
|
|
unsigned long alloc_memory(int);
|
|
|
|
int bit_fns(bitstr_t *, int, int);
|
1996-04-10 06:49:32 +00:00
|
|
|
void die(char *);
|
1997-01-06 08:35:06 +00:00
|
|
|
void execute(struct cmd *);
|
|
|
|
void log_1s(const char *, ...);
|
|
|
|
void log_setup(void);
|
1996-04-10 06:49:32 +00:00
|
|
|
void logerr(char *);
|
1997-01-06 08:35:06 +00:00
|
|
|
char *newstr();
|
1996-04-10 06:49:32 +00:00
|
|
|
void reset_slot(struct slot *);
|
1997-01-06 08:35:06 +00:00
|
|
|
void *xmalloc(int);
|
|
|
|
|
|
|
|
/* file.c */
|
1996-06-18 19:52:30 +00:00
|
|
|
void readfile(char *);
|
1995-08-24 09:03:04 +00:00
|
|
|
|
|
|
|
#define IOPORTS 0x400
|
|
|
|
#define MEMUNIT 0x1000
|
|
|
|
#define MEMSTART 0xA0000
|
|
|
|
#define MEMEND 0x100000
|
|
|
|
#define MEMBLKS ((MEMEND-MEMSTART)/MEMUNIT)
|
|
|
|
#define MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT)
|
|
|
|
#define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
|