fix: repeated keyboard input when INT 16h polls an empty 8042 buffer - #2320
Open
fusefib wants to merge 1 commit into
Open
fix: repeated keyboard input when INT 16h polls an empty 8042 buffer#2320fusefib wants to merge 1 commit into
fusefib wants to merge 1 commit into
Conversation
INT 16h may invoke INT 09h while waiting for a keystroke. When the 8042 output buffer is empty, reading port 0x60 returns the previous data byte, causing the same scancode to be processed repeatedly. Check the controller status before reading the keyboard data port.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
Added a check in
BiosKeyboardInt9Handler.Run()for the Intel 8042 output-buffer-full/data-pending status bit before reading keyboard data from port0x60.If no new keyboard data is pending, the handler acknowledges IRQ1 and returns without processing a scancode.
Rationale behind Changes
The in-memory INT 16h handler invokes INT 09h when the BIOS keyboard buffer is empty in order to fetch pending keyboard input.
However,
BiosKeyboardInt9Handler.Run()previously read port0x60unconditionally.Intel8042Controller.ReadByte()intentionally returns the previous data byte when no new data is pending.This meant that when INT 16h invoked INT 09h while the 8042 output buffer was empty, the previous keyboard scancode could be processed again as if it were new input. In affected software, this caused a single physical key press to be duplicated repeatedly.
The issue was reproduced with the text adventure game Solus (1988). With
SOLUS.COM: pressingLonce resulted in a rapid flood oflcharacters despite the input pipeline receiving exactly one key-down and one key-up event. PressingEnteronce similarly resulted in multiple Enter key events being processed.Suggested Testing Steps
Run
SOLUS.COMand wait for its text parser prompt.Tap a letter key such as
Lonce, or pressEnteronce.