📄 mk_main.c
字号:
xInitEnv ();
#endif
#ifdef XMK_ADD_MICRO_TESTER
#ifdef XMK_ADD_PSC_TRACE
/*
** Initialize PSC trace
*/
xmk_TSDL_PSC_CreateAll();
#endif
#if defined(XMK_ADD_MICRO_RECORDER)
xmk_InitRecordMode ();
XMK_END_CRITICAL_PATH;
xmk_InitPlayMode ();
XMK_BEGIN_CRITICAL_PATH;
#endif /* ... XMK_ADD_MICRO_RECORDER */
#endif /* ... XMK_ADD_MICRO_TESTER */
/*
** Execute SDL Starttransitions
*/
xmk_StartProcesses() ;
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
/*
** Enable preemptive scheduling
*/
xmk_EnablePreemption();
#endif
/*-PREEMPT*/
/*
** critical path ends here, because system start phase ends
*/
XMK_END_CRITICAL_PATH;
#ifdef XMK_ADD_PRINTF_MAIN
XMK_TRACE_EXIT("xmk_InitSDL");
#endif
} /* END OF FUNCTION */
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_RunSDL |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This functions processes either a number of signals or processes forever, |
| if CountSignals is given with 0xff. |
| Before processing signals, SDL-timeouts are checked and a the function |
| "xInEnv", which must be filled out by the user, is called. |
| |
| Parameter : CountSignals - amount of signals, which is to be worked on |
| in this function call, where |
| 0xff means endless. |
| |
| Return : XMK_NORMALRETURN - SDL-System not to be stopped. There are |
| processes living or the queue is not empty. |
| |
| XMK_STOP - SDL-System is to be stopped, because |
| there are no more processinstances living and|
| no signal to be worked on. |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifdef XMK_USE_HIGH_OPTIMIZATION
#ifndef XNOPROTO
void xmk_RunSDL (void)
#else
void xmk_RunSDL ()
#endif
#else
#ifndef XNOPROTO
int xmk_RunSDL (unsigned char CountSignals)
#else
int xmk_RunSDL (CountSignals)
unsigned char CountSignals;
#endif
#endif /* ... XMK_USE_HIGH_OPTIMIZATION */
/*-FDEF E*/
{
#ifdef XMK_ADD_MICRO_TESTER
char * p_data;
char buffer [256];
int result;
int MessageClass;
int MessageTag;
int MessageLength;
#endif /* ... XMK_ADD_MICRO_TESTER */
#ifdef XMK_ADD_PRINTF_MAIN
XMK_FUNCTION("xmk_RunSDL");
#endif
do
{
#ifdef XMK_ADD_MICRO_RECORDER
if (xmk_RecorderMode == XMK_RECORDER_PLAY)
{
#if defined(XMK_UNIX) || defined(BORLAND_C) || defined(MICROSOFT_C)
int c;
c = xmk_GetChar ();
if (XMK_TERMINATION_CHAR(c))
{
/* possibility to terminate the program when target */
/* is a PC. Attention ! Files and Communications Link are not*/
/* closed or disabled. This is only the "emergency exit" */
/* of the program, which is currently running in play mode. */
PRINTF (( "**WARNING: User wants to quit->Using emergency exit\n"));
XMK_KERNEL_EXIT (0);
}
#endif /* ... defined(XMK_UNIX) || defined(BORLAND_C) || defined(MICROSOFT_C) */
} /* ... if (xmk_RecorderMode == ... PLAY) */
else
{
/*
** No activities here from the Cmicro Recorder
** when recording or recorder off
** ==> Ordinary Environment handling
*/
#ifdef XMK_USE_xInEnv
xInEnv ();
#endif /* ... XMK_USE_xInEnv */
/*
** Check if any timer is expired ...
*/
#ifdef XMK_USED_TIMER
#ifdef XMK_USE_DEBUGGING
#if defined(XMK_ADD_CSHUTDOWN)
XMK_MAIN_SHUTDOWN;
#endif /* ... XMK_ADD_CSHUTDOWN */
#if defined(XMK_ADD_CREINIT)
/*
** System is to be reinitialized on user requests;
** This may lead to unexpected results
** because the hardware and physical layer initialization
** may fail for some reasons. Also, the buffers of the
** communications link will be removed here and the trace
** may probably not work.
** Reinitialization can restrictively be used for some test only.
*/
if (xmk_SystemState & XMK_REINIT_SYSTEM)
{
xmk_RestoreXPDTBL ();
xmk_InitSDL ();
}
#endif /* ... XMK_ADD_CREINIT */
/*
** Timer expired check is only to be done
** if timers are not disabled
*/
if (!(xmk_SystemState & XMK_TIMER_DISABLED))
#endif /* ... XMK_USE_DEBUGGING */
xmk_ChkTimer ();
#endif /* ... XMK_USED_TIMER */
} /* ... if (xmk_RecorderMode == ...) */
#else
/*
** If the Cmicro Recorder is not compiled, then
** read in signals from the environment ...
*/
#ifdef XMK_USE_xInEnv
xInEnv ();
#if defined(XMK_ADD_CSHUTDOWN)
XMK_MAIN_SHUTDOWN;
#endif /* ... XMK_ADD_CSHUTDOWN */
#if defined(XMK_USE_DEBUGGING) && defined(XMK_ADD_CREINIT)
if (xmk_SystemState & XMK_REINIT_SYSTEM)
{
xmk_RestoreXPDTBL ();
xmk_InitSDL ();
}
#endif
#endif /* ... XMK_USE_xInEnv */
/*
** Check if any timer is expired ...
*/
#ifdef XMK_USED_TIMER
#ifdef XMK_USE_DEBUGGING
/*
** Timer expired check is only to be done
** if timers aren't disabled
*/
if (!(xmk_SystemState & XMK_TIMER_DISABLED))
#endif /* ... XMK_USE_DEBUGGING */
xmk_ChkTimer ();
#endif /* XMK_USED_TIMER */
#endif /* XMK_ADD_MICRO_RECORDER */
#ifdef XMK_ADD_MICRO_TESTER
p_data = xmk_DLRead () ;
if (p_data != (char *) NULL)
{
result = xmk_Cod_Decode (p_data,
&MessageClass,
&MessageTag,
&MessageLength,
buffer,
sizeof (buffer));
#ifdef XMK_ADD_MICRO_COMMAND
if((MessageClass == XMK_MICRO_COMMAND)
#ifdef XMK_ADD_MICRO_ENVIRONMENT
||(MessageClass == XMK_MICRO_ENVIRONMENT))
#else
)
#endif
{
result = xmk_HandleHostCmd ( MessageTag, (xmk_U_CMDS*) buffer );
if (result != XMK_OKAY)
ErrorHandler (ERR_N_ILLEGAL_CMD);
}
#endif
}
#endif/* ... XMK_ADD_MICRO_TESTER */
/*
** Process the signal (if some exists) ...
*/
#ifdef XMK_USE_PREEMPTIVE
/*
** Actions for preemption ...
*/
XMK_BEGIN_CRITICAL_PATH;
if ((HighestPrioLevel = xmk_FetchHighestPrioLevel())
!= MAX_PRIO_LEVELS)
{
xmk_Queue = &Prio_Queue[HighestPrioLevel];
xmk_CurrentSignal = &Prio_CurrentSignal[HighestPrioLevel];
XMK_END_CRITICAL_PATH;
xmk_ProcessSignal ();
}
else
{
XMK_END_CRITICAL_PATH;
}
#else
/*
** Actions for non preemption ...
*/
xmk_ProcessSignal ();
#endif /* ... XMK_USE_PREEMPTIVE */
#ifdef XMK_USE_KERNEL_WDTRIGGER
/*
** Watchdogtrigger
*/
XMK_WDTRIGGER_FUNCTION;
#endif /* ... XMK_USE_KERNEL_WDTRIGGER */
/*
** If dynamic SDL System stop was recognized ....
*/
#ifdef XMK_USE_SDL_SYSTEM_STOP
if (xmk_QueueEmpty () && ! xmk_IsAnyProcessAlive () )
{
#ifdef XMK_ADD_PRINTF_MAIN
XMK_TRACE_EXIT("xmk_RunSDL");
#endif
#ifdef XMK_USE_HIGH_OPTIMIZATION
return ;
#else
return (XMK_STOP);
#endif
}
#endif /* ...XMK_USE_SDL_SYSTEM_STOP */
#ifndef XMK_USE_HIGH_OPTIMIZATION
/*
** If an upper limit of signals is to be worked on here ....
*/
if (CountSignals != 0xff)
{
/*
** Count the signals that have been processed ...
*/
CountSignals --;
}
}
while (CountSignals > 0);
#ifdef XMK_ADD_PRINTF_MAIN
XMK_TRACE_EXIT("xmk_RunSDL");
#endif
return (XMK_NORMALRETURN) ;
#else
}
while (1);
#endif /* ...XMK_USE_HIGH_OPTIMIZATION */
} /* END OF FUNCTION */
#ifdef XMK_ADD_MICRO_TESTER
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_MicroTesterInit |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This Function calls the host for the Cmicro Tester's configuration |
| |
| Parameter : int flag = 0 Static Init only |
| = 1-N Init from host |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
void xmk_MicroTesterInit( void )
#else
void xmk_MicroTesterInit( )
#endif
/*-FDEF E*/
{
char *p_data;
char buffer [256];
int result;
int MessageClass;
int MessageTag;
int MessageLength;
xmk_DLInit();
xmk_InitOptions ( );
#ifdef XMK_ADD_MICRO_RECORDER
xmk_SetRecorderMode( XMK_RECORDER_OFF );
#endif
xmk_TracerActive = XMK_TRUE;
/*
** Get target's configuration and send it to host as start message
*/
xmk_Encode_CMD_GET_CONFIG( CMD_GET_CONFIG_IND );
#ifdef XMK_WAIT_ON_HOST
/*
** Indicate to host, that waiting here
*/
ENCODE_NPAR ( CMD_START_SDL_IND );
while (1)
{
p_data = xmk_DLRead () ;
if (p_data != (char *) NULL)
{
result = xmk_Cod_Decode (p_data,
&MessageClass,
&MessageTag,
&MessageLength,
buffer,
sizeof (buffer));
#ifdef XMK_ADD_MICRO_COMMAND
if (MessageClass == XMK_MICRO_COMMAND)
{
result = xmk_HandleHostCmd ( MessageTag, (xmk_U_CMDS*) buffer );
if (result != XMK_OKAY)
ErrorHandler (ERR_N_ILLEGAL_CMD);
if (MessageTag == CMD_START_SDL_REQ) break;
} /* else : other message will be lost here */
#endif
}
}
#endif /* ... XMK_WAIT_ON_HOST */
} /* END OF FUNCTION */
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_MicroTesterDeinit |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This Function deinitializes the Cmicro Tester (the data link of it) |
| |
| Parameter : - |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
void xmk_MicroTesterDeinit( void )
#else
void xmk_MicroTesterDeinit( )
#endif
/*-FDEF E*/
{
xmk_DLDeinit();
}
#endif /* ... XMK_ADD_MICRO_TESTER */
#endif /* ... __MK_MAIN_C_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -