diff options
| author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-01-16 10:34:40 +0000 |
|---|---|---|
| committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-01-16 10:34:40 +0000 |
| commit | 23d9812273d9c74af72ccdc3aa4cfea971f220a4 (patch) | |
| tree | 8e60c3a2a41879f8b2a52516fa416b3ab906e239 /apps/plugin.h | |
| parent | 35677cbc54bbe400ebbff59b489dda7ca7f04916 (diff) | |
| download | rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.zip rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.gz rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.bz2 rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.xz | |
loader-initialized global plugin API:
struct plugin_api *rb is declared in PLUGIN_HEADER, and pointed to by
__header.api
the loader uses this pointer to initialize rb before calling entry_point
entry_point is no longer passed a pointer to the plugin API
all plugins, and pluginlib functions, are modified to refer to the
global rb
pluginlib functions which only served to copy the API pointer are
removed
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19776 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugin.h')
| -rw-r--r-- | apps/plugin.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/apps/plugin.h b/apps/plugin.h index 7bb1c7f..992012b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -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 136 +#define PLUGIN_API_VERSION 137 /* 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 136 +#define PLUGIN_MIN_API_VERSION 137 /* plugin return codes */ enum plugin_status { @@ -791,7 +791,8 @@ struct plugin_header { unsigned short api_version; unsigned char *load_addr; unsigned char *end_addr; - enum plugin_status(*entry_point)(const struct plugin_api*, const void*); + enum plugin_status(*entry_point)(const void*); + const struct plugin_api **api; }; #ifdef PLUGIN @@ -799,16 +800,18 @@ struct plugin_header { extern unsigned char plugin_start_addr[]; extern unsigned char plugin_end_addr[]; #define PLUGIN_HEADER \ + const struct plugin_api *rb __attribute__ ((section (".data"))); \ const struct plugin_header __header \ __attribute__ ((section (".header")))= { \ PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ - plugin_start_addr, plugin_end_addr, plugin_start }; + plugin_start_addr, plugin_end_addr, plugin_start, &rb }; #else /* SIMULATOR */ #define PLUGIN_HEADER \ + const struct plugin_api *rb __attribute__ ((section (".data"))); \ const struct plugin_header __header \ __attribute__((visibility("default"))) = { \ PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ - NULL, NULL, plugin_start }; + NULL, NULL, plugin_start, &rb }; #endif /* SIMULATOR */ #ifdef PLUGIN_USE_IRAM @@ -842,46 +845,44 @@ void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size, void plugin_tsr(bool (*exit_callback)(bool reenter)); /* defined by the plugin */ -enum plugin_status plugin_start(const struct plugin_api* rockbox, const void* parameter) +extern const struct plugin_api *rb; +enum plugin_status plugin_start(const void* parameter) NO_PROF_ATTR; /* Use this macro in plugins where gcc tries to optimize by calling * these functions directly */ -#define MEM_FUNCTION_WRAPPERS(api) \ +#define MEM_FUNCTION_WRAPPERS \ void *memcpy(void *dest, const void *src, size_t n) \ { \ - return (api)->memcpy(dest, src, n); \ + return rb->memcpy(dest, src, n); \ } \ void *memset(void *dest, int c, size_t n) \ { \ - return (api)->memset(dest, c, n); \ + return rb->memset(dest, c, n); \ } \ void *memmove(void *dest, const void *src, size_t n) \ { \ - return (api)->memmove(dest, src, n); \ + return rb->memmove(dest, src, n); \ } \ int memcmp(const void *s1, const void *s2, size_t n) \ { \ - return (api)->memcmp(s1, s2, n); \ + return rb->memcmp(s1, s2, n); \ } -#ifndef CACHE_FUNCTION_WRAPPERS - +#undef CACHE_FUNCTION_WRAPPERS #ifdef CACHE_FUNCTIONS_AS_CALL -#define CACHE_FUNCTION_WRAPPERS(api) \ +#define CACHE_FUNCTION_WRAPPERS \ void flush_icache(void) \ { \ - (api)->flush_icache(); \ + rb->flush_icache(); \ } \ void invalidate_icache(void) \ { \ - (api)->invalidate_icache(); \ + rb->invalidate_icache(); \ } #else -#define CACHE_FUNCTION_WRAPPERS(api) +#define CACHE_FUNCTION_WRAPPERS #endif /* CACHE_FUNCTIONS_AS_CALL */ -#endif /* CACHE_FUNCTION_WRAPPERS */ - #endif /* __PCTOOL__ */ #endif |