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 $
27 * $DragonFly: src/usr.sbin/pccard/pccardd/Attic/cardd.h,v 1.2 2003/06/17 04:29:59 dillon Exp $
29 * Common include file for PCMCIA daemon
31 #include <bitstring.h>
33 #include <pccard/cardinfo.h>
34 #include <pccard/cis.h>
44 char *line; /* Command line */
45 int macro; /* Contains macros */
49 struct card_config *next;
50 unsigned char index_type;
52 struct driver *driver;
64 #define ETHTYPE_GENERIC 0
65 #define ETHTYPE_ATTR2 1
75 struct ether *ether; /* For net cards, ether at offset */
76 int reset_time; /* Reset time */
77 int iosize; /* I/O window size (ignore location) */
78 struct card_config *config; /* List of configs */
79 struct cmd *insert; /* Insert commands */
80 struct cmd *remove; /* Remove commands */
81 char *logstr; /* String for logger */
87 char *kernel; /* Kernel driver base name */
88 int unit; /* Unit of driver */
90 * The rest of the structure is allocated dynamically.
91 * Once allocated, it stays allocated.
93 struct card *card; /* Current card, if any */
94 struct card_config *config; /* Config back ptr */
95 unsigned int mem; /* Allocated host address (if any) */
100 * Defines one allocation block i.e a starting address
101 * and size. Used for either memory or I/O ports
104 struct allocblk *next;
105 int addr; /* Address */
107 int flags; /* Flags for block */
108 int cardaddr; /* Card address */
111 * Slot structure - data held for each slot.
119 enum cardstate state;
121 struct card *card; /* Current card */
122 struct card_config *config; /* Current configuration */
123 struct cis_config *card_config;
125 unsigned char eaddr[6]; /* If any */
126 struct allocblk io; /* I/O block spec */
127 struct allocblk mem; /* Memory block spec */
128 int irq; /* Irq value */
129 int flags; /* Resource assignment flags */
133 * Slot resource assignment/configuration flags
135 #define IO_ASSIGNED 0x1
136 #define MEM_ASSIGNED 0x2
137 #define IRQ_ASSIGNED 0x4
138 #define EADDR_CONFIGED 0x8
139 #define WL_CONFIGED 0x10
140 #define AFLAGS (IO_ASSIGNED | MEM_ASSIGNED | IRQ_ASSIGNED)
141 #define CFLAGS (EADDR_CONFIGED | WL_CONFIGED)
143 EXTERN struct slot *slots, *current_slot;
146 EXTERN struct allocblk *pool_ioblks; /* I/O blocks in the pool */
147 EXTERN struct allocblk *pool_mem; /* Memory in the pool */
148 EXTERN int pool_irq[16]; /* IRQ allocations */
149 EXTERN int irq_init[16]; /* initial IRQ allocations */
150 EXTERN struct driver *drivers; /* List of drivers */
151 EXTERN struct card *cards;
152 EXTERN struct card *last_card;
153 EXTERN bitstr_t *mem_avail;
154 EXTERN bitstr_t *mem_init;
155 EXTERN bitstr_t *io_avail;
156 EXTERN bitstr_t *io_init;
157 EXTERN int pccard_init_sleep; /* Time to sleep on init */
158 EXTERN int use_kern_irq;
159 EXTERN int debug_level;
161 /* cardd.c functions */
162 void dump_config_file(void);
163 struct slot *readslots(void);
164 void slot_change(struct slot *);
166 /* util.c functions */
167 unsigned long alloc_memory(int);
168 int bit_fns(bitstr_t *, int, int, int, int);
170 void execute(struct cmd *, struct slot *);
171 void logmsg(const char *, ...);
172 void log_setup(void);
175 void reset_slot(struct slot *);
178 /* file.c functions */
179 void readfile(char *);
181 /* server.c functions */
182 void set_socket(int);
183 void stat_changed(struct slot *);
184 void process_client(void);
186 #define IOPORTS 0x400
187 #define MEMUNIT 0x1000
188 #define MEMSTART 0xA0000
189 #define MEMEND 0x100000
190 #define MEMBLKS ((MEMEND-MEMSTART)/MEMUNIT)
191 #define MEM2BIT(x) (((x)-MEMSTART)/MEMUNIT)
192 #define BIT2MEM(x) (((x)*MEMUNIT)+MEMSTART)
194 #define MAXINCLUDES 10
200 #define NORMAL_INDEX 0
201 #define DEFAULT_INDEX 1