1/*
2 * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3 * Decription: TEE Logging Subsystem, read the tee os log from rdr memory
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef TLOGGER_H
15#define TLOGGER_H
16
17#include <linux/types.h>
18
19#define OPEN_FILE_MODE		  0640U
20#define ROOT_UID			  0
21#define ROOT_GID			  0
22#define SYSTEM_GID			  1000
23#ifdef LAST_TEE_MSG_ROOT_GID
24#define FILE_CHOWN_GID		  0
25#else
26/* system gid for last_teemsg file sys chown */
27#define FILE_CHOWN_GID		  1000
28#endif
29
30#define UINT64_MAX (uint64_t)(~((uint64_t)0)) /* 0xFFFFFFFFFFFFFFFF */
31
32#ifdef CONFIG_TEELOG
33void tz_log_write(void);
34int tlogger_store_msg(const char *file_path, uint32_t file_path_len);
35int register_mem_to_teeos(uint64_t mem_addr, uint32_t mem_len, bool is_cache_mem);
36
37#ifdef CONFIG_TZDRIVER_MODULE
38int init_tlogger_service(void);
39void free_tlogger_service(void);
40int register_tloger_mem(void);
41#endif
42
43#else
44static inline void tz_log_write(void)
45{
46	return;
47}
48
49static inline int tlogger_store_msg(const char *file_path, uint32_t file_path_len)
50{
51	(void)file_path;
52	(void)file_path_len;
53	return 0;
54}
55static inline int register_mem_to_teeos(uint64_t mem_addr, uint32_t mem_len,
56	bool is_cache_mem)
57{
58	(void)mem_addr;
59	(void)mem_len;
60	return 0;
61}
62static inline int init_tlogger_service(void)
63{
64	return 0;
65}
66static inline void free_tlogger_service(void)
67{
68}
69#endif
70#endif
71