1/* 2 * tc_ns_log.h 3 * 4 * log func declaration 5 * 6 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 7 * 8 * This software is licensed under the terms of the GNU General Public 9 * License version 2, as published by the Free Software Foundation, and 10 * may be copied, distributed, and modified under those terms. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 */ 17#ifndef TC_NS_LOG_H 18#define TC_NS_LOG_H 19 20#include <linux/version.h> 21#if (KERNEL_VERSION(4, 14, 0) <= LINUX_VERSION_CODE) 22#include <linux/sched/mm.h> 23#endif 24#include <linux/printk.h> 25enum { 26 TZ_DEBUG_VERBOSE = 0, 27 TZ_DEBUG_DEBUG, 28 TZ_DEBUG_INFO, 29 TZ_DEBUG_WARN, 30 TZ_DEBUG_ERROR, 31}; 32#define MOD_TEE "tzdriver" 33 34#define TEE_LOG_MASK TZ_DEBUG_INFO 35 36#define tlogv(fmt, args...) \ 37do { \ 38 if (TZ_DEBUG_VERBOSE >= TEE_LOG_MASK) \ 39 pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 40} while (0) 41 42 43#define tlogd(fmt, args...) \ 44do { \ 45 if (TZ_DEBUG_DEBUG >= TEE_LOG_MASK) \ 46 pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 47} while (0) 48 49 50#define tlogi(fmt, args...) \ 51do { \ 52 if (TZ_DEBUG_INFO >= TEE_LOG_MASK) \ 53 pr_info("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 54} while (0) 55 56 57#define tlogw(fmt, args...) \ 58do { \ 59 if (TZ_DEBUG_WARN >= TEE_LOG_MASK) \ 60 pr_warn("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args); \ 61} while (0) 62 63 64#define tloge(fmt, args...) \ 65 pr_err("[%s] (%i, %s)%s: " fmt, MOD_TEE, current->pid, current->comm, __func__, ## args) 66 67#endif 68