Next: Contributing Changes, Previous: Coding style, Up: Top [Contents][Index]
Here is a brief map of the GRUB code base.
GRUB uses Autoconf and Automake, with most of the Automake input generated by a Python script. The top-level build rules are in configure.ac, grub-core/Makefile.core.def, and Makefile.util.def. Each block in a *.def file represents a build target, and specifies the source files used to build it on various platforms. The *.def files are processed into Automake input by gentpl.py (which you only need to look at if you are extending the build system). If you are adding a new module which follows an existing pattern, such as a new command or a new filesystem implementation, it is usually easiest to grep grub-core/Makefile.core.def and Makefile.util.def for an existing example of that pattern to find out where it should be added.
In general, code that may be run at boot time is in a subdirectory of grub-core, while code that is only run from within a full operating system is in a subdirectory of the top level.
Low-level boot code, such as the MBR implementation on PC BIOS systems, is in the grub-core/boot/ directory.
The GRUB kernel is in grub-core/kern/. This contains core facilities such as the device, disk, and file frameworks, environment variable handling, list processing, and so on. The kernel should contain enough to get up to a rescue prompt. Header files for kernel facilities, among others, are in include/.
Terminal implementations are in grub-core/term/.
Disk access code is spread across grub-core/disk/ (for accessing the disk devices themselves), grub-core/partmap/ (for interpreting partition table data), and grub-core/fs/ (for accessing filesystems). Note that, with the odd specialised exception, GRUB only contains code to read from filesystems and tries to avoid containing any code to write to filesystems; this lets us confidently assure users that GRUB cannot be responsible for filesystem corruption.
PCI and USB bus handling is in grub-core/bus/.
Video handling code is in grub-core/video/. The graphical menu system uses this heavily, but is in a separate directory, grub-core/gfxmenu/.
Most commands are implemented by files in grub-core/commands/, with the following exceptions:
There are a few other special-purpose exceptions; grep for them if they matter to you.
Next: Contributing Changes, Previous: Coding style, Up: Top [Contents][Index]