Page 1 of 1

Timer causes General Protection Fault

Posted: Wed Jun 11, 2014 9:21 pm
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");
}

Re: Timer IRQ only fires once

Posted: Wed Jun 11, 2014 9:26 pm
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

Re: Timer IRQ only fires once

Posted: Wed Jun 11, 2014 9:31 pm
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 :)