From: Sven Van Asbroeck <thesven73@gmail.com> To: rust-for-linux@vger.kernel.org Subject: [RFC] Short Circuit simplest Rust driver that touches real hardware? Date: Mon, 26 Apr 2021 15:47:59 -0400 [thread overview] Message-ID: <CAGngYiUHmkGTP7encnQOHv9CU6H4+RTN96oJb9B7DY4cuGPwAQ@mail.gmail.com> (raw) (Is this the correct forum for this discussion? Should it go on Rust-for-Linux's GitHub instead?) Senior Linux people have expressed interest in seeing a Rust driver that touches actual hardware. Nvme has been suggested as an excellent candidate. But, that's going to be quite complex, and possibly a long way off still. Is there merit in "short circuiting" a Rust driver that touches actual hardware? I.e. only do the minimum that's reasonably required, to drive a trivial piece of hardware. Suggestion: 1. implement `platform_device` in Rust, just enough to be `probe()`d by the kernel, and receive a live `struct device *` - we should wrap this pointer in a suitable Rust abstraction of course. 2. implement the simplest `IoMemBlock` in Rust. Since we have a live `struct device *`, the `IoMemBlock` constructor can simply call `devm_platform_get_and_ioremap_resource(our struct device *)` in C, which will automatically use the right method to retrieve the `void __iomem *`: devicetree, platform data, etc, we don't have to care. 3. use the `IoMemBlock` above to implement a trivial iomem-only driver as a module. A few possible candidates: * h/w random number generator in Raspberry Pi Zero: `brcm,bcm2835-rng` * SoC thermal sensor in Raspberry Pi Zero: `brcm,bcm2835-thermal` 4. we don't have `hwrng` or `thermal_hwmon` devices in Rust yet, but we could perhaps expose this as a `misc_device`, which is something we already have. A single temp or randnum readout might do the trick. The Raspberry Pi Zero can be purchased for $10. There is [QEMU support](https://qemu.readthedocs.io/en/latest/system/arm/raspi.html) for the peripherals above. Feedback and ideas welcome !
next reply other threads:[~2021-04-26 19:48 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-26 19:47 Sven Van Asbroeck [this message] 2021-04-26 20:22 ` Miguel Ojeda 2021-04-26 20:58 ` Geert Stappers 2021-04-26 21:11 ` Sven Van Asbroeck 2021-04-27 8:17 ` Geert Stappers 2021-04-27 6:49 ` Greg KH
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAGngYiUHmkGTP7encnQOHv9CU6H4+RTN96oJb9B7DY4cuGPwAQ@mail.gmail.com \ --to=thesven73@gmail.com \ --cc=rust-for-linux@vger.kernel.org \ --subject='Re: [RFC] Short Circuit simplest Rust driver that touches real hardware?' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).