NAME
conf – native and hosted kernel configuration file

DESCRIPTION
Plan 9 kernels are built for a given target platform using platform–specific code in directory /sys/src/9/platform and portable code in /sys/src/9/port, /sys/src/9/ip and elsewhere. Existing platforms include alphapc for the DEC Alpha, iPAQ for the Compaq iPAQ, pc for the Intel x86, and ppc for the IBM/Motorola PowerPC. Each platform can have several different kernels with different configurations. A given configuration is built in the platform's directory using the mk(1) command:
mk 'CONF=conf'

where conf is a text file that specifies drivers, protocols and other parameters for that particular kernel: a parts list. The result of a successful mk is an executable or bootable file with a name determined by the platform's mkfile, typically 9conf.

A kernel configuration file has several sections of the form
label
item
[ subitem ... ]
...

Each section begins with a label at the start of a line, which names a configuration category, followed by a list of each item to select from that category, one line per item, with white space (ie, blank or tab) at the start of the line. An item line can optionally list one or more subitems that must be included in the kernel to support it. A line that starts with a # is a comment. Empty lines are ignored.

Labels are chosen from the following set, listed in the order in which they conventionally appear in a configuration file:
dev       Device drivers
ip        IP protocols (native kernels only) taken from ../ip
link      
Hardware–specific parts of device drivers.
misc      Architecture–specific files; specific VGA and SCSI interfaces
lib       Libraries to link with the kernel
port      C code and declarations to include as–is in the generated configuration file
boot      Configuration for boot(8)
bootdir   List of files and directories to put in the boot directory of root(3).

When an item is listed under a given label it causes a corresponding component to be included in the kernel. The details depend on the label, as discussed below. Each subitem represents a kernel subcomponent required by the corresponding item. Both items and subitems can be either portable (platform– independent) or platform–specific. The source file for a given item or subitem is sought in the platform–directory (for platform–specific code), and in directories ../port and ../ip, under control of the platform's mkfile and ../port/portmkfile (which is included by mkfile). Resulting object files are left in the platform directory.

Outside the dev section, each item and subitem x causes the kernel image to include the code compiled from x.c, (or x.s for assembly–language support), or portdir/x.c, where portdir is one of the portable directories mentioned above. In the dev section, an item x corresponds instead to the driver source file devx.c in the current (platform–specific) directory or a portable driver portdir/devx.c. Subitems are handled as in any other section. Typically they are auxiliary files that are needed by the associated driver.

For instance, in a native kernel the portable driver for the draw device uses platform–specific code from screen.c. That can be represented as follows:
dev
draw screen

Each item x in the ip section corresponds to a protocol implementation compiled from ../ip/x.c. Any subitems are dealt with in the same way as in the dev section.

The link section provides a way for hardware–specific parts of drivers to link at runtime to the hardware–invariant part of a device drivers. For each item x, the kernel will call the function xlink during its initialisation. Typically that function makes itself known to the device driver by calling a function provided by that driver, passing the address of a interface–specific data structure or linkage table. For example, ethersmc is an interface–specific component:
link
...
ethersmc

and its source file ethersmc.c provides a function ethersmclink that calls addethercard in the interface–invariant part of the driver, devether.c:
void
ethersmclink(void)
{
addethercard("smc91cXX", reset);
}

The boot section configures boot(8), the first user program run by the kernel. Each line in the section names a possible boot method (see boot(8) for the current list). The first will be the default. Also by default, /boot will run /bin/termrc from cpurc(8), with bootdisk set to #S/sdC0/. To change the defaults, the line (or lines) containing a boot label can be given some options:
boot cpu
The kernel is a cpu server: run /bin/cpurc not /bin/termrc (see cpurc(8)).
boot cpu boot disk
Use disk as the default bootdisk.

The lib section lists the libraries to include when linking the kernel, in an order that satisfies any dependencies amongst them. Each item x corresponds to /$objtype/libx.a, a target–specific library produced by compiling the C source code in /sys/src/libitem, where objtype is set in the platform's mkfile to the target system's object type (eg, 386, power, etc).

An item in the bootdir section has one of the forms:
name
source name

where name and source are path names (often absolute path names). The kernel's initial root file system (see root(3)) will contain a file or directory with the given name. The contents will come from the file name (which must exist) unless an explicit source file is given.

The port section usually contains initialisations for kernel–specific values. The most common one is
int cpuserver = n;

where n is non–zero for cpu servers and file servers, and zero otherwise.

FILES
/sys/src/9/port/mkdevc
/sys/src/9/port/mkdevlist
/sys/src/9/port/mkroot

SEE ALSO
mk(1)
Copyright © 2024 Plan 9 Foundation. All rights reserved.