diff --git a/src/arch/arm/include/arch/memlayout.h b/src/arch/arm/include/arch/memlayout.h index 408443f1ba..991cbb78c6 100644 --- a/src/arch/arm/include/arch/memlayout.h +++ b/src/arch/arm/include/arch/memlayout.h @@ -22,11 +22,6 @@ REGION(stack, addr, size, 8) \ _ = ASSERT(size >= 2K, "stack should be >= 2K, see toolchain.mk"); -#define DMA_COHERENT(addr, size) \ - REGION(dma_coherent, addr, size, SUPERPAGE_SIZE) \ - _ = ASSERT(size % SUPERPAGE_SIZE == 0, \ - "DMA coherency buffer must fit exactly in full superpages!"); - #define FRAMEBUFFER(addr, size) \ REGION(framebuffer, addr, size, SUPERPAGE_SIZE) \ _ = ASSERT(size % SUPERPAGE_SIZE == 0, \ diff --git a/src/arch/arm64/include/arch/memlayout.h b/src/arch/arm64/include/arch/memlayout.h index 69e4731a12..5c648b36f0 100644 --- a/src/arch/arm64/include/arch/memlayout.h +++ b/src/arch/arm64/include/arch/memlayout.h @@ -9,11 +9,6 @@ REGION(ttb, addr, size, 4K) \ _ = ASSERT(size % 4K == 0, "TTB size must be divisible by 4K!"); -#define DMA_COHERENT(addr, size) \ - REGION(dma_coherent, addr, size, 4K) \ - _ = ASSERT(size % 4K == 0, \ - "DMA buffer should be multiple of smallest page size (4K)!"); - #define FRAMEBUFFER(addr, size) \ REGION(framebuffer, addr, size, 1M) \ _ = ASSERT(size % 1M == 0, \ diff --git a/src/include/memlayout.h b/src/include/memlayout.h index 07addbbcde..85f2959434 100644 --- a/src/include/memlayout.h +++ b/src/include/memlayout.h @@ -101,6 +101,32 @@ ALIAS_REGION(postram_cbfs_cache, cbfs_cache) #endif +/* Use either DMA_COHERENT (unified) or both (PRERAM|POSTRAM)_DMA_COHERENT */ +#define DMA_COHERENT(addr, size) \ + REGION(dma_coherent, addr, size, 4K) \ + _ = ASSERT(size % 4K == 0, \ + "DMA buffer should be multiple of smallest page size (4K)!"); \ + ALIAS_REGION(dma_coherent, preram_dma_coherent) \ + ALIAS_REGION(dma_coherent, postram_dma_coherent) + +#if ENV_ROMSTAGE_OR_BEFORE + #define PRERAM_DMA_COHERENT(addr, size) \ + REGION(preram_dma_coherent, addr, size, 4K) \ + _ = ASSERT(size % 4K == 0, \ + "Pre-RAM DMA buffer should be multiple of smallest page size (4K)!"); \ + ALIAS_REGION(preram_dma_coherent, dma_coherent) + #define POSTRAM_DMA_COHERENT(addr, size) \ + REGION(postram_dma_coherent, addr, size, 4K) +#else + #define PRERAM_DMA_COHERENT(addr, size) \ + REGION(preram_dma_coherent, addr, size, 4K) + #define POSTRAM_DMA_COHERENT(addr, size) \ + REGION(postram_dma_coherent, addr, size, 4K) \ + _ = ASSERT(size % 4K == 0, \ + "Post-RAM DMA buffer should be multiple of smallest page size (4K)!"); \ + ALIAS_REGION(postram_dma_coherent, dma_coherent) +#endif + /* Careful: 'INCLUDE ' must always be at the end of the output line */ #if ENV_DECOMPRESSOR #define DECOMPRESSOR(addr, sz) \ diff --git a/src/include/symbols.h b/src/include/symbols.h index ad8231c089..c46b6ff9ef 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -73,6 +73,8 @@ DECLARE_REGION(ramstage) DECLARE_REGION(pagetables) DECLARE_REGION(ttb) DECLARE_OPTIONAL_REGION(ttb_subtables) +DECLARE_OPTIONAL_REGION(preram_dma_coherent) +DECLARE_OPTIONAL_REGION(postram_dma_coherent) DECLARE_REGION(dma_coherent) DECLARE_REGION(soc_registers) DECLARE_OPTIONAL_REGION(framebuffer)