summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-11-08 05:17:20 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-11-08 05:17:20 +0000
commit57d71e4267ecf66c84173f8ff3606091187b93b1 (patch)
tree7992814f1dfbcf7c5251cad0fdc6da9a5ebb70a3 /firmware/export
parent194a66ef83664b0ebd23b9bea031c67c3b80f6ac (diff)
downloadrockbox-57d71e4267ecf66c84173f8ff3606091187b93b1.tar.gz
rockbox-57d71e4267ecf66c84173f8ff3606091187b93b1.zip
Add some CACHEALIGN_* macros and a helper function to assist in aligning data and buffers on PortalPlayer processors to cache line boundaries. They're noops when PROC_NEED_CACHEALIGN isn't defined. Go safe and increase the value to 32 since I'm not sure yet if 16 is sufficient - changing that is a one-liner. Add helper to plugin API which will be needed shortly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15523 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/general.h2
-rw-r--r--firmware/export/system.h32
2 files changed, 34 insertions, 0 deletions
diff --git a/firmware/export/general.h b/firmware/export/general.h
index 427e2773b8..f4ea9e206a 100644
--- a/firmware/export/general.h
+++ b/firmware/export/general.h
@@ -21,6 +21,7 @@
21#define GENERAL_H 21#define GENERAL_H
22 22
23#include <stdbool.h> 23#include <stdbool.h>
24#include <stddef.h>
24 25
25/* round a signed/unsigned 32bit value to the closest of a list of values */ 26/* round a signed/unsigned 32bit value to the closest of a list of values */
26/* returns the index of the closest value */ 27/* returns the index of the closest value */
@@ -34,5 +35,6 @@ int make_list_from_caps32(unsigned long src_mask,
34 unsigned long caps_mask, 35 unsigned long caps_mask,
35 unsigned long *caps_list); 36 unsigned long *caps_list);
36 37
38size_t align_buffer(void **start, size_t size, size_t align);
37 39
38#endif /* GENERAL_H */ 40#endif /* GENERAL_H */
diff --git a/firmware/export/system.h b/firmware/export/system.h
index dc10c4545f..cba4b81631 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -229,4 +229,36 @@ static inline uint32_t swap_odd_even32(uint32_t value)
229#define flush_icache() 229#define flush_icache()
230#endif 230#endif
231 231
232#ifdef PROC_NEEDS_CACHEALIGN
233/* Cache alignment attributes and sizes are enabled */
234
235/* 2^CACHEALIGN_BITS = the byte size */
236#define CACHEALIGN_SIZE (1u << CACHEALIGN_BITS)
237
238#define CACHEALIGN_ATTR __attribute__((aligned(CACHEALIGN_SIZE)))
239/* Aligns x up to a CACHEALIGN_SIZE boundary */
240#define CACHEALIGN_UP(x) \
241 ((typeof (x))ALIGN_UP_P2((uintptr_t)(x), CACHEALIGN_BITS))
242/* Aligns x down to a CACHEALIGN_SIZE boundary */
243#define CACHEALIGN_DOWN(x) \
244 ((typeof (x))ALIGN_DOWN_P2((uintptr_t)(x), CACHEALIGN_BITS))
245/* Aligns at least to the greater of size x or CACHEALIGN_SIZE */
246#define CACHEALIGN_AT_LEAST_ATTR(x) __attribute__((aligned(CACHEALIGN_UP(x))))
247/* Aligns a buffer pointer and size to proper boundaries */
248#define CACHEALIGN_BUFFER(start, size) \
249 ({ align_buffer((start), (size), CACHEALIGN_SIZE); })
250
251#else /* ndef PROC_NEEDS_CACHEALIGN */
252
253/* Cache alignment attributes and sizes are not enabled */
254#define CACHEALIGN_ATTR
255#define CACHEALIGN_AT_LEAST_ATTR(x) __attribute__((aligned(x)))
256#define CACHEALIGN_UP(x) (x)
257#define CACHEALIGN_DOWN(x) (x)
258/* Make no adjustments */
259#define CACHEALIGN_BUFFER(start, size) \
260 ({ (void)(start); (size); })
261
262#endif /* PROC_NEEDS_CACHEALIGN */
263
232#endif /* __SYSTEM_H__ */ 264#endif /* __SYSTEM_H__ */