Page 1 of 2

loop - double fault

Posted: Tue Jun 10, 2003 3:03 am
by LOneWoolF
Why do i get a double fault exception when i reach an endless loop like
for(;;);
or my getch()?

Re:loop - double fault

Posted: Tue Jun 10, 2003 3:12 am
by Pype.Clicker
probably because you have bugs in a first exception handler ... As the 2 instructions you gave are typically "wait" instructions, i would say the problem occurs when an interrupt is risen...

Re:loop - double fault

Posted: Tue Jun 10, 2003 3:46 am
by LOneWoolF
? wait? i have no wait instructions :(
hmmm
that irq handling can be a horror....

but what IS THAT EXCEPTION?
if I don't load the exceptions

EVERYTHING works CORRECT, the getch works correctly...

shouldn't the pc crash or restart if iz really a problem?

I'M RIGHT, THE COMPUTER'S WRONG!!! - that sentence could become famous...

baaa
i just wanted a working keyboard driver.. lol

Re:loop - double fault

Posted: Tue Jun 10, 2003 3:57 am
by Whatever5k
Do you have interrupts enabled? Which ones? Do you have valid Interrupt Service Routine for those?

Re:loop - double fault

Posted: Tue Jun 10, 2003 4:01 am
by beyond infinity lazy
Nay, Loone wolf, you're wrong:

The computer is always right ;-) for it just does what you tell it to do. 8)

And yes, you tell the computer to wait with both of the instructions you have mentioned. either an endless loop or a getch perform some waiting: to be exctly, the endless loop just loops around, and in the getch-function, there is a loop spinning around a condition: has a key been pressed? The both of them also induce wone thing: waiting?or sthg.

stay safe

Re:loop - double fault

Posted: Tue Jun 10, 2003 4:35 am
by LOneWoolF
AAA
thaz right, but, the pc IS wrong

becuase:

I TELL THE COMPUTER TO WAIT
AND WHAT DOES THE COMPUTER???
THE COMPUTER REBOOTS OR PRINTS TEXT (THE EXCEPTION) TO THE SCREEN

You can say what you want, but i am right, and the computer is wrong!

I've routines (print and maybe-hang rts) for ints 0 to 19

when i reach a loop i get "fatal double fault"

what i would like is a sample kernel, with the easiest and most stupid way of just ints 0 to 19 and ends with for(;;); look what i've done wrong
can i get that somewhere?
stop, i've the idt-sample kernel from osdev.neopages.net.... lez have a look and compile that with an endless ending loop :)
WTF, NOT EVEN WITH NO THE ORIGINAL SOURCE, that means without the endless loop
THE PC JUST RESTARTS!!!

can anybody write a working kernel? what shall i do?
that pc is not very nice to me.... i think that piece of metal hates me...

Re:loop - double fault

Posted: Tue Jun 10, 2003 4:46 am
by beyond infinity lazy
1. Stop crying (writing in capitals)

2. the computer does what you tell him.

3. maybe you do something and send some stack or pointer into silicium hell - possible source for mysterious faults.

4. What is a "fatal double fault"? Do you test your os with bochs?

5. Use bochs and trace down your bug. In the end, it is neither mine nor anyone else's but your bug.

6. calm down. order your thoughts.

7. Some here have self coded working operating systems at hands. they have done heavy research to approach to their goal.
stay safe

Re:loop - double fault

Posted: Tue Jun 10, 2003 5:47 am
by LOneWoolF
:-X

no i'm not using bochs
the "fatal" is added by my exception print function
and i'm not crying!
and the computer does NOT (=not cried) do what i'm tellingm to do

yep my kernel doesn't work = thaz my bug

but the idt sample doesn't work either, and thaz NOT (=not cried) fault

Re:loop - double fault

Posted: Tue Jun 10, 2003 6:11 am
by Pype.Clicker
okay . keep calm, people.

just before we get nervous, a small reminder of forum conventions: this is SHOUTING and this is *emphasizing* and this is asm instruction. As people don't like to get shouted at, keep away from the "shift lock" key. I know it's stupid, but that's the way it is ...

