Example #1
0
/*
 *  ======== MessageQ_Instance_finalize ========
 */
Void ti_sdo_ipc_MessageQ_Instance_finalize(
        ti_sdo_ipc_MessageQ_Object* obj, Int status)
{
    UInt key;
    MessageQ_QueueIndex index = (MessageQ_QueueIndex)(obj->queue);
    List_Handle listHandle;

    if (obj->syncSemHandle != NULL) {
        SyncSem_delete(&obj->syncSemHandle);
    }

    listHandle = ti_sdo_ipc_MessageQ_Instance_State_normalList(obj);
    
    /* Destruct the list */
    List_destruct(List_struct(listHandle));
    
    listHandle = ti_sdo_ipc_MessageQ_Instance_State_highList(obj);
    
    /* Destruct the list */
    List_destruct(List_struct(listHandle));
    
    /* lock */
    key = IGateProvider_enter(MessageQ_module->gate);    
        
    /* Null out entry in the array. */
    MessageQ_module->queues[index] = NULL;
        
    /* unlock scheduler */
    IGateProvider_leave(MessageQ_module->gate, key);    
    
    if (obj->nsKey != NULL) {
        NameServer_removeEntry((NameServer_Handle)MessageQ_module->nameServer, 
            obj->nsKey);
    }
}
Example #2
0
/*
 *  ======== ti_sdo_ipc_Notify_Instance_finalize ========
 */
Void ti_sdo_ipc_Notify_Instance_finalize(ti_sdo_ipc_Notify_Object *obj,
        Int status)
{
    UInt    i;
    UInt16  clusterId = ti_sdo_utils_MultiProc_getClusterId(obj->remoteProcId);

    switch (status) {
    case 0:
        /* Unregister the notify instance from the Notify module */
        Notify_module->notifyHandles[clusterId][obj->lineId] = NULL;

        /* Destruct the event lists */
        for (i = 0; i < ti_sdo_ipc_Notify_numEvents; i++) {
            List_destruct(List_struct(List_Object_get(obj->eventList, i)));
        }

        /* Free memory used for the List.Objects */
        Memory_free(ti_sdo_ipc_Notify_Object_heap(), obj->eventList,
                    sizeof(List_Struct) * ti_sdo_ipc_Notify_numEvents);

    /* OK to fall through */

    case 1:
        /* Free memory used for callbacks array */
        Memory_free(ti_sdo_ipc_Notify_Object_heap(), obj->callbacks,
                    sizeof(ti_sdo_ipc_Notify_EventCallback) *
                    ti_sdo_ipc_Notify_numEvents);
    }
}
Example #3
0
/*
 *  ======== NullConverter_Instance_init ========
 */
Void NullConverter_Instance_init(NullConverter_Object *obj, 
    const NullConverter_Params *params)
{
    List_Handle packetList;

    packetList = NullConverter_Instance_State_packetList(obj);

    List_construct(List_struct(packetList), NULL);
}
Example #4
0
/*
 *  ======== DriverAdapter_Instance_init ========
 */
Void DriverAdapter_Instance_init(DriverAdapter_Object *obj,
    const DriverAdapter_Params *params)
{
    List_Handle fromDriver;

    fromDriver = DriverAdapter_Instance_State_fromDriver(obj);

    List_construct(List_struct(fromDriver), NULL);
     
    obj->driverHandle = params->driverHandle;
}
Example #5
0
/*
 *  ======== ti_sdo_ipc_Notify_Instance_init ========
 */
