Drivers in WASI #501
Replies: 3 comments 5 replies
-
this sounds like it could be an interesting use case for multi-memory |
Beta Was this translation helpful? Give feedback.
-
I have no experience in the driver space, so I'm curious how this might work. If we had a way to do a volatile memory mapping in wasm linear memory, I assume there'd need to be some form of address translation, so that a store to linear memory at some index X can be translated to a store to some specific physical (virtual?) address Y. So my first question is, how might this mapping be configured? Who (wasm module and host/engine) knows what (linear-memory address and physical (virtual?) address) when (wasm producer time, startup time, or runtime)? My second question is, is memory mapping essential? If we had an API containing functions for performing reads and writes to I/O, instead of using loads and stores, would would be the impact? Some of the pros would be:
What would the cons be? |
Beta Was this translation helpful? Give feedback.
-
Since this seems to be somewhat inline to what some other people are thinking, I'd better raise the possibility of some "stretch goals" for drivers that extend beyond mere memory-mapped i/o. Adding support for the following types of devices will require careful thought. DMA ControlDevices that have internal buffers often times use direct memory access (DMA) to transfer contents into and out of the device. This is normally beyond the control of software because the device literally takes over the memory bus independently of the CPU. IOMMUDevices that perform their own compute capabilities (mostly graphics cards) oftentimes have a proprietary i/o memory management unit (IOMMU) which aids in address translation and extends the buffer addressing range of what might already be a heavily populated set of chiplets. These are operated on by drivers exclusively since they are usually proprietary and integrated into the device. |
Beta Was this translation helpful? Give feedback.
-
I've been looking over various proposals for drivers in WASI and I think a consesus needs to be raised up on the subject. So far, every abstract type of driver whether it be SPI, USB Serial or any other driver interface has been treated like a separate proposal. I'd like to propose a different framework to add drivers in a more abstract way.
Volitile Memory-Mapping
Every memory-mapped driver has a block of addresses that contains control registers for a particular device. If there were a way to access these from the WASI sandbox, it would be possible to write drivers for MMIO devices within the WebAssembly ecosystem. Of course the sandbox environment itself should block access to hardware-banging except via driver support, but if there were a way to wrap or even rewrite drivers to be instruction-set agnostic, I think that would be a boon to the electronics industry as a whole.
Ways To Make It Happen
There are several ways to make this happen but since this is a discussion rather than a formal proposal, I'd like to hear your thoughts on the subject. Also, if this gets elevated to the main WebAssembly working group, it will probably need a new protocol external to WASI. It will still affect WASI though so I thought I would bring it up here first. Feel free to share!
Beta Was this translation helpful? Give feedback.
All reactions