/*!
 *  @brief      Function to enter a Gate Spinlock.
 *
 *  @param      handle  Handle to previously created gate Spinlock instance.
 *
 *  @sa         GateSpinlock_leave
 */
UInt32
GateSpinlock_enter (GateSpinlock_Handle handle)
{
    UInt32 key = 0x0;

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

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (handle == NULL) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "GateSpinlock_enter",
                             GateSpinlock_E_INVALIDARG,
                             "Handle passed is invalid!");
    }
    else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
        key = OsalSpinlock_enter ((OsalSpinlock_Handle) handle->sHandle);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "GateSpinlock_enter", key);

    /*! @retval Flags Operation successful */
    return key;
}
Example #2
0
/*!
 *  @brief      Closes the handle corresponding to an event. It also frees the
 *              resources allocated, if any, during call to OpenEvent ()
 *
 *  @param      allocated event object handle.
 *  @sa         OsalEvent_delete
 */
Int OsalEvent_delete (OsalEvent_Handle handle)
{
    Int status = OSALEVENT_SUCCESS ;
    OsalEvent_Object* event = (OsalEvent_Object*) handle;

    GT_1trace (curTrace, GT_ENTER,"OsalEvent_close",event );
    GT_assert (curTrace, (NULL != event) );

    status = OsalSpinlock_delete (&(event->lock));
    if (status >= 0)
    {
        event->signature = 0;
    }
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    else {
        status = OSALEVENT_E_SPINLOCK;
        GT_setFailureReason(curTrace, GT_4CLASS,
                            "OsalEvent_close",OSALEVENT_E_SPINLOCK,
                            "SpinLock Delete failed");
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE,"Event_Close",status );

    /*!@status OSALEVENT_SUCCESS if call succeeded.*/
    /*!@status OSALEVENT_E_SPINLOCK when SpinLock operation fails.*/
    return status;
}
/*!
 *  ======== NotifyCircSetup_sharedMemReq ========
 *  Return the amount of shared memory required
 */
SizeT
NotifyCircSetupDm8168_sharedMemReq (UInt16 remoteProcId, Ptr sharedAddr)
{
    SizeT                  memReq = 0x0;
    NotifyDriverCirc_Params params;

    GT_1trace (curTrace, GT_ENTER, "NotifyCircSetupDm8168_sharedMemReq",
               sharedAddr);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (sharedAddr == NULL) {
        /*! @retval  0 Invalid NULL sharedAddr argument provided. */
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "NotifyCircSetupDm8168_sharedMemReq",
                             Notify_E_INVALIDARG,
                             "Invalid NULL sharedAddr provided.");
    }
    else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
        NotifyDriverCirc_Params_init (&params);
        params.sharedAddr = sharedAddr;

        memReq = NotifyDriverCirc_sharedMemReq (&params);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "NotifyCircSetupDm8168_sharedMemReq", memReq);

    /*! @retval Shared-Memory-Requirements Operation successful */
    return (memReq);
}
Example #4
0
/*
 *  ======== DBLL_unload ========
 */
void DBLL_unload(struct DBLL_LibraryObj *lib, struct DBLL_Attrs *attrs)
{
	struct DBLL_LibraryObj *zlLib = (struct DBLL_LibraryObj *)lib;
	s32 err = 0;

	DBC_Require(cRefs > 0);
	DBC_Require(MEM_IsValidHandle(zlLib, DBLL_LIBSIGNATURE));
	DBC_Require(zlLib->loadRef > 0);
	GT_1trace(DBLL_debugMask, GT_ENTER, "DBLL_unload: lib: 0x%x\n", lib);
	zlLib->loadRef--;
	/* Unload only if reference count is 0 */
	if (zlLib->loadRef != 0)
		goto func_end;

	zlLib->pTarget->attrs = *attrs;
	if (zlLib->mHandle) {
		err = Dynamic_Unload_Module(zlLib->mHandle,
			&zlLib->symbol.dlSymbol,
			&zlLib->allocate.dlAlloc, &zlLib->init.dlInit);
		if (err != 0) {
			GT_1trace(DBLL_debugMask, GT_5CLASS,
				 "Dynamic_Unload_Module failed: 0x%x\n", err);
		}
	}
	/* remove symbols from symbol table */
	if (zlLib->symTab != NULL) {
		GH_delete(zlLib->symTab);
		zlLib->symTab = NULL;
	}
	/* delete DOFF desc since it holds *lots* of host OS
	 * resources */
	dofClose(zlLib);
func_end:
	DBC_Ensure(zlLib->loadRef >= 0);
}
Example #5
0
/*
 *  ======== MEM_Free ========
 *  Purpose:
 *      Free the given block of system memory.
 */
void MEM_Free(IN void *pMemBuf)
{
#ifdef MEM_CHECK
	struct memInfo *pMem = (void *)((u32)pMemBuf - sizeof(struct memInfo));
#endif

	DBC_Require(pMemBuf != NULL);

	GT_1trace(MEM_debugMask, GT_ENTER, "MEM_Free: pMemBufs 0x%x\n",
		  pMemBuf);

	if (pMemBuf) {
#ifndef MEM_CHECK
		kfree(pMemBuf);
#else
		if (pMem) {
			if (pMem->dwSignature == memInfoSign) {
				spin_lock(&mMan.lock);
				MLST_RemoveElem(&mMan.lst,
						(struct LST_ELEM *) pMem);
				spin_unlock(&mMan.lock);
				pMem->dwSignature = 0;
				kfree(pMem);
			} else {
				GT_1trace(MEM_debugMask, GT_7CLASS,
					"Invalid allocation or "
					"Buffer underflow at %x\n",
					(u32) pMem + sizeof(struct memInfo));
			}
		}
#endif
	}
}
Example #6
0
/*
 *  ======== KFILE_Close ========
 *  Purpose:
 *      This function closes a file's stream.
 */
s32 KFILE_Close(struct KFILE_FileObj *hFile)
{
	s32 cRetVal = 0;	/* 0 indicates success */
	s32 fRetVal = 0;
	__kernel_pid_t curr_pid;

	GT_1trace(KFILE_debugMask, GT_ENTER, "KFILE_Close: hFile 0x%x\n",
		  hFile);

	/* Check for valid handle */
	if (MEM_IsValidHandle(hFile, SIGNATURE)) {
		/* Close file only if opened by the same process (id). Otherwise
		 * Linux closes all open file handles when process exits.*/
		/* Return PID instead of process handle */
		curr_pid = (__kernel_pid_t)current->pid;
		fRetVal = filp_close(hFile->fileDesc, NULL) ;
		if (fRetVal) {
			cRetVal = E_KFILE_ERROR;
			GT_1trace(KFILE_debugMask, GT_6CLASS,
				  "KFILE_Close: sys_close "
				  "returned %d\n", fRetVal);
		}
		MEM_FreeObject(hFile);
	} else {
		cRetVal = E_KFILE_INVALIDHANDLE;
		GT_0trace(KFILE_debugMask, GT_6CLASS, "KFILE_Close: "
			  "invalid file handle\n");
	}
	return cRetVal;
}
Example #7
0
/*!
 *  @brief      Begin protection of code through spin lock with all ISRs
 *              disabled. Calling this API protects critical regions of code
 *              from preemption by tasks, DPCs and all interrupts.
 *
 *  @param      lockHandle   Spinlock object handle to be acquired.
 *
 *  @sa         OsalSpinlock_leave
 */
UInt32
OsalSpinlock_enter (OsalSpinlock_Handle lockHandle)
{
    UInt32 flags = 0;

    OsalSpinlock_Object * lockObject = (OsalSpinlock_Object*) lockHandle;

    GT_1trace (curTrace, GT_ENTER, "OsalSpinlock_enter", lockHandle);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (lockHandle == NULL) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalSpinlock_enter",
                             OSALSPINLOCK_E_HANDLE,
                             "NULL spinlock handle provided.");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
        spin_lock (&(lockObject->lock));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "OsalSpinlock_enter", flags);

    /*! @retval Flags Flags to be provided to corresponding leave call. */
    return flags;
}
/*!
 *  @brief      Remove and delete entry from the Translation Table
 *
 *  @param      da      Device address
 *
 *  @sa         _SysLinkMemUtils_insertMapElement
 */
static Ptr
_SysLinkMemUtils_removeMapElement (Ptr da)
{
    AddrNode  * node;
    Ptr         addr = NULL;

    GT_1trace (curTrace, GT_ENTER, "_SysLinkMemUtils_removeMapElement", da);

    OsalSemaphore_pend (SysLinkMemUtils_module->semList,
                        OSALSEMAPHORE_WAIT_FOREVER);
    node = _SysLinkMemUtils_findNode (da);
    if (!node || node->da != da) {
#if !defined(SYSLINK_BUILD_OPTIMIZE)
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             (Char *)__func__,
                             PROCMGR_E_FAIL,
                             "Entry not found!");
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
    }
    else {
        addr = node->ua;
        List_remove (SysLinkMemUtils_module->addrTable, &node->elem);
        Memory_free (NULL, node, sizeof (AddrNode));
    }
    OsalSemaphore_post (SysLinkMemUtils_module->semList);

    GT_1trace (curTrace, GT_LEAVE, "_SysLinkMemUtils_removeMapElement", addr);

    return addr;
}
/*!
 *  @brief      Get a valid A9 address from a remote proc address
 *
 *              This function  can be called by an app running
 *              in A9 to access a buffer allocated from remote processor.
 *
 *  @param      da      Device address
 *
 *  @sa         SysLinkMemUtils_alloc, SysLinkMemUtils_free
 */
Ptr
SysLinkMemUtils_DAtoVA (Ptr da)
{
    AddrNode  * node;
    Ptr         addr = NULL;

    GT_1trace (curTrace, GT_ENTER, "SysLinkMemUtils_DAtoVA", da);

#if 1
    /* SysLinkMemUtils_DAtoVA() is now a stub that always      */
    /* returns NULL.  It is necessary to disable this function */
    /* due to the changes to the block lookup that breaks its  */
    /* functionality.                                          */
    (Void)node;
    (Void)da;
    GT_setFailureReason (curTrace,
                         GT_4CLASS,
                         (Char *)__func__,
                         -1,
                         "SysLinkMemUtils_DAtoVA() is unavailable.");
#else
    OsalSemaphore_pend (SysLinkMemUtils_module->semList,
                        OSALSEMAPHORE_WAIT_FOREVER);
    node = _SysLinkMemUtils_findNode (da);
    OsalSemaphore_post (SysLinkMemUtils_module->semList);
    if (node) {
        addr = node->ua + (da - node->da);
    }
#endif

    GT_1trace (curTrace, GT_LEAVE, "SysLinkMemUtils_DAtoVA", addr);

    return addr;
}
Example #10
0
/*
 * ======== OsalKfile_tell ========
 */
UInt32
OsalKfile_tell (OsalKfile_Handle fileHandle)
{
    OsalKfile_Object *  fileObject  = NULL;
    UInt32              posValue    = 0u;

    GT_1trace (curTrace, GT_ENTER, "OsalKfile_tell", fileHandle);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (fileHandle == NULL) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalKfile_seek",
                             OSALKFILE_E_INVALIDARG,
                             "NULL provided for argument fileHandle");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
        fileObject = (OsalKfile_Object*) fileHandle;

        posValue = fileObject->curPos;

        GT_assert (GT_1CLASS, (posValue == fileObject->fileDesc->f_pos));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace(curTrace, GT_LEAVE,"OsalKfile_tell",posValue );

    /* !< @retval File-position Current file pointer position in file.*/
    return posValue;
}
Example #11
0
Int32 decodeReclaim(AUDDEC1_Handle dec, int in, int out)
{
    Int32 status;

    GT_4trace(curMask, GT_1CLASS, "App-> inBuf[%d]=%#x, outBuf[%d]=%#x\n",
              in, encodedBufDesc[in].descs[0].buf,
              out, outBufDesc[out].descs[0].buf);

    status = AUDDEC1_processWait(dec, &encodedBufDesc[in],
                                 &outBufDesc[out],
                                 &decInArgs[in],
                                 &decOutArgs[out],
                                 AUDDEC1_FOREVER);

#ifdef CACHE_ENABLED
    /* Writeback the outBuf. */
    Memory_cacheWb(outBuf[out], OFRAMESIZE);
#endif

    GT_1trace(curMask, GT_2CLASS,
              "App-> Decoder processWait returned 0x%x\n", status);
    if (status != AUDDEC1_EOK) {
        GT_1trace(curMask, GT_7CLASS,
                  "App-> Decoder processing FAILED, extendedError = 0x%x\n",
                  decOutArgs[out].extendedError);
    }

    return status;
}
Example #12
0
/*!
 *  @brief      Interrupt Service Routine for Dm8168IpcInt module
 *
 *  @param      arg     Optional argument to the function.
 *
 *  @sa         _Dm8168IpcInt_checkAndClearFunc
 */
static
Bool
_Dm8168IpcInt_isr (Ptr ref)
{
    UInt16 i = 0;
    GT_1trace (curTrace, GT_ENTER, "_Dm8168IpcInt_isr", ref);

    for (i = 0 ; i < Dm8168IpcInt_state.maxProcessors ; i++) {
        while (Atomic_read (&(Dm8168IpcInt_state.isrObjects [i].asserted)) != 0) {
#if defined  (SYSLINK_INT_LOGGING)
            SysLogging_intCount++;
#endif /* if defined  (SYSLINK_INT_LOGGING) */
            /* Ensure that the ISR for this proc ID is still installed. */
            if (Dm8168IpcInt_state.isrObjects [i].fxn != NULL) {
                Dm8168IpcInt_state.isrObjects [i].fxn (
                                    Dm8168IpcInt_state.isrObjects [i].fxnArgs);
            }
            Atomic_dec_return (&(Dm8168IpcInt_state.isrObjects [i].asserted));
        }
    }

    GT_1trace (curTrace, GT_LEAVE, "_Dm8168IpcInt_isr", TRUE);

    /*! @retval TRUE Interrupt has been handled. */
    return (TRUE);
}
Example #13
0
/*!
 *  @brief      Function to finalize the HAL object
 *
 *  @param      halObj      Pointer to the HAL object
 *
 *  @sa         OMAPL1XX_halInit
 *              OMAPL1XX_phyShmemExit
 */
Int
OMAPL1XX_halExit (Ptr halObj)
{
    Int                  status    = PROCESSOR_SUCCESS;
    OMAPL1XX_HalObject * halObject = NULL;

    GT_1trace (curTrace, GT_ENTER, "OMAPL1XX_halExit", halObj);

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

    halObject = (OMAPL1XX_HalObject *) halObj ;
    status = OMAPL1XX_phyShmemExit (halObj);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (status < 0) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OMAPL1XX_halExit",
                             status,
                             "OMAPL1XX_phyShmemExit failed!");
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    if (halObj != NULL) {
        /* Free the memory for the HAL object. */
        Memory_free (NULL, halObj, sizeof (OMAPL1XX_HalObject));
    }

    GT_1trace (curTrace, GT_LEAVE, "OMAPL1XX_halExit", status);

    /*! @retval PROCESSOR_SUCCESS Operation successful */
    return status;
}
Example #14
0
/*
 *  ======== DMM_DeleteTables ========
 *  Purpose:
 *      Delete DMM Tables.
 */
DSP_STATUS DMM_DeleteTables(struct DMM_OBJECT *hDmmMgr)
{
	struct DMM_OBJECT *pDmmObj = (struct DMM_OBJECT *)hDmmMgr;
	DSP_STATUS status = DSP_SOK;

	GT_1trace(DMM_debugMask, GT_ENTER,
		"Entered DMM_DeleteTables () hDmmMgr %x\n", hDmmMgr);
	DBC_Require(cRefs > 0);
	if (MEM_IsValidHandle(hDmmMgr, DMMSIGNATURE)) {
		/* Delete all DMM tables */
		SYNC_EnterCS(pDmmObj->hDmmLock);

		if (pVirtualMappingTable != NULL)
			MEM_Free(pVirtualMappingTable);

		if (pPhysicalAddrTable != NULL)
			MEM_Free(pPhysicalAddrTable);

		SYNC_LeaveCS(pDmmObj->hDmmLock);
	} else
		status = DSP_EHANDLE;
	GT_1trace(DMM_debugMask, GT_4CLASS,
		"Leaving DMM_DeleteTables status %x\n", status);
	return status;
}
Example #15
0
/*!
 *  @brief      Acquire/lock the Mutex object.
 *
 *              This function acquires the critical section identified by this
 *              mutex handle. Once this function is successfully entered,
 *              further calls to OsalMutex_enter shall block till the critical
 *              section has been released by the caller.
 *
 *  @param      mutexHandle   Mutex object handle to be acquired.
 *
 *  @sa         OsalMutex_leave
 */
IArg
OsalMutex_enter (OsalMutex_Handle mutexHandle)
{
    IArg                retVal      = 0;
    OsalMutex_Object *  mutexObj    = (OsalMutex_Object*) mutexHandle;
    Int                 ret         = 0;

    GT_1trace (curTrace, GT_ENTER, "OsalMutex_enter", mutexHandle);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (mutexHandle == NULL) {
        /* Function does not return status. */
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalMutex_enter",
                             OSALMUTEX_E_HANDLE,
                             "NULL Mutex handle provided.");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
        ret = pthread_mutex_lock (&(mutexObj->lock));
        GT_assert (curTrace, (ret == 0));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "OsalMutex_enter", retVal);

    /*! @retval 0 Operation successfully completed. */
    return retVal;
}
Example #16
0
/*!
 *  @brief  Function to close the Notify driver.
 *
 *  @param  deleteThread  Flag to indicate whether to delete thread or not.
 *
 *  @sa     NotifyDrvUsr_open
 */
Int
NotifyDrvUsr_close (Bool deleteThread)
{
    Int    status      = Notify_S_SUCCESS;

    GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_close", deleteThread);

    /* TBD: Protection for refCount. */
    if (NotifyDrvUsr_refCount == 1) {
        if (deleteThread == TRUE) {
        	Notify_CmdArgsThreadDetach detachParams;
            detachParams.pid = getpid ();
            status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADDETACH, &detachParams);
            if (status < 0) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "NotifyDrvUsr_close",
                                     status,
                                     "Notify detach failed on kernel side!");
            }

            pthread_join (NotifyDrv_workerThread, NULL);
        }
        NotifyDrvUsr_refCount--;
    }
    else {
        NotifyDrvUsr_refCount--;
    }

    GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_close", status);

    return status;
}
/*!
 *  @brief      Function to enter a Gate Mutex.
 *
 *  @param      gmHandle  Handle to previously created gate mutex instance.
 *
 *  @sa         GateMutex_leave
 */
IArg
GateMutex_enter (GateMutex_Handle gmHandle)
{
    IArg   key = 0x0;

    GT_1trace (curTrace, GT_ENTER, "GateMutex_enter", gmHandle);

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (gmHandle == NULL) {
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "GateMutex_enter",
                             GateMutex_E_INVALIDARG,
                             "Handle passed is invalid!");
    }
    else {
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */
        key = OsalMutex_enter ((OsalMutex_Handle) gmHandle->mHandle);
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "GateMutex_enter", key);

    /*! @retval Flags Operation successful */
    return key;
}
/*
 * @brief Function to find out the number of frame buffers in a frame .
 *
 * @param buf      frame.
 */
UInt32
FrameQ_getNumFrameBuffers (FrameQ_Frame frame )
{
    UInt32 numbufs = 0 ;

    GT_1trace (curTrace,
               GT_ENTER,
               "FrameQ_getNumFrameBuffers",
               frame);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (frame == NULL) {
        /*! @retval 0  frame passed is null
         */
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "FrameQ_getNumFrameBuffers",
                             FrameQ_E_INVALIDARG,
                             "frame passed is null !");
    }
    else {
#endif /*#if !defined(SYSLINK_BUILD_OPTIMIZE)*/
        numbufs = frame->numFrameBuffers;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /*#if !defined(SYSLINK_BUILD_OPTIMIZE)*/

    GT_1trace (curTrace, GT_LEAVE, "FrameQ_getNumFrameBuffers",numbufs);

    /*! @retval number of frame buffers*/
    return (numbufs) ;
}
Example #19
0
Int32 encodeReclaim(AUDENC1_Handle enc, int in, int out)
{
    Int32 status;

    GT_4trace(curMask, GT_1CLASS, "App-> inBuf[%d]=%#x, outBuf[%d]=%#x\n",
              in, inBufDesc[in].descs[0].buf,
              out, encodedBufDesc[out].descs[0].buf);

    status = AUDENC1_processWait(enc, &inBufDesc[in],
                                 &encodedBufDesc[out],
                                 &encInArgs[in],
                                 &encOutArgs[out],
                                 AUDENC1_FOREVER);

#ifdef CACHE_ENABLED
    /*
     * Since encodedBuf is an inBuf to the next process call, we
     * must invalidate it, to clean buffer lines.
     */
    Memory_cacheWbInv(encodedBuf[out], EFRAMESIZE);
#endif

    GT_1trace(curMask, GT_2CLASS,
              "App-> Encoder processWait returned 0x%x\n", status);
    if (status != AUDENC1_EOK) {
        GT_1trace(curMask, GT_7CLASS,
                  "App-> Encodcer processing FAILED, extendedError = 0x%x\n",
                  encOutArgs[out].extendedError);
    }

    return status;
}
Example #20
0
/*
 *  ======== DPC_Schedule ========
 *  Purpose:
 *      Schedule a deferred procedure call to be executed at a later time.
 *      Latency and order of DPC execution is platform specific.
 */
DSP_STATUS DPC_Schedule(struct DPC_OBJECT *hDPC)
{
	DSP_STATUS status = DSP_SOK;
	struct DPC_OBJECT *pDPCObject = (struct DPC_OBJECT *)hDPC;
	unsigned long flags;

	GT_1trace(DPC_DebugMask, GT_ENTER, "DPC_Schedule hDPC %x\n", hDPC);
	if (MEM_IsValidHandle(hDPC, SIGNATURE)) {
		/* Increment count of DPC's pending. Needs to be protected
		 * from ISRs since this function is called from process
		 * context also. */
		spin_lock_irqsave(&hDPC->dpc_lock, flags);
		pDPCObject->numRequested++;
		spin_unlock_irqrestore(&hDPC->dpc_lock, flags);
		tasklet_schedule(&(hDPC->dpc_tasklet));
#ifdef DEBUG
		if (pDPCObject->numRequested > pDPCObject->numScheduled +
						pDPCObject->numRequestedMax) {
			pDPCObject->numRequestedMax = pDPCObject->numRequested -
						pDPCObject->numScheduled;
		}
#endif
	/*  If an interrupt occurs between incrementing numRequested and the
	 *  assertion below, then DPC will get executed while returning from
	 *  ISR, which will complete all requests and make numRequested equal
	 * to numScheduled, firing this assertion. This happens only when
	 * DPC is being scheduled in process context */
	} else {
		GT_0trace(DPC_DebugMask, GT_6CLASS,
			  "DPC_Schedule: DSP_EHANDLE\n");
		status = DSP_EHANDLE;
	}
	GT_1trace(DPC_DebugMask, GT_ENTER, "DPC_Schedule status %x\n", status);
	return status;
}
Example #21
0
/*
 *  ======== SemMP_post ========
 */
Void SemMP_post(SemMP_Handle sem)
{
    GT_1trace(curTrace, GT_ENTER, "Entered SemMP_post> sem[0x%x]\n", sem);

        ReleaseSemaphore(sem->id, 1, NULL);

    GT_1trace(curTrace, GT_ENTER, "Leaving SemMP_post> sem[0x%x]\n", sem);
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Handle IRES_ADDRSPACE_constructHandle(
        IRES_ProtocolArgs * resProtocolArgs,
        IALG_MemRec *memRecs,
        IRESMAN_ConstructArgs * constructHandleArgs,
        IRES_Status *status)
{
    IRES_ADDRSPACE_Handle handle = (IRES_ADDRSPACE_Handle)memRecs[0].base;

    IRESMAN_ADDRSPACE_ConstructHandleArgs * constructArgs =
        (IRESMAN_ADDRSPACE_ConstructHandleArgs *)constructHandleArgs;

    GT_3trace(ti_sdo_fc_ires_addrspace_GTMask, GT_ENTER,
            "_IRES_ADDRSPACE_constructHandle> Enter (resProtcolArgs=0x%x, "
            "memRecs=0x%x, constructHandleArgs=0x%x)\n", resProtocolArgs,
            memRecs, constructHandleArgs);

    GT_assert(ti_sdo_fc_ires_addrspace_GTMask, resProtocolArgs != NULL);
    GT_assert(ti_sdo_fc_ires_addrspace_GTMask, memRecs != NULL);
    GT_assert(ti_sdo_fc_ires_addrspace_GTMask, constructHandleArgs != NULL);
    GT_assert(ti_sdo_fc_ires_addrspace_GTMask, status != NULL);

    if (handle == NULL) {
        *status = IRES_ENORESOURCE;

        GT_0trace(ti_sdo_fc_ires_addrspace_GTMask, GT_7CLASS,
                "_IRES_ADDRSPACE_constructHandle> NULL handle passed in "
                "memRecs[0].base\n");

        GT_1trace(ti_sdo_fc_ires_addrspace_GTMask, GT_ENTER,
                "_IRES_ADDRSPACE_constructHandle> Exit (handle=0x%x, "
                "status=IRES_ENORESOURCE)\n", handle);

        return ((IRES_Handle) NULL);
    }

    handle->addr = constructArgs->addr ;

    handle->len = constructArgs->len ;
    ((IRES_ADDRSPACE_IntObj *)handle)->mapBase = constructArgs->mapBase;
    ((IRES_ADDRSPACE_IntObj *)handle)->mapLen = constructArgs->mapLen;

    ((IRES_ADDRSPACE_Handle)handle)->ires.getStaticProperties =
            IRES_ADDRSPACE_getStaticProperties;

    /*
     * Use the constructHandleargs to populate the ShadowPaRams with the
     * correct link
     */

    *status = IRES_OK;

    GT_1trace(ti_sdo_fc_ires_addrspace_GTMask, GT_ENTER,
            "_IRES_ADDRSPACE_constructHandle> Exit (handle=0x%x, "
            "status=IRES_OK)\n", handle);

    return ((IRES_Handle)handle);
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Handle IRES_SDMA_constructHandle(
        IRES_ProtocolArgs * resProtocolArgs,
        IALG_MemRec *memRecs,
        IRESMAN_ConstructArgs * constructHandleArgs,
        IRES_Status *status)
{
    IRES_SDMA_Handle handle = (IRES_SDMA_Handle)memRecs[0].base;

    IRES_SDMA_ConstructHandleArgs * constructArgs =
        (IRES_SDMA_ConstructHandleArgs *)constructHandleArgs;

    GT_3trace(ti_sdo_fc_ires_sdma_GTMask, GT_ENTER,
            "_IRES_SDMA_constructHandle> Enter (resProtcolArgs=0x%x, "
            "memRecs=0x%x, constructHandleArgs=0x%x)\n", resProtocolArgs,
            memRecs, constructHandleArgs);

    GT_assert(ti_sdo_fc_ires_sdma_GTMask, resProtocolArgs != NULL);
    GT_assert(ti_sdo_fc_ires_sdma_GTMask, memRecs != NULL);
    GT_assert(ti_sdo_fc_ires_sdma_GTMask, constructHandleArgs != NULL);
    GT_assert(ti_sdo_fc_ires_sdma_GTMask, status != NULL);

    if (handle == NULL) {

        *status = IRES_ENORESOURCE;

        GT_0trace(ti_sdo_fc_ires_sdma_GTMask, GT_7CLASS,
                "_IRES_SDMA_constructHandle> NULL handle passed in "
                "memRecs[0].base\n");

        GT_1trace(ti_sdo_fc_ires_sdma_GTMask, GT_ENTER,
                "_IRES_SDMA_constructHandle> Exit (handle=0x%x, "
                "status=IRES_ENORESOURCE)\n", handle);

        return ((IRES_Handle) NULL);
    }

    ((IRES_SDMA_Handle)handle)->ires.getStaticProperties =
            IRES_SDMA_getStaticProperties;

    /*
     * Use the constructHandleargs to populate the handle
     */
    handle->channel = (SDMA_ChannelDescriptor *)
            (handle + sizeof(IRES_SDMA_Obj));

    handle->ires.persistent = constructArgs->persistent;

    *status = IRES_OK;

    GT_1trace(ti_sdo_fc_ires_sdma_GTMask, GT_ENTER,
            "_IRES_SDMA_constructHandle> Exit (handle=0x%x, "
            "status=IRES_OK)\n", handle);

    return ((IRES_Handle)handle);
}
Example #24
0
/*!
 *  @brief  Function to open the Notify driver.
 *
 *  @param  createThread  Flag to indicate whether to create thread or not.
 *
 *  @sa     NotifyDrvUsr_close
 */
Int
NotifyDrvUsr_open (Bool createThread)
{
    Int    status   = Notify_S_SUCCESS;

    GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_open", createThread);

    if (NotifyDrvUsr_refCount == 0) {
        /* TBD: Protection for refCount. */
        NotifyDrvUsr_refCount++;

        if (createThread == TRUE) {
            Notify_CmdArgsThreadAttach attachParams;
            attachParams.pid = getpid ();
            status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADATTACH, &attachParams);
            if (status < 0) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "NotifyDrvUsr_close",
                                     status,
                                     "Notify attach failed on kernel "
                                     "side!");
            }
            else {
                /* Create the pthread */
                pthread_create (&NotifyDrv_workerThread,
                                NULL,
                                (Ptr) _NotifyDrvUsr_eventWorker,
                                NULL);
                if (NotifyDrv_workerThread == (UInt32) NULL) {
                    /*! @retval Notify_E_OSFAILURE Failed to create
                                                   Notify thread */
                    status = Notify_E_OSFAILURE;
                    GT_setFailureReason (curTrace,
                                         GT_4CLASS,
                                         "NotifyDrvUsr_open",
                                         status,
                                         "Failed to create Notify "
                                         "thread!");
                }
            }
        }
    }
    else {
        /* TBD: Protection for refCount. */
        NotifyDrvUsr_refCount++;
    }

    GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_open", status);

    /*! @retval Notify_S_SUCCESS Operation successfully completed. */
    return status;
}
Example #25
0
/*!
 *  @brief  Function to close the Notify driver.
 *
 *  @param  deleteThread  Flag to indicate whether to delete thread or not.
 *
 *  @sa     NotifyDrvUsr_open
 */
Int
NotifyDrvUsr_close (Bool deleteThread)
{
    Int    status      = Notify_S_SUCCESS;
    int    osStatus    = 0;
    UInt32 pid;
    Notify_CmdArgsThreadDetach cmdArgs;

    GT_1trace (curTrace, GT_ENTER, "NotifyDrvUsr_close", deleteThread);
    /* TBD: Protection for refCount. */
    if (NotifyDrvUsr_refCount == 1) {
        if (deleteThread == TRUE) {
            pid = getpid ();
            cmdArgs.pid = pid;
            status = NotifyDrvUsr_ioctl (CMD_NOTIFY_THREADDETACH, &cmdArgs);
            if (status < 0) {
                GT_setFailureReason (curTrace,
                                     GT_4CLASS,
                                     "NotifyDrvUsr_close",
                                     status,
                                     "Notify detach failed on kernel side!");
            }

#ifndef LINUX_THREAD
            pthread_join (NotifyDrv_workerThread, NULL);
#endif
        }
        NotifyDrvUsr_refCount--;

        osStatus = close (NotifyDrvUsr_handle);
        if (osStatus != 0) {
            perror ("Notify driver close: " NOTIFY_DRIVER_NAME);
            /*! @retval Notify_E_OSFAILURE Failed to open Notify driver with
                                            OS */
            status = Notify_E_OSFAILURE;
            GT_setFailureReason (curTrace,
                                 GT_4CLASS,
                                 "NotifyDrvUsr_close",
                                 status,
                                 "Failed to close Notify driver with OS!");
        }
        else {
            NotifyDrvUsr_handle = -1;
        }
    }
    else {
        NotifyDrvUsr_refCount--;
    }

    GT_1trace (curTrace, GT_LEAVE, "NotifyDrvUsr_close", status);

    return status;
}
Example #26
0
/*  ======== DMM_CreateTables ========
 *  Purpose:
 *      Create table to hold the information of physical address
 *      the buffer pages that is passed by the user, and the table
 *      to hold the information of the virtual memory that is reserved
 *      for DSP.
 */
DSP_STATUS DMM_CreateTables(struct DMM_OBJECT *hDmmMgr, u32 addr, u32 size)
{
	struct DMM_OBJECT *pDmmObj = (struct DMM_OBJECT *)hDmmMgr;
	DSP_STATUS status = DSP_SOK;

	GT_3trace(DMM_debugMask, GT_ENTER,
		 "Entered DMM_CreateTables () hDmmMgr %x, addr"
		 " %x, size %x\n", hDmmMgr, addr, size);
	status = DMM_DeleteTables(pDmmObj);
	if (DSP_SUCCEEDED(status)) {
		SYNC_EnterCS(pDmmObj->hDmmLock);
		dynMemMapBeg = addr;
		TableSize = (size/PG_SIZE_4K) + 1;
		/*  Create the free list */
		pVirtualMappingTable = (struct MapPage *) MEM_Calloc
		(TableSize*sizeof(struct MapPage), MEM_NONPAGED);
		if (pVirtualMappingTable == NULL)
			status = DSP_EMEMORY;
		else {
			/* This table will be used
			* to store the virtual to physical
			* address translations
			*/
			pPhysicalAddrTable = (u32 *)MEM_Calloc
				(TableSize*sizeof(u32), MEM_NONPAGED);
			GT_1trace(DMM_debugMask, GT_4CLASS,
			"DMM_CreateTables: Allocate"
			"memory for pPhysicalAddrTable=%d entries\n",
			TableSize);
			if (pPhysicalAddrTable == NULL) {
				status = DSP_EMEMORY;
				GT_0trace(DMM_debugMask, GT_7CLASS,
				    "DMM_CreateTables: Memory allocation for "
				    "pPhysicalAddrTable failed\n");
			} else {
			/* On successful allocation,
			* all entries are zero ('free') */
			iFreeRegion = 0;
			iFreeSize = TableSize*PG_SIZE_4K;
			pVirtualMappingTable[0].RegionSize = TableSize;
			}
		}
		SYNC_LeaveCS(pDmmObj->hDmmLock);
	} else
		GT_0trace(DMM_debugMask, GT_7CLASS,
			 "DMM_CreateTables: DMM_DeleteTables"
			 "Failure\n");

	GT_1trace(DMM_debugMask, GT_4CLASS, "Leaving DMM_CreateTables status"
							"0x%x\n", status);
	return status;
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Handle IRES_MEMTCM_constructHandle(
        IRES_ProtocolArgs * resProtocolArgs, 
        IALG_MemRec *memRecs, 
        IRESMAN_ConstructArgs * constructHandleArgs, 
        IRES_Status *status)
{
    IRES_MEMTCM_Handle handle = (IRES_MEMTCM_Handle)memRecs[0].base;

    IRES_MEMTCM_ConstructHandleArgs * constructArgs =
        (IRES_MEMTCM_ConstructHandleArgs *)constructHandleArgs;

    GT_3trace(ti_sdo_fc_ires_memtcm_GTMask, GT_ENTER, 
            "_IRES_MEMTCM_constructHandle> Enter (resProtcolArgs=0x%x, "
            "memRecs=0x%x, constructHandleArgs=0x%x)\n", resProtocolArgs, 
            memRecs, constructHandleArgs);

    GT_assert(ti_sdo_fc_ires_memtcm_GTMask, resProtocolArgs != NULL);
    GT_assert(ti_sdo_fc_ires_memtcm_GTMask, memRecs != NULL);
    GT_assert(ti_sdo_fc_ires_memtcm_GTMask, constructHandleArgs != NULL);
    GT_assert(ti_sdo_fc_ires_memtcm_GTMask, status != NULL);
    
    if (handle == NULL) {
        *status = IRES_ENORESOURCE;

        GT_0trace(ti_sdo_fc_ires_memtcm_GTMask, GT_7CLASS, 
                "_IRES_MEMTCM_constructHandle> NULL handle passed in "
                "memRecs[0].base\n");

        GT_1trace(ti_sdo_fc_ires_memtcm_GTMask, GT_ENTER, 
                "_IRES_MEMTCM_constructHandle> Exit (handle=0x%x, "
                "status=IRES_ENORESOURCE)\n", handle);

        return ((IRES_Handle) NULL);
    }

    handle->ires.persistent = constructArgs->persistent;

    handle->memSize = constructArgs->memSize;

    handle->memAddr = constructArgs->memAddr; 

    ((IRES_MEMTCM_Handle)handle)->ires.getStaticProperties = 
            IRES_MEMTCM_getStaticProperties;                

    *status = IRES_OK;

    GT_1trace(ti_sdo_fc_ires_memtcm_GTMask, GT_ENTER, 
            "_IRES_MEMTCM_constructHandle> Exit (handle=0x%x, "
            "status=IRES_OK)\n", handle);

    return ((IRES_Handle)handle);
}
/*!
 *  @brief      Deletes an instance of Semaphore object.
 *
 *  @param      mutexHandle   Semaphore object handle which needs to be deleted.
 *
 *  @sa         OsalSemaphore_create
 */
Int
OsalSemaphore_delete(OsalSemaphore_Handle *semHandle)
{
    Int status = OSALSEMAPHORE_SUCCESS;
    OsalSemaphore_Object **semObj = (OsalSemaphore_Object **)semHandle;
    int osStatus = 0;

    GT_1trace (curTrace, GT_ENTER, "OsalSemaphore_delete", semHandle);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (semHandle == NULL) {
        status = OSALSEMAPHORE_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalSemaphore_delete",
                             status,
                             "NULL provided for argument semHandle");
    }
    else if (*semHandle == NULL) {
        status = OSALSEMAPHORE_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalSemaphore_delete",
                             status,
                             "NULL Semaphore handle provided.");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
            osStatus = sem_destroy(&((*semObj)->lock));
#if !defined(SYSLINK_BUILD_OPTIMIZE)
            if (osStatus < 0) {
                   status = OSALSEMAPHORE_E_HANDLE;
                GT_setFailureReason (curTrace,
                            GT_4CLASS,
                            "OsalSemaphore_delete",
                            status,
                            "Failed to destroy semaphore");
               }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
        Memory_free(NULL, *semHandle, sizeof (OsalSemaphore_Object));
        *semHandle = NULL;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "OsalSemaphore_delete", status);

    return status;
}
Example #29
0
/*!
 *  @brief      Function to close a handle to an instance of this PwrMgr.
 *
 *  @param      handlePtr  Pointer to Handle to the PwrMgr instance
 *
 *  @sa         DM8168DUCATIPWR_open
 */
Int
DM8168DUCATIPWR_close (DM8168DUCATIPWR_Handle * handlePtr)
{
    Int status = PWRMGR_SUCCESS;

    GT_1trace (curTrace, GT_ENTER, "DM8168DUCATIPWR_close", handlePtr);

    GT_assert (curTrace, (handlePtr != NULL));
    GT_assert (curTrace, ((handlePtr != NULL) && (*handlePtr != 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_close",
                             DM8168DUCATIPWR_E_INVALIDSTATE,
                             "Module was not initialized!");
    }
    else if (handlePtr == NULL) {
        /*! @retval PWRMGR_E_INVALIDARG Invalid NULL handlePtr pointer
                                         specified*/
        status = PWRMGR_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_close",
                             status,
                             "Invalid NULL handlePtr pointer specified");
    }
    else if (*handlePtr == NULL) {
        /*! @retval PWRMGR_E_HANDLE Invalid NULL *handlePtr specified */
        status = PWRMGR_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "DM8168DUCATIPWR_close",
                             status,
                             "Invalid NULL *handlePtr specified");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) && defined(SYSLINK_BUILD_HLOS) */
        /* Nothing to be done for close. */
        *handlePtr = NULL;
#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_close", status);

    /*! @retval PWRMGR_SUCCESS Operation successful */
    return status;
}
Example #30
0
/*
 * ======== OsalKfile_close ========
 */
Int
OsalKfile_close (OsalKfile_Handle * fileHandle)
{
    Int                 status      = OSALKFILE_SUCCESS;
    OsalKfile_Object *  fileObject  = NULL;
    mm_segment_t        fs;

    GT_1trace (curTrace, GT_ENTER, "OsalKfile_close", fileHandle);

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

#if !defined(SYSLINK_BUILD_OPTIMIZE)
    if (fileHandle == NULL) {
        /*! @retval OSALKFILE_E_INVALIDARG NULL provided for argument
                                           fileHandle. */
        status = OSALKFILE_E_INVALIDARG;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalKfile_close",
                             status,
                             "NULL provided for argument fileHandle");
    }
    else if (*fileHandle == NULL) {
        /*! @retval OSALKFILE_E_HANDLE NULL file handle provided. */
        status = OSALKFILE_E_HANDLE;
        GT_setFailureReason (curTrace,
                             GT_4CLASS,
                             "OsalKfile_close",
                             status,
                             "NULL file handle provided.");
    }
    else {
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */
        fileObject = (OsalKfile_Object *) *fileHandle;
        fs = get_fs();
        set_fs (KERNEL_DS);
        filp_close (fileObject->fileDesc, NULL);
        set_fs (fs);
        Memory_free (NULL, fileObject, sizeof(OsalKfile_Object));

        /* Reset user's file handle pointer. */
        *fileHandle = NULL;
#if !defined(SYSLINK_BUILD_OPTIMIZE)
    }
#endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */

    GT_1trace (curTrace, GT_LEAVE, "OsalKfile_close", status);

    /*! @retval OSALKFILE_SUCCESS Operation successfully completed. */
    return status;
}