GDT and IDT problems
GDT and IDT problems
Hi guys, I am doing GDT and IDT, just wondering, what is the best way to check I have correctly make a GDT and IDT.(Will bochs debugger mention that they have been made?) Thanks
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
Re: GDT and IDT problems
Yeah, when scientist finally invent working AI, Bochs will probably be able to tell the right GDT/IDT from the wrong. No, really, Bochs can't know whether or not what you've got is what you want and if it's somehow right. There's no single right here. You may have reasons for setting up unusable segment descriptors. Bochs wouldn't know that. But it will surely tell you of triple faults emanating from #GP's, #SS' and so on.hometue wrote:Hi guys, I am doing GDT and IDT, just wondering, what is the best way to check I have correctly make a GDT and IDT.(Will bochs debugger mention that they have been made?) Thanks
You could probably use some Bochs functionality to dump CPU registers and system tables (I've never done that). You could also use some sort of debug prints or things as simple as "jmp $" to see how far you get without a crash. Be inventive.
Re: GDT and IDT problems
Thanks for the info. By the way, how do I tell if there is a faulty gdt/idt (as in there is a faulty gdt/idt what will happen?)
EDIT: I know the qns is very similar to the one I had but what I mean this time is like if I have a faulty gdt/idt, what are the known problems I will face (fault? registers not having the right value?)
EDIT: I know the qns is very similar to the one I had but what I mean this time is like if I have a faulty gdt/idt, what are the known problems I will face (fault? registers not having the right value?)
Last edited by hometue on Fri Apr 11, 2014 8:16 am, edited 1 time in total.
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: GDT and IDT problems
Triple Fault it is then. (for most cases like you'll maybe switch to an invalid segment (faulty GDT), CPU relaxes and says "Why should I bother?" searches for handler, faulty IDT, can't find the appropriate handler, then asks "Why should I bother?", goes finds the DF handler, faulty IDT, then asks "Why should I bother?", and reboots.) or it can be something beyond our imagination.(as in there is a faulty gdt/idt what will happen?)
EDIT:
Registers will have the correct values btw, but it may be that the segments will be so badly messed up that you'll think you're writing to some memory location and you'll be writing to some other memory address. Has happened to me before.
Last edited by Bender on Fri Apr 11, 2014 8:32 am, edited 1 time in total.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
Re: GDT and IDT problems
Thanks Bender for the info.
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
Re: GDT and IDT problems
Yes, it can do just this. Typically you'd want to set a breakpoint after the lidt and lgdt instructions, and then use the 'info gdt' and 'info idt' commands. The bochs debugger is a powerful tool if you learn to use it properly.hometue wrote:Hi guys, I am doing GDT and IDT, just wondering, what is the best way to check I have correctly make a GDT and IDT.(Will bochs debugger mention that they have been made?) Thanks
Regards,
John.
Re: GDT and IDT problems
Would that be the same as displaying the gdt and idt in the gui debugger. How would I tell a faulty gdt with a proper one then?
Btw, I came across this question which confuses me, when making a gdt and must i fill it for it to work(I see when switching to proteted mode they don't but in some gdt tutorial you actually have to)? And what do I fill it with (I am a visual learner, so if someone can provide me with a good diagram of the gdt and idt I will appreciate it as it would make it much simpler to understand, can't find a good visualization of the gdt and idt anywhere), while there is code provided to fill it I rather understand the structure of the gdt and not rely on other's code to do things for me. Thank you very much.
Btw, I came across this question which confuses me, when making a gdt and must i fill it for it to work(I see when switching to proteted mode they don't but in some gdt tutorial you actually have to)? And what do I fill it with (I am a visual learner, so if someone can provide me with a good diagram of the gdt and idt I will appreciate it as it would make it much simpler to understand, can't find a good visualization of the gdt and idt anywhere), while there is code provided to fill it I rather understand the structure of the gdt and not rely on other's code to do things for me. Thank you very much.
CookieOS. Want a cookie? Its only black and white for now though, probably as bad as my baking skills.
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: GDT and IDT problems
Rule #1 : Tutorials deal with a specific-implementation, You shouldn't rely much on them, basically it's like a ready made answer, from what I've learnt from my mistakes tutorials help you get started and that's it. What happens after is on your hands. Teachers will know the best about what I'm talking about.hometue wrote:Would that be the same as displaying the gdt and idt in the gui debugger. How would I tell a faulty gdt with a proper one then?
Btw, I came across this question which confuses me, when making a gdt and must i fill it for it to work(I see when switching to proteted mode they don't but in some gdt tutorial you actually have to)? And what do I fill it with (I am a visual learner, so if someone can provide me with a good diagram of the gdt and idt I will appreciate it as it would make it much simpler to understand, can't find a good visualization of the gdt and idt anywhere), while there is code provided to fill it I rather understand the structure of the gdt and not rely on other's code to do things for me. Thank you very much.
Rule #2 : Never forget Rule #1
Rule #3 : If you do, well, "triple fault here we come" (or something of that sort perhaps) is going to happen.
Visual Representation? The wiki has a good one. http://wiki.osdev.org/Global_Descriptor_Table
The structure of the GDT and IDT are quite similar, so if you understand the GDT you shouldn't have much problems with the IDT.
I don't know what is meant by "filling" a GDT. Since I have little knowledge about tutorials, I can't really say anything. In my OS the GDT is never touched. The values are hardcoded, by filling a GDT what I can "guess" is setting the GDT entries at runtime, rather than hard coding. (Mind the word "guess")
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)