diff mbox

[KEYSTONE2,02/15] linux-ks2: debug: sort out after merge

Message ID 1426001473-14618-3-git-send-email-taras.kondratiuk@linaro.org
State New
Headers show

Commit Message

Taras Kondratiuk March 10, 2015, 3:31 p.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Signed-off-by: Taras Kondratiuk <taras@ti.com>
---
 platform/linux-keystone2/Makefile.am               |  1 +
 platform/linux-keystone2/include/odp/plat/debug.h  | 88 ++++++++++++++++++++++
 .../linux-keystone2/include/odp_debug_internal.h   | 78 +++----------------
 3 files changed, 98 insertions(+), 69 deletions(-)
 create mode 100644 platform/linux-keystone2/include/odp/plat/debug.h
diff mbox

Patch

diff --git a/platform/linux-keystone2/Makefile.am b/platform/linux-keystone2/Makefile.am
index 638b903..d17ea45 100644
--- a/platform/linux-keystone2/Makefile.am
+++ b/platform/linux-keystone2/Makefile.am
@@ -58,6 +58,7 @@  odpinclude_HEADERS = \
 
 odpplatincludedir = $(includedir)/odp/plat
 odpplatinclude_HEADERS = \
+		  $(srcdir)/include/odp/plat/debug.h \
 		  $(srcdir)/include/odp/plat/mcsdk_tune.h \
 		  $(srcdir)/include/odp/plat/state.h \
 		  $(srcdir)/include/odp/plat/ti_mcsdk.h \
diff --git a/platform/linux-keystone2/include/odp/plat/debug.h b/platform/linux-keystone2/include/odp/plat/debug.h
new file mode 100644
index 0000000..2a40404
--- /dev/null
+++ b/platform/linux-keystone2/include/odp/plat/debug.h
@@ -0,0 +1,88 @@ 
+/*
+ * Copyright (c) 2014, Linaro Limited
+ * Copyright (c) 2014, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#ifndef ODP_DEBUG_INTERNAL_H_
+#define ODP_DEBUG_INTERNAL_H_
+
+#include <stdio.h>
+#include <odp/plat/state.h>
+
+/**
+ * Runtime assertion-macro - aborts if 'cond' is false.
+ */
+#define ODP_ASSERT(cond, fmt, ...) \
+	do { if ((ODP_DEBUG == 1) && (!(cond))) \
+		ODP_ABORT(fmt "\n", ##__VA_ARGS__); \
+	} while (0)
+
+/**
+ * This macro is used to indicate when a given function is not implemented
+ */
+#define ODP_UNIMPLEMENTED() \
+		odp_proc.log_fn(ODP_LOG_UNIMPLEMENTED, \
+			"%s:%d:The function %s() is not implemented\n", \
+			__FILE__, __LINE__, __func__)
+/**
+ * Log debug message if ODP_DEBUG_PRINT flag is set.
+ */
+#define ODP_DBG(fmt, ...) \
+	do { \
+		if (ODP_DEBUG_PRINT == 1) \
+			ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__);\
+	} while (0)
+
+/**
+ * Log error message.
+ */
+#define ODP_ERR(fmt, ...) \
+		ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
+
+/**
+ * Log abort message and then stop execution (by default call abort()).
+ * This function should not return.
+ */
+#define ODP_ABORT(fmt, ...) \
+	do { \
+		ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__); \
+		odp_proc.abort_fn(); \
+	} while (0)
+
+/**
+ * ODP LOG macro.
+ */
+#define ODP_LOG(level, fmt, ...) \
+	odp_proc.log_fn(level, "%s:%d:%s():" fmt, __FILE__, \
+	__LINE__, __func__, ##__VA_ARGS__)
+
+/**
+ * Log print message when the application calls one of the ODP APIs
+ * specifically for dumping internal data.
+ */
+#define ODP_PRINT(fmt, ...) \
+	odp_proc.log_fn(ODP_LOG_PRINT, " " fmt, ##__VA_ARGS__)
+
+#define odp_pr_err  ODP_ERR
+#define odp_pr_warn ODP_ERR
+#define odp_pr_info ODP_PRINT
+#define odp_pr_dbg  ODP_DBG
+#if 0
+#define odp_pr_vdbg ODP_DBG
+#else
+#define odp_pr_vdbg(...)
+#endif
+
+void odp_print_mem(void *addr, size_t size, const char *desc);
+
+#define odp_pr_err_mem(...)  odp_print_mem
+#ifdef ODP_DEBUG_PRINT
+#define odp_pr_dbg_mem odp_print_mem
+#else
+#define odp_pr_dbg_mem
+#endif
+
+#endif
diff --git a/platform/linux-keystone2/include/odp_debug_internal.h b/platform/linux-keystone2/include/odp_debug_internal.h
index a93e282..839d66f 100644
--- a/platform/linux-keystone2/include/odp_debug_internal.h
+++ b/platform/linux-keystone2/include/odp_debug_internal.h
@@ -1,76 +1,16 @@ 
-/*
- * Copyright (c) 2014, Linaro Limited
- * Copyright (c) 2014, Texas Instruments Incorporated
+/* Copyright (c) 2014, Linaro Limited
  * All rights reserved.
  *
  * SPDX-License-Identifier:     BSD-3-Clause
  */
-
-#ifndef ODP_DEBUG_INTERNAL_H_
-#define ODP_DEBUG_INTERNAL_H_
-
-#include <stdio.h>
-#include <odp_debug.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ODP_PRINT_LEVEL_DISABLED 0
-#define ODP_PRINT_LEVEL_CRIT     1
-#define ODP_PRINT_LEVEL_ERR      2
-#define ODP_PRINT_LEVEL_WARN     3
-#define ODP_PRINT_LEVEL_INFO     4
-#define ODP_PRINT_LEVEL_DBG      5
-#define ODP_PRINT_LEVEL_VDBG     6
-#define ODP_PRINT_LEVEL_MAX      7
-
-#define ODP_PRINT_LEVEL ODP_PRINT_LEVEL_DBG
-
-/**
- * Internal debug printing macro
- */
-#ifndef ODP_NO_PRINT
-#define odp_print(level, fmt, ...)                                    \
-		do { if (level <= ODP_PRINT_LEVEL)                    \
-			fprintf(stderr, "%s():%d: " fmt,              \
-				__func__, __LINE__, ##__VA_ARGS__);   \
-		} while (0)
-#else
-#define odp_print(level, fmt, ...)
-#endif
-
-#define odp_pr_err(fmt, ...)  \
-		odp_print(ODP_PRINT_LEVEL_ERR, fmt, ##__VA_ARGS__)
-#define odp_pr_warn(fmt, ...) \
-		odp_print(ODP_PRINT_LEVEL_WARN, fmt, ##__VA_ARGS__)
-#define odp_pr_info(fmt, ...) \
-		odp_print(ODP_PRINT_LEVEL_INFO, fmt, ##__VA_ARGS__)
-#define odp_pr_dbg(fmt, ...)  \
-		odp_print(ODP_PRINT_LEVEL_DBG, fmt, ##__VA_ARGS__)
-#define odp_pr_vdbg(fmt, ...) \
-		odp_print(ODP_PRINT_LEVEL_VDBG, fmt, ##__VA_ARGS__)
-
-void odp_print_mem(void *addr, size_t size, const char *desc);
-
-static inline void odp_pr_mem(int level, void *addr, size_t size,
-				const char *desc)
-{
-	if (level <= ODP_PRINT_LEVEL)
-		odp_print_mem(addr, size, desc);
-}
-
-#define odp_pr_err_mem(...)  odp_pr_mem(ODP_PRINT_LEVEL_ERR, ##__VA_ARGS__)
-#define odp_pr_dbg_mem(...)  odp_pr_mem(ODP_PRINT_LEVEL_DBG, ##__VA_ARGS__)
-
 /**
- * This macro is used to indicate when a given function is not implemented
+ * @file
+ *
+ * ODP Debug internal
+ * This file contains implementer support functions for Debug capabilities.
+ *
+ * @note This is a wrapper for a code reused from linux-generic.
  */
-#define ODP_UNIMPLEMENTED(fmt, ...) \
-		ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
-
-#ifdef __cplusplus
-}
-#endif
 
-#endif
+#include <odp/debug.h>
+#include <odp/plat/debug.h>