[Solved] Development environnement problem or code errors ?

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.
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

[Solved] Development environnement problem or code errors ?

Post by White-spirit »

Hello all,

Maybe I bother you again with my problems and my bad English so I apologise :oops:

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 !
Last edited by White-spirit on Tue Apr 22, 2008 8:06 am, edited 1 time in total.
Working on multi-tasking support ...
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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.
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post by White-spirit »

Thanks, I'm confused, if I debug with while(1), it seems that the GPF happens after

Code: Select all

asm volatile ("int $0x4");
.

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 .
Working on multi-tasking support ...
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 ?
Working on multi-tasking support ...
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 =)
Working on multi-tasking support ...
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 =/
Working on multi-tasking support ...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 :) .
Working on multi-tasking support ...
Hamster1800
Posts: 14
Joined: Wed Apr 16, 2008 5:12 pm

Post 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.
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 .
Working on multi-tasking support ...
White-spirit
Member
Member
Posts: 89
Joined: Sun Mar 23, 2008 2:23 pm
Location: [0x8:0x1000]

Post 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 :)
Working on multi-tasking support ...
Cognition
Member
Member
Posts: 191
Joined: Tue Apr 15, 2008 6:37 pm
Location: Gotham, Batmanistan

Post 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.
Post Reply