SET(TEE_STUB_HEADERS
${TEF_SIMULATOR_INCLUDE_PATH}/include/tee_internal_api.h
+ ${TEF_SIMULATOR_INCLUDE_PATH}/include/log_level.h
+ ${TEF_SIMULATOR_INCLUDE_PATH}/include/debug.h
)
ADD_LIBRARY(${TARGET_TEF_SIMULATOR_TEE_STUB} STATIC
--- /dev/null
+/*
+ * debug.h
+ *
+ * This source file is proprietary property of Samsung Electronics Co., Ltd.
+ *
+ * Copyright (C) 2011 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jaemin Ryu <jm77.ryu@samsung.com>
+ *
+ */
+
+#ifndef __ALLOC_DEBUG_H__
+#define __ALLOC_DEBUG_H__
+
+#include <log_level.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TEE_STUB "TEE_STUB"
+#define LOG_LABEL_SIZE 64
+
+int __logger_log(const char* tag, const usr_log_level lv, const char* fmt, const char* function, const int line, ...);
+
+#define LOGD(Tag, Fmt, ...) __logger_log(Tag, LOG_DEBUG, Fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define LOGI(Tag, Fmt, ...) __logger_log(Tag, LOG_INFO, Fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define LOGW(Tag, Fmt, ...) __logger_log(Tag, LOG_WARNING, Fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define LOGE(Tag, Fmt, ...) __logger_log(Tag, LOG_ERR, Fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define LOGC(Tag, Fmt, ...) __logger_log(Tag, LOG_CRIT, Fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+void setDebugLogLevelNum(const usr_log_level __level);
+int getDebugLogLevelNum(void);
+void setDebugLogLevel(const char* __level);
+void setDebugLogName(const char* __name); /* buffer(__name) size should be LOG_LABEL_SIZE(64) */
+void getDebugLogName(char* __name); /* buffer(__name) size should be LOG_LABEL_SIZE(64) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ALLOC_DEBUG_H */
SET(LOG_SOURCES
${LOG_PATH}/log.c
+ ${LOG_PATH}/ta_log.c
)
+INCLUDE_DIRECTORIES(
+ ${TEF_SIMULATOR_INCLUDE_PATH}/include
+)
+
ADD_LIBRARY(${TARGET_TEF_SIMULATOR_LOG} ${LOG_SOURCES})
INSTALL(TARGETS ${TARGET_TEF_SIMULATOR_LOG} DESTINATION ${LIB_DIR})
switch (module_level) {
case MODULE_UTILS:
return "UTILS";
-
case MODULE_SIM_DAEMON:
return "SIM_DAEMON";
-
case MODULE_TEEC_LIB:
return "TEEC_LIB";
-
case MODULE_TEE_STUB:
return "TEE_STUB";
-
case MODULE_SSF_LIB:
return "SSF_LIB";
-
case MODULE_OSA_LIB:
return "OSA_LIB";
-
+ case MODULE_CLIENT_TA:
+ return "CLIENT_TA";
default:
return "TA_SDK";
}
}
#endif
-static void PrintLog(IN const char *tag, IN const char *function_name,
- IN const int32_t line_no, IN int32_t module_level,
- IN LogLevel log_level, IN const char *message,
- va_list variable_list)
+void PrintLog(IN const char *tag, IN const char *function_name,
+ IN const int32_t line_no, IN int32_t module_level,
+ IN LogLevel log_level, IN const char *message,
+ va_list variable_list)
{
if (!(module_level & gmodule_level)
|| log_level > glog_level)
MODULE_TEST = 0x10,
MODULE_SSF_LIB = 0x20,
MODULE_OSA_LIB = 0x40,
+ MODULE_CLIENT_TA = 0x80,
MODULE_ALL = 0xFFFFFFF,
} ModuleLevel;
void PrintSimulatorLog(IN const char* function_name, IN const int32_t line_no,
IN int32_t module_level, IN int32_t log_level,
IN const char* message, ...);
+
+void PrintLog(IN const char *tag, IN const char *function_name,
+ IN const int32_t line_no, IN int32_t module_level,
+ IN LogLevel log_level, IN const char *message,
+ va_list variable_list);
#if defined(__cplusplus)
} // extern "C"
#endif
--- /dev/null
+/**
+ * Copyright (c) 2015-2017 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.
+ */
+
+/**
+ * @file
+ * @author Igor Kotrasinski (i.kotrasinsk@partner.samsung.som)
+ * @brief Logging interface for TAs
+ */
+
+
+/*-----------------------------------------------------------------------------
+ * Include files
+ *-----------------------------------------------------------------------------*/
+#include <stdlib.h>
+#include "log_level.h"
+#include "log.h"
+
+/* Do not include debug.h, its LOG* definitions conflict with dlog */
+
+#define LOG_LABEL_SIZE 64
+#define LOG_BUFFER_SIZE 4096
+
+static int level = TA_LOG_LEVEL;
+static char log_label[LOG_LABEL_SIZE];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The LOG_* names in log_level.h conflict with syslog names, so we can't use
+ * them directly. At the same time usr_log_level is part of public API, so we
+ * can't change it.
+ */
+static LogLevel taLogLevelToLogLevel(usr_log_level log_level) {
+ switch(log_level) {
+ case LOG_EMERG:
+ return SIMU_LOG_EMERG;
+ case LOG_ALERT:
+ return SIMU_LOG_ALERT;
+ case LOG_CRIT:
+ return SIMU_LOG_CRIT;
+ case LOG_ERR:
+ return SIMU_LOG_ERR;
+ case LOG_WARNING:
+ return SIMU_LOG_WARNING;
+ case LOG_NOTICE:
+ return SIMU_LOG_NOTICE;
+ case LOG_INFO:
+ return SIMU_LOG_INFO;
+ case LOG_DEBUG:
+ return SIMU_LOG_DEBUG;
+ case LOG_SILENT:
+ default:
+ return SIMU_LOG_SILENT;
+ }
+}
+
+int getDebugLogLevelNum(void)
+{
+ return level;
+}
+
+void setDebugLogLevel(const char* __level)
+{
+ if(__level != NULL)
+ level = atoi(__level);
+}
+
+void setDebugLogLevelNum(const usr_log_level __level)
+{
+ level = __level;
+}
+
+void getDebugLogName(char* __name)
+{
+ if(__name != NULL) {
+ int length = strlen(log_label);
+ strncpy(__name, log_label, length);
+ __name[length] = '\0';
+ }
+}
+
+void setDebugLogName(const char* __name)
+{
+ if(__name == NULL)
+ return;
+
+ strncpy(log_label, __name, sizeof(log_label)-1);
+ log_label[sizeof(log_label)-1] = 0;
+}
+
+int __logger_log(const char* tag, const usr_log_level lv,
+ const char* fmt, const char* function,
+ const int line, ...)
+{
+ LogLevel ta_log_level = taLogLevelToLogLevel(lv);
+
+ if (fmt == NULL || function == NULL)
+ return 0;
+ if (tag != NULL && strlen(log_label) == 0)
+ setDebugLogName(tag);
+ if (level < lv || level == LOG_SILENT)
+ return 0;
+
+ va_list args;
+ va_start(args, line);
+ PrintLog(log_label, function, line, MODULE_CLIENT_TA, ta_log_level, fmt, args);
+ va_end(args);
+ return 0; // TODO
+}
+
+void initDebugLogLevel(const char* fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+ __logger_log("Level", LOG_DEBUG, fmt, __FILE__, __LINE__, args);
+ va_end(args);
+}
+
+#ifdef __cplusplus
+}
+#endif
%{lib_dir}/libtef-simulator-log.a
%{lib_dir}/libtef-simulator-osal.a
%{include_dir}/tee_internal_api.h
+%{include_dir}/debug.h
+%{include_dir}/log_level.h
%{lib_dir}/pkgconfig/tef-simulator-devkit.pc
%{data_dir}/cmake/Modules/TEFSimulatorDevkit.cmake
%{data_dir}/GPD_TEE_PROP