/**************************************************************************** * Function: TcpIpEthIsr * * PreCondition: TCPIPInit, PIC32MACEventSetNotifyEvents should have been called. * * Input: p - PIC32 MAC descriptor pointer * * Output: None * * Side Effects: None * * Overview: This function processes the Ethernet interrupts and reports the events back to the user. * * Note: None ******************************************************************************/ static void TcpIpEthIsr(void* p) { eEthEvents currEthEvents, currGroupEvents; PIC32_EV_GROUP_DCPT* pDcpt; int grpIx; PIC32_EMB_MAC_DCPT* pMacD = (PIC32_EMB_MAC_DCPT*)p; currEthEvents = EthEventsGet(); // process per group pDcpt = pMacD->mData._pic32_ev_group_dcpt; for(grpIx = 0; grpIx < sizeof(pMacD->mData._pic32_ev_group_dcpt)/sizeof(*pMacD->mData._pic32_ev_group_dcpt); grpIx++) { currGroupEvents = currEthEvents & pDcpt->_EthEnabledEvents; // keep just the relevant ones if(currGroupEvents) { pDcpt->_EthPendingEvents |= currGroupEvents; // add the new events pDcpt->_TcpPendingEvents |= _XtlEventsEth2Tcp(currGroupEvents); EthEventsEnableClr(currGroupEvents); // these will get reported; disable them until ack is received back EthEventsClr(currGroupEvents); // acknowledge the ETHC if(pDcpt->_TcpNotifyFnc) { (*pDcpt->_TcpNotifyFnc)(pDcpt->_TcpNotifyParam, pDcpt->_TcpPendingEvents); // let the user know } } pDcpt++; } SYS_INT_SourceStatusClear(pMacD->mData._macIntSrc); // acknowledge the int Controller }
/**************************************************************************** * Function: TCPIPEventProcess * * PreCondition: TCPIPInit, TCPIPEventSetNotifyEvents should have been called. * * Input: eventFlags - the events the stack that were asserted by calling the event notification handler * * Output: TRUE if link up and processing ok, * FALSE otherwise * * Side Effects: None * * Overview: This function processes the events that have been reported by the stack (multiple events can be reported orr-ed together). * The processing is meant only for the normal transfer events: TCPIP_EV_TXDONE, TCPIP_EV_PKTPEND and TCPIP_EV_TICK. * Other events are not processed by this call. They should be processed by the application. * * * Note: - The call advances the internal TcpIp state machine. It's intended as a more efficient replacement * for the TCPIPProcess(). Using the event notification system the processing is done only when there's a need to do so. * - The TCPIPEventProcess() can be called even when notification is not enabled (TCPIPEventSetNotifyEvents() has not been called). * The call will behave the same as TCPIPProcess() and serves as an unique entry point. ******************************************************************************/ int TCPIPEventProcess(eTCPIPEvent eventFlags) { int linkUp; if(_TcpEnabledEvents==0) { return TCPIPProcess(); // fake all } // notification enabled // we don't use the user passed events that can be stale eTCPIPEvent procEvents=TCPIP_EV_NONE; linkUp=1; if(_XtlEventsEth2Tcp(_TcpPendingEvents)&TCPIP_EV_PKTPEND) { linkUp&=TCPIPProcessRx(); procEvents|=TCPIP_EV_PKTPEND; } if(_XtlEventsEth2Tcp(_TcpPendingEvents)&TCPIP_EV_TICK) { linkUp&=TCPIPProcessTick(); procEvents|=TCPIP_EV_TICK; } if(_XtlEventsEth2Tcp(_TcpPendingEvents)&TCPIP_EV_TXDONE) { linkUp&=TCPIPProcessTx(); procEvents|=TCPIP_EV_TXDONE; } if(procEvents!=TCPIP_EV_NONE) { _TcpIpEventAck(procEvents); // processed } return linkUp; }
/**************************************************************************** * Function: _TcpIpEthIsr * * PreCondition: TCPIPInit, TCPIPEventSetNotifyEvents should have been called. * * Input: None * * Output: None * * Side Effects: None * * Overview: This function processes the Ethernet interrupts and reports the events back to the user. * * Note: None ******************************************************************************/ void __attribute__((vector(_ETH_VECTOR), interrupt, nomips16, weak)) _TcpIpEthIsr(void) { eEthEvents currEvents; currEvents=EthEventsGet()&_TcpEnabledEvents; // keep just those that are relevant _TcpPendingEvents|=currEvents; // add the new events EthEventsEnableClr(currEvents); // these will get reported; disable them until ack is received back EthEventsClr(currEvents); // acknowledge the ETHC if(_TcpNotifyFnc) { (*_TcpNotifyFnc)(_XtlEventsEth2Tcp(_TcpPendingEvents)); // let the user know } INTClearFlag(INT_ETHERNET); // acknowledge the INTC }
/**************************************************************************** * Function: TCPIPEventGetPending * * PreCondition: TCPIPInit should have been called. * * Input: None * * Output: the stack pending events * * Side Effects: None * * Overview: This function returns the currently pending events that have to be processed. * Multiple events can be orr-ed together as they accumulate. * The user should call back into the stack whenever a stack managed event is present (TCPIPEventProcess()). * The user is supposed to process the other events not managed by the stack and * eventually acknowledge them if re-enabling is needed. * * * Note: - This is the preferred method to get the current pending stack events. * The stack maintains a proper image of the events from their occurrence to their acknowledgement. * - Even with a notification handler in place it's better to use this function to get the current pending events * rather than using the events passed by the notification handler which could be stale. * - The events are persistent. They shouldn't be re-enabled unless they have been processed and the condition that generated them was removed. * Re-enabling them immediately without proper processing will have dramatic effects on system performance. * ******************************************************************************/ eTCPIPEvent TCPIPEventGetPending(void) { return _XtlEventsEth2Tcp(_TcpPendingEvents); }