int hal_common_put_backend(enum hal_module module, void *data);
/**
+ * @brief Get the backend data with the specific library name according to the type of HAL module
+ * @param[in] HAL module id among enum hal_moudle
+ * @param[out] Data pointer where 'hal_backend_[module]_funcs' instance
+ * should be stored from HAL backend binary.
+ * @param[in] HAL backend library name which is not default library name
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int hal_common_get_backend_with_library_name(enum hal_module module,
+ void **data, const char *library_name);
+
+/**
+ * @brief Put the backend data with the specific library name according to the type of HAL module
+ * @param[in] HAL module id among enum hal_moudle
+ * @param[in] Data pointer where 'hal_backend_[module]_funcs' instance
+ * @param[in] HAL backend library name which is not default library name
+ * @return @c 0 on success, otherwise a negative error value
+ */
+int hal_common_put_backend_with_library_name(enum hal_module module,
+ void *data, const char *library_name);
+
+/**
* @brief Check HAL ABI version whehter is suppored or not on current platform
* @param[in] HAL module id among enum hal_moudle
* @param[in] HAL ABI version of backend module among enum hal_abi_version
struct hal_abi_version_match *abi_versions;
bool hal_api;
+ bool hal_backend_extension;
};
+static inline const char* get_backend_library_name(struct __hal_module_info *info)
+{
+ if (!info)
+ return NULL;
+
+#if defined(__aarch64__)
+ return info->library_name_64bit;
+#else
+ return info->library_name;
+#endif
+}
+
#ifdef __cplusplus
}
#endif
static enum hal_abi_version g_platform_curr_abi_version;
G_LOCK_DEFINE_STATIC(hal_common_lock);
-
-static const char* get_backend_library_name(struct __hal_module_info *info)
-{
- if (!info)
- return NULL;
-
-#if defined(__aarch64__)
- return info->library_name_64bit;
-#else
- return info->library_name;
-#endif
-}
-
EXPORT
int hal_common_get_backend_library_name(enum hal_module module, char *name, int size)
{
if (_hal_api_conf_init())
return TIZEN_ERROR_UNKNOWN;
- info = _hal_api_conf_get_module_info(module);
+ info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
ret = TIZEN_ERROR_UNKNOWN;
if (_hal_api_conf_init())
return TIZEN_ERROR_UNKNOWN;
- info = _hal_api_conf_get_module_info(module);
+ info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
ret = TIZEN_ERROR_UNKNOWN;
return ret;
}
-EXPORT
-int hal_common_get_backend(enum hal_module module, void **data)
+static int __get_backend(enum hal_module module, void **data, const char *library_name)
{
struct __hal_module_info *info = NULL;
void *handle = NULL;
hal_backend *backend;
- const char *library_name, *symbol_name;
+ const char *symbol_name;
+ const char *backend_library_name;
int ret = 0;
/* Check parameter whether is valid or not */
goto err;
}
- info = _hal_api_conf_get_module_info(module);
+ info = _hal_api_conf_get_module_info(module, library_name);
if (info == NULL) {
- _E("Failed to get HAL module(%d) information\n", module);
+ if (!library_name)
+ _E("Failed to get HAL module(%d) information\n", module);
+ else
+ _E("Failed to get HAL module(%d) information (%s)\n",
+ module, library_name);
ret = TIZEN_ERROR_UNKNOWN;
goto err;
}
* Load HAL backend library at first loading time
* when usage_count is 0.
*/
- library_name = get_backend_library_name(info);
- if (!library_name) {
+ backend_library_name = get_backend_library_name(info);
+ if (!backend_library_name) {
_E("%s: Failed to get backend library name\n",
info->module_name);
ret = TIZEN_ERROR_INVALID_PARAMETER;
goto err;
}
- ret = access(library_name, F_OK);
+ ret = access(backend_library_name, F_OK);
if (ret < 0) {
_E("%s: Failed to find backend library (%s)\n",
- info->module_name, library_name);
+ info->module_name, backend_library_name);
ret = TIZEN_ERROR_INVALID_PARAMETER;
goto err;
}
- handle = dlopen(library_name, RTLD_LAZY);
+ handle = dlopen(backend_library_name, RTLD_LAZY);
if (!handle) {
_E("%s: Failed to load backend library (%s)\n",
info->module_name, dlerror());
_I("%s: Get HAL backend: name(%s)/vendor(%s)/library(%s)/count(%d)\n",
info->module_name, backend->name, backend->vendor,
- library_name, info->usage_count);
+ backend_library_name, info->usage_count);
G_UNLOCK(hal_common_lock);
return TIZEN_ERROR_NONE;
return ret;
}
-EXPORT
-int hal_common_put_backend(enum hal_module module, void *data)
+static int __put_backend(enum hal_module module, void *data, const char *library_name)
{
struct __hal_module_info *info = NULL;
hal_backend *backend = NULL;
G_LOCK(hal_common_lock);
- info = _hal_api_conf_get_module_info(module);
+ info = _hal_api_conf_get_module_info(module, library_name);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
ret = TIZEN_ERROR_UNKNOWN;
}
EXPORT
+int hal_common_get_backend(enum hal_module module, void **data)
+{
+ return __get_backend(module, data, NULL);
+}
+
+EXPORT
+int hal_common_put_backend(enum hal_module module, void *data)
+{
+ return __put_backend(module, data, NULL);
+}
+
+EXPORT
+int hal_common_get_backend_with_library_name(enum hal_module module,
+ void **data, const char *library_name)
+{
+ return __get_backend(module, data, library_name);
+}
+
+EXPORT
+int hal_common_put_backend_with_library_name(enum hal_module module,
+ void *data, const char *library_name)
+{
+ return __put_backend(module, data, library_name);
+}
+
+EXPORT
int hal_common_check_backend_abi_version(enum hal_module module,
enum hal_abi_version abi_version)
{
if (_hal_api_conf_init())
return TIZEN_ERROR_UNKNOWN;
- info = _hal_api_conf_get_module_info(module);
+ info = _hal_api_conf_get_module_info(module, NULL);
if (info == NULL) {
_E("Failed to get HAL module(%d) information\n", module);
ret = TIZEN_ERROR_UNKNOWN;
} while (0);
struct __hal_module_info *info = (struct __hal_module_info *)data;
- gboolean is_contained = false;
if (info) {
- is_contained = g_hash_table_contains(_module_hash, GINT_TO_POINTER(info->module));
- if (is_contained)
- g_hash_table_steal(_module_hash, GINT_TO_POINTER(info->module));
-
SAFE_FREE_AND_NULL(info->module_name);
SAFE_FREE_AND_NULL(info->library_name);
SAFE_FREE_AND_NULL(info->library_name_64bit);
return info;
}
-__attribute__ ((visibility("default")))
-struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module)
+static struct __hal_module_info* _get_module_info(enum hal_module module)
{
struct __hal_module_info *info = NULL;
json_object *module_array_object = NULL;
return info;
}
+static struct __hal_module_info* _get_module_info_with_library_name(enum hal_module module,
+ const char *library_name)
+{
+ struct __hal_module_info *info = NULL, *new_info = NULL;
+ json_object *module_array_object = NULL;
+ const char *group_name = NULL;
+ const char *module_name = NULL;
+ int ret;
+
+ if (!_json_file_object || !_module_hash | !library_name)
+ return NULL;
+
+ if (!g_str_has_prefix(library_name, "libhal-backend-")) {
+ _E("Invalid library name(%s) of HAL module(%d)\n",
+ library_name, module);
+ return NULL;
+ }
+
+ /* Find module info with the passed library name */
+ info = (struct __hal_module_info*)g_hash_table_lookup(_module_hash,
+ (gpointer)library_name);
+ if (info)
+ return info;
+
+ /* Create new module info with the passed library name */
+ info = _get_module_info(module);
+ if (info == NULL) {
+ _E("Failed to get HAL module(%d) information\n", module);
+ return NULL;
+ }
+
+ new_info = (struct __hal_module_info *)calloc(1,
+ sizeof(struct __hal_module_info));
+ if (new_info == NULL) {
+ _E("Failed to allocate the memory\n");
+ return NULL;
+ }
+
+ new_info->usage_count = 0;
+ new_info->group = info->group;
+ new_info->module = info->module;
+ new_info->license = info->license;
+ new_info->module_name = g_strdup(info->module_name);
+#if defined(__aarch64__)
+ new_info->library_name_64bit = g_strdup_printf("/hal/lib64/%s", library_name);
+#else
+ new_info->library_name = g_strdup_printf("/hal/lib/%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;
+ new_info->hal_api = info->hal_api;
+ new_info->hal_backend_extension = true;
+
+ g_hash_table_insert(_module_hash, (gpointer)library_name, new_info);
+
+ return new_info;
+}
+
+__attribute__ ((visibility("default")))
+struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module,
+ const char *library_name)
+{
+ struct __hal_module_info *info = NULL;
+ json_object *module_array_object = NULL;
+ const char *group_name = NULL;
+ const char *module_name = NULL;
+ const char *key = NULL;
+ int i;
+
+ if (!_json_file_object || !_module_hash)
+ return NULL;
+
+ if (!library_name)
+ return _get_module_info(module);
+ else
+ return _get_module_info_with_library_name(module, library_name);
+}
+
+
enum hal_abi_version _hal_api_conf_get_platform_abi_version(void)
{
const char *abi_version = NULL;
int _hal_api_conf_init(void);
void _hal_api_conf_exit(void);
-struct __hal_module_info *_hal_api_conf_get_module_info(enum hal_module module);
+struct __hal_module_info *_hal_api_conf_get_module_info(enum hal_module module,
+ const char *library_name);
enum hal_abi_version _hal_api_conf_get_platform_abi_version(void);
auto result_info = GetParam();
_hal_api_conf_init();
- info = _hal_api_conf_get_module_info(result_info.module_);
+ info = _hal_api_conf_get_module_info(result_info.module_, NULL);
ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
EXPECT_EQ(info->group, result_info.group_) << "module name is " << result_info.module_name_;
_hal_api_conf_exit();
auto result_info = GetParam();
_hal_api_conf_init();
- info = _hal_api_conf_get_module_info(result_info.module_);
+ info = _hal_api_conf_get_module_info(result_info.module_, NULL);
ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
EXPECT_EQ(info->license, result_info.license_) << "module name is " << result_info.module_name_;
_hal_api_conf_exit();
auto result_info = GetParam();
_hal_api_conf_init();
- info = _hal_api_conf_get_module_info(result_info.module_);
+ info = _hal_api_conf_get_module_info(result_info.module_, NULL);
ASSERT_TRUE(info != nullptr) << "module name is " << result_info.module_name_;
EXPECT_STREQ(info->module_name, result_info.module_name_) << "module name is " << result_info.module_name_;
_hal_api_conf_exit();
auto result_info = GetParam();
_hal_api_conf_init();
- info = _hal_api_conf_get_module_info(result_info.module_);
+ info = _hal_api_conf_get_module_info(result_info.module_, NULL);
ASSERT_TRUE(info != nullptr);
vector<struct hal_abi_version_match> versions = result_info.versions_;