summaryrefslogtreecommitdiff
path: root/apps/plugin.h
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-23 16:56:49 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-23 16:56:49 +0000
commitabdc5935beb7dc3fa63bffeec584921ad2a4c8bd (patch)
tree3eb3ca86063d0fff58ca8ed2c49dbb0af0792570 /apps/plugin.h
parent8106c9dc646bbb26131896eb12d23edb26cba476 (diff)
downloadrockbox-abdc5935beb7dc3fa63bffeec584921ad2a4c8bd.tar.gz
rockbox-abdc5935beb7dc3fa63bffeec584921ad2a4c8bd.zip
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
Diffstat (limited to 'apps/plugin.h')
-rw-r--r--apps/plugin.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 624b7039b8..cb6cc83089 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -155,9 +155,13 @@ void* plugin_get_buffer(size_t *buffer_size);
155#define PLUGIN_MIN_API_VERSION 190 155#define PLUGIN_MIN_API_VERSION 190
156 156
157/* plugin return codes */ 157/* plugin return codes */
158/* internal returns start at 0x100 to make exit(1..255) work */
159#define INTERNAL_PLUGIN_RETVAL_START 0x100
158enum plugin_status { 160enum plugin_status {
159 PLUGIN_OK = 0, 161 PLUGIN_OK = 0, /* PLUGIN_OK == EXIT_SUCCESS */
160 PLUGIN_USB_CONNECTED, 162 /* 1...255 reserved for exit() */
163 PLUGIN_USB_CONNECTED = INTERNAL_PLUGIN_RETVAL_START,
164 PLUGIN_POWEROFF,
161 PLUGIN_GOTO_WPS, 165 PLUGIN_GOTO_WPS,
162 PLUGIN_ERROR = -1, 166 PLUGIN_ERROR = -1,
163}; 167};
@@ -912,14 +916,14 @@ extern unsigned char plugin_end_addr[];
912 const struct plugin_header __header \ 916 const struct plugin_header __header \
913 __attribute__ ((section (".header")))= { \ 917 __attribute__ ((section (".header")))= { \
914 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ 918 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
915 plugin_start_addr, plugin_end_addr, plugin_start, &rb }; 919 plugin_start_addr, plugin_end_addr, plugin__start, &rb };
916#else /* PLATFORM_HOSTED */ 920#else /* PLATFORM_HOSTED */
917#define PLUGIN_HEADER \ 921#define PLUGIN_HEADER \
918 const struct plugin_api *rb DATA_ATTR; \ 922 const struct plugin_api *rb DATA_ATTR; \
919 const struct plugin_header __header \ 923 const struct plugin_header __header \
920 __attribute__((visibility("default"))) = { \ 924 __attribute__((visibility("default"))) = { \
921 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ 925 PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \
922 NULL, NULL, plugin_start, &rb }; 926 NULL, NULL, plugin__start, &rb };
923#endif /* CONFIG_PLATFORM */ 927#endif /* CONFIG_PLATFORM */
924 928
925#ifdef PLUGIN_USE_IRAM 929#ifdef PLUGIN_USE_IRAM
@@ -954,7 +958,7 @@ void plugin_tsr(bool (*exit_callback)(bool reenter));
954 958
955/* defined by the plugin */ 959/* defined by the plugin */
956extern const struct plugin_api *rb; 960extern const struct plugin_api *rb;
957enum plugin_status plugin_start(const void* parameter) 961enum plugin_status plugin__start(const void* parameter)
958 NO_PROF_ATTR; 962 NO_PROF_ATTR;
959 963
960#endif /* __PCTOOL__ */ 964#endif /* __PCTOOL__ */