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.
This is where it breaks. The linker won't automatically patch up the references to the IDT so IDTR ends up wrong as do the entry points in the IDT.
then what should we do such that the idtr points to the corrent IDt entries ..
and why doesnt this thing happens with the GDT?
my GDt is, as i have told u is in my 2nd stage loader which loads this GDt and then sets up the pmode .. so why is that GDT working fine ? i m confused ???
and about the kernel .. ;D well there is nothing i can do about that .. i have my printf etc. functions prototypes in the astdio.h header file and the function definitions in the kernel
and after this kernel size is 8704 bytes
i tried to put the function definitions too in the header file and just call them from the kernel but that doesnt works .. it keeps on rebooting with this way ..
so i dont think there is anything i could do about the kernel size
Where do you do IRETs? I can't find a single one in that source.
My C is horribly bad I'm afraid, so whilst your code looks pretty and all I'm not gonna struggle through it (Besides, there's people on the board with much better C knowledge).
I do have a couple of avenues for investigation based on my own IDT experiences though. Is IDTR set correctly (Use SIDT instruction and verify)? Are the memory address of the ISRs set correctly? Is the GDT selector you're using in the IDT entry setup correctly? Any of those are likely to produce an exception which because the IDT isn't functioning properly won't be handled, which in turn calls another exception which won't be handled, which restarts the processor. Welcome to the wonderful world of triple fault .
Hopefully one of the C gurus will look at your code for the specific problem, I just thought reminding you of some of the more common problems would be useful as a starter.
well i m surprised ..
can we also make IDT in C .. :-\
i was thinking that it is necessary that we set the IDT before jumping to Pmode ..
but obviosuly if u r making it in C it means u r already in Pmode ..
but still i think making IDT in assembly is a bit easier
.. BTW may be u guys forgot my last questions in between
I think, at least it's the way I read the manuals, that you can enter PMode with only a valid GDT so long as you've arranged to make sure there aren't going to be any interrupts happening.
The only thing you have to do then is load the IDT register with some valid properties once you've built your IDT. That's the reason you can't be in PMode without an IDT and have interrupts turned on. Well I guess even that's incorrect, so long as there's no interrupts called (ie IRQs are disabled and your code never causes an exception) you could get away with leaving them on even without an IDT.
I suppose that in theory (So long as you didn't make any jumps/data references) you could operate in PMode without even a GDT. Question to ask yourself is "Do I really want to?" .
Remember that as far as the processor is concerned the only thing that tells it which mode it's operating in are the pmode and v86 flags. The processor is blissfully unaware of the Presence/Lack of valid GDT and IDT until something goes horribly wrong. At which point it'll nip out for a few beers at the pub while your computer reboots .
Interesting challenge. Can you setup a good working environment having the pmode switch as the (Ok, I'll let you set DS after boot :>) 2nd command in your bootloader? Dynamically creating a GDT without a data selector sounds...err...complicated
Slow response time, sorry, still trying to figure my way around loading a gdt in PMode without actually having a data selector. Although vague memories tell me that you keep segment:offset addressing until you make the selector:offset jump to 32 bit code...hmm, interesting. Time for a bootsector rewrite I think (Yuck, need to look up the FDC ports again).
Anyhow, the IDT, yes you need to patch up references when you link. In what way? Damned if I know, I've never bothered linking one . Not a totally constructive answer I know, but until such times as I can put my comp back together I can't really investigate it.
Somewhere to take up the search would be John Fine's code (Aside from the minor point that he's about a billion times better programmer than I am) I seem to remember one of his pmode examples patching up references to link with some C code. That and he has some very nice nasm macros to setup IDT/GDT/LDT. Sorry I can't be more help atm.