Skip to content

wAIfu-DEV/Wade32

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wade32 Operating System

Wade32 is a home-grown 32-bit x86 kernel and tooling stack for experimenting with operating-system internals on bare hardware. The project ships with its own bootloader, runtime, RAM-backed file system, cooperative scheduler, and an interactive shell implemented entirely in C and NASM.

Kernel Shell


Project Snapshot

  • Custom two-stage BIOS boot path that drops the system straight into 32-bit protected mode before transferring control to kernel_main.
  • Kernel services cover VGA text output, interrupt dispatching, programmable interval timer management, keyboard input, stack-canary checking, pseudorandom seeding, and a cooperative scheduler.
  • All dynamic memory comes from an in-kernel page allocator feeding a debug-wrapped heap allocator (built on the bundled xstd support library).
  • The WFS32 RAM file system provides hierarchical directories, file CRUD, streaming reads/writes, and boots through a validation suite at start-up.
  • A shell-centric user environment hosts 15 compiled-in "kapps" for system inspection, file-system management, and utilities.
  • Everything executes in ring 0; there is no reliance on libc or firmware aside from BIOS/RTC calls during initialization.

Kernel Highlights

  • Boot flow: boot/boot.asm loads the linked kernel image, switches to protected mode using a handcrafted GDT, and jumps to the C entry point defined in boot/kernel_entry.asm.
  • Memory and safety: kernel/allocators/kernel_page_allocator.h manages page frames starting at 0x0010_0000, while kernel_init.h layers a debug heap allocator with allocation tracking; kernel_stack_canary.h installs a periodic stack-canary checker.
  • Scheduling and timing: the PIT runs at 100 Hz; kernel/scheduler/scheduler.h enqueues one-shot or periodic callbacks that the main loop drains alongside keyboard events within kernel_process_loop.h.
  • File system: kernel/filesystem/filesystem_wfs32.h implements the WFS32 RAM-only hierarchy and exposes POSIX-style operations (open/close/read/write/list/create/remove); boot-time tests in kernel/filesystem/fs_tests.h verify correctness.
  • Shell and kapps: the primary shell (kernel/kernel_apps/shell/shell_main.h) multiplexes input listeners and stdout buffers, dispatching to kapps registered in kernel/kernel_apps/kapps_reg.h.
  • Diagnostics: VGA banner updates and uptime counters originate from scheduled routines; panics and fatal errors render descriptive outputs through kernel/kernel_utils.

Directory Guide

  • boot/ - stage-1 boot sector, protected-mode switch code, and glue for embedding the linked kernel image.
  • kernel/ - core kernel sources, subsystems, kapps, and shared types.
  • xstd/ - Wade32's self-contained standard-library replacement (allocators, containers, string utilities, writers).

Shell Commands

Command Description
shell Launch a nested shell session inside the current TTY.
help List all registered kapps with their descriptions.
sysinfo Display ASCII art banner and kernel metadata.
utc Show RTC time (-d/-t/-h flags supported).
args Echo parsed arguments (debug utility for parser).
echo Print the provided arguments verbatim.
cd Change the current working directory (supports ..).
ls List entries in the current directory.
mkdir Create a directory under the current path.
rmdir Remove a directory subtree.
mkfile Create an empty file.
rmfile Delete a file.
write Overwrite a file with provided content.
read Dump the contents of a file.
shutdown Trigger an ACPI shutdown via the I/O port path.

Shell built-ins clear (reset screen) and quit (exit the current session) are handled before dispatch.


Build and Run

  • Install NASM, i386-elf-gcc, i386-elf-ld, and QEMU in your WSL toolchain (the batch script expects them under ~/opt/cross/bin).
  • From Windows, run build.bat; it clears out/, assembles the bootloader and interrupt stubs, compiles the kernel with -ffreestanding, links via kernel/kernel_linker.ld, and packages a 1.44 MB floppy image.
  • On success the script launches qemu-system-i386 -fda out/Wade32.bin. Adjust the executable path at the bottom of build.bat if QEMU is installed elsewhere.
  • To skip auto-launching QEMU, comment out the last command and run your preferred emulator manually.

Development Notes

  • Global state lives in kernel/kernel_globals.h; subsystems register themselves during kernel_init() and share the kGlobal struct for coordination.
  • The cooperative scheduler only runs while kernel_process() drains event queues, so contributors should schedule periodic work instead of spinning in kapps.
  • File-system helpers expect absolute paths starting with root or relative paths resolved against kGlobal.file_system.cwd.
  • Kapps interact with the display through buffered screen regions (kapp_request_screen_buffer) or stdout writers (kapp_request_stdout) to avoid tearing.
  • The bundled xstd library provides allocators, containers, string processing, and buffered writers tailored for freestanding kernels.

Limitations and Next Steps

  • Single-core, ring-0 execution only; no task isolation, paging, or privilege separation.
  • The WFS32 file system is RAM-backed and non-persistent between boots.
  • No block-device driver beyond BIOS int 13h loading; storage beyond the RAM disk is unimplemented.
  • Multitasking is cooperative via the scheduler; there is no context switching between independent processes yet.
  • VGA text mode (80x25) is the sole display target.

Ideas under consideration include hardware-backed file systems, real process scheduling, user-space privilege levels, module loading, and richer shell tooling.

About

[early wip] Attempt at BIOS-compatible OS

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages