162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 462306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright(c) 2018 Intel Corporation. All rights reserved. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __INCLUDE_SOUND_SOF_TRACE_H__ 1062306a36Sopenharmony_ci#define __INCLUDE_SOUND_SOF_TRACE_H__ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <sound/sof/header.h> 1362306a36Sopenharmony_ci#include <sound/sof/stream.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* 1662306a36Sopenharmony_ci * DMA for Trace 1762306a36Sopenharmony_ci */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define SOF_TRACE_FILENAME_SIZE 32 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ 2262306a36Sopenharmony_ci/* Deprecated - use sof_ipc_dma_trace_params_ext */ 2362306a36Sopenharmony_cistruct sof_ipc_dma_trace_params { 2462306a36Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 2562306a36Sopenharmony_ci struct sof_ipc_host_buffer buffer; 2662306a36Sopenharmony_ci uint32_t stream_tag; 2762306a36Sopenharmony_ci} __packed; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS_EXT */ 3062306a36Sopenharmony_cistruct sof_ipc_dma_trace_params_ext { 3162306a36Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; 3262306a36Sopenharmony_ci struct sof_ipc_host_buffer buffer; 3362306a36Sopenharmony_ci uint32_t stream_tag; 3462306a36Sopenharmony_ci uint64_t timestamp_ns; /* in nanosecond */ 3562306a36Sopenharmony_ci uint32_t reserved[8]; 3662306a36Sopenharmony_ci} __packed; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ 3962306a36Sopenharmony_cistruct sof_ipc_dma_trace_posn { 4062306a36Sopenharmony_ci struct sof_ipc_reply rhdr; 4162306a36Sopenharmony_ci uint32_t host_offset; /* Offset of DMA host buffer */ 4262306a36Sopenharmony_ci uint32_t overflow; /* overflow bytes if any */ 4362306a36Sopenharmony_ci uint32_t messages; /* total trace messages */ 4462306a36Sopenharmony_ci} __packed; 4562306a36Sopenharmony_ci 4662306a36Sopenharmony_ci/* Values used in sof_ipc_trace_filter_elem: */ 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci/* bits 6..0 */ 4962306a36Sopenharmony_ci#define SOF_IPC_TRACE_FILTER_ELEM_SET_LEVEL 0x01 /**< trace level for selected components */ 5062306a36Sopenharmony_ci#define SOF_IPC_TRACE_FILTER_ELEM_BY_UUID 0x02 /**< filter by uuid key */ 5162306a36Sopenharmony_ci#define SOF_IPC_TRACE_FILTER_ELEM_BY_PIPE 0x03 /**< filter by pipeline */ 5262306a36Sopenharmony_ci#define SOF_IPC_TRACE_FILTER_ELEM_BY_COMP 0x04 /**< filter by component id */ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* bit 7 */ 5562306a36Sopenharmony_ci#define SOF_IPC_TRACE_FILTER_ELEM_FIN 0x80 /**< mark last filter in set */ 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci/* bits 31..8: Unused */ 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/** part of sof_ipc_trace_filter, ABI3.17 */ 6062306a36Sopenharmony_cistruct sof_ipc_trace_filter_elem { 6162306a36Sopenharmony_ci uint32_t key; /**< SOF_IPC_TRACE_FILTER_ELEM_ {LEVEL, UUID, COMP, PIPE} */ 6262306a36Sopenharmony_ci uint32_t value; /**< element value */ 6362306a36Sopenharmony_ci} __packed; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/** Runtime tracing filtration data - SOF_IPC_TRACE_FILTER_UPDATE, ABI3.17 */ 6662306a36Sopenharmony_cistruct sof_ipc_trace_filter { 6762306a36Sopenharmony_ci struct sof_ipc_cmd_hdr hdr; /**< IPC command header */ 6862306a36Sopenharmony_ci uint32_t elem_cnt; /**< number of entries in elems[] array */ 6962306a36Sopenharmony_ci uint32_t reserved[8]; /**< reserved for future usage */ 7062306a36Sopenharmony_ci /** variable size array with new filtering settings */ 7162306a36Sopenharmony_ci struct sof_ipc_trace_filter_elem elems[]; 7262306a36Sopenharmony_ci} __packed; 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* 7562306a36Sopenharmony_ci * Commom debug 7662306a36Sopenharmony_ci */ 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * SOF panic codes 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_ci#define SOF_IPC_PANIC_MAGIC 0x0dead000 8262306a36Sopenharmony_ci#define SOF_IPC_PANIC_MAGIC_MASK 0x0ffff000 8362306a36Sopenharmony_ci#define SOF_IPC_PANIC_CODE_MASK 0x00000fff 8462306a36Sopenharmony_ci#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0x0) 8562306a36Sopenharmony_ci#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 0x1) 8662306a36Sopenharmony_ci#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 0x2) 8762306a36Sopenharmony_ci#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 0x3) 8862306a36Sopenharmony_ci#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 0x4) 8962306a36Sopenharmony_ci#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 0x5) 9062306a36Sopenharmony_ci#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 0x6) 9162306a36Sopenharmony_ci#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 0x7) 9262306a36Sopenharmony_ci#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 0x8) 9362306a36Sopenharmony_ci#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 0x9) 9462306a36Sopenharmony_ci#define SOF_IPC_PANIC_WFI (SOF_IPC_PANIC_MAGIC | 0xa) 9562306a36Sopenharmony_ci#define SOF_IPC_PANIC_ASSERT (SOF_IPC_PANIC_MAGIC | 0xb) 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci/* panic info include filename and line number 9862306a36Sopenharmony_ci * filename array will not include null terminator if fully filled 9962306a36Sopenharmony_ci */ 10062306a36Sopenharmony_cistruct sof_ipc_panic_info { 10162306a36Sopenharmony_ci struct sof_ipc_hdr hdr; 10262306a36Sopenharmony_ci uint32_t code; /* SOF_IPC_PANIC_ */ 10362306a36Sopenharmony_ci uint8_t filename[SOF_TRACE_FILENAME_SIZE]; 10462306a36Sopenharmony_ci uint32_t linenum; 10562306a36Sopenharmony_ci} __packed; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci#endif 108