Accept FS#7264 'Build with -Os switch for coldfire targets'.

Introduces MEM_FUNCTION_WRAPPERS(api) macro which adds wrappers 
functions to a plugin to make plugins link correctly when gcc
calls mem* functions directly.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13625 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2007-06-13 15:35:07 +00:00
parent f50bd1151a
commit c7f9ca4067
21 changed files with 105 additions and 29 deletions

View file

@ -332,7 +332,7 @@ static struct mutex mutex_codecthread NOCACHEBSS_ATTR;
static volatile bool voice_thread_start = false; /* Triggers voice playback (A/V) */ static volatile bool voice_thread_start = false; /* Triggers voice playback (A/V) */
static volatile bool voice_is_playing NOCACHEBSS_ATTR = false; /* Is voice currently playing? (V) */ static volatile bool voice_is_playing NOCACHEBSS_ATTR = false; /* Is voice currently playing? (V) */
static volatile bool voice_codec_loaded NOCACHEBSS_ATTR = false; /* Is voice codec loaded (V/A-) */ static volatile bool voice_codec_loaded NOCACHEBSS_ATTR = false; /* Is voice codec loaded (V/A-) */
static char *voicebuf = NULL; static unsigned char *voicebuf = NULL;
static size_t voice_remaining = 0; static size_t voice_remaining = 0;
#ifdef IRAM_STEAL #ifdef IRAM_STEAL
@ -340,12 +340,12 @@ static size_t voice_remaining = 0;
static bool voice_iram_stolen = false; static bool voice_iram_stolen = false;
#endif #endif
static void (*voice_getmore)(unsigned char** start, int* size) = NULL; static void (*voice_getmore)(unsigned char** start, size_t* size) = NULL;
struct voice_info { struct voice_info {
void (*callback)(unsigned char **start, int *size); void (*callback)(unsigned char **start, size_t* size);
int size; size_t size;
char *buf; unsigned char *buf;
}; };
static void voice_thread(void); static void voice_thread(void);
static void voice_stop(void); static void voice_stop(void);
@ -355,12 +355,12 @@ static void voice_stop(void);
/* --- External interfaces --- */ /* --- External interfaces --- */
void mp3_play_data(const unsigned char* start, int size, void mp3_play_data(const unsigned char* start, int size,
void (*get_more)(unsigned char** start, int* size)) void (*get_more)(unsigned char** start, size_t* size))
{ {
#ifdef PLAYBACK_VOICE #ifdef PLAYBACK_VOICE
static struct voice_info voice_clip; static struct voice_info voice_clip;
voice_clip.callback = get_more; voice_clip.callback = get_more;
voice_clip.buf = (char *)start; voice_clip.buf = (unsigned char*)start;
voice_clip.size = size; voice_clip.size = size;
LOGFQUEUE("mp3 > voice Q_VOICE_STOP"); LOGFQUEUE("mp3 > voice Q_VOICE_STOP");
queue_post(&voice_queue, Q_VOICE_STOP, 0); queue_post(&voice_queue, Q_VOICE_STOP, 0);
@ -1238,7 +1238,7 @@ voice_play_clip:
if (voice_remaining == 0 || voicebuf == NULL) if (voice_remaining == 0 || voicebuf == NULL)
{ {
if (voice_getmore) if (voice_getmore)
voice_getmore((unsigned char **)&voicebuf, (int *)&voice_remaining); voice_getmore((unsigned char **)&voicebuf, &voice_remaining);
/* If this clip is done */ /* If this clip is done */
if (voice_remaining == 0) if (voice_remaining == 0)

View file

@ -114,12 +114,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 57 #define PLUGIN_API_VERSION 58
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 56 #define PLUGIN_MIN_API_VERSION 58
/* plugin return codes */ /* plugin return codes */
enum plugin_status { enum plugin_status {
@ -417,7 +417,7 @@ struct plugin_api {
int (*sound_min)(int setting); int (*sound_min)(int setting);
int (*sound_max)(int setting); int (*sound_max)(int setting);
#ifndef SIMULATOR #ifndef SIMULATOR
void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); void (*mp3_play_data)(const unsigned char* start, int size, void (*get_more)(unsigned char** start, size_t* size));
void (*mp3_play_pause)(bool play); void (*mp3_play_pause)(bool play);
void (*mp3_play_stop)(void); void (*mp3_play_stop)(void);
bool (*mp3_is_playing)(void); bool (*mp3_is_playing)(void);

View file

@ -20,6 +20,7 @@
#ifndef SIMULATOR /* not for the simulator */ #ifndef SIMULATOR /* not for the simulator */
#include "plugin.h" #include "plugin.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
#define BATTERY_LOG "/battery_bench.txt" #define BATTERY_LOG "/battery_bench.txt"
@ -98,6 +99,7 @@ PLUGIN_HEADER
/****************************** Plugin Entry Point ****************************/ /****************************** Plugin Entry Point ****************************/
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
int main(void); int main(void);
bool exit_tsr(bool); bool exit_tsr(bool);
void thread(void); void thread(void);

View file

@ -20,6 +20,7 @@
#include "plugin.h" #include "plugin.h"
#include "card_deck.h" #include "card_deck.h"
#include "card_back.h" #include "card_back.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -213,6 +214,8 @@ extern const fb_data card_back[];
/* global rockbox api */ /* global rockbox api */
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
/* dealer and player card positions */ /* dealer and player card positions */
unsigned int dealer_x, dealer_y, player_x, player_y; unsigned int dealer_x, dealer_y, player_x, player_y;
@ -1399,7 +1402,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
(void)parameter; (void)parameter;
rb = api; rb = api;
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL); rb->lcd_set_backdrop(NULL);
#endif #endif

View file

@ -17,6 +17,7 @@
* *
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -153,6 +154,7 @@ PLUGIN_HEADER
it's nice not to have to pass the api pointer in all function calls it's nice not to have to pass the api pointer in all function calls
in the plugin */ in the plugin */
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
#define MAX_PLAYERS 10 #define MAX_PLAYERS 10
static struct { static struct {
@ -192,7 +194,6 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
(void)parameter; (void)parameter;
rb=api; rb=api;
rb->memset(&settings, 0, sizeof(settings)); rb->memset(&settings, 0, sizeof(settings));
/* now go ahead and have fun! */ /* now go ahead and have fun! */

View file

@ -1062,7 +1062,7 @@ static unsigned char beep[]={255,
111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85};
/* callback to request more mp3 data */ /* callback to request more mp3 data */
void callback(unsigned char** start, int* size) void callback(unsigned char** start, size_t* size)
{ {
*start = beep; /* give it the same frame again */ *start = beep; /* give it the same frame again */
*size = sizeof(beep); *size = sizeof(beep);

View file

@ -27,6 +27,7 @@
#include "plugin.h" #include "plugin.h"
#include "playback_control.h" #include "playback_control.h"
#include "oldmenuapi.h" #include "oldmenuapi.h"
#include "mem_function_wrappers.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "gray.h" #include "gray.h"
@ -186,6 +187,7 @@ PLUGIN_HEADER
/******************************* Globals ***********************************/ /******************************* Globals ***********************************/
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
/* for portability of below JPEG code */ /* for portability of below JPEG code */
#define MEMSET(p,v,c) rb->memset(p,v,c) #define MEMSET(p,v,c) rb->memset(p,v,c)

View file

@ -0,0 +1,44 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Nils Wallménius
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef __MEM_FUNCTION_WRAPPERS_H__
#define __MEM_FUNCTION_WRAPPERS_H__
/* Use this macro in plugins where gcc tries to optimize by calling
* these functions directly */
#define MEM_FUNCTION_WRAPPERS(api) \
void *memcpy(void *dest, const void *src, size_t n) \
{ \
return (api)->memcpy(dest, src, n); \
} \
void *memset(void *dest, int c, size_t n) \
{ \
return (api)->memset(dest, c, n); \
} \
void *memmove(void *dest, const void *src, size_t n) \
{ \
return (api)->memmove(dest, src, n); \
} \
int memcmp(const void *s1, const void *s2, size_t n) \
{ \
return (api)->memcmp(s1, s2, n); \
}
#endif /* __MEM_FUNCTION_WRAPPERS_H__ */

View file

@ -65,10 +65,12 @@ static bool volume(void)
static bool shuffle(void) static bool shuffle(void)
{ {
struct opt_items names[] = { struct opt_items names[2];
{ "No", -1 }, names[0].string = "No";
{ "Yes", -1 } names[0].voice_id = -1;
}; names[1].string = "Yes";
names[1].voice_id = -1;
return api->set_option("Shuffle", &api->global_settings->playlist_shuffle, return api->set_option("Shuffle", &api->global_settings->playlist_shuffle,
BOOL, names, 2,NULL); BOOL, names, 2,NULL);
} }

View file

@ -20,12 +20,15 @@
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "configfile.h" #include "configfile.h"
#include "mem_function_wrappers.h"
/* Include standard plugin macro */ /* Include standard plugin macro */
PLUGIN_HEADER PLUGIN_HEADER
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
#if CONFIG_KEYPAD == RECORDER_PAD #if CONFIG_KEYPAD == RECORDER_PAD
#define MAZEZAM_UP BUTTON_UP #define MAZEZAM_UP BUTTON_UP
#define MAZEZAM_DOWN BUTTON_DOWN #define MAZEZAM_DOWN BUTTON_DOWN

View file

@ -18,6 +18,7 @@
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "pluginlib_actions.h" #include "pluginlib_actions.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -70,6 +71,8 @@ static const struct button_mapping iriver_syncaction[] =
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
static int bpm = 120; static int bpm = 120;
static int period = 0; static int period = 0;
static int minitick = 0; static int minitick = 0;
@ -159,7 +162,7 @@ static unsigned char sound[] = {
85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
85, 85, 85}; 85, 85, 85};
void callback(unsigned char** start, int* size){ void callback(unsigned char** start, size_t* size){
(void)start; /* unused parameter, avoid warning */ (void)start; /* unused parameter, avoid warning */
*size = NULL; /* end of data */ *size = NULL; /* end of data */
sound_active = false; sound_active = false;

View file

@ -12,12 +12,15 @@
* Library General Public License for more details. */ * Library General Public License for more details. */
#include "plugin.h" #include "plugin.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
PLUGIN_IRAM_DECLARE PLUGIN_IRAM_DECLARE
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
#define SAMP_PER_FRAME 1152 #define SAMP_PER_FRAME 1152
#define SAMPL2 576 #define SAMPL2 576
#define SBLIMIT 32 #define SBLIMIT 32

View file

@ -17,11 +17,14 @@
* *
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
bool its_a_dir = false; bool its_a_dir = false;
char str_filename[MAX_PATH]; char str_filename[MAX_PATH];
@ -247,7 +250,6 @@ char * get_props(int selected_item, void* data, char *buffer)
enum plugin_status plugin_start(struct plugin_api* api, void* file) enum plugin_status plugin_start(struct plugin_api* api, void* file)
{ {
rb = api; rb = api;
struct gui_synclist properties_lists; struct gui_synclist properties_lists;
int button; int button;
bool prev_show_statusbar; bool prev_show_statusbar;

View file

@ -30,6 +30,7 @@
#include "errno.h" #include "errno.h"
#include "lib/bmp.h" #include "lib/bmp.h"
#include "lib/rgb_hsv.h" #include "lib/rgb_hsv.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -224,6 +225,8 @@ int errno;
static struct plugin_api* rb; static struct plugin_api* rb;
MEM_FUNCTION_WRAPPERS(rb);
static int drawcolor=0; /* Current color (in palette) */ static int drawcolor=0; /* Current color (in palette) */
static int bgdrawcolor=9; /* Current background color (in palette) */ static int bgdrawcolor=9; /* Current background color (in palette) */
bool isbg = false; /* gruik ugly hack alert */ bool isbg = false; /* gruik ugly hack alert */

View file

@ -423,7 +423,7 @@ void timer4_isr(void)
/* ISR function to get more mp3 data */ /* ISR function to get more mp3 data */
void GetMoreMp3(unsigned char** start, int* size) void GetMoreMp3(unsigned char** start, size_t* size)
{ {
int available; int available;
int advance; int advance;

View file

@ -19,6 +19,7 @@
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "mem_function_wrappers.h"
PLUGIN_HEADER PLUGIN_HEADER
@ -204,6 +205,9 @@ static int difficulty = 75; /* Percentage of screen that needs to be filled
* in order to win the game */ * in order to win the game */
static struct plugin_api *rb; static struct plugin_api *rb;
MEM_FUNCTION_WRAPPERS(rb);
static bool quit = false; static bool quit = false;
static unsigned int board[BOARD_H][BOARD_W]; static unsigned int board[BOARD_H][BOARD_W];
@ -295,7 +299,6 @@ static inline void emptyStack (void)
/*********************** END OF STACK STUFF *********************/ /*********************** END OF STACK STUFF *********************/
/* calculate the new x coordinate of the ball according to angle and speed */ /* calculate the new x coordinate of the ball according to angle and speed */
static inline int get_newx (int x, int len, int deg) static inline int get_newx (int x, int len, int deg)
{ {

View file

@ -132,7 +132,7 @@ static int talk_menu_disable; /* if non-zero, temporarily disable voice UI (not
/***************** Private prototypes *****************/ /***************** Private prototypes *****************/
static void load_voicefile(void); static void load_voicefile(void);
static void mp3_callback(unsigned char** start, int* size); static void mp3_callback(unsigned char** start, size_t* size);
static int shutup(void); static int shutup(void);
static int queue_clip(unsigned char* buf, long size, bool enqueue); static int queue_clip(unsigned char* buf, long size, bool enqueue);
static int open_voicefile(void); static int open_voicefile(void);
@ -262,7 +262,7 @@ load_err:
/* called in ISR context if mp3 data got consumed */ /* called in ISR context if mp3 data got consumed */
static void mp3_callback(unsigned char** start, int* size) static void mp3_callback(unsigned char** start, size_t* size)
{ {
queue[queue_read].len -= sent; /* we completed this */ queue[queue_read].len -= sent; /* we completed this */
queue[queue_read].buf += sent; queue[queue_read].buf += sent;

View file

@ -39,7 +39,7 @@ void demand_irq_enable(bool on);
/* new functions, exported to plugin API */ /* new functions, exported to plugin API */
void mp3_play_init(void); void mp3_play_init(void);
void mp3_play_data(const unsigned char* start, int size, void mp3_play_data(const unsigned char* start, int size,
void (*get_more)(unsigned char** start, int* size) /* callback fn */ void (*get_more)(unsigned char** start, size_t* size) /* callback fn */
); );
void mp3_play_pause(bool play); void mp3_play_pause(bool play);
bool mp3_pause_done(void); bool mp3_pause_done(void);

View file

@ -61,7 +61,7 @@ static long playstart_tick;
static long cumulative_ticks; static long cumulative_ticks;
/* the registered callback function to ask for more mp3 data */ /* the registered callback function to ask for more mp3 data */
static void (*callback_for_more)(unsigned char**, int*); static void (*callback_for_more)(unsigned char**, size_t*);
#endif /* #ifndef SIMULATOR */ #endif /* #ifndef SIMULATOR */
/* list of tracks in memory */ /* list of tracks in memory */
@ -167,7 +167,7 @@ void DEI3(void) __attribute__((interrupt_handler));
void DEI3(void) void DEI3(void)
{ {
unsigned char* start; unsigned char* start;
int size = 0; size_t size = 0;
if (callback_for_more != NULL) if (callback_for_more != NULL)
{ {
@ -502,7 +502,7 @@ void mp3_play_init(void)
} }
void mp3_play_data(const unsigned char* start, int size, void mp3_play_data(const unsigned char* start, int size,
void (*get_more)(unsigned char** start, int* size) /* callback fn */ void (*get_more)(unsigned char** start, size_t* size) /* callback fn */
) )
{ {
/* init DMA */ /* init DMA */

View file

@ -810,7 +810,7 @@ static void reset_mp3_buffer(void)
} }
/* DMA transfer end interrupt callback */ /* DMA transfer end interrupt callback */
static void transfer_end(unsigned char** ppbuf, int* psize) static void transfer_end(unsigned char** ppbuf, size_t* psize)
{ {
if(playing && !paused) if(playing && !paused)
{ {

5
tools/configure vendored
View file

@ -1470,6 +1470,11 @@ if test "$CC" = "sh-elf-gcc"; then
fi fi
fi fi
if test "$CC" = "m68k-elf-gcc"; then
# convert -O to -Os to get smaller binaries!
GCCOPTS=`echo $GCCOPTS | sed 's/ -O / -Os /'`
fi
if test "$1" = "--ccache"; then if test "$1" = "--ccache"; then
echo "Enable ccache for building" echo "Enable ccache for building"
ccache="ccache" ccache="ccache"