Home | History | Annotate | Line # | Download | only in config
gram.y revision 1.56
      1   1.1   thorpej %{
      2  1.56       uwe /*	$NetBSD: gram.y,v 1.56 2020/07/26 22:40:52 uwe Exp $	*/
      3   1.1   thorpej 
      4   1.1   thorpej /*
      5   1.1   thorpej  * Copyright (c) 1992, 1993
      6   1.1   thorpej  *	The Regents of the University of California.  All rights reserved.
      7   1.1   thorpej  *
      8   1.1   thorpej  * This software was developed by the Computer Systems Engineering group
      9   1.1   thorpej  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     10   1.1   thorpej  * contributed to Berkeley.
     11   1.1   thorpej  *
     12   1.1   thorpej  * All advertising materials mentioning features or use of this software
     13   1.1   thorpej  * must display the following acknowledgement:
     14   1.1   thorpej  *	This product includes software developed by the University of
     15   1.1   thorpej  *	California, Lawrence Berkeley Laboratories.
     16   1.1   thorpej  *
     17   1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     18   1.1   thorpej  * modification, are permitted provided that the following conditions
     19   1.1   thorpej  * are met:
     20   1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     21   1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     22   1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     23   1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     24   1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     25   1.1   thorpej  * 3. Neither the name of the University nor the names of its contributors
     26   1.1   thorpej  *    may be used to endorse or promote products derived from this software
     27   1.1   thorpej  *    without specific prior written permission.
     28   1.1   thorpej  *
     29   1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     30   1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     31   1.1   thorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     32   1.1   thorpej  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     33   1.1   thorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     34   1.1   thorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     35   1.1   thorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     36   1.1   thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     37   1.1   thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     38   1.1   thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     39   1.1   thorpej  * SUCH DAMAGE.
     40   1.1   thorpej  *
     41   1.1   thorpej  *	from: @(#)gram.y	8.1 (Berkeley) 6/6/93
     42   1.1   thorpej  */
     43   1.1   thorpej 
     44  1.44  christos #include <sys/cdefs.h>
     45  1.56       uwe __RCSID("$NetBSD: gram.y,v 1.56 2020/07/26 22:40:52 uwe Exp $");
     46  1.44  christos 
     47   1.1   thorpej #include <sys/types.h>
     48   1.1   thorpej #include <sys/param.h>
     49   1.1   thorpej #include <ctype.h>
     50   1.1   thorpej #include <stdio.h>
     51   1.1   thorpej #include <stdlib.h>
     52   1.1   thorpej #include <string.h>
     53   1.1   thorpej #include <errno.h>
     54   1.1   thorpej #include "defs.h"
     55   1.1   thorpej #include "sem.h"
     56   1.1   thorpej 
     57   1.1   thorpej #define	FORMAT(n) (((n).fmt == 8 && (n).val != 0) ? "0%llo" : \
     58   1.1   thorpej     ((n).fmt == 16) ? "0x%llx" : "%lld")
     59   1.1   thorpej 
     60  1.13  christos #define	stop(s)	cfgerror(s), exit(1)
     61   1.1   thorpej 
     62   1.1   thorpej static	struct	config conf;	/* at most one active at a time */
     63  1.54  christos static	int	nowarn;		/* if warning suppression is on */
     64   1.1   thorpej 
     65  1.31  dholland 
     66  1.31  dholland /*
     67  1.31  dholland  * Allocation wrapper functions
     68  1.31  dholland  */
     69  1.31  dholland static void wrap_alloc(void *ptr, unsigned code);
     70  1.31  dholland static void wrap_continue(void);
     71  1.31  dholland static void wrap_cleanup(void);
     72  1.31  dholland 
     73  1.31  dholland /*
     74  1.31  dholland  * Allocation wrapper type codes
     75  1.31  dholland  */
     76  1.31  dholland #define WRAP_CODE_nvlist	1
     77  1.37  dholland #define WRAP_CODE_defoptlist	2
     78  1.37  dholland #define WRAP_CODE_loclist	3
     79  1.37  dholland #define WRAP_CODE_attrlist	4
     80  1.37  dholland #define WRAP_CODE_condexpr	5
     81  1.31  dholland 
     82  1.31  dholland /*
     83  1.31  dholland  * The allocation wrappers themselves
     84  1.31  dholland  */
     85  1.31  dholland #define DECL_ALLOCWRAP(t)	static struct t *wrap_mk_##t(struct t *arg)
     86  1.31  dholland 
     87  1.31  dholland DECL_ALLOCWRAP(nvlist);
     88  1.37  dholland DECL_ALLOCWRAP(defoptlist);
     89  1.36  dholland DECL_ALLOCWRAP(loclist);
     90  1.32  dholland DECL_ALLOCWRAP(attrlist);
     91  1.34  dholland DECL_ALLOCWRAP(condexpr);
     92  1.34  dholland 
     93  1.34  dholland /* allow shorter names */
     94  1.36  dholland #define wrap_mk_loc(p) wrap_mk_loclist(p)
     95  1.34  dholland #define wrap_mk_cx(p) wrap_mk_condexpr(p)
     96  1.31  dholland 
     97  1.31  dholland /*
     98  1.31  dholland  * Macros for allocating new objects
     99  1.31  dholland  */
    100  1.31  dholland 
    101  1.32  dholland /* old-style for struct nvlist */
    102  1.31  dholland #define	new0(n,s,p,i,x)	wrap_mk_nvlist(newnv(n, s, p, i, x))
    103   1.1   thorpej #define	new_n(n)	new0(n, NULL, NULL, 0, NULL)
    104   1.1   thorpej #define	new_nx(n, x)	new0(n, NULL, NULL, 0, x)
    105   1.1   thorpej #define	new_ns(n, s)	new0(n, s, NULL, 0, NULL)
    106   1.1   thorpej #define	new_si(s, i)	new0(NULL, s, NULL, i, NULL)
    107  1.53   mlelstv #define	new_spi(s, p, i)	new0(NULL, s, p, i, NULL)
    108   1.1   thorpej #define	new_nsi(n,s,i)	new0(n, s, NULL, i, NULL)
    109   1.1   thorpej #define	new_np(n, p)	new0(n, NULL, p, 0, NULL)
    110   1.1   thorpej #define	new_s(s)	new0(NULL, s, NULL, 0, NULL)
    111   1.1   thorpej #define	new_p(p)	new0(NULL, NULL, p, 0, NULL)
    112   1.1   thorpej #define	new_px(p, x)	new0(NULL, NULL, p, 0, x)
    113   1.1   thorpej #define	new_sx(s, x)	new0(NULL, s, NULL, 0, x)
    114  1.11      cube #define	new_nsx(n,s,x)	new0(n, s, NULL, 0, x)
    115  1.24     pooka #define	new_i(i)	new0(NULL, NULL, NULL, i, NULL)
    116   1.1   thorpej 
    117  1.34  dholland /* new style, type-polymorphic; ordinary and for types with multiple flavors */
    118  1.32  dholland #define MK0(t)		wrap_mk_##t(mk_##t())
    119  1.32  dholland #define MK1(t, a0)	wrap_mk_##t(mk_##t(a0))
    120  1.32  dholland #define MK2(t, a0, a1)	wrap_mk_##t(mk_##t(a0, a1))
    121  1.36  dholland #define MK3(t, a0, a1, a2)	wrap_mk_##t(mk_##t(a0, a1, a2))
    122  1.32  dholland 
    123  1.34  dholland #define MKF0(t, f)		wrap_mk_##t(mk_##t##_##f())
    124  1.34  dholland #define MKF1(t, f, a0)		wrap_mk_##t(mk_##t##_##f(a0))
    125  1.34  dholland #define MKF2(t, f, a0, a1)	wrap_mk_##t(mk_##t##_##f(a0, a1))
    126  1.34  dholland 
    127  1.32  dholland /*
    128  1.32  dholland  * Data constructors
    129  1.32  dholland  */
    130  1.32  dholland 
    131  1.37  dholland static struct defoptlist *mk_defoptlist(const char *, const char *,
    132  1.37  dholland 					const char *);
    133  1.36  dholland static struct loclist *mk_loc(const char *, const char *, long long);
    134  1.36  dholland static struct loclist *mk_loc_val(const char *, struct loclist *);
    135  1.32  dholland static struct attrlist *mk_attrlist(struct attrlist *, struct attr *);
    136  1.34  dholland static struct condexpr *mk_cx_atom(const char *);
    137  1.34  dholland static struct condexpr *mk_cx_not(struct condexpr *);
    138  1.34  dholland static struct condexpr *mk_cx_and(struct condexpr *, struct condexpr *);
    139  1.34  dholland static struct condexpr *mk_cx_or(struct condexpr *, struct condexpr *);
    140  1.32  dholland 
    141  1.31  dholland /*
    142  1.31  dholland  * Other private functions
    143  1.31  dholland  */
    144  1.31  dholland 
    145  1.20     pooka static	void	setmachine(const char *, const char *, struct nvlist *, int);
    146   1.1   thorpej static	void	check_maxpart(void);
    147   1.1   thorpej 
    148  1.36  dholland static struct loclist *present_loclist(struct loclist *ll);
    149  1.36  dholland static void app(struct loclist *, struct loclist *);
    150  1.36  dholland static struct loclist *locarray(const char *, int, struct loclist *, int);
    151  1.36  dholland static struct loclist *namelocvals(const char *, struct loclist *);
    152   1.1   thorpej 
    153   1.1   thorpej %}
    154   1.1   thorpej 
    155   1.1   thorpej %union {
    156   1.1   thorpej 	struct	attr *attr;
    157   1.1   thorpej 	struct	devbase *devb;
    158   1.1   thorpej 	struct	deva *deva;
    159   1.1   thorpej 	struct	nvlist *list;
    160  1.37  dholland 	struct defoptlist *defoptlist;
    161  1.36  dholland 	struct loclist *loclist;
    162  1.32  dholland 	struct attrlist *attrlist;
    163  1.34  dholland 	struct condexpr *condexpr;
    164   1.1   thorpej 	const char *str;
    165   1.1   thorpej 	struct	numconst num;
    166   1.1   thorpej 	int64_t	val;
    167  1.44  christos 	u_char	flag;
    168  1.44  christos 	devmajor_t devmajor;
    169  1.44  christos 	int32_t i32;
    170   1.1   thorpej }
    171   1.1   thorpej 
    172   1.1   thorpej %token	AND AT ATTACH
    173   1.1   thorpej %token	BLOCK BUILD
    174  1.11      cube %token	CHAR COLONEQ COMPILE_WITH CONFIG
    175  1.16  drochner %token	DEFFS DEFINE DEFOPT DEFPARAM DEFFLAG DEFPSEUDO DEFPSEUDODEV
    176  1.16  drochner %token	DEVICE DEVCLASS DUMPS DEVICE_MAJOR
    177   1.1   thorpej %token	ENDFILE
    178   1.1   thorpej %token	XFILE FILE_SYSTEM FLAGS
    179  1.20     pooka %token	IDENT IOCONF
    180  1.24     pooka %token	LINKZERO
    181   1.1   thorpej %token	XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR
    182  1.54  christos %token	NEEDS_COUNT NEEDS_FLAG NO CNO
    183   1.6      cube %token	XOBJECT OBSOLETE ON OPTIONS
    184  1.52  uebayasi %token	PACKAGE PLUSEQ PREFIX BUILDPREFIX PSEUDO_DEVICE PSEUDO_ROOT
    185   1.1   thorpej %token	ROOT
    186  1.45  uebayasi %token	SELECT SINGLE SOURCE
    187   1.1   thorpej %token	TYPE
    188  1.24     pooka %token	VECTOR VERSION
    189   1.1   thorpej %token	WITH
    190   1.1   thorpej %token	<num> NUMBER
    191   1.8  christos %token	<str> PATHNAME QSTRING WORD EMPTYSTRING
    192   1.1   thorpej %token	ENDDEFS
    193   1.1   thorpej 
    194  1.34  dholland %type	<condexpr>	fopts condexpr condatom
    195  1.34  dholland %type	<condexpr>	cond_or_expr cond_and_expr cond_prefix_expr
    196  1.34  dholland %type	<condexpr>	 cond_base_expr
    197   1.1   thorpej %type	<str>	fs_spec
    198  1.44  christos %type	<flag>	fflags fflag oflags oflag
    199  1.48  uebayasi %type	<str>	rule
    200  1.33  dholland %type	<attr>	depend
    201   1.1   thorpej %type	<devb>	devbase
    202   1.1   thorpej %type	<deva>	devattach_opt
    203  1.36  dholland %type	<list>	atlist
    204  1.36  dholland %type	<loclist> interface_opt
    205   1.1   thorpej %type	<str>	atname
    206  1.36  dholland %type	<loclist>	loclist locdef
    207   1.1   thorpej %type	<str>	locdefault
    208  1.36  dholland %type	<loclist>	values locdefaults
    209  1.33  dholland %type	<attrlist>	depend_list depends
    210  1.36  dholland %type	<loclist>	locators locator
    211   1.1   thorpej %type	<list>	dev_spec
    212   1.1   thorpej %type	<str>	device_instance
    213   1.1   thorpej %type	<str>	attachment
    214   1.1   thorpej %type	<str>	value
    215  1.44  christos %type	<val>	major_minor
    216   1.1   thorpej %type	<num>	signed_number
    217  1.54  christos %type	<i32>	int32 npseudo device_flags no
    218   1.1   thorpej %type	<str>	deffs
    219   1.1   thorpej %type	<list>	deffses
    220  1.37  dholland %type	<defoptlist>	defopt
    221  1.37  dholland %type	<defoptlist>	defopts
    222  1.35  dholland %type	<str>	optdepend
    223  1.35  dholland %type	<list>	optdepends
    224  1.35  dholland %type	<list>	optdepend_list
    225   1.1   thorpej %type	<str>	optfile_opt
    226  1.28  dholland %type	<list>	subarches
    227   1.1   thorpej %type	<str>	filename stringvalue locname mkvarname
    228  1.44  christos %type	<devmajor>	device_major_block device_major_char
    229  1.24     pooka %type	<list>	devnodes devnodetype devnodeflags devnode_dims
    230   1.1   thorpej 
    231   1.1   thorpej %%
    232   1.1   thorpej 
    233   1.1   thorpej /*
    234  1.40  uebayasi  * A complete configuration consists of both the selection part (a
    235  1.25  dholland  * kernel config such as GENERIC or SKYNET, plus also the various
    236  1.25  dholland  * std.* files), which selects the material to be in the kernel, and
    237  1.25  dholland  * also the definition part (files, files.*, etc.) that declares what
    238  1.25  dholland  * material is available to be placed in kernels.
    239  1.25  dholland  *
    240  1.25  dholland  * The two parts have almost entirely separate syntaxes. This grammar
    241  1.25  dholland  * covers both of them. When config is run on a kernel configuration
    242  1.25  dholland  * file, the std.* file for the port is included explicitly. The
    243  1.25  dholland  * files.* files are included implicitly when the std.* file declares
    244  1.25  dholland  * the machine type.
    245  1.25  dholland  *
    246  1.25  dholland  * The machine spec, which brings in the definition part, must appear
    247  1.25  dholland  * before all configuration material except for the "topthings"; these
    248  1.25  dholland  * are the "source" and "build" declarations that tell config where
    249  1.25  dholland  * things are. These are not used by default.
    250  1.25  dholland  *
    251  1.25  dholland  * A previous version of this comment contained the following text:
    252  1.25  dholland  *
    253  1.25  dholland  *       Note that we do not have sufficient keywords to enforce any
    254  1.25  dholland  *       order between elements of "topthings" without introducing
    255  1.25  dholland  *       shift/reduce conflicts.  Instead, check order requirements in
    256  1.25  dholland  *       the C code.
    257  1.25  dholland  *
    258  1.25  dholland  * As of March 2012 this comment makes no sense, as there are only two
    259  1.25  dholland  * topthings and no reason for them to be forcibly ordered.
    260  1.25  dholland  * Furthermore, the statement about conflicts is false.
    261   1.1   thorpej  */
    262  1.25  dholland 
    263  1.25  dholland /* Complete configuration. */
    264  1.28  dholland configuration:
    265  1.40  uebayasi 	topthings machine_spec definition_part selection_part
    266  1.26  dholland ;
    267   1.1   thorpej 
    268  1.25  dholland /* Sequence of zero or more topthings. */
    269   1.1   thorpej topthings:
    270  1.26  dholland 	  /* empty */
    271  1.26  dholland 	| topthings topthing
    272  1.26  dholland ;
    273   1.1   thorpej 
    274  1.25  dholland /* Directory specification. */
    275   1.1   thorpej topthing:
    276  1.27  dholland 	                  '\n'
    277  1.27  dholland 	| SOURCE filename '\n'		{ if (!srcdir) srcdir = $2; }
    278  1.26  dholland 	| BUILD  filename '\n'		{ if (!builddir) builddir = $2; }
    279  1.26  dholland ;
    280   1.1   thorpej 
    281  1.25  dholland /* "machine foo" from std.whatever */
    282   1.1   thorpej machine_spec:
    283  1.26  dholland 	  XMACHINE WORD '\n'			{ setmachine($2,NULL,NULL,0); }
    284  1.28  dholland 	| XMACHINE WORD WORD '\n'		{ setmachine($2,$3,NULL,0); }
    285  1.28  dholland 	| XMACHINE WORD WORD subarches '\n'	{ setmachine($2,$3,$4,0); }
    286  1.26  dholland 	| IOCONF WORD '\n'			{ setmachine($2,NULL,NULL,1); }
    287  1.26  dholland 	| error { stop("cannot proceed without machine or ioconf specifier"); }
    288  1.26  dholland ;
    289   1.1   thorpej 
    290  1.28  dholland /* One or more sub-arches. */
    291   1.1   thorpej subarches:
    292  1.27  dholland 	  WORD				{ $$ = new_n($1); }
    293  1.27  dholland 	| subarches WORD		{ $$ = new_nx($2, $1); }
    294  1.26  dholland ;
    295   1.1   thorpej 
    296  1.54  christos no:
    297  1.54  christos 	  NO	{ $$ = 0; }
    298  1.54  christos 	| CNO	{ $$ = 1; }
    299  1.54  christos ;
    300  1.54  christos 
    301  1.25  dholland /************************************************************/
    302  1.25  dholland 
    303   1.1   thorpej /*
    304   1.1   thorpej  * The machine definitions grammar.
    305   1.1   thorpej  */
    306  1.25  dholland 
    307  1.25  dholland /* Complete definition part: the contents of all files.* files. */
    308  1.28  dholland definition_part:
    309  1.56       uwe 	definitions ENDDEFS		{
    310  1.56       uwe 		CFGDBG(1, "ENDDEFS");
    311  1.56       uwe 		check_maxpart();
    312  1.56       uwe 		check_version();
    313  1.56       uwe 	}
    314  1.26  dholland ;
    315   1.1   thorpej 
    316  1.28  dholland /* Zero or more definitions. Trap errors. */
    317  1.28  dholland definitions:
    318  1.28  dholland 	  /* empty */
    319  1.28  dholland 	| definitions '\n'
    320  1.31  dholland 	| definitions definition '\n'	{ wrap_continue(); }
    321  1.31  dholland 	| definitions error '\n'	{ wrap_cleanup(); }
    322  1.28  dholland 	| definitions ENDFILE		{ enddefs(); checkfiles(); }
    323  1.26  dholland ;
    324   1.1   thorpej 
    325  1.25  dholland /* A single definition. */
    326  1.28  dholland definition:
    327  1.41  uebayasi 	  define_file
    328  1.41  uebayasi 	| define_object
    329  1.41  uebayasi 	| define_device_major
    330  1.41  uebayasi 	| define_prefix
    331  1.52  uebayasi 	| define_buildprefix
    332  1.41  uebayasi 	| define_devclass
    333  1.41  uebayasi 	| define_filesystems
    334  1.41  uebayasi 	| define_attribute
    335  1.41  uebayasi 	| define_option
    336  1.41  uebayasi 	| define_flag
    337  1.41  uebayasi 	| define_obsolete_flag
    338  1.41  uebayasi 	| define_param
    339  1.41  uebayasi 	| define_obsolete_param
    340  1.41  uebayasi 	| define_device
    341  1.41  uebayasi 	| define_device_attachment
    342  1.41  uebayasi 	| define_maxpartitions
    343  1.41  uebayasi 	| define_maxusers
    344  1.41  uebayasi 	| define_makeoptions
    345  1.41  uebayasi 	| define_pseudo
    346  1.41  uebayasi 	| define_pseudodev
    347  1.41  uebayasi 	| define_major
    348  1.41  uebayasi 	| define_version
    349  1.41  uebayasi ;
    350  1.41  uebayasi 
    351  1.41  uebayasi /* source file: file foo/bar.c bar|baz needs-flag compile-with blah */
    352  1.41  uebayasi define_file:
    353  1.48  uebayasi 	XFILE filename fopts fflags rule	{ addfile($2, $3, $4, $5); }
    354  1.41  uebayasi ;
    355  1.41  uebayasi 
    356  1.41  uebayasi /* object file: object zot.o foo|zot needs-flag */
    357  1.41  uebayasi define_object:
    358  1.51  uebayasi 	XOBJECT filename fopts oflags	{ addfile($2, $3, $4, NULL); }
    359  1.41  uebayasi ;
    360  1.41  uebayasi 
    361  1.41  uebayasi /* device major declaration */
    362  1.41  uebayasi define_device_major:
    363  1.41  uebayasi 	DEVICE_MAJOR WORD device_major_char device_major_block fopts devnodes
    364  1.41  uebayasi 					{
    365  1.41  uebayasi 		adddevm($2, $3, $4, $5, $6);
    366  1.41  uebayasi 		do_devsw = 1;
    367  1.41  uebayasi 	}
    368  1.41  uebayasi ;
    369  1.41  uebayasi 
    370  1.41  uebayasi /* prefix delimiter */
    371  1.41  uebayasi define_prefix:
    372  1.41  uebayasi 	  PREFIX filename		{ prefix_push($2); }
    373  1.41  uebayasi 	| PREFIX			{ prefix_pop(); }
    374  1.41  uebayasi ;
    375  1.41  uebayasi 
    376  1.52  uebayasi define_buildprefix:
    377  1.52  uebayasi 	  BUILDPREFIX filename		{ buildprefix_push($2); }
    378  1.52  uebayasi 	| BUILDPREFIX WORD		{ buildprefix_push($2); }
    379  1.52  uebayasi 	| BUILDPREFIX			{ buildprefix_pop(); }
    380  1.52  uebayasi ;
    381  1.52  uebayasi 
    382  1.41  uebayasi define_devclass:
    383  1.42  uebayasi 	DEVCLASS WORD			{ (void)defdevclass($2, NULL, NULL, 1); }
    384  1.41  uebayasi ;
    385  1.41  uebayasi 
    386  1.41  uebayasi define_filesystems:
    387  1.41  uebayasi 	DEFFS deffses optdepend_list	{ deffilesystem($2, $3); }
    388  1.41  uebayasi ;
    389  1.41  uebayasi 
    390  1.41  uebayasi define_attribute:
    391  1.41  uebayasi 	DEFINE WORD interface_opt depend_list
    392  1.42  uebayasi 					{ (void)defattr0($2, $3, $4, 0); }
    393  1.41  uebayasi ;
    394  1.41  uebayasi 
    395  1.41  uebayasi define_option:
    396  1.41  uebayasi 	DEFOPT optfile_opt defopts optdepend_list
    397  1.26  dholland 					{ defoption($2, $3, $4); }
    398  1.41  uebayasi ;
    399  1.41  uebayasi 
    400  1.41  uebayasi define_flag:
    401  1.41  uebayasi 	DEFFLAG optfile_opt defopts optdepend_list
    402  1.26  dholland 					{ defflag($2, $3, $4, 0); }
    403  1.41  uebayasi ;
    404  1.41  uebayasi 
    405  1.41  uebayasi define_obsolete_flag:
    406  1.41  uebayasi 	OBSOLETE DEFFLAG optfile_opt defopts
    407  1.26  dholland 					{ defflag($3, $4, NULL, 1); }
    408  1.41  uebayasi ;
    409  1.41  uebayasi 
    410  1.41  uebayasi define_param:
    411  1.41  uebayasi 	DEFPARAM optfile_opt defopts optdepend_list
    412  1.26  dholland 					{ defparam($2, $3, $4, 0); }
    413  1.41  uebayasi ;
    414  1.41  uebayasi 
    415  1.41  uebayasi define_obsolete_param:
    416  1.41  uebayasi 	OBSOLETE DEFPARAM optfile_opt defopts
    417  1.26  dholland 					{ defparam($3, $4, NULL, 1); }
    418  1.41  uebayasi ;
    419  1.41  uebayasi 
    420  1.41  uebayasi define_device:
    421  1.41  uebayasi 	DEVICE devbase interface_opt depend_list
    422  1.26  dholland 					{ defdev($2, $3, $4, 0); }
    423  1.41  uebayasi ;
    424  1.41  uebayasi 
    425  1.41  uebayasi define_device_attachment:
    426  1.41  uebayasi 	ATTACH devbase AT atlist devattach_opt depend_list
    427  1.26  dholland 					{ defdevattach($5, $2, $4, $6); }
    428  1.41  uebayasi ;
    429  1.41  uebayasi 
    430  1.41  uebayasi define_maxpartitions:
    431  1.44  christos 	MAXPARTITIONS int32		{ maxpartitions = $2; }
    432  1.41  uebayasi ;
    433  1.41  uebayasi 
    434  1.41  uebayasi define_maxusers:
    435  1.44  christos 	MAXUSERS int32 int32 int32
    436  1.44  christos 					{ setdefmaxusers($2, $3, $4); }
    437  1.41  uebayasi ;
    438  1.41  uebayasi 
    439  1.41  uebayasi define_makeoptions:
    440  1.41  uebayasi 	MAKEOPTIONS condmkopt_list
    441  1.41  uebayasi ;
    442  1.41  uebayasi 
    443  1.41  uebayasi define_pseudo:
    444  1.17  drochner 	/* interface_opt in DEFPSEUDO is for backwards compatibility */
    445  1.41  uebayasi 	DEFPSEUDO devbase interface_opt depend_list
    446  1.26  dholland 					{ defdev($2, $3, $4, 1); }
    447  1.41  uebayasi ;
    448  1.41  uebayasi 
    449  1.41  uebayasi define_pseudodev:
    450  1.41  uebayasi 	DEFPSEUDODEV devbase interface_opt depend_list
    451  1.26  dholland 					{ defdev($2, $3, $4, 2); }
    452  1.26  dholland ;
    453   1.1   thorpej 
    454  1.41  uebayasi define_major:
    455  1.41  uebayasi 	MAJOR '{' majorlist '}'
    456  1.41  uebayasi ;
    457  1.41  uebayasi 
    458  1.41  uebayasi define_version:
    459  1.44  christos 	VERSION int32		{ setversion($2); }
    460  1.26  dholland ;
    461   1.1   thorpej 
    462  1.33  dholland /* file options: optional expression of conditions */
    463  1.29  dholland fopts:
    464  1.29  dholland 	  /* empty */			{ $$ = NULL; }
    465  1.33  dholland 	| condexpr			{ $$ = $1; }
    466  1.26  dholland ;
    467   1.1   thorpej 
    468  1.29  dholland /* zero or more flags for a file */
    469  1.35  dholland fflags:
    470  1.29  dholland 	  /* empty */			{ $$ = 0; }
    471  1.35  dholland 	| fflags fflag			{ $$ = $1 | $2; }
    472  1.26  dholland ;
    473   1.1   thorpej 
    474  1.29  dholland /* one flag for a file */
    475  1.29  dholland fflag:
    476  1.29  dholland 	  NEEDS_COUNT			{ $$ = FI_NEEDSCOUNT; }
    477  1.29  dholland 	| NEEDS_FLAG			{ $$ = FI_NEEDSFLAG; }
    478  1.26  dholland ;
    479   1.1   thorpej 
    480  1.48  uebayasi /* extra compile directive for a source file */
    481  1.48  uebayasi rule:
    482  1.48  uebayasi 	  /* empty */			{ $$ = NULL; }
    483  1.48  uebayasi 	| COMPILE_WITH stringvalue	{ $$ = $2; }
    484  1.48  uebayasi ;
    485  1.48  uebayasi 
    486  1.29  dholland /* zero or more flags for an object file */
    487  1.35  dholland oflags:
    488  1.29  dholland 	  /* empty */			{ $$ = 0; }
    489  1.35  dholland 	| oflags oflag			{ $$ = $1 | $2; }
    490  1.29  dholland ;
    491  1.29  dholland 
    492  1.29  dholland /* a single flag for an object file */
    493  1.29  dholland oflag:
    494  1.51  uebayasi 	NEEDS_FLAG			{ $$ = FI_NEEDSFLAG; }
    495  1.29  dholland ;
    496  1.29  dholland 
    497  1.29  dholland /* char 55 */
    498  1.29  dholland device_major_char:
    499  1.29  dholland 	  /* empty */			{ $$ = -1; }
    500  1.44  christos 	| CHAR int32			{ $$ = $2; }
    501  1.26  dholland ;
    502   1.1   thorpej 
    503  1.29  dholland /* block 33 */
    504  1.29  dholland device_major_block:
    505  1.29  dholland 	  /* empty */			{ $$ = -1; }
    506  1.44  christos 	| BLOCK int32			{ $$ = $2; }
    507  1.26  dholland ;
    508   1.1   thorpej 
    509  1.29  dholland /* device node specification */
    510  1.29  dholland devnodes:
    511  1.29  dholland 	  /* empty */			{ $$ = new_s("DEVNODE_DONTBOTHER"); }
    512  1.29  dholland 	| devnodetype ',' devnodeflags	{ $$ = nvcat($1, $3); }
    513  1.29  dholland 	| devnodetype			{ $$ = $1; }
    514  1.26  dholland ;
    515   1.1   thorpej 
    516  1.29  dholland /* device nodes without flags */
    517  1.29  dholland devnodetype:
    518  1.29  dholland 	  SINGLE			{ $$ = new_s("DEVNODE_SINGLE"); }
    519  1.29  dholland 	| VECTOR '=' devnode_dims  { $$ = nvcat(new_s("DEVNODE_VECTOR"), $3); }
    520  1.26  dholland ;
    521   1.1   thorpej 
    522  1.29  dholland /* dimensions (?) */
    523  1.29  dholland devnode_dims:
    524  1.29  dholland 	  NUMBER			{ $$ = new_i($1.val); }
    525  1.29  dholland 	| NUMBER ':' NUMBER		{
    526  1.29  dholland 		struct nvlist *__nv1, *__nv2;
    527  1.26  dholland 
    528  1.29  dholland 		__nv1 = new_i($1.val);
    529  1.29  dholland 		__nv2 = new_i($3.val);
    530  1.29  dholland 		$$ = nvcat(__nv1, __nv2);
    531  1.26  dholland 	  }
    532  1.29  dholland ;
    533  1.29  dholland 
    534  1.29  dholland /* flags for device nodes */
    535  1.29  dholland devnodeflags:
    536  1.29  dholland 	LINKZERO			{ $$ = new_s("DEVNODE_FLAG_LINKZERO");}
    537  1.29  dholland ;
    538  1.26  dholland 
    539  1.29  dholland /* one or more file system names */
    540  1.29  dholland deffses:
    541  1.29  dholland 	  deffs				{ $$ = new_n($1); }
    542  1.29  dholland 	| deffses deffs			{ $$ = new_nx($2, $1); }
    543  1.26  dholland ;
    544   1.1   thorpej 
    545  1.29  dholland /* a single file system name */
    546  1.29  dholland deffs:
    547  1.29  dholland 	WORD				{ $$ = $1; }
    548  1.26  dholland ;
    549   1.1   thorpej 
    550  1.28  dholland /* optional locator specification */
    551   1.1   thorpej interface_opt:
    552  1.26  dholland 	  /* empty */			{ $$ = NULL; }
    553  1.36  dholland 	| '{' '}'			{ $$ = present_loclist(NULL); }
    554  1.36  dholland 	| '{' loclist '}'		{ $$ = present_loclist($2); }
    555  1.26  dholland ;
    556   1.1   thorpej 
    557  1.25  dholland /*
    558  1.25  dholland  * loclist order matters, must use right recursion
    559  1.25  dholland  * XXX wot?
    560  1.25  dholland  */
    561  1.25  dholland 
    562  1.25  dholland /* list of locator definitions */
    563   1.1   thorpej loclist:
    564  1.26  dholland 	  locdef			{ $$ = $1; }
    565  1.26  dholland 	| locdef ',' loclist		{ $$ = $1; app($1, $3); }
    566  1.26  dholland ;
    567   1.1   thorpej 
    568  1.25  dholland /*
    569  1.25  dholland  * "[ WORD locdefault ]" syntax may be unnecessary...
    570  1.25  dholland  */
    571  1.25  dholland 
    572  1.25  dholland /* one locator definition */
    573   1.1   thorpej locdef:
    574  1.36  dholland 	  locname locdefault 		{ $$ = MK3(loc, $1, $2, 0); }
    575  1.36  dholland 	| locname			{ $$ = MK3(loc, $1, NULL, 0); }
    576  1.36  dholland 	| '[' locname locdefault ']'	{ $$ = MK3(loc, $2, $3, 1); }
    577  1.44  christos 	| locname '[' int32 ']'	{ $$ = locarray($1, $3, NULL, 0); }
    578  1.44  christos 	| locname '[' int32 ']' locdefaults
    579  1.44  christos 					{ $$ = locarray($1, $3, $5, 0); }
    580  1.44  christos 	| '[' locname '[' int32 ']' locdefaults ']'
    581  1.44  christos 					{ $$ = locarray($2, $4, $6, 1); }
    582  1.26  dholland ;
    583   1.1   thorpej 
    584  1.25  dholland /* locator name */
    585   1.1   thorpej locname:
    586  1.26  dholland 	  WORD				{ $$ = $1; }
    587  1.26  dholland 	| QSTRING			{ $$ = $1; }
    588  1.26  dholland ;
    589   1.1   thorpej 
    590  1.25  dholland /* locator default value */
    591   1.1   thorpej locdefault:
    592  1.26  dholland 	'=' value			{ $$ = $2; }
    593  1.26  dholland ;
    594   1.1   thorpej 
    595  1.25  dholland /* multiple locator default values */
    596   1.1   thorpej locdefaults:
    597  1.26  dholland 	'=' '{' values '}'		{ $$ = $3; }
    598  1.26  dholland ;
    599   1.1   thorpej 
    600  1.33  dholland /* list of depends, may be empty */
    601  1.33  dholland depend_list:
    602  1.26  dholland 	  /* empty */			{ $$ = NULL; }
    603  1.33  dholland 	| ':' depends			{ $$ = $2; }
    604  1.29  dholland ;
    605  1.29  dholland 
    606  1.33  dholland /* one or more depend items */
    607  1.33  dholland depends:
    608  1.33  dholland 	  depend			{ $$ = MK2(attrlist, NULL, $1); }
    609  1.33  dholland 	| depends ',' depend		{ $$ = MK2(attrlist, $1, $3); }
    610  1.29  dholland ;
    611  1.29  dholland 
    612  1.33  dholland /* one depend item (which is an attribute) */
    613  1.33  dholland depend:
    614  1.43  uebayasi 	WORD				{ $$ = refattr($1); }
    615  1.29  dholland ;
    616  1.29  dholland 
    617  1.35  dholland /* list of option depends, may be empty */
    618  1.35  dholland optdepend_list:
    619  1.35  dholland 	  /* empty */			{ $$ = NULL; }
    620  1.35  dholland 	| ':' optdepends		{ $$ = $2; }
    621  1.35  dholland ;
    622  1.35  dholland 
    623  1.35  dholland /* a list of option dependencies */
    624  1.35  dholland optdepends:
    625  1.35  dholland 	  optdepend			{ $$ = new_n($1); }
    626  1.35  dholland 	| optdepends ',' optdepend	{ $$ = new_nx($3, $1); }
    627  1.35  dholland ;
    628  1.35  dholland 
    629  1.35  dholland /* one option depend, which is an option name */
    630  1.35  dholland optdepend:
    631  1.35  dholland 	WORD				{ $$ = $1; }
    632  1.35  dholland ;
    633  1.35  dholland 
    634  1.35  dholland 
    635  1.29  dholland /* list of places to attach: attach blah at ... */
    636  1.29  dholland atlist:
    637  1.29  dholland 	  atname			{ $$ = new_n($1); }
    638  1.29  dholland 	| atlist ',' atname		{ $$ = new_nx($3, $1); }
    639  1.29  dholland ;
    640  1.29  dholland 
    641  1.29  dholland /* a place to attach a device */
    642  1.29  dholland atname:
    643  1.29  dholland 	  WORD				{ $$ = $1; }
    644  1.29  dholland 	| ROOT				{ $$ = NULL; }
    645  1.26  dholland ;
    646   1.1   thorpej 
    647  1.29  dholland /* one or more defined options */
    648  1.29  dholland defopts:
    649  1.29  dholland 	  defopt			{ $$ = $1; }
    650  1.37  dholland 	| defopts defopt		{ $$ = defoptlist_append($2, $1); }
    651  1.26  dholland ;
    652   1.1   thorpej 
    653  1.29  dholland /* one defined option */
    654  1.29  dholland defopt:
    655  1.37  dholland 	  WORD				{ $$ = MK3(defoptlist, $1, NULL, NULL); }
    656  1.37  dholland 	| WORD '=' value		{ $$ = MK3(defoptlist, $1, $3, NULL); }
    657  1.37  dholland 	| WORD COLONEQ value		{ $$ = MK3(defoptlist, $1, NULL, $3); }
    658  1.37  dholland 	| WORD '=' value COLONEQ value	{ $$ = MK3(defoptlist, $1, $3, $5); }
    659  1.26  dholland ;
    660   1.1   thorpej 
    661  1.29  dholland /* list of conditional makeoptions */
    662  1.29  dholland condmkopt_list:
    663  1.29  dholland 	  condmkoption
    664  1.29  dholland 	| condmkopt_list ',' condmkoption
    665  1.26  dholland ;
    666   1.1   thorpej 
    667  1.29  dholland /* one conditional make option */
    668  1.29  dholland condmkoption:
    669  1.33  dholland 	condexpr mkvarname PLUSEQ value	{ appendcondmkoption($1, $2, $4); }
    670  1.26  dholland ;
    671   1.1   thorpej 
    672  1.29  dholland /* device name */
    673  1.29  dholland devbase:
    674  1.29  dholland 	WORD				{ $$ = getdevbase($1); }
    675  1.26  dholland ;
    676   1.1   thorpej 
    677  1.29  dholland /* optional attachment: with foo */
    678  1.29  dholland devattach_opt:
    679  1.29  dholland 	  /* empty */			{ $$ = NULL; }
    680  1.29  dholland 	| WITH WORD			{ $$ = getdevattach($2); }
    681  1.26  dholland ;
    682   1.1   thorpej 
    683  1.25  dholland /* list of major numbers */
    684  1.25  dholland /* XXX why is this right-recursive? */
    685   1.1   thorpej majorlist:
    686  1.26  dholland 	  majordef
    687  1.26  dholland 	| majorlist ',' majordef
    688  1.26  dholland ;
    689   1.1   thorpej 
    690  1.25  dholland /* one major number */
    691   1.1   thorpej majordef:
    692  1.44  christos 	devbase '=' int32		{ setmajor($1, $3); }
    693  1.44  christos ;
    694  1.44  christos 
    695  1.44  christos int32:
    696  1.44  christos 	NUMBER	{
    697  1.44  christos 		if ($1.val > INT_MAX || $1.val < INT_MIN)
    698  1.44  christos 			cfgerror("overflow %" PRId64, $1.val);
    699  1.44  christos 		else
    700  1.44  christos 			$$ = (int32_t)$1.val;
    701  1.44  christos 	}
    702  1.26  dholland ;
    703   1.1   thorpej 
    704  1.25  dholland /************************************************************/
    705   1.1   thorpej 
    706   1.1   thorpej /*
    707  1.40  uebayasi  * The selection grammar.
    708   1.1   thorpej  */
    709  1.25  dholland 
    710  1.40  uebayasi /* Complete selection part: all std.* files plus selected config. */
    711  1.40  uebayasi selection_part:
    712  1.40  uebayasi 	selections
    713  1.26  dholland ;
    714   1.1   thorpej 
    715  1.28  dholland /* Zero or more config items. Trap errors. */
    716  1.40  uebayasi selections:
    717  1.28  dholland 	  /* empty */
    718  1.40  uebayasi 	| selections '\n'
    719  1.40  uebayasi 	| selections selection '\n'	{ wrap_continue(); }
    720  1.41  uebayasi 	| selections error '\n'		{ wrap_cleanup(); }
    721  1.26  dholland ;
    722   1.1   thorpej 
    723  1.25  dholland /* One config item. */
    724  1.40  uebayasi selection:
    725  1.28  dholland 	  definition
    726  1.45  uebayasi 	| select_attr
    727  1.45  uebayasi 	| select_no_attr
    728  1.41  uebayasi 	| select_no_filesystems
    729  1.41  uebayasi 	| select_filesystems
    730  1.41  uebayasi 	| select_no_makeoptions
    731  1.41  uebayasi 	| select_makeoptions
    732  1.41  uebayasi 	| select_no_options
    733  1.41  uebayasi 	| select_options
    734  1.41  uebayasi 	| select_maxusers
    735  1.41  uebayasi 	| select_ident
    736  1.41  uebayasi 	| select_no_ident
    737  1.41  uebayasi 	| select_config
    738  1.41  uebayasi 	| select_no_config
    739  1.41  uebayasi 	| select_no_pseudodev
    740  1.41  uebayasi 	| select_pseudodev
    741  1.41  uebayasi 	| select_pseudoroot
    742  1.41  uebayasi 	| select_no_device_instance_attachment
    743  1.41  uebayasi 	| select_no_device_attachment
    744  1.41  uebayasi 	| select_no_device_instance
    745  1.41  uebayasi 	| select_device_instance
    746  1.41  uebayasi ;
    747  1.41  uebayasi 
    748  1.45  uebayasi select_attr:
    749  1.45  uebayasi 	SELECT WORD			{ addattr($2); }
    750  1.45  uebayasi ;
    751  1.45  uebayasi 
    752  1.45  uebayasi select_no_attr:
    753  1.54  christos 	no SELECT WORD			{ delattr($3, $1); }
    754  1.45  uebayasi ;
    755  1.45  uebayasi 
    756  1.41  uebayasi select_no_filesystems:
    757  1.54  christos 	no FILE_SYSTEM { nowarn = $1; } no_fs_list { nowarn = 0; }
    758  1.41  uebayasi ;
    759  1.41  uebayasi 
    760  1.41  uebayasi select_filesystems:
    761  1.41  uebayasi 	FILE_SYSTEM fs_list
    762  1.41  uebayasi ;
    763  1.41  uebayasi 
    764  1.41  uebayasi select_no_makeoptions:
    765  1.54  christos 	no MAKEOPTIONS { nowarn = $1; } no_mkopt_list { nowarn = 0; }
    766  1.41  uebayasi ;
    767  1.41  uebayasi 
    768  1.41  uebayasi select_makeoptions:
    769  1.41  uebayasi 	MAKEOPTIONS mkopt_list
    770  1.41  uebayasi ;
    771  1.41  uebayasi 
    772  1.41  uebayasi select_no_options:
    773  1.54  christos 	no OPTIONS { nowarn = $1; } no_opt_list { nowarn = 0; }
    774  1.41  uebayasi ;
    775  1.41  uebayasi 
    776  1.41  uebayasi select_options:
    777  1.41  uebayasi 	OPTIONS opt_list
    778  1.41  uebayasi ;
    779  1.41  uebayasi 
    780  1.41  uebayasi select_maxusers:
    781  1.50  uebayasi 	MAXUSERS int32			{ setmaxusers($2); }
    782  1.41  uebayasi ;
    783  1.41  uebayasi 
    784  1.41  uebayasi select_ident:
    785  1.41  uebayasi 	IDENT stringvalue		{ setident($2); }
    786  1.41  uebayasi ;
    787  1.41  uebayasi 
    788  1.41  uebayasi select_no_ident:
    789  1.54  christos 	no IDENT			{ setident(NULL); }
    790  1.41  uebayasi ;
    791  1.41  uebayasi 
    792  1.41  uebayasi select_config:
    793  1.41  uebayasi 	CONFIG conf root_spec sysparam_list
    794  1.26  dholland 					{ addconf(&conf); }
    795  1.41  uebayasi ;
    796  1.41  uebayasi 
    797  1.41  uebayasi select_no_config:
    798  1.54  christos 	no CONFIG WORD			{ delconf($3, $1); }
    799  1.41  uebayasi ;
    800  1.41  uebayasi 
    801  1.41  uebayasi select_no_pseudodev:
    802  1.54  christos 	no PSEUDO_DEVICE WORD		{ delpseudo($3, $1); }
    803  1.41  uebayasi ;
    804  1.41  uebayasi 
    805  1.41  uebayasi select_pseudodev:
    806  1.41  uebayasi 	PSEUDO_DEVICE WORD npseudo	{ addpseudo($2, $3); }
    807  1.41  uebayasi ;
    808  1.41  uebayasi 
    809  1.41  uebayasi select_pseudoroot:
    810  1.41  uebayasi 	PSEUDO_ROOT device_instance	{ addpseudoroot($2); }
    811  1.41  uebayasi ;
    812  1.41  uebayasi 
    813  1.41  uebayasi select_no_device_instance_attachment:
    814  1.54  christos 	no device_instance AT attachment
    815  1.54  christos 					{ deldevi($2, $4, $1); }
    816  1.41  uebayasi ;
    817  1.41  uebayasi 
    818  1.41  uebayasi select_no_device_attachment:
    819  1.54  christos 	no DEVICE AT attachment		{ deldeva($4, $1); }
    820  1.41  uebayasi ;
    821  1.41  uebayasi 
    822  1.41  uebayasi select_no_device_instance:
    823  1.54  christos 	no device_instance		{ deldev($2, $1); }
    824  1.41  uebayasi ;
    825  1.41  uebayasi 
    826  1.41  uebayasi select_device_instance:
    827  1.41  uebayasi 	device_instance AT attachment locators device_flags
    828  1.26  dholland 					{ adddev($1, $3, $4, $5); }
    829  1.26  dholland ;
    830   1.1   thorpej 
    831  1.25  dholland /* list of filesystems */
    832   1.1   thorpej fs_list:
    833  1.26  dholland 	  fsoption
    834  1.26  dholland 	| fs_list ',' fsoption
    835  1.26  dholland ;
    836   1.1   thorpej 
    837  1.25  dholland /* one filesystem */
    838   1.1   thorpej fsoption:
    839  1.26  dholland 	WORD				{ addfsoption($1); }
    840  1.26  dholland ;
    841   1.1   thorpej 
    842  1.25  dholland /* list of filesystems that had NO in front */
    843   1.1   thorpej no_fs_list:
    844  1.26  dholland 	  no_fsoption
    845  1.26  dholland 	| no_fs_list ',' no_fsoption
    846  1.26  dholland ;
    847   1.1   thorpej 
    848  1.25  dholland /* one filesystem that had NO in front */
    849   1.1   thorpej no_fsoption:
    850  1.54  christos 	WORD				{ delfsoption($1, nowarn); }
    851  1.26  dholland ;
    852   1.1   thorpej 
    853  1.25  dholland /* list of make options */
    854  1.25  dholland /* XXX why is this right-recursive? */
    855   1.1   thorpej mkopt_list:
    856  1.26  dholland 	  mkoption
    857  1.26  dholland 	| mkopt_list ',' mkoption
    858  1.26  dholland ;
    859   1.1   thorpej 
    860  1.25  dholland /* one make option */
    861   1.1   thorpej mkoption:
    862  1.26  dholland 	  mkvarname '=' value		{ addmkoption($1, $3); }
    863  1.26  dholland 	| mkvarname PLUSEQ value	{ appendmkoption($1, $3); }
    864  1.26  dholland ;
    865   1.1   thorpej 
    866  1.25  dholland /* list of make options that had NO in front */
    867   1.1   thorpej no_mkopt_list:
    868  1.26  dholland 	  no_mkoption
    869  1.26  dholland 	| no_mkopt_list ',' no_mkoption
    870  1.26  dholland ;
    871   1.1   thorpej 
    872  1.25  dholland /* one make option that had NO in front */
    873  1.29  dholland /* XXX shouldn't this be mkvarname rather than WORD? */
    874   1.1   thorpej no_mkoption:
    875  1.54  christos 	WORD				{ delmkoption($1, nowarn); }
    876  1.26  dholland ;
    877   1.1   thorpej 
    878  1.25  dholland /* list of options */
    879   1.1   thorpej opt_list:
    880  1.26  dholland 	  option
    881  1.26  dholland 	| opt_list ',' option
    882  1.26  dholland ;
    883   1.1   thorpej 
    884  1.25  dholland /* one option */
    885   1.1   thorpej option:
    886  1.26  dholland 	  WORD				{ addoption($1, NULL); }
    887  1.26  dholland 	| WORD '=' value		{ addoption($1, $3); }
    888  1.26  dholland ;
    889   1.1   thorpej 
    890  1.25  dholland /* list of options that had NO in front */
    891   1.1   thorpej no_opt_list:
    892  1.26  dholland 	  no_option
    893  1.26  dholland 	| no_opt_list ',' no_option
    894  1.26  dholland ;
    895   1.1   thorpej 
    896  1.25  dholland /* one option that had NO in front */
    897   1.1   thorpej no_option:
    898  1.54  christos 	WORD				{ deloption($1, nowarn); }
    899  1.26  dholland ;
    900   1.1   thorpej 
    901  1.25  dholland /* the name in "config name root on ..." */
    902   1.1   thorpej conf:
    903  1.26  dholland 	WORD				{
    904  1.26  dholland 		conf.cf_name = $1;
    905  1.55  christos 		conf.cf_where.w_srcline = currentline();
    906  1.26  dholland 		conf.cf_fstype = NULL;
    907  1.26  dholland 		conf.cf_root = NULL;
    908  1.26  dholland 		conf.cf_dump = NULL;
    909  1.26  dholland 	}
    910  1.26  dholland ;
    911   1.1   thorpej 
    912  1.25  dholland /* root fs specification */
    913   1.1   thorpej root_spec:
    914  1.28  dholland 	  ROOT on_opt dev_spec		{ setconf(&conf.cf_root, "root", $3); }
    915  1.28  dholland 	| ROOT on_opt dev_spec fs_spec	{ setconf(&conf.cf_root, "root", $3); }
    916  1.26  dholland ;
    917   1.1   thorpej 
    918  1.29  dholland /* device for root fs or dump */
    919  1.29  dholland dev_spec:
    920  1.53   mlelstv 	  '?'				{ $$ = new_spi(intern("?"),
    921  1.53   mlelstv 					    NULL,
    922  1.44  christos 					    (long long)NODEV); }
    923  1.53   mlelstv 	| QSTRING			{ $$ = new_spi($1,
    924  1.53   mlelstv 					    __UNCONST("spec"),
    925  1.53   mlelstv 					    (long long)NODEV); }
    926  1.53   mlelstv 	| WORD				{ $$ = new_spi($1,
    927  1.53   mlelstv 					    NULL,
    928  1.44  christos 					    (long long)NODEV); }
    929  1.29  dholland 	| major_minor			{ $$ = new_si(NULL, $1); }
    930  1.29  dholland ;
    931  1.29  dholland 
    932  1.29  dholland /* major and minor device number */
    933  1.29  dholland major_minor:
    934  1.46     joerg 	MAJOR NUMBER MINOR NUMBER	{ $$ = (int64_t)makedev($2.val, $4.val); }
    935  1.29  dholland ;
    936  1.29  dholland 
    937  1.25  dholland /* filesystem type for root fs specification */
    938   1.1   thorpej fs_spec:
    939  1.28  dholland 	  TYPE '?'		   { setfstype(&conf.cf_fstype, intern("?")); }
    940  1.28  dholland 	| TYPE WORD			{ setfstype(&conf.cf_fstype, $2); }
    941  1.26  dholland ;
    942   1.1   thorpej 
    943  1.25  dholland /* zero or more additional system parameters */
    944   1.1   thorpej sysparam_list:
    945  1.26  dholland 	  /* empty */
    946  1.26  dholland 	| sysparam_list sysparam
    947  1.26  dholland ;
    948   1.1   thorpej 
    949  1.25  dholland /* one additional system parameter (there's only one: dumps) */
    950   1.1   thorpej sysparam:
    951  1.26  dholland 	DUMPS on_opt dev_spec	       { setconf(&conf.cf_dump, "dumps", $3); }
    952  1.26  dholland ;
    953   1.1   thorpej 
    954  1.25  dholland /* number of pseudo devices to configure (which is optional) */
    955   1.1   thorpej npseudo:
    956  1.26  dholland 	  /* empty */			{ $$ = 1; }
    957  1.44  christos 	| int32				{ $$ = $1; }
    958  1.26  dholland ;
    959   1.1   thorpej 
    960  1.25  dholland /* name of a device to configure */
    961   1.1   thorpej device_instance:
    962  1.26  dholland 	  WORD				{ $$ = $1; }
    963  1.26  dholland 	| WORD '*'			{ $$ = starref($1); }
    964  1.26  dholland ;
    965   1.1   thorpej 
    966  1.25  dholland /* name of a device to configure an attachment to */
    967   1.1   thorpej attachment:
    968  1.26  dholland 	  ROOT				{ $$ = NULL; }
    969  1.26  dholland 	| WORD				{ $$ = $1; }
    970  1.26  dholland 	| WORD '?'			{ $$ = wildref($1); }
    971  1.26  dholland ;
    972   1.1   thorpej 
    973  1.25  dholland /* zero or more locators */
    974   1.1   thorpej locators:
    975  1.26  dholland 	  /* empty */			{ $$ = NULL; }
    976  1.26  dholland 	| locators locator		{ $$ = $2; app($2, $1); }
    977  1.26  dholland ;
    978   1.1   thorpej 
    979  1.25  dholland /* one locator */
    980   1.1   thorpej locator:
    981  1.36  dholland 	  WORD '?'			{ $$ = MK3(loc, $1, NULL, 0); }
    982  1.36  dholland 	| WORD values			{ $$ = namelocvals($1, $2); }
    983  1.26  dholland ;
    984   1.1   thorpej 
    985  1.25  dholland /* optional device flags */
    986  1.28  dholland device_flags:
    987  1.26  dholland 	  /* empty */			{ $$ = 0; }
    988  1.44  christos 	| FLAGS int32			{ $$ = $2; }
    989  1.26  dholland ;
    990   1.1   thorpej 
    991  1.29  dholland /************************************************************/
    992  1.29  dholland 
    993  1.29  dholland /*
    994  1.33  dholland  * conditions
    995  1.29  dholland  */
    996  1.29  dholland 
    997  1.29  dholland 
    998  1.29  dholland /*
    999  1.29  dholland  * order of options is important, must use right recursion
   1000  1.29  dholland  *
   1001  1.29  dholland  * dholland 20120310: wut?
   1002  1.29  dholland  */
   1003  1.29  dholland 
   1004  1.33  dholland /* expression of conditions */
   1005  1.33  dholland condexpr:
   1006  1.33  dholland 	cond_or_expr
   1007  1.30  dholland ;
   1008  1.30  dholland 
   1009  1.33  dholland cond_or_expr:
   1010  1.33  dholland 	  cond_and_expr
   1011  1.34  dholland 	| cond_or_expr '|' cond_and_expr	{ $$ = MKF2(cx, or, $1, $3); }
   1012  1.30  dholland ;
   1013  1.30  dholland 
   1014  1.33  dholland cond_and_expr:
   1015  1.33  dholland 	  cond_prefix_expr
   1016  1.34  dholland 	| cond_and_expr '&' cond_prefix_expr	{ $$ = MKF2(cx, and, $1, $3); }
   1017  1.30  dholland ;
   1018  1.30  dholland 
   1019  1.33  dholland cond_prefix_expr:
   1020  1.33  dholland 	  cond_base_expr
   1021  1.30  dholland /* XXX notyet - need to strengthen downstream first */
   1022  1.34  dholland /*	| '!' cond_prefix_expr			{ $$ = MKF1(cx, not, $2); } */
   1023  1.30  dholland ;
   1024  1.30  dholland 
   1025  1.33  dholland cond_base_expr:
   1026  1.33  dholland 	  condatom			{ $$ = $1; }
   1027  1.34  dholland 	| '!' condatom			{ $$ = MKF1(cx, not, $2); }
   1028  1.33  dholland 	| '(' condexpr ')'		{ $$ = $2; }
   1029  1.29  dholland ;
   1030  1.29  dholland 
   1031  1.29  dholland /* basic element of config element expression: a config element */
   1032  1.33  dholland condatom:
   1033  1.34  dholland 	WORD				{ $$ = MKF1(cx, atom, $1); }
   1034  1.29  dholland ;
   1035  1.29  dholland 
   1036  1.29  dholland /************************************************************/
   1037  1.29  dholland 
   1038  1.29  dholland /*
   1039  1.29  dholland  * Various nonterminals shared between the grammars.
   1040  1.29  dholland  */
   1041  1.29  dholland 
   1042  1.29  dholland /* variable name for make option */
   1043  1.29  dholland mkvarname:
   1044  1.29  dholland 	  QSTRING			{ $$ = $1; }
   1045  1.29  dholland 	| WORD				{ $$ = $1; }
   1046  1.29  dholland ;
   1047  1.29  dholland 
   1048  1.29  dholland /* optional file for an option */
   1049  1.29  dholland optfile_opt:
   1050  1.29  dholland 	  /* empty */			{ $$ = NULL; }
   1051  1.29  dholland 	| filename			{ $$ = $1; }
   1052  1.29  dholland ;
   1053  1.29  dholland 
   1054  1.29  dholland /* filename. */
   1055  1.29  dholland filename:
   1056  1.29  dholland 	  QSTRING			{ $$ = $1; }
   1057  1.29  dholland 	| PATHNAME			{ $$ = $1; }
   1058  1.29  dholland ;
   1059  1.29  dholland 
   1060  1.29  dholland /* constant value */
   1061  1.29  dholland value:
   1062  1.29  dholland 	  QSTRING			{ $$ = $1; }
   1063  1.29  dholland 	| WORD				{ $$ = $1; }
   1064  1.29  dholland 	| EMPTYSTRING			{ $$ = $1; }
   1065  1.29  dholland 	| signed_number			{
   1066  1.29  dholland 		char bf[40];
   1067  1.29  dholland 
   1068  1.29  dholland 		(void)snprintf(bf, sizeof(bf), FORMAT($1), (long long)$1.val);
   1069  1.29  dholland 		$$ = intern(bf);
   1070  1.29  dholland 	  }
   1071  1.29  dholland ;
   1072  1.29  dholland 
   1073  1.29  dholland /* constant value that is a string */
   1074  1.29  dholland stringvalue:
   1075  1.29  dholland 	  QSTRING			{ $$ = $1; }
   1076  1.29  dholland 	| WORD				{ $$ = $1; }
   1077  1.29  dholland ;
   1078  1.29  dholland 
   1079  1.29  dholland /* comma-separated list of values */
   1080  1.29  dholland /* XXX why right-recursive? */
   1081  1.29  dholland values:
   1082  1.36  dholland 	  value				{ $$ = MKF2(loc, val, $1, NULL); }
   1083  1.36  dholland 	| value ',' values		{ $$ = MKF2(loc, val, $1, $3); }
   1084  1.29  dholland ;
   1085  1.29  dholland 
   1086  1.29  dholland /* possibly negative number */
   1087  1.29  dholland signed_number:
   1088  1.29  dholland 	  NUMBER			{ $$ = $1; }
   1089  1.29  dholland 	| '-' NUMBER			{ $$.fmt = $2.fmt; $$.val = -$2.val; }
   1090  1.29  dholland ;
   1091  1.29  dholland 
   1092  1.29  dholland /* optional ON keyword */
   1093  1.29  dholland on_opt:
   1094  1.29  dholland 	  /* empty */
   1095  1.29  dholland 	| ON
   1096  1.29  dholland ;
   1097  1.29  dholland 
   1098   1.1   thorpej %%
   1099   1.1   thorpej 
   1100   1.1   thorpej void
   1101   1.1   thorpej yyerror(const char *s)
   1102   1.1   thorpej {
   1103   1.1   thorpej 
   1104  1.13  christos 	cfgerror("%s", s);
   1105   1.1   thorpej }
   1106   1.1   thorpej 
   1107  1.31  dholland /************************************************************/
   1108  1.31  dholland 
   1109  1.31  dholland /*
   1110  1.31  dholland  * Wrap allocations that live on the parser stack so that we can free
   1111  1.31  dholland  * them again on error instead of leaking.
   1112  1.31  dholland  */
   1113  1.31  dholland 
   1114  1.31  dholland #define MAX_WRAP 1000
   1115  1.31  dholland 
   1116  1.31  dholland struct wrap_entry {
   1117  1.31  dholland 	void *ptr;
   1118  1.31  dholland 	unsigned typecode;
   1119  1.31  dholland };
   1120  1.31  dholland 
   1121  1.31  dholland static struct wrap_entry wrapstack[MAX_WRAP];
   1122  1.31  dholland static unsigned wrap_depth;
   1123  1.31  dholland 
   1124   1.1   thorpej /*
   1125  1.31  dholland  * Remember pointer PTR with type-code CODE.
   1126   1.1   thorpej  */
   1127   1.1   thorpej static void
   1128  1.31  dholland wrap_alloc(void *ptr, unsigned code)
   1129   1.1   thorpej {
   1130  1.31  dholland 	unsigned pos;
   1131  1.31  dholland 
   1132  1.31  dholland 	if (wrap_depth >= MAX_WRAP) {
   1133  1.31  dholland 		panic("allocation wrapper stack overflow");
   1134  1.31  dholland 	}
   1135  1.31  dholland 	pos = wrap_depth++;
   1136  1.31  dholland 	wrapstack[pos].ptr = ptr;
   1137  1.31  dholland 	wrapstack[pos].typecode = code;
   1138  1.31  dholland }
   1139  1.31  dholland 
   1140  1.31  dholland /*
   1141  1.31  dholland  * We succeeded; commit to keeping everything that's been allocated so
   1142  1.31  dholland  * far and clear the stack.
   1143  1.31  dholland  */
   1144  1.31  dholland static void
   1145  1.31  dholland wrap_continue(void)
   1146  1.31  dholland {
   1147  1.31  dholland 	wrap_depth = 0;
   1148  1.31  dholland }
   1149  1.31  dholland 
   1150  1.31  dholland /*
   1151  1.31  dholland  * We failed; destroy all the objects allocated.
   1152  1.31  dholland  */
   1153  1.31  dholland static void
   1154  1.31  dholland wrap_cleanup(void)
   1155  1.31  dholland {
   1156  1.31  dholland 	unsigned i;
   1157   1.1   thorpej 
   1158  1.36  dholland 	/*
   1159  1.36  dholland 	 * Destroy each item. Note that because everything allocated
   1160  1.36  dholland 	 * is entered on the list separately, lists and trees need to
   1161  1.36  dholland 	 * have their links blanked before being destroyed. Also note
   1162  1.36  dholland 	 * that strings are interned elsewhere and not handled by this
   1163  1.36  dholland 	 * mechanism.
   1164  1.36  dholland 	 */
   1165  1.36  dholland 
   1166  1.31  dholland 	for (i=0; i<wrap_depth; i++) {
   1167  1.31  dholland 		switch (wrapstack[i].typecode) {
   1168  1.31  dholland 		    case WRAP_CODE_nvlist:
   1169  1.31  dholland 			nvfree(wrapstack[i].ptr);
   1170  1.31  dholland 			break;
   1171  1.37  dholland 		    case WRAP_CODE_defoptlist:
   1172  1.37  dholland 			{
   1173  1.37  dholland 				struct defoptlist *dl = wrapstack[i].ptr;
   1174  1.37  dholland 
   1175  1.37  dholland 				dl->dl_next = NULL;
   1176  1.37  dholland 				defoptlist_destroy(dl);
   1177  1.37  dholland 			}
   1178  1.37  dholland 			break;
   1179  1.36  dholland 		    case WRAP_CODE_loclist:
   1180  1.36  dholland 			{
   1181  1.36  dholland 				struct loclist *ll = wrapstack[i].ptr;
   1182  1.36  dholland 
   1183  1.36  dholland 				ll->ll_next = NULL;
   1184  1.36  dholland 				loclist_destroy(ll);
   1185  1.36  dholland 			}
   1186  1.36  dholland 			break;
   1187  1.32  dholland 		    case WRAP_CODE_attrlist:
   1188  1.32  dholland 			{
   1189  1.32  dholland 				struct attrlist *al = wrapstack[i].ptr;
   1190  1.32  dholland 
   1191  1.32  dholland 				al->al_next = NULL;
   1192  1.32  dholland 				al->al_this = NULL;
   1193  1.32  dholland 				attrlist_destroy(al);
   1194  1.32  dholland 			}
   1195  1.32  dholland 			break;
   1196  1.36  dholland 		    case WRAP_CODE_condexpr:
   1197  1.36  dholland 			{
   1198  1.36  dholland 				struct condexpr *cx = wrapstack[i].ptr;
   1199  1.36  dholland 
   1200  1.36  dholland 				cx->cx_type = CX_ATOM;
   1201  1.36  dholland 				cx->cx_atom = NULL;
   1202  1.36  dholland 				condexpr_destroy(cx);
   1203  1.36  dholland 			}
   1204  1.36  dholland 			break;
   1205  1.31  dholland 		    default:
   1206  1.31  dholland 			panic("invalid code %u on allocation wrapper stack",
   1207  1.31  dholland 			      wrapstack[i].typecode);
   1208  1.31  dholland 		}
   1209  1.31  dholland 	}
   1210  1.32  dholland 
   1211  1.31  dholland 	wrap_depth = 0;
   1212   1.1   thorpej }
   1213   1.1   thorpej 
   1214  1.31  dholland /*
   1215  1.31  dholland  * Instantiate the wrapper functions.
   1216  1.31  dholland  *
   1217  1.31  dholland  * Each one calls wrap_alloc to save the pointer and then returns the
   1218  1.31  dholland  * pointer again; these need to be generated with the preprocessor in
   1219  1.31  dholland  * order to be typesafe.
   1220  1.31  dholland  */
   1221  1.31  dholland #define DEF_ALLOCWRAP(t) \
   1222  1.31  dholland 	static struct t *				\
   1223  1.31  dholland 	wrap_mk_##t(struct t *arg)			\
   1224  1.31  dholland 	{						\
   1225  1.31  dholland 		wrap_alloc(arg, WRAP_CODE_##t);		\
   1226  1.31  dholland 		return arg;				\
   1227  1.31  dholland 	}
   1228  1.31  dholland 
   1229  1.31  dholland DEF_ALLOCWRAP(nvlist);
   1230  1.37  dholland DEF_ALLOCWRAP(defoptlist);
   1231  1.36  dholland DEF_ALLOCWRAP(loclist);
   1232  1.32  dholland DEF_ALLOCWRAP(attrlist);
   1233  1.34  dholland DEF_ALLOCWRAP(condexpr);
   1234  1.32  dholland 
   1235  1.32  dholland /************************************************************/
   1236  1.32  dholland 
   1237  1.32  dholland /*
   1238  1.32  dholland  * Data constructors
   1239  1.36  dholland  *
   1240  1.36  dholland  * (These are *beneath* the allocation wrappers.)
   1241  1.32  dholland  */
   1242  1.32  dholland 
   1243  1.37  dholland static struct defoptlist *
   1244  1.37  dholland mk_defoptlist(const char *name, const char *val, const char *lintval)
   1245  1.37  dholland {
   1246  1.37  dholland 	return defoptlist_create(name, val, lintval);
   1247  1.37  dholland }
   1248  1.37  dholland 
   1249  1.36  dholland static struct loclist *
   1250  1.36  dholland mk_loc(const char *name, const char *str, long long num)
   1251  1.36  dholland {
   1252  1.36  dholland 	return loclist_create(name, str, num);
   1253  1.36  dholland }
   1254  1.36  dholland 
   1255  1.36  dholland static struct loclist *
   1256  1.36  dholland mk_loc_val(const char *str, struct loclist *next)
   1257  1.36  dholland {
   1258  1.36  dholland 	struct loclist *ll;
   1259  1.36  dholland 
   1260  1.36  dholland 	ll = mk_loc(NULL, str, 0);
   1261  1.36  dholland 	ll->ll_next = next;
   1262  1.36  dholland 	return ll;
   1263  1.36  dholland }
   1264  1.36  dholland 
   1265  1.32  dholland static struct attrlist *
   1266  1.32  dholland mk_attrlist(struct attrlist *next, struct attr *a)
   1267  1.32  dholland {
   1268  1.32  dholland 	return attrlist_cons(next, a);
   1269  1.32  dholland }
   1270  1.31  dholland 
   1271  1.34  dholland static struct condexpr *
   1272  1.34  dholland mk_cx_atom(const char *s)
   1273  1.34  dholland {
   1274  1.34  dholland 	struct condexpr *cx;
   1275  1.34  dholland 
   1276  1.34  dholland 	cx = condexpr_create(CX_ATOM);
   1277  1.34  dholland 	cx->cx_atom = s;
   1278  1.34  dholland 	return cx;
   1279  1.34  dholland }
   1280  1.34  dholland 
   1281  1.34  dholland static struct condexpr *
   1282  1.34  dholland mk_cx_not(struct condexpr *sub)
   1283  1.34  dholland {
   1284  1.34  dholland 	struct condexpr *cx;
   1285  1.34  dholland 
   1286  1.34  dholland 	cx = condexpr_create(CX_NOT);
   1287  1.34  dholland 	cx->cx_not = sub;
   1288  1.34  dholland 	return cx;
   1289  1.34  dholland }
   1290  1.34  dholland 
   1291  1.34  dholland static struct condexpr *
   1292  1.34  dholland mk_cx_and(struct condexpr *left, struct condexpr *right)
   1293  1.34  dholland {
   1294  1.34  dholland 	struct condexpr *cx;
   1295  1.34  dholland 
   1296  1.34  dholland 	cx = condexpr_create(CX_AND);
   1297  1.34  dholland 	cx->cx_and.left = left;
   1298  1.34  dholland 	cx->cx_and.right = right;
   1299  1.34  dholland 	return cx;
   1300  1.34  dholland }
   1301  1.34  dholland 
   1302  1.34  dholland static struct condexpr *
   1303  1.34  dholland mk_cx_or(struct condexpr *left, struct condexpr *right)
   1304  1.34  dholland {
   1305  1.34  dholland 	struct condexpr *cx;
   1306  1.34  dholland 
   1307  1.34  dholland 	cx = condexpr_create(CX_OR);
   1308  1.34  dholland 	cx->cx_or.left = left;
   1309  1.34  dholland 	cx->cx_or.right = right;
   1310  1.34  dholland 	return cx;
   1311  1.34  dholland }
   1312  1.34  dholland 
   1313  1.31  dholland /************************************************************/
   1314  1.31  dholland 
   1315   1.1   thorpej static void
   1316  1.20     pooka setmachine(const char *mch, const char *mcharch, struct nvlist *mchsubarches,
   1317  1.20     pooka 	int isioconf)
   1318   1.1   thorpej {
   1319   1.1   thorpej 	char buf[MAXPATHLEN];
   1320   1.1   thorpej 	struct nvlist *nv;
   1321   1.1   thorpej 
   1322  1.20     pooka 	if (isioconf) {
   1323  1.20     pooka 		if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0)
   1324  1.20     pooka 			exit(1);
   1325  1.20     pooka 		ioconfname = mch;
   1326  1.20     pooka 		return;
   1327  1.20     pooka 	}
   1328  1.20     pooka 
   1329   1.1   thorpej 	machine = mch;
   1330   1.1   thorpej 	machinearch = mcharch;
   1331   1.1   thorpej 	machinesubarches = mchsubarches;
   1332   1.1   thorpej 
   1333   1.1   thorpej 	/*
   1334  1.14      cube 	 * Define attributes for all the given names
   1335  1.14      cube 	 */
   1336  1.15      cube 	if (defattr(machine, NULL, NULL, 0) != 0 ||
   1337  1.15      cube 	    (machinearch != NULL &&
   1338  1.15      cube 	     defattr(machinearch, NULL, NULL, 0) != 0))
   1339  1.14      cube 		exit(1);
   1340  1.14      cube 	for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
   1341  1.14      cube 		if (defattr(nv->nv_name, NULL, NULL, 0) != 0)
   1342  1.14      cube 			exit(1);
   1343  1.14      cube 	}
   1344  1.14      cube 
   1345  1.14      cube 	/*
   1346   1.1   thorpej 	 * Set up the file inclusion stack.  This empty include tells
   1347   1.1   thorpej 	 * the parser there are no more device definitions coming.
   1348   1.1   thorpej 	 */
   1349  1.20     pooka 	if (include(_PATH_DEVNULL, ENDDEFS, 0, 0) != 0)
   1350   1.1   thorpej 		exit(1);
   1351   1.1   thorpej 
   1352   1.1   thorpej 	/* Include arch/${MACHINE}/conf/files.${MACHINE} */
   1353   1.1   thorpej 	(void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s",
   1354   1.1   thorpej 	    machine, machine);
   1355   1.1   thorpej 	if (include(buf, ENDFILE, 0, 0) != 0)
   1356   1.1   thorpej 		exit(1);
   1357   1.1   thorpej 
   1358   1.1   thorpej 	/* Include any arch/${MACHINE_SUBARCH}/conf/files.${MACHINE_SUBARCH} */
   1359   1.1   thorpej 	for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
   1360   1.1   thorpej 		(void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s",
   1361   1.1   thorpej 		    nv->nv_name, nv->nv_name);
   1362   1.1   thorpej 		if (include(buf, ENDFILE, 0, 0) != 0)
   1363   1.1   thorpej 			exit(1);
   1364   1.1   thorpej 	}
   1365   1.1   thorpej 
   1366   1.1   thorpej 	/* Include any arch/${MACHINE_ARCH}/conf/files.${MACHINE_ARCH} */
   1367   1.1   thorpej 	if (machinearch != NULL)
   1368   1.1   thorpej 		(void)snprintf(buf, sizeof(buf), "arch/%s/conf/files.%s",
   1369   1.1   thorpej 		    machinearch, machinearch);
   1370   1.1   thorpej 	else
   1371   1.1   thorpej 		strlcpy(buf, _PATH_DEVNULL, sizeof(buf));
   1372   1.1   thorpej 	if (include(buf, ENDFILE, 0, 0) != 0)
   1373   1.1   thorpej 		exit(1);
   1374   1.1   thorpej 
   1375   1.1   thorpej 	/*
   1376   1.1   thorpej 	 * Include the global conf/files.  As the last thing
   1377   1.1   thorpej 	 * pushed on the stack, it will be processed first.
   1378   1.1   thorpej 	 */
   1379   1.1   thorpej 	if (include("conf/files", ENDFILE, 0, 0) != 0)
   1380   1.1   thorpej 		exit(1);
   1381   1.2    martin 
   1382   1.2    martin 	oktopackage = 1;
   1383   1.1   thorpej }
   1384   1.1   thorpej 
   1385   1.1   thorpej static void
   1386   1.1   thorpej check_maxpart(void)
   1387   1.1   thorpej {
   1388   1.1   thorpej 
   1389  1.20     pooka 	if (maxpartitions <= 0 && ioconfname == NULL) {
   1390   1.1   thorpej 		stop("cannot proceed without maxpartitions specifier");
   1391   1.1   thorpej 	}
   1392   1.1   thorpej }
   1393   1.1   thorpej 
   1394   1.1   thorpej static void
   1395   1.4      cube check_version(void)
   1396   1.4      cube {
   1397   1.4      cube 	/*
   1398   1.4      cube 	 * In essence, version is 0 and is not supported anymore
   1399   1.4      cube 	 */
   1400   1.4      cube 	if (version < CONFIG_MINVERSION)
   1401   1.4      cube 		stop("your sources are out of date -- please update.");
   1402   1.4      cube }
   1403   1.4      cube 
   1404  1.36  dholland /*
   1405  1.36  dholland  * Prepend a blank entry to the locator definitions so the code in
   1406  1.36  dholland  * sem.c can distinguish "empty locator list" from "no locator list".
   1407  1.36  dholland  * XXX gross.
   1408  1.36  dholland  */
   1409  1.36  dholland static struct loclist *
   1410  1.36  dholland present_loclist(struct loclist *ll)
   1411  1.36  dholland {
   1412  1.36  dholland 	struct loclist *ret;
   1413  1.36  dholland 
   1414  1.36  dholland 	ret = MK3(loc, "", NULL, 0);
   1415  1.36  dholland 	ret->ll_next = ll;
   1416  1.36  dholland 	return ret;
   1417  1.36  dholland }
   1418  1.36  dholland 
   1419   1.4      cube static void
   1420  1.36  dholland app(struct loclist *p, struct loclist *q)
   1421   1.1   thorpej {
   1422  1.36  dholland 	while (p->ll_next)
   1423  1.36  dholland 		p = p->ll_next;
   1424  1.36  dholland 	p->ll_next = q;
   1425   1.1   thorpej }
   1426   1.1   thorpej 
   1427  1.36  dholland static struct loclist *
   1428  1.36  dholland locarray(const char *name, int count, struct loclist *adefs, int opt)
   1429   1.1   thorpej {
   1430  1.36  dholland 	struct loclist *defs = adefs;
   1431  1.36  dholland 	struct loclist **p;
   1432   1.1   thorpej 	char buf[200];
   1433   1.1   thorpej 	int i;
   1434   1.1   thorpej 
   1435   1.1   thorpej 	if (count <= 0) {
   1436   1.1   thorpej 		fprintf(stderr, "config: array with <= 0 size: %s\n", name);
   1437   1.1   thorpej 		exit(1);
   1438   1.1   thorpej 	}
   1439   1.1   thorpej 	p = &defs;
   1440   1.1   thorpej 	for(i = 0; i < count; i++) {
   1441   1.1   thorpej 		if (*p == NULL)
   1442  1.36  dholland 			*p = MK3(loc, NULL, "0", 0);
   1443   1.1   thorpej 		snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i);
   1444  1.36  dholland 		(*p)->ll_name = i == 0 ? name : intern(buf);
   1445  1.36  dholland 		(*p)->ll_num = i > 0 || opt;
   1446  1.36  dholland 		p = &(*p)->ll_next;
   1447   1.1   thorpej 	}
   1448   1.1   thorpej 	*p = 0;
   1449   1.1   thorpej 	return defs;
   1450   1.1   thorpej }
   1451   1.1   thorpej 
   1452   1.1   thorpej 
   1453  1.36  dholland static struct loclist *
   1454  1.36  dholland namelocvals(const char *name, struct loclist *vals)
   1455   1.1   thorpej {
   1456  1.36  dholland 	struct loclist *p;
   1457   1.1   thorpej 	char buf[200];
   1458   1.1   thorpej 	int i;
   1459   1.1   thorpej 
   1460  1.36  dholland 	for (i = 0, p = vals; p; i++, p = p->ll_next) {
   1461   1.1   thorpej 		snprintf(buf, sizeof(buf), "%s%c%d", name, ARRCHR, i);
   1462  1.36  dholland 		p->ll_name = i == 0 ? name : intern(buf);
   1463   1.1   thorpej 	}
   1464   1.1   thorpej 	return vals;
   1465   1.1   thorpej }
   1466   1.1   thorpej 
   1467