Code: Select all
void TASKING_switch(CPU_REGISTERS *regs)
{
if(bEnabled) //Have we enabled tasking yet?
{
if(task_switched == 1)
{
debug_serial_write("Old EIP =");
debug_serial_write(regs->eip);
debug_serial_write("\n\r");
memcpy(¤t_task->Regs, regs, sizeof(CPU_REGISTERS));
current_task = current_task->Next;
if(current_task == 0)
current_task = task_list_head;
}
konsole_write("Switching Task\n\r");
memcpy(regs, ¤t_task->Regs, sizeof(CPU_REGISTERS));
regs->eip = (DWORD)do_switch;
task_switched = 1;
}
}
Code: Select all
void do_switch(void)
{
HAL_set_esp(current_task->Regs.esp);
jmpPtr jmp = (jmpPtr)current_task->Regs.eip;
jmp();
}
The problem is that when the task comes around for the second time a page fault occurs because due to a read operation at a huge (random) address
I want to work towards solving this problem so I do not expect the code needed to fix this. Any help would be greatly appreciated