Some IDT Code...in C
Re:Some IDT Code...in C
!!!!!!!!!!!!!!!!!!!!!!!!!!
;D
IT WORKS!!! IT WORKS!!! IT WORKS!! THE PROBLEM WAS THAT I SET THE IDT.BASE AND I JUST GOT RID OF IT AND I WORKS
Ok..calm down...but I have been working on this for months!
THANK you!
;D
IT WORKS!!! IT WORKS!!! IT WORKS!! THE PROBLEM WAS THAT I SET THE IDT.BASE AND I JUST GOT RID OF IT AND I WORKS
Ok..calm down...but I have been working on this for months!
THANK you!
Re:Some IDT Code...in C
Well, I get a double fault ( error 8 ) and this is what I found on the internet:
double fault
possible for 386+ in real mode if INT vector exceeds IDT limit
What does this mean?
double fault
possible for 386+ in real mode if INT vector exceeds IDT limit
What does this mean?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Some IDT Code...in C
i guess this means that if you return to real mode and leave the pmode IDT installed (and mainly, not restoring the limit to 256*4-1), and that you invoke INT n (or rise up and IRQ to vector n) with n>[IDT.limit / 4], the processor will issue a "double fault" exception. How this exception will be handled is quite mysterious, but if the appropriate GDT and IDT base are still set up, it could possibly deliver it to the 32 bits handler (turning back to pmode).
I'm not sure of it, but i've seen some unreal-mode TSR programs that used some similar trick (hooking SEGFAULTS generated from realmode when attemp is made to go over the 16bits limit of a segment due to a GDT reset by some external program and restoring a clean unreal mode ... impressive, isn't it ? )
In normal conditions, that "double fault" will probably not be handled correctly because you didn't expected such a scenario and leads to a 3rd exception (and reboot).
I'm not sure of it, but i've seen some unreal-mode TSR programs that used some similar trick (hooking SEGFAULTS generated from realmode when attemp is made to go over the 16bits limit of a segment due to a GDT reset by some external program and restoring a clean unreal mode ... impressive, isn't it ? )
In normal conditions, that "double fault" will probably not be handled correctly because you didn't expected such a scenario and leads to a 3rd exception (and reboot).
Re:Some IDT Code...in C
Well....I don't go to realmode...I just enable interrupts after setting up my IDT and my IDT fires a excep 8.
Re:Some IDT Code...in C
Have I misunderstood, or do you mean that you're not setting the base of the idt?Tom wrote: THE PROBLEM WAS THAT I SET THE IDT.BASE AND I JUST GOT RID OF IT
Re:Some IDT Code...in C
hi,
did you make those changes to the err() function? And i hope you didn't iret from it as you did handle the interrupt! if you still have problems, kindly post full relevant source code to be examined!
did you make those changes to the err() function? And i hope you didn't iret from it as you did handle the interrupt! if you still have problems, kindly post full relevant source code to be examined!
Re:Some IDT Code...in C
What should I set the base of the IDT?
I did make the changes too...
I did make the changes too...
Re:Some IDT Code...in C
I'm going to try and help you, but my GDT and IDT are in C++, but I'll attempt to translate.
From looking at your kernel32.c file, you've not made an IDT. I couldn't see anywhere
Your descriptor_reg idt, isn't that just your idtr? so you need to point
So IDT is an array of idt_entry's, the idtr is what you pass to lidt, and must therefore point to the base of your IDT.
I hope this makes sense, and I got it correct.
-Edit-
And for your int set_idt_entry, you could do this, -Edit-
From looking at your kernel32.c file, you've not made an IDT. I couldn't see anywhere
Code: Select all
idt_entry IDT[IDTSIZE] ;
Code: Select all
idtr.base = (unsigned long int) IDT ;
I hope this makes sense, and I got it correct.
-Edit-
And for your int set_idt_entry, you could do this,
Code: Select all
int set_idt_entry(unsigned long num,void (*funct)(void))
{
IDT[num].offset_low =(unsigned short) (((unsigned long)funct & 0xffff));
...
...
...
IDT[num].offset_high=(unsigned short)(((unsigned long)funct >> 16));
}
Re:Some IDT Code...in C
Well, my kernel is C++...but I like C also so i'll try that code.
Re:Some IDT Code...in C
hi,
what is the memory layout for your kernel?
i.e this is mine( at the moment)
0 - 0400h --> bios
....
....
0600h - (0600h+256*8 - 1) --> IDT
paste the update kernel and idt code (part concerning IDT setup) that you are using now.
what is the memory layout for your kernel?
i.e this is mine( at the moment)
0 - 0400h --> bios
....
....
0600h - (0600h+256*8 - 1) --> IDT
paste the update kernel and idt code (part concerning IDT setup) that you are using now.
Re:Some IDT Code...in C
let's say you want to place it before your kernel at 9000h
you can put it at any address that will leave enough memory for 256 enties for example
256*8 =2,048 bytes so
9000h - 2,048 bytes = 8800h
so any address from 8800h to 0400h (bios)
you can put it at any address that will leave enough memory for 256 enties for example
256*8 =2,048 bytes so
9000h - 2,048 bytes = 8800h
so any address from 8800h to 0400h (bios)
Re:Some IDT Code...in C
Cool my IDT works too!!!
But why when I press I key, I have 13th exeption: "General protection fault". Why? I think my handler in C is wrong.
In posted codes you need to set idt base address, why you don't use IDT[256] (not pointer), and set IDTR.offset = (unsigned long)IDT
But why when I press I key, I have 13th exeption: "General protection fault". Why? I think my handler in C is wrong.
In posted codes you need to set idt base address, why you don't use IDT[256] (not pointer), and set IDTR.offset = (unsigned long)IDT