1 /*
2  * Copyright (C) 2022 Huawei Technologies Co., Ltd.
3  * Licensed under the Mulan PSL v2.
4  * You can use this software according to the terms and conditions of the Mulan PSL v2.
5  * You may obtain a copy of Mulan PSL v2 at:
6  *     http://license.coscl.org.cn/MulanPSL2
7  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
8  * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
9  * PURPOSE.
10  * See the Mulan PSL v2 for more details.
11  */
12 #ifndef TLOGCAT_H
13 #define TLOGCAT_H
14 
15 #include <stdint.h>
16 
17 #ifdef LOG_TEEOS_TAG
18 #undef LOG_TEEOS_TAG
19 #endif
20 #define LOG_TEEOS_TAG               "teeos"
21 
22 #define LOG_ITEM_MAX_LEN            1024
23 
24 #define LEVEL_ERROR                 0
25 #define LEVEL_WARNING               1
26 #define LEVEL_INFO                  2
27 #define LEVEL_DEBUG                 3
28 #define LEVEL_VERBO                 4
29 
30 #define TOTAL_LEVEL_NUMS            5
31 
32 #define LOG_FILE_INDEX_MAX          4U
33 
34 #define NEVER_USED_LEN              32U
35 #define TEE_UUID_LEN                16U
36 #define ITEM_RESERVED_LEN           1U
37 
38 /* 64 byte head + user log */
39 struct LogItem {
40     uint8_t neverUsed[NEVER_USED_LEN];
41     uint16_t magic;
42     uint16_t reserved0;
43     uint32_t serialNo;
44     uint16_t logRealLen;    /* log real len */
45     uint16_t logBufferLen; /* log buffer's len, multiple of 32 bytes */
46     uint8_t uuid[TEE_UUID_LEN];
47     uint8_t logSourceType;
48     uint8_t reserved[ITEM_RESERVED_LEN];
49     uint8_t logLevel;
50     uint8_t newLine; /* '\n' char, easy viewing log in bbox.bin file */
51     uint8_t logBuffer[0];
52 };
53 
54 #define CLOCK_SEG_NODE_LEN 8U
55 struct TeeUuid {
56     uint32_t timeLow;
57     uint16_t timeMid;
58     uint16_t timeHiAndVersion;
59     uint8_t clockSeqAndNode[CLOCK_SEG_NODE_LEN];
60 };
61 #endif
62