summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/buffering.c5
-rw-r--r--firmware/export/system.h3
2 files changed, 8 insertions, 0 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index e37b053881..123c7bc85f 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1572,6 +1572,11 @@ void buffering_init(void)
1572/* Initialise the buffering subsystem */ 1572/* Initialise the buffering subsystem */
1573bool buffering_reset(char *buf, size_t buflen) 1573bool buffering_reset(char *buf, size_t buflen)
1574{ 1574{
1575 /* Wraps of storage-aligned data must also be storage aligned,
1576 thus buf and buflen must be a aligned to an integer multiple of
1577 the storage alignment */
1578 STORAGE_ALIGN_BUFFER(buf, buflen);
1579
1575 if (!buf || !buflen) 1580 if (!buf || !buflen)
1576 return false; 1581 return false;
1577 1582
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 65db721bb4..78bddae387 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -388,11 +388,14 @@ static inline void cpucache_flush(void)
388 #define STORAGE_PAD(x) ((x) + CACHEALIGN_SIZE - 1) 388 #define STORAGE_PAD(x) ((x) + CACHEALIGN_SIZE - 1)
389 /* Number of bytes in the last cacheline assuming buffer of size x is aligned */ 389 /* Number of bytes in the last cacheline assuming buffer of size x is aligned */
390 #define STORAGE_OVERLAP(x) ((x) & (CACHEALIGN_SIZE - 1)) 390 #define STORAGE_OVERLAP(x) ((x) & (CACHEALIGN_SIZE - 1))
391 #define STORAGE_ALIGN_BUFFER(start, size) \
392 ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE)
391#else 393#else
392 #define STORAGE_ALIGN_ATTR 394 #define STORAGE_ALIGN_ATTR
393 #define STORAGE_ALIGN_DOWN(x) (x) 395 #define STORAGE_ALIGN_DOWN(x) (x)
394 #define STORAGE_PAD(x) (x) 396 #define STORAGE_PAD(x) (x)
395 #define STORAGE_OVERLAP(x) 0 397 #define STORAGE_OVERLAP(x) 0
398 #define STORAGE_ALIGN_BUFFER(start, size)
396#endif 399#endif
397 400
398/* Double-cast to avoid 'dereferencing type-punned pointer will 401/* Double-cast to avoid 'dereferencing type-punned pointer will