Open nsch0e opened 3 years ago
Function to synchronize between cached and non-cached memory so they contain the same content.
For example dma seems to work only on non-cached memory so all cached memory arguments get copied to extra allocated non-cached memory: https://github.com/kendryte/kendryte-standalone-sdk/blob/06a2ea71f250e91d66fa156ff82ae1f5b9fc6e56/lib/drivers/dmac.c#L373 this is non-performant and dangerous because of the amount of mallocs used.
you can use a normal variable as non-cached by subtracting the offset between cache and non-cached memory like this:
uint8_t arrCached[1024]; uint8_t *arr = arrCached - 0x40000000;
but there is no guarantee at any point that arrCached and arr show the same results although they point to mirrored memory.
Would using the mb() (memory barrier) macro be enough? https://github.com/kendryte/kendryte-standalone-sdk/blob/06a2ea71f250e91d66fa156ff82ae1f5b9fc6e56/lib/bsp/include/atomic.h#L36
mb()
Kind regards!
Missing feature
Function to synchronize between cached and non-cached memory so they contain the same content.
Justification
For example dma seems to work only on non-cached memory so all cached memory arguments get copied to extra allocated non-cached memory: https://github.com/kendryte/kendryte-standalone-sdk/blob/06a2ea71f250e91d66fa156ff82ae1f5b9fc6e56/lib/drivers/dmac.c#L373 this is non-performant and dangerous because of the amount of mallocs used.
Workarounds (kind of)
you can use a normal variable as non-cached by subtracting the offset between cache and non-cached memory like this:
but there is no guarantee at any point that arrCached and arr show the same results although they point to mirrored memory.
Would using the
mb()
(memory barrier) macro be enough? https://github.com/kendryte/kendryte-standalone-sdk/blob/06a2ea71f250e91d66fa156ff82ae1f5b9fc6e56/lib/bsp/include/atomic.h#L36Kind regards!