⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssp_msg.c

📁 abstract rtos
💻 C
📖 第 1 页 / 共 2 页
字号:
    }    if( FALSE == g_pstMpset[mps].status )    {        return MSG_NO_TASK;    }    return AOS_SUCC;}U32 ssp_mpe_print_enable( MPE mpe ){    if( mpe >= MPE_BUTT )    {        return MSG_MPE_INVALID;    }    if( FALSE == g_pstMpe[mpe].status )    {        return MSG_MPE_INVALID;    }    g_pstMpe[mpe].print_flag = TRUE;    return AOS_SUCC;}U32 ssp_mpe_print_disable( MPE mpe ){    if( mpe >= MPE_BUTT )    {        return MSG_MPE_INVALID;    }    if( FALSE == g_pstMpe[mpe].status )    {        return MSG_MPE_INVALID;    }    g_pstMpe[mpe].print_flag = FALSE;    return AOS_SUCC;}U32 ssp_mpe_print_enable_all( ){    MPE mpe;    for( mpe=0; mpe < MPE_BUTT; mpe++ )    {        if( TRUE == g_pstMpe[mpe].status )        {            g_pstMpe[mpe].print_flag = TRUE;        }    }    return AOS_SUCC;}U32 ssp_mpe_print_disable_all( ){    MPE mpe;    for( mpe=0; mpe < MPE_BUTT; mpe++ )    {        if( TRUE == g_pstMpe[mpe].status )        {            g_pstMpe[mpe].print_flag = FALSE;        }    }    return AOS_SUCC;}U32 ssp_mpe_print_verify( MPE mpe ){    if( mpe >= MPE_BUTT )    {        return MSG_MPE_INVALID;    }    if( FALSE == g_pstMpe[mpe].status )    {        return MSG_MPE_INVALID;    }    if( TRUE != g_pstMpe[mpe].print_flag )    {        return MSG_MPE_PRINT_DISABLE;    }    return AOS_SUCC;}VOID ssp_msg_task( U32 mps ){    U32 result, ulEvents;    MSG_S msg;    MPS_S *pCurMpset;    MSG_HEAD_S *pMsgHead;    L3_MSG_HEAD_S *pL3Msg;    U64 now;    AOS_TRACE_IN( ssp_msg_task, mps, 0, 0, 0 );        AOS_ASSERT( (mps < MPS_BUTT) && (TRUE == g_pstMpset[mps].status) );    pCurMpset = &g_pstMpset[mps];    for( ;; )    {        result = aos_event_wait( MSG_SYNC_EVENT, AOS_WAIT_ANY, 0, &ulEvents );        AOS_ASSERT( AOS_SUCC == result );        for( ; ; )        {            struct msg_blk *mb;            mb = msg_deque(&pCurMpset->msg_que[MSG_PRIO_HIGH]);            if( NULL == mb )            {                mb = msg_deque(&pCurMpset->msg_que[MSG_PRIO_NORMAL]);                if( NULL == mb )                {                    break;                }            }            pMsgHead = (MSG_HEAD_S *)mb->head;            pL3Msg   = (L3_MSG_HEAD_S*)mb->data;            AOS_ASSERT( MSG_SENDED == pMsgHead->status );            if( LOCAL_PROCESSOR_ID != pL3Msg->dstProcessorId )            {                pL3Msg->dstProcessorId = LOCAL_PROCESSOR_ID;            }            pMsgHead->status = MSG_RECEIVED;            msg.srcProcessorId = pL3Msg->srcProcessorId;             msg.srcMpe         = pL3Msg->srcMpe;            msg.dstProcessorId = pL3Msg->dstProcessorId;            msg.dstMpe         = pL3Msg->dstMpe;            msg.ulSize         = pL3Msg->ulSize;            msg.msgPrio        = pMsgHead->msgPrio;            msg.pvMsgBuf       = (VOID*)&pL3Msg->msg;            msg_free(mb);                                    SYS_HANDLE_LOCK();                                    if( (MPE_TIMER != msg.srcMpe) ||                (TRUE == ssp_timeout_msg_check(msg.pvMsgBuf)) )            {                if( (msg.dstMpe < MPE_BUTT) &&                    (TRUE == g_pstMpe[msg.dstMpe].status) )                {                    if( g_pstMpe[msg.dstMpe].run )                    {                        dbg_track_msg_in(pL3Msg);                        g_pstMpe[msg.dstMpe].msg_handling = 1;                        g_pstMpe[msg.dstMpe].message_cnt++;                        g_pstMpe[msg.dstMpe].run( &msg, msg.pvMsgBuf );                        g_pstMpe[msg.dstMpe].msg_handling = 0;                                                dbg_track_msg_out();                    }                }            }                                                MSG_RETURN_DMEM(pMsgHead);                        SYS_HANDLE_UNLOCK();                        aos_cputick_get( &now );            aos_cputick_sub( &now, &g_pstTask[pCurMpset->task_id].cputicklast );                        if( aos_cputick_compare( &now, &g_cputAllowed ) >= 0 )            {                sys_task_unlock();                 sys_task_delay(0);                 sys_task_lock();               }        }    }                    AOS_TRACE_OUT( 0, 0, 0, 0 );    }U32 m_msg_system_start(){    MPS mps;    MPS_S *pMpset;    U32 result;        for( mps=0; mps < MPS_BUTT; mps++ )    {        if( FALSE == g_pstMpset[mps].status )        {            continue;        }        pMpset = &g_pstMpset[mps];        result = aos_task_create( pMpset->name,                                  (MPS_H323 == mps ? 2*CONFIG_MSG_TASK_STACK_SIZE : CONFIG_MSG_TASK_STACK_SIZE),                                  (enum tsk_prio)(pMpset->task_prio),                                  MSG_TASK_MODE,                                  (VOID(* )(VOID *))ssp_msg_task,                                  (VOID*) mps,                                  &pMpset->task_id );        if( AOS_SUCC != result )        {            goto system_start_fail;        }            }    clear_watch_dog();        {        MPE mpe;        S32 order;        S8 *tmpstring[STARTUP_BUTT+1] = { "...... STARTUP_BEFORE_INITIAL order begin ......",                                       "...... STARTUP_INITIAL order begin ......",                                       "...... STARTUP_LOAD_DATA order begin ......",                                       "...... STARTUP_GO order begin ......", };        for( order=STARTUP_BEFORE_INITIAL; order<STARTUP_BUTT; order++ )        {            aos_printf( MPE_SYS, "\r%s", tmpstring[order+1] );            dbg_track_run_flow( "%s", tmpstring[order+1] );            clear_watch_dog();            if( STARTUP_GO == order )            {                m_ulMsgEnable = TRUE;            }            for( mpe=0; mpe < MPE_BUTT; mpe++ )            {                if( (TRUE == g_pstMpe[mpe].status) &&                    (NULL != g_pstMpe[mpe].init) )                {                    dbg_track_run_flow( "%s,MPE=%d...", tmpstring[order+1], mpe );                    result = g_pstMpe[mpe].init((START_ORDER_E)order);                    if( AOS_SUCC != result )                    {                        printf( "\r\nErr! MPE = %d order = %d", (int)mpe, (int)order );                        aos_printf( MPE_SYS, "\rErr! MPE = %d init fail!", mpe );                        dbg_track_run_flow("Err! MPE = %d init fail!", mpe );                                                aos_task_delay(1000);                        goto system_start_fail;                    }                }            }        }        aos_printf( MPE_SYS, "\r" );        aos_printf( MPE_SYS, "...... AOS all module initialize successfully ! ...... " );                dbg_track_run_flow("...... AOS all module initialize successfully ! ...... " );#ifdef _EIA2000V5                printf("\r\n@@@@@@@ AOS all module initialize successfully ! @@@@@ \r\n" );#endif    }        clear_watch_dog();    return AOS_SUCC;system_start_fail:    #if( CONFIG_OS_VXWORKS == TRUE )    drv_cpu_reset();#endif    return result;    }AOS_INLINE U32 ssp_msg_send( MSG_S *msg, U32 prim ){    struct msg_blk *newmb;    MSG_HEAD_S *pMsgHead;    L3_MSG_HEAD_S *pL3Msg;    MPE dstMpe;    MPS dstMps = 0;    U32 result = AOS_SUCC, oldStatus;    AOS_ASSERT( NULL != msg );    AOS_ASSERT( DL_DATA_REQUEST == prim || DL_UNIT_DATA_REQUEST == prim );        if( NULL == msg )    {        return MSG_INVALID;    }    pMsgHead = (MSG_HEAD_S*)mem_obj_head(msg->pvMsgBuf);    if( NULL == pMsgHead )    {        return MSG_INVALID;    }    if( MSG_SENDED == pMsgHead->status )    {        aos_printf( MPE_SYS, "resend message,mpe=%d, msg_ptr=0x%x \r\n",                    pMsgHead->srcMpe,msg->pvMsgBuf );        return MSG_RESEND;    }    oldStatus = pMsgHead->status;    if( (MSG_ALLOCATED !=oldStatus) &&        (MSG_RECEIVED != oldStatus) )    {        aos_printf( MPE_SYS, "message invalid  msg_ptr=0x%x \r\n",msg->pvMsgBuf );        return MSG_INVALID;    }    if( msg->msgPrio >= MSG_PRIO_BUTT )    {        result = MSG_MSG_PRIO_INVALID;        goto send_err_ret;    }    if( FALSE == m_ulMsgEnable )    {        result = MSG_NO_TASK;        goto send_err_ret;    }        if( LOCAL_PROCESSOR_ID == msg->dstProcessorId )    {        dstMpe = msg->dstMpe;        if( (dstMpe >= MPE_BUTT)   ||             (FALSE == g_pstMpe[dstMpe].status) )        {            result = MSG_MPE_INVALID;            goto send_err_ret;        }        dstMps = g_pstMpe[dstMpe].mps;        if( (FALSE == g_pstMpset[dstMps].status) ||            (U32_BUTT == g_pstMpset[dstMps].task_id) )        {            result = MSG_NO_TASK;            goto send_err_ret;        }    }    newmb = msg_alloc();    if( NULL == newmb )    {        result = MSG_MPE_NO_MSGB;        goto send_err_ret;    }    if( MSG_RECEIVED == oldStatus )    {        aos_dmem_ref_inc( pMsgHead );    }    pL3Msg = (L3_MSG_HEAD_S*)((U32)msg->pvMsgBuf - ELEMENT_OFFSET(L3_MSG_HEAD_S,msg));    pL3Msg->srcProcessorId = msg->srcProcessorId;     pL3Msg->srcMpe         = msg->srcMpe;    pL3Msg->dstProcessorId = msg->dstProcessorId;    pL3Msg->dstMpe         = msg->dstMpe;    pL3Msg->ulSize         = msg->ulSize;        pMsgHead->msgPrio      = msg->msgPrio;    pMsgHead->status       = MSG_SENDED;    newmb->head = (VOID*)pMsgHead;    newmb->truelen = mem_obj_size(msg->pvMsgBuf);    newmb->end  = newmb->head + newmb->truelen;            newmb->data = (VOID*)pL3Msg;    newmb->len  = msg->ulSize + L3_MSG_HEAD_LEN;    newmb->tail = newmb->data + newmb->len;        if( LOCAL_PROCESSOR_ID == msg->dstProcessorId )    {        msg_que_tail( &g_pstMpset[dstMps].msg_que[msg->msgPrio], newmb );        aos_event_post( g_pstMpset[dstMps].task_id, MSG_SYNC_EVENT );        return AOS_SUCC;    }    else    {                result = lcm_send_data( prim, newmb );        if( AOS_SUCC == result )        {            return AOS_SUCC;        }    }       msg_free( newmb );    send_err_ret:    if( MSG_ALLOCATED == oldStatus )    {         MSG_RETURN_DMEM( pMsgHead );    }    return result;}#ifdef __cplusplus}#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -