oxidecomputer / hubris

A lightweight, memory-protected, message-passing kernel for deeply embedded systems.
Mozilla Public License 2.0
2.96k stars 169 forks source link

MVP implementation of `HostFlash` for Cosmo #1851

Closed mkeeter closed 1 month ago

mkeeter commented 1 month ago

This PR implements the HostFlash API for the Cosmo / Grapefruit flash IC, mediated by an FPGA.

gimlet-hf is renamed to hf in a few places, because we're now using the same API for both Gimlet and Cosmo systems. There are no changes to the API itself.

drv-fmc-nor-flash is renamed to drv-cosmo-hf for symmetry with Gimlet. It is split into main.rs (implementing the actual chip wrangling) and hf.rs (implementing the HostFlash Idol API).

Many functions are left as stubs, to be implemented in later PRs. However, this PR is sufficient to program and verify the flash chip with humility qspi!

mkeeter commented 1 month ago

For me the highest priority things to look at here are:

  1. Switch the generic flash read functions to use dyn so we don't generate multiple copies of them in flash. (The traits appear object-safe.)

  2. The use of Result<(), ()> seems suspicious, consider whether the error type could be something more useful. (I think this might have been inherited from BufWriter, but I think it's arguably wrong there too; no reason to propagate the wrongness when your IPC error types are right there.)

  3. Comment that unwrap please, it's subtle

  4. Make sure those todo!s will get todone, otherwise the operations shouldn't be in the IPC protocol (and we need to fork it).

  5. The flash_foo functions toward the end could use doc comments explaining any assumptions and failure cases.

This is all done except 2, because I opened https://github.com/oxidecomputer/idolatry/pull/55 to fix it upstream.