This turns the MMUKO boot idea into a tiny QEMU-bootable kernel.
Important distinction:
mmuko-boot.c from the gist is a normal hosted C program. It uses printf,
malloc, calloc, and the host OS C runtime.This scaffold supports two boot paths.
This path uses the tools already common in a MinGW + QEMU setup:
asgccldqemu-system-i386Build the raw boot image:
.\build-direct.ps1
Run it:
qemu-system-i386 -drive format=raw,file=build\mmuko-direct.img,if=ide,index=0 -display none -serial stdio -no-reboot
The kernel deliberately halts at the end, so QEMU will keep running until you
stop it with Ctrl+C.
The direct boot path works like this:
boot16.s starts as a 512-byte BIOS boot sector.kernel-flat.bin from disk LBA 1 into memory at 0x10000.kernel-entry.s.kernel-entry.s calls kernel_main() in kernel.c.The GRUB path uses GRUB Multiboot as the loader:
kernel_main() initializes screen and serial output.mmuko_boot() runs the MMUKO boot phases.mmuko_program_main() runs after boot succeeds.boot.asm - Multiboot entry point and stack setup.boot16.s - Direct BIOS boot sector.kernel-entry.s - Direct boot flat-kernel entry point.kernel.c - Freestanding MMUKO boot model and example MMUKO program.linker.ld - Places the kernel at 1 MiB for GRUB.linker-flat.ld - Places the direct boot kernel at 0x10000.grub.cfg - GRUB menu entry.Makefile - Builds an ISO and runs it in QEMU.build-direct.ps1 - Builds the direct BIOS boot image on Windows.The easiest path on Windows is WSL or MSYS2 with:
nasmi686-elf-gccgrub-mkrescuegrub-filexorrisoqemu-system-i386makeOn a Debian/Ubuntu-like environment, QEMU/GRUB/NASM can usually be installed with:
sudo apt install make nasm grub-pc-bin grub-common xorriso qemu-system-x86
You still need an i686-elf-gcc cross compiler. If you do not have one yet,
use an OSDev-style cross compiler, or adapt the Makefile to your existing
freestanding i386 compiler.
make
make run
QEMU will show VGA text, and the same log is also written to serial with
-serial stdio.
Edit this function in kernel.c:
static void mmuko_program_main(MMUKO_System *sys)
That function is the first MMUKO "program" in this scaffold. It only runs after
mmuko_boot(sys) returns BOOT_OK.
Later, you can replace it with a loader that reads a separate payload from disk and jumps to it, but compiling the program into the kernel is the simplest way to experiment with QEMU first.
11 commits
C
55.3%
Papyrus
18.7%
Python
14.4%
Makefile
4.3%
PowerShell
3.3%
Assembly
3.3%
This turns the MMUKO boot idea into a tiny QEMU-bootable kernel.
Important distinction:
mmuko-boot.c from the gist is a normal hosted C program. It uses printf,
malloc, calloc, and the host OS C runtime.This scaffold supports two boot paths.
This path uses the tools already common in a MinGW + QEMU setup:
asgccldqemu-system-i386Build the raw boot image:
.\build-direct.ps1
Run it:
qemu-system-i386 -drive format=raw,file=build\mmuko-direct.img,if=ide,index=0 -display none -serial stdio -no-reboot
The kernel deliberately halts at the end, so QEMU will keep running until you
stop it with Ctrl+C.
The direct boot path works like this:
boot16.s starts as a 512-byte BIOS boot sector.kernel-flat.bin from disk LBA 1 into memory at 0x10000.kernel-entry.s.kernel-entry.s calls kernel_main() in kernel.c.The GRUB path uses GRUB Multiboot as the loader:
kernel_main() initializes screen and serial output.mmuko_boot() runs the MMUKO boot phases.mmuko_program_main() runs after boot succeeds.boot.asm - Multiboot entry point and stack setup.boot16.s - Direct BIOS boot sector.kernel-entry.s - Direct boot flat-kernel entry point.kernel.c - Freestanding MMUKO boot model and example MMUKO program.linker.ld - Places the kernel at 1 MiB for GRUB.linker-flat.ld - Places the direct boot kernel at 0x10000.grub.cfg - GRUB menu entry.Makefile - Builds an ISO and runs it in QEMU.build-direct.ps1 - Builds the direct BIOS boot image on Windows.The easiest path on Windows is WSL or MSYS2 with:
nasmi686-elf-gccgrub-mkrescuegrub-filexorrisoqemu-system-i386makeOn a Debian/Ubuntu-like environment, QEMU/GRUB/NASM can usually be installed with:
sudo apt install make nasm grub-pc-bin grub-common xorriso qemu-system-x86
You still need an i686-elf-gcc cross compiler. If you do not have one yet,
use an OSDev-style cross compiler, or adapt the Makefile to your existing
freestanding i386 compiler.
make
make run
QEMU will show VGA text, and the same log is also written to serial with
-serial stdio.
Edit this function in kernel.c:
static void mmuko_program_main(MMUKO_System *sys)
That function is the first MMUKO "program" in this scaffold. It only runs after
mmuko_boot(sys) returns BOOT_OK.
Later, you can replace it with a loader that reads a separate payload from disk and jumps to it, but compiling the program into the kernel is the simplest way to experiment with QEMU first.
11 commits
C
55.3%
Papyrus
18.7%
Python
14.4%
Makefile
4.3%
PowerShell
3.3%
Assembly
3.3%