Safety requirements of `Port::read` and `Port::write`

Open
#629 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
embedded-iot

Research direction

Start by reading the safety documentation for Port::read and Port::write and the Port implementation in the x86_64 crate; the issue does not name specific files or tests. Identify the safety preconditions, including whether multiple ports with the same ID are valid, and document them. Done means the unsafe methods’ docs give an exhaustive, actionable account of their safety requirements.

Written by the indexing model from the issue text.

Description

Context: I'm working on a Rust os dev course based on https://os.phil-opp.com (which is a great educational resource, thank you!) and I want to restrict students from writing unsafe code. I want to provide all necessary unsafe code in my template and have a safe wrapper around them so that students can use it.

For writing a safe wrapper around Port, I need to know the safety requirements of its unsafe methods. I can think of trivial ones like creating a Port with invalid port id, but it is unclear to me e.g. whether creating two port with same id will lead to UB or not. So an exhaustive list of safety precondition for those functions is much appreciated. Current docs "This function is unsafe because the I/O port could have side effects that violate memory safety." is not really helpful. Thanks!

Dominant language
Rust
Stars
946
Forks
161
Avg merge
1d 21h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-osdev/x86_64

All issues in rust-osdev/x86_64

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.