Keyboard driver resets system when key is pressed.
-
- Member
- Posts: 5531
- Joined: Mon Mar 25, 2013 7:01 pm
-
- 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.
Oh, so its the excatly the same as sending normal commands to the controller, except for sending to the data port, neat!
-
- 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.
So I'm back once again... when will this stupid keyboard driver end...
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.
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.
-
- Member
- Posts: 5531
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Keyboard driver resets system when key is pressed.
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?
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.
-
- Member
- Posts: 787
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
-
- 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.
Ohhhh... Forgot to git pushMichaelPetch 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.
-
- Member
- Posts: 787
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Keyboard driver resets system when key is pressed.
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:
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.
Code: Select all
int keyboard_init() {
attach_interrupt(0x21, keyboard_interrupt);
return KEYBOARD_INIT_SUCCESS;
}
-
- 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.
Okay, I didn't git push when you replied (as I was away from my computer) so I just pushed. Now you can help.
-
- Member
- Posts: 787
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Keyboard driver resets system when key is pressed.
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.
-
- 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.
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.