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.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
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>
|
|
|
|
|
1997-11-18 21:08:14 +00:00
|
|
|
#include <pccard/cardinfo.h>
|
1995-08-24 09:03:04 +00:00
|
|
|
#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;
|
2000-01-26 17:54:00 +00:00
|
|
|
unsigned char index_type;
|
1995-08-24 09:03:04 +00:00
|
|
|
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
|
|
|
|
2000-01-21 09:12:00 +00:00
|
|
|
struct ether {
|
|
|
|
struct ether *next;
|
|
|
|
int type;
|
|
|
|
int value;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ETHTYPE_GENERIC 0
|
|
|
|
#define ETHTYPE_ATTR2 1
|
|
|
|
|
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;
|
2000-05-30 15:33:56 +00:00
|
|
|
char *add_info1;
|
|
|
|
char *add_info2;
|
2000-04-05 18:39:21 +00:00
|
|
|
u_char func_id;
|
|
|
|
int deftype;
|
2000-01-21 09:12:00 +00:00
|
|
|
struct ether *ether; /* For net cards, ether at offset */
|
1996-04-10 06:49:32 +00:00
|
|
|
int reset_time; /* Reset time */
|
1999-07-23 01:33:34 +00:00
|
|
|
int iosize; /* I/O window size (ignore location) */
|
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 */
|
2000-07-14 19:46:35 +00:00
|
|
|
char *logstr; /* String for logger */
|
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];
|
2002-02-20 14:48:23 +00:00
|
|
|
u_int manufacturer;
|
|
|
|
u_int product;
|
|
|
|
u_int prodext;
|
1995-08-24 09:03:04 +00:00
|
|
|
unsigned char eaddr[6]; /* If any */
|
2002-07-22 06:58:24 +00:00
|
|
|
char manufstr[DEV_MAX_CIS_LEN];
|
|
|
|
char versstr[DEV_MAX_CIS_LEN];
|
2003-04-23 23:40:28 +00:00
|
|
|
char cis3str[DEV_MAX_CIS_LEN];
|
|
|
|
char cis4str[DEV_MAX_CIS_LEN];
|
1995-08-24 09:03:04 +00:00
|
|
|
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 */
|
1999-07-23 01:33:34 +00:00
|
|
|
int flags; /* Resource assignment flags */
|
1996-04-10 06:49:32 +00:00
|
|
|
};
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1999-07-23 01:33:34 +00:00
|
|
|
/*
|
|
|
|
* Slot resource assignment/configuration flags
|
|
|
|
*/
|
|
|
|
#define IO_ASSIGNED 0x1
|
|
|
|
#define MEM_ASSIGNED 0x2
|
|
|
|
#define IRQ_ASSIGNED 0x4
|
|
|
|
#define EADDR_CONFIGED 0x8
|
|
|
|
#define WL_CONFIGED 0x10
|
|
|
|
#define AFLAGS (IO_ASSIGNED | MEM_ASSIGNED | IRQ_ASSIGNED)
|
|
|
|
#define CFLAGS (EADDR_CONFIGED | WL_CONFIGED)
|
|
|
|
|
2000-08-20 16:16:57 +00:00
|
|
|
EXTERN struct slot *slots, *current_slot;
|
|
|
|
EXTERN int slen;
|
|
|
|
|
1999-07-23 01:33:34 +00:00
|
|
|
EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */
|
|
|
|
EXTERN struct allocblk *pool_mem; /* Memory in the pool */
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN int pool_irq[16]; /* IRQ allocations */
|
2000-04-08 05:19:44 +00:00
|
|
|
EXTERN int irq_init[16]; /* initial IRQ allocations */
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN struct driver *drivers; /* List of drivers */
|
|
|
|
EXTERN struct card *cards;
|
2000-03-30 16:01:37 +00:00
|
|
|
EXTERN struct card *last_card;
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN bitstr_t *mem_avail;
|
2000-04-08 05:19:44 +00:00
|
|
|
EXTERN bitstr_t *mem_init;
|
1997-01-06 08:35:06 +00:00
|
|
|
EXTERN bitstr_t *io_avail;
|
2000-04-08 05:19:44 +00:00
|
|
|
EXTERN bitstr_t *io_init;
|
1999-08-01 18:04:26 +00:00
|
|
|
EXTERN int pccard_init_sleep; /* Time to sleep on init */
|
2000-10-20 13:08:18 +00:00
|
|
|
EXTERN int use_kern_irq;
|
1999-08-01 18:04:26 +00:00
|
|
|
EXTERN int debug_level;
|
1995-08-24 09:03:04 +00:00
|
|
|
|
1998-02-27 08:19:25 +00:00
|
|
|
/* cardd.c functions */
|
1998-03-09 05:18:59 +00:00
|
|
|
void dump_config_file(void);
|
|
|
|
struct slot *readslots(void);
|
|
|
|
void slot_change(struct slot *);
|
1998-02-27 08:19:25 +00:00
|
|
|
|
1997-01-06 08:35:06 +00:00
|
|
|
/* util.c functions */
|
1998-03-09 05:18:59 +00:00
|
|
|
unsigned long alloc_memory(int);
|
2000-09-21 13:13:00 +00:00
|
|
|
int bit_fns(bitstr_t *, int, int, int, int);
|
1998-03-09 05:18:59 +00:00
|
|
|
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);
|
1997-01-06 08:35:06 +00:00
|
|
|
|
2000-08-20 16:16:57 +00:00
|
|
|
/* file.c functions */
|
1998-03-09 05:18:59 +00:00
|
|
|
void readfile(char *);
|
1995-08-24 09:03:04 +00:00
|
|
|
|
2000-08-20 16:16:57 +00:00
|
|
|
/* server.c functions */
|
|
|
|
void set_socket(int);
|
|
|
|
void stat_changed(struct slot *);
|
|
|
|
void process_client(void);
|
|
|
|
|
2003-08-03 06:17:06 +00:00
|
|
|
#define IOPORTS 0x1000 /* allow most of the low ports */
|
1995-08-24 09:03:04 +00:00
|
|
|
#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)
|
1999-08-17 03:38:51 +00:00
|
|
|
|
|
|
|
#define MAXINCLUDES 10
|
2000-03-30 16:01:37 +00:00
|
|
|
#define MAXERRORS 10
|
2000-01-26 17:54:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Config index types
|
|
|
|
*/
|
|
|
|
#define NORMAL_INDEX 0
|
|
|
|
#define DEFAULT_INDEX 1
|
|
|
|
#define AUTO_INDEX 2
|
|
|
|
|
2000-04-05 18:39:21 +00:00
|
|
|
#define DT_VERS 0
|
|
|
|
#define DT_FUNC 1
|