1 .\" $OpenBSD: files.conf.5,v 1.21 2009/04/26 13:10:20 tobias Exp $
3 .\" Copyright (c) 2002 Miodrag Vallat.
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistribution of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .Dd $Mdocdate: April 26 2009 $
32 .Nd rules base for the config utility
36 files located in the kernel source tree
37 contain all the necessary information needed by
39 to parse a kernel configuration file and determine the list of files to
44 rules base are simple, human-readable, text files.
45 Empty lines, as well as text prefixed by the
47 character, are ignored.
48 .Sh DEVICE TREE CONCEPT
53 the various devices as a hierarchical tree, where the various devices
55 to parent entities, which can either be physical devices themselves
56 .Pq such as a computer bus ,
57 or logical entities, designed to make the driver code simpler.
58 Usually, the top-most devices are attached to the pseudo-device
60 which is itself reported as attached to a fictitious
63 There is no restriction on the
65 a device node may have;
66 some device drivers can attach themselves to different kinds of parent devices.
67 For example, the logical
69 device can either attach at a SCSI controller device,
74 Some device attachments need to provide attachment information.
77 device will use a range of I/O ports, one or more DMA channels, and one
79 This attachment information is known as the
82 Most of the buses support default values for unspecified locators, for devices
83 that either do not require them
87 cards not using interrupts
89 or which can autoconfigure themselves
96 Attachment lines in the kernel configuration file must match the locators of
97 the device they are attaching to.
99 .Bd -literal -offset indent
100 define pci {[dev = -1], [function = -1]}
104 the following kernel configuration lines are valid:
105 .Bd -literal -offset indent
106 pciknob0 at pci? dev 2 function 42 # use fixed values
107 pciknob* at pci? dev ? function ? # use default values
108 pciknob* at pci? # use default locators
111 But the following are not:
112 .Bd -literal -offset indent
113 pciknob* at pci? trick ? treat ? # unknown locators
114 pciknob* at pci? dev ? function ? usefulness ? # unknown locators
117 The following syntax defines a simple attribute,
118 which can be later used to factorize code dependencies:
122 An attachment-like attribute will also require locators to be specified.
123 If no locators are necessary:
125 .Dl define attribute {}
127 If locators are provided:
129 .Dl define attribute {[locator1 = default1], [locator2 = default2]}
131 For simple device attachment, the following syntax
132 defines a simple device, with no locators:
134 .Dl device devicename {}
136 If locators are necessary, they are specified as:
138 .Dl device devicename {[locator1 = default1], [locator2 = default2]}
140 A device can also reference an attribute with locators.
141 This is in fact a dependency rule.
144 defines the following attribute for SCSI controllers:
146 .Dl define scsi {} # no locators
148 And SCSI drivers can then be defined as:
150 .Dl device scsictrl: scsi
152 A device may depend on as many attributes as necessary:
154 .Dl device complexdev: simpledev, otherdev, specialattribute
156 Pseudo devices are defined as regular devices, except that they do not
157 need locators, and use a different keyword:
158 .Bd -literal -offset indent
159 pseudo-device loop: inet
163 The rules above define, respectively,
164 the loopback network interface and the kernel symbols pseudo-device.
165 .Sh DEVICE ATTACHMENT RULES
166 Due to the tree structure of the device nodes, every device but the pseudo
167 devices need to attach to some parent node.
168 A device driver has to specify to which parents it can attach, with the
171 .Dl attach device at parent, parent2, parent3
173 The rule above lists all the parent attributes a device may attach to.
174 For example, given the following:
175 .Bd -literal -offset indent
176 device smartknob: bells, whistles
177 attach smartknob at brainbus
180 The following configuration line is then valid:
182 .Dl smartknob* at brainbus?
184 Whilst the following is not:
186 .Dl smartknob* at dumbbus?
188 If a device supports attachments to multiple parents, using different
190 routines every time, the following syntax specifies the details:
191 .Bd -literal -offset indent
192 attach device at parent with device_parent_glue
193 attach device at parent2 with device_parent2_glue
196 This will define more required attributes, depending on the kernel
197 configuration file's contents.
198 .Sh RULE FILE INCLUSION
199 It is possible to include other rules files anywhere in a file, using the
203 .Dl include \&"dev/pci/files.pci\&"
205 The above rule will include the rules for machine-independent PCI code.
208 .Pa sys/arch/machine/conf/files.machine ,
211 listed in the machine line in the kernel configuration file, as well as
213 are always processed, and do not need to be included.
214 .Sh ATTRIBUTE REQUIREMENTS
215 The kernel configuration file description passed to
217 lists several compilation options, as well as several device definitions.
220 will build a list of required attributes, which are:
222 .Bl -bullet -offset indent -compact
226 lines, with the option name translated to lowercase (for example, an
228 line will produce the
232 The device and pseudo-device names, except for
236 Kernel source files are defined as:
237 .Bd -literal -offset indent
238 file file-list dependencies need-rules
242 typically only specifies a single filename.
243 If instead it contains a list of filenames separated by the
247 will select the first file from the list which exists.
252 is found in the filename, it will be substituted with the
253 relevant base architecture name.
257 part is empty, the file will always be compiled in.
258 This is the case for the core kernel files.
259 Otherwise, the file will only be added to the list if the dependencies are met.
260 Dependencies are based upon attributes and device names.
261 Multiple dependencies can be written using the
268 .Dl file netinet/ipsec_input.c (inet | inet6) & ipsec
270 The above rule teaches
273 .Pa sys/netinet/ipsec_input.c
274 to the filelist if the
276 attribute, and at least one of the
280 attributes, are required.
284 rules can be empty, or one of the following keywords:
286 .Bl -tag -width "needs-count" -compact
288 Create an attribute header file, defining whether or not this
289 attribute is compiled in.
291 Create an attribute header file, defining how many instances of this
292 attribute are to be compiled in.
293 This rule is mostly used for pseudo-devices.
297 .Dq attribute header files
298 are simple C header files created in the kernel compilation directory,
301 and containing the following line:
303 .Dl #define NATTRIBUTE 0
305 This would substitute the attribute name and its uppercase form, prefixed with
315 rule, the value on the
317 line is either 1 if the attribute is required, or 0 if it is not required.
320 rule, the value is the number of device instances required, or 0
321 if the device is not required.
323 Attribute files are created for every attribute listed with a
325 rule, even if it is never referenced from the kernel configuration file.
326 .Sh MISCELLANEOUS ITEMS
327 .Pa sys/arch/machine/conf/files.machine
328 must also supply the following special commands:
329 .Bl -tag -width maxpartitions
331 Defines how many partitions are available on disk block devices, usually 16.
332 This value is used by
334 to set up various device information structures.
336 Defines the bounds, and the default value, for the
338 parameter in the kernel configuration file.
339 The usual values are 2 8 64 ;
341 will report an error if the
342 .Dq maxusers parameter
343 in the kernel configuration file does not fit in the specified range.
347 .It Pa sys/arch/machine/conf/files.machine
348 Rules for architecture-dependent files, for the
351 .It Pa sys/compat/emul/files.emul
354 operating system or subsystem emulation.
355 .It Pa sys/dev/class/files.class
359 .It Pa sys/scsi/files.scsi
360 Rules for the common SCSI subsystem.