debug(mm): 无条件打印 memmap 三参数 + fallback CMOS 原始值

serial.log 显示 memmap 分支(d[..] 转储 / mm: best=)从未打印 → 分支未执行,
size≈4GB 来自 fallback 的 detect_memory_size()(CMOS 读到垃圾)。加两处诊断:
1) init 开头无条件打印 MemmapAddr/MemmapSize/MemmapDescSize;
2) fallback 打印 CMOS 0x15-0x18 与 detect_memory_size 结果。
This commit is contained in:
TermiNexus committed 2026-08-26 19:11:22 +08:00
1 parent 1043343b9d
commit d4200f1129
1 file changed
+13
+13
View File
@@ -503,6 +503,11 @@ def free_memory_regions() -> t.CStatic | t.CVoid:
def init(MemmapAddr: t.CUInt64T, MemmapSize: t.CUInt64T, MemmapDescSize: t.CUInt64T, FbAddr: t.CUInt64T = 0, FbSize: t.CUInt64T = 0):
global BuddySystemObject
import drivers.serial.uart.serial as serial
# [DBG] 无条件打印 memmap 三参数,判定分支未走的根因(用后移除)
_dk0: t.CArray[t.CChar, 100]
viperlib.snprintf(c.Addr(_dk0), 100, "[mm] raw addr=0x%lx size=%lu desc=%lu\n",
MemmapAddr, MemmapSize, MemmapDescSize)
serial.puts(c.Addr(_dk0))
start_addr: t.CVoid | t.CPtr = None
size: t.CUInt64T = 0
if MemmapAddr != 0:
@@ -574,6 +579,14 @@ def init(MemmapAddr: t.CUInt64T, MemmapSize: t.CUInt64T, MemmapDescSize: t.CUInt
start_addr = t.CVoid(best_start, t.CPtr)
size = max_memory
if start_addr is None:
# [DBG] fallback:打印 detect_memory_size 与 CMOS 原始值(用后移除)
_dc0: t.CArray[t.CChar, 100]
viperlib.snprintf(c.Addr(_dc0), 100, "[mm] fallback cmos 0x%02x 0x%02x 0x%02x 0x%02x\n",
cmos_read(0x15), cmos_read(0x16), cmos_read(0x17), cmos_read(0x18))
serial.puts(c.Addr(_dc0))
_dsz: t.CUInt64T = detect_memory_size()
viperlib.snprintf(c.Addr(_dc0), 100, "[mm] fallback detect=%lu\n", _dsz)
serial.puts(c.Addr(_dc0))
size = detect_memory_size()
size = align_4k(size)
# 起始地址 4MB(内核之后),避免超出物理 RAM