Hello,
I have another problem with my "OS": i'm unable to get the PIT to work.
This is what i've tried to do:
Remapped PICs using:
Code:
void irq_remap() {
outb(0x20, 0x11);
outb(0xA0, 0x11);
outb(0x21, 0x20);
outb(0xA1, 0x28);
outb(0x21, 0x04);
outb(0xA1, 0x02);
outb(0x21, 0x01);
outb(0xA1, 0x01);
outb(0x21, 0x0);
outb(0xA1, 0x0);
}
An IRQ handler that is being called from assembly irq_common_stub:
Code:
void irq_handler(registers_t regs) {
if(regs.int_no >= 40) // If IRQ > 7(int_no > 40) reset slave PIC
outb(0xA0, 0x20);
outb(0x20, 0x20); // In either cases, reset master PIC
// Register a new interrupt handler
if(interrupt_handlers[regs.int_no] != 0) {
isr_t handler = interrupt_handlers[regs.int_no];
handler(regs);
}
}
A timer initializer
Code:
void init_timer(uint32_t frequency) {
register_interrupt_handler(32, &timer_callback);
uint32_t divisor = 1193180 / frequency;
outb(0x43, 0x36);
uint8_t low = (uint8_t)(divisor & 0xFF);
uint8_t high = (uint8_t)((divisor >> 8) & 0xFF);
outb(0x40, low);
outb(0x40, high);
}
The problem is that, when i try to call
init_timer() from the kernel nothing happen. The weird thing is that if i try to run the OS with Bochs(starting it with GRUB's countdown, without touching the keyboard) it prints this error:
Code:
03150576036e[CPU0 ] check_cs(0x0206): not a valid code segment !
.
Otherwise(with QEMU or even with Bochs, pressing "enter" from GRUB's menu)nothing gets printed at all.
This is the repo, just in case.