diff --git a/public/common/platform/inc/spu_log.h b/public/common/platform/inc/spu_log.h index e6db64a..4244fbd 100644 --- a/public/common/platform/inc/spu_log.h +++ b/public/common/platform/inc/spu_log.h @@ -15,7 +15,54 @@ #ifndef __SPU_LOG_H__ #define __SPU_LOG_H__ +#include "typedef.h" +#include "ucp_port.h" +#include "ucp_utility.h" +#include "ucp_tick.h" +#include "ucp_printf.h" +#include "log_client.h" +#include "spu_hw_queue.h" +#include "spu_sw_queue.h" #define SPU_LOG_TEST_FLAG +#define __LOG __attribute__((section(".LOG"))) +extern uint8_t gu8osp_print_level; +#define STSW_MSG_INFO_SET(stsw_msg_info, str_len, core_id)\ +do{\ + stsw_msg_info.u8Head[0] = SPU_SW_MSG_INFO_HEAD1;\ + stsw_msg_info.u8Head[1] = SPU_SW_MSG_INFO_HEAD2;\ + stsw_msg_info.u16DataLen = str_len;\ + stsw_msg_info.u8PktType = PKT_TYPE_PLATFORM_LOG;\ + stsw_msg_info.u8CoreId = core_id;\ + stsw_msg_info.u16Tail = 0;}while(0) +#define SPU_VPRINTF_LOG(level,fmt, args...) do{__LOG static char tmp[] = fmt; \ + int32_t i32core_id = get_core_id();\ + int32_t i32ret = 0;\ + uint32_t u32str_len = 0;\ + uint16_t u16_index = 0;\ + uint8_t u8offset = SPU_SW_MSG_INFO_SIZE;\ + uint8_t *pu8_addr = NULL;\ + static int8_t i8str[128];\ + if (level > gu8osp_print_level)\ + {\ + break;\ + }\ + u32str_len = strlen(fmt);\ + memcpy_ucp((char *)i8str, (char *)tmp, u32str_len);\ + __ucps2_synch(0);\ + pu8_addr = spu_log_client_mem_alloc(&u16_index);\ + memset(((char *)pu8_addr), 0, SPU_LOG_CLIENT_BUF_SIZE);\ + u32str_len = spu_vsprint_log(((char *)(pu8_addr+u8offset)), (char *)i8str, ##args);\ + spu_sw_msg_info_t stsw_msg_info;\ + STSW_MSG_INFO_SET(stsw_msg_info, u32str_len, i32core_id);\ + memcpy_ucp((char *)pu8_addr, (void *)&stsw_msg_info, u8offset);\ + __ucps2_synch(0);\ + SpuLogMsgInfo_t stlog_msg_info;\ + stlog_msg_info.cell_id = 0;\ + stlog_msg_info.core_id = i32core_id;\ + stlog_msg_info.buf_idx = u16_index;\ + stlog_msg_info.buf_size = (u32str_len + u8offset);\ + i32ret=ecs_hw_que_send(ECS_RFM_SPU1_HW_QUEUE, stlog_msg_info.value);\ + } while(0) typedef enum SPU_LOG_LEVEL { @@ -43,6 +90,7 @@ void spu_log_init(uint8_t level); void spu_log_output(uint8_t level, const char *fmt, ...); uint8_t spu_log_level_set(spu_log_level_e emlog_level); uint8_t spu_log_level_get(void); +uint32_t spu_vsprint_log(char *dst, const char *fmt, ...); #ifdef PCIE_BACKHAUL void com_debug_log(const char *fmt, ...); diff --git a/public/common/platform/src/spu_log.s.c b/public/common/platform/src/spu_log.s.c index 0817ea9..a9bad97 100644 --- a/public/common/platform/src/spu_log.s.c +++ b/public/common/platform/src/spu_log.s.c @@ -2,18 +2,10 @@ #include #include #include "spu_log.h" -#include "ucp_port.h" -#include "ucp_utility.h" -#include "ucp_tick.h" -#include "ucp_printf.h" -#include "log_client.h" -#include "spu_log.h" -#include "spu_hw_queue.h" -#include "spu_sw_queue.h" #include "spu_shell.h" #define SPU_LOG_INNER_MAX_SIZE (64) -#define __LOG __attribute__((section(".LOG"))) + /**************************************************/ /* 对内接口 */ @@ -61,7 +53,7 @@ uint8_t spu_log_level_set(spu_log_level_e emlog_level) } gu8osp_print_level = emlog_level; - + UCP_PRINT_LOG("spu_log_level_set gu8osp_print_level %u", gu8osp_print_level); return 0; @@ -70,11 +62,20 @@ uint8_t spu_log_level_set(spu_log_level_e emlog_level) /* 获取平台Log打印级别 */ uint8_t spu_log_level_get(void) { - UCP_PRINT_LOG("spu_log_level_get gu8osp_print_level %u", gu8osp_print_level); + UCP_PRINT_LOG("spu_log_level_get gu8osp_print_level %u", gu8osp_print_level); return gu8osp_print_level; } +uint32_t spu_vsprint_log(char *dst, const char *fmt, ...) +{ + uint32_t u32str_len = 0; + va_list st_va_list; + va_start(st_va_list, fmt); + u32str_len = vsprintf(dst, fmt, st_va_list); + va_end(st_va_list); + return u32str_len; +} /* 平台打印输出函数 */ void spu_log_output(uint8_t level, const char *fmt, ...) { @@ -328,11 +329,11 @@ void osp_sendLog_print(int level, char* pbuf, int size, int cell_id) #include "../../../pet_rfm_spu0/driver/inc/ucp_pcie_traffic.h" #define LOGBUFSIZE 256 char tmp_buf[LOGBUFSIZE] = {0}; - + void com_debug_log(const char *fmt, ...) { PcieEpMemBarStruct_t* pUcpMemBar = (PcieEpMemBarStruct_t *)0x08740000;//pMemSection->baseAddr; - uint32_t core_id = get_core_id(); + //uint32_t core_id = get_core_id(); uint32_t count = 0; uint32_t i = 0; diff --git a/public/common/utility/inc/ucp_printf.h b/public/common/utility/inc/ucp_printf.h index 018e62e..f42f774 100644 --- a/public/common/utility/inc/ucp_printf.h +++ b/public/common/utility/inc/ucp_printf.h @@ -34,35 +34,35 @@ #if (UCP_PRINT_LEVEL & PRINT_ERROR) //#define UCP_PRINT_ERROR(fmt, args...) printf(__FILE__ ": [ERROR]: %d: %s():" fmt "\n", __LINE__, __func__, ##args) -#define UCP_PRINT_ERROR(fmt, args...) spu_log_output(LOG_ERROR, "[ERROR]:" fmt "\n", ##args) +#define UCP_PRINT_ERROR(fmt, args...) SPU_VPRINTF_LOG(LOG_ERROR, "[ERROR]:" fmt "\n", ##args) #else #define UCP_PRINT_ERROR(fmt, args...) #endif #if (UCP_PRINT_LEVEL & PRINT_WARN) //#define UCP_PRINT_WARN(fmt, args...) printf(__FILE__ ": [WARN]: %d: %s():" fmt "\n", __LINE__, __func__, ##args) -#define UCP_PRINT_WARN(fmt, args...) spu_log_output(LOG_WARN, "[WARN]:" fmt "\n", ##args) +#define UCP_PRINT_WARN(fmt, args...) SPU_VPRINTF_LOG(LOG_WARN, "[WARN]:" fmt "\n", ##args) #else #define UCP_PRINT_WARN(fmt, args...) #endif #if (UCP_PRINT_LEVEL & PRINT_LOG) //#define UCP_PRINT_LOG(fmt, args...) printf(__FILE__ ": [LOG]: %d: %s():" fmt "\n", __LINE__, __func__, ##args) -#define UCP_PRINT_LOG(fmt, args...) spu_log_output(LOG_INFO, "[LOG]:" fmt "\n", ##args) +#define UCP_PRINT_LOG(fmt, args...) SPU_VPRINTF_LOG(LOG_INFO, "[LOG]:" fmt "\n", ##args) #else #define UCP_PRINT_LOG(fmt, args...) #endif #if (UCP_PRINT_LEVEL & PRINT_DEBUG) //#define UCP_PRINT_LOG(fmt, args...) printf(__FILE__ ": [LOG]: %d: %s():" fmt "\n", __LINE__, __func__, ##args) -#define UCP_PRINT_DEBUG(fmt, args...) spu_log_output(LOG_DEBUG, "[DEBUG]:" fmt "\n", ##args) +#define UCP_PRINT_DEBUG(fmt, args...) SPU_VPRINTF_LOG(LOG_DEBUG, "[DEBUG]:" fmt "\n", ##args) #else #define UCP_PRINT_DEBUG(fmt, args...) #endif #if (UCP_PRINT_LEVEL & PRINT_TICK) //#define UCP_PRINT_TICK(fmt, args...) printf(__FILE__ ": [TICK]: %d: %s():" fmt "\n", __LINE__, __func__, ##args) -#define UCP_PRINT_TICK(fmt, args...) spu_log_output(LOG_TICK, "[TICK]:" fmt "\n", ##args) +#define UCP_PRINT_TICK(fmt, args...) SPU_VPRINTF_LOG(LOG_TICK, "[TICK]:" fmt "\n", ##args) #else #define UCP_PRINT_TICK(fmt, args...) #endif