N.B: Take a look here Before reading the thread : http://wiki.osdev.org/James_Molloy%27s_ ... Known_Bugs
Hi guys,
To build an OS you should Know how you can catch Bugs , So i tried to catch some
but it seems like debug an OS is a tough task .
take a look at this Toaruos Code source (according to Kevin "it's not a refrence, There are some bugs").
https://github.com/klange/toaruos/tree/ ... a34e573d2a
if comment out the fork() function in main.c, everything goes fine.
did anyone have an idea or suggestions ??
image:
http://postimg.org/image/47gbsm0m1/
Page Fault! on Multitasking James's Kernel code !!
Page Fault! on Multitasking James's Kernel code !!
Last edited by smainoo on Fri Sep 05, 2014 7:34 am, edited 3 times in total.
Re: Page Fault! on Multitasking James's Kernel code !!
The bugginess of the JamesM tutorial's approach to multitasking is well known. I wouldn't go digging through any of my old code (or much of my current code for that matter) as a good lot of it is broken.
Re: Page Fault! on Multitasking James's Kernel code !!
You are right kevin , & delving in such problems is a waste of time if you've something interesting , but for someone who want to learn some debugging skills, he should know why this code didn't work . (am i crazy ??)klange wrote:The bugginess of the JamesM tutorial's approach to multitasking is well known. I wouldn't go digging through any of my old code (or much of my current code for that matter) as a good lot of it is broken.
Re: Page Fault! on Multitasking James's Kernel code !!
After some debugging, finally found some Bugs ... lol.
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).
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).
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.
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).