Home | History | Annotate | Line # | Download | only in config
defs.h revision 1.64
      1 /*	$NetBSD: defs.h,v 1.64 2014/11/17 00:53:15 uebayasi 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)((((x) <<  8) & 0x000fff00) | \
     93                                  (((y) << 12) & 0xfff00000) | \
     94                                  (((y) <<  0) & 0x000000ff)))
     95 #define __attribute__(x)
     96 #endif	/* MAKE_BOOTSTRAP */
     97 
     98 #undef setprogname
     99 #undef getprogname
    100 extern 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		20141030
    111 #define CONFIG_MINVERSION	0
    112 
    113 /*
    114  * Name/value lists.  Values can be strings or pointers and/or can carry
    115  * integers.  The names can be NULL, resulting in simple value lists.
    116  */
    117 struct nvlist {
    118 	struct nvlist	*nv_next;
    119 	const char	*nv_name;
    120 	const char	*nv_str;
    121 	void		*nv_ptr;
    122 	long long	nv_num;
    123 	int		nv_ifunit;		/* XXX XXX XXX */
    124 	int		nv_flags;
    125 #define	NV_DEPENDED	1
    126 };
    127 
    128 /*
    129  * Kernel configurations.
    130  */
    131 struct config {
    132 	TAILQ_ENTRY(config) cf_next;
    133 	const char *cf_name;		/* "netbsd" */
    134 	int	cf_lineno;		/* source line */
    135 	const char *cf_fstype;		/* file system type */
    136 	struct	nvlist *cf_root;	/* "root on ra0a" */
    137 	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
    138 };
    139 
    140 /*
    141  * Option definition list
    142  */
    143 struct defoptlist {
    144 	struct defoptlist *dl_next;
    145 	const char *dl_name;
    146 	const char *dl_value;
    147 	const char *dl_lintvalue;
    148 	int dl_obsolete;
    149 	struct nvlist *dl_depends;
    150 };
    151 
    152 struct module {
    153 	const char		*m_name;
    154 #if 1
    155 	struct attrlist		*m_deps;
    156 #else
    157 	struct attrlist		*m_attrs;
    158 	struct modulelist	*m_deps;
    159 #endif
    160 	int			m_expanding;
    161 	TAILQ_HEAD(, files)	m_files;
    162 	int			m_weight;
    163 };
    164 
    165 /*
    166  * Attributes.  These come in three flavors: "plain", "device class,"
    167  * and "interface".  Plain attributes (e.g., "ether") simply serve
    168  * to pull in files.  Device class attributes are like plain
    169  * attributes, but additionally specify a device class (e.g., the
    170  * "disk" device class attribute specifies that devices with the
    171  * attribute belong to the "DV_DISK" class) and are mutually exclusive.
    172  * Interface attributes (e.g., "scsi") carry three lists: locators,
    173  * child devices, and references.  The locators are those things
    174  * that must be specified in order to configure a device instance
    175  * using this attribute (e.g., "tg0 at scsi0").  The a_devs field
    176  * lists child devices that can connect here (e.g., "tg"s), while
    177  * the a_refs are parents that carry the attribute (e.g., actual
    178  * SCSI host adapter drivers such as the SPARC "esp").
    179  */
    180 struct attr {
    181 	/* XXX */
    182 	struct module a_m;
    183 #define	a_name		a_m.m_name
    184 #define	a_deps		a_m.m_deps
    185 #define	a_expanding	a_m.m_expanding
    186 #define	a_files		a_m.m_files
    187 #define	a_weight	a_m.m_weight
    188 
    189 	/* "interface attribute" */
    190 	int	a_iattr;		/* true => allows children */
    191 	struct	loclist *a_locs;	/* locators required */
    192 	int	a_loclen;		/* length of above list */
    193 	struct	nvlist *a_devs;		/* children */
    194 	struct	nvlist *a_refs;		/* parents */
    195 
    196 	/* "device class" */
    197 	const char *a_devclass;		/* device class described */
    198 };
    199 
    200 /*
    201  * List of attributes.
    202  */
    203 struct attrlist {
    204 	struct attrlist *al_next;
    205 	struct attr *al_this;
    206 };
    207 
    208 /*
    209  * List of locators. (Either definitions or uses...)
    210  *
    211  * XXX it would be nice if someone could clarify wtf ll_string and ll_num
    212  * are actually holding. (This stuff was previously stored in a very ad
    213  * hoc fashion, and the code is far from clear.)
    214  */
    215 struct loclist {
    216 	const char *ll_name;
    217 	const char *ll_string;
    218 	long long ll_num;
    219 	struct loclist *ll_next;
    220 };
    221 
    222 /*
    223  * Parent specification.  Multiple device instances may share a
    224  * given parent spec.  Parent specs are emitted only if there are
    225  * device instances which actually reference it.
    226  */
    227 struct pspec {
    228 	TAILQ_ENTRY(pspec) p_list;	/* link on parent spec list */
    229 	struct	attr *p_iattr;		/* interface attribute of parent */
    230 	struct	devbase *p_atdev;	/* optional parent device base */
    231 	int	p_atunit;		/* optional parent device unit */
    232 	struct	nvlist *p_devs;		/* children using it */
    233 	int	p_inst;			/* parent spec instance */
    234 	int	p_active;		/* parent spec is actively used */
    235 };
    236 
    237 /*
    238  * The "base" part (struct devbase) of a device ("uba", "sd"; but not
    239  * "uba2" or "sd0").  It may be found "at" one or more attributes,
    240  * including "at root" (this is represented by a NULL attribute), as
    241  * specified by the device attachments (struct deva).
    242  *
    243  * Each device may also export attributes.  If any provide an output
    244  * interface (e.g., "esp" provides "scsi"), other devices (e.g.,
    245  * "tg"s) can be found at instances of this one (e.g., "esp"s).
    246  * Such a connection must provide locators as specified by that
    247  * interface attribute (e.g., "target").  The base device can
    248  * export both output (aka `interface') attributes, as well as
    249  * import input (`plain') attributes.  Device attachments may
    250  * only import input attributes; it makes no sense to have a
    251  * specific attachment export a new interface to other devices.
    252  *
    253  * Each base carries a list of instances (via d_ihead).  Note that this
    254  * list "skips over" aliases; those must be found through the instances
    255  * themselves.  Each base also carries a list of possible attachments,
    256  * each of which specify a set of devices that the device can attach
    257  * to, as well as the device instances that are actually using that
    258  * attachment.
    259  */
    260 struct devbase {
    261 	const char *d_name;		/* e.g., "sd" */
    262 	TAILQ_ENTRY(devbase) d_next;
    263 	int	d_isdef;		/* set once properly defined */
    264 	int	d_ispseudo;		/* is a pseudo-device */
    265 	devmajor_t d_major;		/* used for "root on sd0", e.g. */
    266 	struct	attrlist *d_attrs;	/* attributes, if any */
    267 	int	d_umax;			/* highest unit number + 1 */
    268 	struct	devi *d_ihead;		/* first instance, if any */
    269 	struct	devi **d_ipp;		/* used for tacking on more instances */
    270 	struct	deva *d_ahead;		/* first attachment, if any */
    271 	struct	deva **d_app;		/* used for tacking on attachments */
    272 	struct	attr *d_classattr;	/* device class attribute (if any) */
    273 };
    274 
    275 struct deva {
    276 	const char *d_name;		/* name of attachment, e.g. "com_isa" */
    277 	TAILQ_ENTRY(deva) d_next;	/* list of all instances */
    278 	struct	deva *d_bsame;		/* list on same base */
    279 	int	d_isdef;		/* set once properly defined */
    280 	struct	devbase *d_devbase;	/* the base device */
    281 	struct	nvlist *d_atlist;	/* e.g., "at tg" (attr list) */
    282 	struct	attrlist *d_attrs;	/* attributes, if any */
    283 	struct	devi *d_ihead;		/* first instance, if any */
    284 	struct	devi **d_ipp;		/* used for tacking on more instances */
    285 };
    286 
    287 /*
    288  * An "instance" of a device.  The same instance may be listed more
    289  * than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
    290  *
    291  * After everything has been read in and verified, the devi's are
    292  * "packed" to collect all the information needed to generate ioconf.c.
    293  * In particular, we try to collapse multiple aliases into a single entry.
    294  * We then assign each "primary" (non-collapsed) instance a cfdata index.
    295  * Note that there may still be aliases among these.
    296  */
    297 struct devi {
    298 	/* created while parsing config file */
    299 	const char *i_name;	/* e.g., "sd0" */
    300 	int	i_unit;		/* unit from name, e.g., 0 */
    301 	struct	devbase *i_base;/* e.g., pointer to "sd" base */
    302 	TAILQ_ENTRY(devi) i_next; /* list of all instances */
    303 	struct	devi *i_bsame;	/* list on same base */
    304 	struct	devi *i_asame;	/* list on same base attachment */
    305 	struct	devi *i_alias;	/* other aliases of this instance */
    306 	const char *i_at;	/* where this is "at" (NULL if at root) */
    307 	struct	pspec *i_pspec;	/* parent spec (NULL if at root) */
    308 	struct	deva *i_atdeva;
    309 	const char **i_locs;	/* locators (as given by pspec's iattr) */
    310 	int	i_cfflags;	/* flags from config line */
    311 	int	i_lineno;	/* line # in config, for later errors */
    312 	const char *i_srcfile;	/* file it appears in */
    313 	int	i_level;	/* position between negated instances */
    314 	int	i_active;
    315 #define	DEVI_ORPHAN	0	/* instance has no active parent */
    316 #define	DEVI_ACTIVE	1	/* instance has an active parent */
    317 #define	DEVI_IGNORED	2	/* instance's parent has been removed */
    318 #define DEVI_BROKEN	3	/* instance is broken (syntax error) */
    319 	int	i_pseudoroot;	/* instance is pseudoroot */
    320 
    321 	/* created during packing or ioconf.c generation */
    322 	short	i_collapsed;	/* set => this alias no longer needed */
    323 	u_short	i_cfindex;	/* our index in cfdata */
    324 	int	i_locoff;	/* offset in locators.vec */
    325 
    326 };
    327 /* special units */
    328 #define	STAR	(-1)		/* unit number for, e.g., "sd*" */
    329 #define	WILD	(-2)		/* unit number for, e.g., "sd?" */
    330 
    331 /*
    332  * Files or objects.  This structure defines the common fields
    333  * between the two.
    334  */
    335 struct filetype
    336 {
    337 	const char *fit_srcfile;	/* the name of the "files" file that got us */
    338 	u_short	fit_srcline;	/* and the line number */
    339 	u_char	fit_flags;	/* as below */
    340 	char	fit_lastc;	/* last char from path */
    341 	const char *fit_path;	/* full file path */
    342 	const char *fit_prefix;	/* any file prefix */
    343 	size_t fit_len;		/* path string length */
    344 	int fit_suffix;		/* single char suffix */
    345 	struct attr *fit_attr;	/* owner attr */
    346 	TAILQ_ENTRY(files) fit_anext;	/* next file in attr */
    347 };
    348 /* Anything less than 0x10 is sub-type specific */
    349 
    350 /*
    351  * Files.  Each file is either standard (always included) or optional,
    352  * depending on whether it has names on which to *be* optional.  The
    353  * options field (fi_optx) is an expression tree of type struct
    354  * condexpr, with nodes for OR, AND, and NOT, as well as atoms (words)
    355  * representing some particular option.
    356  *
    357  * For any file marked as needs-count or needs-flag, fixfiles() will
    358  * build fi_optf, a `flat list' of the options with nv_num fields that
    359  * contain counts or `need' flags; this is used in mkheaders().
    360  */
    361 struct files {
    362 	struct filetype fi_fit;
    363 	TAILQ_ENTRY(files) fi_next;
    364 	const  char *fi_tail;	/* name, i.e., strrchr(fi_path, '/') + 1 */
    365 	const  char *fi_base;	/* tail minus ".c" (or whatever) */
    366 	struct condexpr *fi_optx; /* options expression */
    367 	struct nvlist *fi_optf; /* flattened version of above, if needed */
    368 	const  char *fi_mkrule;	/* special make rule, if any */
    369 };
    370 #define fi_srcfile fi_fit.fit_srcfile
    371 #define fi_srcline fi_fit.fit_srcline
    372 #define fi_flags   fi_fit.fit_flags
    373 #define fi_lastc   fi_fit.fit_lastc
    374 #define fi_path    fi_fit.fit_path
    375 #define fi_prefix  fi_fit.fit_prefix
    376 #define fi_suffix  fi_fit.fit_suffix
    377 #define fi_len     fi_fit.fit_len
    378 #define fi_attr    fi_fit.fit_attr
    379 #define fi_anext   fi_fit.fit_anext
    380 
    381 /* flags */
    382 #define	FI_SEL		0x01	/* selected */
    383 #define	FI_NEEDSCOUNT	0x02	/* needs-count */
    384 #define	FI_NEEDSFLAG	0x04	/* needs-flag */
    385 #define	FI_HIDDEN	0x08	/* obscured by other(s), base names overlap */
    386 
    387 /*
    388  * Objects and libraries.  This allows precompiled object and library
    389  * files (e.g. binary-only device drivers) to be linked in.
    390  */
    391 struct objects {
    392 	struct  filetype oi_fit;
    393 	TAILQ_ENTRY(objects) oi_next;
    394 	struct condexpr *oi_optx;	/* condition expression */
    395 	struct  nvlist *oi_optf;/* flattened version of above, if needed */
    396 };
    397 
    398 #define oi_srcfile oi_fit.fit_srcfile
    399 #define oi_srcline oi_fit.fit_srcline
    400 #define oi_flags   oi_fit.fit_flags
    401 #define oi_lastc   oi_fit.fit_lastc
    402 #define oi_path    oi_fit.fit_path
    403 #define oi_prefix  oi_fit.fit_prefix
    404 
    405 /* flags */
    406 #define	OI_SEL		0x01	/* selected */
    407 #define	OI_NEEDSFLAG	0x02	/* needs-flag */
    408 
    409 /*
    410  * Condition expressions.
    411  */
    412 
    413 enum condexpr_types {
    414 	CX_ATOM,
    415 	CX_NOT,
    416 	CX_AND,
    417 	CX_OR,
    418 };
    419 struct condexpr {
    420 	enum condexpr_types cx_type;
    421 	union {
    422 		const char *atom;
    423 		struct condexpr *not;
    424 		struct {
    425 			struct condexpr *left;
    426 			struct condexpr *right;
    427 		} and, or;
    428 	} cx_u;
    429 };
    430 #define cx_atom	cx_u.atom
    431 #define cx_not	cx_u.not
    432 #define cx_and	cx_u.and
    433 #define cx_or	cx_u.or
    434 
    435 /*
    436  * File/object prefixes.  These are arranged in a stack, and affect
    437  * the behavior of the source path.
    438  */
    439 struct prefix {
    440 	SLIST_ENTRY(prefix)	pf_next;	/* next prefix in stack */
    441 	const char		*pf_prefix;	/* the actual prefix */
    442 };
    443 
    444 /*
    445  * Device major informations.
    446  */
    447 struct devm {
    448 	TAILQ_ENTRY(devm) dm_next;
    449 	const char	*dm_srcfile;	/* the name of the "majors" file */
    450 	u_short		dm_srcline;	/* the line number */
    451 	const char	*dm_name;	/* [bc]devsw name */
    452 	devmajor_t	dm_cmajor;	/* character major */
    453 	devmajor_t	dm_bmajor;	/* block major */
    454 	struct condexpr	*dm_opts;	/* options */
    455 	struct nvlist	*dm_devnodes;	/* information on /dev nodes */
    456 };
    457 
    458 /*
    459  * Hash tables look up name=value pairs.  The pointer value of the name
    460  * is assumed to be constant forever; this can be arranged by interning
    461  * the name.  (This is fairly convenient since our lexer does this for
    462  * all identifier-like strings---it has to save them anyway, lest yacc's
    463  * look-ahead wipe out the current one.)
    464  */
    465 struct hashtab;
    466 
    467 int lkmmode;
    468 const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
    469 const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
    470 const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
    471 struct	nvlist *machinesubarches;
    472 				/* machine subarches, e.g., "sun68k" or "hpc" */
    473 const char *ioconfname;		/* ioconf name, mutually exclusive to machine */
    474 const char *srcdir;		/* path to source directory (rel. to build) */
    475 const char *builddir;		/* path to build directory */
    476 const char *defbuilddir;	/* default build directory */
    477 const char *ident;		/* kernel "ident"ification string */
    478 int	errors;			/* counts calls to error() */
    479 int	minmaxusers;		/* minimum "maxusers" parameter */
    480 int	defmaxusers;		/* default "maxusers" parameter */
    481 int	maxmaxusers;		/* default "maxusers" parameter */
    482 int	maxusers;		/* configuration's "maxusers" parameter */
    483 int	maxpartitions;		/* configuration's "maxpartitions" parameter */
    484 int	version;		/* version of the configuration file */
    485 struct	nvlist *options;	/* options */
    486 struct	nvlist *fsoptions;	/* filesystems */
    487 struct	nvlist *mkoptions;	/* makeoptions */
    488 struct	nvlist *appmkoptions;	/* appending mkoptions */
    489 struct	nvlist *condmkoptions;	/* conditional makeoption table */
    490 struct	hashtab *devbasetab;	/* devbase lookup */
    491 struct	hashtab *devroottab;	/* attach at root lookup */
    492 struct	hashtab *devatab;	/* devbase attachment lookup */
    493 struct	hashtab *devitab;	/* device instance lookup */
    494 struct	hashtab *deaddevitab;	/* removed instances lookup */
    495 struct	hashtab *selecttab;	/* selects things that are "optional foo" */
    496 struct	hashtab *needcnttab;	/* retains names marked "needs-count" */
    497 struct	hashtab *opttab;	/* table of configured options */
    498 struct	hashtab *fsopttab;	/* table of configured file systems */
    499 struct	dlhash *defopttab;	/* options that have been "defopt"'d */
    500 struct	dlhash *defflagtab;	/* options that have been "defflag"'d */
    501 struct	dlhash *defparamtab;	/* options that have been "defparam"'d */
    502 struct	dlhash *defoptlint;	/* lint values for options */
    503 struct	nvhash *deffstab;	/* defined file systems */
    504 struct	dlhash *optfiletab;	/* "defopt"'d option .h files */
    505 struct	hashtab *attrtab;	/* attributes (locators, etc.) */
    506 struct	hashtab *attrdeptab;	/* attribute dependencies */
    507 struct	hashtab *bdevmtab;	/* block devm lookup */
    508 struct	hashtab *cdevmtab;	/* character devm lookup */
    509 
    510 TAILQ_HEAD(, devbase)	allbases;	/* list of all devbase structures */
    511 TAILQ_HEAD(, deva)	alldevas;	/* list of all devbase attachments */
    512 TAILQ_HEAD(conftq, config) allcf;	/* list of configured kernels */
    513 TAILQ_HEAD(, devi)	alldevi,	/* list of all instances */
    514 			allpseudo;	/* list of all pseudo-devices */
    515 TAILQ_HEAD(, devm)	alldevms;	/* list of all device-majors */
    516 TAILQ_HEAD(, pspec)	allpspecs;	/* list of all parent specs */
    517 int	ndevi;				/* number of devi's (before packing) */
    518 int	npspecs;			/* number of parent specs */
    519 devmajor_t maxbdevm;			/* max number of block major */
    520 devmajor_t maxcdevm;			/* max number of character major */
    521 int	do_devsw;			/* 0 if pre-devsw config */
    522 int	oktopackage;			/* 0 before setmachine() */
    523 int	devilevel;			/* used for devi->i_level */
    524 
    525 TAILQ_HEAD(, files)	allfiles;	/* list of all kernel source files */
    526 TAILQ_HEAD(, objects)	allobjects;	/* list of all kernel object and
    527 					   library files */
    528 
    529 SLIST_HEAD(, prefix)	prefixes,	/* prefix stack */
    530 			allprefixes;	/* all prefixes used (after popped) */
    531 SLIST_HEAD(, prefix)	curdirs;	/* curdir stack */
    532 
    533 extern struct attr allattr;
    534 struct	devi **packed;		/* arrayified table for packed devi's */
    535 size_t	npacked;		/* size of packed table, <= ndevi */
    536 
    537 struct {			/* loc[] table for config */
    538 	const char **vec;
    539 	int	used;
    540 } locators;
    541 
    542 struct numconst {
    543 	int64_t	val;
    544 	int fmt;
    545 };
    546 
    547 /* files.c */
    548 void	initfiles(void);
    549 void	checkfiles(void);
    550 int	fixfiles(void);		/* finalize */
    551 int	fixobjects(void);
    552 int	fixdevsw(void);
    553 void	addfile(const char *, struct condexpr *, u_char, const char *);
    554 void	addobject(const char *, struct condexpr *, u_char);
    555 int	expr_eval(struct condexpr *, int (*)(const char *, void *), void *);
    556 
    557 /* hash.c */
    558 struct	hashtab *ht_new(void);
    559 void	ht_free(struct hashtab *);
    560 int	ht_insrep2(struct hashtab *, const char *, const char *, void *, int);
    561 int	ht_insrep(struct hashtab *, const char *, void *, int);
    562 #define	ht_insert2(ht, nam1, nam2, val) ht_insrep2(ht, nam1, nam2, val, 0)
    563 #define	ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
    564 #define	ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
    565 int	ht_remove2(struct hashtab *, const char *, const char *);
    566 int	ht_remove(struct hashtab *, const char *);
    567 void	*ht_lookup2(struct hashtab *, const char *, const char *);
    568 void	*ht_lookup(struct hashtab *, const char *);
    569 void	initintern(void);
    570 const char *intern(const char *);
    571 typedef int (*ht_callback2)(const char *, const char *, void *, void *);
    572 typedef int (*ht_callback)(const char *, void *, void *);
    573 int	ht_enumerate2(struct hashtab *, ht_callback2, void *);
    574 int	ht_enumerate(struct hashtab *, ht_callback, void *);
    575 
    576 /* typed hash, named struct HT, whose type is string -> struct VT */
    577 #define DECLHASH(HT, VT) \
    578 	struct HT;							\
    579 	struct HT *HT##_create(void);					\
    580 	int HT##_insert(struct HT *, const char *, struct VT *);	\
    581 	int HT##_replace(struct HT *, const char *, struct VT *);	\
    582 	int HT##_remove(struct HT *, const char *);			\
    583 	struct VT *HT##_lookup(struct HT *, const char *);		\
    584 	int HT##_enumerate(struct HT *,					\
    585 			int (*)(const char *, struct VT *, void *),	\
    586 			void *)
    587 DECLHASH(nvhash, nvlist);
    588 DECLHASH(dlhash, defoptlist);
    589 
    590 /* lint.c */
    591 void	emit_instances(void);
    592 void	emit_options(void);
    593 void	emit_params(void);
    594 
    595 /* main.c */
    596 extern	int Mflag;
    597 void	addoption(const char *, const char *);
    598 void	addfsoption(const char *);
    599 void	addmkoption(const char *, const char *);
    600 void	appendmkoption(const char *, const char *);
    601 void	appendcondmkoption(struct condexpr *, const char *, const char *);
    602 void	deffilesystem(struct nvlist *, struct nvlist *);
    603 void	defoption(const char *, struct defoptlist *, struct nvlist *);
    604 void	defflag(const char *, struct defoptlist *, struct nvlist *, int);
    605 void	defparam(const char *, struct defoptlist *, struct nvlist *, int);
    606 void	deloption(const char *);
    607 void	delfsoption(const char *);
    608 void	delmkoption(const char *);
    609 int	devbase_has_instances(struct devbase *, int);
    610 int	is_declared_option(const char *);
    611 int	deva_has_instances(struct deva *, int);
    612 void	setupdirs(void);
    613 const char *strtolower(const char *);
    614 
    615 /* tests on option types */
    616 #define OPT_FSOPT(n)	(nvhash_lookup(deffstab, (n)) != NULL)
    617 #define OPT_DEFOPT(n)	(dlhash_lookup(defopttab, (n)) != NULL)
    618 #define OPT_DEFFLAG(n)	(dlhash_lookup(defflagtab, (n)) != NULL)
    619 #define OPT_DEFPARAM(n)	(dlhash_lookup(defparamtab, (n)) != NULL)
    620 #define OPT_OBSOLETE(n)	(dlhash_lookup(obsopttab, (n)) != NULL)
    621 #define DEFINED_OPTION(n) (is_declared_option((n)))
    622 
    623 /* main.c */
    624 void	logconfig_include(FILE *, const char *);
    625 
    626 /* mkdevsw.c */
    627 int	mkdevsw(void);
    628 
    629 /* mkheaders.c */
    630 int	mkheaders(void);
    631 int	moveifchanged(const char *, const char *);
    632 int	emitlocs(void);
    633 int	emitioconfh(void);
    634 
    635 /* mkioconf.c */
    636 int	mkioconf(void);
    637 
    638 /* mkmakefile.c */
    639 int	mkmakefile(void);
    640 
    641 /* mkswap.c */
    642 int	mkswap(void);
    643 
    644 /* pack.c */
    645 void	pack(void);
    646 
    647 /* scan.l */
    648 u_short	currentline(void);
    649 int	firstfile(const char *);
    650 void	package(const char *);
    651 int	include(const char *, int, int, int);
    652 
    653 /* sem.c, other than for yacc actions */
    654 void	initsem(void);
    655 int	onlist(struct nvlist *, void *);
    656 
    657 /* util.c */
    658 void	prefix_push(const char *);
    659 void	prefix_pop(void);
    660 char	*sourcepath(const char *);
    661 extern	int dflag;
    662 #define	CFGDBG(n, ...) \
    663 	do { if ((dflag) >= (n)) cfgdbg(__VA_ARGS__); } while (0)
    664 void	cfgdbg(const char *, ...)			/* debug info */
    665      __printflike(1, 2);
    666 void	cfgwarn(const char *, ...)			/* immediate warns */
    667      __printflike(1, 2);
    668 void	cfgxwarn(const char *, int, const char *, ...)	/* delayed warns */
    669      __printflike(3, 4);
    670 void	cfgerror(const char *, ...)			/* immediate errs */
    671      __printflike(1, 2);
    672 void	cfgxerror(const char *, int, const char *, ...)	/* delayed errs */
    673      __printflike(3, 4);
    674 __dead void panic(const char *, ...)
    675      __printflike(1, 2);
    676 struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *);
    677 void	nvfree(struct nvlist *);
    678 void	nvfreel(struct nvlist *);
    679 struct nvlist *nvcat(struct nvlist *, struct nvlist *);
    680 void	autogen_comment(FILE *, const char *);
    681 struct defoptlist *defoptlist_create(const char *, const char *, const char *);
    682 void defoptlist_destroy(struct defoptlist *);
    683 struct defoptlist *defoptlist_append(struct defoptlist *, struct defoptlist *);
    684 struct attrlist *attrlist_create(void);
    685 struct attrlist *attrlist_cons(struct attrlist *, struct attr *);
    686 void attrlist_destroy(struct attrlist *);
    687 void attrlist_destroyall(struct attrlist *);
    688 struct loclist *loclist_create(const char *, const char *, long long);
    689 void loclist_destroy(struct loclist *);
    690 struct condexpr *condexpr_create(enum condexpr_types);
    691 void condexpr_destroy(struct condexpr *);
    692 
    693 /* liby */
    694 void	yyerror(const char *);
    695 int	yylex(void);
    696