2 * Copyright (c) 1995 Andrew McRae. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. The name of the author may not be used to endorse or promote products
13 * derived from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $FreeBSD: src/usr.sbin/pccard/pccardd/cardd.h,v 1.18.2.6 2001/05/23 21:56:40 dmlb Exp $
28 * Common include file for PCMCIA daemon
30 #include <bitstring.h>
32 #include <pccard/cardinfo.h>
33 #include <pccard/cis.h>
43 char *line; /* Command line */
44 int macro; /* Contains macros */
48 struct card_config *next;
49 unsigned char index_type;
51 struct driver *driver;
63 #define ETHTYPE_GENERIC 0
64 #define ETHTYPE_ATTR2 1
74 struct ether *ether; /* For net cards, ether at offset */
75 int reset_time; /* Reset time */
76 int iosize; /* I/O window size (ignore location) */
77 struct card_config *config; /* List of configs */
78 struct cmd *insert; /* Insert commands */
79 struct cmd *remove; /* Remove commands */
80 char *logstr; /* String for logger */
86 char *kernel; /* Kernel driver base name */
87 int unit; /* Unit of driver */
89 * The rest of the structure is allocated dynamically.
90 * Once allocated, it stays allocated.
92 struct card *card; /* Current card, if any */
93 struct card_config *config; /* Config back ptr */
94 unsigned int mem; /* Allocated host address (if any) */
99 * Defines one allocation block i.e a starting address
100 * and size. Used for either memory or I/O ports
103 struct allocblk *next;
104 int addr; /* Address */
106 int flags; /* Flags for block */
107 int cardaddr; /* Card address */
110 * Slot structure - data held for each slot.
118 enum cardstate state;
120 struct card *card; /* Current card */
121 struct card_config *config; /* Current configuration */
122 struct cis_config *card_config;
124 unsigned char eaddr[6]; /* If any */
125 struct allocblk io; /* I/O block spec */
126 struct allocblk mem; /* Memory block spec */
127 int irq; /* Irq value */
128 int flags; /* Resource assignment flags */
132 * Slot resource assignment/configuration flags
134 #define IO_ASSIGNED 0x1
135 #define MEM_ASSIGNED 0x2
136 #define IRQ_ASSIGNED 0x4
137 #define EADDR_CONFIGED 0x8
138 #define WL_CONFIGED 0x10
139 #define AFLAGS (IO_ASSIGNED | MEM_ASSIGNED | IRQ_ASSIGNED)
140 #define CFLAGS (EADDR_CONFIGED | WL_CONFIGED)
142 EXTERN struct slot *slots, *current_slot;
145 EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */
146 EXTERN struct allocblk *pool_mem; /* Memory in the pool */
147 EXTERN int pool_irq[16]; /* IRQ allocations */
148 EXTERN int irq_init[16]; /* initial IRQ allocations */
149 EXTERN struct driver *drivers; /* List of drivers */
150 EXTERN struct card *cards;
151 EXTERN struct card *last_card;
152 EXTERN bitstr_t *mem_avail;
153 EXTERN bitstr_t *mem_init;
154 EXTERN bitstr_t *io_avail;
155 EXTERN bitstr_t *io_init;
156 EXTERN int pccard_init_sleep; /* Time to sleep on init */
157 EXTERN int use_kern_irq;
158 EXTERN int debug_level;
160 /* cardd.c functions */
161 void dump_config_file(void);
162 struct slot *readslots(void);
163 void slot_change(struct slot *);
165 /* util.c functions */
166 unsigned long alloc_memory(int);
167 int bit_fns(bitstr_t *, int, int, int, int);
169 void execute(struct cmd *, struct slot *);
170 void logmsg(const char *, ...);
171 void log_setup(void);
174 void reset_slot(struct slot *);
177 /* file.c functions */
178 void readfile(char *);
180 /* server.c functions */
181 void set_socket(int);
182 void stat_changed(struct slot *);
183 void process_client(void);
185 #define IOPORTS 0x400
186 #define MEMUNIT 0x1000
187 #define MEMSTART 0xA0000
188 #define MEMEND 0x100000
189 #define MEMBLKS ((MEMEND-MEMSTART)/MEMUNIT)
190 #define MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT)
191 #define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
193 #define MAXINCLUDES 10
199 #define NORMAL_INDEX 0
200 #define DEFAULT_INDEX 1