//------------------------------------------------------------------------------ void eventkcal_process(void) { tOplkError ret; tEvent* pEvent; size_t readSize = sizeof(aRxBuffer_l); if (instance_l.fInitialized == FALSE) return; if (eventkcal_getEventCountCircbuf(kEventQueueKInt) > 0) { ret = eventkcal_getEventCircbuf(kEventQueueKInt, aRxBuffer_l, &readSize); if (ret == kErrorOk) { pEvent = (tEvent*)aRxBuffer_l; pEvent->eventArgSize = (readSize - sizeof(tEvent)); if (pEvent->eventArgSize > 0) pEvent->eventArg.pEventArg = &aRxBuffer_l[sizeof(tEvent)]; else pEvent->eventArg.pEventArg = NULL; if (!eventSinkIsKernel(pEvent->eventSink)) { // Events from the kernel-internal queue to the user layer // have to be posted to the kernel-to-user queue finally. ret = eventkcal_postEventCircbuf(kEventQueueK2U, pEvent); if (ret != kErrorOk) { tEventQueue eventQueue = kEventQueueK2U; // Forward error to API eventk_postError(kEventSourceEventk, ret, sizeof(eventQueue), &eventQueue); } } else { // Events from the kernel-internal queue to kernel event sinks // can be processed directly. ret = eventk_process(pEvent); } } } else { if (eventkcal_getEventCountCircbuf(kEventQueueU2K) > 0) { ret = eventkcal_processEventCircbuf(kEventQueueU2K); } } }
//------------------------------------------------------------------------------ tOplkError eventucal_postKernelEvent(tEvent* pEvent_p) { tOplkError ret; /*TRACE("U2K type:%s(%d) sink:%s(%d) size:%d!\n", debugstr_getEventTypeStr(pEvent_p->eventType), pEvent_p->eventType, debugstr_getEventSinkStr(pEvent_p->eventSink), pEvent_p->eventSink, pEvent_p->eventArgSize);*/ target_enableGlobalInterrupt(FALSE); ret = eventk_process(pEvent_p); target_enableGlobalInterrupt(TRUE); return ret; }
//------------------------------------------------------------------------------ tOplkError eventkcal_postKernelEvent(tEvent* pEvent_p) { tOplkError ret = kErrorOk; if (target_getInterruptContextFlag() && checkForwardEventToKint(pEvent_p)) { // CPU is in interrupt context and forward to kernel-internal queue ret = eventkcal_postEventCircbuf(kEventQueueKInt, pEvent_p); } else { // CPU is not in interrupt context and kernel-internal queue post is not // needed -> direct processing! ret = eventk_process(pEvent_p); } return ret; }
//------------------------------------------------------------------------------ void test_eventk_process(void) { tEvent event; event.eventSink = kEventSinkDllk; CU_ASSERT_EQUAL(eventk_process(&event), kErrorOk); event.eventSink = kEventSinkDllkCal; CU_ASSERT_EQUAL(eventk_process(&event), kErrorOk); event.eventSink = kEventSinkNmtk; CU_ASSERT_EQUAL(eventk_process(&event), kErrorOk); event.eventSink = kEventSinkErrk; CU_ASSERT_EQUAL(eventk_process(&event), kErrorOk); event.eventSink = kEventSinkPdokCal; CU_ASSERT_EQUAL(eventk_process(&event), kErrorOk); event.eventSink = kEventSinkPdok; CU_ASSERT_EQUAL(eventk_process(&event), kErrorEventUnknownSink); }