Keyboard driver resets system when key is pressed.

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.
Tomrs123
Member
Member
Posts: 40
Joined: Mon Aug 19, 2024 11:12 am
GitHub: https://github.com/ilikecoding-197

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

Oh, so its the excatly the same as sending normal commands to the controller, except for sending to the data port, neat!
Tomrs123
Member
Member
Posts: 40
Joined: Mon Aug 19, 2024 11:12 am
GitHub: https://github.com/ilikecoding-197

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

So I'm back once again... when will this stupid keyboard driver end... :cry:

Anyway so I implmented stole the heap code from https://wiki.osdev.org/User:Pancakes/Si ... ementation, but that doesn't matter for todays post.

So I.. rewrote the keyboard driver. I got it to send a interrupt, BUT it.. stops sending them.

And I also didn't implment the reset code (because i'm pretty sure you need to send it to the keyboards, and I don't really know how to set up the sending commands to keyboards), so that might be the issue; the PS/2 keyboard in a bad state.

I would really appreciate if I can get help with sending commands to the keyboard and the single interrupt issue.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Keyboard driver resets system when key is pressed.

Post by Octocontrabass »

Tomrs123 wrote: Wed Nov 20, 2024 6:41 pmSo I.. rewrote the keyboard driver. I got it to send a interrupt, BUT it.. stops sending them.
Did you acknowledge the PS/2 controller? Did you acknowledge the interrupt controller? Are you disabling interrupts at some point after returning from the first interrupt? Is a higher-priority interrupt blocking the keyboard interrupt?
Tomrs123 wrote: Wed Nov 20, 2024 6:41 pmAnd I also didn't implment the reset code (because i'm pretty sure you need to send it to the keyboards, and I don't really know how to set up the sending commands to keyboards), so that might be the issue; the PS/2 keyboard in a bad state.
What (if anything) did you do to initialize the PS/2 controller? If you didn't initialize it at all, it's probably in a reasonable state, although you should still check the output buffer so it doesn't get stuck waiting for you to respond to an interrupt that got lost when you initialized the interrupt controllers.

Sending bytes (command or otherwise) to the keyboard works very much like sending commands to the PS/2 controller, except you don't write anything to port 0x64. The keyboard will send a reply after every byte you send. You must wait for each reply before sending the next byte. You receive the reply exactly the same way you receive a scan code byte.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard driver resets system when key is pressed.

Post by MichaelPetch »

Tomrs123 wrote: Wed Nov 20, 2024 6:41 pm So I'm back once again... when will this stupid keyboard driver end... :cry:
You could always start by updating your Github repo with the code that you are having issues with.
Tomrs123
Member
Member
Posts: 40
Joined: Mon Aug 19, 2024 11:12 am
GitHub: https://github.com/ilikecoding-197

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

MichaelPetch wrote: Wed Nov 20, 2024 8:03 pm You could always start by updating your Github repo with the code that you are having issues with.
Ohhhh... Forgot to git push #-o
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard driver resets system when key is pressed.

Post by MichaelPetch »

My builds don't get any keyboard interrupts (not even one) when I run under QEMU and BOCHS. If I change `keyboard_init` to skip over your PS/2 and Keyboard initialization code it works as expected:

Code: Select all

int keyboard_init() {
    attach_interrupt(0x21, keyboard_interrupt);
    return KEYBOARD_INIT_SUCCESS;
}
This suggests to me you aren't setting things up correctly and you've managed to disable the keyboard interrupts. I think you need to revisit your `keyboard_init` code and see where you are going wrong.
Tomrs123
Member
Member
Posts: 40
Joined: Mon Aug 19, 2024 11:12 am
GitHub: https://github.com/ilikecoding-197

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

Okay, I didn't git push when you replied (as I was away from my computer) so I just pushed. Now you can help.
MichaelPetch
Member
Member
Posts: 797
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Keyboard driver resets system when key is pressed.

Post by MichaelPetch »

If your keyboard interrupt handler doesn't read a character from the data port you won't get further keyboard interrupts. As a test - in keyboard_handler() add an `inb(DATA_PORT);`. This just reads the character and throws it away, but reading the data port will be enough to allow an interrupt to be generated for the next key event.
Tomrs123
Member
Member
Posts: 40
Joined: Mon Aug 19, 2024 11:12 am
GitHub: https://github.com/ilikecoding-197

Re: Keyboard driver resets system when key is pressed.

Post by Tomrs123 »

The interrupts are in! Now, how do I send commands to the keyboards? I still need to fill in the reset devices part, and i would like to change the keyboard lights.
Post Reply