Happy Egghead wrote:I've just written my PIT code and it's seems to be working OK. Straight off the bat I can recommend an optimization and that is in the second setting of your divisor to the PIT the (&0xFF) isn't needed after shifting right (>>).
Thanks for this. Will do!
Happy Egghead wrote:
The only other thing I can think of is that something is masking the irq without unmasking it later. I was trying to add spinlocks to various global variables and everything ground to a confusing halt.
Thanks for the thought, but the problem only occurs when I unmask the interrupt. If it is masked (ie, not working), Bochs does not seem to give me the warning. Also, if i CLI, no warning. Looks like the problem only hapens when the PIT is allowed to fire.
Happy Egghead wrote:
Does the EOI to the PIT occur in assembler or C? I remember in another post your timer was optimised to minimise calling the reschedule function (in C). I think there's some way to ask Bochs to log whether or not the EOI was actually received. Something in the log file settings.
Well remembered! That is certainly the case, but as I am rewriting such a large portion of the code, I have not put my multitasking routines back again yet. The EOI is sent in C, again, as per Brandon's kernel development tutorial(ish):
Code: Select all
printf("Unhandled IRQ %#x (%d) - device driver not installed!\n", r->errcode, r->errcode);
/* send 'end of interrupt' commands to PIC */
if(r->errcode>=0x08) outportb(PIC_SLAVE, PIC_EOI);
outportb(PIC_MASTER, PIC_EOI);
The difference between my code and Brandon's is that a single C handler handles all interrupts (Exceptions, IRQ's, Software ints). The idea is to optimise this later. The 'errcode' field contains the IRQ. I know this works, as the first time the timer fires, I get the message on the screen as expected from the code above. The function then returns to the ASM stub and iret's.
After timer initialisation, my kernel just goes in to an idle loop at the moment. I'm not handling any other IRQ yet, so don't think it's a masking issue. Before the PIT initialisation functions (above), I don't touch the PIT.
I'm just going to write a simpler ASM handler and see how I get on, but my feeling is still that the PIT is to blame, not my handler code, because bochs prefixes the message with [PIT81]....
Thanks for your help,
Adam[/code]