TermiNexus
b33fbb75dc
fix(boot): read the ACPI RSDP before taking the memory-map key
...
ExitBootServices failed with EFI_INVALID_PARAMETER because Print ran
after GetMemoryMap, so the console output could change the memory map
and invalidate MapKey. Locate the RSDP and print it before GetMemoryMap.
2026-10-27 17:14:51 +08:00
TermiNexus
7e0aa5c7af
feat(acpi): power off via the ACPI FADT
...
Pass the firmware ACPI RSDP through boot_info so the kernel can locate
the FADT. Shutdown now writes the S5 sleep type to the PM1a/PM1b control
blocks advertised by the FADT instead of fixed QEMU/Bochs/VirtualBox
ports.
- boot: capture the ACPI 2.0/1.0 RSDP from the UEFI configuration table
- kernel: add platform/acpi; walk RSDP -> RSDT/XSDT -> FADT
- syscall: power_shutdown calls acpi.poweroff()
2026-10-27 17:05:05 +08:00
TermiNexus
ad6f0f68a2
chore(boot): GOP 显示模式改用 22
...
同时精简 GOP 初始化处的冗余注释。bootx64.efi 为编译产物,已停止跟踪,
需要时用 build.py --bootloader 重编。
2026-10-26 22:41:52 +08:00
TermiNexus
1ebb744418
fix(boot, build): bootloader 预留补上内核 .bss(多留 256KB);build 跳过路径过期的 kernel.elf
...
崩溃症状:paging.init 清 CR0.WP 的窗口里遍历页表时 #GP(cr0=0x80000033 → WP=0),
随内核体积变化时有时无。
根因分析(已实测确认):kernel.bin 由 ld.lld --oformat binary 产出,链接脚本里那条
“强制 .bss 为 PROGBITS”的写法对 lld 无效 —— 实测 kernel.bin 只有 249088 字节(0x3CD00),
而 .bss 结尾在 ~0x14B900,即约 60KB 的 .bss 尾部并未写进文件。bootloader 只按文件大小
预留物理页(61 页 → 0x100000..0x13D000),于是 .bss 尾部落在未预留的 EfiConventionalMemory
中:bootloader 自身的分配(页表、缓冲等)可能落进去,内核一写 .bss 就把它们破坏 ——
表现就是 paging.init 遍历到被破坏的页表项而 #GP,且随体积变化“时有时无”。
修改:
- boot/boot.c:PagesNeeded 在文件大小之外显式多预留 64 页(256KB),覆盖 .bss 并留余量。
- build.py:生成 kernel.elf 前逐个校验 .bat 里的 .obj 是否存在,缺失即跳过并给出提示
(--rebuild-includes 后 includes.binary_mlir 下目标文件名会变,.bat 路径会过期)。
注意:本修复需要同时重编 bootloader(python build.py --bootloader)才生效。
2026-10-14 15:17:13 +08:00
TermiNexus
0919a058a8
fix(vkernel): 预留内核 .bss 与栈区,修堆 arena 覆盖未预留内核内存
...
根因:bootloader 只按 kernel 文件大小 AllocatePages(.bss 不占文件),于是 .bss
尾部(ticks/_perf_* 等全局量)与主线程栈区(0x60000~0x80000)在 memmap 里仍是
EfiConventionalMemory,被内核 mm 的堆 arena 当作空闲内存占用 → 内核全局量被写坏、
堆元数据被反向破坏,最终桌面线程栈上的 va_list 被改坏,vsnprintf 读 %d 变参时
#GP(rip=0x130d45, err=0x0)。
- linker.ld: .bss 末尾加 LONG(0) 强制 PROGBITS,使 kernel.bin 的 FileSize 涵盖
.bss,bootloader 的 PagesNeeded 得以预留整块内核镜像(含 .bss)
- mm.init: 新增 KernelAddr/KernelEnd,挑 arena 时把与内核镜像 [kernel_PhysAddr,
__bss_end) 重叠的 region 起点抬到镜像末端(不整段丢弃)
- main.vp: 取 __bss_end 并传入 mm.init
- boot.c: ExitBootServices 前用 AllocatePages(AllocateAddress, EfiLoaderData)
占位内核栈区 0x60000~0x80000,使其在 memmap 中标记已用
另含在途整理:多处补显式收窄转换(uint8()/uint16() 等)、kbd_svc 构造改为
kbd_svc.__init__() 等。
2026-10-14 12:54:43 +08:00
Viper
6813947181
Initial import of ViperOS
2026-07-19 12:38:20 +08:00