Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / pccard / pccardd / cardd.h
1 /*
2  * Copyright (c) 1995 Andrew McRae.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
14  *
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.
25  *
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 $
28  *
29  *      Common include file for PCMCIA daemon
30  */
31 #include <bitstring.h>
32
33 #include <pccard/cardinfo.h>
34 #include <pccard/cis.h>
35
36 #include "readcis.h"
37
38 #ifndef EXTERN
39 #define EXTERN extern
40 #endif
41
42 struct cmd {
43         struct cmd *next;
44         char   *line;           /* Command line */
45         int     macro;          /* Contains macros */
46 };
47
48 struct card_config {
49         struct card_config *next;
50         unsigned char index_type;
51         unsigned char index;
52         struct driver *driver;
53         int     irq;
54         int     flags;
55         char    inuse;
56 };
57
58 struct ether {
59         struct ether *next;
60         int     type;
61         int     value;
62 };
63
64 #define ETHTYPE_GENERIC         0
65 #define ETHTYPE_ATTR2           1
66
67 struct card {
68         struct card *next;
69         char   *manuf;
70         char   *version;
71         char   *add_info1;
72         char   *add_info2;
73         u_char  func_id;
74         int     deftype;
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 */
82 };
83
84 struct driver {
85         struct driver *next;
86         char   *name;
87         char   *kernel;                 /* Kernel driver base name */
88         int     unit;                   /* Unit of driver */
89         /*
90          * The rest of the structure is allocated dynamically.
91          * Once allocated, it stays allocated.
92          */
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) */
96         int     inuse;
97 };
98
99 /*
100  *      Defines one allocation block i.e a starting address
101  *      and size. Used for either memory or I/O ports
102  */
103 struct allocblk {
104         struct allocblk *next;
105         int     addr;                   /* Address */
106         int     size;                   /* Size */
107         int     flags;                  /* Flags for block */
108         int     cardaddr;               /* Card address */
109 };
110 /*
111  *      Slot structure - data held for each slot.
112  */
113 struct slot {
114         struct slot *next;
115         int     fd;
116         int     mask;
117         int     slot;
118         char   *name;
119         enum cardstate state;
120         struct cis *cis;
121         struct card *card;              /* Current card */
122         struct card_config *config;     /* Current configuration */
123         struct cis_config *card_config;
124         char    devname[16];
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 */
130 };
131
132 /*
133  * Slot resource assignment/configuration flags
134  */
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)
142
143 EXTERN struct slot *slots, *current_slot;
144 EXTERN int slen;
145
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;
160
161 /* cardd.c functions */
162 void             dump_config_file(void);
163 struct slot     *readslots(void);
164 void             slot_change(struct slot *);
165
166 /* util.c functions */
167 unsigned long    alloc_memory(int);
168 int              bit_fns(bitstr_t *, int, int, int, int);
169 void             die(char *);
170 void             execute(struct cmd *, struct slot *);
171 void             logmsg(const char *, ...);
172 void             log_setup(void);
173 void             logerr(char *);
174 char            *newstr();
175 void             reset_slot(struct slot *);
176 void            *xmalloc(int);
177
178 /* file.c functions */
179 void             readfile(char *);
180
181 /* server.c functions */
182 void             set_socket(int);
183 void             stat_changed(struct slot *);
184 void             process_client(void);
185
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)
193
194 #define MAXINCLUDES     10
195 #define MAXERRORS       10
196
197 /*
198  * Config index types
199  */
200 #define NORMAL_INDEX    0
201 #define DEFAULT_INDEX   1
202 #define AUTO_INDEX      2
203
204 #define DT_VERS 0
205 #define DT_FUNC 1