55 */
66
77#include <zephyr/logging/log_frontend_stmesp_demux.h>
8+ #include <zephyr/logging/log_frontend_stmesp.h>
89#include <zephyr/logging/log_ctrl.h>
910#include <zephyr/sys/mpsc_pbuf.h>
1011#include <zephyr/sys/__assert.h>
@@ -43,9 +44,25 @@ struct log_frontend_stmesp_demux_active_entry {
4344 int off ;
4445};
4546
46- struct log_frontend_stmesp_coop_sources {
47+ /* Coprocessors (FLPR, PPR) sends location where APP can find strings and logging
48+ * source names utilizing the fact that APP has access to FLPR/PPR memory if it is
49+ * an owner of that coprocessor. During the initialization FLPR/PPR sends 2 DMTS32
50+ * to the specific channel. First word is an address where logging source constant
51+ * data section is located and second is where a section with addresses to constant
52+ * strings used for logging is located.
53+ */
54+ struct log_frontend_stmesp_coproc_sources {
4755 uint32_t m_id ;
48- const struct log_source_const_data * log_const ;
56+ uint32_t data_cnt ;
57+ union {
58+ struct {
59+ const struct log_source_const_data * log_const ;
60+ uintptr_t * log_str_section ;
61+ } data ;
62+ struct {
63+ uintptr_t data [2 ];
64+ } raw_data ;
65+ };
4966};
5067
5168struct log_frontend_stmesp_demux {
@@ -72,7 +89,7 @@ struct log_frontend_stmesp_demux {
7289
7390 uint32_t dropped ;
7491
75- struct log_frontend_stmesp_coop_sources coop_sources [2 ];
92+ struct log_frontend_stmesp_coproc_sources coproc_sources [2 ];
7693};
7794
7895struct log_frontend_stmesp_entry_source_pair {
@@ -404,10 +421,33 @@ const char *log_frontend_stmesp_demux_sname_get(uint32_t m_id, uint16_t s_id)
404421
405422 if (demux .m_ids [m_id ] == APP_M_ID ) {
406423 return log_source_name_get (0 , s_id );
407- } else if (m_id == demux .coop_sources [0 ].m_id ) {
408- return demux .coop_sources [0 ].log_const [s_id ].name ;
409- } else if (m_id == demux .coop_sources [1 ].m_id ) {
410- return demux .coop_sources [1 ].log_const [s_id ].name ;
424+ } else if (m_id == demux .coproc_sources [0 ].m_id ) {
425+ return demux .coproc_sources [0 ].data .log_const [s_id ].name ;
426+ } else if (m_id == demux .coproc_sources [1 ].m_id ) {
427+ return demux .coproc_sources [1 ].data .log_const [s_id ].name ;
428+ }
429+
430+ return "unknown" ;
431+ }
432+
433+ const char * log_frontend_stmesp_demux_str_get (uint32_t m_id , uint16_t s_id )
434+ {
435+ if (!IS_ENABLED (CONFIG_LOG_FRONTEND_STMESP_TURBO_LOG )) {
436+ return "" ;
437+ }
438+
439+ uintptr_t * log_str_start = NULL ;
440+
441+ if (demux .m_ids [m_id ] == APP_M_ID ) {
442+ log_str_start = (uintptr_t * )TYPE_SECTION_START (log_stmesp_ptr );
443+ } else if (m_id == demux .coproc_sources [0 ].m_id ) {
444+ log_str_start = demux .coproc_sources [0 ].data .log_str_section ;
445+ } else if (m_id == demux .coproc_sources [1 ].m_id ) {
446+ log_str_start = demux .coproc_sources [1 ].data .log_str_section ;
447+ }
448+
449+ if (log_str_start ) {
450+ return (const char * )log_str_start [s_id ];
411451 }
412452
413453 return "unknown" ;
@@ -439,15 +479,16 @@ int log_frontend_stmesp_demux_packet_start(uint32_t *data, uint64_t *ts)
439479
440480 if (IS_ENABLED (CONFIG_LOG_FRONTEND_STMESP_TURBO_LOG ) &&
441481 (ch == CONFIG_LOG_FRONTEND_STPESP_TURBO_SOURCE_PORT_ID )) {
442- if (demux .m_ids [m ] == FLPR_M_ID ) {
443- demux .coop_sources [0 ].m_id = m ;
444- demux .coop_sources [0 ].log_const =
445- (const struct log_source_const_data * )(uintptr_t )* data ;
446- } else if (demux .m_ids [m ] == PPR_M_ID ) {
447- demux .coop_sources [1 ].m_id = m ;
448- demux .coop_sources [1 ].log_const =
449- (const struct log_source_const_data * )(uintptr_t )* data ;
482+ struct log_frontend_stmesp_coproc_sources * src =
483+ & demux .coproc_sources [demux .m_ids [m ] == FLPR_M_ID ? 0 : 1 ];
484+
485+ if (src -> data_cnt >= 2 ) {
486+ /* Unexpected packet. */
487+ return - EINVAL ;
450488 }
489+
490+ src -> m_id = m ;
491+ src -> raw_data .data [src -> data_cnt ++ ] = (uintptr_t )* data ;
451492 return 0 ;
452493 }
453494
0 commit comments