Page 1 of 1
[Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 1:01 am
by zhiayang
Okay. Bear with me, i know this has probably been asked many times, and I KNOW the cause is that my pages are not memory mapped. But I don't understand how to solve it.
Right. I followed Bran's tutorial for setting up GDT, IDT and all that, then started working on a shell, just for an easier way to test things. Now I want memory management, and I've been using JMolloy's tutorial for that.
I copied code from 6.-Paging and 7.-The Heap and edited the references and stuff, and I got it to compile. (Finally). But as you might have guessed from the title, it hangs when it enters the switch_page_directory function.
I have tried to scrap things of the random internet in hopes of getting it to work, even trying a higher-half kernel (both the bare_bones and GDT version, I'm using grub) but I keep getting error 7. Either way, I can't get anything to work. Would someone be kind enough to help me?
Also, how do I get QEMU to actually reboot on a triple-fault? Now it just hangs on me.
PS: No code yet, I'm downloading something and my linux VM is on my OSX partition...
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 1:16 am
by thepowersgang
Trick #1, use bochs (with the debugger enabled)
#2, Make sure you set CR3 to the _physical_ address
#3, Ensure you have identity paging set up as well as what you want to end up using.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 1:29 am
by zhiayang
thepowersgang wrote:Trick #1, use bochs (with the debugger enabled)
#2, Make sure you set CR3 to the _physical_ address
#3, Ensure you have identity paging set up as well as what you want to end up using.
#1: Okay, but is there a binary for linux? It won't compile.
#2: How do I do that?
#3: How?
Yes, I'm a newb.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 1:47 am
by VolTeK
requimrar wrote:#1: Okay, but is there a binary for linux? It won't compile.
#2: How do I do that?
#3: How?
From what i have heard about his tutorials, they are good enough, that no questions are asked
Or maybe you need to know what those registers are and how to interact with them before reading the tutorial?
requimrar wrote:Yes, I'm a newb.
Your a newb if you say you are one. Using the word is bad enough.
Give that tutorial a good and through re-read. Always assume answers are not going to come easy, if they are easy to answer
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 2:04 am
by bluemoon
requimrar wrote:I copied code from 6.-Paging and 7.-
This is where things start getting wrong. Copy & paste from tutorial is probably the worst method to learn things.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 3:32 am
by zhiayang
bluemoon wrote:
This is where things start getting wrong. Copy & paste from tutorial is probably the worst method to learn things.
Well yes, but it's the best way for me to learn things, by example. Get it to work, modify it, then finally write my own.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 9:24 am
by zhiayang
berkus wrote:
Sooo... get it to work then?
Well, yes actually! I typed everything from scratch this time, and it WORKED! But here's another problem: (posting it here cuz I dun wanna spam topics)
James Molloy's tutorial has the part at the end where he forcefully causes a page fault, and I did that too. Problem? Nothing. which is the problem. No error, no fault, no nothing. Things just carry on. At first I thought maybe 0xA0000000 was a bit low, so I used overkill of 0xFFFFFFFF but err... nothing happens. At all.
Code: Select all
void init_paging()
{
unsigned int mem_end = MEM_END_PAGE;
nframes = mem_end / 0x1000;
frames = (unsigned int)kmalloc(INDEX_FROM_BIT(nframes));
memset(frames, 0, INDEX_FROM_BIT(nframes));
Where there was supposed to be 0x1000000 there, I put MEM_END_PAGE, which is defined in one of my header files (as 0x1000000, no less).
So, what's with the lack of the problem?
EDIT: Was conducting further testing, I realised that if i changed the "end" of memory to 0x100000 as opposed to 0x1000000 (1 less zero), the OS will triple fault on switch_directory. However, increasing that value (I tried 0xF00000) will solve the problem. Either way, I can't get page faults to work. Also, can someone explain to me why it will triple fault on 0x100000 and not 0xF00000?
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 10:10 am
by VolTeK
requimrar wrote:I typed everything from scratch this time
Tainted thoughts. Its too late forget about learning it -.-
That is NOT the way to learn this! If you think its how you should learn you had better change soon or you will be copying someones os!
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 10:31 am
by zhiayang
GhostXoPCorp wrote:requimrar wrote:I typed everything from scratch this time
Tainted thoughts. Its too late forget about learning it -.-
That is NOT the way to learn this! If you think its how you should learn you had better change soon or you will be copying someones os!
What. I stared long and hard at his code, understood it, twrote my own. The problem is still not solved. The question is not about how I learn things, or if my os is a copy of someone elses. (Tho rest assured it is not.). I don't mean to sound rude, but how about we get back on topic?
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 10:57 am
by bluemoon
I'm trying to bring up the idea that, although we can provide solution to this typical, frequently asked problem, you will face much more problems on next steps.
If it sound surprising, getting paging, IDT, basic scheduling things to work is the easiest part of OS development, you need to understand how it work inside-out.
OK, back to the topic. The root cause is unclear concept on paging, to resolve it I would advice to read the text from the tutorials, learn the difference between physical address, linear address, and the address translation logic. and feel free to ask if anything is unclear.
The actual implementation of identity mapping + enable paging will be just a some tens lines of code with a simple maths.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 11:28 am
by VolTeK
requimrar wrote: The question is not about how I learn things
Your right (im kidding, seriously. Your wrong.) Your learning is fine. Enjoy your problems down the road.
Re: [Another newb question] Triple fault on paging enable
Posted: Sun Jan 22, 2012 10:48 pm
by zhiayang
GhostXoPCorp wrote:requimrar wrote: The question is not about how I learn things
Your right (im kidding, seriously. Your wrong.) Your learning is fine. Enjoy your problems down the road.
Yes, I will. You may have mis-interpreted "I typed everything from scratch" as me copying it off. No, I read, understood then regurgitated my knowledge. AKA: understanding and learning.
Also, I solved the problem. All I had to do to fault it was to print the value... ZZZ
Re: [Another newb question] Triple fault on paging enable
Posted: Mon Jan 23, 2012 3:23 pm
by VolTeK
requimrar wrote:Yes, I will. You may have mis-interpreted "I typed everything from scratch" as me copying it off. No, I read, understood then regurgitated my knowledge. AKA: understanding and learning.
That being the case then.
-Also try writing summaries on the codes concept on how it works in words. From there this helps give you the ability to translate it into different programming languages.
It has helped me alot, can help you as well.
Re: [Another newb question] Triple fault on paging enable
Posted: Mon Jan 23, 2012 7:48 pm
by zhiayang
GhostXoPCorp wrote:
-Also try writing summaries on the codes concept on how it works in words. From there this helps give you the ability to translate it into different programming languages.
It has helped me alot, can help you as well.
Thanks then, I will try that.