Update ipc interface, some functions are not static in the PluginLoader

This commit is contained in:
Maschell 2019-11-16 15:04:04 +01:00
parent 82f5f6eb05
commit 73640c01f5
2 changed files with 46 additions and 54 deletions

View File

@ -68,7 +68,7 @@ public:
\return a list of PluginInformation objects, one for each valid plugin. \return a list of PluginInformation objects, one for each valid plugin.
**/ **/
std::vector<PluginInformation *> getPluginInformation(const char * path); static std::vector<PluginInformation *> getPluginInformation(const char * path);
/** /**
\brief Gets plugin information from the global struct. \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 \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. plugin which are still on the sd card.
**/ **/
std::vector<PluginInformation *> getPluginsLoadedInMemory(); static std::vector<PluginInformation *> getPluginsLoadedInMemory();
/** /**
\brief Takes a list of plugins that should be linked (relocated) loaded into the memory. \brief Takes a list of plugins that should be linked (relocated) loaded into the memory.

View File

@ -2,6 +2,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "ipc.h" #include "ipc.h"
#include "common/retain_vars.h"
extern void RestoreEverything(); extern void RestoreEverything();
extern void afterLoadAndLink(); extern void afterLoadAndLink();
@ -53,12 +54,11 @@ int ipc_ioctl(ipcmessage *message) {
} }
case IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH: { case IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH: {
DEBUG_FUNCTION_LINE("IOCTL_PLUGIN_LOADER_GET_INFORMATION_FOR_PATH\n"); 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"); DEBUG_FUNCTION_LINE("IPC_ERROR_INVALID_SIZE\n");
res = IPC_ERROR_INVALID_SIZE; res = IPC_ERROR_INVALID_SIZE;
} else { } else {
void * ptr = (void *) message->ioctl.buffer_in[0]; char * path = (char *) message->ioctl.buffer_in[0];
char * path = (char *) message->ioctl.buffer_in[1];
uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io; uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io;
plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]); plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]);
uint32_t lengthIo = message->ioctl.length_io - 4; 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); //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<PluginLoader*>(ptr))*/) { std::vector<PluginInformation *> pluginList = PluginLoader::getPluginInformation(path);
PluginLoader* pluginLoader = (PluginLoader * )ptr; uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle);
std::vector<PluginInformation *> pluginList = pluginLoader->getPluginInformation(path);
uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle);
//DEBUG_FUNCTION_LINE("pluginInfoSpace %d\n", pluginInfoSpace); //DEBUG_FUNCTION_LINE("pluginInfoSpace %d\n", pluginInfoSpace);
uint32_t cur = 0; uint32_t cur = 0;
for (std::vector<PluginInformation *>::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { for (std::vector<PluginInformation *>::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) {
PluginInformation * curPlugin = *it; PluginInformation * curPlugin = *it;
DEBUG_FUNCTION_LINE("cur %d filledCount %d curPlugin %08X\n", cur, *filledCount,curPlugin); //DEBUG_FUNCTION_LINE("cur %d filledCount %d curPlugin %08X\n", cur, *filledCount,curPlugin);
if(cur >= pluginInfoSpace) { if(cur >= pluginInfoSpace) {
DEBUG_FUNCTION_LINE("deleted plugins because they don't fit in buffer..\n"); //DEBUG_FUNCTION_LINE("deleted plugins because they don't fit in buffer..\n");
// delete all that don't fit into the target list. // delete all that don't fit into the target list.
delete curPlugin; delete curPlugin;
continue; continue;
}
io_handles[cur] = (plugin_information_handle) curPlugin;
DEBUG_FUNCTION_LINE("%08X = %08X\n", &(io_handles[cur]), io_handles[cur]);
cur++;
(*filledCount)++;
} }
io_handles[cur] = (plugin_information_handle) curPlugin;
DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io); //DEBUG_FUNCTION_LINE("%08X = %08X\n", &(io_handles[cur]), io_handles[cur]);
ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io); cur++;
} else { (*filledCount)++;
res = IPC_ERROR_INVALID_ARG;
} }
DCFlushRange(message->ioctl.buffer_io,message->ioctl.length_io);
ICInvalidateRange(message->ioctl.buffer_io,message->ioctl.length_io);
} }
break; break;
} }
case IOCTL_PLUGIN_LOADER_GET_INFORMATION_LOADED: { 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; res = IPC_ERROR_INVALID_SIZE;
} else { } else {
void * ptr = (void *) message->ioctl.buffer_in[0];
uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io; uint32_t * filledCount = (uint32_t *)message->ioctl.buffer_io;
plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]); plugin_information_handle * io_handles = (plugin_information_handle *) &(message->ioctl.buffer_io[1]);
uint32_t lengthIo = message->ioctl.length_io - 4; uint32_t lengthIo = message->ioctl.length_io - 4;
*filledCount = 0; *filledCount = 0;
if(ptr != NULL) { std::vector<PluginInformation *> pluginList = PluginLoader::getPluginsLoadedInMemory();
PluginLoader* pluginLoader = (PluginLoader * )ptr; uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle);
std::vector<PluginInformation *> pluginList = pluginLoader->getPluginsLoadedInMemory();
uint32_t pluginInfoSpace = lengthIo / sizeof(plugin_information_handle);
uint32_t cur = 0; uint32_t cur = 0;
if(pluginInfoSpace > 0) { if(pluginInfoSpace > 0) {
for (std::vector<PluginInformation *>::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) { for (std::vector<PluginInformation *>::iterator it = pluginList.begin() ; it != pluginList.end(); ++it) {
PluginInformation * curPlugin = *it; PluginInformation * curPlugin = *it;
if(cur >= pluginInfoSpace) { if(cur >= pluginInfoSpace) {
// delete all that don't fit into the target list. // delete all that don't fit into the target list.
delete curPlugin; delete curPlugin;
continue; continue;
}
io_handles[cur] = (plugin_information_handle) curPlugin;
cur++;
(*filledCount)++;
} }
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; break;
} }
@ -175,9 +165,12 @@ int ipc_ioctl(ipcmessage *message) {
if(message->ioctl.length_io < plugin_information_handle_list_size * sizeof(plugin_information)) { if(message->ioctl.length_io < plugin_information_handle_list_size * sizeof(plugin_information)) {
res = IPC_ERROR_INVALID_SIZE; res = IPC_ERROR_INVALID_SIZE;
} else { } 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++ ) { for(uint32_t i = 0; i < plugin_information_handle_list_size; i++ ) {
PluginInformation* curHandle = (PluginInformation * )plugin_information_handle_list[i]; PluginInformation* curHandle = (PluginInformation * )plugin_information_handle_list[i];
if(curHandle == NULL){
continue;
}
plugin_information_list[i].handle = plugin_information_handle_list[i]; 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].path, curHandle->getPath().c_str(),255);
strncpy(plugin_information_list[i].name, curHandle->getName().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()); //DEBUG_FUNCTION_LINE("willBeLoaded size is %d\n",willBeLoaded.size());
//if(willBeLoaded.size() > 0){
RestoreEverything(); RestoreEverything();
pluginLoader->loadAndLinkPlugins(willBeLoaded); pluginLoader->loadAndLinkPlugins(willBeLoaded);
afterLoadAndLink(); afterLoadAndLink();
//}
*linkedCount = willBeLoaded.size(); *linkedCount = willBeLoaded.size();
} else { } else {