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
This commit is contained in:
Michael Sevakis 2007-11-08 05:17:20 +00:00
parent 194a66ef83
commit 57d71e4267
8 changed files with 87 additions and 5 deletions

View file

@ -17,6 +17,7 @@
*
****************************************************************************/
#include <limits.h>
#include "system.h"
#include "config.h"
#include "general.h"
@ -75,3 +76,26 @@ int make_list_from_caps32(unsigned long src_mask,
return count;
} /* make_list_from_caps32 */
/* Only needed for cache aligning atm */
#ifdef PROC_NEEDS_CACHEALIGN
/* Align a buffer and size to a size boundary while remaining within
* the original boundaries */
size_t align_buffer(void **start, size_t size, size_t align)
{
void *newstart = *start;
void *newend = newstart + size;
/* Align the end down and the start up */
newend = (void *)ALIGN_DOWN((intptr_t)newend, align);
newstart = (void *)ALIGN_UP((intptr_t)newstart, align);
/* Hmmm - too small for this */
if (newend <= newstart)
return 0;
/* Return adjusted pointer and size */
*start = newstart;
return newend - newstart;
}
#endif /* PROC_NEEDS_CACHEALIGN */