How do i get my keyboard handler to work?

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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: IRQ1 never gets fired

Post by iansjack »

Are you reading the scancode from the data port during your interrupt handler? If not you will get just the one interrupt no matter how many key presses you make.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: IRQ1 never gets fired

Post by DixiumOS »

iansjack wrote:Are you reading the scancode from the data port during your interrupt handler? If not you will get just the one interrupt no matter how many key presses you make.
Yes, i am.

I'll update my GitHub now.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i get my keyboard handler to work?

Post by iansjack »

You send the EOI command in int irq0(), but not in any of the other irqn() routines.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i get my keyboard handler to work?

Post by DixiumOS »

iansjack wrote:You send the EOI command in int irq0(), but not in any of the other irqn() routines.
I do send it in all routines.

0x21 is IRQ1, and 0x20 is an EOI code (if you want to send an EOI to IRQ0, do outb(0x20, 0x20) ).
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do i get my keyboard handler to work?

Post by Octocontrabass »

DixiumOS wrote:0x21 is IRQ1, and 0x20 is an EOI code
Where did you see anything like that? Neither the wiki page nor the datasheet agree with that statement.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i get my keyboard handler to work?

Post by DixiumOS »

Octocontrabass wrote:
DixiumOS wrote:0x21 is IRQ1, and 0x20 is an EOI code
Where did you see anything like that? Neither the wiki page nor the datasheet agree with that statement.
So where should i send? Is it 0x28?

Glaux told me, btw.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i get my keyboard handler to work?

Post by iansjack »

What does the Wiki say?

http://wiki.osdev.org/PIC
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i get my keyboard handler to work?

Post by DixiumOS »

iansjack wrote:What does the Wiki say?

http://wiki.osdev.org/PIC
0x28, 0x27 or 0x21.

None of them make IRQ1 get EOI's.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i get my keyboard handler to work?

Post by iansjack »

It doesn't say that at all. Read section 4.2 of the page referenced.

You must learn to read, and understand, documentation.
You must learn to read C code and create it.
You must stop expecting others to spoonfeed you with every little detail.

Otherwise, what's the point?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: How do i get my keyboard handler to work?

Post by Octacone »

End of Interrupt
Perhaps the most common command issued to the PIC chips is the end of interrupt (EOI) command (code 0x20). This is issued to the PIC chips at the end of an IRQ-based interrupt routine. If the IRQ came from the Master PIC, it is sufficient to issue this command only to the Master PIC; however if the IRQ came from the Slave PIC, it is necessary to issue the command to both PIC chips.

Code: Select all

#define PIC_EOI		0x20		/* End-of-interrupt command code */
 
void PIC_sendEOI(unsigned char irq)
{
	if(irq >= 8)
		outb(PIC2_COMMAND,PIC_EOI);
 
	outb(PIC1_COMMAND,PIC_EOI);
}
Then at the end of your keyboard handler do:
PIC_sendEOI(1);
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i get my keyboard handler to work?

Post by DixiumOS »

octacone wrote:
End of Interrupt
Perhaps the most common command issued to the PIC chips is the end of interrupt (EOI) command (code 0x20). This is issued to the PIC chips at the end of an IRQ-based interrupt routine. If the IRQ came from the Master PIC, it is sufficient to issue this command only to the Master PIC; however if the IRQ came from the Slave PIC, it is necessary to issue the command to both PIC chips.

Code: Select all

#define PIC_EOI		0x20		/* End-of-interrupt command code */
 
void PIC_sendEOI(unsigned char irq)
{
	if(irq >= 8)
		outb(PIC2_COMMAND,PIC_EOI);
 
	outb(PIC1_COMMAND,PIC_EOI);
}
Then at the end of your keyboard handler do:
PIC_sendEOI(1);
PIC_EOI and PIC1_COMMAND is 0x20, 0x20. This is sending to IRQ0 and not IRQ1.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
glauxosdever
Member
Member
Posts: 501
Joined: Wed Jun 17, 2015 9:40 am
Libera.chat IRC: glauxosdever
Location: Athens, Greece

Re: How do i get my keyboard handler to work?

Post by glauxosdever »

Hi,

DixiumOS wrote:
Octocontrabass wrote:
DixiumOS wrote:0x21 is IRQ1, and 0x20 is an EOI code
Where did you see anything like that? Neither the wiki page nor the datasheet agree with that statement.
So where should i send? Is it 0x28?

Glaux told me, btw.
I didn't told you that. I told you that, based on how you remapped the PIC, IRQ0 has interrupt number 0x20, IRQ1 has interrupt number 0x21, and IRQ2 has interrupt number 0x22 (and not 0x28). Nothing concerning what to send to the PIC on an EOI.


Regards,
glauxosdever
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i get my keyboard handler to work?

Post by iansjack »

DixiumOS wrote:This is sending to IRQ0 and not IRQ1.
You send the EOI command to the PIC(s), not to an IRQ.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How do i get my keyboard handler to work?

Post by iansjack »

DixiumOS wrote:Glaux told me, btw.
That rather illustrates the danger of telling you anything.

I think it would be better all round if we all ignore you completely from now on and not give you even the smallest nugget of information (which you will misquote). That way you will have to work it out for yourself by reading the documentation (if you can ever break the habit of copying what every Tom, **** - Jeez, what a swearword filter! - , and Harry has written in some crap tutorial).

Then perhaps - one day, many years from now - you may understand what you are doing.
User avatar
DixiumOS
Member
Member
Posts: 84
Joined: Tue Jan 10, 2017 3:19 pm
Libera.chat IRC: NunoLava1998

Re: How do i get my keyboard handler to work?

Post by DixiumOS »

glauxosdever wrote:Hi,
I didn't tell you that. I told you that, based on how you remapped the PIC, IRQ0 has interrupt number 0x20, IRQ1 has interrupt number 0x21, and IRQ2 has interrupt number 0x22 (and not 0x28). Nothing concerning what to send to the PIC on an EOI.


Regards,
glauxosdever
Ahh, okay. But what port do I send an EOI to?

EDIT: 0x20. I was a bit confused. It now works. I thought it differed when the IRQ was different. Thanks!
Last edited by DixiumOS on Sun Jan 15, 2017 5:37 am, edited 2 times in total.
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1
Post Reply