mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
Introduce plugin_crt0.c that every plugin links.
It handles exit() properly, calling the handler also when the plugin returns normally (also it makes exit() more standard compliant while at it). It also holds PLUGIN_HEADER, so that it doesn't need to be in each plugin anymore. To work better together with callbacks passed to rb->default_event_handler_ex introduce exit_on_usb() which will call the exit handler before showing the usb screen and exit() after it. In most cases it was passed a callback which was manually called at all other return points. This can now be done via atexit(). In future plugin_crt0.c could also handle clearing bss, initializing iram and more. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27862 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8106c9dc64
commit
abdc5935be
142 changed files with 372 additions and 341 deletions
|
@ -155,9 +155,13 @@ void* plugin_get_buffer(size_t *buffer_size);
|
|||
#define PLUGIN_MIN_API_VERSION 190
|
||||
|
||||
/* plugin return codes */
|
||||
/* internal returns start at 0x100 to make exit(1..255) work */
|
||||
#define INTERNAL_PLUGIN_RETVAL_START 0x100
|
||||
enum plugin_status {
|
||||
PLUGIN_OK = 0,
|
||||
PLUGIN_USB_CONNECTED,
|
||||
PLUGIN_OK = 0, /* PLUGIN_OK == EXIT_SUCCESS */
|
||||
/* 1...255 reserved for exit() */
|
||||
PLUGIN_USB_CONNECTED = INTERNAL_PLUGIN_RETVAL_START,
|
||||
PLUGIN_POWEROFF,
|
||||
PLUGIN_GOTO_WPS,
|
||||
PLUGIN_ERROR = -1,
|
||||
};
|
||||
|
@ -912,14 +916,14 @@ extern unsigned char plugin_end_addr[];
|
|||
const struct plugin_header __header \
|
||||
__attribute__ ((section (".header")))= { \
|
||||
PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
|
||||
plugin_start_addr, plugin_end_addr, plugin_start, &rb };
|
||||
plugin_start_addr, plugin_end_addr, plugin__start, &rb };
|
||||
#else /* PLATFORM_HOSTED */
|
||||
#define PLUGIN_HEADER \
|
||||
const struct plugin_api *rb DATA_ATTR; \
|
||||
const struct plugin_header __header \
|
||||
__attribute__((visibility("default"))) = { \
|
||||
PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
|
||||
NULL, NULL, plugin_start, &rb };
|
||||
NULL, NULL, plugin__start, &rb };
|
||||
#endif /* CONFIG_PLATFORM */
|
||||
|
||||
#ifdef PLUGIN_USE_IRAM
|
||||
|
@ -954,7 +958,7 @@ void plugin_tsr(bool (*exit_callback)(bool reenter));
|
|||
|
||||
/* defined by the plugin */
|
||||
extern const struct plugin_api *rb;
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
enum plugin_status plugin__start(const void* parameter)
|
||||
NO_PROF_ATTR;
|
||||
|
||||
#endif /* __PCTOOL__ */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
/* Only build for (correct) target */
|
||||
#if CONFIG_CPU==SH7034 && !(CONFIG_STORAGE & STORAGE_MMC)
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS /* player model */
|
||||
#define LINES 2
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "version.h"
|
||||
#include "plugin.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define BATTERY_LOG "/battery_bench.txt"
|
||||
#define BUF_SIZE 16000
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "midi/sequencer.h"
|
||||
#include "midi/midifile.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
/* variable button definitions */
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "plugin.h"
|
||||
#include "lib/jpeg_mem.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* a null output plugin to save memory and better isolate decode cost */
|
||||
static unsigned int get_size_null(struct bitmap *bm)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "plugin.h"
|
||||
#include "lib/jpeg_mem.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static unsigned char output;
|
||||
static int output_y = 0;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "lib/highscore.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* save files */
|
||||
#define SCORE_FILE PLUGIN_GAMES_DIR "/blackjack.score"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "time.h"
|
||||
#include "lib/fixedpoint.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define SS_TITLE "Bouncer"
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "pluginbitmaps/brickmania_break.h"
|
||||
#endif
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "lib/playback_control.h"
|
||||
#include "lib/highscore.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
/* files */
|
||||
#define SCORE_FILE PLUGIN_GAMES_DIR "/bubbles.score"
|
||||
#define SAVE_FILE PLUGIN_GAMES_DIR "/bubbles.save"
|
||||
|
|
|
@ -78,7 +78,7 @@ F3: equal to "="
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "math.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
|
||||
#define M_TWOPI (M_PI * 2.0)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "lib/playback_control.h"
|
||||
#include "lib/configfile.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
#define CALENDAR_QUIT BUTTON_OFF
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "lib/overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
|
|
|
@ -49,7 +49,7 @@ struct cb_command {
|
|||
extern const fb_data chessbox_pieces[];
|
||||
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Tile size defined by the assigned bitmap */
|
||||
#include "pluginbitmaps/chessbox_pieces.h"
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define EXTERN static
|
||||
#define STATIC static
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "lib/helper.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/*
|
||||
Still To do:
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "lib/playback_control.h"
|
||||
#include "lib/display_text.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if (CONFIG_KEYPAD == SANSA_E200_PAD)
|
||||
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "plugin.h"
|
||||
#include "time.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
#include "lib/xlcd.h"
|
||||
|
||||
#include "clock.h"
|
||||
|
@ -30,7 +31,7 @@
|
|||
#include "clock_menu.h"
|
||||
#include "clock_settings.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Keymaps */
|
||||
const struct button_mapping* plugin_contexts[]={
|
||||
|
@ -56,9 +57,8 @@ const struct button_mapping* plugin_contexts[]={
|
|||
/**************************
|
||||
* Cleanup on plugin return
|
||||
*************************/
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
clock_draw_restore_colors();
|
||||
if(clock_settings.general.save_settings == 1)
|
||||
save_settings();
|
||||
|
@ -115,6 +115,7 @@ enum plugin_status plugin_start(const void* parameter){
|
|||
struct counter counter;
|
||||
bool exit_clock = false;
|
||||
(void)parameter;
|
||||
atexit(cleanup);
|
||||
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_backdrop(NULL);
|
||||
|
@ -174,9 +175,7 @@ enum plugin_status plugin_start(const void* parameter){
|
|||
exit_clock=main_menu();
|
||||
break;
|
||||
default:
|
||||
if(rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
if(time.second != last_second){
|
||||
last_second=time.second;
|
||||
redraw=true;
|
||||
|
@ -193,6 +192,5 @@ enum plugin_status plugin_start(const void* parameter){
|
|||
}
|
||||
}
|
||||
|
||||
cleanup(NULL);
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "lib/playback_control.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Limits */
|
||||
#define MAX_PIECES_COUNT 5
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static const char* const credits[] = {
|
||||
#include "credits.raw" /* generated list of names from docs/CREDITS */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static void aes_encrypt(void* data, uint32_t size)
|
||||
{
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
***************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "lib/playergfx.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
#if LCD_DEPTH > 1
|
||||
#include "lib/mylcd.h" /* MYLCD_CFG_RB_XLCD or MYLCD_CFG_PGFX */
|
||||
#include "lib/grey.h"
|
||||
|
@ -32,8 +33,6 @@
|
|||
#include "lib/xlcd.h"
|
||||
#include "lib/fixedpoint.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
/* Loops that the values are displayed */
|
||||
#define DISP_TIME 30
|
||||
|
||||
|
@ -611,10 +610,8 @@ static void cube_draw(void)
|
|||
}
|
||||
}
|
||||
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
|
||||
#ifdef USEGSLIB
|
||||
grey_release();
|
||||
#elif defined HAVE_LCD_CHARCELLS
|
||||
|
@ -638,7 +635,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
bool highspeed = false;
|
||||
bool paused = false;
|
||||
bool redraw = true;
|
||||
bool exit = false;
|
||||
bool quit = false;
|
||||
|
||||
(void)(parameter);
|
||||
|
||||
|
@ -651,6 +648,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
rb->splash(HZ, "Couldn't init greyscale display");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
|
||||
/* init lcd_ function pointers */
|
||||
lcdfuncs.update = rb->lcd_update;
|
||||
lcdfuncs.clear_display = rb->lcd_clear_display;
|
||||
|
@ -673,7 +671,8 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
pgfx_display(0, 0);
|
||||
#endif
|
||||
|
||||
while(!exit)
|
||||
atexit(cleanup);
|
||||
while(!quit)
|
||||
{
|
||||
if (redraw)
|
||||
{
|
||||
|
@ -830,24 +829,17 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
case CUBE_RC_QUIT:
|
||||
#endif
|
||||
case CUBE_QUIT:
|
||||
exit = true;
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
if (button != BUTTON_NONE)
|
||||
lastbutton = button;
|
||||
}
|
||||
|
||||
#ifdef USEGSLIB
|
||||
grey_release();
|
||||
#elif defined(HAVE_LCD_CHARCELLS)
|
||||
pgfx_release();
|
||||
#endif
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/helper.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define DEFAULT_WAIT_TIME 3
|
||||
#define DEFAULT_NB_POLYGONS 7
|
||||
|
@ -259,10 +260,8 @@ void polygons_draw(struct polygon_fifo * polygons, struct screen * display)
|
|||
}
|
||||
}
|
||||
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
|
||||
backlight_use_settings();
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
remote_backlight_use_settings();
|
||||
|
@ -394,7 +393,6 @@ int plugin_main(void)
|
|||
switch(action)
|
||||
{
|
||||
case DEMYSTIFY_QUIT:
|
||||
cleanup(NULL);
|
||||
return PLUGIN_OK;
|
||||
|
||||
case DEMYSTIFY_ADD_POLYGON:
|
||||
|
@ -421,9 +419,7 @@ int plugin_main(void)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(action, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -436,6 +432,8 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
int ret;
|
||||
|
||||
(void)parameter;
|
||||
atexit(cleanup);
|
||||
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_backdrop(NULL);
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@ struct dices
|
|||
};
|
||||
|
||||
#define PRINT_BUFFER_LENGTH MAX_DICES*4
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static struct dices dice;
|
||||
static int sides_index;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/simple_viewer.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define MIN_DESC_BUF_SIZE 0x400 /* arbitrary minimum size for description */
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "errno.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* function return values */
|
||||
enum tidy_return
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "st_stuff.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
extern boolean timingdemo, singledemo, demoplayback, fastdemo; // killough
|
||||
|
|
|
@ -45,7 +45,7 @@ To do:
|
|||
- The Irish currency needs 6 digits after the . to have sufficient precision on big number
|
||||
*/
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Name and path of the config file*/
|
||||
static const char cfg_filename[] = "euroconverter.cfg";
|
||||
|
@ -387,10 +387,8 @@ static int euro_menu(void)
|
|||
|
||||
|
||||
/* Call when the program end */
|
||||
static void euro_exit(void *parameter)
|
||||
static void euro_exit(void)
|
||||
{
|
||||
(void)parameter;
|
||||
|
||||
//Restore the old pattern (i don't find another way to do this. An idea?)
|
||||
rb->lcd_unlock_pattern(heuro);
|
||||
rb->lcd_unlock_pattern(hhome);
|
||||
|
@ -411,6 +409,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
/* if you don't use the parameter, you can do like
|
||||
this to avoid the compiler warning about it */
|
||||
(void)parameter;
|
||||
atexit(euro_exit);
|
||||
|
||||
/*Get the pattern handle*/
|
||||
heuro=rb->lcd_get_locked_pattern();
|
||||
|
@ -587,9 +586,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, euro_exit, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
/*Display*/
|
||||
|
@ -599,7 +596,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
e=mydiv(h,currency[country]);
|
||||
display(e,h,pos);
|
||||
}
|
||||
euro_exit(NULL);
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#endif
|
||||
#include "lib/mylcd.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
GREY_INFO_STRUCT
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#define FIRE_XPOS 0
|
||||
#endif
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
#ifndef HAVE_LCD_COLOR
|
||||
GREY_INFO_STRUCT
|
||||
static unsigned char draw_buffer[FIRE_WIDTH];
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "lib/helper.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/***
|
||||
* FIREWORKS.C by ZAKK ROBERTS
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
#error this platform is not (yet) flashable
|
||||
#endif
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if CONFIG_KEYPAD == ONDIO_PAD /* limited keypad */
|
||||
#define KEY1 BUTTON_LEFT
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "fractal_rect.h"
|
||||
#include "fractal_sets.h"
|
||||
#include "mandelbrot_set.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
#ifdef USEGSLIB
|
||||
GREY_INFO_STRUCT
|
||||
|
@ -41,7 +42,7 @@ static size_t gbuf_size = 0;
|
|||
#define REDRAW_FULL 2
|
||||
#define REDRAW_FULL_OVERLAY 3
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* returns 1 if a button has been pressed, 0 otherwise */
|
||||
static int button_yield(void *ctx)
|
||||
|
@ -85,9 +86,8 @@ static int button_yield(void *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
static void cleanup(void *parameter)
|
||||
static void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
#ifdef USEGSLIB
|
||||
grey_release();
|
||||
#endif
|
||||
|
@ -109,11 +109,13 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL))
|
||||
{
|
||||
rb->splash(HZ, "Couldn't init greyscale display");
|
||||
return 0;
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
grey_show(true); /* switch on greyscale overlay */
|
||||
#endif
|
||||
|
||||
/* release greylib on exit */
|
||||
atexit(cleanup);
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_backdrop(NULL);
|
||||
#endif
|
||||
|
@ -161,9 +163,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
case FRACTAL_RC_QUIT:
|
||||
#endif
|
||||
case FRACTAL_QUIT:
|
||||
#ifdef USEGSLIB
|
||||
grey_release();
|
||||
#endif
|
||||
return PLUGIN_OK;
|
||||
|
||||
case FRACTAL_ZOOM_OUT:
|
||||
|
@ -246,18 +245,13 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
|
||||
if (button != BUTTON_NONE)
|
||||
lastbutton = button;
|
||||
}
|
||||
#ifdef USEGSLIB
|
||||
grey_release();
|
||||
#endif
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "lib/pluginlib_exit.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
extern int frotz_main(void);
|
||||
extern bool hot_key_quit(void);
|
||||
|
@ -41,7 +41,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
int i;
|
||||
char* ext;
|
||||
|
||||
PLUGINLIB_EXIT_INIT_ATEXIT(atexit_cleanup);
|
||||
atexit(atexit_cleanup);
|
||||
|
||||
if (!parameter)
|
||||
return PLUGIN_ERROR;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "lib/overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "lib/playback_control.h"
|
||||
#include "lib/configfile.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#include "goban.h"
|
||||
#include "game.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
|
||||
#include "lib/grey.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
@ -316,9 +316,7 @@ int main(void)
|
|||
|
||||
button = rb->button_get(true);
|
||||
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
|
||||
if (button & GREYSCALE_SHIFT)
|
||||
{
|
||||
|
@ -369,8 +367,6 @@ int main(void)
|
|||
case GREYSCALE_RC_OFF:
|
||||
#endif
|
||||
case GREYSCALE_OFF:
|
||||
|
||||
cleanup(NULL);
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
}
|
||||
|
@ -382,6 +378,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
{
|
||||
(void)parameter;
|
||||
|
||||
atexit(cleanup);
|
||||
return main();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
/* This macros must always be included. Should be placed at the top by
|
||||
convention, although the actual position doesn't matter */
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <lib/configfile.h>
|
||||
#include "imageviewer.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifdef USEGSLIB
|
||||
GREY_INFO_STRUCT
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
#define FIRE_WIDTH BMPWIDTH_invadrox_fire
|
||||
#define FIRE_HEIGHT BMPHEIGHT_invadrox_fire
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Original graphics is only 1bpp so it should be portable
|
||||
* to most targets. But for now, only support the simple ones.
|
||||
|
|
|
@ -35,7 +35,7 @@ ssize_t audiobuf_size;
|
|||
|
||||
#ifdef PLATFORM_ID
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if CONFIG_KEYPAD == IRIVER_H100_PAD
|
||||
#define KEY1 BUTTON_OFF
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
ssize_t buf_size;
|
||||
static char *filename;
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/picture.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
const struct button_mapping* plugin_contexts[]={pla_main_ctx};
|
||||
#define NB_PICTURES 9
|
||||
|
@ -109,9 +110,8 @@ void patterns_deinit(struct screen* display)
|
|||
#endif /* HAVE_LCD_CHARCELLS */
|
||||
|
||||
/*Call when the program exit*/
|
||||
void jackpot_exit(void *parameter)
|
||||
void jackpot_exit(void)
|
||||
{
|
||||
(void)parameter;
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
patterns_deinit(rb->screens[SCREEN_MAIN]);
|
||||
#endif /* HAVE_LCD_CHARCELLS */
|
||||
|
@ -298,6 +298,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
int action, i;
|
||||
struct jackpot game;
|
||||
(void)parameter;
|
||||
atexit(jackpot_exit);
|
||||
rb->srand(*rb->current_tick);
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
patterns_init(rb->screens[SCREEN_MAIN]);
|
||||
|
@ -323,12 +324,9 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(action, jackpot_exit, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
jackpot_exit(NULL);
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/playback_control.h"
|
||||
#include "lib/md5.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define KEYBOX_FILE PLUGIN_APPS_DIR "/keybox.dat"
|
||||
#define BLOCK_SIZE 8
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions - only targets with a colour display */
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
|
|
|
@ -2,7 +2,6 @@ gcc-support.c
|
|||
pluginlib_actions.c
|
||||
helper.c
|
||||
md5.c
|
||||
pluginlib_exit.c
|
||||
jhash.c
|
||||
configfile.c
|
||||
fixedpoint.c
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2009 by Maurus Cuelenaere
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include "pluginlib_exit.h"
|
||||
|
||||
jmp_buf __exit_env DATA_ATTR;
|
||||
|
|
@ -22,35 +22,33 @@
|
|||
#ifndef __PLUGINLIB_EXIT_H__
|
||||
#define __PLUGINLIB_EXIT_H__
|
||||
|
||||
#include "config.h"
|
||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||
#include "../../codecs/lib/setjmp.h"
|
||||
#else
|
||||
#include <setjmp.h>
|
||||
/* make sure we are in sync with the real definitions, especially on
|
||||
* hosted systems */
|
||||
#include <stdlib.h>
|
||||
#include "gcc_extensions.h"
|
||||
|
||||
/* these are actually implemented in plugin_crt0.c which all plugins link */
|
||||
extern int atexit(void (*func)(void));
|
||||
extern void exit(int status) NORETURN_ATTR;
|
||||
/* these don't call the exit handlers */
|
||||
extern void _exit(int status) NORETURN_ATTR;
|
||||
/* C99 version */
|
||||
#define _Exit _exit
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
|
||||
#define _PLUGINLIB_EXIT_INIT(atexit) switch(setjmp(__exit_env)) \
|
||||
{ \
|
||||
case 1: \
|
||||
atexit \
|
||||
return PLUGIN_OK; \
|
||||
case 2: \
|
||||
atexit \
|
||||
return PLUGIN_ERROR; \
|
||||
case 0: \
|
||||
default: \
|
||||
break; \
|
||||
}
|
||||
|
||||
/* Either PLUGINLIB_EXIT_INIT or PLUGINLIB_EXIT_INIT_ATEXIT needs to be placed
|
||||
* as the first line in plugin_start. The _ATEXIT version will call the named
|
||||
* no-argument function when exit() is called before exiting the plugin, to
|
||||
* allow for cleanup.
|
||||
/**
|
||||
* helper function to handle USB connected events coming from
|
||||
* button_get()
|
||||
*
|
||||
* it will exit the plugin if usb is detected, but it will call the atexit func
|
||||
* before actually showing the usb screen
|
||||
*
|
||||
* it additionally handles power off as well, with the same behavior
|
||||
*/
|
||||
#define PLUGINLIB_EXIT_INIT _PLUGINLIB_EXIT_INIT()
|
||||
#define PLUGINLIB_EXIT_INIT_ATEXIT(atexit) _PLUGINLIB_EXIT_INIT(atexit();)
|
||||
|
||||
extern jmp_buf __exit_env;
|
||||
#define exit(status) longjmp(__exit_env, status != 0 ? 2 : 1)
|
||||
extern void exit_on_usb(int button);
|
||||
|
||||
#endif /* __PLUGINLIB_EXIT_H__ */
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/playergfx.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#define DISPLAY_WIDTH LCD_WIDTH
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "lib/helper.h"
|
||||
#include <ctype.h>
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define MAX_LINE_LEN 256
|
||||
#define LRC_BUFFER_SIZE 0x3000 /* 12 kiB */
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
#include "lua.h"
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
|
@ -28,7 +27,7 @@
|
|||
#include "rockmalloc.h"
|
||||
#include "luadir.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static const luaL_Reg lualibs[] = {
|
||||
{"", luaopen_base},
|
||||
|
@ -148,8 +147,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
const char* filename;
|
||||
int status;
|
||||
|
||||
PLUGINLIB_EXIT_INIT
|
||||
|
||||
if (parameter == NULL)
|
||||
{
|
||||
rb->splash(HZ, "Play a .lua file!");
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
#include "plugin.h"
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Images */
|
||||
#include "pluginbitmaps/matrix_bold.h"
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* key assignments */
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "lib/playback_control.h"
|
||||
|
||||
/* Include standard plugin macro */
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if (CONFIG_KEYPAD == IPOD_3G_PAD)
|
||||
# define MAZEZAM_MENU BUTTON_MENU
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/md5.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define BUFFERSIZE 16384
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
#if CONFIG_CODEC != SWCODEC
|
||||
/* tick sound from a metronome */
|
||||
|
@ -846,13 +847,14 @@ void timer_callback(void)
|
|||
}
|
||||
}
|
||||
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
|
||||
rb->timer_unregister();
|
||||
MET_PLAY_STOP; /* stop audio ISR */
|
||||
rb->led(0);
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tap(void)
|
||||
|
@ -885,9 +887,9 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
{
|
||||
int button;
|
||||
static int last_button = BUTTON_NONE;
|
||||
enum plugin_status status;
|
||||
|
||||
(void)parameter;
|
||||
atexit(cleanup);
|
||||
|
||||
if (MET_IS_PLAYING)
|
||||
MET_PLAY_STOP; /* stop audio IS */
|
||||
|
@ -927,9 +929,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
|
||||
case METRONOME_QUIT:
|
||||
/* get out of here */
|
||||
cleanup(NULL);
|
||||
status = PLUGIN_OK;
|
||||
goto metronome_exit;
|
||||
return PLUGIN_OK;
|
||||
|
||||
case METRONOME_PAUSE:
|
||||
if(!sound_paused)
|
||||
|
@ -981,12 +981,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
#endif
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
{
|
||||
status = PLUGIN_USB_CONNECTED;
|
||||
goto metronome_exit;
|
||||
}
|
||||
exit_on_usb(button);
|
||||
reset_tap = false;
|
||||
break;
|
||||
|
||||
|
@ -998,11 +993,5 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
}
|
||||
rb->yield();
|
||||
}
|
||||
|
||||
metronome_exit:
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
|
||||
#endif
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "sequencer.h"
|
||||
#include "midifile.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
/* variable button definitions */
|
||||
|
@ -450,7 +450,6 @@ static int midimain(const void * filename)
|
|||
enum plugin_status plugin_start(const void* parameter)
|
||||
{
|
||||
int retval;
|
||||
PLUGINLIB_EXIT_INIT;
|
||||
|
||||
PLUGIN_IRAM_INIT(rb)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* what the minesweeper() function can return */
|
||||
enum minesweeper_status {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "lib/playergfx.h"
|
||||
#include "lib/mylcd.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#define GFX_X (LCD_WIDTH/2-1)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <inttypes.h>
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
#define SAMP_PER_FRAME 1152
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
#include "stream_thread.h"
|
||||
#include "stream_mgr.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
/* button definitions */
|
||||
|
|
|
@ -48,7 +48,7 @@ V1.2 : 2003-07-30
|
|||
take a match. Later you are obliged to take at least one.)
|
||||
*/
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/*Pattern for the game*/
|
||||
static unsigned char smile[]={0x00, 0x11, 0x04, 0x04, 0x00, 0x11, 0x0E}; /* :-) */
|
||||
|
@ -144,6 +144,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
int x,v,min;
|
||||
bool ok;
|
||||
bool go;
|
||||
atexit(nim_exit);
|
||||
|
||||
/* if you don't use the parameter, you can do like
|
||||
this to avoid the compiler warning about it */
|
||||
|
@ -193,7 +194,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
{
|
||||
case BUTTON_STOP|BUTTON_REL:
|
||||
go = true;
|
||||
nim_exit(NULL);
|
||||
return PLUGIN_OK;
|
||||
break;
|
||||
|
||||
|
@ -214,9 +214,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, nim_exit,
|
||||
NULL) == SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
display_first_line(x);
|
||||
|
@ -291,7 +289,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
min=1;
|
||||
}
|
||||
}
|
||||
nim_exit(NULL);
|
||||
return PLUGIN_OK;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,12 +23,13 @@
|
|||
|
||||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "lib/xlcd.h"
|
||||
#include "lib/configfile.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
@ -751,9 +752,8 @@ void anim_vertical(int cur_left, int cur_right)
|
|||
last_pos = cur_y;
|
||||
}
|
||||
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_foreground(LCD_DEFAULT_FG);
|
||||
rb->lcd_set_background(LCD_DEFAULT_BG);
|
||||
|
@ -772,6 +772,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
|
||||
(void)parameter;
|
||||
|
||||
atexit(cleanup);
|
||||
configfile_load(cfg_filename, disk_config,
|
||||
sizeof(disk_config) / sizeof(disk_config[0]),
|
||||
CFGFILE_MINVERSION);
|
||||
|
@ -892,9 +893,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
if (button != BUTTON_NONE)
|
||||
|
@ -908,7 +907,6 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
displaymsg = true;
|
||||
}
|
||||
}
|
||||
cleanup(NULL);
|
||||
if (rb->memcmp(&osc, &osc_disk, sizeof(osc))) /* save settings if changed */
|
||||
{
|
||||
rb->memcpy(&osc_disk, &osc, sizeof(osc));
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "lib/configfile.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
struct pacman_settings {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "PDa/src/s_stuff.h"
|
||||
|
||||
/* Welcome to the PDBox plugin */
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
/* Name of the file to open. */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "pluginbitmaps/pegbox_header.h"
|
||||
#include "pluginbitmaps/pegbox_pieces.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define CONFIG_FILE_NAME "pegbox.cfg"
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "lib/overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <albumart.h>
|
||||
#include "lib/read_image.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/configfile.h"
|
||||
#include "lib/grey.h"
|
||||
|
@ -34,7 +35,7 @@
|
|||
#include "lib/feature_wrappers.h"
|
||||
#include "lib/buflib.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/******************************* Globals ***********************************/
|
||||
|
||||
|
@ -2068,9 +2069,8 @@ void update_scroll_animation(void)
|
|||
/**
|
||||
Cleanup the plugin
|
||||
*/
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void) parameter;
|
||||
int i;
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(false);
|
||||
|
@ -2610,19 +2610,6 @@ int main(void)
|
|||
cache_version = CACHE_VERSION;
|
||||
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||
|
||||
|
||||
#ifdef USEGSLIB
|
||||
long grey_buf_used;
|
||||
if (!grey_init(buf, buf_size, GREY_BUFFERED|GREY_ON_COP,
|
||||
LCD_WIDTH, LCD_HEIGHT, &grey_buf_used))
|
||||
{
|
||||
error_wait("Greylib init failed!");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
grey_setfont(FONT_UI);
|
||||
buf_size -= grey_buf_used;
|
||||
buf = (void*)(grey_buf_used + (char*)buf);
|
||||
#endif
|
||||
buflib_init(&buf_ctx, (void *)buf, buf_size);
|
||||
|
||||
if (!(empty_slide_hid = read_pfraw(EMPTY_SLIDE, 0)))
|
||||
|
@ -2841,9 +2828,7 @@ int main(void)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if (rb->default_event_handler_ex(button, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2855,6 +2840,7 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
{
|
||||
int ret, i;
|
||||
(void) parameter;
|
||||
atexit(cleanup);
|
||||
|
||||
FOR_NB_SCREENS(i)
|
||||
rb->viewportmanager_theme_enable(i, false, NULL);
|
||||
|
@ -2873,6 +2859,21 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USEGSLIB
|
||||
long grey_buf_used;
|
||||
if (!grey_init(buf, buf_size, GREY_BUFFERED|GREY_ON_COP,
|
||||
LCD_WIDTH, LCD_HEIGHT, &grey_buf_used))
|
||||
{
|
||||
error_wait("Greylib init failed!");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
grey_setfont(FONT_UI);
|
||||
buf_size -= grey_buf_used;
|
||||
buf = (void*)(grey_buf_used + (char*)buf);
|
||||
#endif
|
||||
|
||||
atexit(cleanup);
|
||||
ret = main();
|
||||
if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) {
|
||||
if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS,
|
||||
|
@ -2882,7 +2883,5 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
ret = PLUGIN_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup(NULL);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
#include "lib/helper.h"
|
||||
#include "pluginbitmaps/pitch_notes.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
/* Some fixed point calculation stuff */
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/pluginlib_exit.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
||||
|
@ -35,7 +36,6 @@
|
|||
#endif
|
||||
#include "lib/fixedpoint.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
/******************************* Globals ***********************************/
|
||||
|
||||
|
@ -131,10 +131,8 @@ static void shades_generate(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void cleanup(void *parameter)
|
||||
void cleanup(void)
|
||||
{
|
||||
(void)parameter;
|
||||
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
if (boosted)
|
||||
rb->cpu_boost(false);
|
||||
|
@ -144,6 +142,9 @@ void cleanup(void *parameter)
|
|||
#endif
|
||||
/* Turn on backlight timeout (revert to settings) */
|
||||
backlight_use_settings(); /* backlight control in lib/helper.c */
|
||||
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
||||
rb->lcd_set_mode(LCD_MODE_RGB565);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -180,10 +181,15 @@ int main(void)
|
|||
/* get the remainder of the plugin buffer */
|
||||
gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size);
|
||||
|
||||
grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL);
|
||||
if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL))
|
||||
{
|
||||
rb->splash(HZ, "Couldn't init greyscale display");
|
||||
return PLUGIN_ERROR;
|
||||
}
|
||||
/* switch on greyscale overlay */
|
||||
grey_show(true);
|
||||
#endif
|
||||
atexit(cleanup);
|
||||
sp1 = 4;
|
||||
sp2 = 2;
|
||||
sp3 = 4;
|
||||
|
@ -261,7 +267,6 @@ int main(void)
|
|||
{
|
||||
case PLA_EXIT:
|
||||
case PLA_CANCEL:
|
||||
cleanup(NULL);
|
||||
return PLUGIN_OK;
|
||||
break;
|
||||
|
||||
|
@ -299,9 +304,7 @@ int main(void)
|
|||
#endif
|
||||
|
||||
default:
|
||||
if (rb->default_event_handler_ex(action, cleanup, NULL)
|
||||
== SYS_USB_CONNECTED)
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
exit_on_usb(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -311,8 +314,6 @@ int main(void)
|
|||
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
{
|
||||
int ret;
|
||||
|
||||
(void)parameter;
|
||||
#if LCD_DEPTH > 1
|
||||
rb->lcd_set_backdrop(NULL);
|
||||
|
@ -323,14 +324,7 @@ enum plugin_status plugin_start(const void* parameter)
|
|||
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
||||
rb->lcd_set_mode(LCD_MODE_PAL256);
|
||||
#endif
|
||||
|
||||
ret = main();
|
||||
|
||||
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_PAL256)
|
||||
rb->lcd_set_mode(LCD_MODE_RGB565);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
return main();
|
||||
}
|
||||
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
|
116
apps/plugins/plugin_crt0.c
Executable file
116
apps/plugins/plugin_crt0.c
Executable file
|
@ -0,0 +1,116 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2010 by Thomas Martitz
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#include "plugin.h"
|
||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||
#include "../codecs/lib/setjmp.h"
|
||||
#else
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
/*
|
||||
* EXIT_MAGIC magic, because 0 cannot be used due to setjmp()
|
||||
* must be > 0
|
||||
*/
|
||||
#define EXIT_MAGIC 0x0CDEBABE
|
||||
|
||||
extern enum plugin_status plugin_start(const void*);
|
||||
|
||||
static jmp_buf __exit_env;
|
||||
/* only 1 atexit handler for now, chain in the exit handler if you need more */
|
||||
static void (*atexit_handler)(void);
|
||||
|
||||
int atexit(void (*fn)(void))
|
||||
{
|
||||
if (atexit_handler)
|
||||
return -1;
|
||||
atexit_handler = fn;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit(int status)
|
||||
{ /* jump back in time to before starting the plugin */
|
||||
longjmp(__exit_env, status != 0 ? status : EXIT_MAGIC);
|
||||
}
|
||||
|
||||
void _exit(int status)
|
||||
{ /* don't call exit handler */
|
||||
atexit_handler = NULL;
|
||||
exit(status);
|
||||
}
|
||||
|
||||
enum plugin_status plugin__start(const void *param)
|
||||
{
|
||||
int exit_ret;
|
||||
enum plugin_status ret;
|
||||
|
||||
/* we come back here if exit() was called or the plugin returned normally */
|
||||
exit_ret = setjmp(__exit_env);
|
||||
if (exit_ret == 0)
|
||||
{ /* start the plugin */
|
||||
ret = plugin_start(param);
|
||||
}
|
||||
else
|
||||
{ /* plugin exit via exit() */
|
||||
if (exit_ret == EXIT_MAGIC)
|
||||
{ /* exit(EXIT_SUCCESS) */
|
||||
ret = PLUGIN_OK;
|
||||
}
|
||||
else if (exit_ret < INTERNAL_PLUGIN_RETVAL_START)
|
||||
{ /* exit(EXIT_FAILURE) */
|
||||
ret = PLUGIN_ERROR;
|
||||
}
|
||||
else
|
||||
{ /* exit(PLUGIN_XXX) */
|
||||
ret = (enum plugin_status)exit_ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* before finishing, call the exit handler if there was one */
|
||||
if (atexit_handler != NULL)
|
||||
atexit_handler();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void cleanup_wrapper(void *param)
|
||||
{
|
||||
(void)param;
|
||||
if (atexit_handler)
|
||||
atexit_handler();
|
||||
}
|
||||
|
||||
void exit_on_usb(int button)
|
||||
{ /* the default handler will call the exit handler before
|
||||
* showing the usb screen; after that we don't want the exit handler
|
||||
* to be called a second time, hence _exit()
|
||||
*
|
||||
* if not usb, then the handler will only be called if powering off
|
||||
* if poweroff, the plugin doesn't want to run any further so exit as well*/
|
||||
long result = rb->default_event_handler_ex(button, cleanup_wrapper, NULL);
|
||||
if (result == SYS_USB_CONNECTED)
|
||||
_exit(PLUGIN_USB_CONNECTED);
|
||||
else if (result == SYS_POWEROFF)
|
||||
_exit(PLUGIN_POWEROFF);
|
||||
}
|
|
@ -33,7 +33,7 @@ PLUGIN_LDS := $(APPSDIR)/plugins/plugin.lds
|
|||
PLUGINLINK_LDS := $(BUILDDIR)/apps/plugins/plugin.link
|
||||
OVERLAYREF_LDS := $(BUILDDIR)/apps/plugins/overlay_ref.link
|
||||
endif
|
||||
|
||||
PLUGIN_CRT0 := $(BUILDDIR)/apps/plugins/plugin_crt0.o
|
||||
# multifile plugins (subdirs):
|
||||
PLUGINSUBDIRS := $(call preprocess, $(APPSDIR)/plugins/SUBDIRS)
|
||||
|
||||
|
@ -49,7 +49,7 @@ PLUGINFLAGS = -I$(APPSDIR)/plugins -DPLUGIN $(CFLAGS)
|
|||
$(ROCKS1): $(BUILDDIR)/%.rock: $(BUILDDIR)/%.o
|
||||
|
||||
# dependency for all plugins
|
||||
$(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB)
|
||||
$(ROCKS): $(APPSDIR)/plugin.h $(PLUGINLINK_LDS) $(PLUGINLIB) $(PLUGINBITMAPLIB) $(PLUGIN_CRT0)
|
||||
|
||||
$(PLUGINLIB): $(PLUGINLIB_OBJ)
|
||||
$(SILENT)$(shell rm -f $@)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define PAD_HEIGHT LCD_HEIGHT / 6 /* Recorder: 10 iRiver: 21 */
|
||||
#define PAD_WIDTH LCD_WIDTH / 50 /* Recorder: 2 iRiver: 2 */
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#if defined(HAVE_LCD_COLOR)
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* Magic constants. */
|
||||
#define PPM_MAGIC1 'P'
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
bool its_a_dir = false;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "file.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
static bool cancel;
|
||||
static int fd;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "lib/pluginlib_actions.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define PLUGIN_CONTINUE 10
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ further options:
|
|||
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* This is initialized at the start of the plugin and used to determine the
|
||||
* Appropriate game board size/legend spacing if the font is larger than a cell
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
/* This macros must always be included. Should be placed at the top by
|
||||
convention, although the actual position doesn't matter */
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/*Be sure to change MESSAGES when you change the array, or bad things
|
||||
will happen.*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "lib/playergfx.h"
|
||||
#include "lib/mylcd.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
||||
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
#if (CONFIG_CPU == SH7034) /* Only for SH targets */
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* define DUMMY if you only want to "play" with the UI, does no harm */
|
||||
/* #define DUMMY */
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "lib/overlay.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* this is the plugin entry point */
|
||||
enum plugin_status plugin_start(const void* parameter)
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "hw.h"
|
||||
#include "pcm.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
PLUGIN_IRAM_DECLARE
|
||||
|
||||
int shut,cleanshut;
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#include "lib/pluginlib_actions.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define ROCKLIFE_PLAY_PAUSE PLA_SELECT
|
||||
#define ROCKLIFE_INIT PLA_DOWN
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "lib/rgb_hsv.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Buttons
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "plugin.h"
|
||||
#include <ctype.h>
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define BUFFER_SIZE 16384
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "token.h"
|
||||
#include "dbinterface.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
void *audio_bufferbase;
|
||||
void *audio_bufferpointer;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define FILENAME "/settings_dumper.txt"
|
||||
static int setting_count = 0;
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define MAX_LIST_SIZE 400
|
||||
#define DESC_SIZE 40
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "shortcuts.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
|
||||
bool append_entry_to_file(sc_file_t *file, char *path, bool is_dir)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "shortcuts.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
enum sc_list_action_type
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "plugin.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -38,7 +38,7 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
|
|||
#include "lib/highscore.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
/* variable button definitions */
|
||||
#if CONFIG_KEYPAD == RECORDER_PAD
|
||||
|
|
|
@ -34,7 +34,7 @@ Head and Tail are stored
|
|||
#include "lib/highscore.h"
|
||||
#include "lib/playback_control.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#define WIDTH 28
|
||||
#define HEIGHT 16
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "lib/playergfx.h"
|
||||
#include "lib/mylcd.h"
|
||||
|
||||
PLUGIN_HEADER
|
||||
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#define NUM_PARTICLES (LCD_WIDTH * LCD_HEIGHT / 72)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue