386BSD 0.1 development
[unix-history] / usr / othersrc / share / doc / smm / 02.config / 3.t
CommitLineData
af5acba4
WJ
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)3.t 6.3 (Berkeley) 4/17/91
33.\"
34.\".ds RH "System Building Process
35.ne 2i
36.NH
37SYSTEM BUILDING PROCESS
38.PP
39In this section we consider the steps necessary to build a bootable system
40image. We assume the system source is located in the ``/sys'' directory
41and that, initially, the system is being configured from source code.
42.PP
43Under normal circumstances there are 5 steps in building a system.
44.IP 1) 3
45Create a configuration file for the system.
46.IP 2) 3
47Make a directory for the system to be constructed in.
48.IP 3) 3
49Run
50.I config
51on the configuration file to generate the files required
52to compile and load the system image.
53.IP 4)
54Construct the source code interdependency rules for the
55configured system with
56.I make depend
57using
58.IR make (1).
59.IP 5)
60Compile and load the system with
61.IR make .
62.PP
63Steps 1 and 2 are usually done only once. When a system configuration
64changes it usually suffices to just run
65.I config
66on the modified configuration file, rebuild the source code dependencies,
67and remake the system. Sometimes,
68however, configuration dependencies may not be noticed in which case
69it is necessary to clean out the relocatable object files saved
70in the system's directory; this will be discussed later.
71.NH 2
72Creating a configuration file
73.PP
74Configuration files normally reside in the directory ``/sys/conf''.
75A configuration file is most easily constructed by copying an
76existing configuration file and modifying it. The 4.3BSD distribution
77contains a number of configuration files for machines at Berkeley;
78one may be suitable or, in worst case, a copy
79of the generic configuration file may be edited.
80.PP
81The configuration file must have the same name as the directory in
82which the configured system is to be built.
83Further,
84.I config
85assumes this directory is located in the parent directory of
86the directory in which it
87is run. For example, the generic
88system has a configuration file ``/sys/conf/GENERIC'' and an accompanying
89directory named ``/sys/GENERIC''.
90Although it is not required that the system sources and configuration
91files reside in ``/sys,'' the configuration and compilation procedure
92depends on the relative locations of directories within that hierarchy,
93as most of the system code and the files created by
94.I config
95use pathnames of the form ``../''.
96If the system files are not located in ``/sys,''
97it is desirable to make a symbolic link there for use in installation
98of other parts of the system that share files with the kernel.
99.PP
100When building the configuration file, be sure to include the items
101described in section 2. In particular, the machine type,
102cpu type, timezone, system identifier, maximum users, and root device
103must be specified. The specification of the hardware present may take
104a bit of work; particularly if your hardware is configured at non-standard
105places (e.g. device registers located at funny places or devices not
106supported by the system). Section 4 of this document
107gives a detailed description of the configuration file syntax,
108section 5 explains some sample configuration files, and
109section 6 discusses how to add new devices to
110the system. If the devices to be configured are not already
111described in one of the existing configuration files you should check
112the manual pages in section 4 of the UNIX Programmers Manual. For each
113supported device, the manual page synopsis entry gives a
114sample configuration line.
115.PP
116Once the configuration file is complete, run it through
117.I config
118and look for any errors. Never try and use a system which
119.I config
120has complained about; the results are unpredictable.
121For the most part,
122.IR config 's
123error diagnostics are self explanatory. It may be the case that
124the line numbers given with the error messages are off by one.
125.PP
126A successful run of
127.I config
128on your configuration file will generate a number of files in
129the configuration directory. These files are:
130.IP \(bu 3
131A file to be used by \fImake\fP\|(1)
132in compiling and loading the system,
133.IR Makefile .
134.IP \(bu 3
135One file for each possible system image for this machine,
136.IR swapxxx.c ,
137where
138.I xxx
139is the name of the system image,
140which describes where swapping, the root file system, and other
141miscellaneous system devices are located.
142.IP \(bu 3
143A collection of header files, one per possible device the
144system supports, which define the hardware configured.
145.IP \(bu 3
146A file containing the I/O configuration tables used by the system
147during its
148.I autoconfiguration
149phase,
150.IR ioconf.c .
151.IP \(bu 3
152An assembly language file of interrupt vectors which
153connect interrupts from the machine's external buses to the main
154system path for handling interrupts,
155and a file that contains counters and names for the interrupt vectors.
156.PP
157Unless you have reason to doubt
158.IR config ,
159or are curious how the system's autoconfiguration scheme
160works, you should never have to look at any of these files.
161.NH 2
162Constructing source code dependencies
163.PP
164When
165.I config
166is done generating the files needed to compile and link your system it
167will terminate with a message of the form ``Don't forget to run make depend''.
168This is a reminder that you should change over to the configuration
169directory for the system just configured and type ``make depend''
170to build the rules used by
171.I make
172to recognize interdependencies in the system source code.
173This will insure that any changes to a piece of the system
174source code will result in the proper modules being recompiled
175the next time
176.I make
177is run.
178.PP
179This step is particularly important if your site makes changes
180to the system include files. The rules generated specify which source code
181files are dependent on which include files. Without these rules,
182.I make
183will not recognize when it must rebuild modules
184due to the modification of a system header file.
185The dependency rules are generated by a pass of the C preprocessor
186and reflect the global system options.
187This step must be repeated when the configuration file is changed
188and
189.I config
190is used to regenerate the system makefile.
191.NH 2
192Building the system
193.PP
194The makefile constructed by
195.I config
196should allow a new system to be rebuilt by simply typing ``make image-name''.
197For example, if you have named your bootable system image ``vmunix'',
198then ``make vmunix''
199will generate a bootable image named ``vmunix''. Alternate system image names
200are used when the root file system location and/or swapping configuration
201is done in more than one way. The makefile which
202.I config
203creates has entry points for each system image defined in
204the configuration file.
205Thus, if you have configured ``vmunix'' to be a system with the root file
206system on an ``hp'' device and ``hkvmunix'' to be a system with the root
207file system on an ``hk'' device, then ``make vmunix hkvmunix'' will generate
208binary images for each.
209As the system will generally use the disk from which it is loaded
210as the root filesystem, separate system images are only required
211to support different swap configurations.
212.PP
213Note that the name of a bootable image is different from the system
214identifier. All bootable images are configured for the same system;
215only the information about the root file system and paging devices differ.
216(This is described in more detail in section 4.)
217.PP
218The last step in the system building process is to rearrange certain commonly
219used symbols in the symbol table of the system image; the makefile
220generated by
221.I config
222does this automatically for you.
223This is advantageous for programs such as
224\fInetstat\fP\|(1) and \fIvmstat\fP\|(1),
225which run much faster when the symbols they need are located at
226the front of the symbol table.
227Remember also that many programs expect
228the currently executing system to be named ``/vmunix''. If you install
229a new system and name it something other than ``/vmunix'', many programs
230are likely to give strange results.
231.NH 2
232Sharing object modules
233.PP
234If you have many systems which are all built on a single machine
235there are at least two approaches to saving time in building system
236images. The best way is to have a single system image which is run on
237all machines. This is attractive since it minimizes disk space used
238and time required to rebuild systems after making changes. However,
239it is often the case that one or more systems will require a separately
240configured system image. This may be due to limited memory (building
241a system with many unused device drivers can be expensive), or to
242configuration requirements (one machine may be a development machine
243where disk quotas are not needed, while another is a production machine
244where they are), etc. In these cases it is possible
245for common systems to share relocatable object modules which are not
246configuration dependent; most of the modules in the directory ``/sys/sys''
247are of this sort.
248.PP
249To share object modules, a generic system should be built. Then, for
250each system configure the system as before, but before recompiling and
251linking the system, type ``make links'' in the system compilation directory.
252This will cause the system
253to be searched for source modules which are safe to share between systems
254and generate symbolic links in the current directory to the appropriate
255object modules in the directory ``../GENERIC''. A shell script,
256``makelinks'' is generated with this request and may be checked for
257correctness. The file ``/sys/conf/defines'' contains a list of symbols
258which we believe are safe to ignore when checking the source code
259for modules which may be shared. Note that this list includes the definitions
260used to conditionally compile in the virtual memory tracing facilities, and
261the trace point support used only rarely (even at Berkeley).
262It may be necessary
263to modify this file to reflect local needs. Note further that
264interdependencies which are not directly visible
265in the source code are not caught. This means that if you place
266per-system dependencies in an include file, they will not be recognized
267and the shared code may be selected in an unexpected fashion.
268.NH 2
269Building profiled systems
270.PP
271It is simple to configure a system which will automatically
272collect profiling information as it operates. The profiling data
273may be collected with \fIkgmon\fP\|(8) and processed with
274\fIgprof\fP\|(1)
275to obtain information regarding the system's operation. Profiled
276systems maintain histograms of the program counter as well as the
277number of invocations of each routine. The \fIgprof\fP
278command will also generate a dynamic call graph of the executing
279system and propagate time spent in each routine along the arcs
280of the call graph (consult the \fIgprof\fP documentation for elaboration).
281The program counter sampling can be driven by the system clock, or
282if you have an alternate real time clock, this can be used. The
283latter is highly recommended, as use of the system clock will result
284in statistical anomalies, and time spent in the clock routine will
285not be accurately attributed.
286.PP
287To configure a profiled system, the
288.B \-p
289option should be supplied to \fIconfig\fP.
290A profiled system is about 5-10% larger in its text space due to
291the calls to count the subroutine invocations. When the system
292executes, the profiling data is stored in a buffer which is 1.2
293times the size of the text space. The overhead for running a
294profiled system varies; under normal load we see anywhere from 5-25%
295of the system time spent in the profiling code.
296.PP
297Note that systems configured for profiling should not be shared as
298described above unless all the other shared systems are also to be
299profiled.