Developer World
Spresense SDK Library v3.2.0-ebc0364
MsgLog.h
1/****************************************************************************
2 * modules/include/memutils/message/MsgLog.h
3 *
4 * Copyright 2018 Sony Semiconductor Solutions Corporation
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17 * the names of its contributors may be used to endorse or promote
18 * products derived from this software without specific prior written
19 * permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *
34 ****************************************************************************/
35
36#ifndef MSG_LOG_H_INCLUDED
37#define MSG_LOG_H_INCLUDED
38
39#include "memutils/common_utils/common_types.h"
40//#include "dmp_id.h"
41
42struct MsgLog {
43 uint8_t m_kind; /* log kind */
44 uint8_t m_task; /* call task. 0 is ISR */
45 uint16_t m_type; /* message type */
46 uint16_t m_pri_dest; /* priority (MSB) and destination queue ID */
47 uint16_t m_reply; /* reply queue ID */
48 uint8_t m_src_cpu; /* source CPU-ID */
49 uint8_t m_stored; /* stored count of target queue */
50 uint16_t m_param_size; /* parameter size */
51 uint32_t m_param; /* parameter (head 4byte) */
52public:
53 MsgLog(uint8_t kind, uint16_t type, uint16_t dest, uint8_t pri, uint16_t reply,
54 uint8_t src_cpu, uint16_t stored, uint16_t param_size, uint32_t param) :
55 m_kind(kind),
56// m_task(DMP_GET_TASK_ID),
57 m_task(0),
58 m_type(type),
59 m_pri_dest((pri << 15) | dest),
60 m_reply(reply),
61 m_src_cpu(src_cpu),
62 m_stored(static_cast<uint8_t>(stored)),
63 m_param_size(param_size),
64 m_param(param)
65 {}
66
67 MsgLog(uint8_t kind, uint16_t dest, uint8_t pri, uint16_t stored, MsgPacket* msg) :
68 m_kind(kind),
69// m_task(DMP_GET_TASK_ID),
70 m_task(0),
71 m_type(msg->getType()),
72 m_pri_dest((pri << 15) | dest),
73 m_reply(msg->getReply()),
74 m_src_cpu(msg->getSrcCpu()),
75 m_stored(static_cast<uint8_t>(stored)),
76 m_param_size(msg->getParamSize()),
77 m_param(msg->peekParamHead())
78 {}
79}; /* struct MsgLog */
80
81/* For shared use of LogAnalyzer,
82 * use the same structure and carve out by m_kind field.
83 */
84
85typedef MsgLog MsgSeqLog; /* m_kind: 's': send, 'i': sendIsr, 'r': recv */
86typedef MsgLog MsgRetryLog; /* m_kind: 'b': begin retry, 'n': normal end, 'e': error */
87
88/* Valid when DMP_MSG_SEQ 2 entry in dmp_layout.conf is true. */
89
90#if defined(DMP_MSG_SEQ2_NUM) && DMP_MSG_SEQ2_NUM != 0
91/* Use interrupt disable to store logs of multiple tasks and ISR sequentially. */
92
93#define DUMP_MSG_SEQ_LOCK(p) do { InterruptLock _lock_; DMP_MSG_SEQ2_SEQ_LOG(p); } while (0)
94#define DUMP_MSG_SEQ(p) DMP_MSG_SEQ2_SEQ_LOG(p)
95#else
96#define DUMP_MSG_SEQ_LOCK(p)
97#define DUMP_MSG_SEQ(p)
98#endif /* defined(DMP_MSG_SEQ2_NUM) && DMP_MSG_SEQ2_NUM != 0 */
99
101 uint16_t m_stored; /* stored count of target queue */
102 uint8_t m_task; /* call task. 0 is ISR */
103 uint8_t resv; /* reserved */
104 uint16_t m_msg_type; /* message type */
105 uint16_t m_msg_reply; /* reply queue ID */
106 uint16_t m_top_msg_type; /* message type */
107 uint16_t m_top_msg_reply; /* reply queue ID */
108public:
109 MsgPeakLog(uint16_t stored, MsgPacket* msg, MsgPacket* top_msg) :
110 m_stored(stored),
111// m_task(DMP_GET_TASK_ID),
112 m_task(0),
113 m_msg_type(msg->getType()),
114 m_msg_reply(msg->getReply()),
115 m_top_msg_type(top_msg->getType()),
116 m_top_msg_reply(top_msg->getReply())
117 {}
118}; /* struct MsgPeakLog */
119
120/* Valid when the DMP_MSG_PEAK entry in dmp_layout.conf is true. */
121
122#if defined(DMP_MSG_PEAK_NUM) && DMP_MSG_PEAK_NUM != 0
123#define DUMP_MSG_PEAK(id, pri, p) DMP_MSG_PEAK_IDX_LOG((((id) - 1) * NumMsgPri + (pri)), (p))
124#else
125#define DUMP_MSG_PEAK(id, pri, p)
126#endif /* defined(DMP_MSG_PEAK_NUM) && DMP_MSG_PEAK_NUM != 0 */
127
128/* If there is no DMP_MSGLIB_NUM entry in dmp_layout.conf, empty it here. */
129
130#ifndef DMP_MSGLIB_NUM
131#define DMP_MSGLIB_DEBUG_PRINT(...)
132#define DMP_MSGLIB_DEBUG(p)
133#define DMP_MSGLIB_INFO(p)
134#define DMP_MSGLIB_NOTICE(p)
135#define DMP_MSGLIB_WARN(p)
136#define DMP_MSGLIB_ERROR(p)
137#endif /* DMP_MEMMGR_NUM */
138
139#endif /* MSG_LOG_H_INCLUDED */
Definition: MsgPacket.h:142
Definition: MsgLog.h:42
Definition: MsgLog.h:100