extern "C" {
#endif
-enum syscommon_plugin_abi_version {
- SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN = 0,
- SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_7_0,
- SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_9_0,
- SYSCOMMON_PLUGIN_ABI_VERSION_END,
-};
-
-static const char *const syscommon_plugin_abi_version_str[] = {
- [SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN] = "Unknown PLUGIN ABI Version",
- [SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_7_0] = "PLUGIN_ABI_VERSION_TIZEN_7_0",
- [SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0] = "PLUGIN_ABI_VERSION_TIZEN_8_0",
- [SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_9_0] = "PLUGIN_ABI_VERSION_TIZEN_9_0",
-};
-
typedef struct __syscommon_plugin_backend {
const char *name;
const char *vendor;
- const unsigned int abi_version;
int (*init) (void **data);
int (*exit) (void *data);
} syscommon_plugin_backend;
enum syscommon_plugin_module module,
void *data, const char *library_name);
-/**
- * @brief Check PLUGIN ABI version whehter is suppored or not on current platform
- * @param[in] PLUGIN module id among enum plugin_moudle
- * @param[in] PLUGIN ABI version of backend module among enum plugin_abi_version
- * @return @c 0 on success, otherwise a negative error value
- */
-int syscommon_plugin_common_check_backend_abi_version(
- enum syscommon_plugin_module module,
- enum syscommon_plugin_abi_version abi_version);
-
-/**
- * @brief Get the backend PLUGIN ABI version according to the type of PLUGIN module
- * @param[in] PLUGIN module id among enum plugin_moudle
- * @return @c positive integer value on success, otherwise a zero error value
- */
-unsigned int syscommon_plugin_common_get_backend_abi_version(
- enum syscommon_plugin_module module);
-
/**
* @brief Get the backend name according to the type of PLUGIN module
* @param[in] PLUGIN module id among enum plugin_moudle
[PLUGIN_GROUP_UPDATE_CONTROL] = "PLUGIN_GROUP_UPDATE_CONTROL",
};
-/**
- * syscommon-plugin-api-common provides the PLUGIN ABI * (Application Binary Interface)
- * version check feature which is used to check the ABI compatibility between
- * PLUGIN API package and PLUGIN backend package.
- * In order to compare ABI version between two binary, Tizen core platform
- * always must maintain the current PLUGIN ABI version.
- * So that, define the below global variable (g_platform_curr_abi_version).
- *
- * 'g_platform_curr_abi_version' will be used for all PLUGIN API modules,
- * to check whether PLUGIN backend ABI version of each module is supported
- * or not with current PLUGIN ABI version.
- *
- * 'g_platform_curr_abi_version' must be updated when Tizen platform will be
- * released officially.
- */
-struct plugin_abi_version_match {
- enum syscommon_plugin_abi_version platform_abi_version;
- enum syscommon_plugin_abi_version backend_min_abi_version;
-};
-
struct __plugin_module_info {
int usage_count;
void *handle;
syscommon_plugin_backend *backend;
char *symbol_name;
-
- unsigned int num_abi_versions;
- struct plugin_abi_version_match *abi_versions;
};
static inline const char* get_backend_library_name(struct __plugin_module_info *info)
#define EXPORT __attribute__ ((visibility("default")))
#endif
-static enum syscommon_plugin_abi_version g_platform_curr_abi_version;
G_LOCK_DEFINE_STATIC(plugin_common_lock);
EXPORT
return -EINVAL;
}
- /* Check PLUGIN ABI Version */
- ret = syscommon_plugin_common_check_backend_abi_version(info->module,
- info->backend->abi_version);
- if (ret < 0) {
- _E("%s: Failed to check ABI version\n", info->module_name);
- return -EINVAL;
- }
-
/* Initialize backend */
ret = info->backend->init(data);
if (ret < 0) {
return ret;
}
-static int __get_backend_data(enum syscommon_plugin_module module, unsigned int *abi_version,
+static int __get_backend_data(enum syscommon_plugin_module module,
char *name, int name_size, char *vendor, int vendor_size)
{
struct __plugin_module_info *info = NULL;
G_LOCK(plugin_common_lock);
if (_plugin_api_conf_init()) {
- ret = SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN;
+ ret = -EINVAL;
goto err_unlock;
}
info = _plugin_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get PLUGIN module(%d) information\n", module);
- ret = SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN;
+ ret = -EINVAL;
goto err_conf_exit;
}
if (ret < 0)
goto err_conf_exit;
- /* Return abi_verion of plugin_backend structure */
- if (!name_size && !vendor_size) {
- *abi_version = info->backend->abi_version;
-
/* Return name of plugin_backend structure */
- } else if (info->backend->name && name_size && !vendor_size) {
+ if (info->backend->name && name_size && !vendor_size) {
len = strlen(info->backend->name);
if (!info->backend->name || (len + 1 > name_size)) {
return __put_backend(module, data, library_name);
}
-EXPORT
-int syscommon_plugin_common_check_backend_abi_version(enum syscommon_plugin_module module,
- enum syscommon_plugin_abi_version abi_version)
-{
- struct __plugin_module_info *info = NULL;
- int i;
- int ret;
-
- /* Check parameter whether is valid or not */
- if (module <= SYSCOMMON_PLUGIN_MODULE_UNKNOWN || module >= SYSCOMMON_PLUGIN_MODULE_END) {
- _E("Invalid paramer of PLUGIN module(%d)\n", module);
- return -EINVAL;
- }
-
- if (abi_version <= SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN
- || abi_version >= SYSCOMMON_PLUGIN_ABI_VERSION_END) {
- _E("Invalid paramer of PLUGIN ABI version(%d) for PLUGIN module(%d)\n",
- abi_version, module);
- return -EINVAL;
- }
-
- if (_plugin_api_conf_init())
- return -EINVAL;
-
- info = _plugin_api_conf_get_module_info(module, NULL);
- if (info == NULL) {
- _E("Failed to get PLUGIN module(%d) information\n", module);
- ret = -EINVAL;
- goto out;
- }
-
- if (!info->num_abi_versions
- || !info->abi_versions) {
- _E("%s: Doesn't have the ABI version information\n",
- info->module_name);
- ret = -EINVAL;
- goto out;
- }
-
- g_platform_curr_abi_version = _plugin_api_conf_get_platform_abi_version();
-
- if (g_platform_curr_abi_version <= SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN
- || g_platform_curr_abi_version >= SYSCOMMON_PLUGIN_ABI_VERSION_END) {
- _E("Invalid paramer of current PLUGIN ABI version(%d)(%d)\n",
- g_platform_curr_abi_version, module);
- ret = -EINVAL;
- goto out;
- }
-
- for (i = 0; i < info->num_abi_versions; i++) {
- struct plugin_abi_version_match *data
- = &info->abi_versions[i];
-
- if (g_platform_curr_abi_version != data->platform_abi_version)
- continue;
-
- if (data->backend_min_abi_version <= SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN ||
- data->backend_min_abi_version >= SYSCOMMON_PLUGIN_ABI_VERSION_END) {
- _E("%s: abi_versions[%d].backend_min_abi_version(%d) is invalid\n",
- info->module_name, i, data->backend_min_abi_version);
- ret = -EINVAL;
- goto out;
- }
-
- if (abi_version <= data->platform_abi_version
- && abi_version >= data->backend_min_abi_version) {
- ret = 0;
- goto out;
- }
-
- _E("%s: \'%s\' doesn't support \'%s\'\n",
- info->module_name,
- syscommon_plugin_abi_version_str[g_platform_curr_abi_version],
- syscommon_plugin_abi_version_str[abi_version]);
- _E("%s: Must use ABI versions from \'%s\' to \'%s\'\n",
- info->module_name,
- syscommon_plugin_abi_version_str[data->backend_min_abi_version],
- syscommon_plugin_abi_version_str[data->platform_abi_version]);
- }
- ret = -EINVAL;
-
-out:
- _plugin_api_conf_exit();
- return ret;
-}
-
-EXPORT
-unsigned int syscommon_plugin_common_get_backend_abi_version(enum syscommon_plugin_module module)
-{
- unsigned int abi_version;
- int ret;
-
- ret = __get_backend_data(module, &abi_version, NULL, 0, NULL, 0);
- if (ret < 0)
- return SYSCOMMON_PLUGIN_ABI_VERSION_UNKNOWN;
-
- return abi_version;
-}
-
EXPORT
int syscommon_plugin_common_get_backend_name(enum syscommon_plugin_module module, char *name, int size)
{
- return __get_backend_data(module, NULL, name, size, NULL, 0);
+ return __get_backend_data(module, name, size, NULL, 0);
}
EXPORT
int syscommon_plugin_common_get_backend_vendor(enum syscommon_plugin_module module, char *vendor, int size)
{
- return __get_backend_data(module, NULL, NULL, 0, vendor, size);
+ return __get_backend_data(module, NULL, 0, vendor, size);
}
new_info->library_name = g_strdup_printf("/usr/lib/system/plugin/%s", library_name);
#endif
new_info->symbol_name = g_strdup(info->symbol_name);
- new_info->num_abi_versions = info->num_abi_versions;
- new_info->abi_versions = info->abi_versions;
g_hash_table_insert(_module_hash, (gpointer)library_name, new_info);
return _get_module_info_with_library_name(module, library_name);
}
-
-enum syscommon_plugin_abi_version _plugin_api_conf_get_platform_abi_version(void)
-{
- return g_platform_curr_abi_version;
-}
-
EXPORT
int _plugin_api_conf_init(void)
{
enum syscommon_plugin_module module,
const char *library_name);
-enum syscommon_plugin_abi_version _plugin_api_conf_get_platform_abi_version(void);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include "common.h"
-#define PLUGIN_ABI_VERSION_MAX 10
-
-enum syscommon_plugin_abi_version g_platform_curr_abi_version =
- SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0;
-
-static struct plugin_abi_version_match abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_END][PLUGIN_ABI_VERSION_MAX] = {
- [SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- },
- },
- /* PLUGIN_GROUP_DEVICED */
- [SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- },
- },
- [SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- },
- },
- [SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- },
- },
- [SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_8_0,
- },
- },
- [SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL] = {
- [0] = {
- .platform_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_9_0,
- .backend_min_abi_version = SYSCOMMON_PLUGIN_ABI_VERSION_TIZEN_9_0,
- },
- },
-};
-
static struct __plugin_module_info g_plugin_module_info[] = {
[SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK] = {
.group = PLUGIN_GROUP_RESOURCED,
.library_name = "/usr/lib/system/plugin/libplugin-backend-resourced-memory-lmk.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-resourced-memory-lmk.so",
.symbol_name = "system_plugin_backend_resourced_memory_lmk_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_MEMORY_LMK],
},
[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY] = {
.group = PLUGIN_GROUP_DEVICED,
.library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-battery.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-battery.so",
.symbol_name = "system_plugin_backend_deviced_battery_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_BATTERY],
},
[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT] = {
.group = PLUGIN_GROUP_DEVICED,
.library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-input.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-input.so",
.symbol_name = "system_plugin_backend_deviced_input_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_INPUT],
},
[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY] = {
.group = PLUGIN_GROUP_DEVICED,
.library_name = "/usr/lib/system/plugin/libplugin-backend-deviced-display.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-deviced-display.so",
.symbol_name = "system_plugin_backend_deviced_display_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_DEVICED_DISPLAY],
},
[SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING] = {
.group = PLUGIN_GROUP_RESOURCED,
.library_name = "/usr/lib/system/plugin/libplugin-backend-resourced-cpu-boosting.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-resourced-cpu-boosting.so",
.symbol_name = "system_plugin_backend_resourced_cpu_boosting_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_RESOURCED_CPU_BOOSTING],
},
[SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL] = {
- .group = PLUGIN_GROUP_UPDATE_CONTROL,
- .module = SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL,
+ .group = PLUGIN_GROUP_UPDATE_CONTROL,
+ .module = SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL,
.license = PLUGIN_LICENSE_APACHE_2_0,
.module_name = "SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL",
.backend_module_name = "update-control",
.library_name = "/usr/lib/system/plugin/libplugin-backend-update-control.so",
.library_name_64bit = "/usr/lib64/system/plugin/libplugin-backend-update-control.so",
.symbol_name = "system_plugin_backend_update_control_data",
- .num_abi_versions = ARRAY_SIZE(abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL]),
- .abi_versions = abi_version_match_data[SYSCOMMON_PLUGIN_MODULE_UPDATE_CONTROL],
},
};