fix(mm): get_block_size 移位改 64 位,修复伙伴初始化无限循环
4096<<20 在 i32 下溢出为 0x0 → bs=0x0 → cur_addr/remaining 不变 → 无限循环 ([mm] it=1..6 order=20 bs=0x0 addr 不变)。改 t.CUInt64T 移位。另增关键数值 打印(memmap addr/size/desc/entries),配合描述符转储定位 4GB 伪可用区。
This commit is contained in:
1 parent
f9ec205816
commit
1043343b9d
1 file changed
+8
-1
@@ -86,7 +86,9 @@ def get_order(size: t.CUInt64T) -> t.CStatic | t.CInt:
|
||||
|
||||
# 计算块大小
|
||||
def get_block_size(order: t.CInt) -> t.CStatic | t.CUInt64T:
|
||||
return MIN_BLOCK_SIZE << order
|
||||
# 4096 << 20 = 4GB 超出 i32 范围 → 0x0 → 伙伴初始化无限循环(bs=0x0)。
|
||||
# 必须用 64 位移位(4096<<20 = 4294967296)。
|
||||
return t.CUInt64T(MIN_BLOCK_SIZE) << t.CUInt64T(order)
|
||||
|
||||
|
||||
@t.Object
|
||||
@@ -507,6 +509,11 @@ def init(MemmapAddr: t.CUInt64T, MemmapSize: t.CUInt64T, MemmapDescSize: t.CUInt
|
||||
if MemmapSize > 0:
|
||||
if MemmapDescSize > 0:
|
||||
num_entries: t.CUInt64T = MemmapSize / MemmapDescSize
|
||||
# [DBG] 关键数值:memmap 缓冲/步长/条目数(用后移除)
|
||||
_dk1: t.CArray[t.CChar, 100]
|
||||
viperlib.snprintf(c.Addr(_dk1), 100, "[mm] addr=0x%lx size=%lu desc=%lu entries=%lu\n",
|
||||
MemmapAddr, MemmapSize, MemmapDescSize, num_entries)
|
||||
serial.puts(c.Addr(_dk1))
|
||||
max_memory: t.CUInt64T = 0
|
||||
best_start: t.CUInt64T = 0
|
||||
best_avail_size: t.CUInt64T = 0
|
||||
|
||||
Reference in new issue
Block a user