From b8fad3d02986222fa162d455eca2ffe807b6a15a Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Tue, 27 Aug 2013 15:48:32 -0700 Subject: arm: libpayload: Add cache coherent DMA memory definition and management This patch adds a mechanism to set aside a region of cache-coherent (i.e. usually uncached) virtual memory, which can be used to communicate with DMA devices without automatic cache snooping (common on ARM) without the need of explicit flush/invalidation instructions in the driver code. This works by setting aside said region in the (board-specific) page table setup, as exemplary done in this patch for the Snow and Pit boards. It uses a new mechanism for adding board-specific Coreboot table entries to describe this region in an entry with the LB_DMA tag. Libpayload's memory allocator is enhanced to be able to operate on distinct types/regions of memory. It provides dma_malloc() and dma_memalign() functions for use in drivers, which by default just operate on the same heap as their traditional counterparts. However, if the Coreboot table parsing code finds a CB_DMA section, further requests through the dma_xxx() functions will return memory from the region described therein instead. Change-Id: Ia9c249249e936bbc3eb76e7b4822af2230ffb186 Signed-off-by: Julius Werner Reviewed-on: https://chromium-review.googlesource.com/167155 (cherry picked from commit d142ccdcd902a9d6ab4d495fbe6cbe85c61a5f01) Signed-off-by: Isaac Christensen Reviewed-on: http://review.coreboot.org/6622 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/include/coreboot_tables.h | 1 + payloads/libpayload/include/stdlib.h | 3 +++ 2 files changed, 4 insertions(+) (limited to 'payloads/libpayload/include') diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 5132d50261..e20249d627 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -187,6 +187,7 @@ struct cb_gpios { #define CB_TAG_VDAT 0x0015 #define CB_TAG_VBNV 0x0019 #define CB_TAG_VBOOT_HANDOFF 0x0020 +#define CB_TAG_DMA 0x0022 struct lb_range { uint32_t tag; uint32_t size; diff --git a/payloads/libpayload/include/stdlib.h b/payloads/libpayload/include/stdlib.h index 92a13e38e7..8c8c200873 100644 --- a/payloads/libpayload/include/stdlib.h +++ b/payloads/libpayload/include/stdlib.h @@ -112,6 +112,9 @@ void *calloc(size_t nmemb, size_t size); void *realloc(void *ptr, size_t size); void *memalign(size_t align, size_t size); #endif +void init_dma_memory(void *start, u32 size); +void *dma_malloc(size_t size); +void *dma_memalign(size_t align, size_t size); /** @} */ /** -- cgit v1.2.3