11/*
2- * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
88#include <string.h>
99#include <assert.h>
1010#include <sys/cdefs.h>
11+ #include <inttypes.h>
1112
1213#include "esp_private/regdma_link.h"
1314
@@ -713,13 +714,17 @@ void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint
713714 return NULL ;
714715}
715716
716- #if REGDMA_LINK_DBG
717717static __attribute__((unused )) const char * TAG = "regdma_link" ;
718+ static const char * s_link_mode_str [] = { "CONTINUOUS" , "ADDR_MAP" , "WRITE" , "WAIT" };
719+ static const char * s_boolean_str [] = { "false" , "true" };
718720
719721static void print_info_link_data (FILE * out , const uint32_t buf [], int len )
720722{
721723 for (int i = 0 ; i < len ; i ++ ) {
722- fprintf (out , ((i + 1 ) % 8 ) ? "%08lx " : "%08lx\n" , buf [i ]);
724+ if (i % 8 == 0 ) {
725+ fprintf (out , "\t\t" );
726+ }
727+ fprintf (out , ((i + 1 ) % 8 ) ? "%08" PRIx32 " " : "%08" PRIx32 "\n" , buf [i ]);
723728 }
724729 if (len % 8 ) {
725730 fprintf (out , "\n" );
@@ -730,38 +735,50 @@ static void print_info_continuous_wrapper(FILE *out, void *link)
730735{
731736 regdma_link_head_t head = REGDMA_LINK_HEAD (link );
732737 regdma_link_continuous_t * cons = __containerof (link , regdma_link_continuous_t , head );
733- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, restore:%p, buff:%p\n" ,
734- cons -> stat .module , cons -> stat .id , link , * (uint32_t * )& cons -> head , cons -> body .next ,
735- cons -> body .backup , cons -> body .restore , cons -> body .mem );
738+ assert ((cons -> stat .module & (cons -> stat .module - 1 )) == 0 );
739+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p\n" LOG_RESET_COLOR ,
740+ __builtin_ffs (cons -> stat .module ) - 1 , cons -> stat .id , link ,
741+ s_link_mode_str [cons -> head .mode ], cons -> head .length , s_boolean_str [cons -> head .branch ], s_boolean_str [cons -> head .skip_r ], s_boolean_str [cons -> head .skip_b ], s_boolean_str [cons -> head .eof ],
742+ cons -> body .next ,
743+ cons -> body .backup , cons -> body .restore ,
744+ cons -> body .mem );
736745 print_info_link_data (out , (const uint32_t * )cons -> body .mem , head .length );
737746}
738747
739748static void print_info_addr_map_wrapper (FILE * out , void * link )
740749{
741750 regdma_link_head_t head = REGDMA_LINK_HEAD (link );
742751 regdma_link_addr_map_t * map = __containerof (link , regdma_link_addr_map_t , head );
743- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, restore:%p, buff:%p, map:{%lx,%lx,%lx,%lx}\n" ,
744- map -> stat .module , map -> stat .id , link , * (uint32_t * )& map -> head , map -> body .next , map -> body .backup ,
745- map -> body .restore , map -> body .mem , map -> body .map [0 ], map -> body .map [1 ],
746- map -> body .map [2 ], map -> body .map [3 ]);
752+ assert ((map -> stat .module & (map -> stat .module - 1 )) == 0 );
753+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p, map:{%" PRIx32 ",%" PRIx32 ",%" PRIx32 ",%" PRIx32 "}\n" LOG_RESET_COLOR ,
754+ __builtin_ffs (map -> stat .module ) - 1 , map -> stat .id , link ,
755+ s_link_mode_str [map -> head .mode ], map -> head .length , s_boolean_str [map -> head .branch ], s_boolean_str [map -> head .skip_r ], s_boolean_str [map -> head .skip_b ], s_boolean_str [map -> head .eof ],
756+ map -> body .next ,
757+ map -> body .backup , map -> body .restore ,
758+ map -> body .mem , map -> body .map [0 ], map -> body .map [1 ], map -> body .map [2 ], map -> body .map [3 ]);
747759 print_info_link_data (out , (const uint32_t * )map -> body .mem , head .length );
748760}
749761
750762static void print_info_write_wait_wrapper (FILE * out , void * link )
751763{
752764 regdma_link_write_wait_t * ww = __containerof (link , regdma_link_write_wait_t , head );
753- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:%p, backup:%p, value:%lx, mask:%lx\n" ,
754- ww -> stat .module , ww -> stat .id , link , * (uint32_t * )& ww -> head , ww -> body .next ,
765+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, value:%" PRIx32 ", mask:%" PRIx32 "\n" LOG_RESET_COLOR ,
766+ __builtin_ffs (ww -> stat .module ) - 1 , ww -> stat .id , link ,
767+ s_link_mode_str [ww -> head .mode ], ww -> head .length , s_boolean_str [ww -> head .branch ], s_boolean_str [ww -> head .skip_r ], s_boolean_str [ww -> head .skip_b ], s_boolean_str [ww -> head .eof ],
768+ ww -> body .next ,
755769 ww -> body .backup , ww -> body .value , ww -> body .mask );
756770}
757771
758772static void print_info_branch_continuous_wrapper (FILE * out , void * link )
759773{
760774 regdma_link_head_t head = REGDMA_LINK_HEAD (link );
761775 regdma_link_branch_continuous_t * cons = __containerof (link , regdma_link_branch_continuous_t , head );
762- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, restore:%p, buff:%p\n" ,
763- cons -> stat .module , cons -> stat .id , link , * (uint32_t * )& cons -> head , cons -> body .next [0 ], cons -> body .next [1 ],
764- cons -> body .next [2 ], cons -> body .next [3 ], cons -> body .backup , cons -> body .restore ,
776+ assert ((cons -> stat .module & (cons -> stat .module - 1 )) == 0 );
777+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p\n" LOG_RESET_COLOR ,
778+ __builtin_ffs (cons -> stat .module ) - 1 , cons -> stat .id , link ,
779+ s_link_mode_str [cons -> head .mode ], cons -> head .length , s_boolean_str [cons -> head .branch ], s_boolean_str [cons -> head .skip_r ], s_boolean_str [cons -> head .skip_b ], s_boolean_str [cons -> head .eof ],
780+ cons -> body .next ,
781+ cons -> body .backup , cons -> body .restore ,
765782 cons -> body .mem );
766783 print_info_link_data (out , (const uint32_t * )cons -> body .mem , head .length );
767784}
@@ -770,20 +787,24 @@ static void print_info_branch_addr_map_wrapper(FILE *out, void *link)
770787{
771788 regdma_link_head_t head = REGDMA_LINK_HEAD (link );
772789 regdma_link_branch_addr_map_t * map = __containerof (link , regdma_link_branch_addr_map_t , head );
773- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, restore:%p, buff:%p, map:{%lx,%lx,%lx,%lx}\n" ,
774- map -> stat .module , map -> stat .id , link , * (uint32_t * )& map -> head , map -> body .next [0 ], map -> body .next [1 ], map -> body .next [2 ],
775- map -> body .next [3 ], map -> body .backup , map -> body .restore , map -> body .mem , map -> body .map [0 ],
776- map -> body .map [1 ], map -> body .map [2 ], map -> body .map [3 ]);
790+ assert ((map -> stat .module & (map -> stat .module - 1 )) == 0 );
791+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, restore start:%p, buff_ptr:%p, map:{%" PRIx32 ",%" PRIx32 ",%" PRIx32 ",%" PRIx32 "}\n" LOG_RESET_COLOR ,
792+ __builtin_ffs (map -> stat .module ) - 1 , map -> stat .id , link ,
793+ s_link_mode_str [map -> head .mode ], map -> head .length , s_boolean_str [map -> head .branch ], s_boolean_str [map -> head .skip_r ], s_boolean_str [map -> head .skip_b ], s_boolean_str [map -> head .eof ],
794+ map -> body .next ,
795+ map -> body .backup , map -> body .restore ,
796+ map -> body .mem , map -> body .map [0 ], map -> body .map [1 ], map -> body .map [2 ], map -> body .map [3 ]);
777797 print_info_link_data (out , (const uint32_t * )map -> body .mem , head .length );
778798}
779799
780800static void print_info_branch_write_wait_wrapper (FILE * out , void * link )
781801{
782802 regdma_link_branch_write_wait_t * ww = __containerof (link , regdma_link_branch_write_wait_t , head );
783- fprintf (out , "[%08lx/%04x] link:%p, head:%lx, next:{%p,%p,%p,%p}, backup:%p, value:%lx, mask:%lx\n" ,
784- ww -> stat .module , ww -> stat .id , link , * (uint32_t * )& ww -> head , ww -> body .next [0 ], ww -> body .next [1 ],
785- ww -> body .next [2 ], ww -> body .next [3 ], ww -> body .backup , ww -> body .value ,
786- ww -> body .mask );
803+ fprintf (out , LOG_COLOR_I " [%02d/%04x] link_ptr:%p, head: {mode:%s len:%d branch:%s skip_r:%s skip_b:%s eof:%s}, next:%p, backup start:%p, value:%" PRIx32 ", mask:%" PRIx32 "\n" LOG_RESET_COLOR ,
804+ __builtin_ffs (ww -> stat .module ) - 1 , ww -> stat .id , link ,
805+ s_link_mode_str [ww -> head .mode ], ww -> head .length , s_boolean_str [ww -> head .branch ], s_boolean_str [ww -> head .skip_r ], s_boolean_str [ww -> head .skip_b ], s_boolean_str [ww -> head .eof ],
806+ ww -> body .next ,
807+ ww -> body .backup , ww -> body .value , ww -> body .mask );
787808}
788809
789810static void print_link_info (FILE * out , void * args , int entry , int depth )
@@ -821,4 +842,3 @@ void regdma_link_dump(FILE *out, void *link, int entry)
821842 fprintf (out , "This REGDMA linked list is empty!\n" );
822843 }
823844}
824- #endif
0 commit comments