Int ti_sdo_ipc_Notify_Instance_init(
    ti_sdo_ipc_Notify_Object *obj,
    INotifyDriver_Handle driverHandle,
    UInt16 remoteProcId, UInt16 lineId,
    const ti_sdo_ipc_Notify_Params *params,
    Error_Block *eb)
{
    UInt        i;
    UInt16      clusterId = ti_sdo_utils_MultiProc_getClusterId(remoteProcId);
    List_Handle eventList;

    Assert_isTrue(remoteProcId < ti_sdo_utils_MultiProc_numProcessors &&
                  lineId < ti_sdo_ipc_Notify_numLines, ti_sdo_ipc_Notify_A_invArgument);
    Assert_isTrue(Notify_module->notifyHandles[clusterId][lineId] == NULL,
                  ti_sdo_ipc_Notify_A_alreadyRegistered);

    obj->remoteProcId = remoteProcId;
    obj->lineId = lineId;
    obj->nesting = 0;

    /* Allocate and initialize (to 0 with calloc()) the callbacks array. */
    obj->callbacks = Memory_calloc(ti_sdo_ipc_Notify_Object_heap(),
                                   (sizeof(ti_sdo_ipc_Notify_EventCallback) *
                                    ti_sdo_ipc_Notify_numEvents), 0, eb);
    if (obj->callbacks == NULL) {
        return (2);
    }

    obj->eventList = Memory_alloc(ti_sdo_ipc_Notify_Object_heap(),
                                  sizeof(List_Struct) * ti_sdo_ipc_Notify_numEvents, 0, eb);
    if (obj->eventList == NULL) {
        return (1);
    }

    for (i = 0; i < ti_sdo_ipc_Notify_numEvents; i++) {
        eventList = List_Object_get(obj->eventList, i);

        /* Pass in NULL for eb since construct should never fail */
        List_construct(List_struct(eventList), NULL);
    }

    /* Used solely for remote driver (NULL if remoteProcId == self) */
    obj->driverHandle = driverHandle;

    if (driverHandle != NULL) {
        /* Send this handle to the INotifyDriver */
        INotifyDriver_setNotifyHandle(driverHandle, obj);
    }

    Notify_module->notifyHandles[clusterId][lineId] = obj;

    return (0);
}
Example #6
0
/*
 *  ======== Stream_Instance_finalize ========
 */
Void Stream_Instance_finalize(Stream_Object *obj, Int status)
{    
    List_Handle freeList;
    SyncSemThread_Handle tempSyncHdl;

    Assert_isTrue((obj->issued == 0), Stream_A_pendingReclaims);

    /* fall through in switch below is intentional */
    switch (status) {
        /* Stream_delete() */
        case 0:        
            IConverter_close(obj->convHandle, NULL);
                
        /* IConverter_open failed */
        case 5:
           if (obj->drvAdapHdl == TRUE) {
               IConverter_delete(&obj->convHandle);
           }
               
        /* DriverAdapter create failed */
        case 4:
        
        /* name not found */
        case 3:
            Memory_free(obj->packetHeap, obj->packets, 
            sizeof(DriverTypes_Packet) * obj->maxIssues);
        
        /* alloc packets failed */
        case 2:
            
            freeList = Stream_Instance_State_freeList(obj);
            List_destruct(List_struct(freeList));
            
            if (obj->userSync == FALSE) {
                tempSyncHdl = SyncSemThread_Handle_downCast(obj->complete);
                SyncSemThread_delete(&tempSyncHdl);
            }

        /* Sync_create failed */
        case 1:

        default:
            break;
    };

}
Example #7
0
/*
 *  ======== Stream_Instance_init ========
 */
Int Stream_Instance_init(Stream_Object *obj, String name, UInt mode, 
    const Stream_Params *params, Error_Block *eb)
{
    List_Handle     freeList;
    
    obj->name = name;
    obj->chanParams = params->chanParams;
    obj->maxIssues = params->maxIssues;
    obj->ready = 0;
    obj->issued = 0;
    obj->mode = mode;
    obj->packetHeap = params->packetHeap;

    if (params->sync == NULL) {       
        obj->complete = 
            SyncSemThread_Handle_upCast(SyncSemThread_create(NULL, eb));
        obj->userSync = FALSE;
        if (obj->complete == NULL) {
            return (1);
        }
    }
    else {
        obj->complete = params->sync;
        obj->userSync = TRUE;
    }

    freeList = Stream_Instance_State_freeList(obj);
    List_construct(List_struct(freeList), NULL);
    
    /* allocate packets */
    obj->packets = Memory_alloc(obj->packetHeap, 
        sizeof(DriverTypes_Packet) * (obj->maxIssues), 0, eb);

    if (obj->packets == NULL) {
        return (2);
    }
   
    return (Stream_postInit(obj, eb));
}
Example #8
0
/*
 *  ======== MessageQ_Instance_init ========
 */
Int ti_sdo_ipc_MessageQ_Instance_init(ti_sdo_ipc_MessageQ_Object *obj, String name,
        const ti_sdo_ipc_MessageQ_Params *params, Error_Block *eb)
{
    Int              i;
    UInt16           start;
    UInt16           count;
    UInt             key;
    Bool             found = FALSE;    
    List_Handle      listHandle;
    SyncSem_Handle   syncSemHandle;
    MessageQ_QueueIndex queueIndex;    

    /* lock */
    key = IGateProvider_enter(MessageQ_module->gate);    

    start = ti_sdo_ipc_MessageQ_Object_count(); 
    count = MessageQ_module->numQueues;
         
    /* Search the dynamic array for any holes */
    for (i = start; (i < count) && (found == FALSE); i++) {
        if (MessageQ_module->queues[i] == NULL) {
            MessageQ_module->queues[i] = obj;            
            queueIndex = i;
            found = TRUE;            
        }
    } 
   
    /*
     *  If no free slot was found:
     *     - if no growth allowed, raise and error
     *     - if growth is allowed, grow the array
     */
    if (found == FALSE) {
        if (ti_sdo_ipc_MessageQ_maxRuntimeEntries != NameServer_ALLOWGROWTH) {
            /* unlock scheduler */
            IGateProvider_leave(MessageQ_module->gate, key);    
            
            Error_raise(eb, ti_sdo_ipc_MessageQ_E_maxReached, 
                ti_sdo_ipc_MessageQ_maxRuntimeEntries, 0);
            return (1);
        }
        else {
            queueIndex = MessageQ_grow(obj, eb);
            if (queueIndex == MessageQ_INVALIDMESSAGEQ) {
                /* unlock scheduler */
                IGateProvider_leave(MessageQ_module->gate, key);    
                return (2);
            }
        }
    }

    /* create default sync if not specified */
    if (params->synchronizer == NULL) {
        /* Create a SyncSem as the synchronizer */
        syncSemHandle = SyncSem_create(NULL, eb);

        if (syncSemHandle == NULL) {
            /* unlock scheduler */
            IGateProvider_leave(MessageQ_module->gate, key);    
            return (3);
        }

        /* store handle for use in finalize ...  */
        obj->syncSemHandle = syncSemHandle;

        obj->synchronizer = SyncSem_Handle_upCast(syncSemHandle);
    }
    else {
        obj->syncSemHandle = NULL;

        obj->synchronizer = params->synchronizer;
    }
    
    /* unlock scheduler */
    IGateProvider_leave(MessageQ_module->gate, key);    
         
    /* Fill in the message queue object */
    listHandle = ti_sdo_ipc_MessageQ_Instance_State_normalList(obj);
    List_construct(List_struct(listHandle), NULL);                 

    listHandle = ti_sdo_ipc_MessageQ_Instance_State_highList(obj);
    List_construct(List_struct(listHandle), NULL);                 

    obj->queue = ((MessageQ_QueueId)(MultiProc_self()) << 16) | queueIndex;
    
    obj->unblocked = FALSE;
    
    /* Add into NameServer */
    if (name != NULL) {
        obj->nsKey = NameServer_addUInt32(
                (NameServer_Handle)MessageQ_module->nameServer, name, 
                obj->queue);

        if (obj->nsKey == NULL) {
            Error_raise(eb, ti_sdo_ipc_MessageQ_E_nameFailed, name, 0);
            return (4);
        }
    }    
    
    return (0);
}