Re: IRQ Firing Bug
Posted: Wed Jul 27, 2016 5:35 am
Your PS2_WaitWrite function is wrong. Change the == to !=.
The Place to Start for Operating System Developers
http://f.osdev.org/
Nice catch! That might be why it didn't work for other guys that have their IRQs working.SpyderTL wrote:Your PS2_WaitWrite function is wrong. Change the == to !=.
Code: Select all
volatile unsigned int timer_ticks = 0;
struct regs
{
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_no, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};
void Timer_Handler(struct regs *r)
{
timer_ticks++;
PIC_SendEOI(0);
if (timer_ticks % 18 == 0)
{
PIC_SendEOI(0);
PrintString("\nOne second has passed");
WriteOutputToQemu("One second has passed");
}
}
void InstallTimer()
{
IRQ_Install_Handler(32, (unsigned)Timer_Handler);
}
void TimerWait(int ticks)
{
unsigned int eticks;
eticks = timer_ticks + ticks;
while(timer_ticks < eticks)
{
__asm__ __volatile__("hlt");
}
}
YESSSSSSSCh4ozz wrote:Make sure to send EOI to the PIC.
It will resend you the interrupt until you acknowledge and say you received it.
Also why do I see so many calls to PIC_SendEOI(0); in your code?
Its ONLY supposed to be called after you received an interrupt..
That's very odd, because the PS/2 keyboard should be reset before initialization. My OS uses the PS/2 keyboard reset and works on Bochs, QEMU, VirtualBox, VMware, two tested PCs, and really everywhere.thehardcoreOS wrote:omarrx024
I discovered something related to your code.
When I enable this line: PS2_Send(0xFF); //for those who don't know what this is, see my screenshot
After that point nothing gets executed, I don't see the rest of my output that I am supposed to see, suggesting that my kernel is hanging, when I disable that line everything executes as usual.
I don't know, maybe it is something else, or just your hardware.omarrx024 wrote:That's very odd, because the PS/2 keyboard should be reset before initialization. My OS uses the PS/2 keyboard reset and works on Bochs, QEMU, VirtualBox, VMware, two tested PCs, and really everywhere.thehardcoreOS wrote:omarrx024
I discovered something related to your code.
When I enable this line: PS2_Send(0xFF); //for those who don't know what this is, see my screenshot
After that point nothing gets executed, I don't see the rest of my output that I am supposed to see, suggesting that my kernel is hanging, when I disable that line everything executes as usual.
Without the while(1) your main function will be left and returns to your GRUB entry point of the kernel.thehardcoreOS wrote:I don't know, maybe it is something else, or just your hardware.omarrx024 wrote:That's very odd, because the PS/2 keyboard should be reset before initialization. My OS uses the PS/2 keyboard reset and works on Bochs, QEMU, VirtualBox, VMware, two tested PCs, and really everywhere.thehardcoreOS wrote:omarrx024
I discovered something related to your code.
When I enable this line: PS2_Send(0xFF); //for those who don't know what this is, see my screenshot
After that point nothing gets executed, I don't see the rest of my output that I am supposed to see, suggesting that my kernel is hanging, when I disable that line everything executes as usual.
By the way can you answer the question I asked? (one post up)
Code: Select all
asm volatile("hlt");
Ch4ozz so I have to use that freaky while loop. RIP that means I can't use them anywhere else since I don't have multitasking.Ch4ozz wrote:
Without the while(1) your main function will be left and returns to your GRUB entry point of the kernel.
If you followed some tutorials it will usually do "CLI; HLT;"
You can putinto your while(1) so no CPU is used until an interrupt occurs.Code: Select all
asm volatile("hlt");
Please don't use color formatting. Your C code probably returns to your assembly stub when you don't have a while(1); loop, and (assuming you copied the assembly stub from any tutorial) the assembly stub has a CLI, HLT after calling kmain. And the CLI/HLT combination prevents IRQs.thehardcoreOS wrote:Please answer this: Why I don't get any interrupts when I don't have while(1) loop?
Hmm, you guys hate colors.omarrx024 wrote:Please don't use color formatting. Your C code probably returns to your assembly stub when you don't have a while(1); loop, and (assuming you copied the assembly stub from any tutorial) the assembly stub has a CLI, HLT after calling kmain. And the CLI/HLT combination prevents IRQs.thehardcoreOS wrote:Please answer this: Why I don't get any interrupts when I don't have while(1) loop?
Code: Select all
cli
call Kernel_Main
hlt
jmp $
Code: Select all
printf("%c", kbdus[keycode]);
Yes. You should notify the master PIC any time it signals an IRQ (0-7), and notify both the master and slave PIC when the slave PIC signals an IRQ (8-15). Any IRQs that you have unmasked should have valid interrupt handlers that will notify the proper PICs installed before you unmask them.thehardcoreOS wrote:Should I use SendEOI Inside my kbd and timer handlers?
Any time you see repeated three stacked horizontal lines followed by an S, you are printing your 16-bit Interrupt Table to the screen. This is likely because you are passing a null to a draw string function, so it is drawing everything from RAM address zero until it finds a null value.thehardcoreOS wrote:When I enable while(1) loop I can use my timer and my keyboard. But I get these weird glyphs: