Пример #1
0
/*!
 *  @brief      Function to destroy the DM8168DUCATIPWR module.
 *
 *              Once this function is called, other DM8168DUCATIPWR module APIs, except
 *              for the DM8168DUCATIPWR_getConfig API cannot be called anymore.
 *
 *  @sa         DM8168DUCATIPWR_setup
 *              GateMutex_delete
 */
Int
DM8168DUCATIPWR_destroy (Void)
{
    Int    status = PWRMGR_SUCCESS;
    UInt16 i;
    IArg key;

    GT_0trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_destroy");

    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        status = DM8168DUCATIPWR_E_INVALIDSTATE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_destroy",
                             status,
                             "Module was not initialized!");
    }
    else {
#endif /* !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        key = Gate_enterSystem();
        DM8168DUCATIPWR_state.refCount--;
        Gate_leaveSystem(key);

        if (DM8168DUCATIPWR_state.refCount == 0) {
            /* Temporarily increment refCount here. */
            key = Gate_enterSystem();
            DM8168DUCATIPWR_state.refCount = 1;
            Gate_leaveSystem(key);

            /* Check if any DM8168DUCATIPWR instances have not been deleted so far. If not,
             * delete them.
             */
            for (i = 0 ; i < MultiProc_MAXPROCESSORS ; i++) {
                GT_assert (curTrace, (DM8168DUCATIPWR_state.pwrHandles [i] == NULL));
                if (DM8168DUCATIPWR_state.pwrHandles [i] != NULL) {
                    DM8168DUCATIPWR_delete (&(DM8168DUCATIPWR_state.pwrHandles [i]));
                }
            }
            /* restore refCount here. */
            key = Gate_enterSystem();
            DM8168DUCATIPWR_state.refCount = 0;
            Gate_leaveSystem(key);

            if (DM8168DUCATIPWR_state.gateHandle != NULL) {
                GateMutex_delete ((GateMutex_Handle *)
                                        &(DM8168DUCATIPWR_state.gateHandle));
            }
            DM8168DUCATIPWR_state.isSetup = FALSE;
        }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_destroy", status);

    /*! @retval PWRMGR_SUCCESS Operation successful */
    return (status);
}
Пример #2
0
/*
 *  ======== HeapStd_alloc ========
 *  This heap uses the 'C' rts malloc call. 
 *
 *  Only support alignment requests that will be honored by malloc.
 */
Ptr HeapStd_alloc(HeapStd_Object *obj, SizeT size, SizeT align,
                  Error_Block *eb)
{
    Ptr buf;
    IArg key;

    /* Make sure the specified alignment is not too large */
    Assert_isTrue((align <= Memory_getMaxDefaultTypeAlign()),
        HeapStd_A_invalidAlignment);

    /* Determine if there is enough memory */
    key = Gate_enterSystem();
    if ((SizeT)(obj->remainSize) < size) {
        Gate_leaveSystem(key);
        return (NULL);
    }
    obj->remainSize -= size;
    Gate_leaveSystem(key);
    
    /* malloc the buffer! */
    if ((buf = malloc(size)) == NULL) {
        /* Undo the size change in case of a failure */
        key = Gate_enterSystem();
        obj->remainSize += size;
        Gate_leaveSystem(key);
        return (NULL);
    }

    return (buf);
}
Пример #3
0
/*
 *  ======== HeapMin_alloc ========
 *  This is a simple growth-only heap. This function returns the current
 *  location of the top of unused buffer.
 */
Ptr HeapMin_alloc(HeapMin_Object *obj, SizeT size, SizeT align,
    Error_Block *eb)
{
    Ptr block;
    IArg key;
    SizeT offset = 0;    

    key = Gate_enterSystem();
    /*
     * If the current buffer is not on the requested alignment, 
     * determine the offset needed.
     */
    if ((UArg)(obj->buf) & (align - 1)) {
        offset = align - ((UArg)(obj->buf) & (align - 1));
    }
    
    /* Make sure there is enough memory.  Must factor in the offset. */
    if (((SizeT)obj->remainSize) < size + offset) {
        Gate_leaveSystem(key);
        return (NULL);
    }
    
    /* Determine the addr based off the current buf and the needed offset. */
    block = obj->buf + offset;
    
    /* Update the two instance fields accordingly */
    obj->remainSize -= (size + offset);
    obj->buf        += (size + offset);    
    Gate_leaveSystem(key);
    
    return (block);
}
Пример #4
0
/*
 *  ======== System_abort ========
 */
Void System_abort(String str)
{
    Gate_enterSystem();

    System_SupportProxy_abort(str);

    abort();
}
Пример #5
0
/*
 *  ======== System_rtsExit ========
 */
Void System_rtsExit()
{
    Int i;

    Gate_enterSystem();

    for (i = module->numAtexitHandlers; i > 0; i--) {
        (module->atexitHandlers[i - 1])(module->exitStatus);
    }
    System_SupportProxy_exit(module->exitStatus);
}
Пример #6
0
/*
 * ====== injectIntoTrace ======
 * Inject syncPoint info into GEM Trace
 * This method logs a sync point event and injects
 * correlation info into the trace stream (if available)
 * to enable correlation between software events and hardware trace.
 *
 */
Void GemTraceSync_injectIntoTrace(UInt32 serialNumber, 
        IUIATraceSyncProvider_ContextType ctxType){
    volatile UInt32 syncWord;
    IArg key = Gate_enterSystem();

    /* build word to inject into overlay register without using the OVERLAY 
     * register as scratchpad */
    syncWord= getSyncWord(serialNumber,ctxType);

    OVERLAY = syncWord;
    Gate_leaveSystem(key);
}
Пример #7
0
/*
 *  ======== SysMin_putch ========
 */
Void SysMin_putch(Char ch)
{
    UInt coreId;
    UInt outidx;
    UInt i;
    Char *outbuf;
    IArg key;
    
    if (SysMin_bufSize != 0) {

        /* 
         * only disable local interrupts to place chars in 
         * local line buffer 
         */

        key = (IArg)Core_hwiDisable();

        coreId = Core_getId();
        outidx = module->lineBuffers[coreId].outidx;
        outbuf = module->lineBuffers[coreId].outbuf;
        outbuf[outidx++] = ch;
        SysMin_module->lineBuffers[coreId].outidx = outidx;
    
        /* At EOL, copy core's line buffer to shared outbuf */
        if ((ch == '\n') || (outidx >= 256)) {

            /* 
             * disable interrupts globally to transfer lines 
             * to the shared output buffer
             */

            Gate_enterSystem();

            for (i = 0; i < outidx; i++) {
                module->outbuf[module->outidx++] = outbuf[i];
                if (module->outidx == SysMin_bufSize) {
                    module->outidx = 0;
                    module->wrapped = TRUE;
                }
            }

            SysMin_module->lineBuffers[coreId].outidx = 0;

            Gate_leaveSystem(key);
        }
        else {
            /* restore local interrupts */
            Core_hwiRestore((UInt)key);
        }
    }
}
Пример #8
0
/*
 * ====== injectCtxDataIntoTrace ======
 * Inject syncPoint info into GEM Trace
 * This method logs a sync point event and injects
 * correlation info into the trace stream (if available)
 * to enable correlation between software events and hardware trace.
 *
 */
Void GemTraceSync_injectCtxDataIntoTrace(UInt32 serialNumber, 
        IUIATraceSyncProvider_ContextType ctxType, UInt32 ctxData){
    volatile UInt32 syncWord1;
    volatile UInt32 syncWord2;
    IArg key;

    switch(ctxType){
    /* Sync Point event sequence number */
    case IUIATraceSyncProvider_ContextType_SyncPoint: 
    /* Context Change event sequence number */
    case IUIATraceSyncProvider_ContextType_ContextChange:
    /* Snapshot event Snapshot ID  */
    case IUIATraceSyncProvider_ContextType_Snapshot: 
        key = Gate_enterSystem();

        /* build word to inject into overlay register without using the 
         * OVERLAY register as scratchpad */
        syncWord1= getSyncWord(ctxType,serialNumber);

        OVERLAY = syncWord1;

        Gate_leaveSystem(key);
        break;
    default:
        key = Gate_enterSystem();

        /* build the two words to inject into overlay register without using 
         * the OVERLAY register as scratchpad */
        syncWord1= getSyncWord1(ctxType,ctxData,serialNumber);
        syncWord2= getSyncWord2(ctxType,ctxData,serialNumber);

        OVERLAY = syncWord1;
        OVERLAY = syncWord2;

        Gate_leaveSystem(key);

    }
}
Пример #9
0
/*
 *  ======== HeapStd_free ========
 *  Free the memory back and adjust the remaining free accordingly
 */
Void HeapStd_free(HeapStd_Object *obj, Ptr block, SizeT size)
{
    IArg key;
    
    free(block);
    
    key = Gate_enterSystem();
    
    /* Adjust the remaining size */
    obj->remainSize += size;    
    
    /* Make sure something fishy is not going on */
    Assert_isTrue((obj->remainSize <= obj->startSize),
        HeapStd_A_invalidTotalFreeSize);
    
    Gate_leaveSystem(key);    
}
Пример #10
0
/*
 *  ======== SysMin_putch ========
 */
Void SysMin_putch(Char ch)
{
    IArg key;
    
    if (SysMin_bufSize != 0) {

        key = Gate_enterSystem();

        module->outbuf[module->outidx++] = ch;
        if (module->outidx == SysMin_bufSize) {
            module->outidx = 0;
            module->wrapped = TRUE;
        }

        Gate_leaveSystem(key);
    }    
}
/*
 * ======== getSnapshotId ========
 * returns a unique ID to use to group a set of snapshot event logs together
 * and, if injectIntoTraceFxn is not null, injects it into the trace stream
 * in order to support trace correlation with the snapshot data.
 */
UInt32 LogSnapshot_getSnapshotId() {
    IArg key;
    UInt16 newSnapshotId;

    key = Gate_enterSystem();

    newSnapshotId = (UInt16)((UInt32)LogSnapshot_SNAPSHOTID_MASK & ++ti_uia_runtime_LogSnapshot_gLastUsedSnapshotId);
    if (newSnapshotId == 0) {
        ti_uia_runtime_LogSnapshot_gLastUsedSnapshotId = 1;
        newSnapshotId = 1;
    }
    if (LogSnapshot_injectIntoTraceFxn != NULL){
        LogSnapshot_injectIntoTraceFxn(newSnapshotId,
                IUIATraceSyncProvider_ContextType_Snapshot);
    }
    Gate_leaveSystem(key);
    return((UInt32)newSnapshotId);
}
/*
 *  ======== gpioButtonFxn1 ========
 *  Callback function for the right button
 *
 *  It posts a message with image index 1 to display.
 */
Void gpioButtonFxn1(Void)
{
    UInt key;
    DrawMessage drawMsg;

    drawMsg.drawCommand = IMAGE;
    drawMsg.drawImageIndex = 1;

    key = Gate_enterSystem();
    /* Clear the last command */
    lastCommand[0] = 0x0;
    Gate_leaveSystem(key);

    /* Do not wait if there is no room for the new mail */
    Mailbox_post(mailboxHandle, &drawMsg, BIOS_NO_WAIT);

    GPIO_clearInt(EK_TM4C123GXL_SW2);//??
}
Пример #13
0
/*
 *  ======== System_atexit ========
 */
Bool System_atexit(System_AtexitHandler handler)
{
    IArg key;
    Bool status = TRUE;
    
    key = Gate_enterSystem();

    if (module->numAtexitHandlers < System_maxAtexitHandlers) {
        module->atexitHandlers[module->numAtexitHandlers] = handler;
        module->numAtexitHandlers++;
    }
    else {
        status = FALSE;
    }

    Gate_leaveSystem(key);
    
    return (status);
}
Пример #14
0
/*
 *  ======== QueueDescriptor_removeFromList ========
 */
Void QueueDescriptor_removeFromList(QueueDescriptor_Header *pHdrToRemove)
{
    IArg key;
    QueueDescriptor_Header *pList;

    /* Enter the gate and traverse the list, looking for a match */
    key = Gate_enterSystem();
    
    /*
     *  If the list is empty, do nothing.
     *  If the header to remove is the first one, update the global accordingly
     *  else traverse the list looking for a match. Once the match is found,
     *      remove the header.
     *  If the header is never found, do nothing.
     */    
    if (ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor != NULL) {
        if (ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor == 
            pHdrToRemove) {
            ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor = 
                pHdrToRemove->next;
            ti_uia_runtime_QueueDescriptor_gUpdateCount++;
        }
        else {
            pList = ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor;
            while (pList->next != NULL)  {
        
                if (pList->next == pHdrToRemove) {
                    /* Found a match, remove the header */
                    pList->next = pHdrToRemove->next;            
                    ti_uia_runtime_QueueDescriptor_gUpdateCount++;
                    break;
                }
        
               pList = pList->next;
           }
        }
    }
    Gate_leaveSystem(key);
    
    /* Make sure the next pointer is NULL if it is re-used */
    pHdrToRemove->next = NULL;
}
Пример #15
0
/*
 *  ======== SysMin_flush ========
 *  Called during SysMin_exit, System_exit or System_flush.
 */
Void SysMin_flush()
{
    IArg key;
    
    key = Gate_enterSystem();
    
    /*
     *  If a wrap occured, we need to flush the "end" of the internal buffer
     *  first to maintain fifo character output order.
     */    
    if (module->wrapped == TRUE) {
        SysMin_outputFunc(module->outbuf + module->outidx,
                          SysMin_bufSize - module->outidx);
    }
    
    SysMin_outputFunc(module->outbuf, module->outidx);
    module->outidx = 0;
    module->wrapped = FALSE;
    
    Gate_leaveSystem(key);
}
Пример #16
0
/*
 *  ======== QueueDescriptor_addToList ========
 */
Void QueueDescriptor_addToList(QueueDescriptor_Header *pHdrToAdd)
{
    IArg key;
    QueueDescriptor_Header* pList;        
    
    /* Enter the gate and find the end. */
    key = Gate_enterSystem();

    /* 
     *  If the global is NULL, set it to point to this header 
     *  If it is not NULL, traverse the list and add to the end. This
     *  should not happen often and the list should not be long, so the
     *  using a tail is not needed.
     */
    if (ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor == NULL) {
        ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor = pHdrToAdd;
    }
    else {
        pList = ti_uia_runtime_QueueDescriptor_gPtrToFirstDescriptor;
        /* Find the end of the list */
        while (pList->next != NULL) {
            pList = pList->next;
        }

        /* Add onto the end */
        pList->next = pHdrToAdd;
    }        
    
    ti_uia_runtime_QueueDescriptor_gUpdateCount++;

    /* Ensure that dynamically created logger instances have a 
     * unique instance ID to allow them to be handled properly
     * on the host.  Set b15 to 1 to indicate that the ID was auto-generated
     * and that the logger was dynamically created.
     */
    if (pHdrToAdd->instanceId == 0){
        pHdrToAdd->instanceId = 0x8000 | ti_uia_runtime_QueueDescriptor_gUpdateCount;
    }
    Gate_leaveSystem(key);
}
Пример #17
0
/*
 *  ======== SysMin_flush ========
 *  Called during SysMin_exit, System_exit or System_flush.
 */
Void SysMin_flush()
{
/* Using custom circular buffer implementation without resetting write ptr */
#if 0
    IArg key;

    key = Gate_enterSystem();

    /*
     *  If a wrap occured, we need to flush the "end" of the internal buffer
     *  first to maintain fifo character output order.
     */
    if (module->wrapped == TRUE) {
        SysMin_outputFunc(module->outbuf + module->outidx,
                          SysMin_bufSize - module->outidx);
    }

    SysMin_outputFunc(module->outbuf, module->outidx);
    module->outidx = 0;
    module->wrapped = FALSE;

    Gate_leaveSystem(key);
#endif
}
Пример #18
0
/*
 *  ======== grlibTaskFxn ========
 *  Drawing task
 *
 *  It is pending for the message either from console task or from button ISR.
 *  Once the messages received, it draws to the screen based on information
 *  contained in the message.
 */
Void grlibTaskFxn(UArg arg0, UArg arg1)
{
    DrawMessage curMsg;
    const UChar *pucCurImage;
    UInt key;
    UInt fontHeight = GrStringHeightGet(&context);

    while (TRUE) {
        Mailbox_pend(mailboxHandle, &curMsg, BIOS_WAIT_FOREVER);

        fillBox(4);
        /* Clear screen before drawing */
        clearDisplay();

        /* Parse the message and draw */
        switch (curMsg.drawCommand) {
        case IMAGE:
            pucCurImage = image_Gallery[curMsg.drawImageIndex];

            /* Draw image at (0,0) */
            GrImageDraw(&context, pucCurImage, 0, 0);
            break;

        case KeyBoadCOMMAND:
        	switch(curMsg.MoveCommand){
        	case UP:
        		 // copy the data to message
        			           	key = Gate_enterSystem();
        			            up_remove_blank(4);
        			            up(4);



        			            copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048);
        			            Gate_leaveSystem(key);
        		            break;
        	case DOWN:
        		// copy the data to message
        						key = Gate_enterSystem();
        			        	down_remove_blank(4);
        						down(4);



        						copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048);
        						Gate_leaveSystem(key);
        	        		break;
        	case LEFT:
        		// copy the data to message
        						key = Gate_enterSystem();
        						left_remove_blank(4);
        						left(4);


        						copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048);
        						Gate_leaveSystem(key);
        	        		break;
        	case RIGHT:
        		// copy the data to message
        						key = Gate_enterSystem();
        						right_remove_blank(4);
        						right(4);

        						copyFrom2048ArrayToDrawMessage(4,curMsg.draw2048 , Array2048);
        						Gate_leaveSystem(key);
        	        		break;
        	default:
        	            break;
        	}
        	output(4,curMsg.draw2048);

            break;

        case ScreenCOMMAND:
        	// copy the data to message
        	key = Gate_enterSystem();
        	fillBox(4);
        	Gate_leaveSystem(key);
        	output(4,curMsg.draw2048);
        	System_printf("here\n");
//        	printf("data X %d , data Y %d /n",curMsg.touchPosition[0],curMsg.touchPosition[1]);
        	break;

        default:
            break;
        }
    }
}
Пример #19
0
/*!
 *  @brief      Function to power on the slave processor.
 *
 *              Power on the IVA subsystem, hold the DSP and SEQ in reset, and
 *              release IVA2_RST. This is a hostile reset of the IVA. If the IVA
 *              is already powered on, then it must be powered off in order to
 *              terminate all current activity and initiate a power-on-reset
 *              transition to bring the IVA to a know good state.
 *
 *  @param      handle    Handle to the PwrMgr instance
 *
 *  @sa         DM8168DUCATIPWR_off
 */
Int
DM8168DUCATIPWR_on (PwrMgr_Handle handle)
{
    Int                  status       = PWRMGR_SUCCESS ;
    Int32                tmpstatus    = 0;
    PwrMgr_Object *      pwrMgrHandle = (PwrMgr_Object *) handle;
    DM8168DUCATIPWR_Object * object   = NULL;
    IArg                     key;
    (Void)tmpstatus;
    GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_on", handle);

    GT_assert (curTrace, (handle != NULL));
    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_on",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        /* This sets the refCount variable is not initialized, upper 16 bits is
         * written with module Id to ensure correctness of refCount variable.
         */
        key = Gate_enterSystem();
        DM8168DUCATIPWR_state.pwrstateRefCount++;
        if (DM8168DUCATIPWR_state.pwrstateRefCount > 1) {
            status = DM8168DUCATIPWR_S_ALREADYSETUP;
            Gate_leaveSystem(key);
        }
        else {
            Gate_leaveSystem(key);
#if !defined(SYSLINK_BUILD_OPTIMIZE)&& defined(SYSLINK_BUILD_HLOS)
            if (handle == NULL) {
                /*! @retval PWRMGR_E_HANDLE Invalid argument */
                status = PWRMGR_E_HANDLE;
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "DM8168DUCATIPWR_on",
                                     status,
                                     "Invalid handle specified");
            }
            else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS) */
                 object = (DM8168DUCATIPWR_Object *) pwrMgrHandle->object;

                 GT_assert (curTrace, (object != NULL));
                 /* Enable spinlocks, mailbox and timers before powering on ducati */

                 DM8168DUCATIPWR_state.ducatiSpinlockHandle
                            = ClockOps_get(object->clockHandle, "spinbox_ick");
                     /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
                 GT_assert (curTrace,
                               (DM8168DUCATIPWR_state.ducatiSpinlockHandle != NULL));
                 status = ClockOps_enable(object->clockHandle,
                                         DM8168DUCATIPWR_state.ducatiSpinlockHandle);
                 GT_assert (curTrace, (status >= 0));

                 DM8168DUCATIPWR_state.ducatiMailboxHandle
                            = ClockOps_get(object->clockHandle, "mailbox_ick");
                             /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
                 GT_assert (curTrace, (DM8168DUCATIPWR_state.ducatiMailboxHandle != NULL));
                 status = ClockOps_enable(object->clockHandle,
                                          DM8168DUCATIPWR_state.ducatiMailboxHandle);
                 GT_assert (curTrace, (status >= 0));

                 if ((handle->bootMode == ProcMgr_BootMode_Boot) ||
                     (handle->bootMode == ProcMgr_BootMode_NoLoad_Pwr)) {
                     /* power on ducati */
                     DM8168DUCATIPWR_state.ducatiClkHandle
                                 = ClockOps_get(object->clockHandle, "ducati_ick");
                     /* Do not put this check under SYSLINK_BUILD_OPTIMIZE */
                     if (DM8168DUCATIPWR_state.ducatiClkHandle == NULL) {
                             /*! @retval PWRMGR_E_HANDLE Invalid argument */
                             status = PWRMGR_E_HANDLE;
                             GT_setFailureReason (curTrace,
                                                  GT_4CLASS,
                                                  "DM8168DUCATIPWR_on",
                                                  status,
                                              "object->clkHandle retuned NULL clk_get failed for ducati");
                     }
                     else {
                         tmpstatus = ClockOps_enable(object->clockHandle,
                                                  DM8168DUCATIPWR_state.ducatiClkHandle);
                         GT_assert (curTrace, (tmpstatus >= 0));
                         /* Complete the remaining power sequence here*/
                         DM8168DUCATIMMU_enable(pwrMgrHandle);
                     }
                 }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS)
            }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS)*/
        }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)*/
    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_on", status);
    /*! @retval PWRMGR_SUCCESS Operation successful */
    return (status);
}
Пример #20
0
static Int dvsdk_grapx_display_rpc_remote_mode_init ()
{
   RcmClient_Params  rcmClientParams;
   IArg key;
   Bool doInit = FALSE;
   Int status = 0;
   
   key = Gate_enterSystem();
   if (FALSE == g_RemoteStubContext.bRemoteInitDone) {
     doInit = TRUE;
   }
   Gate_leaveSystem(key);
  
   if (TRUE == doInit) {
       GateThread_Params gtParams;
    
    GateThread_Params_init (&gtParams);
       g_RemoteStubContext.hGate = GateThread_Handle_upCast(GateThread_create(&gtParams, NULL));
    key = GateH_enter (g_RemoteStubContext.hGate);
    
    MessageQ_registerHeap(SharedRegion_getHeap(0),Global_GrpxDssMsgHeapId);
    RcmClient_Params_init (&rcmClientParams);
    rcmClientParams.heapId = Global_GrpxDssMsgHeapId;
    do {
      status = RcmClient_create(DVSDK_DSS_GRPX_SERVER_NAME,
                      &rcmClientParams,
                  &g_RemoteStubContext.hRcmClient);
    if (status < 0) {
      Thread_yield(NULL);
    }
       } while (status < 0);
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_INIT_FXN_NAME,
                                          &g_RemoteStubContext.nInitFxnIdx);
    }
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_START_FXN_NAME,
                                          &g_RemoteStubContext.nStartFxnIdx);
    }
       if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_STOP_FXN_NAME,
                                          &g_RemoteStubContext.nStopFxnIdx);
    }
    if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_DEINIT_FXN_NAME,
                                          &g_RemoteStubContext.nDeinitFxnIdx);
    }
    if (0 == status) {
      status = RcmClient_getSymbolIndex (g_RemoteStubContext.hRcmClient,
                                          DVSDK_DSS_GRPX_DISPLAYTOGGLE_FXN_NAME,
                                          &g_RemoteStubContext.nDisplayToggelFxnIdx);
    }
    g_RemoteStubContext.bRemoteInitDone = TRUE;
    GateH_leave(g_RemoteStubContext.hGate, key);
   }
   return status;   
}
Пример #21
0
/*!
 *  @brief      Function to power off the slave processor.
 *
 *              Turn the IVA power domain off. To ensure a clean power-off
 *              transition, the IVA subsystem must first be turned on so that
 *              the DSP can initiate an autonomous power-off transition.
 *
 *  @param      handle    Handle to the PwrMgr instance
 *  @param      force     Indicates whether power-off is to be forced
 *
 *  @sa         DM8168DUCATIPWR_on
 */
Int
DM8168DUCATIPWR_off (PwrMgr_Handle handle, Bool force)
{
    Int                  status       = PWRMGR_SUCCESS ;
    PwrMgr_Object *      pwrMgrHandle = (PwrMgr_Object *) handle;
    DM8168DUCATIPWR_Object * object   = NULL;
    IArg                     key;

    GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_off", handle);

    GT_assert (curTrace, (handle != NULL));

    GT_assert (curTrace, (DM8168DUCATIPWR_state.refCount != 0));

#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    if (DM8168DUCATIPWR_state.refCount == 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_off",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else if (handle == NULL) {
        /*! @retval PWRMGR_E_HANDLE Invalid argument */
        status = PWRMGR_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_off",
                             status,
                             "Invalid handle specified");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS) */
        object = (DM8168DUCATIPWR_Object *) pwrMgrHandle->object;
        key = Gate_enterSystem();
        DM8168DUCATIPWR_state.pwrstateRefCount--;
        Gate_leaveSystem(key);

        if (DM8168DUCATIPWR_state.pwrstateRefCount == 0) {
            if ((handle->bootMode == ProcMgr_BootMode_Boot) ||
                (handle->bootMode == ProcMgr_BootMode_NoLoad_Pwr)) {
                DM8168DUCATIMMU_disable(pwrMgrHandle);
            }

            /* Disable Mailbox clocks */
            if(DM8168DUCATIPWR_state.ducatiMailboxHandle) {
                ClockOps_disable(object->clockHandle,
                                     DM8168DUCATIPWR_state.ducatiMailboxHandle);
                ClockOps_put(object->clockHandle,
                                     DM8168DUCATIPWR_state.ducatiMailboxHandle);
            }
            /* Disable Spinlock clocks */
            if(DM8168DUCATIPWR_state.ducatiSpinlockHandle) {
                ClockOps_disable(object->clockHandle,
                                    DM8168DUCATIPWR_state.ducatiSpinlockHandle);
                ClockOps_put(object->clockHandle,
                                    DM8168DUCATIPWR_state.ducatiSpinlockHandle);
            }

            if ((handle->bootMode == ProcMgr_BootMode_Boot) || 
                (handle->bootMode == ProcMgr_BootMode_NoLoad_Pwr)) {
                if(DM8168DUCATIPWR_state.ducatiClkHandle) {
                    ClockOps_disable(object->clockHandle,
                                    DM8168DUCATIPWR_state.ducatiClkHandle);
                    ClockOps_put(object->clockHandle,
                                    DM8168DUCATIPWR_state.ducatiClkHandle);
                }
            }
        }
#if !defined(SYSLINK_BUILD_OPTIMIZE) && defined (SYSLINK_BUILD_HLOS)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS) */
    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_off", status);
    /*! @retval PWRMGR_SUCCESS Operation successful */
    return (status);
}
Пример #22
0
/*!
 *  @brief      Function to setup the DM8168DUCATIPWR module.
 *
 *              This function sets up the DM8168DUCATIPWR module. This function must
 *              be called before any other instance-level APIs can be invoked.
 *              Module-level configuration needs to be provided to this
 *              function. If the user wishes to change some specific config
 *              parameters, then DM8168DUCATIPWR_getConfig can be called to get the
 *              configuration filled with the default values. After this, only
 *              the required configuration values can be changed. If the user
 *              does not wish to make any change in the default parameters, the
 *              application can simply call DM8168DUCATIPWR_setup with NULL
 *              parameters. The default parameters would get automatically used.
 *
 *  @param      cfg   Optional DM8168DUCATIPWR module configuration. If provided as
 *                    NULL, default configuration is used.
 *
 *  @sa         DM8168DUCATIPWR_destroy
 *              GateMutex_create
 */
Int
DM8168DUCATIPWR_setup (DM8168DUCATIPWR_Config * cfg)
{
    Int                      status = PWRMGR_SUCCESS;
    DM8168DUCATIPWR_Config   tmpCfg;
    IArg                     key;
    Error_Block              eb;

#if defined(SYSLINK_BUILD_RTOS)
    Error_init(&eb);
#endif /* #if defined(SYSLINK_BUILD_RTOS) */
#if defined(SYSLINK_BUILD_HLOS)
    eb = 0;
#endif /* #if defined(SYSLINK_BUILD_HLOS) */

    GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_setup", cfg);
    if (cfg == NULL) {
        DM8168DUCATIPWR_getConfig (&tmpCfg);
        cfg = &tmpCfg;
    }

    /* This sets the refCount variable is not initialized, upper 16 bits is
     * written with module Id to ensure correctness of refCount variable.
     */
    key = Gate_enterSystem();
    DM8168DUCATIPWR_state.refCount++;
    if (DM8168DUCATIPWR_state.refCount > 1) {
        status = DM8168DUCATIPWR_S_ALREADYSETUP;
        Gate_leaveSystem(key);
    }
    else {
        Gate_leaveSystem(key);

        /* Create a default gate handle for local module protection. */
        DM8168DUCATIPWR_state.gateHandle = (IGateProvider_Handle)
                                GateMutex_create ((GateMutex_Params*)NULL, &eb);
        if (DM8168DUCATIPWR_state.gateHandle == NULL) {
            key = Gate_enterSystem();
            DM8168DUCATIPWR_state.refCount = 0;
            Gate_leaveSystem(key);
            /*! @retval PWRMGR_E_FAIL Failed to create GateMutex! */
            status = PWRMGR_E_FAIL;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "DM8168DUCATIPWR_setup",
                                 status,
                                 "Failed to create GateMutex!");
        }
        else {
            /* Copy the user provided values into the state object. */
            memcpy (&DM8168DUCATIPWR_state.cfg,
                         cfg,
                         sizeof (DM8168DUCATIPWR_Config));

            /* Initialize the name to handles mapping array. */
            memset (&DM8168DUCATIPWR_state.pwrHandles,
                        0,
                        (sizeof (DM8168DUCATIPWR_Handle) * MultiProc_MAXPROCESSORS));
            DM8168DUCATIPWR_state.isSetup = TRUE;
        }
    }

    GT_1trace (curTrace, GT_LEAVE, "DM8168DUCATIPWR_setup", status);
    /*! @retval PWRMGR_SUCCESS Operation successful */
    return (status);
}
Пример #23
0
/*
 *  ======== SysMin_putch ========
 *  Custom implementation for using circular
 *  buffer without using flush
 */
Void SysMin_putch(Char ch)
{
    IArg        key;
    UInt        i;
#ifndef SMP
    static UInt coreId = 0;
#else
    UInt        coreId;
#endif
    UInt        lineIdx;
    Char        *lineBuf;
    Int         index;
    UInt64      uSec;
    static Bool configure = FALSE;
    static UInt startIdx;
    static UInt endIdx;
    static UInt timeStampSecCharLen;
    const  UInt minSecCharLen   = 4;  /* for 1 us tick period */
    const  UInt maxuSecCharLen  = 6; /* for 1 us tick period */
    /* Max characters for seconds would be 10 assuming 1 sec tick period,
     * so decimal point index will be 11, and maximum time stamp buffer
     * length would be 18 accounting maxuSecCharLen and a trailing NULL */
    const  UInt decPtIdx        = 11;
    const  UInt timeStampBufLen = 18;
    const  UInt leftSpaceIdx    = 10;
    Char        timeStamp[18]   = {"                 \0"};

    /* Configure the trace timestamp format */
    if (!configure) {
        Int i = 0, mod = 10;

        /* Find number of characters needes for seconds and sub-seconds,
         * tick periods are specified in microseconds */
        for (; i < maxuSecCharLen; i++) {
            if (Clock_tickPeriod % mod) {
                break;
            }
            mod = mod * 10;
        }
        timeStampSecCharLen = minSecCharLen + i;
        startIdx = decPtIdx - timeStampSecCharLen;
        endIdx = timeStampBufLen - (i + 1); /* Account for null character too */
        configure = TRUE;
    }

    if (SysMin_bufSize != 0) {

#ifndef SMP
        key = Gate_enterSystem();
#else
        /* Disable only local interrupts to place chars in local line buffer */
        key = (IArg)Core_hwiDisable();
        coreId = Core_getId();
#endif

        lineIdx = module->lineBuffers[coreId].lineidx;
        lineBuf = module->lineBuffers[coreId].linebuf;
        lineBuf[lineIdx++] = ch;
        module->lineBuffers[coreId].lineidx = lineIdx;

#ifdef SMP
        /* Copy line buffer to shared output buffer at EOL or when filled up */
        if ((ch == '\n') || (lineIdx >= SysMin_LINEBUFSIZE)) {
            Gate_enterSystem();

            /* Tag core number */
            SysMin_output('[');
            SysMin_output(0x30 + coreId);
            SysMin_output(']');
#else
        if (module->getTime == TRUE) {
#endif
            uSec  = Clock_getTicks() * (UInt64)Clock_tickPeriod;
            SysMin_output('[');
            if (uSec) {
                sprintf(timeStamp, "%17llu\0", uSec);
            }
            for (index = startIdx; index < endIdx; index++) {
                if (index == decPtIdx) {
                    SysMin_output('.');
                }
                if (timeStamp[index] == ' ' && index >= leftSpaceIdx) {
                    SysMin_output('0');
                }
                else {
                    SysMin_output(timeStamp[index]);
                }
            }
            SysMin_output(']');
            SysMin_output(' ');
#ifdef SMP
            for (i = 0; i < lineIdx; i++) {
                SysMin_output(lineBuf[i]);
            }
            module->writeidx[0] =  module->outidx;
            module->lineBuffers[coreId].lineidx = 0;

            Gate_leaveSystem(key);
        }
        else {
            /* restore local interrupts */
            Core_hwiRestore((UInt)key);
        }
#else
            module->getTime = FALSE;
        }

        /* Copy line buffer to shared output buffer at EOL or when filled up */
        if ((ch == '\n') || (lineIdx >= SysMin_LINEBUFSIZE)) {
            for (i = 0; i < lineIdx; i++) {
                SysMin_output(lineBuf[i]);
            }
            module->lineBuffers[coreId].lineidx = 0;
            module->getTime = TRUE;
            module->writeidx[0] = module->outidx;
        }

        Gate_leaveSystem(key);
#endif

    }
}
/*
 *  ======== consoleTaskFxn ========
 *  Console task
 *
 *  This task listens to the key pressed in the keyboard through USBCDC.
 *  The string ended with return character '\n' will trigger the task
 *  to send this string to the mailbox.
 *  For example, when the user enter "ls\n", this task will scan all the
 *  files in the root of SD card and send the file list to the mailbox to
 *  inform the drawing task to display on the screen.
 *  The up/down arrow can be used to scroll up/down to display more files
 *  in the SD card.
 */
Void consoleTaskFxn (UArg arg0, UArg arg1)
{
    unsigned int count;
    unsigned int cpuLoad;
    char input[128];
    UInt key;
    DrawMessage drawMsg;
    count = 1;

    /* printf goes to the UART com port */
    printf("\f======== Welcome to the Console ========\n");
    printf("Enter a command followed by return.\n"
           "Type help for a list of commands.\n\n");

    printf("%d %% ", count++);
    fflush(stdout);

    /* Loop forever receiving commands */
    while(true) {
        /* Get the user's input */
        scanf("%s", input);
        /* Flush the remaining characters from stdin since they are not used. */
        fflush(stdin);

        if (!strcmp(input, "a")) {
            /* Print the CPU load */
            cpuLoad = Load_getCPULoad();
            printf("CPU Load: %d\n", cpuLoad);
            drawMsg.drawCommand = KeyBoadCOMMAND;


            up_remove_blank(4);
            up(4);


            // copy the data to message
            key = Gate_enterSystem();
            copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048);
            Gate_leaveSystem(key);

            Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER);
        }
        else if (!strcmp(input, "d")) {
            /* Print the CPU load */
            cpuLoad = Load_getCPULoad();
            printf("CPU Load: %d\n", cpuLoad);
            drawMsg.drawCommand = KeyBoadCOMMAND;

            down_remove_blank(4);
            down(4);


            // copy the data to message
            key = Gate_enterSystem();
            copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048);
            Gate_leaveSystem(key);

            Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER);
        } else if (!strcmp(input, "w")) {
            /* Print the CPU load */
            cpuLoad = Load_getCPULoad();
            printf("CPU Load: %d\n", cpuLoad);
            drawMsg.drawCommand = KeyBoadCOMMAND;

            left_remove_blank(4);
            left(4);


            // copy the data to message
            key = Gate_enterSystem();
            copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048);
            Gate_leaveSystem(key);

            Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER);
        } else if (!strcmp(input, "s")) {
            /* Print the CPU load */
            cpuLoad = Load_getCPULoad();
            printf("CPU Load: %d\n", cpuLoad);
            drawMsg.drawCommand = KeyBoadCOMMAND;

            right_remove_blank(4);
            right(4);


            // copy the data to message
            key = Gate_enterSystem();
            copyFrom2048ArrayToDrawMessage(4,drawMsg.draw2048 , Array2048);
            Gate_leaveSystem(key);

            Mailbox_post(mailboxHandle, &drawMsg, BIOS_WAIT_FOREVER);
        }
        else if (!strcmp(input, "exit")) {
            /* Exit the console task */
            printf("Are you sure you want to exit the console? Y/N: ");
            fflush(stdout);
            scanf("%s", input);
            fflush(stdin);
            if ((input[0] == 'y' || input[0] == 'Y') && input[1] == 0x00) {
                printf("Exiting console, goodbye.\n");
                Task_exit();
            }
        }
        else {
            /* Print a list of valid commands. */
            printf("Valid commands:\n"
                   "- w: move up.\n"
                   "- a: move left.\n"
                   "- s: move down.\n"
                   "- a: move right.\n"
                   "- exit: Exit the console task.\n");
        }

        fillBox(4);
//	        printf("%d %% ", count++);
        fflush(stdout);
    }

}