承接上篇,Zircon初始化启动,调用hook函数:
void userboot_init(uint)
从函数结尾部分看到:
// Start the process's initial thread.
auto arg1 = static_cast<uintptr_t>(hv);
status = thread->Start(
ThreadDispatcher::EntryState{entry, sp, arg1, vdso_base},
/* initial_thread= */ true);
ASSERT(status == ZX_OK);
init_time.Add(current_time() / 1000000LL);
执行PC地址为entry,参数为arg1以及vdso_base
回溯entry code
// Map in the userboot image along with the vDSO.
UserbootImage userboot(vdso);
uintptr_t vdso_base = 0;
uintptr_t entry = 0;
status = userboot.Map(vmar, &vdso_base, &entry);
ASSERT(status == ZX_OK);
回溯vdso,
// It also gets many VMOs for VDSOs and other things.
const VDso* vdso = VDso::Create();
vdso->GetVariants(&handles[kFirstVdso])

本文详细介绍了Zircon系统在初始化过程中,如何从kernel调用hook函数,执行entry点,传递参数,并通过channel消息启动user进程bootsvc的过程。这一过程涉及的关键文件包括BUILD.gn和start.cc,以及kernel传递的cmd line选项。通过对代码的回溯,读者可以深入理解Zircon的启动机制。

4507

被折叠的 条评论
为什么被折叠?



