New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PS/2 Overhaul #667
PS/2 Overhaul #667
Conversation
Thanks for this awesome PR @hecatia-elegua! Much appreciated. I'm a bit pressed for time this week, but I did a quick review and things generally look quite good! I will do a more detailed review next week, but in the meantime feel free to finish up the various to-do items and clean up tasks that you had noted, since I definitely plan to merge this PR in. I will also answer your questions above when time permits. |
fb7a866
to
d759a0e
Compare
This is done. |
haha, thanks so much, it's really an awesome contribution. I've been a bit backlogged but am slowly catching up; I will definitely do a full review this week. Much appreciated, and sorry for the delays! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok phew, I got through all the changes! In general everything looks great! I did leave a lot of comments, some of which are a bit nitpicky, and others which can be applied to many other parts of the code.
Thanks again, and kindly do let me know if there's anything you disagree with; I'm more than open to discussion.
Some questions about |
- save MOUSE_ID in Once cell - MousePacket structs for all ids - handle overflow - impl MousePacket seems large but easy
making it more obvious where we poll and where we retry sending
c222ac4
to
1bd86d7
Compare
wait, why did this break only now? |
1bd86d7
to
6693e35
Compare
Sure, you can call rustdoc on a specific crate, like I do here. But there's no real reason to do that (unless I'm missing something?)
The crates in
On some things, yes. That's mostly so intra-doc links on private items are checked and processed correctly, but technically it's not required. |
@hecatia-elegua thanks for addressing my comments! Everything looks pretty good, but it's a bit hard to tell if I missed any significant changes due to the fact that the branch has been force-pushed, which causes github to lose track of what I had previously reviewed. Anyway, are there any other remaining to-do items that you intend to work on, or do you consider this PR ready to be tested and merged in? |
What I meant by this: would we want another build-target with
Does it? It says "outdated" on most of your review comments, but on the lines I didn't change it doesn't. Changes started from this commit, so you could go through them from there, but Line 566 in 6693e35
The PR already had CI runs btw. and can be merged. |
Oh, I see. In that case, yes, potentially. Feel free to open up a new PR with that change; if it's good and only improves the docs then we can enable it unconditionally.
Yeah it breaks the nice github feature that shows "changes since your last review". But no big deal, since you told me the relevant starting commit too. Thanks!
Great, but those CI passes don't actually perform any runtime tests (yet... one day we'll get around to it). I test it myself, so I'll do that and merge things in if it goes well. I assume you've tested it thoroughly on QEMU at least. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested everything and it's working well, yay! I made a few small changes and merged in the latest changes from theseus_main
to ensure the branch still builds on our more recent nightly Rust version.
There's only one very minor issue - when pressing the Caps lock key, I see this error on the log:
[E] kernel/keyboard/src/lib.rs:192: handle_keyboard_input(): Unknown scancode: 250, adjusted scancode: 122
[E] kernel/keyboard/src/lib.rs:90: ps2_keyboard_handler: error handling PS2_PORT input: "unknown keyboard scancode"
If you have a moment to address that error, that'd be great. If not, let me know and I'm happy to look into it. Aside from that, I'd say this PR is ready to merge!
Thank you. If you have an idea what it could be, you can fix or tell me, otherwise I'll look into it later |
In our code, it looks like a caps lock press first triggers an interrupt with scancode 58 (make caps), then immediately another one with 250 (ack), a release only triggers an interrupt with 186 (break caps). I'm guessing the update: waiting works, but I just printed some stuff in a loop to wait, so instead, what's the right way to do it? |
I'm not sure if the keyboard works this way, but a lot of legacy devices on x86 (e.g., like this in the serial port) require you to spin in a loop while polling a status register in order to determine when the device is ready to receive another command. Perhaps you need to do that here too.
If there's not a status register (as I mentioned above) with a bit flag that indicates whether the keyboard is ready to receive a command, then we can insert a wait loop (but not by using print statements). This shouldn't be necessary, but a common way to do that in minimal legacy environments is this. |
Ok I took a deeper look, and fortunately this is probably a lot simpler than what we were discussing. You can ignore what i wrote above; i double-checked that your code paths are all properly checking/waiting for status registers. Your guess about |
A lot of wording online sounded like you always need to use polling for commands, e.g. when initializing the devices. We also at least need polling-send, as the PS/2 Controller does not support interrupt-driven sending to devices. I think we can merge now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks so much for this amazing contribution!
See referenced PR for more details a76ca0f
I intend to come back to these, yes. |
No more magic values, less errors, more docs, simpler functions, structs for all the response-bits, so no bit ops.
In general, saner code.
Some notes/questions:
I would still like to improve a bitI have improved a bit.map_err(|_| { warn!("..."); "disable mouse streaming failed"})
? it might make sense because it shows a kind of backtrace-like route up the error stack, but still seems/feels bad? I have read the recommended reading, but maybe I should look into some error-handling/logging crates (though I dislike the topic) -> some map_err calls were obsolete, but I'm still not comfortable with some of the error handling, again because we can't impl Error and I wonder in what cases we should just shutdown the system or reset the device/sKBD_MODIFIERS
right -> there is a note about "remove unsafe static mut" on it, not sure what to do about it (access is unsafe but there also is a note on access like "it should never race"Feel free to critique!