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.
I have this problem with my kernel I'm making. I have just set up the GDT, IDT, IRQs and is making the PIT. I just have the problem that my OS crashes as soon as I run it, even if I don't call the init_timer function. This is my PIT code:
u32int tick = 0;
static void timer_callback(registers_t regs){
tick++;
io::puts("Tick: ");
io::puti(tick);
regs = regs; //only so that I don't get regs unused warning
}
void init_timer(u32int frequency){
register_interrupt_handler(IRQ0, &timer_callback);
u32int divisor = 1193180 / frequency;
clib::outb(0x43, 0x36);
u8int l = (u8int)(divisor & 0xFF);
u8int h = (u8int)( (divisor>>8) & 0xFF );
clib::outb(0x40, l);
clib::outb(0x40, h);
}
(from the JamesM tutorials )
if I comment out the last two lines of code (clib::outb(0x40, l); and clib::outb(0x40, h);), it all works just fine (except the timer ofc). My interrupt system works perfectly.
Anybody knows what I could be doing wrong?
I have this problem with my kernel I'm making. I have just set up the GDT, IDT, IRQs and is making the PIT. I just have the problem that my OS crashes as soon as I run it, even if I don't call the init_timer function. This is my PIT code:
If your kernel crashes as soon as you run it, what makes you think the problem is in this code?
Some things that could be wrong:
1. the way you implemented cli.
2. you didnt take the necessary steps for a c++ kernel. search the wiki on this because i have no idea what they are, just that you need a few more things.
I have this problem with my kernel I'm making. I have just set up the GDT, IDT, IRQs and is making the PIT. I just have the problem that my OS crashes as soon as I run it, even if I don't call the init_timer function. This is my PIT code:
If your kernel crashes as soon as you run it, what makes you think the problem is in this code?
Some things that could be wrong:
1. the way you implemented cli.
2. you didnt take the necessary steps for a c++ kernel. search the wiki on this because i have no idea what they are, just that you need a few more things.
It works perfectly without the PIT. And I have read the wiki page about C++. It could be the problem, since I haven't heard about anyone else having this problem, but I just can't see how...
ulrik wrote:Ok, I ported everything to plain C, and now it doesn't crash, but it's not executing timer_callback either...
Then your problem most likely has something to do with the GDT/IDT/Interrupt Routines not being set up correctly. An other cause could be that you're not acknowleding IRQ's, but then you would probably get at least 1 IRQ or interrupt after which it would infinitely await the acknowledgement.
I suggest checking if your structures are valid, packed (__attribute__((aligned)) which I presume is necessary for GDT and IDT hardware structures) and if you made a mistake somewhere. Also don't forget at tiny things that you might've forgotten, such as this:
RTFM, Intel 2B, and look up the opcode in question.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]