summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard/pccardd/cardd.h
blob: c68c14a9ad9a657acfdb0d003b2ba3b17fd84a61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

/*
 *	Common include file for PCMCIA daemon
 */
#include <bitstring.h>

#include <pccard/card.h>
#include <pccard/cis.h>

#include "readcis.h"

struct cmd {
	struct cmd *next;
	char   *line;		/* Command line */
	int     macro;		/* Contains macros */
};

struct card_config {
	struct card_config *next;
	unsigned char index;
	struct driver *driver;
	int     irq;
	int     flags;
	char    inuse;
};

struct card {
	struct card *next;
	char   *manuf;
	char   *version;
	int     ether;			/* For net cards, ether at offset */
	int     reset_time;		/* Reset time */
	struct card_config *config;	/* List of configs */
	struct cmd *insert;		/* Insert commands */
	struct cmd *remove;		/* Remove commands */
};

struct driver {
	struct driver *next;
	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.
	 */
	struct card *card;		/* Current card, if any */
	struct card_config *config;	/* Config back ptr */
#if 0
	struct device *device;		/* System device info */
#endif
	unsigned int mem;		/* Allocated host address (if any) */
	int     inuse;
};

#if 0
struct device {
	struct device *next;		/* List of devices */
	int     inuse;			/* Driver being used */
	struct cmd *insert;		/* Insert commands */
	struct cmd *remove;		/* Remove commands */
};
#endif

/*
 *	Defines one allocation block i.e a starting address
 *	and size. Used for either memory or I/O ports
 */
struct allocblk {
	struct allocblk *next;
	int     addr;			/* Address */
	int     size;			/* Size */
	int     flags;			/* Flags for block */
	int     cardaddr;		/* Card address */
};
/*
 *	Slot structure - data held for each slot.
 */
struct slot {
	struct slot *next;
	int     fd;
	int     mask;
	int     slot;
	char   *name;
	enum cardstate state;
	struct cis *cis;
	struct card *card;		/* Current card */
	struct card_config *config;	/* Current configuration */
	struct cis_config *card_config;
	char    devname[16];
	unsigned char eaddr[6];		/* If any */
	struct allocblk io;		/* I/O block spec */
	struct allocblk mem;		/* Memory block spec */
	int     irq;			/* Irq value */
};

struct slot *slots, *current_slot;

struct allocblk *pool_ioblks;		/* I/O blocks in the pool */
struct allocblk *pool_mem;		/* Memory in the pool */
int     pool_irq[16];			/* IRQ allocations */
struct driver *drivers;			/* List of drivers */
struct card *cards;
#if 0
struct device *devlist;
#endif
bitstr_t *mem_avail;
bitstr_t *io_avail;

int     verbose, do_log;

char   *newstr();
void    die(char *);
void   *xmalloc(int);
void    log_1s(char *, char *);
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
#define	MEMSTART 0xA0000
#define	MEMEND	0x100000
#define	MEMBLKS	((MEMEND-MEMSTART)/MEMUNIT)
#define	MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT)
#define	BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
OpenPOWER on IntegriCloud