23#define DMA_COMPLETE 0x400
26#define DMA_CHECK_MASK 0x401
29static const uint32_t DMA_WRITE_FLAGS =
33static const uint32_t DMA_READ_FLAGS =
38static inline bool dma_done(
void) {
39 return (dma[DMA_STAT] & DMA_CHECK_MASK) == DMA_COMPLETE;
47static inline void do_fast_dma_write(
void *tcm_address,
void *system_address,
49#if LOG_LEVEL >= LOG_DEBUG
53 if (stat & 0x1FFFFF) {
54 log_error(
"DMA pending or in progress on write: 0x%08x", stat);
58 uint32_t desc = DMA_WRITE_FLAGS | n_bytes;
59 dma[
DMA_ADRS] = (uint32_t) system_address;
60 dma[
DMA_ADRT] = (uint32_t) tcm_address;
69static inline void do_fast_dma_read(
void *system_address,
void *tcm_address,
71#if LOG_LEVEL >= LOG_DEBUG
75 if (stat & 0x1FFFFF) {
76 log_error(
"DMA pending or in progress on read: 0x%08x", stat);
80 uint32_t desc = DMA_READ_FLAGS | n_bytes;
81 dma[
DMA_ADRS] = (uint32_t) system_address;
82 dma[
DMA_ADRT] = (uint32_t) tcm_address;
87static inline void wait_for_dma_to_complete(
void) {
88#if LOG_LEVEL >= LOG_DEBUG
92 while (!dma_done() && n_loops < 10000) {
96 log_error(
"Timeout on DMA loop: DMA stat = 0x%08x!", dma[DMA_STAT]);
101 while (!dma_done()) {
110static inline void cancel_dmas(
void) {
112 while (dma[DMA_STAT] & 0x1) {
116 while (dma[DMA_CTRL] & 0xD) {
void log_error(const char *message,...)
void rt_error(uint code,...)