Skip to content

Commit 9d01912

Browse files
fg-cfhcarlescufi
authored andcommitted
segger: config: RTT spinlock implementation
RTT locking is now implemented with spinlocks: * The prior implementation did not support RTT logging and tracing from ISR context. * Mutexes caused infinite loops when tracing. * Spinlocks are more lightweight than mutexes, especially on non-SMP systems. Fixes: #61133 Signed-off-by: Florian Grandel <[email protected]>
1 parent 5792675 commit 9d01912

File tree

1 file changed

+39
-85
lines changed

1 file changed

+39
-85
lines changed

Config/SEGGER_SYSVIEW_Conf.h

Lines changed: 39 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,39 @@
1-
/*********************************************************************
2-
* SEGGER Microcontroller GmbH *
3-
* The Embedded Experts *
4-
**********************************************************************
5-
* *
6-
* (c) 1995 - 2021 SEGGER Microcontroller GmbH *
7-
* *
8-
* www.segger.com Support: [email protected] *
9-
* *
10-
**********************************************************************
11-
* *
12-
* SEGGER SystemView * Real-time application analysis *
13-
* *
14-
**********************************************************************
15-
* *
16-
* All rights reserved. *
17-
* *
18-
* SEGGER strongly recommends to not make any changes *
19-
* to or modify the source code of this software in order to stay *
20-
* compatible with the SystemView and RTT protocol, and J-Link. *
21-
* *
22-
* Redistribution and use in source and binary forms, with or *
23-
* without modification, are permitted provided that the following *
24-
* condition is met: *
25-
* *
26-
* o Redistributions of source code must retain the above copyright *
27-
* notice, this condition and the following disclaimer. *
28-
* *
29-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
30-
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
31-
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
32-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
33-
* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR *
34-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
35-
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
36-
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
37-
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
38-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
39-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
40-
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
41-
* DAMAGE. *
42-
* *
43-
**********************************************************************
44-
* *
45-
* SystemView version: 3.40 *
46-
* *
47-
**********************************************************************
48-
-------------------------- END-OF-HEADER -----------------------------
49-
50-
File : SEGGER_SYSVIEW_Conf.h
51-
Purpose : SEGGER SystemView configuration file.
52-
Set defines which deviate from the defaults (see SEGGER_SYSVIEW_ConfDefaults.h) here.
53-
Revision: $Rev: 21292 $
54-
55-
Additional information:
56-
Required defines which must be set are:
57-
SEGGER_SYSVIEW_GET_TIMESTAMP
58-
SEGGER_SYSVIEW_GET_INTERRUPT_ID
59-
For known compilers and cores, these might be set to good defaults
60-
in SEGGER_SYSVIEW_ConfDefaults.h.
61-
62-
SystemView needs a (nestable) locking mechanism.
63-
If not defined, the RTT locking mechanism is used,
64-
which then needs to be properly configured.
65-
*/
66-
67-
#ifndef SEGGER_SYSVIEW_CONF_H
68-
#define SEGGER_SYSVIEW_CONF_H
69-
70-
/*********************************************************************
71-
*
72-
* Defines, configurable
73-
*
74-
**********************************************************************
75-
*/
76-
77-
/*********************************************************************
78-
* TODO: Add your defines here. *
79-
**********************************************************************
80-
*/
81-
82-
83-
#endif // SEGGER_SYSVIEW_CONF_H
84-
85-
/*************************** End of file ****************************/
1+
/*
2+
* Copyright (c) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef SEGGER_SEGGER_SYSVIEW_CONF_H_
8+
#define SEGGER_SEGGER_SYSVIEW_CONF_H_
9+
10+
#include <stdint.h>
11+
12+
#define SEGGER_SYSVIEW_GET_TIMESTAMP sysview_get_timestamp
13+
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID sysview_get_interrupt
14+
15+
uint32_t sysview_get_timestamp(void);
16+
uint32_t sysview_get_interrupt(void);
17+
18+
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE CONFIG_SEGGER_SYSVIEW_RTT_BUFFER_SIZE
19+
#define SEGGER_SYSVIEW_POST_MORTEM_MODE CONFIG_SEGGER_SYSVIEW_POST_MORTEM_MODE
20+
#define SEGGER_SYSVIEW_RTT_CHANNEL CONFIG_SEGGER_SYSVIEW_RTT_CHANNEL
21+
22+
#if defined(CONFIG_SEGGER_SYSVIEW_SECTION_DTCM)
23+
#define SEGGER_SYSVIEW_SECTION ".dtcm_data"
24+
#endif
25+
26+
extern unsigned int zephyr_rtt_irq_lock(void);
27+
extern void zephyr_rtt_irq_unlock(unsigned int key);
28+
29+
/* Lock SystemView (nestable) */
30+
#define SEGGER_SYSVIEW_LOCK() \
31+
{ \
32+
unsigned int __sysview_irq_key = zephyr_rtt_irq_lock()
33+
34+
/* Unlock SystemView (nestable) */
35+
#define SEGGER_SYSVIEW_UNLOCK() \
36+
zephyr_rtt_irq_unlock(__sysview_irq_key); \
37+
}
38+
39+
#endif /* SEGGER_SEGGER_SYSVIEW_CONF_H_ */

0 commit comments

Comments
 (0)