Isso gera o arquivo `adros-x86.bin`.
### Criar ISO Bootável (GRUB)
-Para x86, precisamos empacotar o kernel numa ISO com GRUB.
+Para x86, o repositório já inclui uma árvore `iso/` com o GRUB configurado.
-1. Compile o gerador de InitRD:
```bash
-gcc tools/mkinitrd.c -o mkinitrd
+make ARCH=x86 iso
```
-2. Crie arquivos de teste:
-```bash
-echo "Hello from File System!" > test.txt
-echo "AdrOS v0.3" > version.txt
-./mkinitrd initrd.img test.txt version.txt
-```
+Isso gera `adros-x86.iso`.
-3. Empacote a ISO:
+### Rodar no QEMU
```bash
-mkdir -p iso_root/boot/grub
-cp adros-x86.bin iso_root/boot/
-cp initrd.img iso_root/boot/
-
-cat > iso_root/boot/grub/grub.cfg << EOF
-menuentry "AdrOS" {
- multiboot2 /boot/adros-x86.bin
- module2 /boot/initrd.img
- boot
-}
-EOF
-
-grub-mkrescue -o adros.iso iso_root
+make ARCH=x86 run
```
-### Rodar no QEMU
+Saídas/artefatos gerados:
+- `serial.log`: log do UART (saída principal do kernel)
+- `qemu.log`: só é gerado quando o debug do QEMU está habilitado (veja abaixo)
+
+Para habilitar debug do QEMU (mais leve por padrão, para evitar travamentos por I/O excessivo):
```bash
-qemu-system-i386 -cdrom adros.iso -serial stdio
+make ARCH=x86 run QEMU_DEBUG=1
```
-- A saída de texto aparecerá no terminal (`-serial stdio`).
-- Se tivermos VGA ativado, uma janela gráfica abrirá.
## 3. Compilando e Rodando (ARM64)
## 5. Troubleshooting Comum
- **"Multiboot header not found"**: Verifique se o `grub-file --is-x86-multiboot2 adros-x86.bin` retorna sucesso (0). Se falhar, a ordem das seções no `linker.ld` pode estar errada.
-- **Triple Fault (Reset infinito)**: Geralmente erro na tabela de paginação (VMM) ou IDT mal configurada. Use `-d int,cpu_reset -D log.txt` no QEMU para debugar.
+- **"Triple Fault (Reset infinito)"**: Geralmente erro na tabela de paginação (VMM) ou IDT mal configurada. Rode `make ARCH=x86 run QEMU_DEBUG=1` e inspecione `qemu.log`.
- **Tela preta (VGA)**: Se estiver rodando com `-nographic`, você não verá o VGA. Remova essa flag para ver a janela.
- **Bootloader:** GRUB2 (Multiboot2 compliant)
- **Build System:** Make + Cross-Compilers
+## Features
+- **Multi-arch build system**
+ - `make ARCH=x86|arm|riscv|mips`
+ - x86 is the primary, working target
+- **x86 (i386) boot & memory layout**
+ - Multiboot2 (via GRUB)
+ - Higher-half kernel mapping (3GB+)
+ - Early paging + VMM initialization
+ - W^X-oriented linker layout (separate RX/R/RW segments)
+ - Non-executable stack markers in assembly (`.note.GNU-stack`)
+- **Memory management**
+ - Physical Memory Manager (PMM)
+ - Virtual Memory Manager (x86)
+ - Kernel heap allocator (`kmalloc`/`kfree`)
+- **Basic drivers & console**
+ - UART serial console logging
+ - VGA text console (x86)
+ - Keyboard driver + input callback
+ - PIT timer + periodic tick
+- **Kernel services**
+ - Simple scheduler / multitasking (kernel threads)
+ - Basic shell with built-in commands
+- **InitRD + VFS glue**
+ - InitRD-backed filesystem node tree
+ - Minimal VFS helpers (`vfs_read`/`vfs_write`/open/close)
+- **Syscalls & ring3 bring-up (x86)**
+ - `int 0x80` syscall gate
+ - `SYSCALL_WRITE`, `SYSCALL_EXIT`, `SYSCALL_GETPID`
+ - Centralized user-pointer access API (`user_range_ok`, `copy_from_user`, `copy_to_user`)
+ - Ring3 stub test program with fault-injection for invalid pointers
+
+## TODO
+- **Multi-architecture kernel bring-up**
+ - Implement VMM/interrupts/scheduler for ARM/RISC-V/MIPS
+ - Standardize arch entrypoint behavior (`arch_start`) across architectures
+- **Userspace**
+ - Real userspace loader (e.g., ELF)
+ - Process address spaces + page fault handling
+ - Safer syscall ABI expansion
+- **Virtual memory hardening**
+ - Reduce early identity mapping further (keep only what is required)
+ - Guard pages, user/kernel separation checks beyond current page-walk
+- **Filesystem**
+ - Persisted storage (ATA/AHCI/virtio-blk or similar)
+ - Path resolution, directories, permissions
+- **Observability & tooling**
+ - Better memory stats (`mem` shell command)
+ - Debug facilities (panic backtraces, symbolization, structured logs)
+
## Directory Structure
- `src/kernel/` - Architecture-independent kernel code
- `src/arch/` - Architecture-specific code (boot, context switch, interrupts)