old post removed

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.
Post Reply
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

old post removed

Post by Octacone »

old post removed
Last edited by Octacone on Sun Feb 19, 2017 4:14 am, edited 2 times in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
hgoel
Member
Member
Posts: 89
Joined: Sun Feb 09, 2014 7:11 pm
Libera.chat IRC: hgoel
Location: Within a meter of a computer

Re: Paging && Triple Fault && JamesM && Again

Post by hgoel »

Looks like you don't have the identity map setup correctly.
Make sure your code to build the page table is correct.
"If the truth is a cruel mistress, than a lie must be a nice girl"
Working on Cardinal
Find me at [url=irc://chat.freenode.net:6697/Cardinal-OS]#Cardinal-OS[/url] on freenode!
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Paging && Triple Fault && JamesM && Again

Post by Octacone »

removed
Last edited by Octacone on Sun Feb 19, 2017 4:15 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Paging && Triple Fault && JamesM && Again

Post 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?
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Paging && Triple Fault && JamesM && Again

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: Paging && Triple Fault && JamesM && Again

Post by BrightLight »

neon wrote:Never, ever copy and paste memory management code.
Never, ever copy and paste any code.
Fixed it for you.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Paging && Triple Fault && JamesM && Again

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
linuxyne
Member
Member
Posts: 211
Joined: Sat Jul 02, 2016 7:02 am

Re: Paging && Triple Fault && JamesM && Again

Post 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.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Paging && Triple Fault && JamesM && Again

Post by Octacone »

removed
Last edited by Octacone on Sun Feb 19, 2017 4:15 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Paging && Triple Fault && JamesM && Again

Post by Octacone »

removed
Last edited by Octacone on Sun Feb 19, 2017 4:15 am, edited 2 times in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
linuxyne
Member
Member
Posts: 211
Joined: Sat Jul 02, 2016 7:02 am

Re: Paging && Triple Fault && JamesM && Again

Post 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
. . .
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Paging && Triple Fault && JamesM && Again

Post 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!
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Paging && Triple Fault && JamesM && Again

Post by Octacone »

removed fixed
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Post Reply