void bsp_log_bin_ind(s32 str_id, void* ind_data, u32 ind_data_size)
{
    u32 pbuf = 0;
    u32 buflen = 0;
    bsp_om_head_s        *bsp_om_header  = NULL;
    log_ind_enter_cnt ++;

    if((NULL == ind_data) ||(0 == ind_data_size) || (ind_data_size > BSP_DIAG_IND_DATA_MAX_LEN))
    {
        return ;
    }

    if( TRUE != bsp_om_get_hso_conn_flag())
    {
        return ;
    }

    buflen = sizeof(bsp_socp_head_s)+sizeof(bsp_om_head_s)+ind_data_size ;

    /*获取buf*/
    if(bsp_om_buf_sem_take())
    {
        return;
    }
    pbuf = bsp_om_get_buf(BSP_OM_SOCP_BUF_TYPE,buflen);

    if(0 == pbuf)
    {
        bsp_om_buf_sem_give();
        return ;
    }

    /*打包SOCP头*/
    PACKET_BSP_SOCP_HEAD(pbuf);

    bsp_om_header = (bsp_om_head_s*)(pbuf + sizeof(bsp_socp_head_s));

    bsp_om_header->om_id            = (BSP_STRU_ID_28_31_GROUP_MSP << 28) | (BSP_STRU_ID_16_23_BSP_CMD_IND << 16) |(u16)str_id;

    memcpy((u8*)bsp_om_header +sizeof(bsp_om_head_s),ind_data,ind_data_size);

    if(BSP_OK != bsp_om_into_send_list(pbuf,buflen))
    {
        bsp_om_free_buf(pbuf,buflen);
    }

    bsp_om_buf_sem_give();
    log_ind_exit_cnt ++;
}
예제 #2
0
u32 report_cpu_trace(void)
{
    u32 task_num = 0;
    BSP_CPU_TRACE_STRU  *p_cpu_trace_stru = NULL;
    BSP_TASK_CPU_TRACE_STRU *p_cpu_trace_data = NULL;
    u32          buf_len = 0;
    u32          task_slices = 0;


    buf_len = sizeof(BSP_CPU_TRACE_STRU) + sizeof(BSP_TASK_CPU_TRACE_STRU)*g_task_num;

    if(cpu_info_stru.report_swt == BSP_SYSVIEW_SWT_ON)
    {
        if(bsp_om_buf_sem_take())
        {
            return BSP_ERR_SYSVIEW_FAIL;
        }
        p_cpu_trace_stru = (BSP_CPU_TRACE_STRU *)bsp_om_get_buf(BSP_OM_SOCP_BUF_TYPE,buf_len);
         if(NULL == p_cpu_trace_stru)
        {
            bsp_om_buf_sem_give();
            return BSP_ERR_SYSVIEW_MALLOC_FAIL;
        }
    }
    else
    {
        p_cpu_trace_stru = (BSP_CPU_TRACE_STRU *)osl_malloc(buf_len);
         if(NULL == p_cpu_trace_stru)
        {
            return BSP_ERR_SYSVIEW_MALLOC_FAIL;
        }
    }

#ifdef ENABLE_BUILD_SYSVIEW
    sysview_trace_packet((u8*)p_cpu_trace_stru,buf_len,BSP_SYSVIEW_CPU_INFO);
#endif

    p_cpu_trace_data = p_cpu_trace_stru->cpu_info_stru;

    for(task_num =0;task_num < g_task_num; task_num++)
    {
        /*lint -save -e701*/
        p_cpu_trace_data[task_num].task_id =  PID_PPID_GET(kernel_tid_list[task_num]);
        /*lint -restore*/
        strncpy( (char *)(p_cpu_trace_data[task_num].task_name), (char *)(g_om_cpu_trace[task_num].task_name), BSP_SYSVIEW_TASK_NAME_LEN);
        p_cpu_trace_data[task_num].task_name[BSP_SYSVIEW_TASK_NAME_LEN-1] = '\0';
        task_slices =g_om_cpu_trace[task_num].slices - g_om_cpu_trace[task_num].cmdslice;
        p_cpu_trace_data[task_num].interval_slice = task_slices;

        /* for uart debug begin*/
        if(cpu_info_stru.report_swt == BSP_SYSVIEW_SWT_OFF)
        {
            if(task_slices != 0)
            {
                printk("taskid:0x%x,  %-11s,  rate = %u%% \n"
                                        ,p_cpu_trace_data[task_num].task_id,p_cpu_trace_data[task_num].task_name
                                        ,(u32)((task_slices *100)/g_cpu_task_taet));
            }
        }
        /* for uart debug end*/
    }

    if(cpu_info_stru.report_swt == BSP_SYSVIEW_SWT_ON)
    {
        if( BSP_OK != bsp_om_into_send_list((u32)p_cpu_trace_stru,buf_len))
        {
            bsp_om_free_buf((u32)p_cpu_trace_stru,buf_len );
            bsp_om_buf_sem_give();
            return BSP_ERR_SYSVIEW_FAIL;
        }

        bsp_om_buf_sem_give();
    }
    else
    {
        osl_free(p_cpu_trace_stru);
    }

    return BSP_OK;
}
void report_sysview_trace(bsp_sysview_type_e data_type)
{
    dump_queue_t *queue_head = NULL;
    u32 data_size = 0;
    u32 send_buf_len = 0;
    u32 q_front;
    u32 q_maxnum;
    u32 q_num;

    BSP_SYS_VIEW_TRACE_STRU *p_sysview_trace_stru = NULL;
    u32 threshold_size ;

    if( TRUE != bsp_om_get_hso_conn_flag())
    {
        return ;
    }

    if(BSP_SYSVIEW_TASK_INFO == data_type)
    {
        threshold_size  = task_info_stru.threshold_size;
        queue_head = (dump_queue_t *)DUMP_TASK_SWITCH_ADDR;
    }
    /* 内部接口,由入参保证*/
    else
    {
       threshold_size  = int_lock_stru.threshold_size;
       queue_head = (dump_queue_t *)DUMP_INTLOCK_ADDR;
    }

    q_num           = queue_head->num;
    q_maxnum    = queue_head->maxNum;
    q_front           = queue_head->front ;

    if(0 == q_num)
    {
        return ;
    }

    /* 每次触发上报最多上报门限值大小*/

    if((q_num *sizeof(int)) >= threshold_size )
    {
        data_size = threshold_size;
    }
    else
    {
        data_size = (q_num *sizeof(int));
    }

    /*不处理回卷指针*/
    if((q_front + data_size/sizeof(u32)) >=q_maxnum)
    {
        data_size = (q_maxnum - q_front )* sizeof(u32);
    }

    /*申请编码通道缓存buf*/
    send_buf_len = sizeof(BSP_SYS_VIEW_TRACE_STRU)+data_size ;

    if(bsp_om_buf_sem_take())
    {
        return;
    }
    p_sysview_trace_stru = bsp_om_get_buf(BSP_OM_SOCP_BUF_TYPE,send_buf_len );

    if(NULL == p_sysview_trace_stru)
    {
        QueueFrontDel(queue_head,data_size/sizeof(int));
        bsp_om_buf_sem_give();
        return ;
    }

    /*打包数据头*/
    sysview_trace_packet((u8*)p_sysview_trace_stru,send_buf_len,data_type);

    /*从dump模块指定地址中获取数据、发送数据到SOCP、更新dump模块队列指针*/
    memcpy((u8*)p_sysview_trace_stru +sizeof(BSP_SYS_VIEW_TRACE_STRU),(u8*)(queue_head->data+q_front),data_size);

    if(BSP_OK == bsp_om_into_send_list((void*)p_sysview_trace_stru,send_buf_len))
    {
        QueueFrontDel(queue_head,data_size/sizeof(int));
        g_sysview_debug[data_type].info_send_times++;
        g_sysview_debug[data_type].info_send_size += data_size;
    }
    else
    {
        QueueFrontDel(queue_head,data_size/sizeof(int));
        bsp_om_free_buf((void*)p_sysview_trace_stru,send_buf_len );
    }

    bsp_om_buf_sem_give();
    return ;

}