diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/general.h | 2 | ||||
-rw-r--r-- | firmware/export/system.h | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/firmware/export/general.h b/firmware/export/general.h index 7bcd08da00..d1bd14558c 100644 --- a/firmware/export/general.h +++ b/firmware/export/general.h | |||
@@ -37,6 +37,4 @@ int make_list_from_caps32(unsigned long src_mask, | |||
37 | unsigned long caps_mask, | 37 | unsigned long caps_mask, |
38 | unsigned long *caps_list); | 38 | unsigned long *caps_list); |
39 | 39 | ||
40 | size_t align_buffer(void **start, size_t size, size_t align); | ||
41 | |||
42 | #endif /* GENERAL_H */ | 40 | #endif /* GENERAL_H */ |
diff --git a/firmware/export/system.h b/firmware/export/system.h index 8ebd30ac4e..cc2a08db2e 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -110,6 +110,17 @@ int get_cpu_boost_counter(void); | |||
110 | #define ALIGN_DOWN(n, a) ((n)/(a)*(a)) | 110 | #define ALIGN_DOWN(n, a) ((n)/(a)*(a)) |
111 | #define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a) | 111 | #define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a) |
112 | 112 | ||
113 | /* align start and end of buffer to nearest integer multiple of a */ | ||
114 | #define ALIGN_BUFFER(ptr,len,align) \ | ||
115 | {\ | ||
116 | uintptr_t tmp_ptr1 = (uintptr_t)ptr; \ | ||
117 | uintptr_t tmp_ptr2 = tmp_ptr1 + len;\ | ||
118 | tmp_ptr1 = ALIGN_UP(tmp_ptr1,align); \ | ||
119 | tmp_ptr2 = ALIGN_DOWN(tmp_ptr2,align); \ | ||
120 | len = tmp_ptr2 - tmp_ptr1; \ | ||
121 | ptr = (typeof(ptr))tmp_ptr1; \ | ||
122 | } | ||
123 | |||
113 | /* live endianness conversion */ | 124 | /* live endianness conversion */ |
114 | #ifdef ROCKBOX_LITTLE_ENDIAN | 125 | #ifdef ROCKBOX_LITTLE_ENDIAN |
115 | #define letoh16(x) (x) | 126 | #define letoh16(x) (x) |
@@ -275,7 +286,7 @@ static inline uint32_t swap_odd_even32(uint32_t value) | |||
275 | __attribute__((aligned(CACHEALIGN_UP(x)))) | 286 | __attribute__((aligned(CACHEALIGN_UP(x)))) |
276 | /* Aligns a buffer pointer and size to proper boundaries */ | 287 | /* Aligns a buffer pointer and size to proper boundaries */ |
277 | #define CACHEALIGN_BUFFER(start, size) \ | 288 | #define CACHEALIGN_BUFFER(start, size) \ |
278 | ({ align_buffer(PUN_PTR(void **, (start)), (size), CACHEALIGN_SIZE); }) | 289 | ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE) |
279 | 290 | ||
280 | #else /* ndef PROC_NEEDS_CACHEALIGN */ | 291 | #else /* ndef PROC_NEEDS_CACHEALIGN */ |
281 | 292 | ||
@@ -286,8 +297,7 @@ static inline uint32_t swap_odd_even32(uint32_t value) | |||
286 | #define CACHEALIGN_UP(x) (x) | 297 | #define CACHEALIGN_UP(x) (x) |
287 | #define CACHEALIGN_DOWN(x) (x) | 298 | #define CACHEALIGN_DOWN(x) (x) |
288 | /* Make no adjustments */ | 299 | /* Make no adjustments */ |
289 | #define CACHEALIGN_BUFFER(start, size) \ | 300 | #define CACHEALIGN_BUFFER(start, size) |
290 | ({ (void)(start); (size); }) | ||
291 | 301 | ||
292 | #endif /* PROC_NEEDS_CACHEALIGN */ | 302 | #endif /* PROC_NEEDS_CACHEALIGN */ |
293 | 303 | ||