Port of 4a6bea479a
Co-authored-by: Steve Fan <sf@m-labs.hk>
Reviewed-on: M-Labs/artiq-zynq#156
Co-authored-by: stevefan1999 <sf@m-labs.hk>
Co-committed-by: stevefan1999 <sf@m-labs.hk>
The previous method of taking the channel could cause deadlock, we now
use semaphore to signal if the channel is available instead of busy
polling the mutex.
* Changed the KERNEL_CHANNEL_* to Mutex<T> with proper type, remove the
need for unsafe.
* Exposed a const pointer to KernelImage, with UnsafeCell holding
the library field for unbind with interior mutability.
* Cache flush should be done before playback instead when getting the
handler.
* `csr::rtio_dma::enable_read()` would loop forever, probably bug in the
gateware.