Let's remember what happens when building a kernel: after editing the kernel config file located in /sys/arch/<arch>/conf and running config(8) on it, a number of files are created in /sys/arch/<arch>/compile/KERNELNAME. The header files contain data about what and how many devices to include, as well as other data for the system's configuration. Besides that, a Makefile is created, that is used to build the kernel from source. The interesting point to note here is that there is only one Makefile that will locate and compile all the needed sources and place the object files in the .../compile/KERNELNAME directory. In NetBSD, there is no recursive tree-walk of the whole source tree utilizing several Makefiles to build the various sub-trees of the kernel source. This allows building kernels for several configurations and platforms from the same source, without different builds tripping across each other.
Still, the various parts of the NetBSD kernel are placed in various subdirectories that we will have a closer look at now. Under /usr/src/sys, there are:
The filesystems are stored in the "ufs" subdirectory, filesystems contained in there include
The filesystems included here are:
If a chip implements some functionality like audio, network or scsi, it is often used on several cards that all have the same chip, but different bus interfaces - ISA, PCI, etc. To prevent maintaining several drivers that have identical core functionality, NetBSD drivers are seperated into bus-glue code kept in the bus-specific directories mentioned above, and the core functionality of the integrated circuit. Naming conventions help identifying e.g. network cards (if_*), but aren't implemented throughoutly, unfortunately.
The drivers for the core functionality are stored in the "ic" subdirectory, with the file names indicating the IC's chip numbers:
% ls /sys/dev/ic CVS cac.c isp_target.c pckbc.c Makefile cacreg.h isp_target.h pckbcvar.h README.ncr5380sbc cacvar.h isp_tpublic.h pdq.c ac97.c cd1190reg.h ispmbox.h pdq_ifsubr.c ac97reg.h cd1400reg.h ispreg.h pdqreg.h ...
Port-specific directories contain several subdirectories, with the following ones being present for all ports:
Further directories may exist in the arch specific directories that contain bus-specific/non-machine independent device drivers which don't fit into /sys/dev as they work on one port only. Ideally, a port only uses machine independent drivers, of course.