Beispiel #1
0
/*******************************************************************************
Name         : STDVMi_EventTerm()

Description  : Terminates STDVM event notification task

Parameters   : BOOL     ForceTerminate

Return Value :
*******************************************************************************/
ST_ErrorCode_t STDVMi_EventTerm(ST_DeviceName_t     DVMDeviceName,
                                ST_DeviceName_t     PRMDeviceName,
                                ST_DeviceName_t     MP3PBDeviceName,
                                BOOL                ForceTerminate)
{
    ST_ErrorCode_t  ErrorCode;
    STDVMi_Event_t *Event_p;


    ErrorCode = STDVMi_UnRegisterAndUnSubscribeEvents(DVMDeviceName, PRMDeviceName, MP3PBDeviceName);
    if(ErrorCode != ST_NO_ERROR)
    {
        STTBX_Report((STTBX_REPORT_LEVEL_ERROR, "STDVMi_UnRegisterAndUnSubscribeEvents()=%08X\n", ErrorCode));
        return ErrorCode;
    }


    Event_p = (STDVMi_Event_t *)message_claim(STDVMi_EventTaskMQ_p);

    STDVMi_EventTaskState = TASK_STOPPED;

    message_send(STDVMi_EventTaskMQ_p, Event_p);

    task_wait(&STDVMi_EventTask_p, 1, TIMEOUT_INFINITY);
    if(task_delete(STDVMi_EventTask_p) != 0 )
    {
        STTBX_Report((STTBX_REPORT_LEVEL_ERROR, "task_delete failed\n"));
        return ST_ERROR_BAD_PARAMETER;
    }

    message_delete_queue(STDVMi_EventTaskMQ_p);

    return ST_NO_ERROR;
}
Beispiel #2
0
/*******************************************************************************
Name         : STDVMi_ServiceTaskTerm()

Description  : Terminates STDVM event notification task

Parameters   : BOOL     ForceTerminate

Return Value :
*******************************************************************************/
ST_ErrorCode_t STDVMi_ServiceTaskTerm(void)
{
    STDVMi_Handle_t   **Msg2Send;


    Msg2Send = (STDVMi_Handle_t **)message_claim(STDVMi_ServiceTaskMQ_p);

    STDVMi_ServiceTaskState = TASK_STOPPED;

    message_send(STDVMi_ServiceTaskMQ_p, Msg2Send);

    task_wait(&STDVMi_ServiceTask_p, 1, TIMEOUT_INFINITY);
    if(task_delete(STDVMi_ServiceTask_p) != 0 )
    {
        STTBX_Report((STTBX_REPORT_LEVEL_ERROR, "task_delete failed\n"));
        return ST_ERROR_BAD_PARAMETER;
    }

    message_delete_queue(STDVMi_ServiceTaskMQ_p);

    return ST_NO_ERROR;
}
/*
 * message_create_queue_timeout
 */
message_queue_t * message_create_queue(size_t ElementSize, unsigned int NoElements)
{
    MessageQueueList_t  * Current_p;
    MessageQueueList_t  * New_p;
    message_queue_t     * MesQ_p = NULL;


    if ((New_p = wrapper_allocate(sizeof(MessageQueueList_t))) != NULL)
    {
        if ((New_p->MessageQueue_p = wrapper_allocate(sizeof(message_queue_t))) != NULL)
        {
            if ((New_p->Memory_p = wrapper_allocate(MESSAGE_MEMSIZE_QUEUE(ElementSize, NoElements))) == NULL)
            {
                /* Memory allocation pb, deallocate list element */
                wrapper_deallocate(New_p->MessageQueue_p);
                wrapper_deallocate(New_p);
                New_p = NULL;
            }
        }
        else
        {
            /* Memory allocation pb, deallocate list element */
            wrapper_deallocate(New_p);
            New_p = NULL;
        }
    }
	printf("\n\nmessage_create_queue 111\n");
    if (New_p != NULL)
    {
        message_init_queue( New_p->MessageQueue_p, New_p->Memory_p,
                                    ElementSize, NoElements);
		printf("\n\nmessage_create_queue 222\n");
        if (MessageArray[ New_p->MessageQueue_p->Index ].Used_p != NULL)
        {
            /* At this stage, we know that all allocations have been correctly done */
            New_p->Next_p = NULL;

            locker_lock(message_mutex);
            Current_p = MessageQueueList_p;
            if (Current_p != NULL)
            {
                while (Current_p->Next_p != NULL)
                    Current_p = Current_p->Next_p;

                Current_p->Next_p = New_p;
            }
            else
            {
                MessageQueueList_p = New_p;
            }
            locker_unlock(message_mutex);

            MesQ_p = New_p->MessageQueue_p;

	        PrintMessageQ_Debug(("COMPAT: message_create_queue_timeout done (0x%x)!!!\n", MesQ_p));
        }
        else
        {
            message_delete_queue(New_p->MessageQueue_p);

            wrapper_deallocate(New_p->MessageQueue_p);
            wrapper_deallocate(New_p->Memory_p);
            wrapper_deallocate(New_p);

            printf("%s(): message queue init problem !!!\n", __FUNCTION__);
        }
    }
    else
    {
        printf("%s(): no memory !!!\n", __FUNCTION__);
    }

    /* NULL if Message Queue creation problem, message queue pointer otherwise */
    return(MesQ_p);
}