📄 mk_sche.c
字号:
#if defined(XMK_USE_DEBUGGING) && defined(XMK_ADD_MICRO_COMMAND)
#if defined(XMK_ADD_CBREAK_LOGIC)
xmk_T_CMD_BREAK_HIT_IND BreakHitDescr ;
#endif
#endif
#ifndef XMK_USE_PREEMPTIVE
#if defined(XMK_USE_CHECK_TRANS_TIME) || defined(XMK_ADD_CQUERY_PROCESS)
xmk_T_TIME begin_time, end_time ;
#endif
#endif
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_FUNCTION("*SI*ProcessSignal");
#endif
#if defined(XMK_USE_DEBUGGING) && (defined(XMK_ADD_CREINIT) || defined(XMK_ADD_CSHUTDOWN))
if (xmk_SystemState & (XMK_REINIT_SYSTEM | XMK_SYSTEM_SHUTDOWN) )
{
XMK_SUPPRESS(xmk_SystemState);
return ;
}
#endif /* ... XMK_ADD_CREINIT */
#ifdef XMK_USE_DEBUGGING
if (!(xmk_SystemState & XMK_BREAKPOINT_HIT))
{
#endif
/*
** load pointer to signal with first signal in the queue
*/
p_Message = xmk_FirstSignal () ;
/*
** while there is a signal to be worked on
*/
#if defined(XMK_ADD_MICRO_TESTER) && defined(XMK_ADD_PSC_TRACE)
/*
** Send Systemtime to PSC
*/
PSCTime.time = xmk_NOW();
if(( PSCTime.time & 0x000000ffL) == 0x00000080 )
{
xmk_Cod_Encode (XMK_MICRO_TRACER, CMD_TPSC_TIME, (char*)&PSCTime, sizeof( xmk_T_CMD_TPSC_TIME) );
}
#endif
while( p_Message != (xmk_T_MESSAGE xmk_RAM_ptr) NULL )
{
/*
** Use a Routing function, if the signal in the queue contains
** no receiver-PID. The user has to implement the function
** anywhere; a template is given in mk_user - module.
*/
#ifndef XMK_USE_RECEIVER_PID_IN_SIGNAL
/*
** Set new active process-PID
*/
XMK_BEGIN_CRITICAL_PATH;
xRunPID = xRouteSignal (p_Message->signal);
#ifdef XMK_USE_PREEMPTIVE
/*
** store the priority-level working on
*/
CurrentPrioLevel = EPRIOLEVEL;
#endif
XMK_END_CRITICAL_PATH;
#ifdef XMK_USE_MAX_ERR_CHECK
if (xRunPID == xNULLPID)
{
ErrorHandler (ERR_N_xRouteSignal);
xmk_RemoveCurrentSignal ();
/*
** Leave signal-handling ( leave while-loop )
*/
p_Message = NULL;
continue;
}
#endif
#else
/*
** Set new active process-PID
*/
XMK_BEGIN_CRITICAL_PATH;
xRunPID = p_Message->rec;
#ifdef XMK_USE_PREEMPTIVE
CurrentPrioLevel = EPRIOLEVEL;
#endif
XMK_END_CRITICAL_PATH;
#endif /* ... ifndef XMK_USE_RECEIVER_PID_IN_SIGNAL */
#ifdef XMK_USE_DEBUGGING
/*
** Check whether the system is in single-stepping
*/
if (xmk_SystemState & XMK_SINGLE_STEPPING)
{
if (xmk_SystemState & XMK_SYSTEM_NEXT_STEP)
{
XMK_BEGIN_CRITICAL_PATH;
xmk_SystemState &= ~XMK_SYSTEM_NEXT_STEP;
XMK_END_CRITICAL_PATH;
}
else
{
return;
}
}
/*
** Check whether the system is suspended or not
*/
if (xmk_SystemState & XMK_SYSTEM_SUSPENDED)
{
#ifdef XMK_ADD_PRINTF_ADDITIONAL
PRINTF(("\n...Sorry, suspended\n\n"));
#endif
return;
}
#ifdef XMK_ADD_CBREAK_LOGIC
/*
** Check whether the current system state is a breakpoint
*/
if (xmk_CheckIfBreakpointTrue(xRunPID, p_Message->signal,
XMK_NO_STATE,&BreakHitDescr))
{
XMK_BEGIN_CRITICAL_PATH;
xmk_SystemState |= XMK_BREAKPOINT_HIT;
XMK_END_CRITICAL_PATH;
#ifdef XMK_ADD_PRINTF_ADDITIONAL
PRINTF(("\n\n Breakpoint Signal was hit \n\n"));
#endif
#if defined(XMK_ADD_MICRO_COMMAND)
(void) xmk_HandleHostCmd (CMD_BREAK_HIT_IND,
(xmk_U_CMDS *) &BreakHitDescr);
#endif /* ... defined(XMK_ADD_MICRO_COMMAND) */
return;
}
#endif /* ... XMK_ADD_CBREAK_LOGIC */
#endif /* ... XMK_USE_DEBUGGING */
#ifdef XMK_ADD_PRINTF_ADDITIONAL
XMK_TRACE_SCHE("*SI*ProcessSignal(): WORKING ON A SIGNAL");
XMK_TRACE_SCHE("----------------------------------------");
PRINTF (("*SI*ProcessSignal():Signal-ID:%d\n", p_Message->signal));
#endif /* ... XMK_ADD_PRINTF_ADDITIONAL */
#ifdef XMK_USED_DYNAMIC_CREATE
/*
** If current signal is a system-signal
*/
if( p_Message->signal == XMK_CREATE_SIGNALID)
{
/*
** work on it
*/
xmk_HandleSystemSignal ( p_Message );
/*
** Leave signal-handling ( leave while-loop )
*/
p_Message = NULL;
} /* END IF */
/*
** if signal isn't system-signal
*/
else
#endif /* ... XMK_USED_DYNAMIC_CREATE */
{
/*
** load pointer with process-description-table of current processtype
*/
p_ReceiverProcess = xPDTBL [ RUN_PROC ] ;
#if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING)
XMK_BEGIN_CRITICAL_PATH;
pRunPIDTable = &( p_ReceiverProcess->pPIDTable [RUN_INST]) ;
XMK_END_CRITICAL_PATH;
#endif /* ... defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) */
/*
** Get current state of the receiver-process-instance from <process-state-table>
*/
CurrentState = p_ReceiverProcess->ProcessStateTable [ RUN_INST ] ;
/*
** Receiving processinstance remains in a state,
** where the signal to work on is defined as "SAVE"
*/
#ifdef XMK_USED_SAVE
if( xmk_TestAndSetSaveState( CurrentState ) )
{
/*
** define handling of signal
*/
TestResult = SAVE_NOT_TRACE ;
} /* END IF */
else
#endif /* XMK_USED_SAVE */
{
/*
** Get action for signals not yet saved ...
*/
TestResult =
xmk_CheckSignal ( p_Message->signal, CurrentState, p_ReceiverProcess );
} /* END ELSE */
/*
** Perform action ...
*/
switch( TestResult )
{
#ifdef XMK_USED_SAVE
case SAVE_NOT_TRACE :
{
/*
** No action for this signal, work on next Signal
*/
p_Message = xmk_NextSignal () ;
break ;
} /* END CASE */
case SAVE :
{
#ifdef XMK_ADD_TSAVE
xmk_TSDL_Save (p_Message);
#endif
/*
** No action for signals to be saved, work on next signal
*/
p_Message = xmk_NextSignal () ;
break ;
} /* END CASE */
#endif /* XMK_USED_SAVE */
case IMPLICIT_CONSUMPTION :
{
/*
** INTERPRETATION ERROR : Signal has been consumed
*/
ErrorHandler (ERR_N_SDL_IMPLICIT_CONSUMPTION);
#ifndef XMK_USE_NO_ERR_CHECK
{
#ifdef XMK_ADD_TIMPLICIT_CONSUMPTION
xmk_TSDL_ImplicitConsumption (p_Message, CurrentState);
#endif
/*
** Remove signal from queue
*/
xmk_RemoveCurrentSignal () ;
/*
** ... and work on next signal
*/
p_Message = xmk_NextSignal () ;
break ;
}
#endif /* ... XMK_USE_NO_ERR_CHECK */
} /* END CASE */
/*
** ------------V
** Fall into case DISCARD, if no error check is selected...
** ------------V
*/
case DISCARD :
{
/*
** INTERPRETATION ERROR : SDL-discard -> process doesn't exist's
*/
ErrorHandler (ERR_N_SDL_DISCARD);
#ifdef XMK_ADD_TDISCARD
xmk_TSDL_Discard (p_Message, CurrentState);
#endif
/*
** Remove signal from queue
*/
xmk_RemoveCurrentSignal () ;
/*
** ... and work on next signal
*/
p_Message = xmk_NextSignal () ;
break ;
} /* END CASE */
default :
{
XMK_BEGIN_CRITICAL_PATH;
/*
** NORMAL CASE :
** Load global pointer before calling the transitionfunction
*/
xmk_SignalInstPtr = p_Message ;
/*
** Load global pointer to enable access instancedata for the
** transitionfunction
*/
/*
* Dynamic instance data:
* Since it is the pointers that are stored in the array
* pInstanceData, we just copy a pointer value.
*/
#ifndef XMK_USED_ONLY_X_1
pRunData = ((unsigned char **)(p_ReceiverProcess->pInstanceData))[RUN_INST];
#else
pRunData = p_ReceiverProcess->pInstanceData;
#endif
XMK_END_CRITICAL_PATH;
#ifdef XMK_ADD_TINPUT
xmk_TSDL_Input (p_Message, CurrentState);
#endif
/*
** load symbolnumber and address of the transitionfunction to execute ...
*/
#ifdef XMK_USE_PREEMPTIVE
TmpSymbolNr = p_ReceiverProcess->TransitionTable [ TestResult ].SymbolNr;
#else
XMK_BEGIN_CRITICAL_PATH;
xmk_SymbolNrVar = p_ReceiverProcess->TransitionTable [ TestResult ].SymbolNr;
XMK_END_CRITICAL_PATH;
#endif
TransitionFunction = p_ReceiverProcess->yPAD_Function ;
#ifndef XMK_USE_PREEMPTIVE
#if defined(XMK_USE_CHECK_TRANS_TIME) || defined(XMK_ADD_CQUERY_PROCESS)
/*
** Get systemtime to administer execution time of the transition to be performed
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -