diff options
Diffstat (limited to 'firmware/general.c')
-rw-r--r-- | firmware/general.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/general.c b/firmware/general.c index 7f4348046c..cc3710c8f3 100644 --- a/firmware/general.c +++ b/firmware/general.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include <limits.h> | 19 | #include <limits.h> |
20 | #include "system.h" | ||
20 | #include "config.h" | 21 | #include "config.h" |
21 | #include "general.h" | 22 | #include "general.h" |
22 | 23 | ||
@@ -75,3 +76,26 @@ int make_list_from_caps32(unsigned long src_mask, | |||
75 | 76 | ||
76 | return count; | 77 | return count; |
77 | } /* make_list_from_caps32 */ | 78 | } /* make_list_from_caps32 */ |
79 | |||
80 | /* Only needed for cache aligning atm */ | ||
81 | #ifdef PROC_NEEDS_CACHEALIGN | ||
82 | /* Align a buffer and size to a size boundary while remaining within | ||
83 | * the original boundaries */ | ||
84 | size_t align_buffer(void **start, size_t size, size_t align) | ||
85 | { | ||
86 | void *newstart = *start; | ||
87 | void *newend = newstart + size; | ||
88 | |||
89 | /* Align the end down and the start up */ | ||
90 | newend = (void *)ALIGN_DOWN((intptr_t)newend, align); | ||
91 | newstart = (void *)ALIGN_UP((intptr_t)newstart, align); | ||
92 | |||
93 | /* Hmmm - too small for this */ | ||
94 | if (newend <= newstart) | ||
95 | return 0; | ||
96 | |||
97 | /* Return adjusted pointer and size */ | ||
98 | *start = newstart; | ||
99 | return newend - newstart; | ||
100 | } | ||
101 | #endif /* PROC_NEEDS_CACHEALIGN */ | ||