- // This surely need to be simplified or encapsulated!
- // It is a living nightmare!
-
- extern void my_dummy();
- static char dummy_stack[DUMMY_STACK_SIZE] __attribute__((aligned(16)));
-
- struct exec_param* execp =
- (void*)dummy_stack + DUMMY_STACK_SIZE - sizeof(struct exec_param);
-
- *execp = (struct exec_param){
- .cs = KCODE_SEG,
- .eflags = cpu_reflags() | 0x0200,
- .eip = (ptr_t)my_dummy,
- .ss = KDATA_SEG,
- };
-
- // memset to 0
- dummy_proc = (struct proc_info){};
- dummy_proc.intr_ctx = (isr_param){ .registers = { .ds = KDATA_SEG,
- .es = KDATA_SEG,
- .fs = KDATA_SEG,
- .gs = KDATA_SEG },
- .execp = execp };
-
- dummy_proc.page_table = cpu_rcr3();
- dummy_proc.state = PS_READY;
- dummy_proc.parent = &dummy_proc;
- dummy_proc.pid = KERNEL_PID;
-
- __current = &dummy_proc;
+ thread->state = PS_RUNNING;
+ thread->process->state = PS_RUNNING;
+ thread->process->th_active = thread;
+
+ procvm_mount_self(vmspace(thread->process));
+ set_current_executing(thread);
+
+ switch_context();
+
+ fail("unexpected return from switching");