📄 event_handler.c
字号:
#ifdef MMI_FRM_BACKWARD_COMPATIBLE_EVENTS
if (currPostInterruptFuncPtr)
{
(*currPostInterruptFuncPtr) (MsgStruct, mod_src, peerBuf);
}
#endif /* MMI_FRM_BACKWARD_COMPATIBLE_EVENTS */
/* New interruption mechanism */
if (query_result && post_int_func)
{
execute_result = (*post_int_func)(current_frm_int_event);
}
#if defined (MMI_EVENT_PROFILING)
kal_get_time(&end_tick);
accu_ticks += (end_tick - start_tick);
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "ExecuteCurrProtocolHandler accu_count = %d", accu_count);
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "ExecuteCurrProtocolHandler accu_ticks = %d", accu_ticks);
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "ExecuteCurrProtocolHandler maxProtocolEvent = %d", maxProtocolEvent);
#endif /* defined (MMI_EVENT_PROFILING) */
}
/*****************************************************************************
* FUNCTION
* SetProtocolEventHandler
* DESCRIPTION
* This function is used for register the protocol event handler. Whenever
* an event is received from the protocol or system corresponding function
* is executed.
* PARAMETERS
* funcPtr [IN] Function to be executed whenever a event is received
* from the protocol or system
* eventID [IN] Unique Protocol/System EventID.
* RETURNS
* void
*****************************************************************************/
void mmi_frm_set_protocol_event_handler(PsFuncPtr funcPtr, U16 eventID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
static U16 maxUsedInHistory = 0;
U16 count;
S16 i, firstNotUsed;
S16 pos;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_ASSERT(eventID != 0);
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_SETPTO_HDLR, eventID, funcPtr, usedProtocolEvent,
maxProtocolEvent);
/* serach */
pos = -1;
firstNotUsed = -1;
for (count = 0; count < maxProtocolEvent; count++)
{
if (protocolEventHandler[count].eventID == eventID)
{
pos = count;
break;
}
/* BTW, find a non-used item */ ;
if ((firstNotUsed == -1) && (protocolEventHandler[count].eventID == MMI_EVENT_INVALID))
{
firstNotUsed = count;
}
}
if (pos != -1)
{
/* found */
if (funcPtr != NULL)
{
/* just need to update */
protocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* reset it */
protocolEventHandler[pos].eventID = MMI_EVENT_INVALID;
protocolEventHandler[pos].entryFuncPtr = NULL;
usedProtocolEvent--;
}
}
else
{
/* not found */
if (funcPtr != NULL)
{
/* newly set */
if (firstNotUsed != -1)
{
pos = firstNotUsed;
}
else
{
/* need to enlarge current searching list */
pos = maxProtocolEvent;
maxProtocolEvent++;
MMI_ASSERT(maxProtocolEvent < MAX_PROTOCOL_EVENT);
}
usedProtocolEvent++;
protocolEventHandler[pos].eventID = eventID;
protocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* do nothing */
}
}
/* recycle not-used items in the tail of list. It is for searching efficency */
for (i = (maxProtocolEvent - 1); i >= 0; i--)
{
if (protocolEventHandler[i].eventID != MMI_EVENT_INVALID)
{
break;
}
}
maxProtocolEvent = i + 1;
/* record the max value for array size analysis */
if (maxUsedInHistory < maxProtocolEvent)
{
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "SetProtocolEventHandler old maxUsedInHistory = %d", maxUsedInHistory);
maxUsedInHistory = maxProtocolEvent;
PRINT_INFORMATION_2(MMI_FW_TRC_G1_FRM, "SetProtocolEventHandler maxUsedInHistory = %d", maxUsedInHistory);
}
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_SETPTO_HDLR, eventID, funcPtr, usedProtocolEvent,
maxProtocolEvent);
}
/*****************************************************************************
* FUNCTION
* ClearProtocolEventHandler
* DESCRIPTION
* This is used to clear protocol event handler
* PARAMETERS
* eventID [IN] Clear the handler of event ID.
* RETURNS
* void
*****************************************************************************/
void mmi_frm_clear_protocol_event_handler(U16 eventID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_CLRPTO_HDLR, eventID);
SetProtocolEventHandler(NULL, eventID);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_clear_all_protocol_event_handler
* DESCRIPTION
* This is used to clear all the protocol event handlers
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_frm_clear_all_protocol_event_handler(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_TRACE(MMI_FW_TRC_G1_FRM, MMI_FRM_INFO_EVENT_CLRALLPTO_HDLR);
memset(protocolEventHandler, 0, sizeof(PseventInfo)* maxProtocolEvent);
usedProtocolEvent = 0;
SetProtocolEventHandler(mmi_proc_inject_string, MSG_ID_TST_INJECT_STRING);
#ifdef __MMI_DUAL_SIM__
mmi_frm_clear_all_slave_protocol_event_handler();
#endif
}
#ifdef __MMI_DUAL_SIM__
/*****************************************************************************
* FUNCTION
* mmi_frm_set_slave_protocol_event_handler
* DESCRIPTION
* This function is used for register the protocol event handler for slave card.
* Whenever an event is received from the protocol or system corresponding function
* is executed.
* PARAMETERS
* funcPtr [IN] Function to be executed whenever a event is received
* from the protocol or system
* eventID [IN] Unique Protocol/System EventID.
* RETURNS
* void
*****************************************************************************/
void mmi_frm_set_slave_protocol_event_handler(PsFuncPtr funcPtr, U16 eventID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
static U16 maxUsedInHistory = 0;
U16 count;
S16 i, firstNotUsed;
S16 pos;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
MMI_ASSERT(eventID != 0);
//MMI_TRACE(MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETSLPTO_HDLR, eventID, funcPtr, usedSlaveProtocolEvent,
// maxSlaveProtocolEvent);
/* serach */
pos = -1;
firstNotUsed = -1;
for (count = 0; count < maxSlaveProtocolEvent; count++)
{
if (SlaveProtocolEventHandler[count].eventID == eventID)
{
pos = count;
break;
}
/* BTW, find a non-used item */ ;
if ((firstNotUsed == -1) && (SlaveProtocolEventHandler[count].eventID == MMI_EVENT_INVALID))
{
firstNotUsed = count;
}
}
if (pos != -1)
{
/* found */
if (funcPtr != NULL)
{
/* just need to update */
SlaveProtocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* reset it */
SlaveProtocolEventHandler[pos].eventID = MMI_EVENT_INVALID;
SlaveProtocolEventHandler[pos].entryFuncPtr = NULL;
usedSlaveProtocolEvent--;
}
}
else
{
/* not found */
if (funcPtr != NULL)
{
/* newly set */
if (firstNotUsed != -1)
{
pos = firstNotUsed;
}
else
{
/* need to enlarge current searching list */
pos = maxSlaveProtocolEvent;
maxSlaveProtocolEvent++;
MMI_ASSERT(maxSlaveProtocolEvent < MAX_SLAVE_PROTOCOL_EVENT);
}
usedSlaveProtocolEvent++;
SlaveProtocolEventHandler[pos].eventID = eventID;
SlaveProtocolEventHandler[pos].entryFuncPtr = funcPtr;
}
else
{
/* do nothing */
}
}
/* recycle not-used items in the tail of list. It is for searching efficency */
for (i = (maxSlaveProtocolEvent - 1); i >= 0; i--)
{
if (SlaveProtocolEventHandler[i].eventID != MMI_EVENT_INVALID)
{
break;
}
}
maxSlaveProtocolEvent = i + 1;
/* record the max value for array size analysis */
if (maxUsedInHistory < maxSlaveProtocolEvent)
{
// PRINT_INFORMATION_2(MMI_TRACE_G1_FRM, "SetSlaveProtocolEventHandler old maxUsedInHistory = %d", maxUsedInHistory);
maxUsedInHistory = maxSlaveProtocolEvent;
// PRINT_INFORMATION_2(MMI_TRACE_G1_FRM, "SetSlaveProtocolEventHandler maxUsedInHistory = %d", maxUsedInHistory);
}
// MMI_TRACE(MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_SETSLPTO_HDLR, eventID, funcPtr, usedSlaveProtocolEvent,
// maxSlaveProtocolEvent);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_clear_slave_protocol_event_handler
* DESCRIPTION
* This is used to clear protocol event handler
* PARAMETERS
* eventID [IN] Clear the handler of event ID.
* RETURNS
* void
*****************************************************************************/
void mmi_frm_clear_slave_protocol_event_handler(U16 eventID)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
//MMI_TRACE(MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRSLPTO_HDLR, eventID);
mmi_frm_set_slave_protocol_event_handler(NULL, eventID);
}
/*****************************************************************************
* FUNCTION
* mmi_frm_clear_all_slave_protocol_event_handler
* DESCRIPTION
* This is used to clear all the protocol event handlers
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void mmi_frm_clear_all_slave_protocol_event_handler(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
// MMI_TRACE(MMI_TRACE_G1_FRM, MMI_FRM_INFO_EVENT_CLRSLALLPTO_HDLR);
memset(SlaveProtocolEventHandler, 0, sizeof(PseventInfo) * maxSlaveProtocolEvent);
usedSlaveProtocolEvent = 0;
mmi_frm_set_slave_protocol_event_handler(mmi_proc_inject_string, MSG_ID_TST_INJECT_STRING);
}
#endif /* __MMI_DUAL_SIM__ */
/*****************************************************************************
* FUNCTION
* mmi_frm_query_interrupt_event_information
* DESCRIPTION
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -