After some debugging, finally found some Bugs

... lol.
Code: Select all
.............
.............
0x001037d7 <+159>: mov ds:0x105010,eax
0x001037dc <+164>: mov eax,ds:0x105010
0x001037e1 <+169>: mov ebx,DWORD PTR [eax+0x2000]
0x001037e7 <+175>: mov eax,DWORD PTR [ebp-0x14] <----- eax = eip
0x001037ea <+178>: mov edx,DWORD PTR [ebp-0xc]
0x001037ed <+181>: mov ecx,DWORD PTR [ebp-0x10] <----- ecx = ebp
0x001037f0 <+184>: cli asm volatile(" cli; \
0x001037f1 <+185>: mov ecx,eax <---- ecx = eip (overwriting ebp) mov %0, %%ecx; \
0x001037f3 <+187>: mov esp,edx mov %1, %%esp; \
0x001037f5 <+189>: mov ebp,ecx <---- ebp = ecx =eip mov %2, %%ebp; \
0x001037f7 <+191>: mov cr3,ebx mov %3, %%cr3; \
0x001037fa <+194>: mov eax,0x12345 mov $0x12345, %%eax; \
0x001037ff <+199>: sti sti \
0x00103800 <+200>: jmp ecx jmp *%%ecx \
0x00103802 <+202>: add esp,0x14 : : "r"(eip), "r"(esp), "r"(ebp), "r"(current_directory->physicalAddr) );
0x00103805 <+205>: pop ebx
0x00103806 <+206>: pop ebp
0x00103807 <+207>: ret
End of assembler dump.
You can see in the above code that
ebp will receive the value of
eip instead of our stack ebp.
Add clobbered registers to our inline asm, & use ebx instead of ecx solves the problem of "page fault" (on James'S Multitasking code).
Code: Select all
asm volatile(" \
cli; \
mov %0, %%ebx; \
mov %1, %%esp; \
mov %2, %%ebp; \
mov %3, %%cr3; \
mov $0x12345, %%eax; \
sti; \
jmp *%%ebx "
: : "r"(eip), "r"(esp), "r"(ebp), "r"(current_directory->physicalAddr)// );
: "%ebx", "%esp", "%eax");
N.B: after viewing some newer commits i found that Kevin just resolve the problem with this solution, which help me to get the problem.
https://github.com/klange/toaruos/commi ... df1c38be3a.
N.B : On ToaruOS commit (after switch_task() the code just leave the main & stuck in the infinite loop of start.s).