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