okay, I'll answer my own question, I accidentally
set my my stack segment to code which prevents
the cpu from writing data to it. That's why it reboots
IDT and GDT
Re:IDT and GDT
But how do you edit the GDT after you already have set it up? Can you tell me that? Thanks!
Re:IDT and GDT
You could just modify the contents of the GDT...BUT
you can not modify an entry which is beyond the limit specified in your GDTR, for example, you've set up your limit to be at 63, which is around 8 GDT entries, you cannot add an entry to make int a total of 9. I have not tried modifying an entry in which its corresponding selector is being used (CS for example) though.
you can not modify an entry which is beyond the limit specified in your GDTR, for example, you've set up your limit to be at 63, which is around 8 GDT entries, you cannot add an entry to make int a total of 9. I have not tried modifying an entry in which its corresponding selector is being used (CS for example) though.
Re:IDT and GDT
If you add entries to the GDT, and therefore change the limits, you will need to reload it using LGDT. If you change entries, you don't need to reload the GDT, but you will have to reload any segment registers that refer to the changed descriptors. This is because you need to refresh the descriptor caches that the CPU keeps.
Re:IDT and GDT
How exactly would you "modify" the GDT? Could you supply some code?
Also, could you please look at the thread here:
http://www.mega-tokyo.com/forum/index.p ... readid=699
I'm having problems setting up the initial GDT because when I get to that part on the boot, my computer restarts. I can't figure out what is causing this. Can you?
Also, could you please look at the thread here:
http://www.mega-tokyo.com/forum/index.p ... readid=699
I'm having problems setting up the initial GDT because when I get to that part on the boot, my computer restarts. I can't figure out what is causing this. Can you?
Re:IDT and GDT
The GDT is just a normal variable in memory. Think of it as an array of 8-byte structures. To modify it in C, I'd recommend that you set up a structure definition as per the Intel documentation. To modify it from assembler, obtain the address of a descriptor by multiplying the index of your descriptor by 8. Then modify the various fields relative to that. The layout is all documented in the Intel manual; other than that, it's just basic assembly.
If you're having problems switching to protected mode, I'd advise you to start debugging under Bochs. It won't stop your code triple-faulting, but it will tell you why and where your code failed.
If you're having problems switching to protected mode, I'd advise you to start debugging under Bochs. It won't stop your code triple-faulting, but it will tell you why and where your code failed.
Re:IDT and GDT
Can you point me to this "Bochs" tool? It might come in handy and I'll try the debug thing. Although, I may need some guidance on how to debug with this "Bochs". Thanks!
Re:IDT and GDT
You can get Bochs from http://bochs.sourceforge.net.
I haven't used the debugger that much myself, but the documentation available at the above url should be enough to atleast get you started...
I haven't used the debugger that much myself, but the documentation available at the above url should be enough to atleast get you started...