mboot is a minimal os for i386 platforms.
Building mboot depends on:
- llvm tools (clang, ld.lld)
- nasm
Running mboot needs:
- the building tools or a disk image
- qemu-system-x86_64
make
# normal os
qemu-system-x86_64 -m 4G -drive file=image.img -serial stdio
# with networking enabled
qemu-system-x86_64 -m 4G -drive file=image.img -serial stdio -device e1000,netdev=n0 -netdev user,id=n0 -object filter-dump,id=f1,netdev=n0,file=netdump.pcap
# with networking enabled and UDP forwarded from host port 10007 to guest port 7
qemu-system-x86_64 -m 4G -drive file=image.img -serial stdio \
-device e1000,netdev=n0 \
-netdev user,id=n0,hostfwd=udp::10007-:7 \
-object filter-dump,id=f1,netdev=n0,file=netdump.pcapThe kernel brings up the network interface at boot (stage2/net/net.c): guest IP
10.0.2.15/24 with gateway 10.0.2.2. The init system (user/src/init.c) assigns each
process a tty at spawn: init stays on tty1, the Lua interpreter runs on tty4, the UDP
echo service on tty2, and ping (user/src/ping.c, a raw ICMP socket via
socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) on tty3. Processes cannot rebind their stdio
to a different tty — the kernel rejects dup2 of another tty onto stdin/stdout/stderr.
Run QEMU with host UDP forwarding:
qemu-system-x86_64 -m 4G -drive file=image.img -serial stdio \
-device e1000,netdev=n0 \
-netdev user,id=n0,hostfwd=udp::10007-:7 \
-object filter-dump,id=f1,netdev=n0,file=netdump.pcapFrom the host, send a datagram to the forwarded port:
printf 'hello from host\n' | nc -u -w 1 127.0.0.1 10007If your nc supports listen mode, you can also watch the echoed reply with a second terminal:
nc -u -l 10007On the guest serial log you should see:
NET:andIPV4:messages for the kernel-side interface bring-upping:messages for the raw-socket ICMP echo round trips- an
RX a.b.c.d:src -> 10.0.2.15:7log line for the UDP datagram
- 32 bit protected mode
- cpu exceptions
- individual hardware interrupts
- a ps/2 keyboard
- vga driver
- reading ata drives
- rs232 interface
- the intel 8259 PIC
- the intel 8253 PIT
- the mbr partitioning scheme
- fat 16 as the filesystem
- enable x87 fpu
- memory allocator
- elf loader
- paging
- libc
- implement more demos to show syscalls working

