Skip to content

BooleOS 0.18.0 - Phase 18: Safety/portability foundation (HAL, msg(ID), Safe Mode)

Choose a tag to compare

@TheShannonDev TheShannonDev released this 25 Sep 22:30
· 57 commits to main since this release

BooleOS 0.18.0 - Phase 18: Safety/portability foundation (HAL, msg(ID), Safe Mode)

All you need to run it is QEMU; the exact command is in the README.txt inside the ISO package.

  • booleos-0.18.0-iso-img(originally-nullos).zip: the bootable ISO built from this tag (the image itself still says NullOS, because the project was renamed after this version), the blank disk image when this version has one, and a README.txt with the QEMU command and what this ISO does
  • booleos-0.18.0-docs-original.zip: the docs of this version, exactly as they were

Changes

Added

  • Hardware abstraction layer (kernel/hal.h, kernel/hal.c,
    docs/hal.md): an arch-neutral interface over the existing drivers, as thin
    forwarding wrappers (the drivers were not rewritten).
    • Console: console_putc, console_puts, console_put_hex,
      console_put_dec, console_set_color, console_clear,
      console_set_cursor, console_color_t (CONSOLE_*).
    • Input: input_poll_key, input_poll_raw, input_flush.
    • Block device: block_read_sector, block_write_sector.
    • Power: power_reboot, power_shutdown (reachable through hal.h).
    • Boot info: hal_boot_init, boot_get_memory_map, boot_get_module,
      boot_get_info_region, boot_get_cmdline, boot_has_flag, backed by new
      Multiboot2 parsers (memory map, command line) in kernel/multiboot2.h.
      The kernel used to ignore the command line entirely (the debug word of the
      "serial debug mode" GRUB entry was never read).
  • msg(ID), a central table for all user-visible text (one English
    column; not a translation system): kernel/messages.h/.c for the kernel
    (boot log, errors, dumps, exception names, ps states) and
    user/lib/messages.h/.c for the shell, editor and cat (umsg_id_t,
    UMSG_*, linked only into those programs). msg() never returns NULL
    ("(?)" for a bad ID) and works from the exception handler. Output is
    unchanged. selftest/forktest and init/spintest are not migrated.
  • Safe Mode (docs/safemode.md), a recovery environment inside the same
    kernel binary that runs in ring 0 before the PMM, VMM, heap, scheduler,
    exec and syscalls exist:
    • a boot configuration store in one raw sector (LBA 1, inside FAT16's
      reserved region, read and written only through the HAL block I/O, magic
      line # nullos-config v1, empty defaults when the sector is invalid,
      guarded by the boot sector's reserved_sectors) — kernel/bootcfg.h/.c;
    • a boot failure counter (boot_fail_count): incremented right after the
      disk is up, reset on the first keyboard read; at
      BOOTCFG_FAIL_THRESHOLD (3) failed boots in a row, or with safemode on
      the boot command line, the kernel enters Safe Mode instead of booting;
    • a text UI (kernel/safemode.c, static buffers, no heap): reboot normally
      (resets the counter), a reboot submenu, disk info from the raw boot
      sector, and a sector hexdump; Safe Mode is left only by rebooting;
    • a restricted read-only shell (menu item 5, kernel/safeshell.c) that
      initializes the PMM, VMM, heap and FAT16 on demand, once per session, and
      offers help, ls, cat, pwd, cd, back calling FAT16 directly —
      no processes, no exec;
    • GRUB entries "NullOS (Safe Mode)" (safemode flag) and "NullOS
      v (previous release)", which boots the last release's kernel and
      ramfs kept together in the tracked tools/prev/; make snapshot records
      the current build there (run by hand after tagging a release, never
      automatically). tools/prev/ holds the v0.17.1 build.

Changed

  • Everything outside the drivers goes through the HAL: kmain, syscall.c,
    process.c, scheduler.c, exec.c, power.c, memory/{pmm,vmm,heap}.c,
    drivers/pci.c, all disk access in fs/fat16.c, and idt.c's exception
    handler and progress lines (the HAL console holds no state of its own, so
    this adds no risk there). Driver bring-up calls stay direct. kmain's
    Multiboot magic check goes through hal_boot_init().
  • ata_init() runs right after interrupts are enabled, before the PMM (it is
    still called once), so the boot log shows [ATA] before [PMM].
  • pmm_init() consumes the bootloader's real memory map instead of one fixed
    contiguous block: only usable regions are freed (rounded inward to pages,
    fragmented maps supported), the first 1 MB and 1–4 MB stay reserved, and
    kmain marks the ramfs module and the Multiboot2 info block used by their
    real addresses. The allocation ceiling is an explicit 8 MB (PMM_LIMIT_ADDR,
    2048 pages): the kernel touches physical pages through its 0–8 MB identity
    map, so nothing above it is handed out. This is a mitigation of a
    pre-existing bug recorded in PROGRESS.md (fix: Phase 22); [PMM] Total
    in the boot log now shows the allocatable 8192 KB (it used to show the old
    compile-time 32768 KB cap).
  • tools/make_disk.sh passes -R 8 to mkfs.vfat so sector 1 is explicitly
    outside FAT16 (existing disks already have it: 4 reserved sectors).
  • PROGRESS.md records two pre-existing problems found during this phase:
    the kernel writes to physical pages through the identity map without
    checking (elf.c, process.c; Phase 22), and edit with no file name
    cannot save (Ctrl+S reports the misleading "saved (no disk)").
  • kernel/version.h: 0.18.0, phase 18, "Safety/portability foundation".

Fixed

  • pmm_free_pages() over-reported by the total page count since Phase 2:
    pmm_used started at 0 while the bitmap started all-used, so releasing a
    region drove it negative (the old boot log showed Free: 61440KB for
    Total: 32768KB). It now starts at the total; boot free is 1024 pages
    (4096 KB), the real figure.

Full history: CHANGELOG.md