diff --git a/src/plugin/PluginLoader.h b/src/plugin/PluginLoader.h index b15b5fa..ff03985 100644 --- a/src/plugin/PluginLoader.h +++ b/src/plugin/PluginLoader.h @@ -68,7 +68,7 @@ public: \return a list of PluginInformation objects, one for each valid plugin. **/ - std::vector getPluginInformation(const char * path); + static std::vector getPluginInformation(const char * path); /** \brief Gets plugin information from the global struct. @@ -76,7 +76,7 @@ public: \return a list of MetaInformation objects for all plugins currently loaded and linked (relocated). Will only contain plugin which are still on the sd card. **/ - std::vector getPluginsLoadedInMemory(); + static std::vector getPluginsLoadedInMemory(); /** \brief Takes a list of plugins that should be linked (relocated) loaded into the memory. diff --git a/src/utils/ipc.cpp b/src/utils/ipc.cpp index aaac6e9..5b150bc 100644 --- a/src/utils/ipc.cpp +++ b/src/utils/ipc.cpp @@ -2,6 +2,7 @@ #include #include #include "ipc.h" +#include "common/retain_vars.h" extern void RestoreEverything(); extern void afterLoadAndLink(); @@ -53,12 +54,11 @@ int ipc_ioctl(ipcmessage *message) { } case IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH: { DEBUG_FUNCTION_LINE("IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH\n"); - if(message->ioctl.length_in != 8 || message->ioctl.length_io < 4) { + if(message->ioctl.length_in != 4 || message->ioctl.length_io < 4) { DEBUG_FUNCTION_LINE("IPC_ERROR_INVALID_SIZE\n"); res = IPC_ERROR_INVALID_SIZE; } else { - void * ptr = (void *) message->ioctl.buffer_in[0]; - char * path = (char *) message->ioctl.buffer_in[1]; + char * path = (char *) message->ioctl.buffer_in[0]; uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io; plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]); uint32_t lengthIo = message->ioctl.length_io - 4; @@ -67,76 +67,66 @@ int ipc_ioctl(ipcmessage *message) { //DEBUG_FUNCTION_LINE("path %08X %s, filledcount_ptr %08X io_handles%08X lengthio%d\n", path,path, filledCount,io_handles,lengthIo); - if(ptr != NULL && path != NULL/* && (PluginLoader* pluginLoader = dynamic_cast(ptr))*/) { - PluginLoader* pluginLoader = (PluginLoader * )ptr; - std::vector pluginList = pluginLoader->getPluginInformation(path); - uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle); + std::vector pluginList = PluginLoader::getPluginInformation(path); + uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle); //DEBUG_FUNCTION_LINE("pluginInfoSpace %d\n", pluginInfoSpace); - uint32_t cur = 0; + uint32_t cur = 0; - for (std::vector::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { + for (std::vector::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { - PluginInformation * curPlugin = *it; - DEBUG_FUNCTION_LINE("cur %d filledCount %d curPlugin %08X\n", cur, *filledCount,curPlugin); - if(cur >= pluginInfoSpace) { - DEBUG_FUNCTION_LINE("deleted plugins because they don't fit in buffer..\n"); - // delete all that don't fit into the target list. - delete curPlugin; - continue; - } - io_handles[cur] = (plugin_information_handle) curPlugin; - DEBUG_FUNCTION_LINE("%08X = %08X\n", &(io_handles[cur]), io_handles[cur]); - cur++; - (*filledCount)++; + PluginInformation * curPlugin = *it; + //DEBUG_FUNCTION_LINE("cur %d filledCount %d curPlugin %08X\n", cur, *filledCount,curPlugin); + if(cur >= pluginInfoSpace) { + //DEBUG_FUNCTION_LINE("deleted plugins because they don't fit in buffer..\n"); + // delete all that don't fit into the target list. + delete curPlugin; + continue; } - - DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io); - ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io); - } else { - res = IPC_ERROR_INVALID_ARG; + io_handles[cur] = (plugin_information_handle) curPlugin; + //DEBUG_FUNCTION_LINE("%08X = %08X\n", &(io_handles[cur]), io_handles[cur]); + cur++; + (*filledCount)++; } + + DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io); + ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io); + } break; } - case IOCTL_PLUGIN_LOADER_GET_INFORMATION_LOADED: { - if(message->ioctl.length_in != 4 || message->ioctl.length_io < 4) { + if(message->ioctl.length_in != 0 || message->ioctl.length_io < 4) { res = IPC_ERROR_INVALID_SIZE; } else { - void * ptr = (void *) message->ioctl.buffer_in[0]; uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io; plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]); uint32_t lengthIo = message->ioctl.length_io - 4; *filledCount = 0; - if(ptr != NULL) { - PluginLoader* pluginLoader = (PluginLoader * )ptr; - std::vector pluginList = pluginLoader->getPluginsLoadedInMemory(); - uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle); + std::vector pluginList = PluginLoader::getPluginsLoadedInMemory(); + uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle); - uint32_t cur = 0; + uint32_t cur = 0; - if(pluginInfoSpace > 0) { - for (std::vector::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { - PluginInformation * curPlugin = *it; - if(cur >= pluginInfoSpace) { - // delete all that don't fit into the target list. - delete curPlugin; - continue; - } - io_handles[cur] = (plugin_information_handle) curPlugin; - cur++; - (*filledCount)++; + if(pluginInfoSpace > 0) { + for (std::vector::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { + PluginInformation * curPlugin = *it; + if(cur >= pluginInfoSpace) { + // delete all that don't fit into the target list. + delete curPlugin; + continue; } + io_handles[cur] = (plugin_information_handle) curPlugin; + cur++; + (*filledCount)++; } - DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io); - ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io); - } else { - res = IPC_ERROR_INVALID_ARG; } + DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io); + ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io); + } break; } @@ -175,9 +165,12 @@ int ipc_ioctl(ipcmessage *message) { if(message->ioctl.length_io < plugin_information_handle_list_size * sizeof(plugin_information)) { res = IPC_ERROR_INVALID_SIZE; } else { - if(plugin_information_handle_list != NULL && plugin_information_handle_list != NULL) { + if(plugin_information_handle_list != NULL && plugin_information_handle_list_size != 0) { for(uint32_t i = 0; i < plugin_information_handle_list_size; i++ ) { PluginInformation* curHandle = (PluginInformation * )plugin_information_handle_list[i]; + if(curHandle == NULL){ + continue; + } plugin_information_list[i].handle = plugin_information_handle_list[i]; strncpy(plugin_information_list[i].path, curHandle->getPath().c_str(),255); strncpy(plugin_information_list[i].name, curHandle->getName().c_str(),255); @@ -221,11 +214,10 @@ int ipc_ioctl(ipcmessage *message) { //DEBUG_FUNCTION_LINE("willBeLoaded size is %d\n",willBeLoaded.size()); - //if(willBeLoaded.size() > 0){ RestoreEverything(); pluginLoader->loadAndLinkPlugins(willBeLoaded); afterLoadAndLink(); - //} + *linkedCount = willBeLoaded.size(); } else {