Page 3 of 3
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 1:00 pm
by MichaelPetch
Your IRQ common stub would look like:
Code: Select all
; Common IRQ code. Identical to ISR code except for the 'call'
irq_common_stub:
pusha
mov ax, ds
push eax
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
cld
push esp
call IRQHandler ; Different than the ISR code
pop eax
pop eax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
popa
add esp, 8
sti
iret
One other change I made here was the use of EAX like that of the ISR common stub. Using EBX instead of EAX doesn't get you anything so I changed it to EAX compared with the code you have in Github.
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 1:06 pm
by MichaelPetch
Someone else mentioned this previously on here. ISRs don't come in on the PIC so don't send any EOIs to the PIC. As well when doing the IRQ handlers you have part of the EOI processing before and after the IRQ handler. To start with to simplify things I would place the EOI processing after you call the IRQHandler. The code should look like:
Code: Select all
void ISRHandler(Registers& registers)
{
InterruptHandler(registers);
}
void IRQHandler(Registers& registers)
{
InterruptHandler(registers);
if (registers.interruptNumber >= 40)
outb(0xA0, 0x20); /* slave */
outb(0x20, 0x20); /* master */
}
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 1:31 pm
by austanss
Thanks for your help, Petch. I am no longer being spammed with general protection faults. I do believe my exception handlers were causing these issues, which in turn, since the exceptions were spamming, it triggered spams of GPFs. My real issue has shown itself to be invalid opcode exceptions. I will be working to find the faulty line of code.
New screenshot:
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 3:20 pm
by austanss
I used QEMU with
-d int,in_asm and this is the output that I found relevant (I added an endless loop to act as a breakpoint when an exception occurs)
[PASTEBIN:
https://pastebin.com/5FCf7SsU]
By "relevant", I mean since the last action that occurred that I recognized myself in my ASM code. (In this case, my
hlt loop)
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 3:30 pm
by MichaelPetch
You have a serious bug in Boot.S:
You are jumping to memory address 0x00000001 and executing there. You meant to jmp back to the numbered label 1. To do that you should have done:
After the first interrupt you went off into never never land.
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 3:52 pm
by austanss
MichaelPetch wrote:You have a serious bug in Boot.S:
You are jumping to memory address 0x00000001 and executing there. You meant to jmp back to the numbered label 1. To do that you should have done:
After the first interrupt you went off into never never land.
Alas! This works! Thank you so much! I constantly receive IRQ 0, is this normal? It is the Programmable Interrupt Timer, I assume this is normal.
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 3:56 pm
by MichaelPetch
The default timer (IRQ0) from PIT 0 will fire every 18.2 times a second (every 55ms) approximately.
Re: Reading bad data from keyboard
Posted: Mon Oct 19, 2020 3:57 pm
by austanss
MichaelPetch wrote:The default timer (IRQ0) from PIT 0 will fire every 18.2 times a second approximately.
Thank you so much! I will ignore this until I need it for chronology-related purpose.