Page 1 of 2
[Solved] Development environnement problem or code errors ?
Posted: Tue Apr 15, 2008 9:17 am
by White-spirit
Hello all,
Maybe I bother you again with my problems and my bad English so I apologise
I've verified all my code and it must theoretically work, but after compiling creating the floppy image on Windows ( using Cygwin with a cross gcc ), Bochs boots fine, but, my isr_handler receives an infinit number of interruptions 13 ( GPF ) .
Question : It's a problem with my development environnement or there's a code error ?
Another question : Does someone would kindly to test my code in Linux? Remember to change the name of the GCC compiler, LD and OBJCOPY in Makefile.
PS : I'm using my own bootloader which loads a correct ( at least, I think it does ) GDT instead of using Grub and reloading the GDT .
Thanks !
Posted: Tue Apr 15, 2008 10:08 am
by piranha
Yes, it compiles fine on Linux. Debugging with for(;;); statements, you GPF happens before you kernel.c file even does anything. If I put the loop at the very top of the function it still GPF's.
-JL
Posted: Tue Apr 15, 2008 10:26 am
by JamesM
GPF = coding error. Go on the basis that you as a starting developer are always wrong and you will, 99.9% of the time, find your bugs. Eventually.
Posted: Tue Apr 15, 2008 10:26 am
by White-spirit
Thanks, I'm confused, if I debug with while(1), it seems that the GPF happens after
.
Edit : Thanks JamesM, I will do my best !
Edit 2 : I debugged idt.s with jmp $ and it seems that's a problem with iret .
Posted: Tue Apr 15, 2008 10:48 am
by piranha
Did you try putting the while(1) at the top? idk about you, but when theres a loop at the beginning of the function, I assume that the problem is before the function.....
Are you sure the bootloader works? Try booting with grub, and see if it still happens.
-JL
Posted: Tue Apr 15, 2008 11:02 am
by White-spirit
piranha wrote:Did you try putting the while(1) at the top?
Yes and it doesn't give me GPF's .
piranha wrote:
Are you sure the bootloader works? Try booting with grub, and see if it still happens.
Thanks but I prefer to know why it's not working before trying grub ( and again, I don't have Linux, so I can't build a grub floppy image
) .
PS : are you sure you are puting your for( ; ; ) at kernel.c ?
Posted: Tue Apr 15, 2008 11:15 am
by piranha
Yes, thats where it is.
And before figuring out why something doesn't work you first have to verify that it in fact doesn't work.
And you can download a grub floppy from osdever.net, and there are utilities for mounting images on Windows.
-JL
Posted: Tue Apr 15, 2008 11:18 am
by White-spirit
piranha wrote:Yes, thats where it is.
And before figuring out why something doesn't work you first have to verify that it in fact doesn't work.
And you can download a grub floppy from osdever.net, and there are utilities for mounting images on Windows.
-JL
Okay thanks =)
Posted: Sat Apr 19, 2008 11:33 am
by White-spirit
I've used GRUB, redefined the GDT in the C code, and compiled the whole code on Linux ( Ubuntu Dapper Drake on an emulated Virtualbox machine ), but it's still the same, so it's not the boot loader ...
Please help me, I've done all my best to find the source of the error but I was not successfull =/
Posted: Sat Apr 19, 2008 3:26 pm
by Combuster
get the bochs debugger, and use that to pinpoint the instruction causing the GPF, then trace all possible causes of that generating said GPF.
Also, check the error code pushed to see if it has anything to do with an external interrupt.
Posted: Sat Apr 19, 2008 3:49 pm
by White-spirit
Thanks, the error code is 0x0 and I don't have any idea on what it does mean, I'ill debug the kernel after building a bochs debugger ( but I think it bugs in iret ) .
PS : under Linux at this moment
.
Posted: Sat Apr 19, 2008 6:56 pm
by Hamster1800
Having just gone through a problem with identical symptoms, I will share my fix with you. It turned out that the interrupts were actually caused by the PIT firing and my IDT was not properly set up for this. Try adding code to remap the PIC and handle the hardware interrupts, then see if you still get the GPFs.
Posted: Sun Apr 20, 2008 1:53 am
by White-spirit
JamesM isn't getting GPF's with his code ( only software interrupts, no PIC or PIT remapping ), there's probably a little mistake somewhere but thanks I'ill try to remap the PIC .
Posted: Sun Apr 20, 2008 9:06 am
by White-spirit
I've done the PIC remap but it's still the same
Let's see what I'm using on my kernel that JamesM isn't using ... :
* Floating-point numbers .
* stdargs .
I'ill look there ...
Thanks
Posted: Sun Apr 20, 2008 10:50 am
by Cognition
If you're using floating point numbers you might need to make sure the FPU unit is operation by issuing an FINIT command. I don't know that it'd cause a GPF, but it's worth checking out.