2006-06-04 17:52:27 +04:00
|
|
|
/* $NetBSD: defs.h,v 1.11 2006/06/04 13:52:27 cube Exp $ */
|
1996-03-03 20:21:25 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by the Computer Systems Engineering group
|
|
|
|
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
|
|
|
* contributed to Berkeley.
|
|
|
|
*
|
|
|
|
* All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Lawrence Berkeley Laboratories.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 15:25:11 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1995-04-28 10:54:58 +04:00
|
|
|
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1996-11-08 01:59:39 +03:00
|
|
|
/*
|
2002-01-29 13:20:28 +03:00
|
|
|
* defs.h: Global definitions for "config"
|
1996-11-08 01:59:39 +03:00
|
|
|
*/
|
|
|
|
|
2003-10-27 03:12:41 +03:00
|
|
|
#if HAVE_NBTOOL_CONFIG_H
|
|
|
|
#include "nbtool_config.h"
|
2002-01-29 13:20:28 +03:00
|
|
|
#endif
|
|
|
|
|
1996-11-08 01:59:39 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
2002-06-05 14:56:17 +04:00
|
|
|
#include <sys/queue.h>
|
1996-11-08 01:59:39 +03:00
|
|
|
|
|
|
|
#if !defined(MAKE_BOOTSTRAP) && defined(BSD)
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <paths.h>
|
2000-10-02 23:48:34 +04:00
|
|
|
#endif
|
1996-11-08 01:59:39 +03:00
|
|
|
|
2001-12-17 18:39:43 +03:00
|
|
|
#include <stdio.h>
|
1996-11-08 01:59:39 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
/* These are really for MAKE_BOOTSTRAP but harmless. */
|
|
|
|
#ifndef __dead
|
|
|
|
#define __dead
|
|
|
|
#endif
|
|
|
|
#ifndef _PATH_DEVNULL
|
|
|
|
#define _PATH_DEVNULL "/dev/null"
|
|
|
|
#endif
|
|
|
|
|
1999-04-02 10:36:30 +04:00
|
|
|
#ifdef MAKE_BOOTSTRAP
|
2000-10-02 23:59:42 +04:00
|
|
|
#undef dev_t
|
|
|
|
#undef NODEV
|
1999-04-02 10:36:30 +04:00
|
|
|
#undef major
|
|
|
|
#undef minor
|
|
|
|
#undef makedev
|
2000-10-02 23:59:42 +04:00
|
|
|
#define dev_t int /* XXX: assumes int is 32 bits */
|
|
|
|
#define NODEV ((dev_t)-1)
|
|
|
|
#define major(x) ((int)((((x) & 0x000fff00) >> 8)))
|
|
|
|
#define minor(x) ((int)((((x) & 0xfff00000) >> 12) | \
|
|
|
|
(((x) & 0x000000ff) >> 0)))
|
|
|
|
#define makedev(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
|
|
|
|
(((y) << 12) & 0xfff00000) | \
|
2000-10-12 00:23:46 +04:00
|
|
|
(((y) << 0) & 0x000000ff)))
|
|
|
|
#define __attribute__(x)
|
2001-10-03 01:31:01 +04:00
|
|
|
#endif /* MAKE_BOOTSTRAP */
|
2001-02-21 02:51:59 +03:00
|
|
|
|
2001-10-03 01:31:01 +04:00
|
|
|
#undef setprogname
|
|
|
|
#undef getprogname
|
2001-02-21 02:51:59 +03:00
|
|
|
extern const char *progname;
|
|
|
|
#define setprogname(s) ((void)(progname = (s)))
|
|
|
|
#define getprogname() (progname)
|
1996-11-08 01:59:39 +03:00
|
|
|
|
1999-01-21 16:10:08 +03:00
|
|
|
#define ARRCHR '#'
|
|
|
|
|
Introduce versioning to config(1). This will allow us to provide a way to
error out in a bit more friendly way when the user is trying to use
config(1) on a too old or too recent source tree.
To achieve that, introduce the "version NUMBER" statement which can be use
about anywhere in the config files. Also, use two defines, CONFIG_VERSION
(which is the actual version of binary), and CONFIG_MINVERSION, which is
the minimum version the binary supports.
Allowing a range of versions serves several purposes: first it allows me
to introduce the versioning without requiring it to be used right away in
the kernel tree, which means it will be possible to introduce new features
of config(1) rather progressively in the future. E.g., using 'no pci' in
a config file could only require the new version in that config file, so
that the rest remains compatible.
In the end, an actual bump of the main config system (i.e., in conf/files)
will only be required when e.g., ioconf.c semantics change.
(Mostly-)silently accepted on tech-kern. Error messages turned into
correct and meaningful English thanks to Tracy and Perry.
2005-10-12 05:17:43 +04:00
|
|
|
/*
|
|
|
|
* The next two lines define the current version of the config(1) binary,
|
|
|
|
* and the minimum version of the configuration files it supports.
|
|
|
|
*/
|
2006-06-04 17:52:27 +04:00
|
|
|
#define CONFIG_VERSION 20060604
|
Introduce versioning to config(1). This will allow us to provide a way to
error out in a bit more friendly way when the user is trying to use
config(1) on a too old or too recent source tree.
To achieve that, introduce the "version NUMBER" statement which can be use
about anywhere in the config files. Also, use two defines, CONFIG_VERSION
(which is the actual version of binary), and CONFIG_MINVERSION, which is
the minimum version the binary supports.
Allowing a range of versions serves several purposes: first it allows me
to introduce the versioning without requiring it to be used right away in
the kernel tree, which means it will be possible to introduce new features
of config(1) rather progressively in the future. E.g., using 'no pci' in
a config file could only require the new version in that config file, so
that the rest remains compatible.
In the end, an actual bump of the main config system (i.e., in conf/files)
will only be required when e.g., ioconf.c semantics change.
(Mostly-)silently accepted on tech-kern. Error messages turned into
correct and meaningful English thanks to Tracy and Perry.
2005-10-12 05:17:43 +04:00
|
|
|
#define CONFIG_MINVERSION 0
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Name/value lists. Values can be strings or pointers and/or can carry
|
|
|
|
* integers. The names can be NULL, resulting in simple value lists.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist {
|
|
|
|
struct nvlist *nv_next;
|
|
|
|
const char *nv_name;
|
1993-03-21 12:45:37 +03:00
|
|
|
union {
|
1995-04-28 10:54:58 +04:00
|
|
|
const char *un_str;
|
|
|
|
void *un_ptr;
|
|
|
|
} nv_un;
|
|
|
|
#define nv_str nv_un.un_str
|
|
|
|
#define nv_ptr nv_un.un_ptr
|
|
|
|
int nv_int;
|
1997-05-25 22:42:54 +04:00
|
|
|
int nv_ifunit; /* XXX XXX XXX */
|
1999-09-22 18:23:03 +04:00
|
|
|
int nv_flags;
|
|
|
|
#define NV_DEPENDED 1
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
#define NV_OBSOLETE 2
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Kernel configurations.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct config {
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(config) cf_next;
|
2004-06-05 03:44:35 +04:00
|
|
|
const char *cf_name; /* "netbsd" */
|
1995-04-28 10:54:58 +04:00
|
|
|
int cf_lineno; /* source line */
|
1997-01-31 06:12:30 +03:00
|
|
|
const char *cf_fstype; /* file system type */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist *cf_root; /* "root on ra0a" */
|
|
|
|
struct nvlist *cf_swap; /* "swap on ra0b and ra1b" */
|
|
|
|
struct nvlist *cf_dump; /* "dumps on ra0b" */
|
|
|
|
};
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
1998-02-17 01:05:35 +03:00
|
|
|
* Attributes. These come in three flavors: "plain", "device class,"
|
|
|
|
* and "interface". Plain attributes (e.g., "ether") simply serve
|
|
|
|
* to pull in files. Device class attributes are like plain
|
|
|
|
* attributes, but additionally specify a device class (e.g., the
|
|
|
|
* "disk" device class attribute specifies that devices with the
|
|
|
|
* attribute belong to the "DV_DISK" class) and are mutually exclusive.
|
1995-04-28 10:54:58 +04:00
|
|
|
* Interface attributes (e.g., "scsi") carry three lists: locators,
|
|
|
|
* child devices, and references. The locators are those things
|
|
|
|
* that must be specified in order to configure a device instance
|
|
|
|
* using this attribute (e.g., "tg0 at scsi0"). The a_devs field
|
|
|
|
* lists child devices that can connect here (e.g., "tg"s), while
|
|
|
|
* the a_refs are parents that carry the attribute (e.g., actual
|
|
|
|
* SCSI host adapter drivers such as the SPARC "esp").
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct attr {
|
|
|
|
const char *a_name; /* name of this attribute */
|
|
|
|
int a_iattr; /* true => allows children */
|
1998-02-17 01:05:35 +03:00
|
|
|
const char *a_devclass; /* device class described */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist *a_locs; /* locators required */
|
|
|
|
int a_loclen; /* length of above list */
|
|
|
|
struct nvlist *a_devs; /* children */
|
|
|
|
struct nvlist *a_refs; /* parents */
|
2002-10-10 00:17:00 +04:00
|
|
|
struct nvlist *a_deps; /* we depend on these other attrs */
|
|
|
|
int a_expanding; /* to detect cycles in attr graph */
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
|
2002-09-26 08:07:35 +04:00
|
|
|
/*
|
|
|
|
* Parent specification. Multiple device instances may share a
|
|
|
|
* given parent spec. Parent specs are emitted only if there are
|
|
|
|
* device instances which actually reference it.
|
|
|
|
*/
|
|
|
|
struct pspec {
|
|
|
|
TAILQ_ENTRY(pspec) p_list; /* link on parent spec list */
|
|
|
|
struct attr *p_iattr; /* interface attribute of parent */
|
|
|
|
struct devbase *p_atdev; /* optional parent device base */
|
|
|
|
int p_atunit; /* optional parent device unit */
|
|
|
|
struct nvlist *p_devs; /* children using it */
|
|
|
|
int p_inst; /* parent spec instance */
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
int p_active; /* parent spec is actively used */
|
2002-09-26 08:07:35 +04:00
|
|
|
};
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/*
|
1996-03-17 05:08:22 +03:00
|
|
|
* The "base" part (struct devbase) of a device ("uba", "sd"; but not
|
|
|
|
* "uba2" or "sd0"). It may be found "at" one or more attributes,
|
|
|
|
* including "at root" (this is represented by a NULL attribute), as
|
|
|
|
* specified by the device attachments (struct deva).
|
1995-04-28 10:54:58 +04:00
|
|
|
*
|
|
|
|
* Each device may also export attributes. If any provide an output
|
|
|
|
* interface (e.g., "esp" provides "scsi"), other devices (e.g.,
|
|
|
|
* "tg"s) can be found at instances of this one (e.g., "esp"s).
|
|
|
|
* Such a connection must provide locators as specified by that
|
1996-03-17 05:08:22 +03:00
|
|
|
* interface attribute (e.g., "target"). The base device can
|
|
|
|
* export both output (aka `interface') attributes, as well as
|
|
|
|
* import input (`plain') attributes. Device attachments may
|
|
|
|
* only import input attributes; it makes no sense to have a
|
|
|
|
* specific attachment export a new interface to other devices.
|
1995-04-28 10:54:58 +04:00
|
|
|
*
|
|
|
|
* Each base carries a list of instances (via d_ihead). Note that this
|
|
|
|
* list "skips over" aliases; those must be found through the instances
|
1996-03-17 05:08:22 +03:00
|
|
|
* themselves. Each base also carries a list of possible attachments,
|
|
|
|
* each of which specify a set of devices that the device can attach
|
|
|
|
* to, as well as the device instances that are actually using that
|
|
|
|
* attachment.
|
1995-04-28 10:54:58 +04:00
|
|
|
*/
|
|
|
|
struct devbase {
|
|
|
|
const char *d_name; /* e.g., "sd" */
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(devbase) d_next;
|
1995-04-28 10:54:58 +04:00
|
|
|
int d_isdef; /* set once properly defined */
|
|
|
|
int d_ispseudo; /* is a pseudo-device */
|
|
|
|
int d_major; /* used for "root on sd0", e.g. */
|
1996-03-17 05:08:22 +03:00
|
|
|
struct nvlist *d_attrs; /* attributes, if any */
|
|
|
|
int d_umax; /* highest unit number + 1 */
|
|
|
|
struct devi *d_ihead; /* first instance, if any */
|
|
|
|
struct devi **d_ipp; /* used for tacking on more instances */
|
|
|
|
struct deva *d_ahead; /* first attachment, if any */
|
|
|
|
struct deva **d_app; /* used for tacking on attachments */
|
2001-05-18 11:48:07 +04:00
|
|
|
struct attr *d_classattr; /* device class attribute (if any) */
|
1996-03-17 05:08:22 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct deva {
|
|
|
|
const char *d_name; /* name of attachment, e.g. "com_isa" */
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(deva) d_next; /* list of all instances */
|
1996-03-17 05:08:22 +03:00
|
|
|
struct deva *d_bsame; /* list on same base */
|
|
|
|
int d_isdef; /* set once properly defined */
|
|
|
|
struct devbase *d_devbase; /* the base device */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist *d_atlist; /* e.g., "at tg" (attr list) */
|
|
|
|
struct nvlist *d_attrs; /* attributes, if any */
|
|
|
|
struct devi *d_ihead; /* first instance, if any */
|
|
|
|
struct devi **d_ipp; /* used for tacking on more instances */
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
1996-03-17 09:29:19 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* An "instance" of a device. The same instance may be listed more
|
|
|
|
* than once, e.g., "xx0 at isa? port FOO" + "xx0 at isa? port BAR".
|
|
|
|
*
|
|
|
|
* After everything has been read in and verified, the devi's are
|
|
|
|
* "packed" to collect all the information needed to generate ioconf.c.
|
|
|
|
* In particular, we try to collapse multiple aliases into a single entry.
|
|
|
|
* We then assign each "primary" (non-collapsed) instance a cfdata index.
|
|
|
|
* Note that there may still be aliases among these.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct devi {
|
|
|
|
/* created while parsing config file */
|
|
|
|
const char *i_name; /* e.g., "sd0" */
|
|
|
|
int i_unit; /* unit from name, e.g., 0 */
|
|
|
|
struct devbase *i_base;/* e.g., pointer to "sd" base */
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(devi) i_next; /* list of all instances */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct devi *i_bsame; /* list on same base */
|
1996-03-17 05:08:22 +03:00
|
|
|
struct devi *i_asame; /* list on same base attachment */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct devi *i_alias; /* other aliases of this instance */
|
|
|
|
const char *i_at; /* where this is "at" (NULL if at root) */
|
2002-09-26 08:07:35 +04:00
|
|
|
struct pspec *i_pspec; /* parent spec (NULL if at root) */
|
1996-03-17 05:08:22 +03:00
|
|
|
struct deva *i_atdeva;
|
2002-09-26 08:07:35 +04:00
|
|
|
const char **i_locs; /* locators (as given by pspec's iattr) */
|
1995-04-28 10:54:58 +04:00
|
|
|
int i_cfflags; /* flags from config line */
|
|
|
|
int i_lineno; /* line # in config, for later errors */
|
2005-10-04 16:35:00 +04:00
|
|
|
const char *i_srcfile; /* file it appears in */
|
2005-10-05 00:13:39 +04:00
|
|
|
int i_level; /* position between negated instances */
|
2005-10-02 03:30:37 +04:00
|
|
|
int i_active;
|
|
|
|
#define DEVI_ORPHAN 0 /* instance has no active parent */
|
|
|
|
#define DEVI_ACTIVE 1 /* instance has an active parent */
|
|
|
|
#define DEVI_IGNORED 2 /* instance's parent has been removed */
|
2005-10-04 17:06:45 +04:00
|
|
|
#define DEVI_BROKEN 3 /* instance is broken (syntax error) */
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* created during packing or ioconf.c generation */
|
|
|
|
short i_collapsed; /* set => this alias no longer needed */
|
|
|
|
short i_cfindex; /* our index in cfdata */
|
|
|
|
short i_locoff; /* offset in locators.vec */
|
|
|
|
|
|
|
|
};
|
|
|
|
/* special units */
|
|
|
|
#define STAR (-1) /* unit number for, e.g., "sd*" */
|
|
|
|
#define WILD (-2) /* unit number for, e.g., "sd?" */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2005-11-07 06:26:20 +03:00
|
|
|
/*
|
|
|
|
* Files or objects. This structure defines the common fields
|
|
|
|
* between the two.
|
|
|
|
*/
|
|
|
|
struct filetype
|
|
|
|
{
|
|
|
|
const char *fit_srcfile; /* the name of the "files" file that got us */
|
|
|
|
u_short fit_srcline; /* and the line number */
|
|
|
|
u_char fit_flags; /* as below */
|
|
|
|
char fit_lastc; /* last char from path */
|
|
|
|
const char *fit_path; /* full file path */
|
|
|
|
const char *fit_prefix; /* any file prefix */
|
|
|
|
};
|
|
|
|
/* Anything less than 0x10 is sub-type specific */
|
|
|
|
#define FIT_NOPROLOGUE 0x10 /* Don't prepend $S/ */
|
|
|
|
#define FIT_FORCESELECT 0x20 /* Always include this file */
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Files. Each file is either standard (always included) or optional,
|
1996-03-17 16:18:15 +03:00
|
|
|
* depending on whether it has names on which to *be* optional. The
|
|
|
|
* options field (fi_optx) is actually an expression tree, with nodes
|
|
|
|
* for OR, AND, and NOT, as well as atoms (words) representing some
|
|
|
|
* particular option. The node type is stored in the nv_int field.
|
|
|
|
* Subexpressions appear in the `next' field; for the binary operators
|
|
|
|
* AND and OR, the left subexpression is first stored in the nv_ptr field.
|
|
|
|
*
|
|
|
|
* For any file marked as needs-count or needs-flag, fixfiles() will
|
|
|
|
* build fi_optf, a `flat list' of the options with nv_int fields that
|
|
|
|
* contain counts or `need' flags; this is used in mkheaders().
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct files {
|
2005-11-07 06:26:20 +03:00
|
|
|
struct filetype fi_fit;
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(files) fi_next;
|
2005-11-07 06:26:20 +03:00
|
|
|
const char *fi_tail; /* name, i.e., strrchr(fi_path, '/') + 1 */
|
|
|
|
const char *fi_base; /* tail minus ".c" (or whatever) */
|
|
|
|
struct nvlist *fi_optx; /* options expression */
|
|
|
|
struct nvlist *fi_optf; /* flattened version of above, if needed */
|
|
|
|
const char *fi_mkrule; /* special make rule, if any */
|
1995-04-28 10:54:58 +04:00
|
|
|
};
|
2005-11-07 06:26:20 +03:00
|
|
|
#define fi_srcfile fi_fit.fit_srcfile
|
|
|
|
#define fi_srcline fi_fit.fit_srcline
|
|
|
|
#define fi_flags fi_fit.fit_flags
|
|
|
|
#define fi_lastc fi_fit.fit_lastc
|
|
|
|
#define fi_path fi_fit.fit_path
|
|
|
|
#define fi_prefix fi_fit.fit_prefix
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/* flags */
|
|
|
|
#define FI_SEL 0x01 /* selected */
|
1996-08-12 04:55:54 +04:00
|
|
|
#define FI_NEEDSCOUNT 0x02 /* needs-count */
|
|
|
|
#define FI_NEEDSFLAG 0x04 /* needs-flag */
|
|
|
|
#define FI_HIDDEN 0x08 /* obscured by other(s), base names overlap */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-10 14:27:53 +04:00
|
|
|
/*
|
|
|
|
* Objects and libraries. This allows precompiled object and library
|
|
|
|
* files (e.g. binary-only device drivers) to be linked in.
|
|
|
|
*/
|
|
|
|
struct objects {
|
2005-11-07 06:26:20 +03:00
|
|
|
struct filetype oi_fit;
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_ENTRY(objects) oi_next;
|
1997-10-10 14:27:53 +04:00
|
|
|
struct nvlist *oi_optx;/* options expression */
|
|
|
|
struct nvlist *oi_optf;/* flattened version of above, if needed */
|
|
|
|
};
|
2005-11-07 06:26:20 +03:00
|
|
|
|
|
|
|
#define oi_srcfile oi_fit.fit_srcfile
|
|
|
|
#define oi_srcline oi_fit.fit_srcline
|
|
|
|
#define oi_flags oi_fit.fit_flags
|
|
|
|
#define oi_lastc oi_fit.fit_lastc
|
|
|
|
#define oi_path oi_fit.fit_path
|
|
|
|
#define oi_prefix oi_fit.fit_prefix
|
|
|
|
|
1997-10-10 14:27:53 +04:00
|
|
|
/* flags */
|
|
|
|
#define OI_SEL 0x01 /* selected */
|
|
|
|
#define OI_NEEDSFLAG 0x02 /* needs-flag */
|
|
|
|
|
|
|
|
#define FX_ATOM 0 /* atom (in nv_name) */
|
|
|
|
#define FX_NOT 1 /* NOT expr (subexpression in nv_next) */
|
|
|
|
#define FX_AND 2 /* AND expr (lhs in nv_ptr, rhs in nv_next) */
|
|
|
|
#define FX_OR 3 /* OR expr (lhs in nv_ptr, rhs in nv_next) */
|
|
|
|
|
1999-07-09 10:44:58 +04:00
|
|
|
/*
|
|
|
|
* File/object prefixes. These are arranged in a stack, and affect
|
|
|
|
* the behavior of the source path.
|
|
|
|
*/
|
|
|
|
struct prefix {
|
2002-06-05 14:56:17 +04:00
|
|
|
SLIST_ENTRY(prefix) pf_next; /* next prefix in stack */
|
|
|
|
const char *pf_prefix; /* the actual prefix */
|
1999-07-09 10:44:58 +04:00
|
|
|
};
|
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
/*
|
|
|
|
* Device major informations.
|
|
|
|
*/
|
|
|
|
struct devm {
|
|
|
|
TAILQ_ENTRY(devm) dm_next;
|
|
|
|
const char *dm_srcfile; /* the name of the "majors" file */
|
|
|
|
u_short dm_srcline; /* the line number */
|
|
|
|
const char *dm_name; /* [bc]devsw name */
|
|
|
|
int dm_cmajor; /* character major */
|
|
|
|
int dm_bmajor; /* block major */
|
|
|
|
struct nvlist *dm_opts; /* options */
|
|
|
|
};
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-28 10:54:58 +04:00
|
|
|
* Hash tables look up name=value pairs. The pointer value of the name
|
|
|
|
* is assumed to be constant forever; this can be arranged by interning
|
|
|
|
* the name. (This is fairly convenient since our lexer does this for
|
|
|
|
* all identifier-like strings---it has to save them anyway, lest yacc's
|
|
|
|
* look-ahead wipe out the current one.)
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
1995-04-28 10:54:58 +04:00
|
|
|
struct hashtab;
|
|
|
|
|
2005-11-07 06:26:20 +03:00
|
|
|
int lkmmode;
|
1995-04-28 10:54:58 +04:00
|
|
|
const char *conffile; /* source file, e.g., "GENERIC.sparc" */
|
|
|
|
const char *machine; /* machine type, e.g., "sparc" or "sun3" */
|
|
|
|
const char *machinearch; /* machine arch, e.g., "sparc" or "m68k" */
|
2001-06-08 16:47:06 +04:00
|
|
|
struct nvlist *machinesubarches;
|
|
|
|
/* machine subarches, e.g., "sun68k" or "hpc" */
|
1996-09-01 00:58:16 +04:00
|
|
|
const char *srcdir; /* path to source directory (rel. to build) */
|
|
|
|
const char *builddir; /* path to build directory */
|
|
|
|
const char *defbuilddir; /* default build directory */
|
2000-01-24 02:37:42 +03:00
|
|
|
const char *ident; /* kernel "ident"ification string */
|
1995-04-28 10:54:58 +04:00
|
|
|
int errors; /* counts calls to error() */
|
|
|
|
int minmaxusers; /* minimum "maxusers" parameter */
|
|
|
|
int defmaxusers; /* default "maxusers" parameter */
|
|
|
|
int maxmaxusers; /* default "maxusers" parameter */
|
|
|
|
int maxusers; /* configuration's "maxusers" parameter */
|
|
|
|
int maxpartitions; /* configuration's "maxpartitions" parameter */
|
Introduce versioning to config(1). This will allow us to provide a way to
error out in a bit more friendly way when the user is trying to use
config(1) on a too old or too recent source tree.
To achieve that, introduce the "version NUMBER" statement which can be use
about anywhere in the config files. Also, use two defines, CONFIG_VERSION
(which is the actual version of binary), and CONFIG_MINVERSION, which is
the minimum version the binary supports.
Allowing a range of versions serves several purposes: first it allows me
to introduce the versioning without requiring it to be used right away in
the kernel tree, which means it will be possible to introduce new features
of config(1) rather progressively in the future. E.g., using 'no pci' in
a config file could only require the new version in that config file, so
that the rest remains compatible.
In the end, an actual bump of the main config system (i.e., in conf/files)
will only be required when e.g., ioconf.c semantics change.
(Mostly-)silently accepted on tech-kern. Error messages turned into
correct and meaningful English thanks to Tracy and Perry.
2005-10-12 05:17:43 +04:00
|
|
|
int version; /* version of the configuration file */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist *options; /* options */
|
1997-01-31 06:12:30 +03:00
|
|
|
struct nvlist *fsoptions; /* filesystems */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct nvlist *mkoptions; /* makeoptions */
|
2004-06-04 08:38:27 +04:00
|
|
|
struct nvlist *appmkoptions; /* appending mkoptions */
|
2004-06-04 11:28:26 +04:00
|
|
|
struct hashtab *condmkopttab; /* conditional makeoption table */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct hashtab *devbasetab; /* devbase lookup */
|
Rework the way orphan device instances are handled. To achieve that, keep
track of instances attaching at root, and walk down the tree of active
device instances. Then, all instances that are not marked active are
found as orphans.
Doing it that way allows us to simply ignore orphan devices, instead of
warning about them and still keep them in the configuration. Now, orphaned
instances are considered as never having existed.
In the end, this allows 'no <device> at <attachment>' to be much more
efficient, as the user doesn't have to negate all descendents of the
instance s/he actually wants to negate. Warnings are still emitted,
though.
While there, make official a side-effect of the previous lack of action
against orphaned instances: config(1) used to warn about instances that
attach at a numbered device when no instance of that device with that
number existed, even though there was a starred instance of the device.
E.g. (provided by Alan Barrett):
pciide* at pci? dev ? function ? flags 0x0000
wdc0 at isa? port 0x1f0 irq 14 flags 0x00
wdc1 at isa? port 0x170 irq 15 flags 0x00
atabus* at ata?
wd0 at atabus0 drive 0
With this commit, config(1) will no longer warn about 'wd0 at atabus0'.
2005-10-01 02:36:20 +04:00
|
|
|
struct hashtab *devroottab; /* attach at root lookup */
|
1996-03-17 05:08:22 +03:00
|
|
|
struct hashtab *devatab; /* devbase attachment lookup */
|
2003-01-27 08:00:54 +03:00
|
|
|
struct hashtab *devitab; /* device instance lookup */
|
2005-10-02 03:30:37 +04:00
|
|
|
struct hashtab *deaddevitab; /* removed instances lookup */
|
1995-04-28 10:54:58 +04:00
|
|
|
struct hashtab *selecttab; /* selects things that are "optional foo" */
|
|
|
|
struct hashtab *needcnttab; /* retains names marked "needs-count" */
|
1997-02-03 00:12:30 +03:00
|
|
|
struct hashtab *opttab; /* table of configured options */
|
1997-01-31 06:12:30 +03:00
|
|
|
struct hashtab *fsopttab; /* table of configured file systems */
|
1997-02-03 00:12:30 +03:00
|
|
|
struct hashtab *defopttab; /* options that have been "defopt"'d */
|
1998-06-24 15:20:54 +04:00
|
|
|
struct hashtab *defflagtab; /* options that have been "defflag"'d */
|
|
|
|
struct hashtab *defparamtab; /* options that have been "defparam"'d */
|
1998-02-19 03:27:00 +03:00
|
|
|
struct hashtab *deffstab; /* defined file systems */
|
1998-01-12 10:37:40 +03:00
|
|
|
struct hashtab *optfiletab; /* "defopt"'d option .h files */
|
1997-03-14 03:14:09 +03:00
|
|
|
struct hashtab *attrtab; /* attributes (locators, etc.) */
|
2002-09-06 17:18:43 +04:00
|
|
|
struct hashtab *bdevmtab; /* block devm lookup */
|
|
|
|
struct hashtab *cdevmtab; /* character devm lookup */
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_HEAD(, devbase) allbases; /* list of all devbase structures */
|
|
|
|
TAILQ_HEAD(, deva) alldevas; /* list of all devbase attachments */
|
|
|
|
TAILQ_HEAD(, config) allcf; /* list of configured kernels */
|
|
|
|
TAILQ_HEAD(, devi) alldevi, /* list of all instances */
|
|
|
|
allpseudo; /* list of all pseudo-devices */
|
2002-09-06 17:18:43 +04:00
|
|
|
TAILQ_HEAD(, devm) alldevms; /* list of all device-majors */
|
2002-09-26 08:07:35 +04:00
|
|
|
TAILQ_HEAD(, pspec) allpspecs; /* list of all parent specs */
|
2002-06-05 14:56:17 +04:00
|
|
|
int ndevi; /* number of devi's (before packing) */
|
2002-09-26 08:07:35 +04:00
|
|
|
int npspecs; /* number of parent specs */
|
2002-09-06 17:18:43 +04:00
|
|
|
int maxbdevm; /* max number of block major */
|
|
|
|
int maxcdevm; /* max number of character major */
|
2002-09-11 10:20:09 +04:00
|
|
|
int do_devsw; /* 0 if pre-devsw config */
|
2005-09-10 19:38:46 +04:00
|
|
|
int oktopackage; /* 0 before setmachine() */
|
2005-10-05 00:13:39 +04:00
|
|
|
int devilevel; /* used for devi->i_level */
|
1995-04-28 10:54:58 +04:00
|
|
|
|
2002-06-05 14:56:17 +04:00
|
|
|
TAILQ_HEAD(, files) allfiles; /* list of all kernel source files */
|
|
|
|
TAILQ_HEAD(, objects) allobjects; /* list of all kernel object and
|
|
|
|
library files */
|
|
|
|
|
|
|
|
SLIST_HEAD(, prefix) prefixes, /* prefix stack */
|
|
|
|
allprefixes; /* all prefixes used (after popped) */
|
2003-09-03 22:56:37 +04:00
|
|
|
SLIST_HEAD(, prefix) curdirs; /* curdir stack */
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
struct devi **packed; /* arrayified table for packed devi's */
|
|
|
|
int npacked; /* size of packed table, <= ndevi */
|
|
|
|
|
|
|
|
struct { /* loc[] table for config */
|
|
|
|
const char **vec;
|
|
|
|
int used;
|
|
|
|
} locators;
|
|
|
|
|
2003-11-19 21:06:13 +03:00
|
|
|
struct numconst {
|
|
|
|
int64_t val;
|
|
|
|
int fmt;
|
|
|
|
};
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/* files.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
void initfiles(void);
|
|
|
|
void checkfiles(void);
|
|
|
|
int fixfiles(void); /* finalize */
|
|
|
|
int fixobjects(void);
|
2002-09-06 17:18:43 +04:00
|
|
|
int fixdevsw(void);
|
2000-10-02 23:48:34 +04:00
|
|
|
void addfile(const char *, struct nvlist *, int, const char *);
|
|
|
|
void addobject(const char *, struct nvlist *, int);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* hash.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
struct hashtab *ht_new(void);
|
|
|
|
int ht_insrep(struct hashtab *, const char *, void *, int);
|
1995-04-28 10:54:58 +04:00
|
|
|
#define ht_insert(ht, nam, val) ht_insrep(ht, nam, val, 0)
|
|
|
|
#define ht_replace(ht, nam, val) ht_insrep(ht, nam, val, 1)
|
2002-06-05 14:56:17 +04:00
|
|
|
int ht_remove(struct hashtab *, const char *);
|
2000-10-02 23:48:34 +04:00
|
|
|
void *ht_lookup(struct hashtab *, const char *);
|
|
|
|
void initintern(void);
|
|
|
|
const char *intern(const char *);
|
|
|
|
typedef int (*ht_callback)(const char *, void *, void *);
|
|
|
|
int ht_enumerate(struct hashtab *, ht_callback, void *);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* main.c */
|
2002-06-05 14:56:17 +04:00
|
|
|
void addoption(const char *, const char *);
|
|
|
|
void addfsoption(const char *);
|
|
|
|
void addmkoption(const char *, const char *);
|
2004-06-04 08:38:27 +04:00
|
|
|
void appendmkoption(const char *, const char *);
|
2004-06-04 11:28:26 +04:00
|
|
|
void appendcondmkoption(const char *, const char *, const char *);
|
2002-06-05 14:56:17 +04:00
|
|
|
void deffilesystem(const char *, struct nvlist *);
|
|
|
|
void defoption(const char *, struct nvlist *, struct nvlist *);
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
void defflag(const char *, struct nvlist *, struct nvlist *, int);
|
|
|
|
void defparam(const char *, struct nvlist *, struct nvlist *, int);
|
2002-06-05 14:56:17 +04:00
|
|
|
void deloption(const char *);
|
|
|
|
void delfsoption(const char *);
|
|
|
|
void delmkoption(const char *);
|
2000-10-02 23:48:34 +04:00
|
|
|
int devbase_has_instances(struct devbase *, int);
|
2002-06-05 14:56:17 +04:00
|
|
|
struct nvlist * find_declared_option(const char *);
|
2000-10-02 23:48:34 +04:00
|
|
|
int deva_has_instances(struct deva *, int);
|
|
|
|
void setupdirs(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
1998-06-30 07:30:56 +04:00
|
|
|
/* tests on option types */
|
|
|
|
#define OPT_FSOPT(n) (ht_lookup(deffstab, (n)) != NULL)
|
|
|
|
#define OPT_DEFOPT(n) (ht_lookup(defopttab, (n)) != NULL)
|
|
|
|
#define OPT_DEFFLAG(n) (ht_lookup(defflagtab, (n)) != NULL)
|
|
|
|
#define OPT_DEFPARAM(n) (ht_lookup(defparamtab, (n)) != NULL)
|
Introduce two new statements:
obsolete defflag <option> [, <option> [, ...]]
obsolete defparam <option> [, <option> [, ...]]
The two statements actually do the same thing (there could be only one),
but it makes things less cryptic that way. The optional ": deps" part of
a 'defflag' or 'defparam' still has to be dropped when it gets obsoleted.
When the user has 'options OBSOLETE_OPTION' in his configuration file, it
is ignored (that is, opt_*.h files are generated as if it wasn't there),
and the user gets a warning about it.
Bump version to 20060525.
When someone first uses that syntax in the tree, a "version 20060525"
statement should be added before its occurrence, preferably at the top
of sys/conf/files.
Suggested by Matt Thomas a few months ago.
2006-05-26 02:28:38 +04:00
|
|
|
#define OPT_OBSOLETE(n) (ht_lookup(obsopttab, (n)) != NULL)
|
1998-06-30 07:30:56 +04:00
|
|
|
#define DEFINED_OPTION(n) (find_declared_option((n)) != NULL)
|
|
|
|
|
2001-12-17 18:39:43 +03:00
|
|
|
/* main.c */
|
|
|
|
void logconfig_include(FILE *, const char *);
|
1998-06-30 07:30:56 +04:00
|
|
|
|
2002-09-06 17:18:43 +04:00
|
|
|
/* mkdevsw.c */
|
|
|
|
int mkdevsw(void);
|
|
|
|
|
1995-04-28 10:54:58 +04:00
|
|
|
/* mkheaders.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
int mkheaders(void);
|
2002-02-13 02:20:11 +03:00
|
|
|
int moveifchanged(const char *, const char *);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* mkioconf.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
int mkioconf(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* mkmakefile.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
int mkmakefile(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* mkswap.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
int mkswap(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* pack.c */
|
2000-10-02 23:48:34 +04:00
|
|
|
void pack(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* scan.l */
|
2000-10-02 23:48:34 +04:00
|
|
|
int currentline(void);
|
|
|
|
int firstfile(const char *);
|
2002-11-18 02:36:19 +03:00
|
|
|
void package(const char *);
|
2001-12-17 18:39:43 +03:00
|
|
|
int include(const char *, int, int, int);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* sem.c, other than for yacc actions */
|
2000-10-02 23:48:34 +04:00
|
|
|
void initsem(void);
|
1995-04-28 10:54:58 +04:00
|
|
|
|
|
|
|
/* util.c */
|
2003-11-25 00:44:37 +03:00
|
|
|
void *ecalloc(size_t, size_t);
|
2000-10-02 23:48:34 +04:00
|
|
|
void *emalloc(size_t);
|
|
|
|
void *erealloc(void *, size_t);
|
|
|
|
char *estrdup(const char *);
|
|
|
|
void prefix_push(const char *);
|
|
|
|
void prefix_pop(void);
|
|
|
|
char *sourcepath(const char *);
|
2000-10-12 00:23:46 +04:00
|
|
|
void warn(const char *, ...) /* immediate warns */
|
|
|
|
__attribute__((__format__(__printf__, 1, 2)));
|
2005-10-04 16:35:00 +04:00
|
|
|
void xwarn(const char *, int, const char *, ...) /* delayed warns */
|
|
|
|
__attribute__((__format__(__printf__, 3, 4)));
|
2000-10-12 00:23:46 +04:00
|
|
|
void error(const char *, ...) /* immediate errs */
|
|
|
|
__attribute__((__format__(__printf__, 1, 2)));
|
|
|
|
void xerror(const char *, int, const char *, ...) /* delayed errs */
|
|
|
|
__attribute__((__format__(__printf__, 3, 4)));
|
|
|
|
__dead void panic(const char *, ...)
|
|
|
|
__attribute__((__format__(__printf__, 1, 2)));
|
2000-10-02 23:48:34 +04:00
|
|
|
struct nvlist *newnv(const char *, const char *, void *, int, struct nvlist *);
|
|
|
|
void nvfree(struct nvlist *);
|
|
|
|
void nvfreel(struct nvlist *);
|
1997-10-18 11:58:56 +04:00
|
|
|
|
|
|
|
/* liby */
|
2000-10-02 23:48:34 +04:00
|
|
|
void yyerror(const char *);
|
|
|
|
int yylex(void);
|