//------------------------------------------------------------------------------
tOplkError eventkcal_postUserEvent(tEvent* pEvent_p)
{
    tOplkError      ret = kErrorOk;

    ret = eventkcal_postEventCircbuf(kEventQueueK2U, pEvent_p);

    return ret;
}
//------------------------------------------------------------------------------
tOplkError eventkcal_postKernelEvent(tEvent* pEvent_p)
{
    tOplkError      ret = kErrorOk;

    ret = eventkcal_postEventCircbuf(kEventQueueKInt, pEvent_p);

    return ret;
}
Пример #3
0
//------------------------------------------------------------------------------
tOplkError eventkcal_postUserEvent(tEvent* pEvent_p)
{
    tOplkError    ret = kErrorOk;

    if (target_getInterruptContextFlag())
    {
        // CPU is in interrupt context
        // -> Post to kernel-internal queue first
        ret = eventkcal_postEventCircbuf(kEventQueueKInt, pEvent_p);
    }
    else
    {
        // CPU is outside of any interrupt context (background loop)
        // -> Post to kernel-to-user queue
        ret = eventkcal_postEventCircbuf(kEventQueueK2U, pEvent_p);
    }

    return ret;
}
//------------------------------------------------------------------------------
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 eventkcal_postKernelEvent(const tEvent* pEvent_p)
{
    tOplkError  ret;

    // Check parameter validity
    ASSERT(pEvent_p != NULL);

    if (instance_l.fInitialized)
        ret = eventkcal_postEventCircbuf(kEventQueueKInt, pEvent_p);
    else
        ret = kErrorIllegalInstance;

    return ret;
}
Пример #6
0
//------------------------------------------------------------------------------
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 eventkcal_postEventFromUser(const void* pEvent_p)
{
    tEvent  event;

    // Check parameter validity
    ASSERT(pEvent_p != NULL);

    if (!instance_l.fInitialized)
        return;

    // Copy the event to the local buffer
    OPLK_MEMCPY(&event, pEvent_p, sizeof(tEvent));

    // Assign the event argument which is present after the event memory, if argument valid
    if (event.eventArgSize != 0)
        event.eventArg.pEventArg = (void*)((UINT8*)pEvent_p + sizeof(tEvent));

    switch (event.eventSink)
    {
        case kEventSinkSync:
        case kEventSinkNmtk:
        case kEventSinkDllk:
        case kEventSinkDllkCal:
        case kEventSinkPdok:
        case kEventSinkPdokCal:
        case kEventSinkErrk:
        case kEventSinkTimesynck:
            DEBUG_LVL_EVENTK_TRACE("U2K  type:%s(%d) sink:%s(%d) size:%d!\n",
                                   debugstr_getEventTypeStr(event.eventType),
                                   event.eventType,
                                   debugstr_getEventSinkStr(event.eventSink),
                                   event.eventSink,
                                   event.eventArgSize);
            eventkcal_postEventCircbuf(kEventQueueU2K, &event);
            break;

        case kEventSinkNmtMnu:
        case kEventSinkNmtu:
        case kEventSinkSdoAsySeq:
        case kEventSinkApi:
        case kEventSinkDlluCal:
        case kEventSinkErru:
            DEBUG_LVL_EVENTK_TRACE("UINT type:%s(%d) sink:%s(%d) size:%d!\n",
                                   debugstr_getEventTypeStr(event.eventType),
                                   event.eventType,
                                   debugstr_getEventSinkStr(event.eventSink),
                                   event.eventSink,
                                   event.eventArgSize);
            eventkcal_postEventCircbuf(kEventQueueUInt, &event);
            break;

        default:
            DEBUG_LVL_EVENTK_TRACE("UNKNOWN Event: Type:%s(%d) sink:%s(%d) size:%d!\n",
                                   debugstr_getEventTypeStr(event.eventType),
                                   event.eventType,
                                   debugstr_getEventSinkStr(event.eventSink),
                                   event.eventSink,
                                   event.eventArgSize);
            break;
    }
}