| --- |
| license: other |
| license_name: mii-open-license-v1.0 |
| license_link: https://github.com/cripto-bot/natkernel/blob/master/LICENSE |
| pretty_name: NATKERNEL v3.0 |
| language: |
| - en |
| tags: |
| - kernel |
| - operating-system |
| - n-4-12 |
| - graphlab |
| - universal-grammar |
| - qemu |
| - c |
| - josue-argana |
| - systems-programming |
| - low-level |
| - x86 |
| - bootloader |
| - compression |
| - reproducible-research |
| - research |
| - science |
| task_categories: |
| - other |
| size_categories: |
| - 1K<n<10K |
| --- |
| |
| # 🧬 NATKERNEL v3.0 — Universal Grammar Kernel |
|
|
| **37 modules. 52KB binary. N=7 ∈ [4,12]. Boots in QEMU.** |
|
|
| **Author: Josué Argaña Silguero** |
|
|
| --- |
|
|
| ## What This Is |
|
|
| A functional kernel written in C. Real filesystem, scheduler, memory allocator, crypto. Interactive shell. Compiles with `gcc -m32`. Boots via QEMU multiboot. |
|
|
| --- |
|
|
| ## Quick Start |
|
|
| ```bash |
| git clone https://huggingface.co/datasets/Jose-dev/natkernel |
| cd natkernel |
| make |
| make run |
| ``` |
|
|
| --- |
|
|
| ## Verified Output (QEMU, August 2026) |
|
|
| ``` |
| ===== NATKERNEL v3.0 ===== |
| |
| > write /test HOLA |
| OK 4 bytes |
| > cat /test |
| HOLA |
| > ls |
| / |
| /test |
| > hash NATKERNEL |
| acdc3e9dcd9bbfd69c361db7796a44064d324274f090958612567ed0f9577755 |
| > spawn |
| PID=1 |
| > spawn |
| PID=2 |
| > ps |
| PID STATE |
| 1 READY |
| 2 READY |
| Total: 2 |
| > mem |
| Free: 131072 KB Used: 0 pages |
| > ver |
| N=7 |
| ``` |
|
|
| --- |
|
|
| ## IR Kinds — Universal Grammar |
|
|
| ``` |
| N=7 ∈ [4,12] |
| |
| IR-define — constants, flags, limits |
| IR-typedef — type system |
| IR-struct — data structures (PCB, inode, socket) |
| IR-extern — global state, static tables |
| IR-inline — atomic operations, helpers |
| IR-loop — iteration (for/while) |
| IR-if — control flow, validation |
| IR-return — results, error codes |
| ``` |
|
|
| All 37 modules use only these 7 patterns. |
| Same grammar across USB, PCIe, ATA, filesystem, network, crypto. |
|
|
| --- |
|
|
| ## Real Capabilities |
|
|
| | Command | What it does | API | |
| |---|---|---| |
| | `write` | Create file | vfs_open + vfs_write | |
| | `cat` | Read file | vfs_open + vfs_read | |
| | `ls` | List files | vfs_list | |
| | `ps` | Process list | sched_procs + sched_count | |
| | `spawn` | Create process | sched_spawn | |
| | `hash` | SHA-256 | sha256() | |
| | `mem` | Memory stats | get_free + get_allocated | |
|
|
| --- |
|
|
| ## Architecture |
|
|
| ``` |
| 37 C modules → gcc -m32 → 52KB ELF → QEMU multiboot |
| |
| scheduler.c spawn/tick/yield |
| memory.c alloc_page/free_page/kmalloc |
| filesystem.c vfs_open/read/write/close |
| crypto.c sha256/hmac_sha256/aes_encrypt/rand_u32 |
| shell.c interactive readline + all commands |
| usb.c open/control/descriptor/scan |
| pcie.c init/scan/enable |
| ata.c read/write/identify |
| network.c socket_create/bind/listen/send/recv |
| x86.c IDT/GDT/MSR/TSS |
| ... 27 more |
| ``` |
|
|
| --- |
|
|
| ## Formulas |
|
|
| ``` |
| SHA-256: |
| h0..h7 initial values (FIPS 180-4) |
| 64 rounds per block: Ch, Maj, Σ0, Σ1 |
| Output: 32-byte hash |
| |
| Page Allocator: |
| bitmap[frames/64], O(n) first-fit |
| TOTAL_FRAMES = 128MB / 4096 |
| |
| Scheduler: |
| round-robin queue, PROC_READY/RUNNING/BLOCKED/ZOMBIE |
| sched_spawn → enqueue → sched_tick → schedule |
| |
| VFS: |
| open(name, flags) → fd |
| read(fd, buf, len) → bytes |
| write(fd, buf, len) → bytes |
| close(fd) |
| ``` |
|
|
| --- |
|
|
| ## 🔲 Blueprint: What's Done vs What's Missing |
|
|
| The grammar is complete. The implementations are not. |
| Every missing module follows the **same 7 IR kinds** as the working ones. |
|
|
| ### ✅ Working (compiles, boots, verified) |
|
|
| | Module | What it does | |
| |---|---| |
| | scheduler | spawn/tick/yield, round-robin | |
| | memory | page allocator, kmalloc/kfree | |
| | filesystem | VFS open/read/write/close/list | |
| | crypto | SHA-256, HMAC, AES, RNG | |
| | shell | interactive readline, 7 real commands | |
| | usb | open/control/descriptor/scan | |
| | pcie | init/scan/enable | |
| | ata | read/write/identify | |
| | x86 | IDT/GDT/MSR/TSS | |
| | syscall | write/read/exit/fork/getpid | |
|
|
| ### 🔲 Blueprint Ready (needs implementation) |
|
|
| | Module | What to build | Lines | |
| |---|---|---| |
| | arm64 | GIC, timer, MMU setup | ~200 | |
| | riscv | PLIC, CLINT, SATP, SBI | ~200 | |
| | gpu | PCI BARs, command buffers, vsync | ~300 | |
| | audio | HD Audio controller, DMA buffers | ~250 | |
| | virt | KVM ioctls: VMCS, EPT, vCPU run | ~400 | |
| | network | TCP state machine, ARP, IP routing | ~500 | |
| | smp | IPIs, TLB shootdown, percpu | ~300 | |
|
|
| **All use the same 7 patterns: define, typedef, struct, extern, inline, loop, if, return.** |
|
|
| --- |
|
|
| ## 📝 Citation |
|
|
| ```bibtex |
| @dataset{argana2026natkernel, |
| author = {Josué Argaña Silguero}, |
| title = {NATKERNEL v3.0 — Universal Grammar Kernel}, |
| year = {2026}, |
| publisher = {HuggingFace}, |
| url = {https://huggingface.co/datasets/Jose-dev/natkernel} |
| } |
| ``` |
|
|
| --- |
|
|
| *"The universe speaks a grammar. N is its alphabet size." — Josué Argaña Silguero* |
|
|