x86 bootloader
Find a file
Peter Farley 8e17bedd58 tools: Fix lboot_prepare.sh
This resolves two issues:
 - When used with a real floppy device, it would complain that it did
   not exist as it was not a regular file
 - It would fail when attempting to create the LBOOT directory when it
   already exists, as `mmd` does not have an option to not fail when the
   target directory exists
2025-03-12 20:14:27 -05:00
docs Add screenshot to README.md 2022-08-28 10:46:37 -05:00
inc intr: Add option to show more verbose info on exceptions 2025-03-02 15:10:22 -06:00
src build: Fix verbose exception message enable 2025-03-12 20:13:50 -05:00
stage1 build: Fix cross-build 2025-03-02 15:05:33 -06:00
tools tools: Fix lboot_prepare.sh 2025-03-12 20:14:27 -05:00
.defconfig intr: Add option to show more verbose info on exceptions 2025-03-02 15:10:22 -06:00
.gitignore build: Use kconfig for build configuration 2025-03-01 12:08:09 -06:00
Kconfig intr: Add option to show more verbose info on exceptions 2025-03-02 15:10:22 -06:00
lboot.cfg.example storage/protocol: Add XMODEM protocol 2022-09-12 19:16:22 -05:00
LICENSE Update README, add LICENSE 2022-07-30 20:27:52 -05:00
Makefile build: Fix cross-build 2025-03-02 15:05:33 -06:00
README.md build: Use kconfig for build configuration 2025-03-01 12:08:09 -06:00
stage1.mk build: Fix cross-build 2025-03-02 15:05:33 -06:00
stage2.ld Add method to switch to real mode to call BIOS interrupts. 2022-08-14 20:11:12 -05:00
stage2.mk build: Use kconfig for build configuration 2025-03-01 12:08:09 -06:00

LBoot

x86 bootloader for floppy disks. For a working example of LBoot being used, see Lambda OS.

Screenshot of LBoot boot loading kernel

Current Support

  • Filesystems
    • FAT12
      • Limited to the boot device
      • No long filename support
  • Serial transfer protocols
    • XMODEM
  • Kernel Format
    • ELF
  • Multiboot 2 (optional)
    • CMDLINE
    • BOOTLOADER_NAME
    • MODULE
    • BASIC_MEMINFO
    • MMAP
    • ACPI_OLD
    • ACPI_NEW
  • Outputs
    • VGA
    • Serial

Features can be toggled via inc/config.h. Stage 2 size based on features:

  • All features disabled: ~20 KiB
  • With all features: ~23 KiB
  • With all debugging enabled: ~25 KiB

Future Work

  • Loading kernel via Kermit
  • Flat binary support
  • Kernel relocation support (maybe)
  • Look into adding minimal FAT12 support to stage 1 loader
    • Currently this is leveraging an additional tool (sector_mapper) to generate a list of sectors to load for stage 2. This makes writing/updating the bootloader to the floppy more complicated than is probably necessary.
    • Simply giving the stage 1 loader the first sector of the stage 2 file would probably be sufficient.

Building

Requirements:

  • make
  • gcc or clang
  • mtools for generating floppy image
  • menuconfig or similar, for easy configuration
    • Not required, .config file can be modified by hand
    • If no .config file is present, .defconfig is used instead
    • For a standalone Kconfig-compatible menuconfig, see Kconfiglib

To build, simply run make in the main directory. This will generate a boot.img file containing the bootloader. A configuration and kernel file will need to be provided.

To write the bootloader to an existing floppy disk or image, use the following from within the root of the repository:

tools/lboot_prepare.sh <floppy disk/image>

Testing

LBoot has been tested both within QEMU, and on a Compaq Armada 1700, booting the Lambda Kernel

Config

LBoot is configured using a text file (currently must be named LBOOT.CFG in the LBOOT directory of the boot filesystem). The syntax is simple, but somewhat strict. Each configuration line is a key-value pair separated by a =. There must be no spaces on either side of the =, and lines not containing a = are effectively comments.

The following are the currently supported set of configuration keys:

  • CFGVER: Config version, must be 1
  • KERNEL: Kernel file to load
  • CMDLINE: Commandline to pass to kernel
  • MODULE: File to load as a module.
    • Each instance will add a new module, currently up to 4 are supported.

Files can be any of the following:

  • Plain filename - Attempts to find the file on the boot filesystem
  • xmodem://COMx - Loads file via XMODEM, where x is the serial port to use, 1-4