rust-osdev / rust-osdev/ps2-mouse
`new` or `init` function should probably be marked as `unsafe`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Currently, there is no unsafe stopping someone from doing something like this:
let mut m1 = Mouse::new();
let mut m2 = Mouse::new();
// At the same time
m1.init();
m2.init();
Which would mess things up if the same ports are being accessed simultaneously.
I would suggest: making the init function unsafe:
/// # Safety
/// Reads and writes to ports 0x60 and 0x64. You must ensure that these ports are not being accessed concurrently by other code.
And another idea: What if the init function (and the other functions such as was a standalone function instead of being a method of Mouse? This way, we can leave Mouse as a pure, safe parser for incoming mouse data while making it more obvious that the init function modifies global state.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Mouse::new and Mouse::init implementations and the code accessing ports 0x60 and 0x64. Resolve whether initialization should become unsafe or a standalone operation, then update the API and its safety documentation; done means the chosen design prevents undocumented concurrent port access while preserving Mouse as a parser where applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100