From a29ad41a620a1a07c19f9dffd7a602d5c7e6cbe0 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 18 Dec 2020 13:20:37 +0900 Subject: [PATCH 02/11] Add support hal-api-common library to check HAL ABI and support of haltest Need to provide the helper function of HAL ABI version check in order to support HAL API layer on Tizen 6.5. By supporing the ABI check method, Tizen can separate the hal.img from core image and then we can remove the h/w dependency from Tizen core image. hal-api-common-*.rpm contains the shared library providing the helper function of the HAL ABI version check and the HAL ABI data of all modules. If some module changes the their owr HAL ABI interface, they must update the ABI information to /platform/hal/api/common. It contains the following files: - /usr/lib/hal/libhal-api-common.so - /usr/share/licenses/hal-api-common/LICENSE hal-api-common-devel-*.rpm contains the header file for including the helper function of HAL ABI version check. It contains the following files: - /usr/include/hal/hal-common.h - /usr/lib/pkgconfig/hal-api-common.pc But, this patch is not enough. Usually, the configuraiton data like HAL ABI version information should get the file like xml, json style format file and so on. But, it just specify the HAL ABI versin information of all modules in the src/common.h as workardound style. It must need to be fixed on later. And this version doesn't include the any haltest code even if it is necessary. Also on later, The role of common-haltest make the pre-considition environment for all haltests and then execute the haltest file to verify the hal.img and the implementation of HAL backend pacakges. For example, show the relationship among hal-api-foo, hal-backend-foo and hal-api-common as following: ----------------------------------- | 'User of hal-api-foo' | | executes C HAl API. | ----------------------------------- | | (Call HAL API) | ----------------------------------- | /usr/include/hal-foo.h | | | | | ---------------------------------- | hal-api-foo.rpm | <---> | (Check HAL ABI Version) | | (/usr/lib/libhal-api-foo.so) | | | | | | hal-api-common.rpm | | | | (/usr/lib/libhal-api-common.so)| | /usr/include/hal-foo-interface.h| ---------------------------------- ----------------------------------| | | dlopen ("/hal/lib/libhal-backend-foo.so") | dlsym ("hal_backend_foo_daa") | ----------------------------------- | hal-backend-foo-rpi4.rpm | | (/hal/lib/libhal-backend-foo.so)| ----------------------------------- Change-Id: Ifb4b10e94c419517882794cc101bfcd598570335 Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 45 +++ LICENSE | 203 +++++++++++ hal-api-common.pc | 16 + include/hal-common.h | 134 +++++++ packaging/hal-api-common.manifest | 6 + packaging/hal-api-common.spec | 66 ++++ src/common.h | 748 ++++++++++++++++++++++++++++++++++++++ src/hal-api-common.c | 117 ++++++ 8 files changed, 1335 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE create mode 100644 hal-api-common.pc create mode 100644 include/hal-common.h create mode 100644 packaging/hal-api-common.manifest create mode 100644 packaging/hal-api-common.spec create mode 100644 src/common.h create mode 100644 src/hal-api-common.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..935bf78 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(hal-api-common C) + +SET(VERSION_MAJOR 0) +SET(VERSION "${VERSION_MAJOR}.1.0") + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}/bin") +SET(INCLUDEDIR "${PREFIX}/include") +SET(LIBDIR ${CMAKE_LIBDIR_PREFIX}) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +SET(PKG_MODULES + dlog + gio-2.0 + glib-2.0 +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED ${PKG_MODULES}) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -fPIE") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -finstrument-functions") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -lrt") +SET(CMAKE_EXE_LINKER_FLAGS "-pie") + +ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_COMMON\"") + +SET(SRCS + src/hal-api-common.c) + +ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,-z,nodelete,--no-undefined) +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) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-common.h DESTINATION ${INCLUDEDIR}/hal) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1bca952 --- /dev/null +++ b/LICENSE @@ -0,0 +1,203 @@ +Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/hal-api-common.pc b/hal-api-common.pc new file mode 100644 index 0000000..5a281de --- /dev/null +++ b/hal-api-common.pc @@ -0,0 +1,16 @@ +# Package Information for pkg-config + +package_name=hal-api-common +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@/hal +libdir=@LIBDIR@hal +includedir=@INCLUDEDIR@/hal + +Name: ${package_name} +Description: ${package_name} interface +Version: @VERSION@ + +Requires: +Libs: -L${libdir} -l${package_name} +Cflags: -I${includedir} +CXXflags: -I${includedir} diff --git a/include/hal-common.h b/include/hal-common.h new file mode 100644 index 0000000..165993a --- /dev/null +++ b/include/hal-common.h @@ -0,0 +1,134 @@ +/* + * HAL (Hardware Abstract Layer) Common API + * + * 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. + */ + +#ifndef __HAL_COMMON__ +#define __HAL_COMMON__ + +#ifdef __cplusplus +extern "C" { +#endif + +enum hal_abi_version { + HAL_ABI_VERSION_UNKNOWN = 0, + HAL_ABI_VERSION_TIZEN_6_5, + HAL_ABI_VERSION_END, +}; + +enum hal_license { + HAL_LICENSE_UNKNOWN = 0, + HAL_LICENSE_APACHE_2_0, + HAL_LICENSE_FLORA, + HAL_LICENSE_MIT, + HAL_LICENSE_END, +}; + +enum hal_group { + HAL_GROUP_UNKNOWN = 0, + HAL_GROUP_GRAPHICS, + HAL_GROUP_MULTIMEDIA, + HAL_GROUP_CONNECTIVITY, + HAL_GROUP_TELEPHONY, + HAL_GROUP_LOCATION, + HAL_GROUP_SYSTEM, + HAL_GROUP_MISCELLANEOUS, + HAL_GROUP_END, +}; + +enum hal_module { + HAL_MODULE_UNKNOWN = 0, + + /* HAL_GROUP_GRAPHICS */ + HAL_MODULE_TBM = 1, + HAL_MODULE_TDM, + HAL_MODULE_COREGL, + HAL_MODULE_INPUT, + + /* HAL_GROUP_MULTIMEDIA */ + HAL_MODULE_AUDIO = 15, + HAL_MODULE_CAMERA, + HAL_MODULE_RADIO, + HAL_MODULE_CODEC, + HAL_MODULE_USB_AUDIO, + HAL_MODULE_ALSAUCM, + + /* HAL_GROUP_CONNECTIVITY */ + HAL_MODULE_BLUETOOTH = 30, + HAL_MODULE_WIFI, + HAL_MODULE_NAN, + HAL_MODULE_NFC, + HAL_MODULE_ZIGBEE, + HAL_MODULE_UWB, + HAL_MODULE_MTP, + + /* HAL_GROUP_TELEPHONY */ + HAL_MODULE_TELPEPHONY = 45, + + /* HAL_GROUP_LOCATION */ + HAL_MODULE_LOCATION = 50, + + /* HAL_GROUP_SYSTEM */ + HAL_MODULE_COMMON = 55, + HAL_MODULE_POWER, + HAL_MODULE_SENSOR, + HAL_MODULE_PERIPHERAL, + HAL_MODULE_DEVICE_BATTERY, + HAL_MODULE_DEVICE_BEZEL, + HAL_MODULE_DEVICE_DISPLAY, + HAL_MODULE_DEVICE_IR, + HAL_MODULE_DEVICE_TOUCHSCREEN, + HAL_MODULE_DEVICE_LED, + HAL_MODULE_DEVICE_BOARD, + HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, + HAL_MODULE_DEVICE_THERMAL, + HAL_MODULE_DEVICE_USB_GADGET, + HAL_MODULE_DEVICE_HAPTIC, + + /* HAL_GROUP_MISCELLANEOUS */ + HAL_MODULE_FOO, /* FIXME: Add for test and will be removed */ + HAL_MODULE_END, +}; + +/** + * @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. + */ +const char *hal_common_get_backend_library_name(enum hal_module handle); + +/** + * @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. + */ +const char *hal_common_get_backend_symbol_name(enum hal_module handle); + +/** + * @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 + * @return @c 0 on success, otherwise a negative error value + */ +int hal_common_check_backend_abi_version(enum hal_module handle, + enum hal_abi_version abi_version); + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_COMMON__ */ diff --git a/packaging/hal-api-common.manifest b/packaging/hal-api-common.manifest new file mode 100644 index 0000000..81ace0c --- /dev/null +++ b/packaging/hal-api-common.manifest @@ -0,0 +1,6 @@ + + + + + + diff --git a/packaging/hal-api-common.spec b/packaging/hal-api-common.spec new file mode 100644 index 0000000..9704ee6 --- /dev/null +++ b/packaging/hal-api-common.spec @@ -0,0 +1,66 @@ +%define name hal-api-common +%define devel_name hal-api-common-devel + +### main package ######### +Name: %{name} +Summary: %{name} interface +Version: 0.0.1 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest + +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(gio-2.0) +BuildRequires: pkgconfig(glib-2.0) + +%description +%{name} interface + +### devel package ######### +%package -n %{devel_name} +Summary: %{name} interface +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description -n %{devel_name} +%{name} Interface for product vendor developer + +### build and install ######### +%prep +%setup -q + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_LIBDIR_PREFIX=%{_libdir}/ + +%build +cp %{SOURCE1} . +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +### contain files to package ######### +%files -n %{name} +%license LICENSE +%manifest %{name}.manifest +%defattr(-,root,root,-) +%{_libdir}/hal/*.so* + +%files -n %{devel_name} +%defattr(-,root,root,-) +%{_includedir}/hal/*.h +%{_libdir}/pkgconfig/*.pc diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..de47485 --- /dev/null +++ b/src/common.h @@ -0,0 +1,748 @@ +/* + * Copyright (c) 2020 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 __COMMON_H__ +#define __COMMON_H__ + +#include + +#include "hal-common.h" + +#define _D(fmt, args...) SLOGD(fmt, ##args) +#define _I(fmt, args...) SLOGI(fmt, ##args) +#define _W(fmt, args...) SLOGW(fmt, ##args) +#define _E(fmt, args...) SLOGE(fmt, ##args) + +#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) +#define HAL_ABI_VERSION_MAX 10 + +/** + * hal-api-common (/platform/hal/api/common) provides the HAL ABI + * (Application Binary Interface) version check feature which is used to check + * the ABI compatibility between HAL API package like hal-api-audio-*.rpm + * and HAL backend package like hal-backend-audio-*.rpm which is included + * in hal.img. In order to compare ABI version between two binary, + * Tizen core platform always must maintain the current HAL ABI version. + * So that, define the below global variable (g_curr_hal_abi_version). + * + * 'g_curr_hal_abi_version' will be used for all HAL API modules, + * to check whether HAL backend ABI version of each module in hal.img + * is supported or not with current Tizen core HAL ABI version. + * + * 'g_curr_hal_abi_version' must be updated when Tizen platform will be released + * officially. + */ +/* FIXME: Need to be initialized by configuration file like xml */ +enum hal_abi_version g_curr_hal_abi_version = HAL_ABI_VERSION_TIZEN_6_5; + +struct hal_abi_version_match { + enum hal_abi_version curr_version; + enum hal_abi_version compat_version; +} 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] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_TDM] = { + /* FIXME: Need to be filled from configuration file. */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_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] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_CAMERA] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_RADIO] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_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] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_WIFI] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_NAN] = { + }, + [HAL_MODULE_NFC] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_ZIGBEE] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_UWB] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_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_TELPEPHONY] = { + /* FIXME: Need to be determined whehter support HAL API or not. */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + /* HAL_GROUP_LOCATION */ + [HAL_MODULE_LOCATION] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_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] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_SENSOR] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_PERIPHERAL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + [HAL_MODULE_DEVICE_BATTERY] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_BEZEL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_DISPLAY] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_IR] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_TOUCHSCREEN] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_LED] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_BOARD] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_EXTERNAL_CONNECTION] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_THERMAL] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_USB_GADGET] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + [HAL_MODULE_DEVICE_HAPTIC] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, + + /* FIXME: Add for test and will be removed */ + /* HAL_GROUP_MISCELLANEOUS */ + [HAL_MODULE_FOO] = { + /* FIXME: Need to be initialized by configuration file like xml */ + [0] = { + .curr_version = HAL_ABI_VERSION_TIZEN_6_5, + .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + }, + }, +}; + +static const struct __hal_module_info { + enum hal_group group; + enum hal_module module; + enum hal_license license; + char *module_name; + char *library_name; + char *library_name_64bit; + char *symbol_name; + unsigned int num_abi_versions; + struct hal_abi_version_match *abi_versions; + + bool hal_api; +} hal_module_info[] = { + /* HAL_GROUP_GRAPHICS */ + [HAL_MODULE_TBM] = { + .group = HAL_GROUP_GRAPHICS, + .module = HAL_MODULE_TBM, + .license = HAL_LICENSE_MIT, + .module_name = "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 = "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 = "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 = "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 = "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 = "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 = "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_UNKNOWN, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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 = "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_TELPEPHONY] = { + .group = HAL_GROUP_TELEPHONY, + .module = HAL_MODULE_TELPEPHONY, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "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 = "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 = "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 = "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 = "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 = "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 = "DEVICE_BATTERY", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_BEZEL", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_DISPLAY", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_IR", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .num_abi_versions = ARRAY_SIZE(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 = "DEVICE_TOUCHSCREEN", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_LED", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_BOARD", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_EXTERNAL_CONNECTION", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_THERMAL", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_USB_GADGET", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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 = "DEVICE_HAPTIC", + .library_name = NULL, + .library_name_64bit = NULL, + .symbol_name = NULL, + .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_GROUP_MISCELLANEOUS */ + [HAL_MODULE_FOO] = { /* FIXME: Add for test and will be removed */ + .group = HAL_GROUP_SYSTEM, + .module = HAL_MODULE_FOO, + .license = HAL_LICENSE_APACHE_2_0, + .module_name = "FOO", + .library_name = "/hal/lib/libhal-backend-foo.so", + .library_name_64bit = "/hal/lib64/libhal-backend-foo.so", + .symbol_name = "hal_backend_foo_data", + .num_abi_versions = ARRAY_SIZE(abi_version_match_data[HAL_MODULE_FOO]), + .abi_versions = abi_version_match_data[HAL_MODULE_FOO], + .hal_api = true, + }, +}; + +#endif /* __COMMON_H__ */ diff --git a/src/hal-api-common.c b/src/hal-api-common.c new file mode 100644 index 0000000..205ddd5 --- /dev/null +++ b/src/hal-api-common.c @@ -0,0 +1,117 @@ +/* + * HAL Common API + * + * 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 "common.h" + +#ifndef EXPORT +#define EXPORT __attribute__ ((visibility("default"))) +#endif + +EXPORT +const char *hal_common_get_backend_library_name(enum hal_module module) +{ + char *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; + } + +#if defined(__aarch64__) + library_name = hal_module_info[module].library_name_64bit; +#else + library_name = hal_module_info[module].library_name; +#endif + + if (!library_name) { + _E("%s backend library name is NULL\n", + hal_module_info[module].module_name); + return NULL; + } + return library_name; +} + +EXPORT +const char *hal_common_get_backend_symbol_name(enum hal_module module) +{ + /* 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; + } + + if (!hal_module_info[module].symbol_name) { + _E("%s backend library name is NULL\n", + hal_module_info[module].module_name); + return NULL; + } + + return hal_module_info[module].symbol_name; +} + +EXPORT +int hal_common_check_backend_abi_version(enum hal_module module, + enum hal_abi_version abi_version) +{ + int i; + + /* 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 TIZEN_ERROR_INVALID_PARAMETER; + } + + if (abi_version <= HAL_ABI_VERSION_UNKNOWN + || abi_version >= HAL_ABI_VERSION_END) { + _E("Invalid paramer of HAL ABI version (%d)\n", abi_version); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + /* Check abi_version whether is supported or not */ + if (!hal_module_info[module].hal_api) { + _E("HAL module(%d) doesn't support HAL API\n", module); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + if (!hal_module_info[module].num_abi_versions + || !hal_module_info[module].abi_versions) { + _E("HAL module(%d) doesn't have the ABI version information\n", + module); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + for (i = 0; i < hal_module_info[module].num_abi_versions; i++) { + struct hal_abi_version_match *data + = &hal_module_info[module].abi_versions[i]; + + if (g_curr_hal_abi_version != data->curr_version) + continue; + + if (abi_version <= data->curr_version + && abi_version >= data->compat_version) + return TIZEN_ERROR_NONE; + } + + return TIZEN_ERROR_INVALID_PARAMETER; +} -- 2.7.4 From cc4b7f2129a4ec345500ebab2c7536d61025cd75 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 28 Dec 2020 16:21:36 +0900 Subject: [PATCH 03/11] halapi: common: Add library and symbol name for hal-api-device Change-Id: I83f661c30b1e2dcb763c9956804d03db57e3aa46 Signed-off-by: Chanwoo Choi --- src/common.h | 66 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/common.h b/src/common.h index de47485..022e8a1 100644 --- a/src/common.h +++ b/src/common.h @@ -603,9 +603,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_BATTERY, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_BATTERY", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -615,9 +615,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_BEZEL, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_BEZEL", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -627,9 +627,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_DISPLAY, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_DISPLAY", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -639,9 +639,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_IR, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_IR", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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]), .hal_api = true, }, @@ -650,9 +650,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_TOUCHSCREEN, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_TOUCHSCREEN", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -662,9 +662,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_LED, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_LED", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -674,9 +674,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_BOARD, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_BOARD", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -686,9 +686,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_EXTERNAL_CONNECTION, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_EXTERNAL_CONNECTION", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -698,9 +698,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_THERMAL, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_THERMAL", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -710,9 +710,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_USB_GADGET, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_USB_GADGET", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, @@ -722,9 +722,9 @@ static const struct __hal_module_info { .module = HAL_MODULE_DEVICE_HAPTIC, .license = HAL_LICENSE_APACHE_2_0, .module_name = "DEVICE_HAPTIC", - .library_name = NULL, - .library_name_64bit = NULL, - .symbol_name = NULL, + .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, -- 2.7.4 From ee9bfb651823262cdade3229eeeaf429efd3f389 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 28 Dec 2020 13:50:34 +0900 Subject: [PATCH 04/11] halapi: common: Divide hal-common.h into two header files Divide hal-common.h into two header files as following: - hal-common.h is used for HAL API packages (/platform/hal/api/) - hal-common-interface.h is used for HAL backend packages (/platform/hal/device/) Change-Id: Ida3192ed4dbb29d9b718b2b90f3a61f8ed380e2e Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 21 ++++++++++++--------- include/hal-common-interface.h | 35 +++++++++++++++++++++++++++++++++++ include/hal-common.h | 8 ++------ 3 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 include/hal-common-interface.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 935bf78..359496c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,12 +34,15 @@ ADD_DEFINITIONS("-DLOG_TAG=\"HALAPI_COMMON\"") SET(SRCS src/hal-api-common.c) -ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,-z,nodelete,--no-undefined) -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) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR}/hal) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/hal-common.h DESTINATION ${INCLUDEDIR}/hal) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIBDIR}/pkgconfig) +ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,-z,nodelete,--no-undefined) +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) +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 + DESTINATION ${LIBDIR}/pkgconfig) diff --git a/include/hal-common-interface.h b/include/hal-common-interface.h new file mode 100644 index 0000000..40ef158 --- /dev/null +++ b/include/hal-common-interface.h @@ -0,0 +1,35 @@ +/* + * HAL (Hardware Abstract Layer) Common Interface + * + * 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. + */ + +#ifndef __HAL_COMMON_INTERFACE__ +#define __HAL_COMMON_INTERFACE__ + +#ifdef __cplusplus +extern "C" { +#endif + +enum hal_abi_version { + HAL_ABI_VERSION_UNKNOWN = 0, + HAL_ABI_VERSION_TIZEN_6_5, + HAL_ABI_VERSION_END, +}; + +#ifdef __cplusplus +} +#endif +#endif /* __HAL_COMMON_INTERFACE__ */ diff --git a/include/hal-common.h b/include/hal-common.h index 165993a..0be04a1 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -19,16 +19,12 @@ #ifndef __HAL_COMMON__ #define __HAL_COMMON__ +#include "hal-common-interface.h" + #ifdef __cplusplus extern "C" { #endif -enum hal_abi_version { - HAL_ABI_VERSION_UNKNOWN = 0, - HAL_ABI_VERSION_TIZEN_6_5, - HAL_ABI_VERSION_END, -}; - enum hal_license { HAL_LICENSE_UNKNOWN = 0, HAL_LICENSE_APACHE_2_0, -- 2.7.4 From 5d2b552a3dea8299299fd153c2ea7f51d928ed1a Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 28 Dec 2020 13:43:47 +0900 Subject: [PATCH 05/11] halapi: common: Add hal_common_(get|put)_backend() function to handle backend data Following step is for getting the backend data which contains the function pointers for each HAL module. 1. get library name of HAL backend 2. dlopen with library name 3. get symbol name of HAL backend 4. dlsym with symbol name 5. Get the backend data via backend->init() In order to reduce the duplicate code on each HAL API packages, add hal_common_get_backend() helper function which contains the above steps to get the backend data. And add hal_common_put_backend() helper function to free the hal_backend instance and dlclose the shared library. Change-Id: Ic603d3e4f0ba1ff2aed9699b1eaf925cbd97c60c Signed-off-by: Chanwoo Choi --- CMakeLists.txt | 2 +- include/hal-common-interface.h | 8 ++++ include/hal-common.h | 16 +++++++ src/common.h | 6 ++- src/hal-api-common.c | 106 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 136 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 359496c..fc2b438 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ SET(SRCS src/hal-api-common.c) ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SRCS}) -TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -Wl,-z,nodelete,--no-undefined) +TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${pkgs_LDFLAGS} -ldl -Wl,-z,nodelete,--no-undefined) SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) SET_TARGET_PROPERTIES( ${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) diff --git a/include/hal-common-interface.h b/include/hal-common-interface.h index 40ef158..56b1c3c 100644 --- a/include/hal-common-interface.h +++ b/include/hal-common-interface.h @@ -29,6 +29,14 @@ enum hal_abi_version { HAL_ABI_VERSION_END, }; +typedef struct __hal_backend { + const char *name; + const char *vendor; + const unsigned int abi_version; + int (*init) (void **data); + void (*exit) (void *data); +} hal_backend; + #ifdef __cplusplus } #endif diff --git a/include/hal-common.h b/include/hal-common.h index 0be04a1..e6d025c 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -116,6 +116,22 @@ const char *hal_common_get_backend_library_name(enum hal_module handle); const char *hal_common_get_backend_symbol_name(enum hal_module handle); /** + * @brief Get the backend data 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. + * @return @c 0 on success, otherwise a negative error value + */ +int hal_common_get_backend(enum hal_module handle, void **data); + +/** + * @brief Put the backend data 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 + */ +void hal_common_put_backend(enum hal_module handle, void *data); + +/** * @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 022e8a1..39ab920 100644 --- a/src/common.h +++ b/src/common.h @@ -298,14 +298,18 @@ struct hal_abi_version_match { }, }; -static const struct __hal_module_info { +static struct __hal_module_info { enum hal_group group; enum hal_module module; enum hal_license license; char *module_name; + char *library_name; char *library_name_64bit; + void *library_handle; + hal_backend *library_backend; char *symbol_name; + unsigned int num_abi_versions; struct hal_abi_version_match *abi_versions; diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 205ddd5..03cb953 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "common.h" @@ -71,6 +72,111 @@ const char *hal_common_get_backend_symbol_name(enum hal_module module) } EXPORT +int hal_common_get_backend(enum hal_module module, void **data) +{ + void *handle = NULL; + hal_backend *backend; + const char *library_name, *symbol_name; + int ret = 0; + + /* Load module */ + library_name = hal_common_get_backend_library_name(HAL_MODULE_FOO); + if (!library_name) { + _E("Failed to get backend library name of %s\n", + hal_module_info[module].module_name); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + handle = dlopen(library_name, RTLD_LAZY); + if (!handle) { + _E("Failed to load shared library (%s)\n", dlerror()); + return TIZEN_ERROR_INVALID_PARAMETER; + } + + symbol_name = hal_common_get_backend_symbol_name(HAL_MODULE_FOO); + if (!symbol_name) { + _E("Failed to get backend symbol name of %s\n", + hal_module_info[module].module_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + + backend = dlsym(handle, symbol_name); + if (!backend) { + _E("Failed to find backend data (%s)\n", dlerror()); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + + /* Print backend module and vendor name */ + + /* Check HAL ABI Version */ + ret = hal_common_check_backend_abi_version(HAL_MODULE_FOO, + backend->abi_version); + if (ret < 0) { + _E("Failed to check ABI version of %s\n", + hal_module_info[module].module_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + + /* Get the backend module data */ + if (!backend->init) { + _E("hal_backend->init() is NULL for %s\n", + hal_module_info[module].module_name); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + + ret = backend->init(data); + if (ret < 0) { + _E("Failed to initialize backend: name(%s)/vendor(%s)\n", + backend->name, backend->vendor); + ret = TIZEN_ERROR_INVALID_PARAMETER; + goto err; + } + + hal_module_info[module].library_backend = backend; + hal_module_info[module].library_handle = handle; + + _I("Get HAL backend: name(%s)/vendor(%s)\n", + backend->name, backend->vendor); + + return TIZEN_ERROR_NONE; +err: + dlclose(handle); + return ret; +} + +EXPORT +void hal_common_put_backend(enum hal_module module, void *data) +{ + hal_backend *backend = NULL; + void *handle = NULL; + int ret; + + /* 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; + } + + backend = hal_module_info[module].library_backend; + handle = hal_module_info[module].library_handle; + + if (backend) { + if (backend->exit) + backend->exit(data); + + _I("Put HAL backend: name(%s)/vendor(%s)\n", + backend->name, backend->vendor); + } + + if (handle) + dlclose(handle); +} + +EXPORT int hal_common_check_backend_abi_version(enum hal_module module, enum hal_abi_version abi_version) { -- 2.7.4 From a8a4f31acf54d50b7ba1ab2d3b18122d454ebec2 Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Thu, 7 Jan 2021 14:35:40 +0900 Subject: [PATCH 06/11] halapi: common: Change return type of hal_common_put_backend and backend->exit Change the return type of hal_common_put_backend() and backend->exit() from void to int in order to pass the error value. Change-Id: I155a33e469511319303bd56d3866d3bbfbec786c Signed-off-by: Chanwoo Choi --- include/hal-common-interface.h | 2 +- include/hal-common.h | 3 ++- src/hal-api-common.c | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/hal-common-interface.h b/include/hal-common-interface.h index 56b1c3c..39831b9 100644 --- a/include/hal-common-interface.h +++ b/include/hal-common-interface.h @@ -34,7 +34,7 @@ typedef struct __hal_backend { const char *vendor; const unsigned int abi_version; int (*init) (void **data); - void (*exit) (void *data); + int (*exit) (void *data); } hal_backend; #ifdef __cplusplus diff --git a/include/hal-common.h b/include/hal-common.h index e6d025c..e25503b 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -128,8 +128,9 @@ int hal_common_get_backend(enum hal_module handle, void **data); * @brief Put the backend data 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 + * @return @c 0 on success, otherwise a negative error value */ -void hal_common_put_backend(enum hal_module handle, void *data); +int hal_common_put_backend(enum hal_module handle, void *data); /** * @brief Check HAL ABI version whehter is suppored or not on current platform diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 03cb953..9be72fa 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -149,7 +149,7 @@ err: } EXPORT -void hal_common_put_backend(enum hal_module module, void *data) +int hal_common_put_backend(enum hal_module module, void *data) { hal_backend *backend = NULL; void *handle = NULL; @@ -158,22 +158,28 @@ void hal_common_put_backend(enum hal_module module, void *data) /* 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; + return TIZEN_ERROR_INVALID_PARAMETER; } backend = hal_module_info[module].library_backend; handle = hal_module_info[module].library_handle; - if (backend) { - if (backend->exit) - backend->exit(data); - - _I("Put HAL backend: name(%s)/vendor(%s)\n", - backend->name, backend->vendor); + if (backend && backend->exit) { + ret = backend->exit(data); + if (ret < 0) { + _E("Failed to exit backend: name(%s)/vendor(%s)\n", + backend->name, backend->vendor); + return TIZEN_ERROR_INVALID_PARAMETER; + } } if (handle) dlclose(handle); + + _I("Put HAL backend: name(%s)/vendor(%s)\n", + backend->name, backend->vendor); + + return TIZEN_ERROR_NONE; } EXPORT -- 2.7.4 From 8736c8c1577b9c634b4eb2cdf250750c7c5de92e Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 8 Jan 2021 12:30:03 +0900 Subject: [PATCH 07/11] halapi: common: Fix bug by using the module parameter hal-api-common helper functions have been used the fixed hal module id such as HAL_MODULE_FOO. It is wrong usage. hal-api-common helper functions have to use the 'module' parameter. Change-Id: Ifa27e0e4df3c5b89ce96511802ef5a008cf2a279 Signed-off-by: Chanwoo Choi --- src/hal-api-common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 9be72fa..9f47636 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -80,7 +80,7 @@ int hal_common_get_backend(enum hal_module module, void **data) int ret = 0; /* Load module */ - library_name = hal_common_get_backend_library_name(HAL_MODULE_FOO); + library_name = hal_common_get_backend_library_name(module); if (!library_name) { _E("Failed to get backend library name of %s\n", hal_module_info[module].module_name); @@ -93,7 +93,7 @@ int hal_common_get_backend(enum hal_module module, void **data) return TIZEN_ERROR_INVALID_PARAMETER; } - symbol_name = hal_common_get_backend_symbol_name(HAL_MODULE_FOO); + symbol_name = hal_common_get_backend_symbol_name(module); if (!symbol_name) { _E("Failed to get backend symbol name of %s\n", hal_module_info[module].module_name); @@ -111,8 +111,7 @@ int hal_common_get_backend(enum hal_module module, void **data) /* Print backend module and vendor name */ /* Check HAL ABI Version */ - ret = hal_common_check_backend_abi_version(HAL_MODULE_FOO, - backend->abi_version); + ret = hal_common_check_backend_abi_version(module, backend->abi_version); if (ret < 0) { _E("Failed to check ABI version of %s\n", hal_module_info[module].module_name); -- 2.7.4 From 6c39b97c886d317b624d6f7d6d386cb48aae30dd Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Fri, 8 Jan 2021 12:46:15 +0900 Subject: [PATCH 08/11] halapi: common: Change the parameter name of helper functions for readability hal-api-common's helper functions have the 'enum hal_module' as first parameter. In order to improve the readability, replace parameter name from 'handle' to 'module'. Change-Id: I3baa384885d9e5225987f143d4b1951c4b6aedd6 Signed-off-by: Chanwoo Choi --- include/hal-common.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/hal-common.h b/include/hal-common.h index e25503b..9df3d31 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -105,7 +105,7 @@ enum hal_module { * @return @c backend library name on success and don't need to be freed * due to the global variable, otherwise NULL. */ -const char *hal_common_get_backend_library_name(enum hal_module handle); +const char *hal_common_get_backend_library_name(enum hal_module module); /** * @brief Get the backend symbol name according to the type of HAL module @@ -113,7 +113,7 @@ const char *hal_common_get_backend_library_name(enum hal_module handle); * @return @c backend library name on success and don't need to be freed * due to the global variable, otherwise NULL. */ -const char *hal_common_get_backend_symbol_name(enum hal_module handle); +const char *hal_common_get_backend_symbol_name(enum hal_module module); /** * @brief Get the backend data according to the type of HAL module @@ -122,7 +122,7 @@ const char *hal_common_get_backend_symbol_name(enum hal_module handle); * should be stored from HAL backend binary. * @return @c 0 on success, otherwise a negative error value */ -int hal_common_get_backend(enum hal_module handle, void **data); +int hal_common_get_backend(enum hal_module module, void **data); /** * @brief Put the backend data according to the type of HAL module @@ -130,7 +130,7 @@ int hal_common_get_backend(enum hal_module handle, void **data); * @param[in] Data pointer where 'hal_backend_[module]_funcs' instance * @return @c 0 on success, otherwise a negative error value */ -int hal_common_put_backend(enum hal_module handle, void *data); +int hal_common_put_backend(enum hal_module module, void *data); /** * @brief Check HAL ABI version whehter is suppored or not on current platform @@ -138,7 +138,7 @@ int hal_common_put_backend(enum hal_module handle, void *data); * @param[in] HAL ABI version of backend module among enum hal_abi_version * @return @c 0 on success, otherwise a negative error value */ -int hal_common_check_backend_abi_version(enum hal_module handle, +int hal_common_check_backend_abi_version(enum hal_module module, enum hal_abi_version abi_version); #ifdef __cplusplus -- 2.7.4 From 415c591303fca1ea627f277b620b7f71914973b6 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Mon, 11 Jan 2021 08:03:47 +0900 Subject: [PATCH 09/11] halapi: common: Add hal_api_version_str array and an error message Add hal_api_version_str array to display as string after converting each enum value. It's easier to understand than using enum value. If abi version doesn't support about current version and compatible version, then it needs to notice about not supporting abi_version. Change-Id: I67f31423a4b9d911b269d8c7560c9907a6bafc8b Signed-off-by: Jaehoon Chung --- include/hal-common-interface.h | 5 +++++ src/hal-api-common.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/hal-common-interface.h b/include/hal-common-interface.h index 39831b9..dab26cb 100644 --- a/include/hal-common-interface.h +++ b/include/hal-common-interface.h @@ -29,6 +29,11 @@ enum hal_abi_version { HAL_ABI_VERSION_END, }; +static const char *const hal_abi_version_str[] = { + [HAL_ABI_VERSION_UNKNOWN] = "Unknown HAL ABI Version", + [HAL_ABI_VERSION_TIZEN_6_5] = "HAL_ABI_VERSION_TIZEN_6_5", +}; + typedef struct __hal_backend { const char *name; const char *vendor; diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 9f47636..61ef60c 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -222,6 +222,12 @@ int hal_common_check_backend_abi_version(enum hal_module module, if (abi_version <= data->curr_version && abi_version >= data->compat_version) return TIZEN_ERROR_NONE; + + _E("%s doesn't support %s of HAL Backend\n", hal_abi_version_str[g_curr_hal_abi_version], + hal_abi_version_str[abi_version]); + _E("Must use the following ABI versions from %s to %s\n", + hal_abi_version_str[data->compat_version], + hal_abi_version_str[data->curr_version]); } return TIZEN_ERROR_INVALID_PARAMETER; -- 2.7.4 From b615b27655bbaae210b76483f3760cd1791a2a8c Mon Sep 17 00:00:00 2001 From: Chanwoo Choi Date: Mon, 11 Jan 2021 15:00:55 +0900 Subject: [PATCH 10/11] halapi: common: Change variable name for improving the readability Change the variable name for improving the readability because prior defined variable name is vague to pass the correct meaning of version. So that change the name as following in order to improve the readability and understanding. [Chagned variable names] - g_curr_hal_abi_version -> g_platform_curr_abi_version - current_version -> platform_abi_version - compat_version -> backend_min_abi_version Change-Id: I733b203a6c0fe058dedb6e9e26f832a0629ccc15 Signed-off-by: Chanwoo Choi --- src/common.h | 122 +++++++++++++++++++++++++-------------------------- src/hal-api-common.c | 12 ++--- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/common.h b/src/common.h index 39ab920..7f9dadf 100644 --- a/src/common.h +++ b/src/common.h @@ -36,35 +36,35 @@ * and HAL backend package like hal-backend-audio-*.rpm which is included * in hal.img. In order to compare ABI version between two binary, * Tizen core platform always must maintain the current HAL ABI version. - * So that, define the below global variable (g_curr_hal_abi_version). + * So that, define the below global variable (g_platform_curr_abi_version). * - * 'g_curr_hal_abi_version' will be used for all HAL API modules, + * 'g_platform_curr_abi_version' will be used for all HAL API modules, * to check whether HAL backend ABI version of each module in hal.img * is supported or not with current Tizen core HAL ABI version. * - * 'g_curr_hal_abi_version' must be updated when Tizen platform will be released - * officially. + * 'g_platform_curr_abi_version' must be updated when Tizen platform + * will be released officially. */ /* FIXME: Need to be initialized by configuration file like xml */ -enum hal_abi_version g_curr_hal_abi_version = HAL_ABI_VERSION_TIZEN_6_5; +enum hal_abi_version g_platform_curr_abi_version = HAL_ABI_VERSION_TIZEN_6_5; struct hal_abi_version_match { - enum hal_abi_version curr_version; - enum hal_abi_version compat_version; + enum hal_abi_version platform_abi_version; + enum hal_abi_version backend_min_abi_version; } 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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, [HAL_MODULE_COREGL] = { @@ -84,22 +84,22 @@ struct hal_abi_version_match { [HAL_MODULE_AUDIO] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, [HAL_MODULE_CODEC] = { @@ -125,15 +125,15 @@ struct hal_abi_version_match { [HAL_MODULE_BLUETOOTH] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, [HAL_MODULE_NAN] = { @@ -141,22 +141,22 @@ struct hal_abi_version_match { [HAL_MODULE_NFC] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, [HAL_MODULE_MTP] = { @@ -170,8 +170,8 @@ struct hal_abi_version_match { [HAL_MODULE_TELPEPHONY] = { /* FIXME: Need to be determined whehter support HAL API or not. */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, @@ -179,8 +179,8 @@ struct hal_abi_version_match { [HAL_MODULE_LOCATION] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, @@ -190,100 +190,100 @@ struct hal_abi_version_match { [HAL_MODULE_POWER] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .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] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, @@ -292,8 +292,8 @@ struct hal_abi_version_match { [HAL_MODULE_FOO] = { /* FIXME: Need to be initialized by configuration file like xml */ [0] = { - .curr_version = HAL_ABI_VERSION_TIZEN_6_5, - .compat_version = HAL_ABI_VERSION_TIZEN_6_5, + .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, + .backend_min_abi_version = HAL_ABI_VERSION_TIZEN_6_5, }, }, }; diff --git a/src/hal-api-common.c b/src/hal-api-common.c index 61ef60c..896691c 100644 --- a/src/hal-api-common.c +++ b/src/hal-api-common.c @@ -216,18 +216,18 @@ int hal_common_check_backend_abi_version(enum hal_module module, struct hal_abi_version_match *data = &hal_module_info[module].abi_versions[i]; - if (g_curr_hal_abi_version != data->curr_version) + if (g_platform_curr_abi_version != data->platform_abi_version) continue; - if (abi_version <= data->curr_version - && abi_version >= data->compat_version) + if (abi_version <= data->platform_abi_version + && abi_version >= data->backend_min_abi_version) return TIZEN_ERROR_NONE; - _E("%s doesn't support %s of HAL Backend\n", hal_abi_version_str[g_curr_hal_abi_version], + _E("%s doesn't support %s of HAL Backend\n", hal_abi_version_str[g_platform_curr_abi_version], hal_abi_version_str[abi_version]); _E("Must use the following ABI versions from %s to %s\n", - hal_abi_version_str[data->compat_version], - hal_abi_version_str[data->curr_version]); + hal_abi_version_str[data->backend_min_abi_version], + hal_abi_version_str[data->platform_abi_version]); } return TIZEN_ERROR_INVALID_PARAMETER; -- 2.7.4 From b7115a417e172637844acb3e2229161d915bd989 Mon Sep 17 00:00:00 2001 From: Seungha Son Date: Tue, 12 Jan 2021 17:52:23 +0900 Subject: [PATCH 11/11] Fix wrong spelling HAL_MODULE_TELPEPHONY -> HAL_MODULE_TELEPHONY Change-Id: Ie3b77e9b3839de8306e2c49e10bdeb4b3fe91744 Signed-off-by: Seungha Son --- include/hal-common.h | 2 +- src/common.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hal-common.h b/include/hal-common.h index 9df3d31..09df968 100644 --- a/include/hal-common.h +++ b/include/hal-common.h @@ -72,7 +72,7 @@ enum hal_module { HAL_MODULE_MTP, /* HAL_GROUP_TELEPHONY */ - HAL_MODULE_TELPEPHONY = 45, + HAL_MODULE_TELEPHONY = 45, /* HAL_GROUP_LOCATION */ HAL_MODULE_LOCATION = 50, diff --git a/src/common.h b/src/common.h index 7f9dadf..c8b263b 100644 --- a/src/common.h +++ b/src/common.h @@ -167,7 +167,7 @@ struct hal_abi_version_match { }, /* HAL_GROUP_TELEPHONY */ - [HAL_MODULE_TELPEPHONY] = { + [HAL_MODULE_TELEPHONY] = { /* FIXME: Need to be determined whehter support HAL API or not. */ [0] = { .platform_abi_version = HAL_ABI_VERSION_TIZEN_6_5, @@ -526,9 +526,9 @@ static struct __hal_module_info { }, /* HAL_GROUP_TELEPHONY */ - [HAL_MODULE_TELPEPHONY] = { + [HAL_MODULE_TELEPHONY] = { .group = HAL_GROUP_TELEPHONY, - .module = HAL_MODULE_TELPEPHONY, + .module = HAL_MODULE_TELEPHONY, .license = HAL_LICENSE_APACHE_2_0, .module_name = "TELEPHONY", .library_name = NULL, -- 2.7.4