Reading bad data from keyboard

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.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Reading bad data from keyboard

Post 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.
Last edited by MichaelPetch on Mon Oct 19, 2020 1:26 pm, edited 1 time in total.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Reading bad data from keyboard

Post 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 */
}
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Reading bad data from keyboard

Post 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:
Screenshot_20201019_152828.png
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Reading bad data from keyboard

Post 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)
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Reading bad data from keyboard

Post by MichaelPetch »

You have a serious bug in Boot.S:

Code: Select all

1:
        hlt
        jmp 1
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:

Code: Select all

1:
        hlt
        jmp 1b
After the first interrupt you went off into never never land.
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Reading bad data from keyboard

Post by austanss »

MichaelPetch wrote:You have a serious bug in Boot.S:

Code: Select all

1:
        hlt
        jmp 1
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:

Code: Select all

1:
        hlt
        jmp 1b
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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Reading bad data from keyboard

Post by MichaelPetch »

The default timer (IRQ0) from PIT 0 will fire every 18.2 times a second (every 55ms) approximately.
Last edited by MichaelPetch on Mon Oct 19, 2020 4:00 pm, edited 1 time in total.
User avatar
austanss
Member
Member
Posts: 377
Joined: Sun Oct 11, 2020 9:46 pm
Location: United States

Re: Reading bad data from keyboard

Post 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.
Skylight: https://github.com/austanss/skylight

I make stupid mistakes and my vision is terrible. Not a good combination.

NOTE: Never respond to my posts with "it's too hard".
Post Reply