1/*	$NetBSD: defs.h,v 1.109 2024/04/05 00:43:42 riastradh Exp $	*/
2
3/*
4 * Copyright (c) 1992, 1993
5 *	The Regents of the University of California.  All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 *	This product includes software developed by the University of
14 *	California, Lawrence Berkeley Laboratories.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 *    notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 *    notice, this list of conditions and the following disclaimer in the
23 *    documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 *    may be used to endorse or promote products derived from this software
26 *    without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 *	from: @(#)config.h	8.1 (Berkeley) 6/6/93
41 */
42
43/*
44 * defs.h:  Global definitions for "config"
45 */
46
47#if HAVE_NBTOOL_CONFIG_H
48#include "nbtool_config.h"
49#endif
50
51#include <sys/types.h>
52#include <sys/param.h>
53#include <sys/queue.h>
54
55#if !defined(MAKE_BOOTSTRAP) && defined(BSD)
56#include <sys/cdefs.h>
57#include <paths.h>
58#endif
59
60#include <stdio.h>
61#include <stdlib.h>
62#include <unistd.h>
63
64/* These are really for MAKE_BOOTSTRAP but harmless. */
65#ifndef __dead
66#define __dead
67#endif
68#ifndef __printflike
69#define __printflike(a, b)
70#endif
71#ifndef _PATH_DEVNULL
72#define _PATH_DEVNULL "/dev/null"
73#endif
74
75#ifdef	MAKE_BOOTSTRAP
76#undef	dev_t
77#undef	devmajor_t
78#undef	devminor_t
79#undef	NODEV
80#undef	NODEVMAJOR
81#undef	major
82#undef	minor
83#undef	makedev
84#define	dev_t		unsigned int	/* XXX: assumes int is 32 bits */
85#define	NODEV		((dev_t)-1)
86#define devmajor_t	int
87#define devminor_t	int
88#define NODEVMAJOR	(-1)
89#define major(x)        ((devmajor_t)((((x) & 0x000fff00) >>  8)))
90#define minor(x)        ((devminor_t)((((x) & 0xfff00000) >> 12) | \
91			       (((x) & 0x000000ff) >>  0)))
92#define makedev(x,y)    ((dev_t)((((dev_t)(x) <<  8) & 0x000fff00U) | \
93                                 (((dev_t)(y) << 12) & 0xfff00000U) | \
94                                 (((dev_t)(y) <<  0) & 0x000000ffU)))
95#define __attribute__(x)
96#endif	/* MAKE_BOOTSTRAP */
97
98#undef setprogname
99#undef getprogname
100extern const char *progname;
101#define	setprogname(s)	((void)(progname = (s)))
102#define	getprogname()	(progname)
103
104#define ARRCHR '#'
105
106/*
107 * The next two lines define the current version of the config(1) binary,
108 * and the minimum version of the configuration files it supports.
109 */
110#define CONFIG_VERSION		20240118
111#define CONFIG_MINVERSION	0
112
113struct where {
114	const char *w_srcfile;		/* file name where we are defined */
115	u_short	w_srcline;		/* line number where we are defined */
116};
117/*
118 * Name/value lists.  Values can be strings or pointers and/or can carry
119 * integers.  The names can be NULL, resulting in simple value lists.
120 */
121struct nvlist {
122	struct nvlist	*nv_next;
123	const char	*nv_name;
124	const char	*nv_str;
125	void		*nv_ptr;
126	long long	nv_num;
127	int		nv_ifunit;		/* XXX XXX XXX */
128	int		nv_flags;
129#define	NV_DEPENDED	1
130	struct where	nv_where;
131};
132
133/*
134 * Kernel configurations.
135 */
136struct config {
137	TAILQ_ENTRY(config) cf_next;
138	const char *cf_name;		/* "netbsd" */
139	const char *cf_fstype;		/* file system type */
140	struct	nvlist *cf_root;	/* "root on ra0a" */
141	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
142	struct where	cf_where;
143};
144
145/*
146 * Option definition list
147 */
148struct defoptlist {
149	struct defoptlist *dl_next;
150	const char *dl_name;
151	const char *dl_value;
152	const char *dl_lintvalue;
153	int dl_obsolete;
154	int dl_mkvar;
155	struct nvlist *dl_depends;
156	struct where	dl_where;
157};
158
159struct files;
160TAILQ_HEAD(filelist, files);
161
162struct module {
163	const char		*m_name;
164#if 1
165	struct attrlist		*m_deps;
166#else
167	struct attrlist		*m_attrs;
168	struct modulelist	*m_deps;
169#endif
170	int			m_expanding;
171	struct filelist		m_files;
172	int			m_weight;
173};
174
175/*
176 * Attributes.  These come in three flavors: "plain", "device class,"
177 * and "interface".  Plain attributes (e.g., "ether") simply serve
178 * to pull in files.  Device class attributes are like plain
179 * attributes, but additionally specify a device class (e.g., the
180 * "disk" device class attribute specifies that devices with the
181 * attribute belong to the "DV_DISK" class) and are mutually exclusive.
182 * Interface attributes (e.g., "scsi") carry three lists: locators,
183 * child devices, and references.  The locators are those things
184 * that must be specified in order to configure a device instance
185 * using this attribute (e.g., "tg0 at scsi0").  The a_devs field
186 * lists child devices that can connect here (e.g., "tg"s), while
187 * the a_refs are parents that carry the attribute (e.g., actual
188 * SCSI host adapter drivers such as the SPARC "esp").
189 */
190struct attr {
191	/* XXX */
192	struct module a_m;
193#define	a_name		a_m.m_name
194#define	a_deps		a_m.m_deps
195#define	a_expanding	a_m.m_expanding
196#define	a_files		a_m.m_files
197#define	a_weight	a_m.m_weight
198
199	/* "interface attribute" */
200	uint8_t	a_iattr;		/* true => allows children */
201	uint8_t a_deselected;		/* deselected */
202	struct	loclist *a_locs;	/* locators required */
203	int	a_loclen;		/* length of above list */
204	struct	nvlist *a_devs;		/* children */
205	struct	nvlist *a_refs;		/* parents */
206
207	/* "device class" */
208	const char *a_devclass;		/* device class described */
209	struct where a_where;
210
211	size_t	a_idx;			/* index to break sorting ties */
212};
213
214/*
215 * List of attributes.
216 */
217struct attrlist {
218	struct attrlist *al_next;
219	struct attr *al_this;
220};
221
222/*
223 * List of locators. (Either definitions or uses...)
224 *
225 * XXX it would be nice if someone could clarify wtf ll_string and ll_num
226 * are actually holding. (This stuff was previously stored in a very ad
227 * hoc fashion, and the code is far from clear.)
228 */
229struct loclist {
230	const char *ll_name;
231	const char *ll_string;
232	long long ll_num;
233	struct loclist *ll_next;
234};
235
236/*
237 * Parent specification.  Multiple device instances may share a
238 * given parent spec.  Parent specs are emitted only if there are
239 * device instances which actually reference it.
240 */
241struct pspec {
242	TAILQ_ENTRY(pspec) p_list;	/* link on parent spec list */
243	struct	attr *p_iattr;		/* interface attribute of parent */
244	struct	devbase *p_atdev;	/* optional parent device base */
245	int	p_atunit;		/* optional parent device unit */
246	struct	nvlist *p_devs;		/* children using it */
247	int	p_inst;			/* parent spec instance */
248	int	p_active;		/* parent spec is actively used */
249	int	p_ref;			/* refcount */
250};
251
252/*
253 * The "base" part (struct devbase) of a device ("uba", "sd"; but not
254 * "uba2" or "sd0").  It may be found "at" one or more attributes,
255 * including "at root" (this is represented by a NULL attribute), as
256 * specified by the device attachments (struct deva).
257 *
258 * Each device may also export attributes.  If any provide an output
259 * interface (e.g., "esp" provides "scsi"), other devices (e.g.,
260 * "tg"s) can be found at instances of this one (e.g., "esp"s).
261 * Such a connection must provide locators as specified by that
262 * interface attribute (e.g., "target").  The base device can
263 * export both output (aka `interface') attributes, as well as
264 * import input (`plain') attributes.  Device attachments may
265 * only import input attributes; it makes no sense to have a
266 * specific attachment export a new interface to other devices.
267 *
268 * Each base carries a list of instances (via d_ihead).  Note that this
269 * list "skips over" aliases; those must be found through the instances
270 * themselves.  Each base also carries a list of possible attachments,
271 * each of which specify a set of devices that the device can attach
272 * to, as well as the device instances that are actually using that
273 * attachment.
274 */
275struct devbase {
276	const char *d_name;		/* e.g., "sd" */
277	TAILQ_ENTRY(devbase) d_next;
278	int 	d_level;
279	struct devbase *d_levelparent;
280	int	d_isdef;		/* set once properly defined */
281	int	d_ispseudo;		/* is a pseudo-device */
282	devmajor_t d_major;		/* used for "root on sd0", e.g. */
283	struct	attrlist *d_attrs;	/* attributes, if any */
284	int	d_umax;			/* highest unit number + 1 */
285	struct	devi *d_ihead;		/* first instance, if any */
286	struct	devi **d_ipp;		/* used for tacking on more instances */
287	struct	deva *d_ahead;		/* first attachment, if any */
288	struct	deva **d_app;		/* used for tacking on attachments */
289	struct	attr *d_classattr;	/* device class attribute (if any) */
290	struct	where d_where;
291};
292
293struct deva {
294	const char *d_name;		/* name of attachment, e.g. "com_isa" */
295	TAILQ_ENTRY(deva) d_next;	/* list of all instances */
296	struct	deva *d_bsame;		/* list on same base */
297	int	d_isdef;		/* set once properly defined */
298	struct	devbase *d_devbase;	/* the base device */
299	struct	nvlist *d_atlist;	/* e.g., "at tg" (attr list) */
300	struct	attrlist *d_attrs;	/* attributes, if any */
301	struct	devi *d_ihead;		/* first instance, if any */
302	struct	devi **d_ipp;		/* used for tacking on more instances */
303	struct	where d_where;
304};
305
306/*
307 * An "instance" of a device.  The same instance may be listed more
308 * than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
309 *
310 * After everything has been read in and verified, the devi's are
311 * "packed" to collect all the information needed to generate ioconf.c.
312 * In particular, we try to collapse multiple aliases into a single entry.
313 * We then assign each "primary" (non-collapsed) instance a cfdata index.
314 * Note that there may still be aliases among these.
315 */
316struct devi {
317	/* created while parsing config file */
318	const char *i_name;	/* e.g., "sd0" */
319	int	i_unit;		/* unit from name, e.g., 0 */
320	struct	devbase *i_base;/* e.g., pointer to "sd" base */
321	TAILQ_ENTRY(devi) i_next; /* list of all instances */
322	struct	devi *i_bsame;	/* list on same base */
323	struct	devi *i_asame;	/* list on same base attachment */
324	struct	devi *i_alias;	/* other aliases of this instance */
325	const char *i_at;	/* where this is "at" (NULL if at root) */
326	struct	pspec *i_pspec;	/* parent spec (NULL if at root) */
327	struct	deva *i_atdeva;
328	const char **i_locs;	/* locators (as given by pspec's iattr) */
329	int	i_cfflags;	/* flags from config line */
330	int	i_level;	/* position between negated instances */
331	int	i_active;
332#define	DEVI_ORPHAN	0	/* instance has no active parent */
333#define	DEVI_ACTIVE	1	/* instance has an active parent */
334#define	DEVI_IGNORED	2	/* instance's parent has been removed */
335#define DEVI_BROKEN	3	/* instance is broken (syntax error) */
336	int	i_pseudoroot;	/* instance is pseudoroot */
337
338	/* created during packing or ioconf.c generation */
339	short	i_collapsed;	/* set => this alias no longer needed */
340	u_short	i_cfindex;	/* our index in cfdata */
341	int	i_locoff;	/* offset in locators.vec */
342	struct	where i_where;
343};
344/* special units */
345#define	STAR	(-1)		/* unit number for, e.g., "sd*" */
346#define	WILD	(-2)		/* unit number for, e.g., "sd?" */
347
348/*
349 * Files (*.c, *.S, or *.o).  This structure defines the common fields
350 * between the two.
351 */
352struct files {
353	TAILQ_ENTRY(files) fi_next;
354	TAILQ_ENTRY(files) fi_snext;	/* per-suffix list */
355	struct	where fi_where;
356	u_char fi_flags;	/* as below */
357	const char *fi_tail;	/* name, i.e., strrchr(fi_path, '/') + 1 */
358	const char *fi_base;	/* tail minus ".c" (or whatever) */
359	const char *fi_dir;	/* path to file */
360	const char *fi_path;	/* full file path */
361	const char *fi_prefix;	/* any file prefix */
362	const char *fi_buildprefix;	/* prefix in builddir */
363	int fi_suffix;		/* single char suffix */
364	size_t fi_len;		/* path string length */
365	struct condexpr *fi_optx; /* options expression */
366	struct nvlist *fi_optf; /* flattened version of above, if needed */
367	const char *fi_mkrule;	/* special make rule, if any */
368	struct attr *fi_attr;	/* owner attr */
369	int fi_order;		/* score of order in ${ALLFILES} */
370	TAILQ_ENTRY(files) fi_anext;	/* next file in attr */
371};
372
373/* flags */
374#define	FI_SEL		0x01	/* selected */
375#define	FI_NEEDSCOUNT	0x02	/* needs-count */
376#define	FI_NEEDSFLAG	0x04	/* needs-flag */
377#define	FI_HIDDEN	0x08	/* obscured by other(s), base names overlap */
378
379extern size_t nselfiles;
380extern struct files **selfiles;
381
382/*
383 * Condition expressions.
384 */
385
386enum condexpr_types {
387	CX_ATOM,
388	CX_NOT,
389	CX_AND,
390	CX_OR,
391};
392struct condexpr {
393	enum condexpr_types cx_type;
394	union {
395		const char *atom;
396		struct condexpr *not;
397		struct {
398			struct condexpr *left;
399			struct condexpr *right;
400		} and, or;
401	} cx_u;
402};
403#define cx_atom	cx_u.atom
404#define cx_not	cx_u.not
405#define cx_and	cx_u.and
406#define cx_or	cx_u.or
407
408/*
409 * File/object prefixes.  These are arranged in a stack, and affect
410 * the behavior of the source path.
411 */
412
413struct prefix;
414SLIST_HEAD(prefixlist, prefix);
415
416struct prefix {
417	SLIST_ENTRY(prefix)	pf_next;	/* next prefix in stack */
418	const char		*pf_prefix;	/* the actual prefix */
419};
420
421/*
422 * Device major informations.
423 */
424struct devm {
425	TAILQ_ENTRY(devm) dm_next;
426	const char	*dm_name;	/* [bc]devsw name */
427	devmajor_t	dm_cmajor;	/* character major */
428	devmajor_t	dm_bmajor;	/* block major */
429	struct condexpr	*dm_opts;	/* options */
430	struct nvlist	*dm_devnodes;	/* information on /dev nodes */
431	struct where dm_where;
432};
433
434/*
435 * Hash tables look up name=value pairs.  The pointer value of the name
436 * is assumed to be constant forever; this can be arranged by interning
437 * the name.  (This is fairly convenient since our lexer does this for
438 * all identifier-like strings---it has to save them anyway, lest yacc's
439 * look-ahead wipe out the current one.)
440 */
441struct hashtab;
442
443extern int lkmmode;
444extern const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
445extern const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
446extern const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
447extern struct	nvlist *machinesubarches;
448				/* machine subarches, e.g., "sun68k" or "hpc" */
449extern const char *ioconfname;		/* ioconf name, mutually exclusive to machine */
450extern const char *srcdir;		/* path to source directory (rel. to build) */
451extern const char *builddir;		/* path to build directory */
452extern const char *defbuilddir;	/* default build directory */
453extern const char *ident;		/* kernel "ident"ification string */
454extern int	errors;			/* counts calls to error() */
455extern int	minmaxusers;		/* minimum "maxusers" parameter */
456extern int	defmaxusers;		/* default "maxusers" parameter */
457extern int	maxmaxusers;		/* default "maxusers" parameter */
458extern int	maxusers;		/* configuration's "maxusers" parameter */
459extern int	maxpartitions;		/* configuration's "maxpartitions" parameter */
460extern int	version;		/* version of the configuration file */
461extern struct	nvlist *options;	/* options */
462extern struct	nvlist *fsoptions;	/* filesystems */
463extern struct	nvlist *mkoptions;	/* makeoptions */
464extern struct	nvlist *appmkoptions;	/* appending mkoptions */
465extern struct	nvlist *condmkoptions;	/* conditional makeoption table */
466extern struct	hashtab *devbasetab;	/* devbase lookup */
467extern struct	hashtab *devroottab;	/* attach at root lookup */
468extern struct	hashtab *devatab;	/* devbase attachment lookup */
469extern struct	hashtab *devitab;	/* device instance lookup */
470extern struct	hashtab *deaddevitab;	/* removed instances lookup */
471extern struct	hashtab *selecttab;	/* selects things that are "optional foo" */
472extern struct	hashtab *needcnttab;	/* retains names marked "needs-count" */
473extern struct	hashtab *opttab;	/* table of configured options */
474extern struct	hashtab *fsopttab;	/* table of configured file systems */
475extern struct	dlhash *defopttab;	/* options that have been "defopt"'d */
476extern struct	dlhash *defflagtab;	/* options that have been "defflag"'d */
477extern struct	dlhash *defparamtab;	/* options that have been "defparam"'d */
478extern struct	dlhash *defoptlint;	/* lint values for options */
479extern struct	nvhash *deffstab;	/* defined file systems */
480extern struct	dlhash *optfiletab;	/* "defopt"'d option .h files */
481extern struct	hashtab *attrtab;	/* attributes (locators, etc.) */
482extern struct	hashtab *attrdeptab;	/* attribute dependencies */
483extern struct	hashtab *bdevmtab;	/* block devm lookup */
484extern struct	hashtab *cdevmtab;	/* character devm lookup */
485
486TAILQ_HEAD(devbasetq, devbase);
487TAILQ_HEAD(devatq, deva);
488TAILQ_HEAD(conftq, config);
489TAILQ_HEAD(devitq, devi);
490TAILQ_HEAD(devmtq, devm);
491TAILQ_HEAD(pspectq, pspec);
492
493extern struct devbasetq allbases;	/* list of all devbase structures */
494extern struct devatq alldevas;		/* list of all devbase attachments */
495extern struct conftq allcf;		/* list of configured kernels */
496extern struct devitq alldevi,		/* list of all instances */
497		     allpseudo;		/* list of all pseudo-devices */
498extern struct devmtq alldevms;		/* list of all device-majors */
499extern struct pspectq allpspecs;	/* list of all parent specs */
500extern int	ndevi;			/* number of devi's (before packing) */
501extern int	npspecs;		/* number of parent specs */
502extern devmajor_t maxbdevm;		/* max number of block major */
503extern devmajor_t maxcdevm;		/* max number of character major */
504extern int	do_devsw;		/* 0 if pre-devsw config */
505extern int	oktopackage;		/* 0 before setmachine() */
506extern int	devilevel;		/* used for devi->i_level */
507
508extern struct filelist		allfiles;	/* list of all kernel source files */
509extern struct filelist		allcfiles;	/* list of all .c files */
510extern struct filelist		allsfiles;	/* list of all .S files */
511extern struct filelist		allofiles;	/* list of all .o files */
512
513extern struct prefixlist	prefixes,	/* prefix stack */
514				allprefixes;	/* all prefixes used
515						 * (after popped) */
516extern struct prefixlist	buildprefixes,	/* build prefix stack */
517				allbuildprefixes;/* all build prefixes used
518						  * (after popped) */
519
520extern struct attr allattr;
521extern struct devi **packed;	/* arrayified table for packed devi's */
522extern size_t npacked;		/* size of packed table, <= ndevi */
523
524extern struct locators {			/* loc[] table for config */
525	const char **vec;
526	int	used;
527} locators;
528
529struct numconst {
530	int64_t	val;
531	int fmt;
532};
533
534/* files.c */
535void	initfiles(void);
536void	checkfiles(void);
537int	fixfiles(void);		/* finalize */
538int	fixdevsw(void);
539void	addfile(const char *, struct condexpr *, u_char, const char *);
540int	expr_eval(struct condexpr *, int (*)(const char *, void *), void *);
541
542/* hash.c */
543struct	hashtab *ht_new(void);
544void	ht_free(struct hashtab *);
545int	ht_insrep2(struct hashtab *, const char *, const char *, void *, int);
546int	ht_insrep(struct hashtab *, const char *, void *, int);
547#define	ht_insert2(ht, nam1, nam2, val) ht_insrep2(ht, nam1, nam2, val, 0)
548#define	ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
549#define	ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
550int	ht_remove2(struct hashtab *, const char *, const char *);
551int	ht_remove(struct hashtab *, const char *);
552void	*ht_lookup2(struct hashtab *, const char *, const char *);
553void	*ht_lookup(struct hashtab *, const char *);
554void	initintern(void);
555const char *intern(const char *);
556typedef int (*ht_callback2)(const char *, const char *, void *, void *);
557typedef int (*ht_callback)(const char *, void *, void *);
558int	ht_enumerate2(struct hashtab *, ht_callback2, void *);
559int	ht_enumerate(struct hashtab *, ht_callback, void *);
560
561/* typed hash, named struct HT, whose type is string -> struct VT */
562#define DECLHASH(HT, VT) \
563	struct HT;							\
564	struct HT *HT##_create(void);					\
565	int HT##_insert(struct HT *, const char *, struct VT *);	\
566	int HT##_replace(struct HT *, const char *, struct VT *);	\
567	int HT##_remove(struct HT *, const char *);			\
568	struct VT *HT##_lookup(struct HT *, const char *);		\
569	int HT##_enumerate(struct HT *,					\
570			int (*)(const char *, struct VT *, void *),	\
571			void *)
572DECLHASH(nvhash, nvlist);
573DECLHASH(dlhash, defoptlist);
574
575/* lint.c */
576void	emit_instances(void);
577void	emit_options(void);
578void	emit_params(void);
579
580/* main.c */
581extern	int Mflag;
582extern	int Sflag;
583void	addoption(const char *, const char *);
584void	addfsoption(const char *);
585void	addmkoption(const char *, const char *);
586void	appendmkoption(const char *, const char *);
587void	appendcondmkoption(struct condexpr *, const char *, const char *);
588void	deffilesystem(struct nvlist *, struct nvlist *);
589void	defoption(const char *, struct defoptlist *, struct nvlist *);
590void	defflag(const char *, struct defoptlist *, struct nvlist *, int);
591void	defparam(const char *, struct defoptlist *, struct nvlist *, int);
592void	deloption(const char *, int);
593void	delfsoption(const char *, int);
594void	delmkoption(const char *, int);
595int	devbase_has_instances(struct devbase *, int);
596struct where *find_declared_option(const char *);
597struct defoptlist *find_declared_option_option(const char *name);
598int	deva_has_instances(struct deva *, int);
599void	setupdirs(void);
600void	fixmaxusers(void);
601void	fixmkoption(void);
602void	mkflagvar(struct defoptlist *);
603const char *strtolower(const char *);
604
605/* tests on option types */
606#define OPT_FSOPT(n)	(nvhash_lookup(deffstab, (n)) != NULL)
607#define OPT_DEFOPT(n)	(dlhash_lookup(defopttab, (n)) != NULL)
608#define OPT_DEFFLAG(n)	(dlhash_lookup(defflagtab, (n)) != NULL)
609#define OPT_DEFPARAM(n)	(dlhash_lookup(defparamtab, (n)) != NULL)
610#define OPT_OBSOLETE(n)	(dlhash_lookup(obsopttab, (n)) != NULL)
611#define DEFINED_OPTION(n) (find_declared_option((n)))
612
613/* main.c */
614void	logconfig_include(FILE *, const char *);
615
616/* mkdevsw.c */
617int	mkdevsw(void);
618
619/* mkheaders.c */
620int	mkheaders(void);
621int	moveifchanged(const char *, const char *);
622int	emitlocs(void);
623int	emitioconfh(void);
624
625/* mkioconf.c */
626int	mkioconf(void);
627
628/* mkmakefile.c */
629int	mkmakefile(void);
630
631/* mkswap.c */
632int	mkswap(void);
633
634/* pack.c */
635void	pack(void);
636
637/* scan.l */
638u_short	currentline(void);
639int	firstfile(const char *);
640void	package(const char *);
641int	include(const char *, int, int, int);
642extern int includedepth;
643
644/* sem.c, other than for yacc actions */
645void	initsem(void);
646int	onlist(struct nvlist *, void *);
647
648/* util.c */
649void	prefix_push(const char *);
650void	prefix_pop(void);
651void	buildprefix_push(const char *);
652void	buildprefix_pop(void);
653char	*sourcepath(const char *);
654extern	int dflag;
655#define	CFGDBG(n, ...) \
656	do { if ((dflag) >= (n)) cfgdbg(__VA_ARGS__); } while (0)
657void	cfgdbg(const char *, ...)			/* debug info */
658     __printflike(1, 2);
659void	cfgwarn(const char *, ...)			/* immediate warns */
660     __printflike(1, 2);
661void	cfgxwarn(const char *, int, const char *, ...)	/* delayed warns */
662     __printflike(3, 4);
663void	cfgerror(const char *, ...)			/* immediate errs */
664     __printflike(1, 2);
665void	cfgxerror(const char *, int, const char *, ...)	/* delayed errs */
666     __printflike(3, 4);
667__dead void panic(const char *, ...)
668     __printflike(1, 2);
669struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *);
670void	nvfree(struct nvlist *);
671void	nvfreel(struct nvlist *);
672struct nvlist *nvcat(struct nvlist *, struct nvlist *);
673void	autogen_comment(FILE *, const char *);
674struct defoptlist *defoptlist_create(const char *, const char *, const char *);
675void defoptlist_destroy(struct defoptlist *);
676struct defoptlist *defoptlist_append(struct defoptlist *, struct defoptlist *);
677struct attrlist *attrlist_create(void);
678struct attrlist *attrlist_cons(struct attrlist *, struct attr *);
679void attrlist_destroy(struct attrlist *);
680void attrlist_destroyall(struct attrlist *);
681struct loclist *loclist_create(const char *, const char *, long long);
682void loclist_destroy(struct loclist *);
683struct condexpr *condexpr_create(enum condexpr_types);
684void condexpr_destroy(struct condexpr *);
685
686/* liby */
687void	yyerror(const char *);
688int	yylex(void);
689