defs.h revision 1.6 1 1.6 cube /* $NetBSD: defs.h,v 1.6 2005/10/04 13:06:45 cube Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*
4 1.1 thorpej * Copyright (c) 1992, 1993
5 1.1 thorpej * The Regents of the University of California. All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This software was developed by the Computer Systems Engineering group
8 1.1 thorpej * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 1.1 thorpej * contributed to Berkeley.
10 1.1 thorpej *
11 1.1 thorpej * All advertising materials mentioning features or use of this software
12 1.1 thorpej * must display the following acknowledgement:
13 1.1 thorpej * This product includes software developed by the University of
14 1.1 thorpej * California, Lawrence Berkeley Laboratories.
15 1.1 thorpej *
16 1.1 thorpej * Redistribution and use in source and binary forms, with or without
17 1.1 thorpej * modification, are permitted provided that the following conditions
18 1.1 thorpej * are met:
19 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
20 1.1 thorpej * notice, this list of conditions and the following disclaimer.
21 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
22 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
23 1.1 thorpej * documentation and/or other materials provided with the distribution.
24 1.1 thorpej * 3. Neither the name of the University nor the names of its contributors
25 1.1 thorpej * may be used to endorse or promote products derived from this software
26 1.1 thorpej * without specific prior written permission.
27 1.1 thorpej *
28 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 1.1 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 1.1 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 1.1 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.1 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 1.1 thorpej * SUCH DAMAGE.
39 1.1 thorpej *
40 1.1 thorpej * from: @(#)config.h 8.1 (Berkeley) 6/6/93
41 1.1 thorpej */
42 1.1 thorpej
43 1.1 thorpej /*
44 1.1 thorpej * defs.h: Global definitions for "config"
45 1.1 thorpej */
46 1.1 thorpej
47 1.1 thorpej #if HAVE_NBTOOL_CONFIG_H
48 1.1 thorpej #include "nbtool_config.h"
49 1.1 thorpej #endif
50 1.1 thorpej
51 1.1 thorpej #include <sys/types.h>
52 1.1 thorpej #include <sys/param.h>
53 1.1 thorpej #include <sys/queue.h>
54 1.1 thorpej
55 1.1 thorpej #if !defined(MAKE_BOOTSTRAP) && defined(BSD)
56 1.1 thorpej #include <sys/cdefs.h>
57 1.1 thorpej #include <paths.h>
58 1.1 thorpej #endif
59 1.1 thorpej
60 1.1 thorpej #include <stdio.h>
61 1.1 thorpej #include <stdlib.h>
62 1.1 thorpej #include <unistd.h>
63 1.1 thorpej
64 1.1 thorpej /* These are really for MAKE_BOOTSTRAP but harmless. */
65 1.1 thorpej #ifndef __dead
66 1.1 thorpej #define __dead
67 1.1 thorpej #endif
68 1.1 thorpej #ifndef _PATH_DEVNULL
69 1.1 thorpej #define _PATH_DEVNULL "/dev/null"
70 1.1 thorpej #endif
71 1.1 thorpej
72 1.1 thorpej #ifdef MAKE_BOOTSTRAP
73 1.1 thorpej #undef dev_t
74 1.1 thorpej #undef NODEV
75 1.1 thorpej #undef major
76 1.1 thorpej #undef minor
77 1.1 thorpej #undef makedev
78 1.1 thorpej #define dev_t int /* XXX: assumes int is 32 bits */
79 1.1 thorpej #define NODEV ((dev_t)-1)
80 1.1 thorpej #define major(x) ((int)((((x) & 0x000fff00) >> 8)))
81 1.1 thorpej #define minor(x) ((int)((((x) & 0xfff00000) >> 12) | \
82 1.1 thorpej (((x) & 0x000000ff) >> 0)))
83 1.1 thorpej #define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
84 1.1 thorpej (((y) << 12) & 0xfff00000) | \
85 1.1 thorpej (((y) << 0) & 0x000000ff)))
86 1.1 thorpej #define __attribute__(x)
87 1.1 thorpej #endif /* MAKE_BOOTSTRAP */
88 1.1 thorpej
89 1.1 thorpej #undef setprogname
90 1.1 thorpej #undef getprogname
91 1.1 thorpej extern const char *progname;
92 1.1 thorpej #define setprogname(s) ((void)(progname = (s)))
93 1.1 thorpej #define getprogname() (progname)
94 1.1 thorpej
95 1.1 thorpej #define ARRCHR '#'
96 1.1 thorpej
97 1.1 thorpej /*
98 1.1 thorpej * Name/value lists. Values can be strings or pointers and/or can carry
99 1.1 thorpej * integers. The names can be NULL, resulting in simple value lists.
100 1.1 thorpej */
101 1.1 thorpej struct nvlist {
102 1.1 thorpej struct nvlist *nv_next;
103 1.1 thorpej const char *nv_name;
104 1.1 thorpej union {
105 1.1 thorpej const char *un_str;
106 1.1 thorpej void *un_ptr;
107 1.1 thorpej } nv_un;
108 1.1 thorpej #define nv_str nv_un.un_str
109 1.1 thorpej #define nv_ptr nv_un.un_ptr
110 1.1 thorpej int nv_int;
111 1.1 thorpej int nv_ifunit; /* XXX XXX XXX */
112 1.1 thorpej int nv_flags;
113 1.1 thorpej #define NV_DEPENDED 1
114 1.1 thorpej };
115 1.1 thorpej
116 1.1 thorpej /*
117 1.1 thorpej * Kernel configurations.
118 1.1 thorpej */
119 1.1 thorpej struct config {
120 1.1 thorpej TAILQ_ENTRY(config) cf_next;
121 1.1 thorpej const char *cf_name; /* "netbsd" */
122 1.1 thorpej int cf_lineno; /* source line */
123 1.1 thorpej const char *cf_fstype; /* file system type */
124 1.1 thorpej struct nvlist *cf_root; /* "root on ra0a" */
125 1.1 thorpej struct nvlist *cf_swap; /* "swap on ra0b and ra1b" */
126 1.1 thorpej struct nvlist *cf_dump; /* "dumps on ra0b" */
127 1.1 thorpej };
128 1.1 thorpej
129 1.1 thorpej /*
130 1.1 thorpej * Attributes. These come in three flavors: "plain", "device class,"
131 1.1 thorpej * and "interface". Plain attributes (e.g., "ether") simply serve
132 1.1 thorpej * to pull in files. Device class attributes are like plain
133 1.1 thorpej * attributes, but additionally specify a device class (e.g., the
134 1.1 thorpej * "disk" device class attribute specifies that devices with the
135 1.1 thorpej * attribute belong to the "DV_DISK" class) and are mutually exclusive.
136 1.1 thorpej * Interface attributes (e.g., "scsi") carry three lists: locators,
137 1.1 thorpej * child devices, and references. The locators are those things
138 1.1 thorpej * that must be specified in order to configure a device instance
139 1.1 thorpej * using this attribute (e.g., "tg0 at scsi0"). The a_devs field
140 1.1 thorpej * lists child devices that can connect here (e.g., "tg"s), while
141 1.1 thorpej * the a_refs are parents that carry the attribute (e.g., actual
142 1.1 thorpej * SCSI host adapter drivers such as the SPARC "esp").
143 1.1 thorpej */
144 1.1 thorpej struct attr {
145 1.1 thorpej const char *a_name; /* name of this attribute */
146 1.1 thorpej int a_iattr; /* true => allows children */
147 1.1 thorpej const char *a_devclass; /* device class described */
148 1.1 thorpej struct nvlist *a_locs; /* locators required */
149 1.1 thorpej int a_loclen; /* length of above list */
150 1.1 thorpej struct nvlist *a_devs; /* children */
151 1.1 thorpej struct nvlist *a_refs; /* parents */
152 1.1 thorpej struct nvlist *a_deps; /* we depend on these other attrs */
153 1.1 thorpej int a_expanding; /* to detect cycles in attr graph */
154 1.1 thorpej };
155 1.1 thorpej
156 1.1 thorpej /*
157 1.1 thorpej * Parent specification. Multiple device instances may share a
158 1.1 thorpej * given parent spec. Parent specs are emitted only if there are
159 1.1 thorpej * device instances which actually reference it.
160 1.1 thorpej */
161 1.1 thorpej struct pspec {
162 1.1 thorpej TAILQ_ENTRY(pspec) p_list; /* link on parent spec list */
163 1.1 thorpej struct attr *p_iattr; /* interface attribute of parent */
164 1.1 thorpej struct devbase *p_atdev; /* optional parent device base */
165 1.1 thorpej int p_atunit; /* optional parent device unit */
166 1.1 thorpej struct nvlist *p_devs; /* children using it */
167 1.1 thorpej int p_inst; /* parent spec instance */
168 1.3 cube int p_active; /* parent spec is actively used */
169 1.1 thorpej };
170 1.1 thorpej
171 1.1 thorpej /*
172 1.1 thorpej * The "base" part (struct devbase) of a device ("uba", "sd"; but not
173 1.1 thorpej * "uba2" or "sd0"). It may be found "at" one or more attributes,
174 1.1 thorpej * including "at root" (this is represented by a NULL attribute), as
175 1.1 thorpej * specified by the device attachments (struct deva).
176 1.1 thorpej *
177 1.1 thorpej * Each device may also export attributes. If any provide an output
178 1.1 thorpej * interface (e.g., "esp" provides "scsi"), other devices (e.g.,
179 1.1 thorpej * "tg"s) can be found at instances of this one (e.g., "esp"s).
180 1.1 thorpej * Such a connection must provide locators as specified by that
181 1.1 thorpej * interface attribute (e.g., "target"). The base device can
182 1.1 thorpej * export both output (aka `interface') attributes, as well as
183 1.1 thorpej * import input (`plain') attributes. Device attachments may
184 1.1 thorpej * only import input attributes; it makes no sense to have a
185 1.1 thorpej * specific attachment export a new interface to other devices.
186 1.1 thorpej *
187 1.1 thorpej * Each base carries a list of instances (via d_ihead). Note that this
188 1.1 thorpej * list "skips over" aliases; those must be found through the instances
189 1.1 thorpej * themselves. Each base also carries a list of possible attachments,
190 1.1 thorpej * each of which specify a set of devices that the device can attach
191 1.1 thorpej * to, as well as the device instances that are actually using that
192 1.1 thorpej * attachment.
193 1.1 thorpej */
194 1.1 thorpej struct devbase {
195 1.1 thorpej const char *d_name; /* e.g., "sd" */
196 1.1 thorpej TAILQ_ENTRY(devbase) d_next;
197 1.1 thorpej int d_isdef; /* set once properly defined */
198 1.1 thorpej int d_ispseudo; /* is a pseudo-device */
199 1.1 thorpej int d_major; /* used for "root on sd0", e.g. */
200 1.1 thorpej struct nvlist *d_attrs; /* attributes, if any */
201 1.1 thorpej int d_umax; /* highest unit number + 1 */
202 1.1 thorpej struct devi *d_ihead; /* first instance, if any */
203 1.1 thorpej struct devi **d_ipp; /* used for tacking on more instances */
204 1.1 thorpej struct deva *d_ahead; /* first attachment, if any */
205 1.1 thorpej struct deva **d_app; /* used for tacking on attachments */
206 1.1 thorpej struct attr *d_classattr; /* device class attribute (if any) */
207 1.1 thorpej };
208 1.1 thorpej
209 1.1 thorpej struct deva {
210 1.1 thorpej const char *d_name; /* name of attachment, e.g. "com_isa" */
211 1.1 thorpej TAILQ_ENTRY(deva) d_next; /* list of all instances */
212 1.1 thorpej struct deva *d_bsame; /* list on same base */
213 1.1 thorpej int d_isdef; /* set once properly defined */
214 1.1 thorpej struct devbase *d_devbase; /* the base device */
215 1.1 thorpej struct nvlist *d_atlist; /* e.g., "at tg" (attr list) */
216 1.1 thorpej struct nvlist *d_attrs; /* attributes, if any */
217 1.1 thorpej struct devi *d_ihead; /* first instance, if any */
218 1.1 thorpej struct devi **d_ipp; /* used for tacking on more instances */
219 1.1 thorpej };
220 1.1 thorpej
221 1.1 thorpej /*
222 1.1 thorpej * An "instance" of a device. The same instance may be listed more
223 1.1 thorpej * than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
224 1.1 thorpej *
225 1.1 thorpej * After everything has been read in and verified, the devi's are
226 1.1 thorpej * "packed" to collect all the information needed to generate ioconf.c.
227 1.1 thorpej * In particular, we try to collapse multiple aliases into a single entry.
228 1.1 thorpej * We then assign each "primary" (non-collapsed) instance a cfdata index.
229 1.1 thorpej * Note that there may still be aliases among these.
230 1.1 thorpej */
231 1.1 thorpej struct devi {
232 1.1 thorpej /* created while parsing config file */
233 1.1 thorpej const char *i_name; /* e.g., "sd0" */
234 1.1 thorpej int i_unit; /* unit from name, e.g., 0 */
235 1.1 thorpej struct devbase *i_base;/* e.g., pointer to "sd" base */
236 1.1 thorpej TAILQ_ENTRY(devi) i_next; /* list of all instances */
237 1.1 thorpej struct devi *i_bsame; /* list on same base */
238 1.1 thorpej struct devi *i_asame; /* list on same base attachment */
239 1.1 thorpej struct devi *i_alias; /* other aliases of this instance */
240 1.1 thorpej const char *i_at; /* where this is "at" (NULL if at root) */
241 1.1 thorpej struct pspec *i_pspec; /* parent spec (NULL if at root) */
242 1.1 thorpej struct deva *i_atdeva;
243 1.1 thorpej const char **i_locs; /* locators (as given by pspec's iattr) */
244 1.1 thorpej int i_cfflags; /* flags from config line */
245 1.1 thorpej int i_lineno; /* line # in config, for later errors */
246 1.5 cube const char *i_srcfile; /* file it appears in */
247 1.4 cube int i_active;
248 1.4 cube #define DEVI_ORPHAN 0 /* instance has no active parent */
249 1.4 cube #define DEVI_ACTIVE 1 /* instance has an active parent */
250 1.4 cube #define DEVI_IGNORED 2 /* instance's parent has been removed */
251 1.6 cube #define DEVI_BROKEN 3 /* instance is broken (syntax error) */
252 1.1 thorpej
253 1.1 thorpej /* created during packing or ioconf.c generation */
254 1.1 thorpej short i_collapsed; /* set => this alias no longer needed */
255 1.1 thorpej short i_cfindex; /* our index in cfdata */
256 1.1 thorpej short i_locoff; /* offset in locators.vec */
257 1.1 thorpej
258 1.1 thorpej };
259 1.1 thorpej /* special units */
260 1.1 thorpej #define STAR (-1) /* unit number for, e.g., "sd*" */
261 1.1 thorpej #define WILD (-2) /* unit number for, e.g., "sd?" */
262 1.1 thorpej
263 1.1 thorpej /*
264 1.1 thorpej * Files. Each file is either standard (always included) or optional,
265 1.1 thorpej * depending on whether it has names on which to *be* optional. The
266 1.1 thorpej * options field (fi_optx) is actually an expression tree, with nodes
267 1.1 thorpej * for OR, AND, and NOT, as well as atoms (words) representing some
268 1.1 thorpej * particular option. The node type is stored in the nv_int field.
269 1.1 thorpej * Subexpressions appear in the `next' field; for the binary operators
270 1.1 thorpej * AND and OR, the left subexpression is first stored in the nv_ptr field.
271 1.1 thorpej *
272 1.1 thorpej * For any file marked as needs-count or needs-flag, fixfiles() will
273 1.1 thorpej * build fi_optf, a `flat list' of the options with nv_int fields that
274 1.1 thorpej * contain counts or `need' flags; this is used in mkheaders().
275 1.1 thorpej */
276 1.1 thorpej struct files {
277 1.1 thorpej TAILQ_ENTRY(files) fi_next;
278 1.1 thorpej const char *fi_srcfile; /* the name of the "files" file that got us */
279 1.1 thorpej u_short fi_srcline; /* and the line number */
280 1.1 thorpej u_char fi_flags; /* as below */
281 1.1 thorpej char fi_lastc; /* last char from path */
282 1.1 thorpej const char *fi_path; /* full file path */
283 1.1 thorpej const char *fi_tail; /* name, i.e., strrchr(fi_path, '/') + 1 */
284 1.1 thorpej const char *fi_base; /* tail minus ".c" (or whatever) */
285 1.1 thorpej const char *fi_prefix; /* any file prefix */
286 1.1 thorpej struct nvlist *fi_optx;/* options expression */
287 1.1 thorpej struct nvlist *fi_optf;/* flattened version of above, if needed */
288 1.1 thorpej const char *fi_mkrule; /* special make rule, if any */
289 1.1 thorpej };
290 1.1 thorpej /* flags */
291 1.1 thorpej #define FI_SEL 0x01 /* selected */
292 1.1 thorpej #define FI_NEEDSCOUNT 0x02 /* needs-count */
293 1.1 thorpej #define FI_NEEDSFLAG 0x04 /* needs-flag */
294 1.1 thorpej #define FI_HIDDEN 0x08 /* obscured by other(s), base names overlap */
295 1.1 thorpej
296 1.1 thorpej /*
297 1.1 thorpej * Objects and libraries. This allows precompiled object and library
298 1.1 thorpej * files (e.g. binary-only device drivers) to be linked in.
299 1.1 thorpej */
300 1.1 thorpej struct objects {
301 1.1 thorpej TAILQ_ENTRY(objects) oi_next;
302 1.1 thorpej const char *oi_srcfile; /* the name of the "objects" file that got us */
303 1.1 thorpej u_short oi_srcline; /* and the line number */
304 1.1 thorpej u_char oi_flags; /* as below */
305 1.1 thorpej char oi_lastc; /* last char from path */
306 1.1 thorpej const char *oi_path; /* full object path */
307 1.1 thorpej const char *oi_prefix; /* any file prefix */
308 1.1 thorpej struct nvlist *oi_optx;/* options expression */
309 1.1 thorpej struct nvlist *oi_optf;/* flattened version of above, if needed */
310 1.1 thorpej };
311 1.1 thorpej /* flags */
312 1.1 thorpej #define OI_SEL 0x01 /* selected */
313 1.1 thorpej #define OI_NEEDSFLAG 0x02 /* needs-flag */
314 1.1 thorpej
315 1.1 thorpej #define FX_ATOM 0 /* atom (in nv_name) */
316 1.1 thorpej #define FX_NOT 1 /* NOT expr (subexpression in nv_next) */
317 1.1 thorpej #define FX_AND 2 /* AND expr (lhs in nv_ptr, rhs in nv_next) */
318 1.1 thorpej #define FX_OR 3 /* OR expr (lhs in nv_ptr, rhs in nv_next) */
319 1.1 thorpej
320 1.1 thorpej /*
321 1.1 thorpej * File/object prefixes. These are arranged in a stack, and affect
322 1.1 thorpej * the behavior of the source path.
323 1.1 thorpej */
324 1.1 thorpej struct prefix {
325 1.1 thorpej SLIST_ENTRY(prefix) pf_next; /* next prefix in stack */
326 1.1 thorpej const char *pf_prefix; /* the actual prefix */
327 1.1 thorpej };
328 1.1 thorpej
329 1.1 thorpej /*
330 1.1 thorpej * Device major informations.
331 1.1 thorpej */
332 1.1 thorpej struct devm {
333 1.1 thorpej TAILQ_ENTRY(devm) dm_next;
334 1.1 thorpej const char *dm_srcfile; /* the name of the "majors" file */
335 1.1 thorpej u_short dm_srcline; /* the line number */
336 1.1 thorpej const char *dm_name; /* [bc]devsw name */
337 1.1 thorpej int dm_cmajor; /* character major */
338 1.1 thorpej int dm_bmajor; /* block major */
339 1.1 thorpej struct nvlist *dm_opts; /* options */
340 1.1 thorpej };
341 1.1 thorpej
342 1.1 thorpej /*
343 1.1 thorpej * Hash tables look up name=value pairs. The pointer value of the name
344 1.1 thorpej * is assumed to be constant forever; this can be arranged by interning
345 1.1 thorpej * the name. (This is fairly convenient since our lexer does this for
346 1.1 thorpej * all identifier-like strings---it has to save them anyway, lest yacc's
347 1.1 thorpej * look-ahead wipe out the current one.)
348 1.1 thorpej */
349 1.1 thorpej struct hashtab;
350 1.1 thorpej
351 1.1 thorpej const char *conffile; /* source file, e.g., "GENERIC.sparc" */
352 1.1 thorpej const char *machine; /* machine type, e.g., "sparc" or "sun3" */
353 1.1 thorpej const char *machinearch; /* machine arch, e.g., "sparc" or "m68k" */
354 1.1 thorpej struct nvlist *machinesubarches;
355 1.1 thorpej /* machine subarches, e.g., "sun68k" or "hpc" */
356 1.1 thorpej const char *srcdir; /* path to source directory (rel. to build) */
357 1.1 thorpej const char *builddir; /* path to build directory */
358 1.1 thorpej const char *defbuilddir; /* default build directory */
359 1.1 thorpej const char *ident; /* kernel "ident"ification string */
360 1.1 thorpej int errors; /* counts calls to error() */
361 1.1 thorpej int minmaxusers; /* minimum "maxusers" parameter */
362 1.1 thorpej int defmaxusers; /* default "maxusers" parameter */
363 1.1 thorpej int maxmaxusers; /* default "maxusers" parameter */
364 1.1 thorpej int maxusers; /* configuration's "maxusers" parameter */
365 1.1 thorpej int maxpartitions; /* configuration's "maxpartitions" parameter */
366 1.1 thorpej struct nvlist *options; /* options */
367 1.1 thorpej struct nvlist *fsoptions; /* filesystems */
368 1.1 thorpej struct nvlist *mkoptions; /* makeoptions */
369 1.1 thorpej struct nvlist *appmkoptions; /* appending mkoptions */
370 1.1 thorpej struct hashtab *condmkopttab; /* conditional makeoption table */
371 1.1 thorpej struct hashtab *devbasetab; /* devbase lookup */
372 1.3 cube struct hashtab *devroottab; /* attach at root lookup */
373 1.1 thorpej struct hashtab *devatab; /* devbase attachment lookup */
374 1.1 thorpej struct hashtab *devitab; /* device instance lookup */
375 1.4 cube struct hashtab *deaddevitab; /* removed instances lookup */
376 1.1 thorpej struct hashtab *selecttab; /* selects things that are "optional foo" */
377 1.1 thorpej struct hashtab *needcnttab; /* retains names marked "needs-count" */
378 1.1 thorpej struct hashtab *opttab; /* table of configured options */
379 1.1 thorpej struct hashtab *fsopttab; /* table of configured file systems */
380 1.1 thorpej struct hashtab *defopttab; /* options that have been "defopt"'d */
381 1.1 thorpej struct hashtab *defflagtab; /* options that have been "defflag"'d */
382 1.1 thorpej struct hashtab *defparamtab; /* options that have been "defparam"'d */
383 1.1 thorpej struct hashtab *deffstab; /* defined file systems */
384 1.1 thorpej struct hashtab *optfiletab; /* "defopt"'d option .h files */
385 1.1 thorpej struct hashtab *attrtab; /* attributes (locators, etc.) */
386 1.1 thorpej struct hashtab *bdevmtab; /* block devm lookup */
387 1.1 thorpej struct hashtab *cdevmtab; /* character devm lookup */
388 1.1 thorpej
389 1.1 thorpej TAILQ_HEAD(, devbase) allbases; /* list of all devbase structures */
390 1.1 thorpej TAILQ_HEAD(, deva) alldevas; /* list of all devbase attachments */
391 1.1 thorpej TAILQ_HEAD(, config) allcf; /* list of configured kernels */
392 1.1 thorpej TAILQ_HEAD(, devi) alldevi, /* list of all instances */
393 1.1 thorpej allpseudo; /* list of all pseudo-devices */
394 1.1 thorpej TAILQ_HEAD(, devm) alldevms; /* list of all device-majors */
395 1.1 thorpej TAILQ_HEAD(, pspec) allpspecs; /* list of all parent specs */
396 1.1 thorpej int ndevi; /* number of devi's (before packing) */
397 1.1 thorpej int npspecs; /* number of parent specs */
398 1.1 thorpej int maxbdevm; /* max number of block major */
399 1.1 thorpej int maxcdevm; /* max number of character major */
400 1.1 thorpej int do_devsw; /* 0 if pre-devsw config */
401 1.2 martin int oktopackage; /* 0 before setmachine() */
402 1.1 thorpej
403 1.1 thorpej TAILQ_HEAD(, files) allfiles; /* list of all kernel source files */
404 1.1 thorpej TAILQ_HEAD(, objects) allobjects; /* list of all kernel object and
405 1.1 thorpej library files */
406 1.1 thorpej
407 1.1 thorpej SLIST_HEAD(, prefix) prefixes, /* prefix stack */
408 1.1 thorpej allprefixes; /* all prefixes used (after popped) */
409 1.1 thorpej SLIST_HEAD(, prefix) curdirs; /* curdir stack */
410 1.1 thorpej
411 1.1 thorpej struct devi **packed; /* arrayified table for packed devi's */
412 1.1 thorpej int npacked; /* size of packed table, <= ndevi */
413 1.1 thorpej
414 1.1 thorpej struct { /* loc[] table for config */
415 1.1 thorpej const char **vec;
416 1.1 thorpej int used;
417 1.1 thorpej } locators;
418 1.1 thorpej
419 1.1 thorpej struct numconst {
420 1.1 thorpej int64_t val;
421 1.1 thorpej int fmt;
422 1.1 thorpej };
423 1.1 thorpej
424 1.1 thorpej /* files.c */
425 1.1 thorpej void initfiles(void);
426 1.1 thorpej void checkfiles(void);
427 1.1 thorpej int fixfiles(void); /* finalize */
428 1.1 thorpej int fixobjects(void);
429 1.1 thorpej int fixdevsw(void);
430 1.1 thorpej void addfile(const char *, struct nvlist *, int, const char *);
431 1.1 thorpej void addobject(const char *, struct nvlist *, int);
432 1.1 thorpej
433 1.1 thorpej /* hash.c */
434 1.1 thorpej struct hashtab *ht_new(void);
435 1.1 thorpej int ht_insrep(struct hashtab *, const char *, void *, int);
436 1.1 thorpej #define ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
437 1.1 thorpej #define ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
438 1.1 thorpej int ht_remove(struct hashtab *, const char *);
439 1.1 thorpej void *ht_lookup(struct hashtab *, const char *);
440 1.1 thorpej void initintern(void);
441 1.1 thorpej const char *intern(const char *);
442 1.1 thorpej typedef int (*ht_callback)(const char *, void *, void *);
443 1.1 thorpej int ht_enumerate(struct hashtab *, ht_callback, void *);
444 1.1 thorpej
445 1.1 thorpej /* main.c */
446 1.1 thorpej void addoption(const char *, const char *);
447 1.1 thorpej void addfsoption(const char *);
448 1.1 thorpej void addmkoption(const char *, const char *);
449 1.1 thorpej void appendmkoption(const char *, const char *);
450 1.1 thorpej void appendcondmkoption(const char *, const char *, const char *);
451 1.1 thorpej void deffilesystem(const char *, struct nvlist *);
452 1.1 thorpej void defoption(const char *, struct nvlist *, struct nvlist *);
453 1.1 thorpej void defflag(const char *, struct nvlist *, struct nvlist *);
454 1.1 thorpej void defparam(const char *, struct nvlist *, struct nvlist *);
455 1.1 thorpej void deloption(const char *);
456 1.1 thorpej void delfsoption(const char *);
457 1.1 thorpej void delmkoption(const char *);
458 1.1 thorpej int devbase_has_instances(struct devbase *, int);
459 1.1 thorpej struct nvlist * find_declared_option(const char *);
460 1.1 thorpej int deva_has_instances(struct deva *, int);
461 1.1 thorpej void setupdirs(void);
462 1.1 thorpej
463 1.1 thorpej /* tests on option types */
464 1.1 thorpej #define OPT_FSOPT(n) (ht_lookup(deffstab, (n)) != NULL)
465 1.1 thorpej #define OPT_DEFOPT(n) (ht_lookup(defopttab, (n)) != NULL)
466 1.1 thorpej #define OPT_DEFFLAG(n) (ht_lookup(defflagtab, (n)) != NULL)
467 1.1 thorpej #define OPT_DEFPARAM(n) (ht_lookup(defparamtab, (n)) != NULL)
468 1.1 thorpej #define DEFINED_OPTION(n) (find_declared_option((n)) != NULL)
469 1.1 thorpej
470 1.1 thorpej /* main.c */
471 1.1 thorpej void logconfig_include(FILE *, const char *);
472 1.1 thorpej
473 1.1 thorpej /* mkdevsw.c */
474 1.1 thorpej int mkdevsw(void);
475 1.1 thorpej
476 1.1 thorpej /* mkheaders.c */
477 1.1 thorpej int mkheaders(void);
478 1.1 thorpej int moveifchanged(const char *, const char *);
479 1.1 thorpej
480 1.1 thorpej /* mkioconf.c */
481 1.1 thorpej int mkioconf(void);
482 1.1 thorpej
483 1.1 thorpej /* mkmakefile.c */
484 1.1 thorpej int mkmakefile(void);
485 1.1 thorpej
486 1.1 thorpej /* mkswap.c */
487 1.1 thorpej int mkswap(void);
488 1.1 thorpej
489 1.1 thorpej /* pack.c */
490 1.1 thorpej void pack(void);
491 1.1 thorpej
492 1.1 thorpej /* scan.l */
493 1.1 thorpej int currentline(void);
494 1.1 thorpej int firstfile(const char *);
495 1.1 thorpej void package(const char *);
496 1.1 thorpej int include(const char *, int, int, int);
497 1.1 thorpej
498 1.1 thorpej /* sem.c, other than for yacc actions */
499 1.1 thorpej void initsem(void);
500 1.1 thorpej
501 1.1 thorpej /* util.c */
502 1.1 thorpej void *ecalloc(size_t, size_t);
503 1.1 thorpej void *emalloc(size_t);
504 1.1 thorpej void *erealloc(void *, size_t);
505 1.1 thorpej char *estrdup(const char *);
506 1.1 thorpej void prefix_push(const char *);
507 1.1 thorpej void prefix_pop(void);
508 1.1 thorpej char *sourcepath(const char *);
509 1.1 thorpej void warn(const char *, ...) /* immediate warns */
510 1.1 thorpej __attribute__((__format__(__printf__, 1, 2)));
511 1.5 cube void xwarn(const char *, int, const char *, ...) /* delayed warns */
512 1.5 cube __attribute__((__format__(__printf__, 3, 4)));
513 1.1 thorpej void error(const char *, ...) /* immediate errs */
514 1.1 thorpej __attribute__((__format__(__printf__, 1, 2)));
515 1.1 thorpej void xerror(const char *, int, const char *, ...) /* delayed errs */
516 1.1 thorpej __attribute__((__format__(__printf__, 3, 4)));
517 1.1 thorpej __dead void panic(const char *, ...)
518 1.1 thorpej __attribute__((__format__(__printf__, 1, 2)));
519 1.1 thorpej struct nvlist *newnv(const char *, const char *, void *, int, struct nvlist *);
520 1.1 thorpej void nvfree(struct nvlist *);
521 1.1 thorpej void nvfreel(struct nvlist *);
522 1.1 thorpej
523 1.1 thorpej /* liby */
524 1.1 thorpej void yyerror(const char *);
525 1.1 thorpej int yylex(void);
526