From: Jihoon Jung Date: Thu, 11 Jul 2024 07:40:44 +0000 (+0900) Subject: Apply multi-hal interface X-Git-Tag: accepted/tizen/unified/20240712.160122^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_dev;p=platform%2Fadaptation%2Femulator%2Fnfc-plugin-emul.git Apply multi-hal interface Change-Id: If4684ba42d74c0c7cc403177258314554a182c9f Signed-off-by: Jihoon Jung --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fb5fdc..32d1ab9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,16 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(hal-backend-nfc C) +IF(ENABLE_DLOG STREQUAL on) + ADD_DEFINITIONS("-DFEATURE_DLOG") +ENDIF() + INCLUDE(FindPkgConfig) SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}") -pkg_check_modules(pkgs REQUIRED dlog vconf hal-api-nfc hal-api-common) +pkg_check_modules(pkgs REQUIRED hal-rootstrap) INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS}) LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS}) diff --git a/packaging/nfc-plugin-emul.spec b/packaging/nfc-plugin-emul.spec index e60ef17..3541d16 100644 --- a/packaging/nfc-plugin-emul.spec +++ b/packaging/nfc-plugin-emul.spec @@ -7,10 +7,7 @@ License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(hal-api-nfc) -BuildRequires: pkgconfig(hal-api-common) +BuildRequires: pkgconfig(hal-rootstrap) %description NFC Plugin Emul diff --git a/src/nfc_debug_private.h b/src/nfc_debug_private.h index ade279f..49bc0c9 100644 --- a/src/nfc_debug_private.h +++ b/src/nfc_debug_private.h @@ -24,10 +24,19 @@ #include #include -// below define should define before blog.h -#define LOG_TAG "NFC_PLUGIN_EMUL" - -#include +#ifdef FEATURE_DLOG + #define LOG_TAG "HAL_BACKEND_NFC_PLUGIN_EMUL" + #include + #define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args) + #define _I(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args) + #define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args) + #define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args) +#else + #define _D(x, ...) + #define _I(x, ...) + #define _W(x, ...) + #define _E(x, ...) +#endif #define LOG_COLOR_RED "\033[0;31m" #define LOG_COLOR_GREEN "\033[0;32m" @@ -42,39 +51,39 @@ #define DEBUG_MSG_PRINT_BUFFER(buffer, length) \ do {\ int i = 0;\ - LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\ + _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\ for (; i < length; i++)\ - LOGE(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\ - LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\ + _D(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\ + _D(LOG_COLOR_BLUE""LOG_COLOR_END);\ } while (0) #define DEBUG_MSG_PRINT_BUFFER_CHAR(buffer, length) \ do {\ int i = 0;\ - LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\ + _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\ for (; i < length; i++)\ - LOGE(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\ - LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\ + _D(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\ + _D(LOG_COLOR_BLUE""LOG_COLOR_END);\ } while (0) #define DEBUG_MSG(format, args...) \ do {\ - LOGE(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\ + _D(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\ } while (0) #define DEBUG_ERR_MSG(format, args...) \ do {\ - LOGE(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\ + _E(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\ } while (0) #define DEBUG_EMUL_BEGIN() \ do {\ - LOGE(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\ + _D(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\ } while (0) #define DEBUG_EMUL_END() \ do {\ - LOGE(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\ + _D(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\ } while (0) #define PROFILING(str) \ @@ -85,8 +94,8 @@ do {\ gettimeofday(&mytime, NULL);\ char time_string[128] = {0,};\ sprintf(time_string, "%d.%4d", mytime.tv_sec, mytime.tv_usec);\ - LOGE(str);\ - LOGE("\t time = [%s]", time_string);\ + _D(str);\ + _D("\t time = [%s]", time_string);\ } while (0) #endif diff --git a/src/oem_emul.c b/src/oem_emul.c old mode 100755 new mode 100644 index 8d55576..169dc61 --- a/src/oem_emul.c +++ b/src/oem_emul.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -220,7 +220,7 @@ static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsi static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int line) { if (mem == NULL || *mem == NULL) { - LOGE("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line); + DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line); return; } free(*mem); @@ -230,19 +230,19 @@ static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int li static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsigned int line) { if (mem == NULL || size <= 0) { - LOGE("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line); + DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line); return; } DEBUG_MSG("size to malloc() = [%d]", size); if (*mem != NULL) - LOGE("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line); + DEBUG_ERR_MSG("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line); *mem = calloc(1, size); if (NULL == *mem) - LOGE("FILE: %s, LINE:%d, Allocation is failed", filename, line); + DEBUG_ERR_MSG("FILE: %s, LINE:%d, Allocation is failed", filename, line); } static bool _net_nfc_util_init_data(data_s * data, uint32_t length) @@ -1054,12 +1054,12 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag memcpy(record.payload.buffer, record_payload, sizeof(record.payload.buffer) - 1); #ifndef __EMUL_DEBUG__ - DEBUG_ERR_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>"); + DEBUG_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>"); DEBUG_MSG("TNF >>>>[%d]", record.tnf); - LOGE("type_name >>>>[%s]", type_name); - LOGE("record_id >>>>[%s]", record_id); + DEBUG_MSG("type_name >>>>[%s]", type_name); + DEBUG_MSG("record_id >>>>[%s]", record_id); DEBUG_MSG("record_payload >>>>[%s]", record_payload); - DEBUG_ERR_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>"); + DEBUG_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>"); #endif /* create record */ @@ -1784,7 +1784,7 @@ static void emul_ReaderThread(void *pArg) /* make file name */ snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME); - LOGE("file path : %s", file_name); + DEBUG_MSG("file path : %s", file_name); /* open file for poll */ emulMsg_file_fd = open(file_name, O_RDONLY | O_NONBLOCK); @@ -1894,7 +1894,7 @@ static void emul_ReaderThread(void *pArg) /* make file name */ snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME); - LOGE("file path : %s", file_name); + DEBUG_MSG("file path : %s", file_name); time(&curTime); DEBUG_MSG("Start Current Time [%ld]", (unsigned long)curTime); @@ -3268,11 +3268,18 @@ static bool net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s static int nfc_backend_init(void **data) { - hal_backend_nfc_funcs *nfc_funcs; + hal_backend_nfc_funcs *nfc_funcs; - nfc_funcs = calloc(1, sizeof(hal_backend_nfc_funcs)); - if (!nfc_funcs) - return -ENOMEM; + if (!data) { + _E("data is NULL"); + return -EINVAL; + } + + nfc_funcs = *(hal_backend_nfc_funcs **)data; + if (!nfc_funcs) { + _E("nfc_funcs is NULL"); + return -EINVAL; + } nfc_funcs->start = net_nfc_emul_controller_init; nfc_funcs->stop = net_nfc_emul_controller_deinit; @@ -3349,8 +3356,10 @@ static int nfc_backend_exit(void *data) EXPORT hal_backend hal_backend_nfc_data = { .name = "nfc-backend", - .vendor = "Emulator", + .vendor = "Samsung", .abi_version = HAL_ABI_VERSION_TIZEN_6_5, .init = nfc_backend_init, .exit = nfc_backend_exit, + .major_version = 1, + .minor_version = 0, };