So, first i assume you have pmode kernel, and an IDT loaded ...
A few things:
  • before you enable hardware interrupts with a sti, you must remap IRQ vectors to another location (at boot, IRQ0 is mapped on INT8, but once you entered pmode, INT8 is an exception -- the 'double fault' exception, more precisely).
  • now you'll tell me "but didn't i disabled exceptions with -fnoexception" ? true. You disabled C++ runtime exceptions, which is a pure software mechanism to report errors from software to software. We're here talking about *hardware* exceptions: a cpu-to-software mechanism to report faults to the operating system.
    get a look at a pmode tutorial if you still don't see what i mean ...
  • remapping the interrupts involve the PIC (8259 iirc) cooperation. There are plenty of tutorials about this, including at bona fide

Re:loop - double fault

Posted: Tue Jun 10, 2003 7:19 am
by slacker
beyond infinity lazy wrote: 1. Stop crying (writing in capitals)
ha

Re:loop - double fault

Posted: Tue Jun 10, 2003 7:23 am
by beyond infinity lazy
sorry, slacker, what dost thou want to say?

Re:loop - double fault

Posted: Tue Jun 10, 2003 10:33 am
by LOneWoolF
Pype.Clicker wrote: now you'll tell me "but didn't i disabled exceptions with -fnoexception" ? true. You disabled C++ runtime exceptions, which is a pure software mechanism to report errors from software to software. We're here talking about *hardware* exceptions: a cpu-to-software mechanism to report faults to the operating system.
get a look at a pmode tutorial if you still don't see what i mean ...
I'm not really that stupid...

i did... remapPIC(0x20, 0x28);

IRQ0 is the system time, that means if my remap command is wrong...
i should get that exception not only one time and not the loops are the problems! i don't get the exception when i don't use them because the system is halted to early...
ok now i understand...

i did remapPIC(0x20, 0x28)
and the exception is at 8, not at 20

uff, whaz my mistake? ??? :o ???

I must correct me...
not the loop causes that exception...

it just occures without a reason - it seems to...

i added a complete rewritten kernel with better output, maybe sth with my
loadIDTR is wrong? (it does the lidtr command...)



[attachment deleted by admin]

Re:loop - double fault

Posted: Tue Jun 10, 2003 1:58 pm
by Pype.Clicker
LOneWoolF wrote: I'm not really that stupid...
Noone told you were. i just ignore how far you are, and your sentence "but what is that exception? if I don't load the exceptions" let me thought there might be a misunderstanding around that point ... so i tried to clarify things.
maybe loadIDTR is wrong? (it does the lidtr command...)
i don't think so. A bad IDT would rather raise a triple fault. Imho, your PIC remapping must be buggy ... maybe you could try to press a key and see if you get exc9 ...

Re:loop - double fault

Posted: Tue Jun 10, 2003 2:13 pm
by Pype.Clicker
Pype.Clicker wrote:
LOneWoolF wrote: I'm not really that stupid...
Noone told you were. i just ignore how far you are, and your sentence "but what is that exception? if I don't load the exceptions" let me thought there might be a misunderstanding around that point ... so i tried to clarify things.
maybe loadIDTR is wrong? (it does the lidtr command...)
i don't think so. A bad IDT would rather raise a triple fault. Imho, your PIC remapping must be buggy ... maybe you could try to press a key and see if you get exc9 ...

Code: Select all

       mov al,0xd
        out 21h,al      ;ICW4:=IntelEnvironnement
        mov al,9
        out 0A1h,al     ;ICW4:=IntelEnvironnement
you seem to have odd ICW4 values ...
full ICW4 doc here.

In some intel Chipsets, those extra bits aren't necessary (because Intel knows how Intel architecture works and just ignore the "master/slave" and "8085/8086"), but other manufacturer require those bits to be set (and i think bochs requires it too)

Now, i admit my #1 reference book (Pc Bible VI by M.Tischer) did the error too, so you're excused ...

Re:loop - double fault

Posted: Tue Jun 10, 2003 3:17 pm
by AvengerX
The computer not doing what you tell it to? It is indeed doing what you tell it to, for you are telling it to do the wrong thing with your faulty code. I know you are not directly coding in the double fault, but somewhere along the line, it's occuring

And i never knew that IRQ0 was the system time[if that was a misspelling, i am sorry].. i thought it was the PIT [i'm probably wrong, now].. with a regular frequency of approx. 18 Hz.

My apologies if i offended anyone.