diff options
| author | Josh Rahm <rahm@google.com> | 2024-02-13 17:53:30 -0700 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2024-02-13 17:54:04 -0700 |
| commit | 10a5272eaca6407982b3707027ea8704f3484377 (patch) | |
| tree | 413ebfa9cffe703e596d33d7fd5e06249d7af477 /harness/include/plugin.h | |
| parent | d065af8c16bcb8ef54024c0f2082d827f83f37f9 (diff) | |
| download | montis-10a5272eaca6407982b3707027ea8704f3484377.tar.gz montis-10a5272eaca6407982b3707027ea8704f3484377.tar.bz2 montis-10a5272eaca6407982b3707027ea8704f3484377.zip | |
WIP: Working on the foreign interface.
Diffstat (limited to 'harness/include/plugin.h')
| -rw-r--r-- | harness/include/plugin.h | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/harness/include/plugin.h b/harness/include/plugin.h index 615c3db..db56845 100644 --- a/harness/include/plugin.h +++ b/harness/include/plugin.h @@ -2,8 +2,12 @@ #define _PLUGIN_H_ #include <dlfcn.h> +#include <linux/limits.h> #include <pthread.h> #include <stdint.h> +#include <stdlib.h> + +#include "foreign_intf.h" /* * Marker macro to define what functions should be exported. This generates the @@ -17,10 +21,29 @@ typedef void *dlhandle_t; * really can be.) */ typedef void *opqst_t; +struct PLUGIN; +/* This structure represents an action requested by the plugin for the harness. + */ +typedef struct { + int (*action)(struct PLUGIN *requester); +} requested_action_t; + /* * Structure for the plugin. */ typedef struct PLUGIN { + /* The argc this plugin is loaded with. Typically the argc from main(). */ + int argc; + + /* The argv this plugin is loaded with. Typically the argv from main(). */ + char **argv; + + /* Filename the plugin is loaded from. */ + char filename[PATH_MAX]; + + /* Interface to the harness that this plugin can use. */ + foreign_interface_t foreign_intf; + /* Opaque state of this plugin. The state is usually some kind of pointer to * the plugin state, but all the harness knows is the opaque state is a * pointer-sized piece of data. @@ -50,7 +73,7 @@ typedef struct PLUGIN { /** Intializes the plugin with the given argc/argv. This is the first thing * called on the plugin and is called immediately after the library is loaded. */ - EXPORT(void (*plugin_load)(int argc, char **argv)); + EXPORT(void (*plugin_load)(int argc, char **argv, foreign_interface_t *intf)); /* Start the plugin with the marshalled state from the previous plugin. * @@ -95,22 +118,33 @@ typedef struct PLUGIN { EXPORT(opqst_t (*plugin_handle_surface_unmap)(void *surface, opqst_t)); EXPORT(opqst_t (*plugin_handle_surface_destroy)(void *surface, opqst_t)); + /* List of requested actions by the plugin. Right now there is a maximum of 8 + * allowed at one time. That should be plenty. The actions should be flushed + * after each call to a handler anyway. */ + size_t n_requested_actions; + requested_action_t requested_actions[8]; } plugin_t; -/** Loads a plugin from the dynamic library handle. Returns a non-zero error - * code on error. */ -int load_plugin_from_dl(dlhandle_t library, plugin_t *out); +#undef EXPORT /* Reloads the plugin. This tears down the existing plugin, marshals the state * for it and reloads it. * - * This function will call dlclose on the plugin's library handle if it is not - * the same as 'library'. + * This function will call dlclose on the plugin's library handle. */ int plugin_hot_reload(int argc, char **argv, const char *filepath, plugin_t *plugin); +/* + * Like hot-reload, but uses the same parameters the plugin was originally + * loaded with. + */ +int plugin_hot_reload_same_state(plugin_t *plugin); + /* Reads a plugin from a filename. */ -int load_plugin_from_file(const char *filename, plugin_t *plugin); +int load_plugin_from_file(int argc, char **argv, const char *filename, + plugin_t *plugin); + +void plugin_run_requested_actions(plugin_t *plugin); #endif /* _PLUGIN_H_ */ |