1419b0af8Sopenharmony_ci/* 2419b0af8Sopenharmony_ci * tc_ns_log.h 3419b0af8Sopenharmony_ci * 4419b0af8Sopenharmony_ci * log func declaration 5419b0af8Sopenharmony_ci * 6419b0af8Sopenharmony_ci * Copyright (C) 2022 Huawei Technologies Co., Ltd. 7419b0af8Sopenharmony_ci * 8419b0af8Sopenharmony_ci * This software is licensed under the terms of the GNU General Public 9419b0af8Sopenharmony_ci * License version 2, as published by the Free Software Foundation, and 10419b0af8Sopenharmony_ci * may be copied, distributed, and modified under those terms. 11419b0af8Sopenharmony_ci * 12419b0af8Sopenharmony_ci * This program is distributed in the hope that it will be useful, 13419b0af8Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14419b0af8Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15419b0af8Sopenharmony_ci * GNU General Public License for more details. 16419b0af8Sopenharmony_ci */ 17419b0af8Sopenharmony_ci#ifndef TC_NS_LOG_H 18419b0af8Sopenharmony_ci#define TC_NS_LOG_H 19419b0af8Sopenharmony_ci 20419b0af8Sopenharmony_ci#include <linux/version.h> 21419b0af8Sopenharmony_ci#if (KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE) 22419b0af8Sopenharmony_ci#include <linux/sched/mm.h> 23419b0af8Sopenharmony_ci#endif 24419b0af8Sopenharmony_ci#include <linux/printk.h> 25419b0af8Sopenharmony_cienum { 26419b0af8Sopenharmony_ci TZ_DEBUG_VERBOSE = 0, 27419b0af8Sopenharmony_ci TZ_DEBUG_DEBUG, 28419b0af8Sopenharmony_ci TZ_DEBUG_INFO, 29419b0af8Sopenharmony_ci TZ_DEBUG_WARN, 30419b0af8Sopenharmony_ci TZ_DEBUG_ERROR, 31419b0af8Sopenharmony_ci}; 32419b0af8Sopenharmony_ci#define MOD_TEE "tzdriver" 33419b0af8Sopenharmony_ci 34419b0af8Sopenharmony_ci#define TEE_LOG_MASK TZ_DEBUG_INFO 35419b0af8Sopenharmony_ci 36419b0af8Sopenharmony_ci#define tlogv(fmt, args...) \ 37419b0af8Sopenharmony_cido { \ 38419b0af8Sopenharmony_ci if (TZ_DEBUG_VERBOSE >= TEE_LOG_MASK) \ 39419b0af8Sopenharmony_ci pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 40419b0af8Sopenharmony_ci} while (0) 41419b0af8Sopenharmony_ci 42419b0af8Sopenharmony_ci 43419b0af8Sopenharmony_ci#define tlogd(fmt, args...) \ 44419b0af8Sopenharmony_cido { \ 45419b0af8Sopenharmony_ci if (TZ_DEBUG_DEBUG >= TEE_LOG_MASK) \ 46419b0af8Sopenharmony_ci pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 47419b0af8Sopenharmony_ci} while (0) 48419b0af8Sopenharmony_ci 49419b0af8Sopenharmony_ci 50419b0af8Sopenharmony_ci#define tlogi(fmt, args...) \ 51419b0af8Sopenharmony_cido { \ 52419b0af8Sopenharmony_ci if (TZ_DEBUG_INFO >= TEE_LOG_MASK) \ 53419b0af8Sopenharmony_ci pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 54419b0af8Sopenharmony_ci} while (0) 55419b0af8Sopenharmony_ci 56419b0af8Sopenharmony_ci 57419b0af8Sopenharmony_ci#define tlogw(fmt, args...) \ 58419b0af8Sopenharmony_cido { \ 59419b0af8Sopenharmony_ci if (TZ_DEBUG_WARN >= TEE_LOG_MASK) \ 60419b0af8Sopenharmony_ci pr_warn("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 61419b0af8Sopenharmony_ci} while (0) 62419b0af8Sopenharmony_ci 63419b0af8Sopenharmony_ci 64419b0af8Sopenharmony_ci#define tloge(fmt, args...) \ 65419b0af8Sopenharmony_ci pr_err("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args) 66419b0af8Sopenharmony_ci 67419b0af8Sopenharmony_ci#endif 68