[chore] Use gnu-efi as a part of project

This commit is contained in:
2026-05-29 19:06:37 +08:00
Unverified
parent 990c2a6295
commit d31cd01771
94 changed files with 22988 additions and 33 deletions
+12 -14
View File
@@ -1,33 +1,31 @@
# Sylva OS — Agent Guide
x86_64 UEFI hobby OS kernel. C17 boot → C++17 kernel, ELF64 → PE32+ via objcopy.
x86_64 UEFI hobby OS. C17 boot (`.c`) → C++17 kernel (`.cpp`), 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 |
| `make run` | QEMU + OVMF, serial port 1 `serial.log`, serial port 2 → stdio, paused for GDB (`-s -S`) |
| `make clean` | **Always before commit** — gnu-efi build produces untracked files outside `build/` |
## 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`)
- `boot.c` — UEFI entrypoint (`efi_main` `kernel_main()`)
- `kernel/main.cpp``extern "C" kernel_main()`: init GOP → serial → PMM → heap → idle (`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)
- `graphics/` — GOP framebuffer pixel drawing, `fonts/` — Hankaku 8×16 font renderer
- `efi/`bundled gnu-efi source; `gnu-efi/` is an unregistered submodule reference
## Quirks
- **`uefi_call_wrapper` required for all UEFI protocol calls or kernel page-faults**
- **`uefi_call_wrapper` required for all UEFI protocol calls** — omitting it causes page-faults (see `kernel/main.cpp:49`)
- `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`
- QEMU starts paused — connect GDB to `:1234` to proceed
- Compiler standards: C17 (`boot.c`), C++17 (`kernel/`), `-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
- `BUILD_INFOS.h` placeholder for CI; `.github/` is empty
- No tests, no CI, no lint/formatter config