File size: 4,663 Bytes
54a7b2b eb22f4a 54a7b2b eb22f4a 8ad4ba9 9fa2ea2 54a7b2b 79ed5e2 8ad4ba9 eb22f4a 8ad4ba9 79ed5e2 eb22f4a 8ad4ba9 79ed5e2 8ad4ba9 79ed5e2 8ad4ba9 79ed5e2 8ad4ba9 79ed5e2 54a7b2b 8ad4ba9 54a7b2b 79ed5e2 8ad4ba9 eb22f4a 8ad4ba9 79ed5e2 8ad4ba9 eb22f4a 8ad4ba9 eb22f4a 8ad4ba9 eb22f4a 8ad4ba9 eb22f4a 8ad4ba9 eb22f4a 8ad4ba9 ea71991 8ad4ba9 79ed5e2 8ad4ba9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | ---
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*
|