Timer causes General Protection Fault

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
ess162
Posts: 2
Joined: Wed Jun 11, 2014 9:18 pm

Timer causes General Protection Fault

Post by ess162 »

My Timer now causes a General Protection Fault to be thrown

Any Ideas?

IRQ Handler

Code: Select all

void irq_handler(registers_t regs) {
    if (regs.int_no >= 40) {
        outb(0xA0, 0x20);
    }
    outb(0x20, 0x20);
    
    if (__interrupt_handlers[regs.int_no] != 0) {
        __isr_t handler = __interrupt_handlers[regs.int_no];
        handler(regs);
    }
    
}
Timer

Code: Select all

uint32_t ticks = 0;

void __timer_init(uint32_t freq) {
    __register_interrupt_handler(IRQ0, &__timer_callback);
    uint32_t divisor = 1193180 / freq;

    outb(0x43, 0x36);
    
    uint8_t l = (uint8_t) (divisor & 0xFF);
    uint8_t h = (uint8_t) ((divisor >> 8) & 0xFF);

    outb(0x40, l);
    outb(0x40, h);
}


void __timer_callback(registers_t regs) {
    ticks++;
    printf("Tick\n");
}
Last edited by ess162 on Wed Jun 11, 2014 9:59 pm, edited 1 time in total.
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Timer IRQ only fires once

Post by FallenAvatar »

http://wiki.osdev.org/I_Cant_Get_Interr ... ve_one_IRQ

EDIT: After checking you question more, looks like you are doing this, see the rest of that page, and try debugging your code on Bochs or another emulator, and also check http://wiki.osdev.org/James_Molloy%27s_ ... Known_Bugs
ess162
Posts: 2
Joined: Wed Jun 11, 2014 9:18 pm

Re: Timer IRQ only fires once

Post by ess162 »

tjmonk15 wrote:http://wiki.osdev.org/I_Cant_Get_Interr ... ve_one_IRQ

EDIT: After checking you question more, looks like you are doing this, see the rest of that page, and try debugging your code on Bochs or another emulator, and also check http://wiki.osdev.org/James_Molloy%27s_ ... Known_Bugs
Thanks :)
Post Reply