remove align_buffer from firmare/general.c, replacing with ALIGN_BUFFER macro, and replace all uses of it (only resize.c in core, and pictureflow and mpegplayer plugins), remove it from plugin_api,
and remove wrapper for it from plugin.h git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19758 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c0d9084d6a
commit
2fbf09752d
12 changed files with 23 additions and 59 deletions
|
@ -308,7 +308,6 @@ static const struct plugin_api rockbox_api = {
|
|||
mutex_init,
|
||||
mutex_lock,
|
||||
mutex_unlock,
|
||||
align_buffer,
|
||||
#endif
|
||||
|
||||
reset_poweroff_timer,
|
||||
|
|
|
@ -126,12 +126,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 135
|
||||
#define PLUGIN_API_VERSION 136
|
||||
|
||||
/* update this to latest version if a change to the api struct breaks
|
||||
backwards compatibility (and please take the opportunity to sort in any
|
||||
new function which are "waiting" at the end of the function table) */
|
||||
#define PLUGIN_MIN_API_VERSION 135
|
||||
#define PLUGIN_MIN_API_VERSION 136
|
||||
|
||||
/* plugin return codes */
|
||||
enum plugin_status {
|
||||
|
@ -419,7 +419,6 @@ struct plugin_api {
|
|||
void (*mutex_init)(struct mutex *m);
|
||||
void (*mutex_lock)(struct mutex *m);
|
||||
void (*mutex_unlock)(struct mutex *m);
|
||||
size_t (*align_buffer)(void **start, size_t size, size_t align);
|
||||
#endif
|
||||
|
||||
void (*reset_poweroff_timer)(void);
|
||||
|
@ -884,13 +883,5 @@ enum plugin_status plugin_start(const struct plugin_api* rockbox, const void* pa
|
|||
|
||||
#endif /* CACHE_FUNCTION_WRAPPERS */
|
||||
|
||||
#ifndef ALIGN_BUFFER_WRAPPER
|
||||
#define ALIGN_BUFFER_WRAPPER(api) \
|
||||
size_t align_buffer(void **start, size_t size, size_t align) \
|
||||
{ \
|
||||
return (api)->align_buffer(start, size, align); \
|
||||
}
|
||||
#endif /* ALIGN_BUFFER_WRAPPER */
|
||||
|
||||
#endif /* __PCTOOL__ */
|
||||
#endif
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
#define cpu_boost rb->cpu_boost
|
||||
#endif
|
||||
#define yield rb->yield
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
#define align_buffer rb->align_buffer
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "plugin.h"
|
||||
#include "mpegplayer.h"
|
||||
#include <system.h>
|
||||
|
||||
/* Main allocator */
|
||||
static off_t mem_ptr;
|
||||
|
@ -132,8 +133,8 @@ bool mpeg_alloc_init(unsigned char *buf, size_t mallocsize)
|
|||
mem_ptr = 0;
|
||||
/* Cache-align buffer or 4-byte align */
|
||||
mallocbuf = buf;
|
||||
bufsize = align_buffer(PUN_PTR(void **, &mallocbuf),
|
||||
mallocsize, CACHEALIGN_UP(4));
|
||||
bufsize = mallocsize;
|
||||
ALIGN_BUFFER(mallocbuf, bufsize, CACHEALIGN_UP(4));
|
||||
|
||||
/* Separate allocator for video */
|
||||
mpeg2_mem_ptr = 0;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "mpegplayer.h"
|
||||
#include <system.h>
|
||||
|
||||
static struct mutex disk_buf_mtx SHAREDBSS_ATTR;
|
||||
static struct event_queue disk_buf_queue SHAREDBSS_ATTR;
|
||||
|
@ -859,7 +860,7 @@ bool disk_buf_init(void)
|
|||
return false;
|
||||
|
||||
#ifdef PROC_NEEDS_CACHEALIGN
|
||||
disk_buf.size = CACHEALIGN_BUFFER(&disk_buf.start, disk_buf.size);
|
||||
CACHEALIGN_BUFFER(disk_buf.start, disk_buf.size);
|
||||
disk_buf.start = UNCACHED_ADDR(disk_buf.start);
|
||||
#endif
|
||||
disk_buf.size -= DISK_GUARDBUF_SIZE;
|
||||
|
|
|
@ -283,7 +283,6 @@ CONFIG_KEYPAD == SANSA_M200_PAD
|
|||
const struct plugin_api* rb;
|
||||
|
||||
CACHE_FUNCTION_WRAPPERS(rb);
|
||||
ALIGN_BUFFER_WRAPPER(rb);
|
||||
|
||||
/* One thing we can do here for targets with remotes is having a display
|
||||
* always on the remote instead of always forcing a popup on the main display */
|
||||
|
|
|
@ -2144,8 +2144,7 @@ enum plugin_status plugin_start(const struct plugin_api *api,
|
|||
rb->cpu_boost(true);
|
||||
#endif
|
||||
plugin_buf = rb->plugin_get_buffer(&plugin_buf_size);
|
||||
plugin_buf_size = rb->align_buffer(PUN_PTR(void**,&plugin_buf),
|
||||
plugin_buf_size, 4);
|
||||
ALIGN_BUFFER(plugin_buf, plugin_buf_size, 4);
|
||||
ret = main();
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(false);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <system.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -616,10 +617,7 @@ int resize_on_load(struct bitmap *bm, bool dither, struct dim *src,
|
|||
uint8_t sc_buf[(needed <= len || needed > MAX_SC_STACK_ALLOC) ?
|
||||
0 : needed];
|
||||
#endif
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
len = (unsigned int)align_buffer(PUN_PTR(void**, &buf), len,
|
||||
sizeof(uint32_t));
|
||||
#endif
|
||||
ALIGN_BUFFER(buf, len, sizeof(uint32_t));
|
||||
if (needed > len)
|
||||
{
|
||||
#if MAX_SC_STACK_ALLOC
|
||||
|
|
|
@ -39,15 +39,6 @@ bool action_userabort(int timeout)
|
|||
\return
|
||||
\description
|
||||
|
||||
size_t align_buffer(void **start, size_t size, size_t align)
|
||||
\group kernel/ system
|
||||
\conditions (CONFIG_CODEC == SWCODEC)
|
||||
\param start
|
||||
\param size
|
||||
\param align
|
||||
\return
|
||||
\description
|
||||
|
||||
const char *appsversion
|
||||
\return version of the plugin API
|
||||
\description
|
||||
|
|
|
@ -37,6 +37,4 @@ int make_list_from_caps32(unsigned long src_mask,
|
|||
unsigned long caps_mask,
|
||||
unsigned long *caps_list);
|
||||
|
||||
size_t align_buffer(void **start, size_t size, size_t align);
|
||||
|
||||
#endif /* GENERAL_H */
|
||||
|
|
|
@ -110,6 +110,17 @@ int get_cpu_boost_counter(void);
|
|||
#define ALIGN_DOWN(n, a) ((n)/(a)*(a))
|
||||
#define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a)
|
||||
|
||||
/* align start and end of buffer to nearest integer multiple of a */
|
||||
#define ALIGN_BUFFER(ptr,len,align) \
|
||||
{\
|
||||
uintptr_t tmp_ptr1 = (uintptr_t)ptr; \
|
||||
uintptr_t tmp_ptr2 = tmp_ptr1 + len;\
|
||||
tmp_ptr1 = ALIGN_UP(tmp_ptr1,align); \
|
||||
tmp_ptr2 = ALIGN_DOWN(tmp_ptr2,align); \
|
||||
len = tmp_ptr2 - tmp_ptr1; \
|
||||
ptr = (typeof(ptr))tmp_ptr1; \
|
||||
}
|
||||
|
||||
/* live endianness conversion */
|
||||
#ifdef ROCKBOX_LITTLE_ENDIAN
|
||||
#define letoh16(x) (x)
|
||||
|
@ -275,7 +286,7 @@ static inline uint32_t swap_odd_even32(uint32_t value)
|
|||
__attribute__((aligned(CACHEALIGN_UP(x))))
|
||||
/* Aligns a buffer pointer and size to proper boundaries */
|
||||
#define CACHEALIGN_BUFFER(start, size) \
|
||||
({ align_buffer(PUN_PTR(void **, (start)), (size), CACHEALIGN_SIZE); })
|
||||
ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE)
|
||||
|
||||
#else /* ndef PROC_NEEDS_CACHEALIGN */
|
||||
|
||||
|
@ -286,8 +297,7 @@ static inline uint32_t swap_odd_even32(uint32_t value)
|
|||
#define CACHEALIGN_UP(x) (x)
|
||||
#define CACHEALIGN_DOWN(x) (x)
|
||||
/* Make no adjustments */
|
||||
#define CACHEALIGN_BUFFER(start, size) \
|
||||
({ (void)(start); (size); })
|
||||
#define CACHEALIGN_BUFFER(start, size)
|
||||
|
||||
#endif /* PROC_NEEDS_CACHEALIGN */
|
||||
|
||||
|
|
|
@ -78,23 +78,3 @@ int make_list_from_caps32(unsigned long src_mask,
|
|||
|
||||
return count;
|
||||
} /* make_list_from_caps32 */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue