Problem with print function

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

Problem with print function

Post by beyondsociety »

I'm having sort of a problem with my protected mode kernel. My kernel prints a few messages to the screen and halts. When I create a .img file and run it in bochs, it displays the first two messages and then tripple faults.
Thats sort of my problem but I also noticed something weird with bochs.

When I comment out one of the lines and re run it in bochs, it shows the same thing before even though I have commented out one of the lines. I think my problem has to do with my print function.

The whole code my print function is attached below. The mart of the code is in print function.c and the rest is just the files I need to run it.

[attachment deleted by admin]
beyondsociety

Re:Problem with print function

Post by beyondsociety »

I fixed my problem. There was problem with the code in my kernel. When I rewrote it, it wirked fine. Now my only problem is trying to figure out my tripple fault error when I enable interrupts.
LOneWoolF

Re:Problem with print function

Post by LOneWoolF »

I had a double fault when i enable interrupts...
maybe you look at the "loop - double fault" thread <-
my problem first where how i remapped the PIC and i also had a wrong outb function... check this things

dunno if that helps ya, but i hope so :)

GreeZ
LOneWoolF
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Problem with print function

Post by Pype.Clicker »

if you get "tripple fault", then it means your IDT is likely to be bad, or that the IDTR register content isn't good. tripple fault usually occur when the "double fault" can't be delivered to a valid handler, which occurs usually when the ISR code of your exceptions isn't correct.

As long as you have no IRQs, no exception thus no problems, but once you STI, hardware IRQs find bad interrupt handler or bad descriptor in IDT, try to raise a GPF which also fails and bang double fault.

Give your IDT a try with INTxx instruction before enabling hardware interrupts...
beyondsociety

Re:Problem with print function

Post by beyondsociety »

When I issue a int 10 in my C kernel and run it in bochs it gives me a tripple fault. When I open the bochs debugger and set the breakpoint to the EIP address thats tripple faulting I get int 10 which is what I tested. If I go I more address location, I get a tripple fault.

Why is this? Is there a problem with my interrupt handler?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Problem with print function

Post by Pype.Clicker »

more likely to be a problem with your IDT itself ... check the IDTR register is loaded with the correct values. Also check you correctly set your IDT descriptor (interrupt gate, DPL0, segment=OSCODE, offset=ISR).

Btw, INT 0x10 is an exception in protected mode, so i would rather use some other interrupt for my tests, if i were you (like -- say -- 0x30 if you mapped IRQs from 0x20 through 0x2f)
beyondsociety

Re:Problem with print function

Post by beyondsociety »

Thanks for the help Pype Clicker. My main problem was that I didin't have any idt descriptors or interrupt_handlers for my exceptions thus an exception was firing off causing my code to tripple fault.
Post Reply