Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Hi
I am learning to write the basic OS and right now I am experimenting with the tasks.
I wrote the code for context switching for tasks but I am getting page faults. I do not know why though.
This is how the physical mem is set up: kernel 4 MB to 8MB. User process: 8MB to 12 MB.
Kernel is identity mapped and the user process is at virtual addr 128 MB.
I wrote a simple test program to execute the context switch:
void task()
{
int entry_file=0;
int a;
char *buf_1= (char *)0x8000000; //set the address of the buffer that has the binary file data to virt add 128 MB
a=file_read(buf_1,30);//read the 30 bytes of file data into buffer
entry_file=0x8048234; /entry point into ELF file
/*tss.esp0 is already set to kernel stack 8MB in the main func before the context switch*/
context_switch(entry_file, 0xC00000); //0xC00000=12 MB is the user stack base ptr addr
}
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
If you want to write your own OS you are going to get a lot of Page Faults and GPFs before you get a half-stable system. You really need to track these down for yourself if you want to get anywhere.
I would recommend that you single step through the code at the machine-code level until you get the fault, then examine the registers, the faulting address and look at the virtual memory to see what is happenning. It should be fairly obvious, and you'll learn a lot about your code this way.
Can I recommend the use of SimNow for this sort of low-level debugging; it's a bit slow as an emulator, but has excellent debugging facilities.