Files
Sylva/AGENTS.md
T
2026-05-24 19:52:01 +08:00

34 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Sylva OS — Agent Guide
x86_64 UEFI hobby OS kernel. C17 boot → C++17 kernel, ELF64 → PE32+ via objcopy.
## Build & Run
| Command | What |
|---------|------|
| `make` | Build `build/BOOTX64.EFI` |
| `make run` | QEMU + OVMF, serial → `serial.log`, paused for GDB (`-s -S`) |
| `make clean` | **Always before commit** — gnu-efi produces untracked files |
## Architecture
- `boot.c` — UEFI entrypoint (`efi_main`), calls `kernel_main()`
- `kernel/main.cpp``extern "C" kernel_main()`: init GOP → serial → PMM → heap → idle loop (`hlt`)
- `kernel/serial.cpp` — UEFI serial protocol wrapper
- `kernel/memory/pmm.cpp` — bitmap + free-list physical page allocator
- `kernel/memory/heap.cpp` — kmalloc/kfree/kcalloc/krealloc (first-fit, coalescing)
- `graphics/` — GOP framebuffer pixel drawing
- `fonts/` — Hankaku 8×16 pixel font renderer
- `gnu-efi/` — git submodule (https://github.com/ncroxon/gnu-efi.git)
## Quirks
- **`uefi_call_wrapper` required for all UEFI protocol calls or kernel page-faults**
- `kernel_main` must be `extern "C"` (C→C++ linkage)
- QEMU starts paused — connect GDB to :1234 to proceed
- No tests, no CI, no lint/formatter config
- C17 (`boot.c`), C++17 (`kernel/`)
- Standards: `-ffreestanding -fno-stack-protector -fshort-wchar -mno-red-zone`
- `#define ASM asm volatile` in `include/common.h`
- `BUILD_INFOS.h` is a placeholder for CI