NetBSD/share/man/man9/config.9

365 lines
12 KiB
Groff
Raw Normal View History

.\" $NetBSD: config.9,v 1.23 2005/07/07 20:57:27 snj Exp $
2001-07-01 08:11:13 +04:00
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Gregory McGarry.
.\"
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the NetBSD
.\" Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\" contributors may be used to endorse or promote products derived
.\" from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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
2001-09-04 06:51:15 +04:00
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2001-07-01 08:11:13 +04:00
.\" 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.
.\"
.Dd August 19, 2003
2001-07-01 08:11:13 +04:00
.Dt CONFIG 9
.Os
.Sh NAME
.Nm config
.Nd the autoconfiguration framework
.Do
device definition
.Dc
language
.Sh DESCRIPTION
In
.Nx ,
the
.Xr config 1
2001-07-01 08:11:13 +04:00
program reads and verifies a machine description file specifying the
2002-10-14 17:43:14 +04:00
devices to include in the kernel.
A table is produced by
.Xr config 1
2001-07-01 08:11:13 +04:00
which is used by the kernel during autoconfiguration (see
.Xr autoconf 9 )
giving needed hints and details on matching hardware devices with
device drivers.
.Pp
Each device in the machine description file has:
.Bl -tag -width xxxxxx
.It A Name
The name is simply an alphanumeric string that ends in a unit number
2002-10-14 17:43:14 +04:00
(e.g., "sd0", "sd1", and so forth).
These unit numbers identify particular instances of a base device name;
the base name in turn maps directly to a device driver.
Device unit numbers are independent of hardware features.
2001-07-01 08:11:13 +04:00
.It A Parent
2002-10-14 17:43:14 +04:00
Every device must have a parent.
The pairing is denoted by "child at parent".
These pairings form the links in a directed graph.
The root device is the only exception, as it does not have a parent.
2001-07-01 08:11:13 +04:00
.It Locators
2004-04-11 20:33:02 +04:00
Locators are used to augment the parent/child pairings that locate
2002-10-14 17:43:14 +04:00
specific devices.
Each locator value is simply an integer that represents some sort of
device address on the parent bus or controller.
2004-04-11 20:33:02 +04:00
This can be a memory address, an I/O port, a driver number, or any
2002-10-14 17:43:14 +04:00
other value.
Locators can sometimes be wildcarded on devices that support direct
connection.
2001-07-01 08:11:13 +04:00
.It Attributes
An attribute describes the device's relationship with the code; it
2002-10-14 17:43:14 +04:00
then serves to constrain the device graph.
A
2001-07-01 08:11:13 +04:00
.Em plain attribute
2002-10-14 17:43:14 +04:00
describes some attribute of a device.
An
2001-07-01 08:11:13 +04:00
.Em interface attribute
describes a kind of
.Do
software interface
.Dc
2003-04-06 22:22:56 +04:00
and declares the device's ability to support other devices that use
2002-10-14 17:43:14 +04:00
that interface.
In addition, an interface attribute usually identifies additional locators.
2001-07-01 08:11:13 +04:00
.El
.Pp
During autoconfiguration, the directed graph is turned into a tree by
nominating one device as the root node and matching drivers with
2002-03-24 01:36:45 +03:00
devices by doing a depth-first traversal through the graph starting at
2001-07-01 08:11:13 +04:00
this root node.
.Pp
However, there must be constraints on the parent/child pairings that
2002-10-14 17:43:14 +04:00
are possible.
These constraints are embedded in the
2001-07-01 08:11:13 +04:00
.Do
device definition
.Dc
2002-10-14 17:43:14 +04:00
files.
The remainder of this page describes the
2001-07-01 08:11:13 +04:00
.Do
device definition
.Dc
language and how to use this language to add new functionality to the
.Nx
kernel.
.Sh DEVICE DEFINITION FILES
The device definition files are separated into machine-dependent and
2002-10-14 17:43:14 +04:00
machine-independent files.
The machine-dependent file is located in
.Pa sys/arch/\*[Lt]arch\*[Gt]/conf/files.\*[Lt]arch\*[Gt] ,
where \*[Lt]arch\*[Gt] is the name of
2001-07-01 08:11:13 +04:00
.Nx
2002-10-14 17:43:14 +04:00
architecture.
The machine-independent file is located in
2001-07-01 08:11:13 +04:00
.Pa sys/conf/files .
It in turn includes files for the machine-independent drivers located
in
.Pa sys/dev/\*[Lt]bus\*[Gt]/files.\*[Lt]bus\*[Gt] ,
where \*[Lt]bus\*[Gt] is the name of the machine-independent bus.
2001-07-01 08:11:13 +04:00
.Pp
2002-10-14 17:43:14 +04:00
These files define all legal devices and pseudo-devices.
They also define all attributes and interfaces, establishing the rules that
2001-07-01 08:11:13 +04:00
determine allowable machine descriptions, and list the source files
that make up the kernel.
.Pp
Each device definition file consists of a list of statements,
2002-10-14 17:43:14 +04:00
typically one per line.
Comments may be inserted anywhere using the
2001-07-01 08:11:13 +04:00
.Do
#
.Dc
character, and any line that begins with white space continues the
2002-10-14 17:43:14 +04:00
previous line.
Valid statements are:
2001-07-01 08:11:13 +04:00
.Bl -tag -width xxxxxx
.It cinclude filename
Conditionally include contents of file
.Ar filename
2003-08-24 02:25:03 +04:00
to currently processed configuration.
If the specified
.Ar filename
doesn't exist, a warning is printed, but the error
ignored.
.It defflag [filename] {options}
The space-separated list of pre-processor macros
.Em options
are defined in file
.Em filename .
This statement permits ``options FOO'' for FOO (i.e, without a value)
in the machine description file.
.Xr config 1
2002-10-14 17:43:14 +04:00
will generate an error if a value is given.
If the filename field is not specified, it will be constructed based upon
the lower-case of the option name, ``opt_foo.h'' for example.
The
.Em option
is case-sensitive.
.It defparam [filename] {options}
The space-separated list of pre-processor macros
.Em options
are defined in file
.Em filename .
This statement permits ``options FOO=bar'' or ``option FOO="\\"com\\""''
in the machine description file.
.Xr config 1
2002-10-14 17:43:14 +04:00
will generate an error if a value is not given.
If the filename field is not specified, it will be constructed based upon
the lower-case of the option name, ``opt_foo.h'' for example.
The
.Em option
is case-sensitive.
2001-07-01 08:11:13 +04:00
.It defopt [filename] {options}
The space-separated list of pre-processor macros
.Em options
are defined in file
.Em filename .
This statement permits the syntax of either the defflag and defparam
statements and
.Xr config 1
does not perform any checking of whether ``options FOO'' takes a
2002-10-14 17:43:14 +04:00
value.
Therefore, the use of the defopt statement is deprecated in
favour of the defflag and defparam statements.
If the filename field is not specified, it will be constructed based upon
the lower-case of the option name, ``opt_foo.h'' for example.
2001-07-01 08:11:13 +04:00
The
.Em option
is case-sensitive.
.It deffs [filename] name
Define a filesystem
.Em name .
.It devclass name
Define a device class
.Em name .
A device class is similar to an attribute.
.It define name [{locators}]
The attribute
.Em name
2002-10-14 17:43:14 +04:00
is defined and device definitions can then refer to it.
If the attribute is an interface attribute and defines optional
2001-07-01 08:11:13 +04:00
.Em locators ,
device attributes that refer to
.Em name
are assumed to share the interface and require the same locators.
.It device name [{locators}]: [attributes]
The device
.Em name
is defined and requires the optional comma-separated list of locators
.Em locators .
The optional
.Em attributes
define attribute dependencies.
.It attach name at interface [with ifname]: [attributes]
The device
.Em name
is defined and supports the interface
.Em interface .
If
.Em ifname
is specified, it is used to specify the interface to the driver for
device
.Em name
(see
.Xr driver 9
for details).
The optional
.Em attributes
define attribute dependencies.
.It defpseudo name: [{locators}]
The pseudo-device
.Em name
2002-10-14 17:43:14 +04:00
is defined.
The optional
2001-07-01 08:11:13 +04:00
.Em locators
may be defined, but are largely pointless since no device can attach
to a pseudo-device.
.It file pathname [attributes [flags]] [rule]
The file
.Em pathname
2002-10-14 17:43:14 +04:00
is added to the list of files used to build the kernel.
If no attributes are specified, the file is always added to the kernel
compilation.
If any of the attributes are specified by other devices in the machine
description file, then the file is included in compilation, otherwise it
2002-10-14 17:43:14 +04:00
is omitted.
Valid values for the optional flags are:
2001-07-01 08:11:13 +04:00
.Bl -tag -width xxxxxx
.It needs-count
Specify that config should generate a file for each of the attributes
notifying the driver how many of some particular device or set of
2002-10-14 17:43:14 +04:00
devices are configured in the kernel.
This flag allows drivers to make calculations of driver used at compile time.
2001-07-01 08:11:13 +04:00
This option prevents autoconfiguration cloning.
.It needs-flag
2002-03-24 01:36:45 +03:00
This flag performs the same operation as
2001-07-01 08:11:13 +04:00
.Em needs-count
2002-10-14 17:43:14 +04:00
but only records if the number is nonzero.
Since the count is not exact,
2001-07-01 08:11:13 +04:00
.Em needs-flag
does not prevent autoconfiguration cloning.
.El
.It device-major name char [block] [attributes]
The character device switch
.Em name
associated with a character major device number is added to the list of
2002-10-14 17:43:14 +04:00
device switches used to build the kernel.
If
.Em block
is specified, the block device switch associated with a block major device
2002-10-14 17:43:14 +04:00
number is also added.
If all of attributes are specified by devices in the machine description
files, then device switches are added into the device switches' table of
the kernel in compilation, otherwise they are omitted.
.It include Ar filename
Include contents of file
.Ar filename
2003-08-24 02:25:03 +04:00
to currently processed configuration.
If the specified
.Ar filename
2004-12-15 18:37:01 +03:00
doesn't exist,
.Xr config 1
exits with error.
.It package Ar filename
Changes prefix to directory of
.Ar filename ,
processes contents of
2004-09-02 15:33:24 +04:00
.Ar filename ,
2003-08-24 02:25:03 +04:00
and switches back to previous prefix.
This is syntactic sugar for:
.Bl -tag -compact -offset indent
.It prefix Ar dirname(filename)
.It include Ar basename(filename)
.It prefix
.El
.It prefix Op Ar dirname
If
.Ar dirname
2003-08-24 02:25:03 +04:00
is specified, it is pushed on top of prefix stack.
Any further files specified via option
.Ar file
would have the prefix implicitly prepended before its
.Ar filename .
If
.Ar dirname
is not specified, pops (removes) a prefix from prefix stack.
2001-07-01 08:11:13 +04:00
.El
.Pp
To allow locators to be wildcarded in the machine description file,
2002-10-14 17:43:14 +04:00
their default value must be defined in the attribute definition.
To allow locators to be omitted entirely in the machine description file,
enclose the locator in square brackets.
This can be used when some locators do not make sense for some devices,
but the software interface requires them.
2001-07-01 08:11:13 +04:00
.Sh CODE REFERENCES
This section describes places within the
.Nx
source tree where actual code implementing or using the
2002-10-14 17:43:14 +04:00
autoconfiguration framework can be found.
All pathnames are relative to
2001-07-01 08:11:13 +04:00
.Pa /usr/src .
.Pp
The device definition files are in
.Pa sys/conf/files ,
.Pa sys/arch/\*[Lt]arch\*[Gt]/conf/files.\*[Lt]arch\*[Gt] ,
2001-07-01 08:11:13 +04:00
and
.Pa sys/dev/\*[Lt]bus\*[Gt]/files.\*[Lt]bus\*[Gt] .
2001-07-01 08:11:13 +04:00
.Pp
The grammar for machine description files can be found in
.Xr config 1 ,
2001-07-01 08:11:13 +04:00
in
.Pa usr.bin/config/gram.y .
2001-07-01 08:11:13 +04:00
.Sh SEE ALSO
.Xr config 1 ,
2001-12-26 03:16:30 +03:00
.Xr autoconf 9 ,
.Xr driver 9
2001-07-01 08:11:13 +04:00
.Rs
.%T "Building 4.4 BSD Systems with Config"
.Re
.Rs
.%A Chris Torek
.%T "Device Configuration in 4.4BSD"
.%D 1992
.Re
.Sh HISTORY
Autoconfiguration first appeared in
.Bx 4.1 .
The autoconfiguration framework was completely revised in
.Bx 4.4 .
It has been modified within
.Nx
to support bus-independent drivers and bus-dependent attachments.