From 055c4c02923ace06187fd3b3006d037a523a0846 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 2 Feb 2021 20:25:34 +0900 Subject: [PATCH 01/16] unittest: Add testcase to check backend abi version Change-Id: Ic740ea639e738dcbd8514497e0f02bd0e1080bd5 Signed-off-by: Seungha Son --- haltests/src/test_hal.cc | 218 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 181 insertions(+), 37 deletions(-) diff --git a/haltests/src/test_hal.cc b/haltests/src/test_hal.cc index 1042adb..a73e484 100644 --- a/haltests/src/test_hal.cc +++ b/haltests/src/test_hal.cc @@ -82,12 +82,15 @@ public: const char *library_name_; const char *library_name_64bit_; const char *symbol_name_; + vector versions_; HalInfo(enum hal_module module, enum hal_group group, enum hal_license license, - const char *module_name, const char *library_name, const char *library_name_64bit, const char *symbol_name) : + const char *module_name, const char *library_name, const char *library_name_64bit, + const char *symbol_name, vector versions) : module_(module), group_(group), license_(license), module_name_(module_name), library_name_(library_name), - library_name_64bit_(library_name_64bit), symbol_name_(symbol_name) {} + library_name_64bit_(library_name_64bit), symbol_name_(symbol_name), + versions_(versions) {} }; class HalInfoMatchedTest : public ::testing::TestWithParam {}; @@ -97,130 +100,250 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ::testing::Values( HalInfo(HAL_MODULE_TBM, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT, "HAL_MODULE_TBM", "/hal/lib/libhal-backend-tbm.so", - "/hal/lib64/libhal-backend-tbm.so", "hal_backend_tbm_data"), + "/hal/lib64/libhal-backend-tbm.so", "hal_backend_tbm_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_TDM, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT, "HAL_MODULE_TDM", "/hal/lib/libhal-backend-tdm.so", - "/hal/lib64/libhal-backend-tdm.so", "hal_backend_tdm_data"), + "/hal/lib64/libhal-backend-tdm.so", "hal_backend_tdm_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_COREGL, HAL_GROUP_GRAPHICS, HAL_LICENSE_UNKNOWN, - "HAL_MODULE_COREGL", nullptr, nullptr, nullptr), + "HAL_MODULE_COREGL", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_INPUT, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT, - "HAL_MODULE_INPUT", nullptr, nullptr, nullptr), + "HAL_MODULE_INPUT", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_AUDIO", "/hal/lib/libhal-backend-audio.so", - "/hal/lib64/libhal-backend-audio.so", "hal_backend_audio_data"), + "/hal/lib64/libhal-backend-audio.so", "hal_backend_audio_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_CAMERA, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_CAMERA", "/hal/lib/libhal-backend-camera.so", - "/hal/lib64/libhal-backend-camera.so", "hal_backend_camera_data"), + "/hal/lib64/libhal-backend-camera.so", "hal_backend_camera_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_RADIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_RADIO", "/hal/lib/libhal-backend-radio.so", - "/hal/lib64/libhal-backend-radio.so", "hal_backend_radio_data"), + "/hal/lib64/libhal-backend-radio.so", "hal_backend_radio_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_CODEC, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_CODEC", nullptr, nullptr, nullptr), + "HAL_MODULE_CODEC", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_USB_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_USB_AUDIO", nullptr, nullptr, nullptr), + "HAL_MODULE_USB_AUDIO", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_ALSAUCM, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_ALSAUCM", nullptr, nullptr, nullptr), + "HAL_MODULE_ALSAUCM", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_BLUETOOTH, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_BLUETOOTH", "/hal/lib/libhal-backend-bluetooth.so", - "/hal/lib64/libhal-backend-bluetooth.so", "hal_backend_bluetooth_data"), + "/hal/lib64/libhal-backend-bluetooth.so", "hal_backend_bluetooth_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_WIFI, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_WIFI", "/hal/lib/libhal-backend-wifi.so", - "/hal/lib64/libhal-backend-wifi.so", "hal_backend_wifi_data"), + "/hal/lib64/libhal-backend-wifi.so", "hal_backend_wifi_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_NAN, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_NAN", nullptr, nullptr, nullptr), + "HAL_MODULE_NAN", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_NFC, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_NFC", "/hal/lib/libhal-backend-nfc.so", - "/hal/lib64/libhal-backend-nfc.so", "hal_backend_nfc_data"), + "/hal/lib64/libhal-backend-nfc.so", "hal_backend_nfc_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_ZIGBEE, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_ZIGBEE", "/hal/lib/libhal-backend-zigbee.so", - "/hal/lib64/libhal-backend-zigbee.so", "hal_backend_zigbee_data"), + "/hal/lib64/libhal-backend-zigbee.so", "hal_backend_zigbee_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_UWB, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_UWB", "/hal/lib/libhal-backend-uwb.so", - "/hal/lib64/libhal-backend-uwb.so", "hal_backend_uwb_data"), + "/hal/lib64/libhal-backend-uwb.so", "hal_backend_uwb_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_MTP, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_MTP", nullptr, nullptr, nullptr), + "HAL_MODULE_MTP", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_TELEPHONY, HAL_GROUP_TELEPHONY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_TELEPHONY", nullptr, nullptr, nullptr), + "HAL_MODULE_TELEPHONY", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_LOCATION, HAL_GROUP_LOCATION, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_LOCATION", "/hal/lib/libhal-backend-location.so", - "/hal/lib64/libhal-backend-location.so", "hal_backend_location_data"), + "/hal/lib64/libhal-backend-location.so", "hal_backend_location_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_COMMON, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_COMMON", nullptr, nullptr, nullptr), + "HAL_MODULE_COMMON", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_POWER, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_POWER", "/hal/lib/libhal-backend-power.so", - "/hal/lib64/libhal-backend-power.so", "hal_backend_power_data"), + "/hal/lib64/libhal-backend-power.so", "hal_backend_power_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_SENSOR, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_SENSOR", "/hal/lib/libhal-backend-sensor.so", - "/hal/lib64/libhal-backend-sensor.so", "hal_backend_sensor_data"), + "/hal/lib64/libhal-backend-sensor.so", "hal_backend_sensor_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_PERIPHERAL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_PERIPHERAL", nullptr, nullptr, nullptr), + "HAL_MODULE_PERIPHERAL", nullptr, nullptr, nullptr, {}), HalInfo(HAL_MODULE_DEVICE_BATTERY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_BATTERY", "/hal/lib/libhal-backend-device-battery.so", - "/hal/lib64/libhal-backend-device-battery.so", "hal_backend_device_battery_data"), + "/hal/lib64/libhal-backend-device-battery.so", "hal_backend_device_battery_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_BEZEL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_BEZEL", "/hal/lib/libhal-backend-device-bezel.so", - "/hal/lib64/libhal-backend-device-bezel.so", "hal_backend_device_bezel_data"), + "/hal/lib64/libhal-backend-device-bezel.so", "hal_backend_device_bezel_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_DISPLAY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_DISPLAY", "/hal/lib/libhal-backend-device-display.so", - "/hal/lib64/libhal-backend-device-display.so", "hal_backend_device_display_data"), + "/hal/lib64/libhal-backend-device-display.so", "hal_backend_device_display_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_IR, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_IR", "/hal/lib/libhal-backend-device-ir.so", - "/hal/lib64/libhal-backend-device-ir.so", "hal_backend_device_ir_data"), + "/hal/lib64/libhal-backend-device-ir.so", "hal_backend_device_ir_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_TOUCHSCREEN, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_TOUCHSCREEN", "/hal/lib/libhal-backend-device-touchscreen.so", - "/hal/lib64/libhal-backend-device-touchscreen.so", "hal_backend_device_touchscreen_data"), + "/hal/lib64/libhal-backend-device-touchscreen.so", "hal_backend_device_touchscreen_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_LED, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_LED", "/hal/lib/libhal-backend-device-led.so", - "/hal/lib64/libhal-backend-device-led.so", "hal_backend_device_led_data"), + "/hal/lib64/libhal-backend-device-led.so", "hal_backend_device_led_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_BOARD, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_BOARD", "/hal/lib/libhal-backend-device-board.so", - "/hal/lib64/libhal-backend-device-board.so", "hal_backend_device_board_data"), + "/hal/lib64/libhal-backend-device-board.so", "hal_backend_device_board_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_EXTERNAL_CONNECTION", "/hal/lib/libhal-backend-device-external-connection.so", - "/hal/lib64/libhal-backend-device-external-connection.so", "hal_backend_device_external_connection_data"), + "/hal/lib64/libhal-backend-device-external-connection.so", "hal_backend_device_external_connection_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_THERMAL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_THERMAL", "/hal/lib/libhal-backend-device-thermal.so", - "/hal/lib64/libhal-backend-device-thermal.so", "hal_backend_device_thermal_data"), + "/hal/lib64/libhal-backend-device-thermal.so", "hal_backend_device_thermal_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_USB_GADGET, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_USB_GADGET", "/hal/lib/libhal-backend-device-usb-gadget.so", - "/hal/lib64/libhal-backend-device-usb-gadget.so", "hal_backend_device_usb_gadget_data"), + "/hal/lib64/libhal-backend-device-usb-gadget.so", "hal_backend_device_usb_gadget_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ), HalInfo(HAL_MODULE_DEVICE_HAPTIC, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_HAPTIC", "/hal/lib/libhal-backend-device-haptic.so", - "/hal/lib64/libhal-backend-device-haptic.so", "hal_backend_device_haptic_data") - )); + "/hal/lib64/libhal-backend-device-haptic.so", "hal_backend_device_haptic_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ) +)); TEST_P(HalInfoMatchedTest, get_backend_library_name) { const char *ret_library_name; @@ -279,3 +402,24 @@ TEST_P(HalInfoMatchedTest, test_module_name_matching) { _destroy_module_info(info); } + +TEST_P(HalInfoMatchedTest, test_check_backend_abi_version) { + struct __hal_module_info *info = NULL; + + + auto result_info = GetParam(); + info = _hal_api_conf_get_module_info(result_info.module_); + ASSERT_TRUE(info != nullptr); + + vector versions = result_info.versions_; + struct hal_abi_version_match *meta_versions = info->abi_versions; + + for (unsigned int i = 0; i < versions.size(); i++) { + struct hal_abi_version_match tmp_version = versions[i]; + + int ret = hal_common_check_backend_abi_version(result_info.module_, tmp_version.platform_abi_version); + EXPECT_EQ(ret, TIZEN_ERROR_NONE) << "module name is " << result_info.module_name_; + EXPECT_EQ(meta_versions[i].platform_abi_version, tmp_version.platform_abi_version) << "module name is " << result_info.module_name_;; + EXPECT_EQ(meta_versions[i].backend_min_abi_version, tmp_version.backend_min_abi_version) << "module name is " << result_info.module_name_;; + } +} -- 2.7.4 From 080fa01f71452ddf70f84372e3a6c2bf9796680b Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 2 Feb 2021 19:09:58 +0900 Subject: [PATCH 02/16] halpai: Add support of reference count for hal_common_(get|put)_backend function Some HAL module need to call hal_common_(get|put)_backend() funcions at multiple points at the same time. So that have to support this requirement by using the reference count. When touching the reference count, uses the mutex in order to keep the data integrity. Change-Id: I2c3a662f21d1c56c7b5b077c7a3f155bf47fd792 Signed-off-by: Chanwoo Choi --- src/common.h | 2 + src/hal-api-common.c | 119 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 83 insertions(+), 38 deletions(-) diff --git a/src/common.h b/src/common.h index 55b28ff..f19e56c 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,8 @@ struct hal_abi_version_match { }; struct __hal_module_info { + int usage_count; + enum hal_group group; enum hal_module module; enum hal_license license; diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 6492aae..be66273 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -22,6 +22,8 @@ #include #include +#include + #include "common.h" #include "hal-api-conf.h" @@ -30,6 +32,7 @@ #endif static enum hal_abi_version g_platform_curr_abi_version; +G_LOCK_DEFINE_STATIC(hal_common_lock); EXPORT const char *hal_common_get_backend_library_name(enum hal_module module) @@ -96,6 +99,14 @@ int hal_common_get_backend(enum hal_module module, void **data) const char *library_name, *symbol_name; int ret = 0; + /* Check parameter whether is valid or not */ + if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) { + _E("Invalid parameter of HAL module (%d)\n", module); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + G_LOCK(hal_common_lock); + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); @@ -103,35 +114,51 @@ int hal_common_get_backend(enum hal_module module, void **data) goto err; } - /* Load module */ - library_name = hal_common_get_backend_library_name(module); - if (!library_name) { - _E("%s: Failed to get backend library name\n", - info->module_name); - return TIZEN_ERROR_INVALID_PARAMETER; - } + if (info->usage_count == 0) { + /* + * Load HAL backend library at first loading time + * when usage_count is 0. + */ + library_name = hal_common_get_backend_library_name(module); + if (!library_name) { + _E("%s: Failed to get backend library name\n", + info->module_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } - handle = dlopen(library_name, RTLD_LAZY); - if (!handle) { - _E("%s: Failed to load shared library (%s)\n", - info->module_name, dlerror()); - return TIZEN_ERROR_INVALID_PARAMETER; - } + handle = dlopen(library_name, RTLD_LAZY); + if (!handle) { + _E("%s: Failed to load shared library (%s)\n", + info->module_name, dlerror()); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } - symbol_name = hal_common_get_backend_symbol_name(module); - if (!symbol_name) { - _E("%s: Failed to get backend symbol name\n", - info->module_name); - ret = TIZEN_ERROR_INVALID_PARAMETER; - goto err; - } + symbol_name = hal_common_get_backend_symbol_name(module); + if (!symbol_name) { + _E("%s: Failed to get backend symbol name\n", + info->module_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err_dlclose; + } - backend = dlsym(handle, symbol_name); - if (!backend) { - _E("%s: Failed to find backend data (%s)\n", - info->module_name, dlerror()); - ret = TIZEN_ERROR_INVALID_PARAMETER; - goto err; + backend = dlsym(handle, symbol_name); + if (!backend) { + _E("%s: Failed to find backend data (%s)\n", + info->module_name, dlerror()); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err_dlclose; + } + + info->library_backend = backend; + info->library_handle = handle; + } else { + /* + * Re-use the already loaded HAL backend instance + * when usage_count is larger than 0. + */ + backend = info->library_backend; } /* Check HAL ABI Version */ @@ -140,7 +167,7 @@ int hal_common_get_backend(enum hal_module module, void **data) _E("%s: Failed to check ABI version\n", info->module_name); ret = TIZEN_ERROR_INVALID_PARAMETER; - goto err; + goto err_dlclose; } /* Get the backend module data */ @@ -148,7 +175,7 @@ int hal_common_get_backend(enum hal_module module, void **data) _E("%s: hal_backend->init() is NULL\n", info->module_name); ret = TIZEN_ERROR_INVALID_PARAMETER; - goto err; + goto err_dlclose; } ret = backend->init(data); @@ -156,18 +183,21 @@ int hal_common_get_backend(enum hal_module module, void **data) _E("%s: Failed to initialize backend: name(%s)/vendor(%s)\n", info->module_name, backend->name, backend->vendor); ret = TIZEN_ERROR_INVALID_PARAMETER; - goto err; + goto err_dlclose; } - info->library_backend = backend; - info->library_handle = handle; - _I("%s: Get HAL backend: name(%s)/vendor(%s)\n", info->module_name, backend->name, backend->vendor); + info->usage_count++; + + G_UNLOCK(hal_common_lock); return TIZEN_ERROR_NONE; -err: + +err_dlclose: dlclose(handle); +err: + G_UNLOCK(hal_common_lock); return ret; } @@ -185,18 +215,28 @@ int hal_common_put_backend(enum hal_module module, void *data) return TIZEN_ERROR_INVALID_PARAMETER; } + G_LOCK(hal_common_lock); + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); - return TIZEN_ERROR_UNKNOWN; + ret = TIZEN_ERROR_UNKNOWN; + goto out; } backend = info->library_backend; handle = info->library_handle; - if (!backend) { + if (!backend || info->usage_count == 0) { _I("%s: Already fully put for HAL module\n", info->module_name); - return TIZEN_ERROR_NONE; + ret = TIZEN_ERROR_NONE; + goto out; + } + + info->usage_count--; + if (info->usage_count > 0) { + ret = TIZEN_ERROR_NONE; + goto out; } if (backend->exit) { @@ -204,7 +244,8 @@ int hal_common_put_backend(enum hal_module module, void *data) if (ret < 0) { _E("%s: Failed to exit backend: name(%s)/vendor(%s)\n", info->module_name, backend->name, backend->vendor); - return TIZEN_ERROR_INVALID_PARAMETER; + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto out; } } @@ -217,7 +258,9 @@ int hal_common_put_backend(enum hal_module module, void *data) info->library_backend = NULL; info->library_handle = NULL; - return TIZEN_ERROR_NONE; +out: + G_UNLOCK(hal_common_lock); + return ret; } EXPORT -- 2.7.4 From 97ebf2bd65d29366d2038415ad6e1ad4b4bbb228 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 4 Feb 2021 15:53:40 +0900 Subject: [PATCH 03/16] halapi: Replace destructor with reference count method to free memory Instead of destructor method to free the memory, use the reference count method to free the memory in order to support multi-thread environment. So that define the _hal_api_conf_(init|exit)() functions to control the reference count. These functions either get the resources from hal-api.json or put the resources according to the reference count. - _hal_api_conf_init() increments the reference count - _hal_api_conf_exit() decrements the reference count hal_common_get_backend() and hal_common_put_backend() functions should be called pairly in order to free the resources of hal-api.json. [Detailed use-case of _hal_api_conf_init() and _hal_api_conf_ext()] hal_common_get_backend() _hal_api_conf_init() /* codes */ hal_common_put_backend() /* codes */ _hal_api_conf_exit() hal_common_get_backend_library_name() _hal_api_conf_init() /* codes */ _hal_api_conf_exit() hal_common_get_backend_symbol_name() _hal_api_conf_init() /* codes */ _hal_api_conf_exit() hal_common_check_backend_abi_version() _hal_api_conf_init() /* codes */ _hal_api_conf_exit() And change the prototype of hal_common_get_backend_library_name, hal_common_get_backend_symbol_name as following: - int hal_common_get_backend_library_name(enum hal_module module, char *name, int size); - int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size); Change-Id: If663b87244cc680d94568818d4358a7b91fb071e Signed-off-by: Chanwoo Choi --- haltests/src/test_hal.cc | 70 +++++++++++++++----------- include/hal-common.h | 14 +++--- src/hal-api-common.c | 127 ++++++++++++++++++++++++++++++++++++----------- src/hal-api-conf.c | 127 ++++++++++++++++++++++++----------------------- src/hal-api-conf.h | 3 ++ 5 files changed, 214 insertions(+), 127 deletions(-) diff --git a/haltests/src/test_hal.cc b/haltests/src/test_hal.cc index a73e484..ddadc56 100644 --- a/haltests/src/test_hal.cc +++ b/haltests/src/test_hal.cc @@ -28,6 +28,8 @@ #include "../../src/hal-api-conf.h" #include "../../src/common.h" +#define MAX_BUFF 128 + using namespace std; @@ -45,11 +47,15 @@ class CommonHaltest : public testing::Test { }; TEST(CommonHaltest, test_symbol_name_invalid_module) { - const char *ret_unknown = hal_common_get_backend_symbol_name(HAL_MODULE_UNKNOWN); - EXPECT_TRUE(ret_unknown == nullptr); + char ret_unknown[MAX_BUFF] = {0, }; + char ret_end[MAX_BUFF] = {0, }; + int ret; - const char *ret_end = hal_common_get_backend_symbol_name(HAL_MODULE_END); - EXPECT_TRUE(ret_end == nullptr); + ret = hal_common_get_backend_symbol_name(HAL_MODULE_UNKNOWN, ret_unknown, MAX_BUFF); + EXPECT_TRUE(ret != TIZEN_ERROR_NONE); + + ret = hal_common_get_backend_symbol_name(HAL_MODULE_UNKNOWN, ret_end, MAX_BUFF); + EXPECT_TRUE(ret != TIZEN_ERROR_NONE); } TEST(CommonHaltest, test_check_backend_abi_version_invalid_parameter) { @@ -69,8 +75,9 @@ TEST(CommonHaltest, test_check_backend_abi_version_invalid_parameter) { } TEST(CommonHaltest, get_backend_library_name_unknown) { - const char *ret = hal_common_get_backend_library_name(HAL_MODULE_UNKNOWN); - EXPECT_TRUE(ret == nullptr); + char ret_name[MAX_BUFF] = {0, }; + int ret = hal_common_get_backend_library_name(HAL_MODULE_UNKNOWN, ret_name, MAX_BUFF); + EXPECT_TRUE(ret != TIZEN_ERROR_NONE); } class HalInfo { @@ -117,10 +124,10 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_COREGL, HAL_GROUP_GRAPHICS, HAL_LICENSE_UNKNOWN, - "HAL_MODULE_COREGL", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_COREGL", "", "", "", {}), HalInfo(HAL_MODULE_INPUT, HAL_GROUP_GRAPHICS, HAL_LICENSE_MIT, - "HAL_MODULE_INPUT", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_INPUT", "", "", "", {}), HalInfo(HAL_MODULE_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_AUDIO", "/hal/lib/libhal-backend-audio.so", @@ -150,13 +157,13 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_CODEC, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_CODEC", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_CODEC", "", "", "", {}), HalInfo(HAL_MODULE_USB_AUDIO, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_USB_AUDIO", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_USB_AUDIO", "", "", "", {}), HalInfo(HAL_MODULE_ALSAUCM, HAL_GROUP_MULTIMEDIA, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_ALSAUCM", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_ALSAUCM", "", "", "", {}), HalInfo(HAL_MODULE_BLUETOOTH, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_BLUETOOTH", "/hal/lib/libhal-backend-bluetooth.so", @@ -177,7 +184,7 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_NAN, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_NAN", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_NAN", "", "", "", {}), HalInfo(HAL_MODULE_NFC, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_NFC", "/hal/lib/libhal-backend-nfc.so", @@ -207,10 +214,10 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_MTP, HAL_GROUP_CONNECTIVITY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_MTP", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_MTP", "", "", "", {}), HalInfo(HAL_MODULE_TELEPHONY, HAL_GROUP_TELEPHONY, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_TELEPHONY", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_TELEPHONY", "", "", "", {}), HalInfo(HAL_MODULE_LOCATION, HAL_GROUP_LOCATION, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_LOCATION", "/hal/lib/libhal-backend-location.so", @@ -222,7 +229,7 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_COMMON, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_COMMON", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_COMMON", "", "", "", {}), HalInfo(HAL_MODULE_POWER, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_POWER", "/hal/lib/libhal-backend-power.so", @@ -243,7 +250,7 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, ), HalInfo(HAL_MODULE_PERIPHERAL, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, - "HAL_MODULE_PERIPHERAL", nullptr, nullptr, nullptr, {}), + "HAL_MODULE_PERIPHERAL", "", "", "", {}), HalInfo(HAL_MODULE_DEVICE_BATTERY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, "HAL_MODULE_DEVICE_BATTERY", "/hal/lib/libhal-backend-device-battery.so", @@ -346,11 +353,12 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, )); TEST_P(HalInfoMatchedTest, get_backend_library_name) { - const char *ret_library_name; - + char ret_library_name[MAX_BUFF] = {0, }; + int ret; auto info = GetParam(); - ret_library_name = hal_common_get_backend_library_name(info.module_); + ret = hal_common_get_backend_library_name(info.module_, ret_library_name, MAX_BUFF); + EXPECT_TRUE(ret == TIZEN_ERROR_NONE); #if defined(__aarch64__) EXPECT_STREQ(info.library_name_64bit_, ret_library_name) << "module name is " << info.module_name_; #else @@ -359,11 +367,12 @@ TEST_P(HalInfoMatchedTest, get_backend_library_name) { } TEST_P(HalInfoMatchedTest, test_symbol_name_module_matching) { - const char *ret_symbol_name = NULL; - + char ret_symbol_name[MAX_BUFF] = {0, }; + int ret; auto info = GetParam(); - ret_symbol_name = hal_common_get_backend_symbol_name(info.module_); + ret = hal_common_get_backend_symbol_name(info.module_, ret_symbol_name, MAX_BUFF); + EXPECT_TRUE(ret == TIZEN_ERROR_NONE); EXPECT_STREQ(ret_symbol_name, info.symbol_name_) << "module name is " << info.module_name_; } @@ -372,11 +381,11 @@ TEST_P(HalInfoMatchedTest, test_group_module_matching) { auto result_info = GetParam(); + _hal_api_conf_init(); info = _hal_api_conf_get_module_info(result_info.module_); 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_; - - _destroy_module_info(info); + _hal_api_conf_exit(); } TEST_P(HalInfoMatchedTest, test_license_module_matching) { @@ -384,11 +393,11 @@ TEST_P(HalInfoMatchedTest, test_license_module_matching) { auto result_info = GetParam(); + _hal_api_conf_init(); info = _hal_api_conf_get_module_info(result_info.module_); 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_; - - _destroy_module_info(info); + _hal_api_conf_exit(); } TEST_P(HalInfoMatchedTest, test_module_name_matching) { @@ -396,18 +405,18 @@ TEST_P(HalInfoMatchedTest, test_module_name_matching) { auto result_info = GetParam(); + _hal_api_conf_init(); info = _hal_api_conf_get_module_info(result_info.module_); 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_; - - _destroy_module_info(info); + _hal_api_conf_exit(); } TEST_P(HalInfoMatchedTest, test_check_backend_abi_version) { struct __hal_module_info *info = NULL; - - auto result_info = GetParam(); + + _hal_api_conf_init(); info = _hal_api_conf_get_module_info(result_info.module_); ASSERT_TRUE(info != nullptr); @@ -422,4 +431,5 @@ TEST_P(HalInfoMatchedTest, test_check_backend_abi_version) { EXPECT_EQ(meta_versions[i].platform_abi_version, tmp_version.platform_abi_version) << "module name is " << result_info.module_name_;; EXPECT_EQ(meta_versions[i].backend_min_abi_version, tmp_version.backend_min_abi_version) << "module name is " << result_info.module_name_;; } + _hal_api_conf_exit(); } diff --git a/include/hal-common.h b/include/hal-common.h index c270279..99ed3d2 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -166,18 +166,20 @@ static const char *const hal_module_string[] = { /** * @brief Get the backend library name according to the type of HAL module * @param[in] HAL module id among enum hal_moudle - * @return @c backend library name on success and don't need to be freed - * due to the global variable, otherwise NULL. + * @param[out] Backend Library name of HAL module + * @param[in] Arrary size of name[] + * @return @c 0 on success, otherwise a negative error value */ -const char *hal_common_get_backend_library_name(enum hal_module module); +int hal_common_get_backend_library_name(enum hal_module module, char *name, int size); /** * @brief Get the backend symbol name according to the type of HAL module * @param[in] HAL module id among enum hal_moudle - * @return @c backend library name on success and don't need to be freed - * due to the global variable, otherwise NULL. + * @param[out] Backend symbol name of HAL module + * @param[in] Arrary size of name[] + * @return @c 0 on success, otherwise a negative error value */ -const char *hal_common_get_backend_symbol_name(enum hal_module module); +int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size); /** * @brief Get the backend data according to the type of HAL module diff --git a/src/hal-api-common.c b/src/hal-api-common.c index be66273..a59bb52 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -34,60 +34,110 @@ 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 -const char *hal_common_get_backend_library_name(enum hal_module module) +int hal_common_get_backend_library_name(enum hal_module module, char *name, int size) { - char *library_name; + const char *library_name = NULL; struct __hal_module_info *info = NULL; + int ret; + int len_library_name; /* Check parameter whether is valid or not */ if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) { _E("Invalid parameter of HAL module (%d)\n", module); - return NULL; + return TIZEN_ERROR_INVALID_PARAMETER; } + if (_hal_api_conf_init()) + return TIZEN_ERROR_UNKNOWN; + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); - return NULL; + ret = TIZEN_ERROR_UNKNOWN; + goto out; } -#if defined(__aarch64__) - library_name = info->library_name_64bit; -#else - library_name = info->library_name; -#endif - + library_name = get_backend_library_name(info); if (!library_name) { _E("%s backend library name is NULL\n", info->module_name); - return NULL; + ret = TIZEN_ERROR_NONE; + goto out; + } + + len_library_name = strlen(library_name); + if (!name || (len_library_name + 1 > size)) { + ret = TIZEN_ERROR_UNKNOWN; + name = NULL; + goto out; } - return library_name; + strncpy(name, library_name, len_library_name); + name[len_library_name] = '\0'; + + ret = TIZEN_ERROR_NONE; +out: + _hal_api_conf_exit(); + + return ret; } EXPORT -const char *hal_common_get_backend_symbol_name(enum hal_module module) +int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size) { struct __hal_module_info *info = NULL; + char *symbol_name = NULL; + int ret; + int len_symbol_name; /* Check parameter whether is valid or not */ if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) { _E("Invalid paramer of HAL module (%d)\n", module); - return NULL; + return TIZEN_ERROR_INVALID_PARAMETER; } + if (_hal_api_conf_init()) + return TIZEN_ERROR_UNKNOWN; + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); - return NULL; + ret = TIZEN_ERROR_UNKNOWN; + goto out; + } + symbol_name = info->symbol_name; + if (!symbol_name) { + _E("%s backend symbol name is NULL\n", info->module_name); + ret = TIZEN_ERROR_NONE; + goto out; } - if (!info->symbol_name) { - _E("%s backend library name is NULL\n", info->module_name); - return NULL; + len_symbol_name = strlen(symbol_name); + if (!name || (len_symbol_name + 1 > size)) { + ret = TIZEN_ERROR_UNKNOWN; + name = NULL; + goto out; } + strncpy(name, symbol_name, len_symbol_name); + name[len_symbol_name] = '\0'; - return info->symbol_name; + ret = TIZEN_ERROR_NONE; +out: + _hal_api_conf_exit(); + + return ret; } EXPORT @@ -107,6 +157,9 @@ int hal_common_get_backend(enum hal_module module, void **data) G_LOCK(hal_common_lock); + if (_hal_api_conf_init()) + return TIZEN_ERROR_UNKNOWN; + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); @@ -119,7 +172,7 @@ int hal_common_get_backend(enum hal_module module, void **data) * Load HAL backend library at first loading time * when usage_count is 0. */ - library_name = hal_common_get_backend_library_name(module); + library_name = get_backend_library_name(info); if (!library_name) { _E("%s: Failed to get backend library name\n", info->module_name); @@ -135,7 +188,7 @@ int hal_common_get_backend(enum hal_module module, void **data) goto err; } - symbol_name = hal_common_get_backend_symbol_name(module); + symbol_name = info->symbol_name; if (!symbol_name) { _E("%s: Failed to get backend symbol name\n", info->module_name); @@ -195,6 +248,7 @@ int hal_common_get_backend(enum hal_module module, void **data) return TIZEN_ERROR_NONE; err_dlclose: + _hal_api_conf_exit(); dlclose(handle); err: G_UNLOCK(hal_common_lock); @@ -258,6 +312,10 @@ int hal_common_put_backend(enum hal_module module, void *data) info->library_backend = NULL; info->library_handle = NULL; + _hal_api_conf_exit(); + + ret = TIZEN_ERROR_NONE; + out: G_UNLOCK(hal_common_lock); return ret; @@ -269,6 +327,7 @@ int hal_common_check_backend_abi_version(enum hal_module module, { struct __hal_module_info *info = NULL; int i; + int ret; /* Check parameter whether is valid or not */ if (module <= HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) { @@ -283,23 +342,29 @@ int hal_common_check_backend_abi_version(enum hal_module module, return TIZEN_ERROR_INVALID_PARAMETER; } + if (_hal_api_conf_init()) + return TIZEN_ERROR_UNKNOWN; + info = _hal_api_conf_get_module_info(module); if (info == NULL) { _E("Failed to get HAL module(%d) information\n", module); - return TIZEN_ERROR_UNKNOWN; + ret = TIZEN_ERROR_UNKNOWN; + goto out; } /* Check abi_version whether is supported or not */ if (!info->hal_api) { _E("%s: Doesn't support HAL API\n", info->module_name); - return TIZEN_ERROR_INVALID_PARAMETER; + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto out; } if (!info->num_abi_versions || !info->abi_versions) { _E("%s: Doesn't have the ABI version information\n", info->module_name); - return TIZEN_ERROR_INVALID_PARAMETER; + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto out; } g_platform_curr_abi_version = _hal_api_conf_get_platform_abi_version(); @@ -314,12 +379,15 @@ int hal_common_check_backend_abi_version(enum hal_module module, data->backend_min_abi_version >= HAL_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); - return TIZEN_ERROR_INVALID_PARAMETER; + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto out; } if (abi_version <= data->platform_abi_version - && abi_version >= data->backend_min_abi_version) - return TIZEN_ERROR_NONE; + && abi_version >= data->backend_min_abi_version) { + ret = TIZEN_ERROR_NONE; + goto out; + } _E("%s: \'%s\' doesn't support \'%s\'\n", info->module_name, @@ -330,6 +398,9 @@ int hal_common_check_backend_abi_version(enum hal_module module, hal_abi_version_str[data->backend_min_abi_version], hal_abi_version_str[data->platform_abi_version]); } + ret = TIZEN_ERROR_INVALID_PARAMETER; - return TIZEN_ERROR_INVALID_PARAMETER; +out: + _hal_api_conf_exit(); + return ret; } diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index 0b4f5d8..9b8480b 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -34,22 +34,7 @@ static JsonObject *_root_object = NULL; static GHashTable *_module_hash = NULL; -static bool _initialized = false; - -void __attribute__ ((destructor)) _destroy_configuration(void); - -void _destroy_configuration(void) -{ - if (_parser) - g_object_unref(_parser); - - if (_module_hash) { - g_hash_table_remove_all(_module_hash); - g_hash_table_unref(_module_hash); - } - - _initialized = false; -} +static int _usage_count = 0; static enum hal_abi_version __convert_abi_version_str_to_enum(const char *abi_version) { int version; @@ -120,43 +105,6 @@ do { \ } } -static bool __init_configuration(void) -{ - JsonNode *root_node = NULL; - GError *error = NULL; - gboolean result; - - if (_initialized) - return _initialized; - - _parser = json_parser_new(); - result = json_parser_load_from_file(_parser, HAL_CONFIGURATION_PATH, &error); - if (result == FALSE) { - _E("Failed to parsing json configuration file : %s\n", error->message); - goto err; - } - - root_node = json_parser_get_root(_parser); - if (JSON_NODE_HOLDS_OBJECT(root_node) == FALSE) { - _E("There is no object in root node\n"); - goto err; - } - - _root_object = json_node_get_object(root_node); - _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); - - _initialized = true; - - return _initialized; - -err: - if (error) - g_error_free(error); - _destroy_configuration(); - - return _initialized; -} - static struct __hal_module_info *__create_hal_module_info(enum hal_module module, JsonObject *object) { struct __hal_module_info *info; @@ -233,13 +181,9 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module) GList *iter_list; const char *group_name = NULL; const char *module_name = NULL; - bool ret_initialized; - ret_initialized = __init_configuration(); - if (ret_initialized == false) { - _E("Failed to parse json information\n"); - goto ret; - } + if (!_root_object || !_module_hash) + return NULL; info = (struct __hal_module_info*)g_hash_table_lookup(_module_hash, GINT_TO_POINTER(module)); if (info != NULL) @@ -277,14 +221,71 @@ enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) if (_platform_abi_version != HAL_ABI_VERSION_END) return _platform_abi_version; - ret_initialized = __init_configuration(); - if (ret_initialized == false) { - _E("Failed to parser json file\n"); + if (!_root_object || !_module_hash) return HAL_ABI_VERSION_UNKNOWN; - } abi_version = json_object_get_string_member(_root_object, "PLATFORM_ABI_VERSION"); _platform_abi_version = __convert_abi_version_str_to_enum(abi_version); return _platform_abi_version; } + +__attribute__ ((visibility("default"))) +int _hal_api_conf_init(void) +{ + JsonNode *root_node = NULL; + GError *error = NULL; + gboolean result; + + if (_usage_count++ > 0) + return 0; + + _parser = json_parser_new(); + result = json_parser_load_from_file(_parser, HAL_CONFIGURATION_PATH, &error); + if (result == FALSE) { + _E("Failed to parsing json configuration file : %s\n", error->message); + goto err; + } + + root_node = json_parser_get_root(_parser); + if (JSON_NODE_HOLDS_OBJECT(root_node) == FALSE) { + _E("There is no object in root node\n"); + goto err; + } + + _root_object = json_node_get_object(root_node); + _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); + + return 0; + +err: + _usage_count--; + + if (error) + g_error_free(error); + if (_parser) + g_object_unref(_parser); + + if (_module_hash) { + g_hash_table_remove_all(_module_hash); + g_hash_table_unref(_module_hash); + } + + return -EINVAL; +} + +__attribute__ ((visibility("default"))) +void _hal_api_conf_exit(void) +{ + _usage_count--; + if (_usage_count != 0) + return; + + if (_parser) + g_object_unref(_parser); + + if (_module_hash) { + g_hash_table_remove_all(_module_hash); + g_hash_table_unref(_module_hash); + } +} diff --git a/src/hal-api-conf.h b/src/hal-api-conf.h index 4920483..f0d0cfd 100644 --- a/src/hal-api-conf.h +++ b/src/hal-api-conf.h @@ -30,6 +30,9 @@ extern "C" { #define HAL_CONFIGURATION_PATH tzplatform_mkpath(TZ_SYS_RO_ETC, "hal/hal-api.json") +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); enum hal_abi_version _hal_api_conf_get_platform_abi_version(void); -- 2.7.4 From 3ad8a3c3bb70302c4bcff37b3c64ba5f83661335 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 4 Feb 2021 18:34:12 +0900 Subject: [PATCH 04/16] halapi: Check whether HAL backend library exists or not Before loading the library, check wehter HAL backend library exists or not into /hal/lib/ or /hal/lib64/. Change-Id: Ibf5c1fd493f785ac8e916eabb285cfad68ea19b0 Signed-off-by: Chanwoo Choi --- src/hal-api-common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hal-api-common.c b/src/hal-api-common.c index a59bb52..cf5c3fd 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -180,9 +180,17 @@ int hal_common_get_backend(enum hal_module module, void **data) goto err; } + ret = access(library_name, F_OK); + if (ret < 0) { + _E("%s: Failed to find backend library (%s)\n", + info->module_name, library_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + handle = dlopen(library_name, RTLD_LAZY); if (!handle) { - _E("%s: Failed to load shared library (%s)\n", + _E("%s: Failed to load backend library (%s)\n", info->module_name, dlerror()); ret = TIZEN_ERROR_INVALID_PARAMETER; goto err; -- 2.7.4 From 7f21e36eb324e60720238382a3189459b227d707 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 2 Feb 2021 19:22:20 +0900 Subject: [PATCH 05/16] haltests: Add hal-common-haltests skeleton code This is a commit to separate hal-common-haltests and uniittests for testing in the target. After the commit is applied, unittest is verified at gbs build time. The hal-common-haltest verifies the function running on the target and is packaged in rpm to generate the result. Change-Id: I6d298e4940370188c8890b4331e7fa952a20fd1b Signed-off-by: Seungha Son --- CMakeLists.txt | 2 +- packaging/hal-api-common.spec | 16 ++++++++-- tests/CMakeLists.txt | 2 ++ tests/haltests/CMakeLists.txt | 24 +++++++++++++++ tests/haltests/test_hal.cc | 43 +++++++++++++++++++++++++++ {haltests/src => tests/haltests}/test_main.cc | 0 {haltests => tests/unittest}/CMakeLists.txt | 4 +-- {haltests/src => tests/unittest}/test_hal.cc | 2 +- tests/unittest/test_main.cc | 37 +++++++++++++++++++++++ 9 files changed, 124 insertions(+), 6 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/haltests/CMakeLists.txt create mode 100644 tests/haltests/test_hal.cc rename {haltests/src => tests/haltests}/test_main.cc (100%) rename {haltests => tests/unittest}/CMakeLists.txt (88%) rename {haltests/src => tests/unittest}/test_hal.cc (99%) create mode 100644 tests/unittest/test_main.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 5409058..60a8c50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,4 +52,4 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hal-api.json DESTINATION /etc/hal) -ADD_SUBDIRECTORY(haltests) +ADD_SUBDIRECTORY(tests) diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec index 4f5bfa6..8ef3a81 100644 --- a/packaging/hal-api-common.spec +++ b/packaging/hal-api-common.spec @@ -1,5 +1,6 @@ %define name hal-api-common %define devel_name hal-api-common-devel +%define test_name hal-api-common-haltests ### main package ######### Name: %{name} @@ -33,6 +34,14 @@ Requires: %{name} = %{version}-%{release} %description -n %{devel_name} %{name} Interface for product vendor developer +### test package ######### +%package -n %{test_name} +Summary: tests for hal-api-common +Requires: hal-api-common = %{version} + +%description -n %{test_name} +Haltests for hal-api-common + ### build and install ######### %prep %setup -q @@ -44,7 +53,7 @@ cp %{SOURCE1} . make %{?jobs:-j%jobs} %check -(cd haltests && LD_LIBRARY_PATH=../ ctest -V) +(cd tests/unittest && LD_LIBRARY_PATH=../../ ctest -V) %install rm -rf %{buildroot} @@ -60,7 +69,7 @@ rm -rf %{buildroot} %post /sbin/ldconfig -if [ ! -d %{TZ_SYS_ETC} ] +if [ ! -d %{TZ_SYS_RO_ETC} ] then mkdir -p %{TZ_SYS_RO_ETC}/hal fi @@ -82,3 +91,6 @@ fi %defattr(-,root,root,-) %{_includedir}/hal/*.h %{_libdir}/pkgconfig/*.pc + +%files -n %{test_name} +%{_bindir}/hal/common-haltests diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..adf4d47 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_SUBDIRECTORY(unittest) +ADD_SUBDIRECTORY(haltests) diff --git a/tests/haltests/CMakeLists.txt b/tests/haltests/CMakeLists.txt new file mode 100644 index 0000000..0d4cbd4 --- /dev/null +++ b/tests/haltests/CMakeLists.txt @@ -0,0 +1,24 @@ +SET(HAL_COMMON_HALTEST "common-haltests") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Werror") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14 -Wall -Werror") + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ HALTEST_SRCS) +ADD_EXECUTABLE(${HAL_COMMON_HALTEST} ${HALTEST_SRCS}) + +TARGET_INCLUDE_DIRECTORIES(${HAL_COMMON_HALTEST} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/../../include" +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(common-haltests_pkgs REQUIRED gmock) + +FOREACH(flag ${common-haltests_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +TARGET_LINK_LIBRARIES(${HAL_COMMON_HALTEST} ${common-haltests_pkgs_LDFLAGS} ${PROJECT_NAME}) +SET_TARGET_PROPERTIES(${HAL_COMMON_HALTEST} PROPERTIES COMPILE_FLAGS "-fPIE -fvisibility=default") +SET_TARGET_PROPERTIES(${HAL_COMMON_HALTEST} PROPERTIES LINK_FLAGS "-pie") + +INSTALL(TARGETS ${HAL_COMMON_HALTEST} DESTINATION ${EXEC_PREFIX}/hal/) diff --git a/tests/haltests/test_hal.cc b/tests/haltests/test_hal.cc new file mode 100644 index 0000000..685a91c --- /dev/null +++ b/tests/haltests/test_hal.cc @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include +#include + +#include "hal-common.h" +#include "hal-common-interface.h" + +#include "../../src/hal-api-conf.h" +#include "../../src/common.h" + +using namespace std; + +class CommonHaltest : public testing::Test { + public: + CommonHaltest() {} + virtual ~CommonHaltest() {} + virtual void SetUp() {} + virtual void TearDown() {} +}; + +TEST(CommonHaltest, test_symbol_name_invalid_module) { +} + diff --git a/haltests/src/test_main.cc b/tests/haltests/test_main.cc similarity index 100% rename from haltests/src/test_main.cc rename to tests/haltests/test_main.cc diff --git a/haltests/CMakeLists.txt b/tests/unittest/CMakeLists.txt similarity index 88% rename from haltests/CMakeLists.txt rename to tests/unittest/CMakeLists.txt index 2ed429c..2ff5c7e 100644 --- a/haltests/CMakeLists.txt +++ b/tests/unittest/CMakeLists.txt @@ -4,11 +4,11 @@ SET(HAL_COMMON_UNITTEST "common-unittest") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Werror") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14 -Wall -Werror") -AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src UNITTEST_SRCS) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ UNITTEST_SRCS) ADD_EXECUTABLE(${HAL_COMMON_UNITTEST} ${UNITTEST_SRCS}) TARGET_INCLUDE_DIRECTORIES(${HAL_COMMON_UNITTEST} PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}/../include" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include" ) INCLUDE(FindPkgConfig) diff --git a/haltests/src/test_hal.cc b/tests/unittest/test_hal.cc similarity index 99% rename from haltests/src/test_hal.cc rename to tests/unittest/test_hal.cc index ddadc56..c195440 100644 --- a/haltests/src/test_hal.cc +++ b/tests/unittest/test_hal.cc @@ -35,7 +35,7 @@ using namespace std; extern "C" const char *tzplatform_mkpath( enum tzplatform_variable id, const char *path) { - return "../hal-api.json"; + return "../../hal-api.json"; } class CommonHaltest : public testing::Test { diff --git a/tests/unittest/test_main.cc b/tests/unittest/test_main.cc new file mode 100644 index 0000000..c2eb730 --- /dev/null +++ b/tests/unittest/test_main.cc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +int main(int argc, char** argv) { + int ret = -1; + + try { + testing::InitGoogleTest(&argc, argv); + } catch(...) { + std::cout << "Exception occurred" << std::endl; + } + + try { + ret = RUN_ALL_TESTS(); + } catch (const ::testing::internal::GoogleTestFailureException& e) { + ret = -1; + std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl; + } + + return ret; +} -- 2.7.4 From a8efa589e52274787fa205406d9317ceec59fdb1 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Wed, 20 Jan 2021 10:33:41 +0900 Subject: [PATCH 06/16] halapi: Add new DEVICE_MEMORY module This module fetches memory usage information whose nodepath or format is dependent to target, such as gpu, gem information. Change-Id: Ib10f201c91a190226991605771b9025642d4a451 Signed-off-by: Youngjae Cho --- hal-api.json | 14 ++++++++++++++ include/hal-common.h | 2 ++ tests/unittest/test_hal.cc | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hal-api.json b/hal-api.json index d9167dd..a2b172f 100644 --- a/hal-api.json +++ b/hal-api.json @@ -430,6 +430,20 @@ "backend_min_abi_version" :"HAL_ABI_VERSION_TIZEN_6_5" } ] + }, + { + "group" :"HAL_GROUP_SYSTEM", + "module" :"HAL_MODULE_DEVICE_MEMORY", + "license" :"APACHE_2_0", + "library_name" :"/hal/lib/libhal-backend-device-memory.so", + "library_name_64bit" :"/hal/lib64/libhal-backend-device-memory.so", + "symbol_name" :"hal_backend_device_memory_data", + "abi_versions" :[ + { + "platform_abi_version" :"HAL_ABI_VERSION_TIZEN_6_5", + "backend_min_abi_version" :"HAL_ABI_VERSION_TIZEN_6_5" + } + ] } ] } diff --git a/include/hal-common.h b/include/hal-common.h index 99ed3d2..7402f05 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -102,6 +102,7 @@ enum hal_module { HAL_MODULE_DEVICE_THERMAL, HAL_MODULE_DEVICE_USB_GADGET, HAL_MODULE_DEVICE_HAPTIC, + HAL_MODULE_DEVICE_MEMORY, /* * TODO: If need to add new module, have to add it below @@ -159,6 +160,7 @@ static const char *const hal_module_string[] = { [HAL_MODULE_DEVICE_THERMAL] = "HAL_MODULE_DEVICE_THERMAL", [HAL_MODULE_DEVICE_USB_GADGET] = "HAL_MODULE_DEVICE_USB_GADGET", [HAL_MODULE_DEVICE_HAPTIC] = "HAL_MODULE_DEVICE_HAPTIC", + [HAL_MODULE_DEVICE_MEMORY] = "HAL_MODULE_DEVICE_MEMORY", [HAL_MODULE_END] = "HAL_MODULE_END", }; diff --git a/tests/unittest/test_hal.cc b/tests/unittest/test_hal.cc index c195440..9c8ae7f 100644 --- a/tests/unittest/test_hal.cc +++ b/tests/unittest/test_hal.cc @@ -349,7 +349,16 @@ INSTANTIATE_TEST_CASE_P(CommonHaltest, .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 }} - ) + ), + + HalInfo(HAL_MODULE_DEVICE_MEMORY, HAL_GROUP_SYSTEM, HAL_LICENSE_APACHE_2_0, + "HAL_MODULE_DEVICE_MEMORY", "/hal/lib/libhal-backend-device-memory.so", + "/hal/lib64/libhal-backend-device-memory.so", "hal_backend_device_memory_data", + vector{{ + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5 + }} + ) )); TEST_P(HalInfoMatchedTest, get_backend_library_name) { -- 2.7.4 From 44d23c1850016504ddd5c2f48c1141dc7983e1cc Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Tue, 9 Feb 2021 15:29:06 +0900 Subject: [PATCH 07/16] systemd: Add /hal/lib/firmware directory to kernel firmware path Before systemd starts any services, execute this command to add /hal/lib/firmware path. - echo "/hal/lib/firmware" > /sys/module/firmware_class/parameters/path Change-Id: I972c0add7709975f595220bb6c108d509e005048 Signed-off-by: INSUN PYO Signed-off-by: Chanwoo Choi --- packaging/hal-api-common.spec | 10 +++++++--- packaging/systemd-hal-firmware-generator | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 packaging/systemd-hal-firmware-generator diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec index 8ef3a81..87a46cd 100644 --- a/packaging/hal-api-common.spec +++ b/packaging/hal-api-common.spec @@ -12,6 +12,7 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest Source2: libhal-api.conf +Source3: systemd-hal-firmware-generator Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -22,6 +23,8 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(json-glib-1.0) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(systemd) + %description %{name} interface @@ -59,9 +62,9 @@ make %{?jobs:-j%jobs} rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d/ mkdir -p %{buildroot}/hal -install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/ld.so.conf.d/ +install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/ld.so.conf.d/libhal-api.conf +install -D -m 0755 %{SOURCE3} %{buildroot}%{_systemdgeneratordir}/systemd-hal-firmware-generator %clean rm -rf %{buildroot} @@ -82,9 +85,10 @@ fi %license LICENSE %manifest %{name}.manifest %defattr(-,root,root,-) +%dir /hal %{_libdir}/hal/*.so* %{_sysconfdir}/ld.so.conf.d/libhal-api.conf -/hal/ +%{_systemdgeneratordir}/systemd-hal-firmware-generator %attr(644,root,root) %{TZ_SYS_RO_ETC}/hal/hal-api.json %files -n %{devel_name} diff --git a/packaging/systemd-hal-firmware-generator b/packaging/systemd-hal-firmware-generator new file mode 100644 index 0000000..b8f3dd7 --- /dev/null +++ b/packaging/systemd-hal-firmware-generator @@ -0,0 +1,5 @@ +#!/bin/sh + +PATH=/bin:/usr/bin:/sbin:/usr/sbin + +echo "/hal/lib/firmware" > /sys/module/firmware_class/parameters/path -- 2.7.4 From d4f17c20ff58d35f66a6795c22dbc37a19998647 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 17 Feb 2021 10:58:29 +0900 Subject: [PATCH 08/16] halapi: Move all extra files into packaging directory Change-Id: I5e09bfad0ee0d7f824a28198c2f35ad1727736da Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 8 +++++--- hal-api-common.pc => packaging/hal-api-common.pc.in | 0 hal-api.json => packaging/hal-api.json | 0 tests/unittest/test_hal.cc | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) rename hal-api-common.pc => packaging/hal-api-common.pc.in (100%) rename hal-api.json => packaging/hal-api.json (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60a8c50..ae9fd01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,13 +43,15 @@ TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -Wl,-z,nodelete,--no SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) -CONFIGURE_FILE( ${PROJECT_NAME}.pc ${PROJECT_NAME}.pc @ONLY) +CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc + @ONLY) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${INCLUDEDIR}/hal FILES_MATCHING PATTERN "*.h") -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hal-api.json DESTINATION /etc/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/hal-api.json DESTINATION /etc/hal) ADD_SUBDIRECTORY(tests) diff --git a/hal-api-common.pc b/packaging/hal-api-common.pc.in similarity index 100% rename from hal-api-common.pc rename to packaging/hal-api-common.pc.in diff --git a/hal-api.json b/packaging/hal-api.json similarity index 100% rename from hal-api.json rename to packaging/hal-api.json diff --git a/tests/unittest/test_hal.cc b/tests/unittest/test_hal.cc index 9c8ae7f..dc3c851 100644 --- a/tests/unittest/test_hal.cc +++ b/tests/unittest/test_hal.cc @@ -35,7 +35,7 @@ using namespace std; extern "C" const char *tzplatform_mkpath( enum tzplatform_variable id, const char *path) { - return "../../hal-api.json"; + return "../../packaging/hal-api.json"; } class CommonHaltest : public testing::Test { -- 2.7.4 From fbd104fef057f3ce362163de21a93e36ccd0028d Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Wed, 17 Feb 2021 11:25:56 +0900 Subject: [PATCH 09/16] halapi: Add macros.hal-api to add new rpm macro for /hal Change-Id: Iae582e0d2b5912837beb1608bc4f0a8eba91595b Signed-off-by: Chanwoo Choi --- packaging/hal-api-common.spec | 3 +++ packaging/macros.hal-api | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 packaging/macros.hal-api diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec index 87a46cd..b381841 100644 --- a/packaging/hal-api-common.spec +++ b/packaging/hal-api-common.spec @@ -13,6 +13,7 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest Source2: libhal-api.conf Source3: systemd-hal-firmware-generator +Source4: macros.hal-api Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -65,6 +66,7 @@ rm -rf %{buildroot} mkdir -p %{buildroot}/hal install -D -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/ld.so.conf.d/libhal-api.conf install -D -m 0755 %{SOURCE3} %{buildroot}%{_systemdgeneratordir}/systemd-hal-firmware-generator +install -D -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/rpm/macros.hal-api %clean rm -rf %{buildroot} @@ -95,6 +97,7 @@ fi %defattr(-,root,root,-) %{_includedir}/hal/*.h %{_libdir}/pkgconfig/*.pc +%{_sysconfdir}/rpm/macros.hal-api %files -n %{test_name} %{_bindir}/hal/common-haltests diff --git a/packaging/macros.hal-api b/packaging/macros.hal-api new file mode 100644 index 0000000..8d172c2 --- /dev/null +++ b/packaging/macros.hal-api @@ -0,0 +1,9 @@ +# RPM macros for /hal directory + +%_hal_prefix /hal +%_hal_bindir %{_hal_prefix}/bin +%_hal_libdir %{_hal_prefix}/%{_lib} +%_hal_includedir %{_hal_prefix}/include +%_hal_sysconfdir %{_hal_prefix}%{_sysconfdir} +%_hal_datadir %{_hal_prefix}/share +%_hal_licensedir %{_hal_prefix}/share/licenses -- 2.7.4 From 21e5da8a27efb24104cc3a5abc29eac979e61e8e Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 23 Feb 2021 23:58:19 +0900 Subject: [PATCH 10/16] halapi: Remove circular dependency between packages Change json parsing library from json-glib to json-c because when using json-glib, the circular dependency problem between dependent rpm is occured. By changing the json-parser-lib from json-glib to json-c, the circular dependency was removed and the problem was solved. Change-Id: I694e05649a875ea8a3af8128efc5be7c88282830 Signed-off-by: Seungha Son --- CMakeLists.txt | 2 +- packaging/hal-api-common.spec | 2 +- src/hal-api-conf.c | 105 ++++++++++++++++++------------------------ 3 files changed, 47 insertions(+), 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae9fd01..df8d137 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ SET(PKG_MODULES dlog gio-2.0 glib-2.0 - json-glib-1.0 + json-c libtzplatform-config ) diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec index b381841..223887f 100644 --- a/packaging/hal-api-common.spec +++ b/packaging/hal-api-common.spec @@ -21,7 +21,7 @@ BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(json-glib-1.0) +BuildRequires: pkgconfig(json-c) BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(systemd) diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index 9b8480b..46d1be6 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -18,7 +18,9 @@ #include #include -#include + +#include +#include #include "hal-common.h" #include "hal-common-interface.h" @@ -29,8 +31,7 @@ static enum hal_abi_version _platform_abi_version = HAL_ABI_VERSION_END; -static JsonParser *_parser = NULL; -static JsonObject *_root_object = NULL; +static json_object *_json_file_object = NULL; static GHashTable *_module_hash = NULL; @@ -105,13 +106,22 @@ do { \ } } -static struct __hal_module_info *__create_hal_module_info(enum hal_module module, JsonObject *object) +static const char * __get_json_object_string(json_object *object, const char *key) +{ + json_object *temp_object = NULL; + + json_object_object_get_ex(object, key, &temp_object); + return json_object_get_string(temp_object); +} + +static struct __hal_module_info *__create_hal_module_info(enum hal_module module, json_object *object) { struct __hal_module_info *info; - JsonArray *abi_versions_array = NULL; GList *abi_list = NULL; GList *iter_list = NULL; int list_index = 0; + json_object *abi_versions_array; + json_object *tmp_object; const char *tmp; info = (struct __hal_module_info *)calloc(1, sizeof(struct __hal_module_info)); @@ -123,52 +133,47 @@ static struct __hal_module_info *__create_hal_module_info(enum hal_module module info->module = module; info->module_name = g_strdup(__convert_module_to_string(module)); - tmp = json_object_get_string_member(object, "group"); + tmp = __get_json_object_string(object, "group"); info->group = __convert_group_str_to_enum(tmp); - tmp = json_object_get_string_member(object, "license"); + tmp = __get_json_object_string(object, "license"); info->license = __convert_license_str_to_enum(tmp); - info->library_name = g_strdup(json_object_get_string_member(object, "library_name")); - info->library_name_64bit = g_strdup(json_object_get_string_member(object, "library_name_64bit")); - info->symbol_name = g_strdup(json_object_get_string_member(object, "symbol_name")); + info->library_name = g_strdup(__get_json_object_string(object, "library_name")); + info->library_name_64bit = g_strdup(__get_json_object_string(object, "library_name_64bit")); + info->symbol_name = g_strdup(__get_json_object_string(object, "symbol_name")); if (info->library_name && info->library_name_64bit && info->symbol_name) info->hal_api = true; - abi_versions_array = json_object_get_array_member(object, "abi_versions"); - if (abi_versions_array == NULL) + json_object_object_get_ex(object, "abi_versions", &abi_versions_array); + if (json_object_get_type(abi_versions_array) != json_type_array) return info; - abi_list = json_array_get_elements(abi_versions_array); - info->num_abi_versions = g_list_length(abi_list); + info->num_abi_versions = json_object_array_length(abi_versions_array); if (info->num_abi_versions > 0) { info->abi_versions = (struct hal_abi_version_match*)calloc(info->num_abi_versions, sizeof(struct hal_abi_version_match)); if (info->abi_versions == NULL) { _E("Out of Memory\n"); _destroy_module_info(info); - g_list_free(abi_list); return NULL; } - for (iter_list = abi_list; iter_list != NULL; iter_list = iter_list->next) { - JsonObject *tmp_object = json_node_get_object(iter_list->data); + for (int i = 0; i < info->num_abi_versions; i++) { + json_object *abi_object = json_object_array_get_idx(abi_versions_array, i); - tmp = json_object_get_string_member(tmp_object, "platform_abi_version"); + tmp = __get_json_object_string(abi_object, "platform_abi_version"); info->abi_versions[list_index].platform_abi_version = __convert_abi_version_str_to_enum(tmp); - tmp = json_object_get_string_member(tmp_object, "backend_min_abi_version"); + tmp = __get_json_object_string(abi_object, "backend_min_abi_version"); info->abi_versions[list_index].backend_min_abi_version = __convert_abi_version_str_to_enum(tmp); list_index++; } } - if (abi_list) - g_list_free(abi_list); - return info; } @@ -176,28 +181,26 @@ __attribute__ ((visibility("default"))) struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module) { struct __hal_module_info *info = NULL; - JsonArray *module_array = NULL; - GList *module_list = NULL; - GList *iter_list; + json_object *module_array_object = NULL; const char *group_name = NULL; const char *module_name = NULL; + int i; - if (!_root_object || !_module_hash) + if (!_json_file_object || !_module_hash) return NULL; info = (struct __hal_module_info*)g_hash_table_lookup(_module_hash, GINT_TO_POINTER(module)); if (info != NULL) return info; - module_array = json_object_get_array_member(_root_object, "MODULE_INFO"); - module_list = json_array_get_elements(module_array); + json_object_object_get_ex(_json_file_object, "MODULE_INFO", &module_array_object); module_name = __convert_module_to_string(module); - for (iter_list = module_list; iter_list != NULL; iter_list = iter_list->next) { - JsonObject *tmp_object = json_node_get_object(iter_list->data); - const char *value = json_object_get_string_member(tmp_object, "module"); + for (i = 0; i < json_object_array_length(module_array_object); i++) { + json_object *temp_object = json_object_array_get_idx(module_array_object, i); + const char *value = __get_json_object_string(temp_object, "module"); if (g_strcmp0(value, module_name) == 0) { - info = __create_hal_module_info(module, tmp_object); + info = __create_hal_module_info(module, temp_object); if (info == NULL) _E("Failed to create hal module info\n"); else @@ -206,10 +209,6 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module) } } -ret: - if (module_list) - g_list_free(module_list); - return info; } @@ -217,14 +216,15 @@ enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) { const char *abi_version = NULL; bool ret_initialized; + json_object *platform_obj = NULL; if (_platform_abi_version != HAL_ABI_VERSION_END) return _platform_abi_version; - if (!_root_object || !_module_hash) + if (!_json_file_object || !_module_hash) return HAL_ABI_VERSION_UNKNOWN; - abi_version = json_object_get_string_member(_root_object, "PLATFORM_ABI_VERSION"); + abi_version = __get_json_object_string(_json_file_object, "PLATFORM_ABI_VERSION"); _platform_abi_version = __convert_abi_version_str_to_enum(abi_version); return _platform_abi_version; @@ -233,27 +233,15 @@ enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) __attribute__ ((visibility("default"))) int _hal_api_conf_init(void) { - JsonNode *root_node = NULL; - GError *error = NULL; - gboolean result; - if (_usage_count++ > 0) return 0; - _parser = json_parser_new(); - result = json_parser_load_from_file(_parser, HAL_CONFIGURATION_PATH, &error); - if (result == FALSE) { - _E("Failed to parsing json configuration file : %s\n", error->message); - goto err; - } - - root_node = json_parser_get_root(_parser); - if (JSON_NODE_HOLDS_OBJECT(root_node) == FALSE) { - _E("There is no object in root node\n"); + _json_file_object = json_object_from_file(HAL_CONFIGURATION_PATH); + if (_json_file_object == NULL) { + _E("Failed to parsing json configuration file : %s\n", json_util_get_last_err()); goto err; } - _root_object = json_node_get_object(root_node); _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); return 0; @@ -261,11 +249,6 @@ int _hal_api_conf_init(void) err: _usage_count--; - if (error) - g_error_free(error); - if (_parser) - g_object_unref(_parser); - if (_module_hash) { g_hash_table_remove_all(_module_hash); g_hash_table_unref(_module_hash); @@ -281,8 +264,10 @@ void _hal_api_conf_exit(void) if (_usage_count != 0) return; - if (_parser) - g_object_unref(_parser); + if (_json_file_object) { + json_object_put(_json_file_object); + _json_file_object = NULL; + } if (_module_hash) { g_hash_table_remove_all(_module_hash); -- 2.7.4 From 7827e46be2462a45b7645e89654acd6e541ddf61 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 8 Mar 2021 18:44:47 +0900 Subject: [PATCH 11/16] halapi: Fix unlock issue when failed to parse hal-api.json There is deadlock issue without unlocking the mutex when error happen. So that fix the unlock issue. Change-Id: I4581202808f9b6f9b8b36c452663be1e59c4e7af Signed-off-by: Chanwoo Choi --- src/hal-api-common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hal-api-common.c b/src/hal-api-common.c index cf5c3fd..4bf3dc4 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -157,8 +157,10 @@ int hal_common_get_backend(enum hal_module module, void **data) G_LOCK(hal_common_lock); - if (_hal_api_conf_init()) - return TIZEN_ERROR_UNKNOWN; + if (_hal_api_conf_init()) { + ret = TIZEN_ERROR_UNKNOWN; + goto err; + } info = _hal_api_conf_get_module_info(module); if (info == NULL) { -- 2.7.4 From f8c7d65a404d22e0020bb5f05210ef15dcd6ff49 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 9 Mar 2021 16:44:06 +0900 Subject: [PATCH 12/16] halapi: Add more information to improve the readability for dlog In order to improve the readability, add more information with library name and usage_count for multi-thread environment. Change-Id: I71b3f68789556ccdf77275ba1932b39b1e7378f5 Signed-off-by: Chanwoo Choi --- src/hal-api-common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 4bf3dc4..cc2f926 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -249,11 +249,12 @@ int hal_common_get_backend(enum hal_module module, void **data) goto err_dlclose; } - _I("%s: Get HAL backend: name(%s)/vendor(%s)\n", - info->module_name, backend->name, backend->vendor); - info->usage_count++; + _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); + G_UNLOCK(hal_common_lock); return TIZEN_ERROR_NONE; @@ -313,8 +314,9 @@ int hal_common_put_backend(enum hal_module module, void *data) } } - _I("%s: Put HAL backend: name(%s)/vendor(%s)\n", - info->module_name, backend->name, backend->vendor); + _I("%s: Put HAL backend: name(%s)/vendor(%s)/library(%s)/count(%d)\n", + info->module_name, backend->name, backend->vendor, + get_backend_library_name(info), info->usage_count); if (handle) dlclose(handle); -- 2.7.4 From 714866a63f2349895f7ceab173a08df0789ca530 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 9 Mar 2021 14:01:59 +0900 Subject: [PATCH 13/16] halapi: Add new get_backend and put_backend with specific library name Basically, hal_common_get_backend has used the promised libray name for HAL backend like 'libhal-backend-[moodule name].so'. But, there are some requirements that need to select the one HAL backend among the multiple HAL backends on same device according to the role of use. So that add the following two functions with new library_name argument. - int hal_common_get_backend_with_library_name(enum hal_module module, void **data, const char *library_name); - int hal_common_put_backend_with_library_name(enum hal_module module, void *data, const char *library_name); [Constraints of library name] This library_name argument must keep the naming rule as following: - 'libhal-backend-[moodule name]-[extented name].so Change-Id: Ia6c69597a718f5a4ae9de2f879f7c4337874b1ee Signed-off-by: Chanwoo Choi --- include/hal-common.h | 21 +++++++++++ src/common.h | 13 +++++++ src/hal-api-common.c | 76 +++++++++++++++++++++++---------------- src/hal-api-conf.c | 88 ++++++++++++++++++++++++++++++++++++++++++---- src/hal-api-conf.h | 3 +- tests/unittest/test_hal.cc | 8 ++--- 6 files changed, 167 insertions(+), 42 deletions(-) diff --git a/include/hal-common.h b/include/hal-common.h index 7402f05..369a78a 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -201,6 +201,27 @@ int hal_common_get_backend(enum hal_module module, void **data); 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 diff --git a/src/common.h b/src/common.h index f19e56c..e3463e2 100644 --- a/src/common.h +++ b/src/common.h @@ -72,8 +72,21 @@ struct __hal_module_info { 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 diff --git a/src/hal-api-common.c b/src/hal-api-common.c index cc2f926..9914c08 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -34,19 +34,6 @@ 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) { @@ -64,7 +51,7 @@ int hal_common_get_backend_library_name(enum hal_module module, char *name, int 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; @@ -111,7 +98,7 @@ int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int s 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; @@ -140,13 +127,13 @@ out: 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 */ @@ -162,9 +149,13 @@ int hal_common_get_backend(enum hal_module module, void **data) 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; } @@ -174,23 +165,23 @@ int hal_common_get_backend(enum hal_module module, void **data) * 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()); @@ -253,7 +244,7 @@ int hal_common_get_backend(enum hal_module module, void **data) _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; @@ -266,8 +257,7 @@ err: 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; @@ -282,7 +272,7 @@ int hal_common_put_backend(enum hal_module module, void *data) 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; @@ -334,6 +324,32 @@ out: } 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) { @@ -357,7 +373,7 @@ int hal_common_check_backend_abi_version(enum hal_module module, 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; diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index 46d1be6..87b4c0c 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -90,13 +90,8 @@ do { \ } 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); @@ -177,8 +172,7 @@ static struct __hal_module_info *__create_hal_module_info(enum hal_module module 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; @@ -212,6 +206,86 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module) 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; diff --git a/src/hal-api-conf.h b/src/hal-api-conf.h index f0d0cfd..c1e7eb9 100644 --- a/src/hal-api-conf.h +++ b/src/hal-api-conf.h @@ -33,7 +33,8 @@ extern "C" { 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); diff --git a/tests/unittest/test_hal.cc b/tests/unittest/test_hal.cc index dc3c851..1700b6a 100644 --- a/tests/unittest/test_hal.cc +++ b/tests/unittest/test_hal.cc @@ -391,7 +391,7 @@ TEST_P(HalInfoMatchedTest, test_group_module_matching) { 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(); @@ -403,7 +403,7 @@ TEST_P(HalInfoMatchedTest, test_license_module_matching) { 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(); @@ -415,7 +415,7 @@ TEST_P(HalInfoMatchedTest, test_module_name_matching) { 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(); @@ -426,7 +426,7 @@ TEST_P(HalInfoMatchedTest, test_check_backend_abi_version) { 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 versions = result_info.versions_; -- 2.7.4 From dd82d44aed96afd79b673029957cc45165643d79 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 15 Mar 2021 15:02:54 +0900 Subject: [PATCH 14/16] halapi: Replace hal-api.json with hal-api-list.h When using hal-api.json, the segmentation falut happen when trying to use json-c library because of some library including json-c statically. In order to fix this issue rapily, use the 'hal-api-list.h' temporarily instead of 'hal-api.json'. After fixing this issue, revert this patch for using 'hal-api.json'. Change-Id: I22ba800b536e974879cbfa758f9160b896813c63 Signed-off-by: Chanwoo Choi --- include/hal-common.h | 2 + src/hal-api-conf.c | 83 ++++-- src/hal-api-list.h | 706 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 764 insertions(+), 27 deletions(-) create mode 100644 src/hal-api-list.h diff --git a/include/hal-common.h b/include/hal-common.h index 369a78a..45c4a10 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -112,6 +112,7 @@ enum hal_module { HAL_MODULE_END, }; +#ifdef HAL_API_CONF_JSON static const char *const hal_module_string[] = { [HAL_MODULE_UNKNOWN] = "HAL_MODULE_UNKNOWN", @@ -164,6 +165,7 @@ static const char *const hal_module_string[] = { [HAL_MODULE_END] = "HAL_MODULE_END", }; +#endif /** * @brief Get the backend library name according to the type of HAL module diff --git a/src/hal-api-conf.c b/src/hal-api-conf.c index 87b4c0c..4465fe6 100644 --- a/src/hal-api-conf.c +++ b/src/hal-api-conf.c @@ -25,18 +25,44 @@ #include "hal-common.h" #include "hal-common-interface.h" -#include "hal-api-conf.h" - #include "common.h" +#include "hal-api-conf.h" +#include "hal-api-list.h" +#ifdef HAL_API_CONF_JSON static enum hal_abi_version _platform_abi_version = HAL_ABI_VERSION_END; static json_object *_json_file_object = NULL; +#endif static GHashTable *_module_hash = NULL; static int _usage_count = 0; +__attribute__ ((visibility("default"))) +void _destroy_module_info(gpointer data) +{ +#define SAFE_FREE_AND_NULL(x) \ +do { \ + if (x) { \ + free(x); \ + x = NULL; \ + } \ +} while (0); + + struct __hal_module_info *info = (struct __hal_module_info *)data; + + if (info) { + SAFE_FREE_AND_NULL(info->module_name); + SAFE_FREE_AND_NULL(info->library_name); + SAFE_FREE_AND_NULL(info->library_name_64bit); + SAFE_FREE_AND_NULL(info->symbol_name); + SAFE_FREE_AND_NULL(info->abi_versions); + SAFE_FREE_AND_NULL(info); + } +} + +#ifdef HAL_API_CONF_JSON static enum hal_abi_version __convert_abi_version_str_to_enum(const char *abi_version) { int version; for (version = HAL_ABI_VERSION_UNKNOWN + 1; version < HAL_ABI_VERSION_END; version++){ @@ -78,29 +104,6 @@ static enum hal_license __convert_license_str_to_enum(const char *license) return HAL_LICENSE_UNKNOWN; } -__attribute__ ((visibility("default"))) -void _destroy_module_info(gpointer data) -{ -#define SAFE_FREE_AND_NULL(x) \ -do { \ - if (x) { \ - free(x); \ - x = NULL; \ - } \ -} while (0); - - struct __hal_module_info *info = (struct __hal_module_info *)data; - - if (info) { - SAFE_FREE_AND_NULL(info->module_name); - SAFE_FREE_AND_NULL(info->library_name); - SAFE_FREE_AND_NULL(info->library_name_64bit); - SAFE_FREE_AND_NULL(info->symbol_name); - SAFE_FREE_AND_NULL(info->abi_versions); - SAFE_FREE_AND_NULL(info); - } -} - static const char * __get_json_object_string(json_object *object, const char *key) { json_object *temp_object = NULL; @@ -205,6 +208,12 @@ static struct __hal_module_info* _get_module_info(enum hal_module module) return info; } +#else +static struct __hal_module_info* _get_module_info(enum hal_module module) +{ + return &g_hal_module_info[module]; +} +#endif static struct __hal_module_info* _get_module_info_with_library_name(enum hal_module module, const char *library_name) @@ -215,7 +224,12 @@ static struct __hal_module_info* _get_module_info_with_library_name(enum hal_mod const char *module_name = NULL; int ret; - if (!_json_file_object || !_module_hash | !library_name) +#ifdef HAL_API_CONF_JSON + if (!_json_file_object) + return NULL; +#endif + + if (!_module_hash | !library_name) return NULL; if (!g_str_has_prefix(library_name, "libhal-backend-")) { @@ -276,7 +290,12 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module, const char *key = NULL; int i; - if (!_json_file_object || !_module_hash) +#ifdef HAL_API_CONF_JSON + if (!_json_file_object) + return NULL; +#endif + + if (!_module_hash) return NULL; if (!library_name) @@ -288,6 +307,7 @@ struct __hal_module_info* _hal_api_conf_get_module_info(enum hal_module module, enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) { +#ifdef HAL_API_CONF_JSON const char *abi_version = NULL; bool ret_initialized; json_object *platform_obj = NULL; @@ -302,6 +322,9 @@ enum hal_abi_version _hal_api_conf_get_platform_abi_version(void) _platform_abi_version = __convert_abi_version_str_to_enum(abi_version); return _platform_abi_version; +#else + return g_platform_curr_abi_version; +#endif } __attribute__ ((visibility("default"))) @@ -310,16 +333,19 @@ int _hal_api_conf_init(void) if (_usage_count++ > 0) return 0; +#ifdef HAL_API_CONF_JSON _json_file_object = json_object_from_file(HAL_CONFIGURATION_PATH); if (_json_file_object == NULL) { _E("Failed to parsing json configuration file : %s\n", json_util_get_last_err()); goto err; } +#endif _module_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, _destroy_module_info); return 0; +#ifdef HAL_API_CONF_JSON err: _usage_count--; @@ -329,6 +355,7 @@ err: } return -EINVAL; +#endif } __attribute__ ((visibility("default"))) @@ -338,10 +365,12 @@ void _hal_api_conf_exit(void) if (_usage_count != 0) return; +#ifdef HAL_API_CONF_JSON if (_json_file_object) { json_object_put(_json_file_object); _json_file_object = NULL; } +#endif if (_module_hash) { g_hash_table_remove_all(_module_hash); diff --git a/src/hal-api-list.h b/src/hal-api-list.h new file mode 100644 index 0000000..a7e0ece --- /dev/null +++ b/src/hal-api-list.h @@ -0,0 +1,706 @@ +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __HAL_API_LIST_H__ +#define __HAL_API_LIST_H__ + +#include "hal-common.h" + +#include "common.h" + +#define HAL_ABI_VERSION_MAX 10 + +enum hal_abi_version g_platform_curr_abi_version = HAL_ABI_VERSION_TIZEN_6_5; + +static struct hal_abi_version_match abi_version_match_data[HAL_MODULE_END][HAL_ABI_VERSION_MAX] = { + /* HAL_GROUP_GRAPHICS */ + [HAL_MODULE_TBM] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_TDM] = { + /* FIXME: Need to be filled from configuration file. */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_COREGL] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + [HAL_MODULE_INPUT] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + + /* HAL_GROUP_MULTIMEDIA */ + [HAL_MODULE_AUDIO] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_CAMERA] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_RADIO] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_CODEC] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + [HAL_MODULE_USB_AUDIO] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + [HAL_MODULE_ALSAUCM] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + + /* HAL_GROUP_CONNECTIVITY */ + [HAL_MODULE_BLUETOOTH] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_WIFI] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_NAN] = { + }, + [HAL_MODULE_NFC] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_ZIGBEE] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_UWB] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_MTP] = { + /** + * Don't need to add abi verion for this module. + * because this module don't support HAL API. + */ + }, + + /* HAL_GROUP_TELEPHONY */ + [HAL_MODULE_TELEPHONY] = { + /* FIXME: Need to be determined whehter support HAL API or not. */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + /* HAL_GROUP_LOCATION */ + [HAL_MODULE_LOCATION] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + /* HAL_GROUP_SYSTEM */ + [HAL_MODULE_COMMON] = { + }, + [HAL_MODULE_POWER] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_SENSOR] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_PERIPHERAL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + [HAL_MODULE_DEVICE_BATTERY] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_BEZEL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_DISPLAY] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_IR] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_TOUCHSCREEN] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_LED] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_BOARD] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_EXTERNAL_CONNECTION] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_THERMAL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_USB_GADGET] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_HAPTIC] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_MEMORY] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, +}; + +static struct __hal_module_info g_hal_module_info[] = { + /* HAL_GROUP_GRAPHICS */ + [HAL_MODULE_TBM] = { + .group = HAL_GROUP_GRAPHICS, + .module = HAL_MODULE_TBM, + .license = HAL_LICENSE_MIT, + .module_name = "HAL_MODULE_TBM", + .library_name = "/hal/lib/libhal-backend-tbm.so", + .library_name_64bit = "/hal/lib64/libhal-backend-tbm.so", + .symbol_name = "hal_backend_tbm_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_TBM]), + .abi_versions = abi_version_match_data[HAL_MODULE_TBM], + .hal_api = true, + }, + [HAL_MODULE_TDM] = { + .group = HAL_GROUP_GRAPHICS, + .module = HAL_MODULE_TDM, + .license = HAL_LICENSE_MIT, + .module_name = "HAL_MODULE_TDM", + .library_name = "/hal/lib/libhal-backend-tdm.so", + .library_name_64bit = "/hal/lib64/libhal-backend-tdm.so", + .symbol_name = "hal_backend_tdm_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_TDM]), + .abi_versions = abi_version_match_data[HAL_MODULE_TDM], + .hal_api = true, + }, + [HAL_MODULE_COREGL] = { + .group = HAL_GROUP_GRAPHICS, + .module = HAL_MODULE_COREGL, + .license = HAL_LICENSE_UNKNOWN, + .module_name = "HAL_MODULE_COREGL", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + [HAL_MODULE_INPUT] = { + .group = HAL_GROUP_GRAPHICS, + .module = HAL_MODULE_INPUT, + .license = HAL_LICENSE_MIT, + .module_name = "HAL_MODULE_INPUT", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + + /* HAL_GROUP_MULTIMEDIA */ + [HAL_MODULE_AUDIO] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_AUDIO, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_AUDIO", + .library_name = "/hal/lib/libhal-backend-audio.so", + .library_name_64bit = "/hal/lib64/libhal-backend-audio.so", + .symbol_name = "hal_backend_audio_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_AUDIO]), + .abi_versions = abi_version_match_data[HAL_MODULE_AUDIO], + .hal_api = true, + }, + [HAL_MODULE_CAMERA] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_CAMERA, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_CAMERA", + .library_name = "/hal/lib/libhal-backend-camera.so", + .library_name_64bit = "/hal/lib64/libhal-backend-camera.so", + .symbol_name = "hal_backend_camera_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_CAMERA]), + .abi_versions = abi_version_match_data[HAL_MODULE_CAMERA], + .hal_api = true, + }, + [HAL_MODULE_RADIO] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_RADIO, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_RADIO", + .library_name = "/hal/lib/libhal-backend-radio.so", + .library_name_64bit = "/hal/lib64/libhal-backend-radio.so", + .symbol_name = "hal_backend_radio_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_RADIO]), + .abi_versions = abi_version_match_data[HAL_MODULE_RADIO], + .hal_api = true, + }, + [HAL_MODULE_CODEC] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_CODEC, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_CODEC", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + [HAL_MODULE_USB_AUDIO] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_USB_AUDIO, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_USB_AUDIO", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + [HAL_MODULE_ALSAUCM] = { + .group = HAL_GROUP_MULTIMEDIA, + .module = HAL_MODULE_ALSAUCM, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_ALSAUCM", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + + /* HAL_GROUP_CONNECTIVITY */ + [HAL_MODULE_BLUETOOTH] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_BLUETOOTH, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_BLUETOOTH", + .library_name = "/hal/lib/libhal-backend-bluetooth.so", + .library_name_64bit = "/hal/lib64/libhal-backend-bluetooth.so", + .symbol_name = "hal_backend_bluetooth_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_BLUETOOTH]), + .abi_versions = abi_version_match_data[HAL_MODULE_BLUETOOTH], + .hal_api = true, + }, + [HAL_MODULE_WIFI] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_WIFI, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_WIFI", + .library_name = "/hal/lib/libhal-backend-wifi.so", + .library_name_64bit = "/hal/lib64/libhal-backend-wifi.so", + .symbol_name = "hal_backend_wifi_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_WIFI]), + .abi_versions = abi_version_match_data[HAL_MODULE_WIFI], + .hal_api = true, + }, + [HAL_MODULE_NAN] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_NAN, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_NAN", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + [HAL_MODULE_NFC] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_NFC, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_NFC", + .library_name = "/hal/lib/libhal-backend-nfc.so", + .library_name_64bit = "/hal/lib64/libhal-backend-nfc.so", + .symbol_name = "hal_backend_nfc_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_NFC]), + .abi_versions = abi_version_match_data[HAL_MODULE_NFC], + .hal_api = true, + }, + [HAL_MODULE_ZIGBEE] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_ZIGBEE, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_ZIGBEE", + .library_name = "/hal/lib/libhal-backend-zigbee.so", + .library_name_64bit = "/hal/lib64/libhal-backend-zigbee.so", + .symbol_name = "hal_backend_zigbee_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_ZIGBEE]), + .abi_versions = abi_version_match_data[HAL_MODULE_ZIGBEE], + .hal_api = true, + }, + [HAL_MODULE_UWB] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_UWB, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_UWB", + .library_name = "/hal/lib/libhal-backend-uwb.so", + .library_name_64bit = "/hal/lib64/libhal-backend-uwb.so", + .symbol_name = "hal_backend_uwb_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_UWB]), + .abi_versions = abi_version_match_data[HAL_MODULE_UWB], + .hal_api = true, + }, + [HAL_MODULE_MTP] = { + .group = HAL_GROUP_CONNECTIVITY, + .module = HAL_MODULE_MTP, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_MTP", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + + /* HAL_GROUP_TELEPHONY */ + [HAL_MODULE_TELEPHONY] = { + .group = HAL_GROUP_TELEPHONY, + .module = HAL_MODULE_TELEPHONY, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_TELEPHONY", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + + /* HAL_GROUP_LOCATION */ + [HAL_MODULE_LOCATION] = { + .group = HAL_GROUP_LOCATION, + .module = HAL_MODULE_LOCATION, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_LOCATION", + .library_name = "/hal/lib/libhal-backend-location.so", + .library_name_64bit = "/hal/lib64/libhal-backend-location.so", + .symbol_name = "hal_backend_location_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_LOCATION]), + .abi_versions = abi_version_match_data[HAL_MODULE_LOCATION], + .hal_api = true, + }, + + /* HAL_GROUP_SYSTEM */ + [HAL_MODULE_COMMON] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_COMMON, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_COMMON", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = true, + }, + [HAL_MODULE_POWER] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_POWER, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_POWER", + .library_name = "/hal/lib/libhal-backend-power.so", + .library_name_64bit = "/hal/lib64/libhal-backend-power.so", + .symbol_name = "hal_backend_power_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_POWER]), + .abi_versions = abi_version_match_data[HAL_MODULE_POWER], + .hal_api = true, + }, + [HAL_MODULE_SENSOR] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_SENSOR, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_SENSOR", + .library_name = "/hal/lib/libhal-backend-sensor.so", + .library_name_64bit = "/hal/lib64/libhal-backend-sensor.so", + .symbol_name = "hal_backend_sensor_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_SENSOR]), + .abi_versions = abi_version_match_data[HAL_MODULE_SENSOR], + .hal_api = true, + }, + [HAL_MODULE_PERIPHERAL] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_PERIPHERAL, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_PERIPHERAL", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = 0, + .abi_versions = NULL, + .hal_api = false, + }, + [HAL_MODULE_DEVICE_BATTERY] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_BATTERY, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_BATTERY", + .library_name = "/hal/lib/libhal-backend-device-battery.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-battery.so", + .symbol_name = "hal_backend_device_battery_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_BATTERY]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_BATTERY], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_BEZEL] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_BEZEL, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_BEZEL", + .library_name = "/hal/lib/libhal-backend-device-bezel.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-bezel.so", + .symbol_name = "hal_backend_device_bezel_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_BEZEL]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_BEZEL], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_DISPLAY] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_DISPLAY, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_DISPLAY", + .library_name = "/hal/lib/libhal-backend-device-display.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-display.so", + .symbol_name = "hal_backend_device_display_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_DISPLAY]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_DISPLAY], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_IR] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_IR, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_IR", + .library_name = "/hal/lib/libhal-backend-device-ir.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-ir.so", + .symbol_name = "hal_backend_device_ir_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_IR]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_IR], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_TOUCHSCREEN] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_TOUCHSCREEN, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_TOUCHSCREEN", + .library_name = "/hal/lib/libhal-backend-device-touchscreen.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-touchscreen.so", + .symbol_name = "hal_backend_device_touchscreen_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_TOUCHSCREEN]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_TOUCHSCREEN], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_LED] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_LED, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_LED", + .library_name = "/hal/lib/libhal-backend-device-led.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-led.so", + .symbol_name = "hal_backend_device_led_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_LED]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_LED], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_BOARD] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_BOARD, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_BOARD", + .library_name = "/hal/lib/libhal-backend-device-board.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-board.so", + .symbol_name = "hal_backend_device_board_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_BOARD]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_BOARD], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_EXTERNAL_CONNECTION] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_EXTERNAL_CONNECTION", + .library_name = "/hal/lib/libhal-backend-device-external-connection.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-external-connection.so", + .symbol_name = "hal_backend_device_external_connection_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_EXTERNAL_CONNECTION]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_EXTERNAL_CONNECTION], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_THERMAL] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_THERMAL, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_THERMAL", + .library_name = "/hal/lib/libhal-backend-device-thermal.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-thermal.so", + .symbol_name = "hal_backend_device_thermal_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_THERMAL]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_THERMAL], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_USB_GADGET] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_USB_GADGET, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_USB_GADGET", + .library_name = "/hal/lib/libhal-backend-device-usb-gadget.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-usb-gadget.so", + .symbol_name = "hal_backend_device_usb_gadget_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_USB_GADGET]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_USB_GADGET], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_HAPTIC] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_HAPTIC, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_HAPTIC", + .library_name = "/hal/lib/libhal-backend-device-haptic.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-haptic.so", + .symbol_name = "hal_backend_device_haptic_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_HAPTIC]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_HAPTIC], + .hal_api = true, + }, + [HAL_MODULE_DEVICE_MEMORY] = { + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_DEVICE_MEMORY, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "HAL_MODULE_DEVICE_MEMORY", + .library_name = "/hal/lib/libhal-backend-device-memory.so", + .library_name_64bit = "/hal/lib64/libhal-backend-device-memory.so", + .symbol_name = "hal_backend_device_memory_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_DEVICE_MEMORY]), + .abi_versions = abi_version_match_data[HAL_MODULE_DEVICE_MEMORY], + .hal_api = true, + }, +}; + +#endif /* __HAL_API_LIST_H__ */ -- 2.7.4 From 21ab7fc3a3afeadffb618d45e3475e45b96da9c2 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Tue, 16 Mar 2021 09:33:10 +0900 Subject: [PATCH 15/16] halapi: Remove unneeded function definition from header file _destroy_module_info() function is not used on outside of hal-api-conf.c. So that remove the unneeded function defintion. Change-Id: I13b17dcc8592d0a0a1c0d392eda9a9c13dd76155 Signed-off-by: Chanwoo Choi --- src/hal-api-conf.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hal-api-conf.h b/src/hal-api-conf.h index c1e7eb9..23d1e72 100644 --- a/src/hal-api-conf.h +++ b/src/hal-api-conf.h @@ -38,8 +38,6 @@ struct __hal_module_info *_hal_api_conf_get_module_info(enum hal_module module, enum hal_abi_version _hal_api_conf_get_platform_abi_version(void); -void _destroy_module_info(gpointer data); - #ifdef __cplusplus } #endif -- 2.7.4 From 456f76db005fed6a0beba8b53d0f6cf598697a8b Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 22 Mar 2021 16:54:53 +0900 Subject: [PATCH 16/16] halapi: Fix svace warning issue Change-Id: I29f2405f1412a99066ae248c1a98f14cf6b30af9 Signed-off-by: Chanwoo Choi --- src/hal-api-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 9914c08..e66446d 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -132,8 +132,8 @@ static int __get_backend(enum hal_module module, void **data, const char *librar struct __hal_module_info *info = NULL; void *handle = NULL; hal_backend *backend; - const char *symbol_name; - const char *backend_library_name; + const char *symbol_name = NULL; + const char *backend_library_name = NULL; int ret = 0; /* Check parameter whether is valid or not */ -- 2.7.4