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 #define UUID_MAX_STR_LEN 40U 38 39 /* 64 byte head + user log */ 40 struct LogItem { 41 uint8_t neverUsed[NEVER_USED_LEN]; 42 uint16_t magic; 43 uint16_t reserved0; 44 uint32_t serialNo; 45 uint16_t logRealLen; /* log real len */ 46 uint16_t logBufferLen; /* log buffer's len, multiple of 32 bytes */ 47 uint8_t uuid[TEE_UUID_LEN]; 48 uint8_t logSourceType; 49 uint8_t reserved[ITEM_RESERVED_LEN]; 50 uint8_t logLevel; 51 uint8_t newLine; /* '\n' char, easy viewing log in bbox.bin file */ 52 uint8_t logBuffer[0]; 53 }; 54 55 #define CLOCK_SEG_NODE_LEN 8U 56 struct TeeUuid { 57 uint32_t timeLow; 58 uint16_t timeMid; 59 uint16_t timeHiAndVersion; 60 uint8_t clockSeqAndNode[CLOCK_SEG_NODE_LEN]; 61 }; 62 63 void GetUuidStr(const struct TeeUuid *uuid, char *name, uint32_t nameLen); 64 65 #endif 66