An OS from Scratch aiming for cyberNet.
BrainDance is an operating system built from scratch. My plans have changed and now its not just an educational project, im going all in for development. I suck at asm but that aint stopping me tho.
- Bootloader: A two-stage 16-bit assembly bootloader. The first stage includes a silent countdown and an optional, simplified BIOS shell. It transitions the CPU to 32-bit protected mode.
- Kernel: A C-based kernel that initializes core systems like the IDT, ISRs, IRQs, and a PIT timer.
- Memory Management: Includes both paging for virtual memory and a simple bump allocator for kernel heap management.
- Drivers: Supports PS/2 keyboard input and ATA (IDE) hard drive for storage.
- Filesystem: A custom-built filesystem, BDFS (BrainDance File System), with support for creating, deleting, reading, and writing files.
- Shell: An interactive command-line interface with commands for file operations, system information (
meminfo,time), and direct hardware access (ataread,atawrite). - Standard Library: A minimal
libcimplementation providing essential functions likememcpy,strlen, and akprintffor formatted output.
The project uses a Makefile to automate the build process.
-
Build the OS:
make
This will produce a bootable disk image named
bdos.img. -
Run with QEMU:
qemu-system-i386 -drive format=raw,file=bdos.img
For a complete and detailed explanation of the OS architecture, components, and functionality, please see the full documentation in docs.md and the BIOS details in bios.md.
- Build a PCI configuration space reader (ports
0xCF8,0xCFC) - Enumerate all PCI devices
- Detect network cards (Class:
0x02, Subclass:0x00)
- Recommended: Intel 82540EM / E1000 (QEMU-supported)
- Alternatives: RTL8139, AMD PCnet
- Map MMIO registers from PCI BAR
- Setup descriptor rings for TX/RX
- Install IRQ handler for NIC
- Implement basic Ethernet frame send/receive
- Print frames via debug shell to verify
- Parse Ethernet headers
- Route frames by EtherType (
0x0800= IPv4,0x0806= ARP)
- Build ARP cache (IP ↔ MAC)
- Handle ARP requests & send ARP replies
- Parse and construct IP headers
- Route IP packets by protocol (ICMP, UDP, TCP)
- Support basic fragmentation (optional early)
- Handle ICMP Echo Request & Reply (Ping)
- Add
ping <ip>command to BD shell
ifconfig– show interface infoping– test ICMParp– print ARP table
- Implement basic UDP parsing & sending
- Build echo/receive tool for testing
- Handle 3-way handshake
- Implement TCP state machine
- Sliding window + ACKs
- Build
echo_serveror simple HTTP fetcher
- Send DNS queries
- Parse responses
- Support A/AAAA record resolution
curl-like app for HTTP- Port scanner
- Reverse shell client/server
- File transfer via TCP
- Packet sniffer (
tcpdump-like) - Raw socket interface
- Packet crafting/injector
- JohnnyNet custom protocol
- USB WiFi NIC driver (very advanced)