OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 1:00 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
Your IRQ common stub would look like:
Code:
; 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.

Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 1:06 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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:
void ISRHandler(Registers& registers)
{
    InterruptHandler(registers);
}

void IRQHandler(Registers& registers)
{
    InterruptHandler(registers);
    if (registers.interruptNumber >= 40)
        outb(0xA0, 0x20); /* slave */
    outb(0x20, 0x20); /* master */
}


Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 1:31 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 363
Location: United States
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:
Attachment:
Screenshot_20201019_152828.png
Screenshot_20201019_152828.png [ 45.43 KiB | Viewed 816 times ]

_________________
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".


Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 3:20 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 363
Location: United States
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".


Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 3:30 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
You have a serious bug in Boot.S:
Code:
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:
1:
        hlt
        jmp 1b
After the first interrupt you went off into never never land.


Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 3:52 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 363
Location: United States
MichaelPetch wrote:
You have a serious bug in Boot.S:
Code:
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:
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".


Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 3:56 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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.

Top
 Profile  
 
 Post subject: Re: Reading bad data from keyboard
PostPosted: Mon Oct 19, 2020 3:57 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 11, 2020 9:46 pm
Posts: 363
Location: United States
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".


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 38 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group