1*01869ca4Swiz.\" $NetBSD: config.9,v 1.30 2017/07/03 21:28:48 wiz Exp $ 28752c231Sgmcgarry.\" 38752c231Sgmcgarry.\" Copyright (c) 2001 The NetBSD Foundation, Inc. 48752c231Sgmcgarry.\" All rights reserved. 58752c231Sgmcgarry.\" 68752c231Sgmcgarry.\" This code is derived from software contributed to The NetBSD Foundation 78752c231Sgmcgarry.\" by Gregory McGarry. 88752c231Sgmcgarry.\" 98752c231Sgmcgarry.\" Redistribution and use in source and binary forms, with or without 108752c231Sgmcgarry.\" modification, are permitted provided that the following conditions 118752c231Sgmcgarry.\" are met: 128752c231Sgmcgarry.\" 1. Redistributions of source code must retain the above copyright 138752c231Sgmcgarry.\" notice, this list of conditions and the following disclaimer. 148752c231Sgmcgarry.\" 2. Redistributions in binary form must reproduce the above copyright 158752c231Sgmcgarry.\" notice, this list of conditions and the following disclaimer in the 168752c231Sgmcgarry.\" documentation and/or other materials provided with the distribution. 178752c231Sgmcgarry.\" 188752c231Sgmcgarry.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 198752c231Sgmcgarry.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 208752c231Sgmcgarry.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 218752c231Sgmcgarry.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 228752c231Sgmcgarry.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 238752c231Sgmcgarry.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 248752c231Sgmcgarry.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 258752c231Sgmcgarry.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 268752c231Sgmcgarry.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 278752c231Sgmcgarry.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 288752c231Sgmcgarry.\" POSSIBILITY OF SUCH DAMAGE. 298752c231Sgmcgarry.\" 308a20bde1Spooka.Dd March 3, 2010 318752c231Sgmcgarry.Dt CONFIG 9 328752c231Sgmcgarry.Os 338752c231Sgmcgarry.Sh NAME 348752c231Sgmcgarry.Nm config 358752c231Sgmcgarry.Nd the autoconfiguration framework 368752c231Sgmcgarry.Do 378752c231Sgmcgarrydevice definition 388752c231Sgmcgarry.Dc 398752c231Sgmcgarrylanguage 408752c231Sgmcgarry.Sh DESCRIPTION 418752c231SgmcgarryIn 428752c231Sgmcgarry.Nx , 438752c231Sgmcgarrythe 44a9b411c1Speter.Xr config 1 45494da5efSperryprogram reads and verifies a machine description file (documented in 46494da5efSperry.Xr config 5 ) 47494da5efSperrythat specifies the devices to include in the kernel. 48770eef21SwizA table is produced by 49a9b411c1Speter.Xr config 1 508752c231Sgmcgarrywhich is used by the kernel during autoconfiguration (see 518752c231Sgmcgarry.Xr autoconf 9 ) 528752c231Sgmcgarrygiving needed hints and details on matching hardware devices with 538752c231Sgmcgarrydevice drivers. 548752c231Sgmcgarry.Pp 558752c231SgmcgarryEach device in the machine description file has: 568752c231Sgmcgarry.Bl -tag -width xxxxxx 578752c231Sgmcgarry.It A Name 588752c231SgmcgarryThe name is simply an alphanumeric string that ends in a unit number 59770eef21Swiz(e.g., "sd0", "sd1", and so forth). 60770eef21SwizThese unit numbers identify particular instances of a base device name; 61770eef21Swizthe base name in turn maps directly to a device driver. 62770eef21SwizDevice unit numbers are independent of hardware features. 638752c231Sgmcgarry.It A Parent 64770eef21SwizEvery device must have a parent. 65770eef21SwizThe pairing is denoted by "child at parent". 66770eef21SwizThese pairings form the links in a directed graph. 67770eef21SwizThe root device is the only exception, as it does not have a parent. 688752c231Sgmcgarry.It Locators 691f2cde04SfredbLocators are used to augment the parent/child pairings that locate 70770eef21Swizspecific devices. 71770eef21SwizEach locator value is simply an integer that represents some sort of 72770eef21Swizdevice address on the parent bus or controller. 731f2cde04SfredbThis can be a memory address, an I/O port, a driver number, or any 74770eef21Swizother value. 75770eef21SwizLocators can sometimes be wildcarded on devices that support direct 76770eef21Swizconnection. 778752c231Sgmcgarry.It Attributes 788752c231SgmcgarryAn attribute describes the device's relationship with the code; it 79770eef21Swizthen serves to constrain the device graph. 80770eef21SwizA 818752c231Sgmcgarry.Em plain attribute 82770eef21Swizdescribes some attribute of a device. 83770eef21SwizAn 848752c231Sgmcgarry.Em interface attribute 858752c231Sgmcgarrydescribes a kind of 868752c231Sgmcgarry.Do 878752c231Sgmcgarrysoftware interface 888752c231Sgmcgarry.Dc 89e6c0e529Swizand declares the device's ability to support other devices that use 90770eef21Swizthat interface. 91770eef21SwizIn addition, an interface attribute usually identifies additional locators. 928752c231Sgmcgarry.El 938752c231Sgmcgarry.Pp 948752c231SgmcgarryDuring autoconfiguration, the directed graph is turned into a tree by 958752c231Sgmcgarrynominating one device as the root node and matching drivers with 96503cf59cSheinzdevices by doing a depth-first traversal through the graph starting at 978752c231Sgmcgarrythis root node. 988752c231Sgmcgarry.Pp 998752c231SgmcgarryHowever, there must be constraints on the parent/child pairings that 100770eef21Swizare possible. 101770eef21SwizThese constraints are embedded in the 1028752c231Sgmcgarry.Do 1038752c231Sgmcgarrydevice definition 1048752c231Sgmcgarry.Dc 105770eef21Swizfiles. 106770eef21SwizThe remainder of this page describes the 1078752c231Sgmcgarry.Do 1088752c231Sgmcgarrydevice definition 1098752c231Sgmcgarry.Dc 1108752c231Sgmcgarrylanguage and how to use this language to add new functionality to the 1118752c231Sgmcgarry.Nx 1128752c231Sgmcgarrykernel. 1138752c231Sgmcgarry.Sh DEVICE DEFINITION FILES 1148752c231SgmcgarryThe device definition files are separated into machine-dependent and 115770eef21Swizmachine-independent files. 116770eef21SwizThe machine-dependent file is located in 117*01869ca4Swiz.Pa sys/arch/<arch>/conf/files.<arch> , 118*01869ca4Swizwhere <arch> is the name of 1198752c231Sgmcgarry.Nx 120770eef21Swizarchitecture. 121770eef21SwizThe machine-independent file is located in 1228752c231Sgmcgarry.Pa sys/conf/files . 1238752c231SgmcgarryIt in turn includes files for the machine-independent drivers located 1248752c231Sgmcgarryin 125*01869ca4Swiz.Pa sys/dev/<bus>/files.<bus> , 126*01869ca4Swizwhere <bus> is the name of the machine-independent bus. 1278752c231Sgmcgarry.Pp 128770eef21SwizThese files define all legal devices and pseudo-devices. 129770eef21SwizThey also define all attributes and interfaces, establishing the rules that 1308752c231Sgmcgarrydetermine allowable machine descriptions, and list the source files 1318752c231Sgmcgarrythat make up the kernel. 1328752c231Sgmcgarry.Pp 1338752c231SgmcgarryEach device definition file consists of a list of statements, 134770eef21Swiztypically one per line. 135770eef21SwizComments may be inserted anywhere using the 1368752c231Sgmcgarry.Do 1378752c231Sgmcgarry# 1388752c231Sgmcgarry.Dc 1398752c231Sgmcgarrycharacter, and any line that begins with white space continues the 140770eef21Swizprevious line. 141770eef21SwizValid statements are: 1428752c231Sgmcgarry.Bl -tag -width xxxxxx 1433faeefafSjdolecek.It cinclude filename 1443faeefafSjdolecekConditionally include contents of file 1453faeefafSjdolecek.Ar filename 1465049850fSwizto currently processed configuration. 1475049850fSwizIf the specified 1483faeefafSjdolecek.Ar filename 1492ed4245fSjdolecekdoesn't exist, a warning is printed, but the error 1502ed4245fSjdolecekignored. 151612fadfcSgmcgarry.It defflag [filename] {options} 152612fadfcSgmcgarryThe space-separated list of pre-processor macros 153612fadfcSgmcgarry.Em options 154612fadfcSgmcgarryare defined in file 155612fadfcSgmcgarry.Em filename . 156612fadfcSgmcgarryThis statement permits ``options FOO'' for FOO (i.e, without a value) 157612fadfcSgmcgarryin the machine description file. 158a9b411c1Speter.Xr config 1 159770eef21Swizwill generate an error if a value is given. 160d40cbfccSheasIf the filename field is not specified, it will be constructed based upon 161d40cbfccSheasthe lower-case of the option name, ``opt_foo.h'' for example. 162612fadfcSgmcgarryThe 163612fadfcSgmcgarry.Em option 164612fadfcSgmcgarryis case-sensitive. 165612fadfcSgmcgarry.It defparam [filename] {options} 166612fadfcSgmcgarryThe space-separated list of pre-processor macros 167612fadfcSgmcgarry.Em options 168612fadfcSgmcgarryare defined in file 169612fadfcSgmcgarry.Em filename . 170bc84af88SjoergThis statement permits ``options FOO=bar'' or ``option FOO="\e"com\e""'' 171612fadfcSgmcgarryin the machine description file. 172a9b411c1Speter.Xr config 1 173770eef21Swizwill generate an error if a value is not given. 174d40cbfccSheasIf the filename field is not specified, it will be constructed based upon 175d40cbfccSheasthe lower-case of the option name, ``opt_foo.h'' for example. 176612fadfcSgmcgarryThe 177612fadfcSgmcgarry.Em option 178612fadfcSgmcgarryis case-sensitive. 1798752c231Sgmcgarry.It defopt [filename] {options} 1808752c231SgmcgarryThe space-separated list of pre-processor macros 1818752c231Sgmcgarry.Em options 1828752c231Sgmcgarryare defined in file 1838752c231Sgmcgarry.Em filename . 184612fadfcSgmcgarryThis statement permits the syntax of either the defflag and defparam 185612fadfcSgmcgarrystatements and 186a9b411c1Speter.Xr config 1 187612fadfcSgmcgarrydoes not perform any checking of whether ``options FOO'' takes a 188770eef21Swizvalue. 189770eef21SwizTherefore, the use of the defopt statement is deprecated in 190770eef21Swizfavour of the defflag and defparam statements. 191d40cbfccSheasIf the filename field is not specified, it will be constructed based upon 192d40cbfccSheasthe lower-case of the option name, ``opt_foo.h'' for example. 1938752c231SgmcgarryThe 1948752c231Sgmcgarry.Em option 1958752c231Sgmcgarryis case-sensitive. 1968a20bde1Spooka.It deffs name [[name] ...] 1978752c231SgmcgarryDefine a filesystem 1988752c231Sgmcgarry.Em name . 1998752c231Sgmcgarry.It devclass name 2008752c231SgmcgarryDefine a device class 2018752c231Sgmcgarry.Em name . 2028752c231SgmcgarryA device class is similar to an attribute. 2038752c231Sgmcgarry.It define name [{locators}] 2048752c231SgmcgarryThe attribute 2058752c231Sgmcgarry.Em name 206770eef21Swizis defined and device definitions can then refer to it. 207770eef21SwizIf the attribute is an interface attribute and defines optional 2088752c231Sgmcgarry.Em locators , 2098752c231Sgmcgarrydevice attributes that refer to 2108752c231Sgmcgarry.Em name 2118752c231Sgmcgarryare assumed to share the interface and require the same locators. 2128752c231Sgmcgarry.It device name [{locators}]: [attributes] 2138752c231SgmcgarryThe device 2148752c231Sgmcgarry.Em name 2158752c231Sgmcgarryis defined and requires the optional comma-separated list of locators 2168752c231Sgmcgarry.Em locators . 2178752c231SgmcgarryThe optional 2188752c231Sgmcgarry.Em attributes 2198752c231Sgmcgarrydefine attribute dependencies. 2208752c231Sgmcgarry.It attach name at interface [with ifname]: [attributes] 2218752c231SgmcgarryThe device 2228752c231Sgmcgarry.Em name 2238752c231Sgmcgarryis defined and supports the interface 2248752c231Sgmcgarry.Em interface . 2258752c231SgmcgarryIf 2268752c231Sgmcgarry.Em ifname 2278752c231Sgmcgarryis specified, it is used to specify the interface to the driver for 2288752c231Sgmcgarrydevice 2298752c231Sgmcgarry.Em name 2308752c231Sgmcgarry(see 2318752c231Sgmcgarry.Xr driver 9 2328752c231Sgmcgarryfor details). 2338752c231SgmcgarryThe optional 2348752c231Sgmcgarry.Em attributes 2358752c231Sgmcgarrydefine attribute dependencies. 2368752c231Sgmcgarry.It defpseudo name: [{locators}] 2378752c231SgmcgarryThe pseudo-device 2388752c231Sgmcgarry.Em name 239770eef21Swizis defined. 240770eef21SwizThe optional 2418752c231Sgmcgarry.Em locators 2428752c231Sgmcgarrymay be defined, but are largely pointless since no device can attach 2438752c231Sgmcgarryto a pseudo-device. 2448752c231Sgmcgarry.It file pathname [attributes [flags]] [rule] 2458752c231SgmcgarryThe file 2468752c231Sgmcgarry.Em pathname 247770eef21Swizis added to the list of files used to build the kernel. 248770eef21SwizIf no attributes are specified, the file is always added to the kernel 249770eef21Swizcompilation. 250770eef21SwizIf any of the attributes are specified by other devices in the machine 251c3397e3cSwizdescription file, then the file is included in compilation, otherwise it 252770eef21Swizis omitted. 253770eef21SwizValid values for the optional flags are: 2548752c231Sgmcgarry.Bl -tag -width xxxxxx 2558752c231Sgmcgarry.It needs-count 2568752c231SgmcgarrySpecify that config should generate a file for each of the attributes 2578752c231Sgmcgarrynotifying the driver how many of some particular device or set of 258770eef21Swizdevices are configured in the kernel. 259770eef21SwizThis flag allows drivers to make calculations of driver used at compile time. 2608752c231SgmcgarryThis option prevents autoconfiguration cloning. 2618752c231Sgmcgarry.It needs-flag 262503cf59cSheinzThis flag performs the same operation as 2638752c231Sgmcgarry.Em needs-count 264770eef21Swizbut only records if the number is nonzero. 265770eef21SwizSince the count is not exact, 2668752c231Sgmcgarry.Em needs-flag 2678752c231Sgmcgarrydoes not prevent autoconfiguration cloning. 2688752c231Sgmcgarry.El 2693fd2dc71Sgehenna.It device-major name char [block] [attributes] 2703fd2dc71SgehennaThe character device switch 2713fd2dc71Sgehenna.Em name 2723fd2dc71Sgehennaassociated with a character major device number is added to the list of 273770eef21Swizdevice switches used to build the kernel. 274770eef21SwizIf 2753fd2dc71Sgehenna.Em block 2763fd2dc71Sgehennais specified, the block device switch associated with a block major device 277770eef21Swiznumber is also added. 278770eef21SwizIf all of attributes are specified by devices in the machine description 279770eef21Swizfiles, then device switches are added into the device switches' table of 280770eef21Swizthe kernel in compilation, otherwise they are omitted. 28158b5cb57Skei.It include Ar filename 2823faeefafSjdolecekInclude contents of file 2833faeefafSjdolecek.Ar filename 2845049850fSwizto currently processed configuration. 2855049850fSwizIf the specified 2863faeefafSjdolecek.Ar filename 2873faeefafSjdolecekdoesn't exist, 288a9b411c1Speter.Xr config 1 2893faeefafSjdolecekexits with error. 2903faeefafSjdolecek.It package Ar filename 2913faeefafSjdolecekChanges prefix to directory of 2923faeefafSjdolecek.Ar filename , 2933faeefafSjdolecekprocesses contents of 2943faeefafSjdolecek.Ar filename , 2955049850fSwizand switches back to previous prefix. 2965049850fSwizThis is syntactic sugar for: 2971a17661dSjoerg.Bd -literal -compact -offset indent 2981a17661dSjoerg.Li prefix Ar dirname(filename) 2991a17661dSjoerg.Li include Ar basename(filename) 3001a17661dSjoerg.Li prefix 3011a17661dSjoerg.Ed 3023faeefafSjdolecek.It prefix Op Ar dirname 3033faeefafSjdolecekIf 3043faeefafSjdolecek.Ar dirname 3055049850fSwizis specified, it is pushed on top of prefix stack. 3065049850fSwizAny further files specified via option 3073faeefafSjdolecek.Ar file 3083faeefafSjdolecekwould have the prefix implicitly prepended before its 3093faeefafSjdolecek.Ar filename . 3103faeefafSjdolecekIf 3113faeefafSjdolecek.Ar dirname 3123faeefafSjdolecekis not specified, pops (removes) a prefix from prefix stack. 3138752c231Sgmcgarry.El 3148752c231Sgmcgarry.Pp 3158752c231SgmcgarryTo allow locators to be wildcarded in the machine description file, 316770eef21Swiztheir default value must be defined in the attribute definition. 317770eef21SwizTo allow locators to be omitted entirely in the machine description file, 318770eef21Swizenclose the locator in square brackets. 319770eef21SwizThis can be used when some locators do not make sense for some devices, 320770eef21Swizbut the software interface requires them. 3218752c231Sgmcgarry.Sh CODE REFERENCES 3228752c231SgmcgarryThe device definition files are in 3238752c231Sgmcgarry.Pa sys/conf/files , 324*01869ca4Swiz.Pa sys/arch/<arch>/conf/files.<arch> , 3258752c231Sgmcgarryand 326*01869ca4Swiz.Pa sys/dev/<bus>/files.<bus> . 3278752c231Sgmcgarry.Pp 3288752c231SgmcgarryThe grammar for machine description files can be found in 329a9b411c1Speter.Xr config 1 , 3308752c231Sgmcgarryin 331944f9952Ssnj.Pa usr.bin/config/gram.y . 3328752c231Sgmcgarry.Sh SEE ALSO 333a9b411c1Speter.Xr config 1 , 334494da5efSperry.Xr config 5 , 335a0a66802Swiz.Xr autoconf 9 , 336a0a66802Swiz.Xr driver 9 3378752c231Sgmcgarry.Rs 3388752c231Sgmcgarry.%T "Building 4.4 BSD Systems with Config" 3398752c231Sgmcgarry.Re 3408752c231Sgmcgarry.Rs 3418752c231Sgmcgarry.%A Chris Torek 3428752c231Sgmcgarry.%T "Device Configuration in 4.4BSD" 3438752c231Sgmcgarry.%D 1992 3448752c231Sgmcgarry.Re 3458752c231Sgmcgarry.Sh HISTORY 3468752c231SgmcgarryAutoconfiguration first appeared in 3478752c231Sgmcgarry.Bx 4.1 . 3488752c231SgmcgarryThe autoconfiguration framework was completely revised in 3498752c231Sgmcgarry.Bx 4.4 . 3508752c231SgmcgarryIt has been modified within 3518752c231Sgmcgarry.Nx 3528752c231Sgmcgarryto support bus-independent drivers and bus-dependent attachments. 353