X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/9b8e0c494de6b447b44454112748f702dffec90d..986ce23ace2f7875a1a561bd947f435a7594146c:/lunaix-os/kernel/k_init.c diff --git a/lunaix-os/kernel/k_init.c b/lunaix-os/kernel/k_init.c index e98be88..a2edf1a 100644 --- a/lunaix-os/kernel/k_init.c +++ b/lunaix-os/kernel/k_init.c @@ -127,11 +127,7 @@ spawn_proc0() proc0->intr_ctx = (isr_param){ .registers = { .ds = KDATA_SEG, .es = KDATA_SEG, .fs = KDATA_SEG, - .gs = KDATA_SEG }, - .cs = KCODE_SEG, - .eip = (void*)__proc0, - .ss = KDATA_SEG, - .eflags = cpu_reflags() }; + .gs = KDATA_SEG } }; proc0->parent = proc0; // 方案1:必须在读取eflags之后禁用。否则当进程被调度时,中断依然是关闭的! @@ -155,19 +151,14 @@ spawn_proc0() VMAP_NULL); } - // 手动设置进程上下文:用于第一次调度 - asm volatile("movl %%esp, %%ebx\n" - "movl %1, %%esp\n" - "pushf\n" - "pushl %2\n" - "pushl %3\n" - "pushl $0\n" - "pushl $0\n" - "movl %%esp, %0\n" - "movl %%ebx, %%esp\n" - : "=m"(proc0->intr_ctx.registers.esp) - : "i"(KSTACK_TOP), "i"(KCODE_SEG), "r"(proc0->intr_ctx.eip) - : "%ebx", "memory"); + struct exec_param* execp = + (struct exec_param*)(KSTACK_TOP - sizeof(struct exec_param)); + + *execp = (struct exec_param){ .cs = KCODE_SEG, + .eip = (void*)__proc0, + .ss = KDATA_SEG, + .eflags = cpu_reflags() }; + proc0->intr_ctx.execp = execp; // 加载x87默认配置 asm volatile("fninit\n"