[Another newb question] Triple fault on paging enable
[Another newb question] Triple fault on paging enable
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...
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...
[nx] kernel: http://github.com/zhiayang/nx
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: [Another newb question] Triple fault on paging enable
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.
#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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: [Another newb question] Triple fault on paging enable
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.
[nx] kernel: http://github.com/zhiayang/nx
Re: [Another newb question] Triple fault on paging enable
From what i have heard about his tutorials, they are good enough, that no questions are askedrequimrar wrote:#1: Okay, but is there a binary for linux? It won't compile.
#2: How do I do that?
#3: How?
Or maybe you need to know what those registers are and how to interact with them before reading the tutorial?
Your a newb if you say you are one. Using the word is bad enough.requimrar wrote:Yes, I'm a newb.
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
This is where things start getting wrong. Copy & paste from tutorial is probably the worst method to learn things.requimrar wrote:I copied code from 6.-Paging and 7.-
Re: [Another newb question] Triple fault on paging enable
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.bluemoon wrote: This is where things start getting wrong. Copy & paste from tutorial is probably the worst method to learn things.
[nx] kernel: http://github.com/zhiayang/nx
Re: [Another newb question] Triple fault on paging enable
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));
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?
[nx] kernel: http://github.com/zhiayang/nx
Re: [Another newb question] Triple fault on paging enable
Tainted thoughts. Its too late forget about learning it -.-requimrar wrote:I typed everything from scratch this time
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
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?GhostXoPCorp wrote:Tainted thoughts. Its too late forget about learning it -.-requimrar wrote:I typed everything from scratch this time
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!
[nx] kernel: http://github.com/zhiayang/nx
Re: [Another newb question] Triple fault on paging enable
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.
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
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
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
[nx] kernel: http://github.com/zhiayang/nx
Re: [Another newb question] Triple fault on paging enable
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
Thanks then, I will try that.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.
[nx] kernel: http://github.com/zhiayang/nx