Page 1 of 1
old post removed
Posted: Sat Aug 06, 2016 3:39 pm
by Octacone
old post removed
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 3:59 pm
by hgoel
Looks like you don't have the identity map setup correctly.
Make sure your code to build the page table is correct.
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 4:03 pm
by Octacone
removed
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 9:40 pm
by BrightLight
Practically thinking, you shouldn't use a tutorial for something as important as paging. Paging is something that plays such a role in design, that you should design it yourself. Personally, the first time I enabled paging, I did so by trial and error without tutorials. Just the Paging Wiki entry was good enough for me.
I don't know much about JamesM's tutorial's design, but how do you have kmalloc() without paging?
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 9:55 pm
by neon
Rule of thumb: Never, ever copy and paste memory management code. It simply doesn't work. Farther, never, ever copy and paste code unless you completely understand what the code does inside and out and can actually already build it yourself and are only doing it to save some time. Memory management code tends to rely on many hidden details since it ties so close with your system architecture and structure that copying and pasting it almost never works.
If you don't know or don't have access to a good debugger such as bochsdbg, I'd advise getting access before going any farther. Posting code and hoping someone sees problems can only go so far. The Bochs debugger has a nice set of paging commands that you can use to view the page tables and page mappings.
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 10:01 pm
by BrightLight
neon wrote:Never, ever copy and paste memory management code.
Never, ever copy and paste
any code.
Fixed it for you.
Re: Paging && Triple Fault && JamesM && Again
Posted: Sat Aug 06, 2016 10:08 pm
by neon
I used to hold that stance but remember getting into a debate here about that some time ago. Personally I don't see the problem as long as you know what the code does and why. Note I use the term know here - i.e. you can already write the code in your sleep.
Re: Paging && Triple Fault && JamesM && Again
Posted: Sun Aug 07, 2016 12:29 am
by linuxyne
* GetPage returns a pointer to the PTE corresponding to the given address i. If AllocateFrame fills that PTE, it needs to know i. It is not sent i.
* Use bochsdbg to reach the insn just before the crash, and print the paging structures.
Re: Paging && Triple Fault && JamesM && Again
Posted: Sun Aug 07, 2016 4:01 am
by Octacone
removed
Re: Paging && Triple Fault && JamesM && Again
Posted: Sun Aug 07, 2016 4:12 am
by Octacone
removed
Re: Paging && Triple Fault && JamesM && Again
Posted: Sun Aug 07, 2016 5:11 am
by linuxyne
octacone wrote:
I can't get any output from int i because my code never reaches there I think.
Here is something interesting (take a look at kernel directory at the top/bottom output):
It was mentioned earlier that the code stops working right after SwitchPageDirectory enables paging.
But the screenshot shows that InstallPaging (and therefore SwitchPageDirectory too) runs to completion.
Did the problem change? Regardless of any changes, bochsdbg should help.
The screenshot output can be explained by this portion of InstallPaging:
Code: Select all
. . .
WriteOutputToQemu(kernelDirectory); //debugging
. . .
kernelDirectory = (page_directory_t*) kmallocA(sizeof(page_directory_t));
. . .
WriteOutputToQemu(IntToString(kernelDirectory)); //debugging
. . .
Re: Paging && Triple Fault && JamesM && Again
Posted: Sun Aug 07, 2016 8:24 am
by iansjack
octacone wrote:
This is my way of learning: see a tutorial, try to reproduce it, start fixing bugs and adapting code, that makes you understand stuff better, because debugging makes your learn stuff you don't get.
I think you are quite correct. You have been given some good tips as to how to debug your problem. Now, get to it and start learning!
Re: Paging && Triple Fault && JamesM && Again
Posted: Tue Aug 09, 2016 2:31 am
by Octacone
removed fixed