Home | History | Annotate | Line # | Download | only in config
defs.h revision 1.36
      1 /*	$NetBSD: defs.h,v 1.36 2012/03/10 21:53:38 dholland 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		20100430
    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 #define	NV_OBSOLETE	2
    127 };
    128 
    129 /*
    130  * Kernel configurations.
    131  */
    132 struct config {
    133 	TAILQ_ENTRY(config) cf_next;
    134 	const char *cf_name;		/* "netbsd" */
    135 	int	cf_lineno;		/* source line */
    136 	const char *cf_fstype;		/* file system type */
    137 	struct	nvlist *cf_root;	/* "root on ra0a" */
    138 	struct	nvlist *cf_swap;	/* "swap on ra0b and ra1b" */
    139 	struct	nvlist *cf_dump;	/* "dumps on ra0b" */
    140 };
    141 
    142 /*
    143  * Attributes.  These come in three flavors: "plain", "device class,"
    144  * and "interface".  Plain attributes (e.g., "ether") simply serve
    145  * to pull in files.  Device class attributes are like plain
    146  * attributes, but additionally specify a device class (e.g., the
    147  * "disk" device class attribute specifies that devices with the
    148  * attribute belong to the "DV_DISK" class) and are mutually exclusive.
    149  * Interface attributes (e.g., "scsi") carry three lists: locators,
    150  * child devices, and references.  The locators are those things
    151  * that must be specified in order to configure a device instance
    152  * using this attribute (e.g., "tg0 at scsi0").  The a_devs field
    153  * lists child devices that can connect here (e.g., "tg"s), while
    154  * the a_refs are parents that carry the attribute (e.g., actual
    155  * SCSI host adapter drivers such as the SPARC "esp").
    156  */
    157 struct attr {
    158 	const char *a_name;		/* name of this attribute */
    159 	int	a_iattr;		/* true => allows children */
    160 	const char *a_devclass;		/* device class described */
    161 	struct	nvlist *a_locs;		/* locators required */
    162 	int	a_loclen;		/* length of above list */
    163 	struct	nvlist *a_devs;		/* children */
    164 	struct	nvlist *a_refs;		/* parents */
    165 	struct	nvlist *a_deps;		/* we depend on these other attrs */
    166 	int	a_expanding;		/* to detect cycles in attr graph */
    167 };
    168 
    169 /*
    170  * Parent specification.  Multiple device instances may share a
    171  * given parent spec.  Parent specs are emitted only if there are
    172  * device instances which actually reference it.
    173  */
    174 struct pspec {
    175 	TAILQ_ENTRY(pspec) p_list;	/* link on parent spec list */
    176 	struct	attr *p_iattr;		/* interface attribute of parent */
    177 	struct	devbase *p_atdev;	/* optional parent device base */
    178 	int	p_atunit;		/* optional parent device unit */
    179 	struct	nvlist *p_devs;		/* children using it */
    180 	int	p_inst;			/* parent spec instance */
    181 	int	p_active;		/* parent spec is actively used */
    182 };
    183 
    184 /*
    185  * The "base" part (struct devbase) of a device ("uba", "sd"; but not
    186  * "uba2" or "sd0").  It may be found "at" one or more attributes,
    187  * including "at root" (this is represented by a NULL attribute), as
    188  * specified by the device attachments (struct deva).
    189  *
    190  * Each device may also export attributes.  If any provide an output
    191  * interface (e.g., "esp" provides "scsi"), other devices (e.g.,
    192  * "tg"s) can be found at instances of this one (e.g., "esp"s).
    193  * Such a connection must provide locators as specified by that
    194  * interface attribute (e.g., "target").  The base device can
    195  * export both output (aka `interface') attributes, as well as
    196  * import input (`plain') attributes.  Device attachments may
    197  * only import input attributes; it makes no sense to have a
    198  * specific attachment export a new interface to other devices.
    199  *
    200  * Each base carries a list of instances (via d_ihead).  Note that this
    201  * list "skips over" aliases; those must be found through the instances
    202  * themselves.  Each base also carries a list of possible attachments,
    203  * each of which specify a set of devices that the device can attach
    204  * to, as well as the device instances that are actually using that
    205  * attachment.
    206  */
    207 struct devbase {
    208 	const char *d_name;		/* e.g., "sd" */
    209 	TAILQ_ENTRY(devbase) d_next;
    210 	int	d_isdef;		/* set once properly defined */
    211 	int	d_ispseudo;		/* is a pseudo-device */
    212 	devmajor_t d_major;		/* used for "root on sd0", e.g. */
    213 	struct	nvlist *d_attrs;	/* attributes, if any */
    214 	int	d_umax;			/* highest unit number + 1 */
    215 	struct	devi *d_ihead;		/* first instance, if any */
    216 	struct	devi **d_ipp;		/* used for tacking on more instances */
    217 	struct	deva *d_ahead;		/* first attachment, if any */
    218 	struct	deva **d_app;		/* used for tacking on attachments */
    219 	struct	attr *d_classattr;	/* device class attribute (if any) */
    220 };
    221 
    222 struct deva {
    223 	const char *d_name;		/* name of attachment, e.g. "com_isa" */
    224 	TAILQ_ENTRY(deva) d_next;	/* list of all instances */
    225 	struct	deva *d_bsame;		/* list on same base */
    226 	int	d_isdef;		/* set once properly defined */
    227 	struct	devbase *d_devbase;	/* the base device */
    228 	struct	nvlist *d_atlist;	/* e.g., "at tg" (attr list) */
    229 	struct	nvlist *d_attrs;	/* attributes, if any */
    230 	struct	devi *d_ihead;		/* first instance, if any */
    231 	struct	devi **d_ipp;		/* used for tacking on more instances */
    232 };
    233 
    234 /*
    235  * An "instance" of a device.  The same instance may be listed more
    236  * than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
    237  *
    238  * After everything has been read in and verified, the devi's are
    239  * "packed" to collect all the information needed to generate ioconf.c.
    240  * In particular, we try to collapse multiple aliases into a single entry.
    241  * We then assign each "primary" (non-collapsed) instance a cfdata index.
    242  * Note that there may still be aliases among these.
    243  */
    244 struct devi {
    245 	/* created while parsing config file */
    246 	const char *i_name;	/* e.g., "sd0" */
    247 	int	i_unit;		/* unit from name, e.g., 0 */
    248 	struct	devbase *i_base;/* e.g., pointer to "sd" base */
    249 	TAILQ_ENTRY(devi) i_next; /* list of all instances */
    250 	struct	devi *i_bsame;	/* list on same base */
    251 	struct	devi *i_asame;	/* list on same base attachment */
    252 	struct	devi *i_alias;	/* other aliases of this instance */
    253 	const char *i_at;	/* where this is "at" (NULL if at root) */
    254 	struct	pspec *i_pspec;	/* parent spec (NULL if at root) */
    255 	struct	deva *i_atdeva;
    256 	const char **i_locs;	/* locators (as given by pspec's iattr) */
    257 	int	i_cfflags;	/* flags from config line */
    258 	int	i_lineno;	/* line # in config, for later errors */
    259 	const char *i_srcfile;	/* file it appears in */
    260 	int	i_level;	/* position between negated instances */
    261 	int	i_active;
    262 #define	DEVI_ORPHAN	0	/* instance has no active parent */
    263 #define	DEVI_ACTIVE	1	/* instance has an active parent */
    264 #define	DEVI_IGNORED	2	/* instance's parent has been removed */
    265 #define DEVI_BROKEN	3	/* instance is broken (syntax error) */
    266 	int	i_pseudoroot;	/* instance is pseudoroot */
    267 
    268 	/* created during packing or ioconf.c generation */
    269 	short	i_collapsed;	/* set => this alias no longer needed */
    270 	short	i_cfindex;	/* our index in cfdata */
    271 	short	i_locoff;	/* offset in locators.vec */
    272 
    273 };
    274 /* special units */
    275 #define	STAR	(-1)		/* unit number for, e.g., "sd*" */
    276 #define	WILD	(-2)		/* unit number for, e.g., "sd?" */
    277 
    278 /*
    279  * Files or objects.  This structure defines the common fields
    280  * between the two.
    281  */
    282 struct filetype
    283 {
    284 	const char *fit_srcfile;	/* the name of the "files" file that got us */
    285 	u_short	fit_srcline;	/* and the line number */
    286 	u_char	fit_flags;	/* as below */
    287 	char	fit_lastc;	/* last char from path */
    288 	const char *fit_path;	/* full file path */
    289 	const char *fit_prefix;	/* any file prefix */
    290 };
    291 /* Anything less than 0x10 is sub-type specific */
    292 #define FIT_NOPROLOGUE  0x10    /* Don't prepend $S/ */
    293 #define FIT_FORCESELECT 0x20    /* Always include this file */
    294 
    295 /*
    296  * Files.  Each file is either standard (always included) or optional,
    297  * depending on whether it has names on which to *be* optional.  The
    298  * options field (fi_optx) is actually an expression tree, with nodes
    299  * for OR, AND, and NOT, as well as atoms (words) representing some
    300  * particular option.  The node type is stored in the nv_num field.
    301  * Subexpressions appear in the `next' field; for the binary operators
    302  * AND and OR, the left subexpression is first stored in the nv_ptr field.
    303  *
    304  * For any file marked as needs-count or needs-flag, fixfiles() will
    305  * build fi_optf, a `flat list' of the options with nv_num fields that
    306  * contain counts or `need' flags; this is used in mkheaders().
    307  */
    308 struct files {
    309 	struct filetype fi_fit;
    310 	TAILQ_ENTRY(files) fi_next;
    311 	const  char *fi_tail;	/* name, i.e., strrchr(fi_path, '/') + 1 */
    312 	const  char *fi_base;	/* tail minus ".c" (or whatever) */
    313 	struct nvlist *fi_optx; /* options expression */
    314 	struct nvlist *fi_optf; /* flattened version of above, if needed */
    315 	const  char *fi_mkrule;	/* special make rule, if any */
    316 };
    317 #define fi_srcfile fi_fit.fit_srcfile
    318 #define fi_srcline fi_fit.fit_srcline
    319 #define fi_flags   fi_fit.fit_flags
    320 #define fi_lastc   fi_fit.fit_lastc
    321 #define fi_path    fi_fit.fit_path
    322 #define fi_prefix  fi_fit.fit_prefix
    323 
    324 /* flags */
    325 #define	FI_SEL		0x01	/* selected */
    326 #define	FI_NEEDSCOUNT	0x02	/* needs-count */
    327 #define	FI_NEEDSFLAG	0x04	/* needs-flag */
    328 #define	FI_HIDDEN	0x08	/* obscured by other(s), base names overlap */
    329 
    330 /*
    331  * Objects and libraries.  This allows precompiled object and library
    332  * files (e.g. binary-only device drivers) to be linked in.
    333  */
    334 struct objects {
    335 	struct  filetype oi_fit;
    336 	TAILQ_ENTRY(objects) oi_next;
    337 	struct  nvlist *oi_optx;/* options expression */
    338 	struct  nvlist *oi_optf;/* flattened version of above, if needed */
    339 };
    340 
    341 #define oi_srcfile oi_fit.fit_srcfile
    342 #define oi_srcline oi_fit.fit_srcline
    343 #define oi_flags   oi_fit.fit_flags
    344 #define oi_lastc   oi_fit.fit_lastc
    345 #define oi_path    oi_fit.fit_path
    346 #define oi_prefix  oi_fit.fit_prefix
    347 
    348 /* flags */
    349 #define	OI_SEL		0x01	/* selected */
    350 #define	OI_NEEDSFLAG	0x02	/* needs-flag */
    351 
    352 #define	FX_ATOM		0	/* atom (in nv_name) */
    353 #define	FX_NOT		1	/* NOT expr (subexpression in nv_next) */
    354 #define	FX_AND		2	/* AND expr (lhs in nv_ptr, rhs in nv_next) */
    355 #define	FX_OR		3	/* OR expr (lhs in nv_ptr, rhs in nv_next) */
    356 
    357 /*
    358  * File/object prefixes.  These are arranged in a stack, and affect
    359  * the behavior of the source path.
    360  */
    361 struct prefix {
    362 	SLIST_ENTRY(prefix)	pf_next;	/* next prefix in stack */
    363 	const char		*pf_prefix;	/* the actual prefix */
    364 };
    365 
    366 /*
    367  * Device major informations.
    368  */
    369 struct devm {
    370 	TAILQ_ENTRY(devm) dm_next;
    371 	const char	*dm_srcfile;	/* the name of the "majors" file */
    372 	u_short		dm_srcline;	/* the line number */
    373 	const char	*dm_name;	/* [bc]devsw name */
    374 	devmajor_t	dm_cmajor;	/* character major */
    375 	devmajor_t	dm_bmajor;	/* block major */
    376 	struct nvlist	*dm_opts;	/* options */
    377 	struct nvlist	*dm_devnodes;	/* information on /dev nodes */
    378 };
    379 
    380 /*
    381  * Hash tables look up name=value pairs.  The pointer value of the name
    382  * is assumed to be constant forever; this can be arranged by interning
    383  * the name.  (This is fairly convenient since our lexer does this for
    384  * all identifier-like strings---it has to save them anyway, lest yacc's
    385  * look-ahead wipe out the current one.)
    386  */
    387 struct hashtab;
    388 
    389 int lkmmode;
    390 const char *conffile;		/* source file, e.g., "GENERIC.sparc" */
    391 const char *machine;		/* machine type, e.g., "sparc" or "sun3" */
    392 const char *machinearch;	/* machine arch, e.g., "sparc" or "m68k" */
    393 struct	nvlist *machinesubarches;
    394 				/* machine subarches, e.g., "sun68k" or "hpc" */
    395 const char *ioconfname;		/* ioconf name, mutually exclusive to machine */
    396 const char *srcdir;		/* path to source directory (rel. to build) */
    397 const char *builddir;		/* path to build directory */
    398 const char *defbuilddir;	/* default build directory */
    399 const char *ident;		/* kernel "ident"ification string */
    400 int	errors;			/* counts calls to error() */
    401 int	minmaxusers;		/* minimum "maxusers" parameter */
    402 int	defmaxusers;		/* default "maxusers" parameter */
    403 int	maxmaxusers;		/* default "maxusers" parameter */
    404 int	maxusers;		/* configuration's "maxusers" parameter */
    405 int	maxpartitions;		/* configuration's "maxpartitions" parameter */
    406 int	version;		/* version of the configuration file */
    407 struct	nvlist *options;	/* options */
    408 struct	nvlist *fsoptions;	/* filesystems */
    409 struct	nvlist *mkoptions;	/* makeoptions */
    410 struct	nvlist *appmkoptions;	/* appending mkoptions */
    411 struct	nvlist *condmkoptions;	/* conditional makeoption table */
    412 struct	hashtab *devbasetab;	/* devbase lookup */
    413 struct	hashtab *devroottab;	/* attach at root lookup */
    414 struct	hashtab *devatab;	/* devbase attachment lookup */
    415 struct	hashtab *devitab;	/* device instance lookup */
    416 struct	hashtab *deaddevitab;	/* removed instances lookup */
    417 struct	hashtab *selecttab;	/* selects things that are "optional foo" */
    418 struct	hashtab *needcnttab;	/* retains names marked "needs-count" */
    419 struct	hashtab *opttab;	/* table of configured options */
    420 struct	hashtab *fsopttab;	/* table of configured file systems */
    421 struct	hashtab *defopttab;	/* options that have been "defopt"'d */
    422 struct	hashtab *defflagtab;	/* options that have been "defflag"'d */
    423 struct	hashtab *defparamtab;	/* options that have been "defparam"'d */
    424 struct	hashtab *defoptlint;	/* lint values for options */
    425 struct	hashtab *deffstab;	/* defined file systems */
    426 struct	hashtab *optfiletab;	/* "defopt"'d option .h files */
    427 struct	hashtab *attrtab;	/* attributes (locators, etc.) */
    428 struct	hashtab *bdevmtab;	/* block devm lookup */
    429 struct	hashtab *cdevmtab;	/* character devm lookup */
    430 
    431 TAILQ_HEAD(, devbase)	allbases;	/* list of all devbase structures */
    432 TAILQ_HEAD(, deva)	alldevas;	/* list of all devbase attachments */
    433 TAILQ_HEAD(, config)	allcf;		/* list of configured kernels */
    434 TAILQ_HEAD(, devi)	alldevi,	/* list of all instances */
    435 			allpseudo;	/* list of all pseudo-devices */
    436 TAILQ_HEAD(, devm)	alldevms;	/* list of all device-majors */
    437 TAILQ_HEAD(, pspec)	allpspecs;	/* list of all parent specs */
    438 int	ndevi;				/* number of devi's (before packing) */
    439 int	npspecs;			/* number of parent specs */
    440 devmajor_t maxbdevm;			/* max number of block major */
    441 devmajor_t maxcdevm;			/* max number of character major */
    442 int	do_devsw;			/* 0 if pre-devsw config */
    443 int	oktopackage;			/* 0 before setmachine() */
    444 int	devilevel;			/* used for devi->i_level */
    445 
    446 TAILQ_HEAD(, files)	allfiles;	/* list of all kernel source files */
    447 TAILQ_HEAD(, objects)	allobjects;	/* list of all kernel object and
    448 					   library files */
    449 
    450 SLIST_HEAD(, prefix)	prefixes,	/* prefix stack */
    451 			allprefixes;	/* all prefixes used (after popped) */
    452 SLIST_HEAD(, prefix)	curdirs;	/* curdir stack */
    453 
    454 struct	devi **packed;		/* arrayified table for packed devi's */
    455 size_t	npacked;		/* size of packed table, <= ndevi */
    456 
    457 struct {			/* loc[] table for config */
    458 	const char **vec;
    459 	int	used;
    460 } locators;
    461 
    462 struct numconst {
    463 	int64_t	val;
    464 	int fmt;
    465 };
    466 
    467 /* files.c */
    468 void	initfiles(void);
    469 void	checkfiles(void);
    470 int	fixfiles(void);		/* finalize */
    471 int	fixobjects(void);
    472 int	fixdevsw(void);
    473 void	addfile(const char *, struct nvlist *, int, const char *);
    474 void	addobject(const char *, struct nvlist *, int);
    475 int	expr_eval(struct nvlist *, int (*)(const char *, void *), void *);
    476 void	expr_free(struct nvlist *);
    477 
    478 /* hash.c */
    479 struct	hashtab *ht_new(void);
    480 void	ht_free(struct hashtab *);
    481 int	ht_insrep(struct hashtab *, const char *, void *, int);
    482 #define	ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
    483 #define	ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
    484 int	ht_remove(struct hashtab *, const char *);
    485 void	*ht_lookup(struct hashtab *, const char *);
    486 void	initintern(void);
    487 const char *intern(const char *);
    488 typedef int (*ht_callback)(const char *, void *, void *);
    489 int	ht_enumerate(struct hashtab *, ht_callback, void *);
    490 
    491 /* lint.c */
    492 void	emit_instances(void);
    493 void	emit_options(void);
    494 void	emit_params(void);
    495 
    496 /* main.c */
    497 void	addoption(const char *, const char *);
    498 void	addfsoption(const char *);
    499 void	addmkoption(const char *, const char *);
    500 void	appendmkoption(const char *, const char *);
    501 void	appendcondmkoption(struct nvlist *, const char *, const char *);
    502 void	deffilesystem(struct nvlist *, struct nvlist *);
    503 void	defoption(const char *, struct nvlist *, struct nvlist *);
    504 void	defflag(const char *, struct nvlist *, struct nvlist *, int);
    505 void	defparam(const char *, struct nvlist *, struct nvlist *, int);
    506 void	deloption(const char *);
    507 void	delfsoption(const char *);
    508 void	delmkoption(const char *);
    509 int	devbase_has_instances(struct devbase *, int);
    510 struct nvlist * find_declared_option(const char *);
    511 int	deva_has_instances(struct deva *, int);
    512 void	setupdirs(void);
    513 const char *strtolower(const char *);
    514 
    515 /* tests on option types */
    516 #define OPT_FSOPT(n)	(ht_lookup(deffstab, (n)) != NULL)
    517 #define OPT_DEFOPT(n)	(ht_lookup(defopttab, (n)) != NULL)
    518 #define OPT_DEFFLAG(n)	(ht_lookup(defflagtab, (n)) != NULL)
    519 #define OPT_DEFPARAM(n)	(ht_lookup(defparamtab, (n)) != NULL)
    520 #define OPT_OBSOLETE(n)	(ht_lookup(obsopttab, (n)) != NULL)
    521 #define DEFINED_OPTION(n) (find_declared_option((n)) != NULL)
    522 
    523 /* main.c */
    524 void	logconfig_include(FILE *, const char *);
    525 
    526 /* mkdevsw.c */
    527 int	mkdevsw(void);
    528 
    529 /* mkheaders.c */
    530 int	mkheaders(void);
    531 int	moveifchanged(const char *, const char *);
    532 int	emitlocs(void);
    533 int	emitioconfh(void);
    534 
    535 /* mkioconf.c */
    536 int	mkioconf(void);
    537 
    538 /* mkmakefile.c */
    539 int	mkmakefile(void);
    540 
    541 /* mkswap.c */
    542 int	mkswap(void);
    543 
    544 /* pack.c */
    545 void	pack(void);
    546 
    547 /* scan.l */
    548 int	currentline(void);
    549 int	firstfile(const char *);
    550 void	package(const char *);
    551 int	include(const char *, int, int, int);
    552 
    553 /* sem.c, other than for yacc actions */
    554 void	initsem(void);
    555 int	onlist(struct nvlist *, void *);
    556 
    557 /* util.c */
    558 void	prefix_push(const char *);
    559 void	prefix_pop(void);
    560 char	*sourcepath(const char *);
    561 void	cfgwarn(const char *, ...)			/* immediate warns */
    562      __printflike(1, 2);
    563 void	cfgxwarn(const char *, int, const char *, ...)	/* delayed warns */
    564      __printflike(3, 4);
    565 void	cfgerror(const char *, ...)			/* immediate errs */
    566      __printflike(1, 2);
    567 void	cfgxerror(const char *, int, const char *, ...)	/* delayed errs */
    568      __printflike(3, 4);
    569 __dead void panic(const char *, ...)
    570      __printflike(1, 2);
    571 struct nvlist *newnv(const char *, const char *, void *, long long, struct nvlist *);
    572 void	nvfree(struct nvlist *);
    573 void	nvfreel(struct nvlist *);
    574 struct nvlist *nvcat(struct nvlist *, struct nvlist *);
    575 void	autogen_comment(FILE *, const char *);
    576 
    577 /* liby */
    578 void	yyerror(const char *);
    579 int	yylex(void);
    580