1/* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _TRACE_TLV_H 33#define _TRACE_TLV_H 34 35#include "los_compiler.h" 36 37#ifdef __cplusplus 38#if __cplusplus 39extern "C" { 40#endif /* __cplusplus */ 41#endif /* __cplusplus */ 42 43#define TRACE_TLV_MSG_HEAD 0xFF 44#define TRACE_TLV_TYPE_NULL 0xFF 45 46typedef struct { 47 UINT8 magicNum; 48 UINT8 msgType; 49 UINT16 len; 50 UINT16 crc; 51} TraceMsgTlvHead; 52 53typedef struct { 54 UINT8 type; 55 UINT8 len; 56 UINT8 value[]; 57} TraceMsgTlvBody; 58 59typedef struct { 60 UINT8 tag; 61 UINT8 elemOffset; 62 UINT8 elemSize; 63} TlvTable; 64 65/** 66 * @ingroup los_trace 67 * @brief Encode trace raw data. 68 * 69 * @par Description: 70 * This API is used to encode trace raw data to tlv data. 71 * @attention 72 * <ul> 73 * <li>Encade trace data</li> 74 * </ul> 75 * 76 * @param type [IN] Type #UINT8. The type stands for different struct of src data. 77 * @param src [IN] Type #UINT8 *. The raw trace data. 78 * @param table [IN] Type #const TlvTable *. The tlv table descript elemOffset and elemSize. 79 * @param dest [OUT] Type #UINT8 *. The tlv data. 80 * @param destLen [IN] Type #UINT8 *. The tlv buf max len. 81 82 * @retval #0 convert failed. 83 * @retval #UINT32 convert success bytes. 84 * 85 * @par Dependency: 86 * <ul><li>trace_tlv.h: the header file that contains the API declaration.</li></ul> 87 * @see LOS_TraceDataEncode 88 */ 89extern UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen); 90 91#ifdef __cplusplus 92#if __cplusplus 93} 94#endif /* __cplusplus */ 95#endif /* __cplusplus */ 96 97#endif /* _TRACE_TLV_H */ 98