# ZenKai 13 (Powered by Zenki Microkernel)

[![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](LICENSE)
[![Built with Kiro](https://img.shields.io/badge/Built%20with-Kiro-white.svg)](https://kiro.dev)
[![Rust](https://img.shields.io/badge/Language-Rust%20nightly-orange.svg)]()
[![Architecture](https://img.shields.io/badge/Arch-x86__64-blue.svg)]()

A free, open-source x86_64 microkernel written in Rust.  
Built from scratch. No Linux. No compromises.

> "Power level over complexity."

---

## What is ZenKai 13?

ZenKai 13 is a performance-first microkernel targeting x86_64, built specifically for the Debian 13 ecosystem.
It boots via the Limine bootloader into a higher-half long-mode environment,
and is designed to grow into a full desktop OS with a live kernel HUD.

This is free software. Use it, fork it, learn from it, build on it.

---

## Current Status

| Milestone | Status | Description |
|-----------|--------|-------------|
| M1 | ✅ Done | Limine boot, higher-half kernel, GDT/IDT/paging stubs, VGA splash |
| M2 | 🔨 In progress | Physical memory manager, virtual memory, interrupts, scheduler |
| M3 | ⏳ Planned | Userland, ELF loader, init process, IPC |
| M4 | ⏳ Planned | Limine framebuffer, font renderer, window compositor |
| M5 | ⏳ Planned | Electron HUD connected via host-daemon WebSocket |

---

## Boot Screen

```
  ██╗  ██╗██╗██████╗  ██████╗       ← Kiro (white)
  ██║ ██╔╝██║██╔══██╗██╔═══██╗
  █████╔╝ ██║██████╔╝██║   ██║
  ██╔═██╗ ██║██╔══██╗██║   ██║
  ██║  ██╗██║██║  ██║╚██████╔╝
  ╚═╝  ╚═╝╚═╝╚═╝  ╚═╝ ╚═════╝

  Built with Kiro — the AI dev environment   ← yellow

  ZENKAI 13 |  Milestone 1  |  x86_64        ← red
  [ OK ]  GDT / IDT / Paging / Serial        ← green
  ZenKai 13  M1 online.                       ← red
```

---

## Architecture

```
zenki-os/
├── src/
│   ├── main.rs               ← kernel entry (_start)
│   ├── arch/x86_64/
│   │   ├── boot.rs           ← init + VGA splash
│   │   ├── gdt.rs            ← Global Descriptor Table
│   │   ├── idt.rs            ← Interrupt Descriptor Table
│   │   ├── paging.rs         ← page table management
│   │   └── serial.rs         ← COM1 serial output
│   └── mm/
│       ├── pmm.rs            ← physical memory manager (bitmap allocator)
│       └── limine_map.rs     ← Limine memory map parser
├── host-daemon/              ← reads serial, serves stats via WebSocket
├── limine/                   ← Limine bootloader config
├── linker.ld                 ← higher-half linker script
├── build-iso.sh              ← builds bootable ISO
└── run-qemu.sh               ← boots ISO in QEMU
```

---

## Building

Requires: Debian 13, WSL2 Ubuntu, Rust nightly, xorriso, qemu-system-x86_64

### Debian 13 Setup
```bash
bash setup-debian.sh
```

### Ubuntu / WSL2 Setup
```bash
bash setup-ubuntu.sh
```

### Build Commands
# One shot — build ISO and boot in QEMU
./make.sh

# Build ISO only
./make.sh iso

# Boot existing ISO headless (serial output only)
./make.sh headless
```

---

## Host Daemon (Electron HUD bridge)

The host daemon reads kernel stats from COM1 serial and serves them
over WebSocket to the Electron HUD.

```bash
# Windows — default COM1, ws://127.0.0.1:9000
./host-daemon/target/release/host-daemon

# Custom port
./host-daemon/target/release/host-daemon --serial COM3 --ws-port 9000
```

Electron connects with:
```js
const ws = new WebSocket('ws://127.0.0.1:9000');
ws.onmessage = (e) => console.log(JSON.parse(e.data));
// { type: "line", data: "STAT tick=100 power=1000000 form=Ssj4 ..." }
```

---

## Contributing

All contributions welcome. This is open source — fork it, open issues, send PRs.

Areas that need work:
- Physical memory manager (M2 — in progress)
- Virtual memory / page table management
- Timer interrupts (APIC, 1000Hz)
- Process scheduler
- Userland ELF loader
- Framebuffer graphics

---

## License

MIT — see [LICENSE](LICENSE).  
Free for anyone to use, modify, and distribute.

---

## Credits

Built by the Zenki OS contributors with [Kiro](https://kiro.dev) — the AI dev environment.
