fix(ide,elf): 移除每次读扇区前的 0x3F6 SRST 软复位写(Gargantua 大数据段读取中途 waitDataReady 失败根因);spawn_elf 用指针算术替代 path[name_start:] 切片传参并加 entry/pid 运行时诊断
This commit is contained in:
1 parent
25d2628cd4
commit
038b0a428e
2 files changed
+16
-3
No files matched your search
@@ -322,6 +322,12 @@ def _elf_entry_wrapper(arg: t.CVoid | t.CPtr) -> t.CInt:
|
||||
proc.switch_pid(pid)
|
||||
cur_p: proc.Process | t.CPtr = proc.ProcessManager.current()
|
||||
entry_fn: t.CVoid | t.CPtr = cur_p.entry
|
||||
# [DIAG] 定位用户进程首个指令 PF:打印 entry 实际值(PF cr2=ELF 物理区最后一页,
|
||||
# 疑似 entry 被写成 phys 地址而非虚拟 0x400000)。
|
||||
_dbw: t.CArray[t.CChar, 160]
|
||||
viperlib.snprintf(c.Addr(_dbw), 160, "[wrap] pid=%d cur=0x%lx ent=0x%lx ebase=0x%lx ks=0x%lx us=0x%lx\n",
|
||||
pid, t.CUInt64T(cur_p), t.CUInt64T(entry_fn), cur_p.elf_base, cur_p.kern_stack, cur_p.user_stack)
|
||||
serial.puts(c.Addr(_dbw))
|
||||
if entry_fn is not None:
|
||||
user_stack_vtop: t.CUInt64T = USER_STACK_VTOP
|
||||
us_sz: t.CUInt64T = USER_STACK_SIZE
|
||||
@@ -442,7 +448,10 @@ def spawn_elf(path: t.CConst | str) -> t.CInt:
|
||||
paging.set_active_pml4(_kernel_cr3)
|
||||
asm.sti()
|
||||
|
||||
p: proc.Process | t.CPtr = proc.ProcessManager.create_process(path[name_start:], entry)
|
||||
# path[name_start:] 切片表达式 translate_subscript 不支持 Slice(返回 None)→
|
||||
# 作为实参丢 name、entry 错位成第一参数(TPV 已修,此处指针算术双保险)
|
||||
nm_ptr: t.CConst | t.CChar | t.CPtr = t.CConst(t.CUInt64T(path) + t.CUInt64T(name_start), t.CPtr)
|
||||
p: proc.Process | t.CPtr = proc.ProcessManager.create_process(nm_ptr, entry)
|
||||
if p is None:
|
||||
serial.puts("[elf] spawn: create_process failed\n")
|
||||
fat32.unlock()
|
||||
@@ -463,6 +472,10 @@ def spawn_elf(path: t.CConst | str) -> t.CInt:
|
||||
slog: t.CArray[t.CChar, 80]
|
||||
viperlib.snprintf(c.Addr(slog), 80, "[elf] spawn: pid=%d tid=%d entry=0x%lx pml4=0x%lx\n", p.pid, tid, t.CUInt64T(entry), p.pml4_root)
|
||||
serial.puts(slog)
|
||||
# [DIAG] 确认 return p.pid 的实际值(main 收到 pid=0 而此处打印 3)
|
||||
_dbw2: t.CArray[t.CChar, 64]
|
||||
viperlib.snprintf(c.Addr(_dbw2), 64, "[elf] spawn ret pid=%d\n", p.pid)
|
||||
serial.puts(c.Addr(_dbw2))
|
||||
fat32.unlock()
|
||||
return p.pid
|
||||
|
||||
|
||||
Reference in new issue
Block a user