grub-dev: Finding your way around

 
 3 Finding your way around
 *************************
 
 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:
 
    * A few core commands live in 'grub-core/kern/corecmd.c'.
 
    * Commands related to normal mode live under 'grub-core/normal/'.
 
    * Commands that load and boot kernels live under 'grub-core/loader/'.
 
    * The 'loopback' command is really a disk device, and so lives in
      'grub-core/disk/loopback.c'.
 
    * The 'gettext' command lives under 'grub-core/gettext/'.
 
    * The 'loadfont' and 'lsfonts' commands live under 'grub-core/font/'.
 
    * The 'serial', 'terminfo', and 'background_image' commands live
      under 'grub-core/term/'.
 
    * The 'efiemu_*' commands live under 'grub-core/efiemu/'.
 
    * OS-dependent code should be under 'grub-core/osdep/'
 
    * Utility programs meant to be run from a full operating system
      (except OS-dependent code mentioned previously) are in 'util/'.
 
    There are a few other special-purpose exceptions; grep for them if
 they matter to you.