my new context swtich code (comment plz on its feasibility)
Posted: Sat Aug 08, 2020 4:45 am
I am doing this in response to comment from this forum that james molloy's context switch code was insane!!
Code: Select all
asm volatile("xchg %%bx, %%bx;"
"cli;"
"push %%edi;"
"push %%esi;"
"push %%ebx;"
"push %%ebp;"
// "pushf;"
"movl %%esp, %0;" // save old esp
"movl $1f, %1;" // save eip
"mov %%cr3, %%eax;"
"movl %%eax, %2;" // save old cr3
"mov %5, %%eax;" // load new cr3
"mov %%eax, %%cr3;"
"mov %4, %%esp;" // load new esp
"jmp *%3;"
"1: ;"
//"mov %3, %%esp;"
//"popf;"
"pop %%ebp;"
"pop %%ebx;"
"pop %%esi;"
"pop %%edi;"
"sti;"
:"=m"(prev->esp),"=m"(prev->eip),"=m"(prev->page_dir->phy_addr):
"m"(current_task->eip), "m"(current_task->esp),"m"(current_task->page_dir->phy_addr)
);