📄 mk_outp.c
字号:
} /* END IF */
} /* END ELSE */
#endif /* ... XMK_USED_SIGNAL_WITH_PARAMS */
/*
** Insert signal into queue ...
*/
xmk_InsertSignal (P_Signal);
#ifdef XMK_ADD_PRINTF_OUTPUT
XMK_TRACE_EXIT("xmk_Send");
#endif
/*
** RETURN (0) means o.k.
*/
RETURN (0);
} /* END OF FUNCTION */
#ifndef XMK_USED_ONLY_X_1
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_Determine_Receiver |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This function is used in the context of SDL output in generated C code. |
| This function determines an instance of the given type to be available as |
| a signal's receiver. If no instance can be found, it returns xNULLPID. |
| |
| Parameter : proc_type - process type to be checked for a receiver |
| |
| Return : global PID of a found receiver, xNULLPID if none is found |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
xPID xmk_Determine_Receiver ( xmk_T_PROCESS proc_type )
#else
xPID xmk_Determine_Receiver ( proc_type )
xmk_T_PROCESS proc_type;
#endif
/*-FDEF E*/
{
X_REGISTER unsigned char i;
#ifdef XMK_ADD_PRINTF_OUTPUT
XMK_FUNCTION("xmk_Determine_Receiver");
#endif
/*
** for all the instances of the given processtype
*/
for (i=0; i < xPDTBL[proc_type]->MaxInstances; i++)
{
/*
** if the instance isn't in state XDORMANT, i.e. active
*/
if ((xPDTBL[proc_type])->ProcessStateTable[i] != XDORMANT)
{
#ifdef XMK_ADD_PRINTF_OUTPUT
XMK_TRACE_EXIT("xmk_Determine_Receiver");
#endif
/*
** return global PID of this instance
*/
return(GLOBALPID(proc_type, i));
}
}
/*
** fatal error: no instance can receive a signal
*/
ErrorHandler(ERR_N_NO_REC_AVAIL);
#ifdef XMK_ADD_PRINTF_OUTPUT
XMK_TRACE_EXIT("xmk_Determine_Receiver");
#endif
/*
** return xNULLPID to enable caller to detect there is no receiver
*/
return(xNULLPID);
}
#endif /* ... XMK_USED_ONLY_X_1 */
#ifdef XMK_USE_EXPANDED_KERNEL
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_EnvSend |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| This function is an alternative to the standard-function. |
| |
| The main difference is that it is impossible to direct a signal to the |
| xOutEnv function. |
| |
| This function represents the basic SDL-Output-function with all necessary |
| parameters. The <signal-instance> to be created is put into the |
| <input-port> of the receiving process. |
| |
| Normally, signals are transferred by using a signalheader plus an area of |
| fixed length containing the <signal-parameter>. If the length of parameters |
| for a signal exceeds the length of this "default"-area, a memory block |
| is allocated for the signal-parameters to be transferred. |
| If there is not enough memory, the ErrorHandler is called. |
| |
| CAUTION !!!!! |
| ================ |
| This function must only be used if the compiler in use does not support |
| reentrant functions. |
| It is the user's duty to set all the function's parameters correctly, |
| There is no errorcheck performed. |
| |
| Parameter : sig - signal's code |
| prio - signal's priority |
| data_len - number of bytes of the signal's parameter |
| p_data - pointer to dynamically allocated memory area |
| containing the signal's parameter |
| (NULL if parameter contained within signal) |
| Receiver - PID of the receiver-process |
| |
| Return : 0 - no error (o.k.) |
| 1 - no more signals left free |
| 2 - no more memory allocatable |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
RETDCL xmk_EnvSend(xmk_T_SIGNAL sig
#ifdef XMK_USE_SIGNAL_PRIORITIES
, xmk_T_PRIO prio
#endif
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
, xmk_T_MESS_LENGTH data_len,
void xmk_RAM_ptr p_data
#endif
#ifdef XMK_USE_RECEIVER_PID_IN_SIGNAL
, xPID Receiver
#endif
)
#else
RETDCL xmk_EnvSend (sig
#ifdef XMK_USE_SIGNAL_PRIORITIES
, prio
#endif
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
, data_len,
p_data
#endif
#ifdef XMK_USE_RECEIVER_PID_IN_SIGNAL
, Receiver
#endif
)
xmk_T_SIGNAL sig;
#ifdef XMK_USE_SIGNAL_PRIORITIES
xmk_T_PRIO prio;
#endif
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
xmk_T_MESS_LENGTH data_len;
void xmk_RAM_ptr p_data;
#endif
#ifdef XMK_USE_RECEIVER_PID_IN_SIGNAL
xPID Receiver;
#endif
#endif
/*-FDEF E*/
{
X_REGISTER xmk_T_MESSAGE xmk_RAM_ptr P_Signal; /* Pointer to signal */
X_STATIC void xmk_RAM_ptr P_Parameter; /* Pointer to signal's parameter */
#ifdef XMK_USE_SIGNAL_TIME_STAMP
xmk_T_TIME timestamp ; /* set signal's timestamp */
#endif
#ifdef XMK_USE_DEBUGGING
if (xmk_SystemState & XMK_SYSTEM_SUSPENDED)
{
RETURN(6);
}
#endif
#ifdef XMK_USE_SIGNAL_TIME_STAMP
timestamp = xmk_NOW() ;
#endif
/*
** Allocate signal. If there is no free signal
** instance left, return with an error code
*/
P_Signal = xmk_AllocSignal();
if (P_Signal == NULL)
{
ErrorHandler (ERR_N_NO_FREE_SIGNAL);
RETURN (1);
}
P_Signal->signal = sig ; /* set signal's code */
#ifdef XMK_USE_SIGNAL_PRIORITIES
P_Signal->prio = prio ; /* set signal's priority */
#endif
#ifdef XMK_USE_SIGNAL_TIME_STAMP
P_Signal->timestamp = timestamp ; /* set signal's timestamp */
#endif
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
P_Signal->mess_length = data_len ; /* set length of signal's parameter */
#endif
#ifdef XMK_USE_RECEIVER_PID_IN_SIGNAL
P_Signal->rec = Receiver ; /* set signal's receiver */
#endif
#ifdef XMK_USE_SENDER_PID_IN_SIGNAL
P_Signal->send = xRunPID ; /* set signal's sender */
#endif
/*
** if number of bytes of the signal's parameter is greater than
** the number of bytes contained in the signal
*/
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
if (data_len > XMK_MSG_BORDER_LEN)
{
/*
** Allocate memory area
*/
P_Parameter = (xmk_T_MESSAGE xmk_RAM_ptr ) xAlloc (data_len);
/*
** if memory allocation failed, free signal and return errorcode
*/
if (P_Parameter == NULL)
{
ErrorHandler (ERR_N_PARAMETER_MEM_ALLOC);
xmk_FreeSignal (P_Signal);
RETURN (2);
}
/*
** copy parameter into the allocated memory area
*/
(void)memcpy (P_Parameter, p_data, data_len);
/*
** store pointer to memory area in signal
*/
P_Signal->ParUnion.ParPtr = P_Parameter;
}
/*
** if parameters can be stored within the signal itself
*/
else
{
if( data_len > 0 )
{
/*
** copy the parameters into the signal
*/
(void)memcpy ((void xmk_RAM_ptr ) (P_Signal->ParUnion.ParCopy), (void xmk_RAM_ptr ) p_data,
XMK_MSG_BORDER_LEN);
} /* END IF */
} /* END ELSE */
#endif /* ... XMK_USED_SIGNAL_WITH_PARAMS */
/*
** insert signal in queue
*/
xmk_InsertSignal (P_Signal);
/*
** RETURN (0) means o.k.
*/
RETURN (0);
} /* END OF FUNCTION */
#endif /* ...XMK_USE_EXPANDED_KERNEL... */
#endif /* __MK_OUTP_C_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -