Skip to content

Commit

Permalink
Update DMA software (#348)
Browse files Browse the repository at this point in the history
* Update DMA software

* Update Comments

* Bug Fix

* Bug Fix
  • Loading branch information
IveanEx committed Sep 26, 2024
1 parent 0d6893e commit fccc4af
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sw/snRuntime/src/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/// A DMA transfer identifier.
typedef uint32_t snrt_dma_txid_t;

// Early declaration of the functions
inline uint32_t __attribute__((const)) snrt_cluster_base_addrh();

/// Initiate an asynchronous 1D DMA transfer with wide 64-bit pointers.
inline snrt_dma_txid_t snrt_dma_start_1d_wideptr(uint64_t dst, uint64_t src,
size_t size) {
Expand Down Expand Up @@ -53,10 +56,14 @@ inline snrt_dma_txid_t snrt_dma_start_1d_wideptr(uint64_t dst, uint64_t src,
}
}

/// Initiate an asynchronous 1D DMA transfer.
/// Initiate an asynchronous 1D DMA transfer. (for local-chip transfers)
inline snrt_dma_txid_t snrt_dma_start_1d(void *dst, const void *src,
size_t size) {
return snrt_dma_start_1d_wideptr((size_t)dst, (size_t)src, size);
uint64_t dst_wideptr = (uint64_t)dst;
dst_wideptr += (uint64_t)snrt_cluster_base_addrh() << 32;
uint64_t src_wideptr = (uint64_t)src;
src_wideptr += (uint64_t)snrt_cluster_base_addrh() << 32;
return snrt_dma_start_1d_wideptr(dst_wideptr, src_wideptr, size);
}

/// Initiate an asynchronous 2D DMA transfer with wide 64-bit pointers.
Expand Down Expand Up @@ -131,11 +138,15 @@ inline snrt_dma_txid_t snrt_dma_start_2d_wideptr(uint64_t dst, uint64_t src,
}
}

/// Initiate an asynchronous 2D DMA transfer.
/// Initiate an asynchronous 2D DMA transfer. (for local-chip transfers)
inline snrt_dma_txid_t snrt_dma_start_2d(void *dst, const void *src,
size_t size, size_t dst_stride,
size_t src_stride, size_t repeat) {
return snrt_dma_start_2d_wideptr((size_t)dst, (size_t)src, size, dst_stride,
uint64_t dst_wideptr = (uint64_t)dst;
dst_wideptr += (uint64_t)snrt_cluster_base_addrh() << 32;
uint64_t src_wideptr = (uint64_t)src;
src_wideptr += (uint64_t)snrt_cluster_base_addrh() << 32;
return snrt_dma_start_2d_wideptr(dst_wideptr, src_wideptr, size, dst_stride,
src_stride, repeat);
}

Expand Down

0 comments on commit fccc4af

Please sign in to comment.