summaryrefslogtreecommitdiff
path: root/firmware/export/system.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/export/system.h')
-rw-r--r--firmware/export/system.h29
1 files changed, 13 insertions, 16 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 7dd01b5c93..9df382bc24 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -293,11 +293,13 @@ static inline void cpucache_flush(void)
293} 293}
294#endif 294#endif
295 295
296#ifdef PROC_NEEDS_CACHEALIGN 296#ifdef CACHEALIGN_BITS
297/* Cache alignment attributes and sizes are enabled */
298
299/* 2^CACHEALIGN_BITS = the byte size */ 297/* 2^CACHEALIGN_BITS = the byte size */
300#define CACHEALIGN_SIZE (1u << CACHEALIGN_BITS) 298#define CACHEALIGN_SIZE (1u << CACHEALIGN_BITS)
299#endif
300
301#ifdef PROC_NEEDS_CACHEALIGN
302/* Cache alignment attributes and sizes are enabled */
301 303
302#define CACHEALIGN_ATTR __attribute__((aligned(CACHEALIGN_SIZE))) 304#define CACHEALIGN_ATTR __attribute__((aligned(CACHEALIGN_SIZE)))
303/* Aligns x up to a CACHEALIGN_SIZE boundary */ 305/* Aligns x up to a CACHEALIGN_SIZE boundary */
@@ -312,16 +314,6 @@ static inline void cpucache_flush(void)
312/* Aligns a buffer pointer and size to proper boundaries */ 314/* Aligns a buffer pointer and size to proper boundaries */
313#define CACHEALIGN_BUFFER(start, size) \ 315#define CACHEALIGN_BUFFER(start, size) \
314 ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE) 316 ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE)
315/* Pad a size so the buffer can be aligned later */
316#define CACHE_PAD(x) ((x) + CACHEALIGN_SIZE - 1)
317/* Number of bytes in the last cacheline assuming buffer of size x is aligned */
318#define CACHE_OVERLAP(x) ((x) & (CACHEALIGN_SIZE - 1))
319
320#ifdef NEEDS_STORAGE_ALIGN
321#define STORAGE_ALIGN_DOWN(x) CACHEALIGN_DOWN(x)
322#define STORAGE_PAD(x) CACHE_PAD(x)
323#define STORAGE_OVERLAP(x) CACHE_OVERLAP(x)
324#endif
325 317
326#else /* ndef PROC_NEEDS_CACHEALIGN */ 318#else /* ndef PROC_NEEDS_CACHEALIGN */
327 319
@@ -333,12 +325,17 @@ static inline void cpucache_flush(void)
333#define CACHEALIGN_DOWN(x) (x) 325#define CACHEALIGN_DOWN(x) (x)
334/* Make no adjustments */ 326/* Make no adjustments */
335#define CACHEALIGN_BUFFER(start, size) 327#define CACHEALIGN_BUFFER(start, size)
336#define CACHE_PAD(x) (x)
337#define CACHE_OVERLAP(x) 0
338 328
339#endif /* PROC_NEEDS_CACHEALIGN */ 329#endif /* PROC_NEEDS_CACHEALIGN */
340 330
341#if !defined(PROC_NEEDS_CACHEALIGN) || !defined(NEEDS_STORAGE_ALIGN) 331#ifdef STORAGE_WANTS_ALIGN
332#define STORAGE_ALIGN_DOWN(x) \
333 ((typeof (x))ALIGN_DOWN_P2((uintptr_t)(x), CACHEALIGN_BITS))
334/* Pad a size so the buffer can be aligned later */
335#define STORAGE_PAD(x) ((x) + CACHEALIGN_SIZE - 1)
336/* Number of bytes in the last cacheline assuming buffer of size x is aligned */
337#define STORAGE_OVERLAP(x) ((x) & (CACHEALIGN_SIZE - 1))
338#else
342#define STORAGE_ALIGN_DOWN(x) (x) 339#define STORAGE_ALIGN_DOWN(x) (x)
343#define STORAGE_PAD(x) (x) 340#define STORAGE_PAD(x) (x)
344#define STORAGE_OVERLAP(x) 0 341#define STORAGE_OVERLAP(x) 0