Page 2 of 2
Re:help in IDT
Posted: Sat Nov 23, 2002 1:55 pm
by adeelmahmood1
ok
better start working on the IDT now

Re:help in IDT
Posted: Sat Nov 23, 2002 3:47 pm
by adeelmahmood1
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

Re:help in IDT
Posted: Sat Nov 23, 2002 10:28 pm
by Tom
I will be releasing pk0.8 with a working IDT...
I already have one, but the code is too unfinished to show you.
Re:help in IDT
Posted: Sun Nov 24, 2002 9:54 am
by Unexpected
[attachment deleted by admin]
Re:help in IDT
Posted: Sun Nov 24, 2002 11:22 am
by Curufir
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.
Curufir
Re:help in IDT
Posted: Sun Nov 24, 2002 12:07 pm
by Unexpected
All defines are declarated. And handlers installation looks like this (keyboard handler):
Code: Select all
void InitKeyboard()
{
Create_IDT(33, (unsigned int)&KBD_Test, CS_SELECTOR, INT_GATE|PRESENT|BITS_32);
Enable_IRQ(PIC_KEYBOARD);
}
void KBD_Test()
{
Print("Key Test\n");
outportb(0x20, 0x20);
asm("IRET");
}
Re:help in IDT
Posted: Sun Nov 24, 2002 2:30 pm
by Tom
I have a question, Unexpected,
If you do a "IRET" in your C(C++?) code, what happends to the "RET" when the function ends(actually, returns)?
I think that the other "RET" in the code is not executed, correct?
Thank you,
Re:help in IDT
Posted: Sun Nov 24, 2002 6:09 pm
by adeelmahmood1
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

Re:help in IDT
Posted: Sun Nov 24, 2002 6:32 pm
by Curufir
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
Curufir
Re:help in IDT
Posted: Sun Nov 24, 2002 6:46 pm
by adeelmahmood1
well that sounds complicated and funny at the same time ;D
ok now coming back .. thats ur quote
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.
and thats mine
then what should we do such that the idtr points to the corrent IDt entries ..
so Curufir wat do u think about this .. :-\
i wanna finish this IDT ..

Re:help in IDT
Posted: Sun Nov 24, 2002 7:24 pm
by Curufir
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.
Curufir