1. allocate some task descriptor
2. possibly link it to some process structure, increment identifier context, etc.
3. prepare the stack frame so that it matches the 'pops' in stack_switch (we want to cheat the dispatcher and make it believe that the new spawned task is just another task from which it switched out earlier
Code: Select all
dword* sp=(dword*) me->cpuState.esp;
/* we assume we have a kernel stack aligned on the datasegment. */
sign("preparing core->kernel return\n");
*(--sp)=(dword)entry; /* sets up the return address to the entry point */
*(--sp)=0; /* starts with a nul %ebp value */
*(--sp)=IA32_INITFLAGS|IA32_INTERRUPT; /* stores the flags */
*(--sp)=0; /* FS selector will be null */
sp=sp-8; /* skip 8 values for generic registers (should be null). */
me->cpuState.esp=(dword) sp;
sign("final esp value = %x\n",me->cpuState.esp);
