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; }
/* Function to write back invalidate the Cache module */ Void Cache_wbInv(Ptr blockPtr, UInt32 byteCnt, Bits16 type, Bool wait) { GT_4trace (curTrace, GT_ENTER, "Cache_wbInv", blockPtr, byteCnt, type, wait); #if 0 /* * It appears that this #if 0'ed code doesn't actually perform the * invalidate part of the wbInv, and it appears that Cache_wb() and Cache_inv() * work properly, so for now we implement wbInv as a combination of the two * individual functions. */ #ifdef USE_CACHE_VOID_ARG #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34) dmac_map_area(blockPtr, (size_t)byteCnt, DMA_BIDIRECTIONAL); outer_flush_range(__pa((UInt32)blockPtr), __pa((UInt32)(blockPtr+byteCnt)) ); #else dmac_flush_range(blockPtr, (blockPtr+byteCnt) ); #endif #else dmac_flush_range( (UInt32)blockPtr, (UInt32)(blockPtr + byteCnt) ); #endif #else Cache_wb(blockPtr, byteCnt, type, wait); Cache_inv(blockPtr, byteCnt, type, wait); #endif GT_0trace (curTrace, GT_LEAVE, "Cache_wbInv"); }
/* * ======== STRM_Issue ======== * Purpose: * Issues a buffer on a stream */ DSP_STATUS STRM_Issue(struct STRM_OBJECT *hStrm, IN u8 *pBuf, u32 ulBytes, u32 ulBufSize, u32 dwArg) { struct WMD_DRV_INTERFACE *pIntfFxns; DSP_STATUS status = DSP_SOK; void *pTmpBuf = NULL; DBC_Require(cRefs > 0); DBC_Require(pBuf != NULL); GT_4trace(STRM_debugMask, GT_ENTER, "STRM_Issue: hStrm: 0x%x\tpBuf: " "0x%x\tulBytes: 0x%x\tdwArg: 0x%x\n", hStrm, pBuf, ulBytes, dwArg); pIntfFxns = hStrm->hStrmMgr->pIntfFxns; if (hStrm->uSegment != 0) { pTmpBuf = CMM_XlatorTranslate(hStrm->hXlator, (void *)pBuf, CMM_VA2DSPPA); if (pTmpBuf == NULL) status = DSP_ETRANSLATE; } if (DSP_SUCCEEDED(status)) { status = (*pIntfFxns->pfnChnlAddIOReq) (hStrm->hChnl, pBuf, ulBytes, ulBufSize, (u32) pTmpBuf, dwArg); } if (status == CHNL_E_NOIORPS) status = DSP_ESTREAMFULL; return status; }
/* * ======== COD_ReadSection ======== * Purpose: * Retrieve the content of a code section given the section name. */ DSP_STATUS COD_ReadSection(struct COD_LIBRARYOBJ *lib, IN char *pstrSect, OUT char *pstrContent, IN u32 cContentSize) { DSP_STATUS status = DSP_SOK; DBC_Require(cRefs > 0); DBC_Require(lib != NULL); DBC_Require(IsValid(lib->hCodMgr)); DBC_Require(pstrSect != NULL); DBC_Require(pstrContent != NULL); GT_4trace(COD_debugMask, GT_ENTER, "Entered COD_ReadSection Args: 0x%x," " 0x%x, 0x%x, 0x%x\n", lib, pstrSect, pstrContent, cContentSize); if (lib != NULL) { status = lib->hCodMgr->fxns.readSectFxn(lib->dbllLib, pstrSect, pstrContent, cContentSize); if (DSP_FAILED(status)) { GT_1trace(COD_debugMask, GT_7CLASS, "COD_ReadSection failed: 0x%lx\n", status); } } else { status = COD_E_NOSYMBOLSLOADED; GT_0trace(COD_debugMask, GT_7CLASS, "COD_ReadSection: No Symbols loaded\n"); } return status; }
/* * ======== PROCWRAP_EnumResources ======== */ u32 PROCWRAP_EnumResources(union Trapped_Args *args, void *pr_ctxt) { DSP_STATUS status = DSP_SOK; struct DSP_RESOURCEINFO pResourceInfo; if (DSP_FAILED(status)) goto func_end; GT_4trace(WCD_debugMask, GT_ENTER, "PROCWRAP_EnumResources: entered args:\n" "0x%x hProcessor: 0x%x\tuResourceMask: 0x%x\tpResourceInfo" " 0x%x\tuResourceInfoSixe \n", args->ARGS_PROC_ENUMRESOURCES.hProcessor, args->ARGS_PROC_ENUMRESOURCES.uResourceType, args->ARGS_PROC_ENUMRESOURCES.pResourceInfo, args->ARGS_PROC_ENUMRESOURCES.uResourceInfoSize); status = PROC_GetResourceInfo(args->ARGS_PROC_ENUMRESOURCES.hProcessor, args->ARGS_PROC_ENUMRESOURCES.uResourceType, &pResourceInfo, args->ARGS_PROC_ENUMRESOURCES.uResourceInfoSize); if (DSP_FAILED(status)) goto func_end; cp_to_usr(args->ARGS_PROC_ENUMRESOURCES.pResourceInfo, &pResourceInfo, status, 1); func_end: return status; }
/* Function to write configuration information to Ipc module */ Int Ipc_writeConfig (UInt16 remoteProcId, UInt32 tag, Ptr cfg, SizeT size) { Int status = Ipc_S_SUCCESS; IpcDrv_CmdArgs cmdArgs; GT_4trace (curTrace, GT_ENTER, "Ipc_writeConfig", remoteProcId, tag, cfg, size); cmdArgs.args.writeConfig.remoteProcId = remoteProcId; cmdArgs.args.writeConfig.tag = tag; cmdArgs.args.writeConfig.cfg = cfg; cmdArgs.args.writeConfig.size = size; status = IpcDrv_ioctl (CMD_IPC_WRITECONFIG, &cmdArgs); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (status < 0) { GT_setFailureReason (curTrace, GT_4CLASS, "Ipc_writeConfig", status, "API (through IOCTL) failed on kernel-side!"); } #endif /* if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_1trace (curTrace, GT_LEAVE, "Ipc_writeConfig", status); /*! @retval Ipc_S_SUCCESS Operation was successful */ return status; }
/* * ======== MGRWRAP_EnumProc_Info ======== */ u32 MGRWRAP_EnumProc_Info(union Trapped_Args *args, void *pr_ctxt) { u8 *pProcessorInfo; u32 uNumProcs; DSP_STATUS status = DSP_SOK; u32 size = args->ARGS_MGR_ENUMPROC_INFO.uProcessorInfoSize; GT_4trace(WCD_debugMask, GT_ENTER, "MGRWRAP_EnumProc_Info: entered args:\n" "0x%x uProcessor: 0x%x\tpProcessorInfo: 0x%x\t" "uProcessorInfoSize: 0x%x\tpuNumProcs \n", args->ARGS_MGR_ENUMPROC_INFO.uProcessor, args->ARGS_MGR_ENUMPROC_INFO.pProcessorInfo, args->ARGS_MGR_ENUMPROC_INFO.uProcessorInfoSize, args->ARGS_MGR_ENUMPROC_INFO.puNumProcs); pProcessorInfo = MEM_Alloc(size, MEM_NONPAGED); if (pProcessorInfo == NULL) status = DSP_EMEMORY; if (DSP_SUCCEEDED(status)) { status = MGR_EnumProcessorInfo(args-> ARGS_MGR_ENUMPROC_INFO.uProcessor, (struct DSP_PROCESSORINFO *)pProcessorInfo, size, &uNumProcs); } cp_to_usr(args->ARGS_MGR_ENUMPROC_INFO.pProcessorInfo, pProcessorInfo, status, size); cp_to_usr(args->ARGS_MGR_ENUMPROC_INFO.puNumProcs, &uNumProcs, status, 1); if (pProcessorInfo) MEM_Free(pProcessorInfo); return status; }
/* * ======== MGRWRAP_EnumNode_Info ======== */ u32 MGRWRAP_EnumNode_Info(union Trapped_Args *args, void *pr_ctxt) { u8 *pNDBProps; u32 uNumNodes; DSP_STATUS status = DSP_SOK; u32 size = args->ARGS_MGR_ENUMNODE_INFO.uNDBPropsSize; GT_4trace(WCD_debugMask, GT_ENTER, "MGR_EnumNodeInfo: entered args:\n0x%x" " uNode: 0x%x\tpNDBProps: 0x%x\tuNDBPropsSize: " "0x%x\tpuNumNodes\n", args->ARGS_MGR_ENUMNODE_INFO.uNode, args->ARGS_MGR_ENUMNODE_INFO.pNDBProps, args->ARGS_MGR_ENUMNODE_INFO.uNDBPropsSize, args->ARGS_MGR_ENUMNODE_INFO.puNumNodes); pNDBProps = MEM_Alloc(size, MEM_NONPAGED); if (pNDBProps == NULL) status = DSP_EMEMORY; if (DSP_SUCCEEDED(status)) { status = MGR_EnumNodeInfo(args->ARGS_MGR_ENUMNODE_INFO.uNode, (struct DSP_NDBPROPS *)pNDBProps, size, &uNumNodes); } cp_to_usr(args->ARGS_MGR_ENUMNODE_INFO.pNDBProps, pNDBProps, status, size); cp_to_usr(args->ARGS_MGR_ENUMNODE_INFO.puNumNodes, &uNumNodes, status, 1); if (pNDBProps) MEM_Free(pNDBProps); return status; }
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; }
Int32 decodeIssue(AUDDEC1_Handle dec, int in, int out) { Int32 status; #ifdef CACHE_ENABLED /* Per DMA Rule 7, our output buffer cache lines must be cleaned */ Memory_cacheInv(outBuf[out], OFRAMESIZE); #endif /* decode the frame */ decInArgs[in].numBytes = EFRAMESIZE; 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_processAsync(dec, &encodedBufDesc[in], &outBufDesc[out], &decInArgs[in], &decOutArgs[out]); GT_1trace(curMask, GT_2CLASS, "App-> Decoder processAsync returned 0x%x\n", status); if (status != AUDDEC1_EOK) { GT_0trace(curMask, GT_7CLASS, "App-> Decoder processing FAILED\n"); } return status; }
/* Function to allocate the specified number of bytes and memory is set to * the specified value. */ Ptr Memory_valloc (IHeap_Handle heap, SizeT size, SizeT align, Char value, Ptr eb) { Ptr buffer = NULL; GT_4trace (curTrace, GT_ENTER, "Memory_valloc", heap, size, align, eb); /* Check whether the right paramaters are passed or not.*/ GT_assert (curTrace, (size > 0)); (Void) eb; /* Not used. */ if (heap == NULL) { buffer = MemoryOS_alloc (size, align, 0); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Failed to allocate memory */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "Failed to allocate memory!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } else { buffer = IHeap_alloc (heap, size, align); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Heap_alloc failed */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "IHeap_alloc failed!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer != NULL) { #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ buffer = Memory_set (buffer, value, size); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Memory_set to 0 failed */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_valloc", Memory_E_MEMORY, "Memory_set to 0 failed!"); } } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ GT_0trace (curTrace, GT_LEAVE, "Memory_valloc"); /*! @retval Pointer Success: Pointer to allocated buffer */ return buffer; }
Int32 encodeIssue(AUDENC1_Handle enc, int in, int out) { Int32 status; #if USE_ANCDATA /* we send the same data as inBuf as ancillory data */ memcpy(ancBuf[in], inBuf[in], ENCANCBUFSIZE); #endif /* Deal with cache issues, if necessary */ #ifdef CACHE_ENABLED #ifdef xdc_target__isaCompatible_64P /* * fread() on this processor is implemented using CCS's stdio, which * is known to write into the cache, not physical memory. To meet * xDAIS DMA Rule 7, we must writeback the cache into physical * memory. Also, per DMA Rule 7, we must invalidate the buffer's * cache before providing it to any xDAIS algorithm. */ Memory_cacheWbInv(inBuf[in], IFRAMESIZE); #else #error Unvalidated config - add appropriate fread-related cache maintenance #endif #if USE_ANCDATA /* ancBuf is an inBuf, filled via memcpy (i.e. CPU writes) */ Memory_cacheWbInv(ancBuf[in], ENCANCBUFSIZE); #endif /* Per DMA Rule 7, our output buffer cache lines must be cleaned */ Memory_cacheInv(encodedBuf[out], EFRAMESIZE); #endif 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); /* * Encode the frame. Note that .numInSamples is the number of * _samples_ not bytes. IFRAMESIZE is in 8-bit bytes, so there's a * little math here to get .numInSamples right. */ encInArgs[in].numInSamples = (IFRAMESIZE / (ENCBITSPERSAMPLE / (8 /* bits per byte */))); status = AUDENC1_processAsync(enc, &inBufDesc[in], &encodedBufDesc[out], &encInArgs[in], &encOutArgs[out]); GT_1trace(curMask, GT_2CLASS, "App-> Encoder processAsync returned 0x%x\n", status); if (status != AUDENC1_EOK) { GT_0trace(curMask, GT_7CLASS, "App-> Encodcer processing FAILED\n"); } return status; }
/* * ======== VIDDECCOPY_TI_control ======== */ XDAS_Int32 VIDDECCOPY_TI_control(IVIDDEC_Handle handle, IVIDDEC_Cmd id, IVIDDEC_DynamicParams *params, IVIDDEC_Status *status) { XDAS_Int32 retVal; GT_4trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_control(0x%lx, 0x%lx, 0x%lx, " "0x%lx)\n", handle, id, params, status); /* validate arguments - this codec only supports "base" xDM. */ if ((params->size != sizeof(*params)) || (status->size != sizeof(*status))) { GT_2trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_control, unsupported size " "(0x%lx, 0x%lx)\n", params->size, status->size); return (IVIDDEC_EFAIL); } switch (id) { case XDM_GETSTATUS: status->extendedError = 0; status->outputHeight = 0; /* TODO */ status->outputWidth = 0; /* TODO */ status->frameRate = 0; /* TODO */ status->bitRate = 0; /* TODO */ status->contentType = 0; /* TODO */ status->outputChromaFormat = 0; /* TODO */ /* Note, intentionally no break here so we fill in bufInfo, too */ case XDM_GETBUFINFO: status->bufInfo.minNumInBufs = MININBUFS; status->bufInfo.minNumOutBufs = MINOUTBUFS; status->bufInfo.minInBufSize[0] = MININBUFSIZE; status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE; retVal = IVIDDEC_EOK; break; case XDM_SETPARAMS: case XDM_SETDEFAULT: case XDM_RESET: case XDM_FLUSH: /* TODO - for now just return success. */ retVal = IVIDDEC_EOK; break; default: /* unsupported cmd */ retVal = IVIDDEC_EFAIL; break; } return (retVal); }
/* * ======== VIDDECCOPY_TI_initObj ======== */ Int VIDDECCOPY_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[], IALG_Handle p, const IALG_Params *algParams) { GT_4trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_initObj(0x%lx, 0x%lx, 0x%lx, " "0x%lx)\n", handle, memTab, p, algParams); return (IALG_EOK); }
/* * ======== DBLL_getSect ======== * Get the base address and size (in bytes) of a COFF section. */ DSP_STATUS DBLL_getSect(struct DBLL_LibraryObj *lib, char *name, u32 *pAddr, u32 *pSize) { u32 uByteSize; bool fOpenedDoff = false; const struct LDR_SECTION_INFO *sect = NULL; struct DBLL_LibraryObj *zlLib = (struct DBLL_LibraryObj *)lib; DSP_STATUS status = DSP_SOK; DBC_Require(cRefs > 0); DBC_Require(name != NULL); DBC_Require(pAddr != NULL); DBC_Require(pSize != NULL); DBC_Require(MEM_IsValidHandle(zlLib, DBLL_LIBSIGNATURE)); GT_4trace(DBLL_debugMask, GT_ENTER, "DBLL_getSect: lib: 0x%x name: %s pAddr:" " 0x%x pSize: 0x%x\n", lib, name, pAddr, pSize); /* If DOFF file is not open, we open it. */ if (zlLib != NULL) { if (zlLib->fp == NULL) { status = dofOpen(zlLib); if (DSP_SUCCEEDED(status)) fOpenedDoff = true; } else { (*(zlLib->pTarget->attrs.fseek))(zlLib->fp, zlLib->ulPos, SEEK_SET); } } else { status = DSP_EHANDLE; } if (DSP_SUCCEEDED(status)) { uByteSize = 1; if (DLOAD_GetSectionInfo(zlLib->desc, name, §)) { *pAddr = sect->load_addr; *pSize = sect->size * uByteSize; /* Make sure size is even for good swap */ if (*pSize % 2) (*pSize)++; /* Align size */ *pSize = DOFF_ALIGN(*pSize); } else { status = DSP_ENOSECT; } } if (fOpenedDoff) { dofClose(zlLib); fOpenedDoff = false; } return status; }
/* * ======== VIDDECCOPY_TI_initObj ======== */ Int VIDDECCOPY_TI_initObj(IALG_Handle handle, const IALG_MemRec memTab[], IALG_Handle p, const IALG_Params *algParams) { GT_4trace(curTrace, GT_ENTER, "VIDDECCOPY_TI_initObj(0x%lx, 0x%lx, 0x%lx, " "0x%lx)\n", handle, memTab, p, algParams); // VIDENCCOPY_TI_Obj *VIDENC_COPY = (Void *)handle; // ((VIDDECCOPY_TI_Obj *)handle)->pGray = memTab[1].base; return (IALG_EOK); }
/* * ======== VIDENCCOPY_TI_control ======== */ XDAS_Int32 VIDENCCOPY_TI_control(IVIDENC_Handle handle, IVIDENC_Cmd id, IVIDENC_DynamicParams *params, IVIDENC_Status *status) { XDAS_Int32 retVal; GT_4trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_control(0x%x, 0x%x, 0x%x, " "0x%x)\n", handle, id, params, status); /* validate arguments - this codec only supports "base" xDM. */ if ((params->size != sizeof(*params)) || (status->size != sizeof(*status))) { GT_2trace(curTrace, GT_ENTER, "VIDENCCOPY_TI_control, unsupported size " "(0x%x, 0x%x)\n", params->size, status->size); return (IVIDENC_EFAIL); } switch (id) { case XDM_GETSTATUS: case XDM_GETBUFINFO: status->extendedError = 0; status->bufInfo.minNumInBufs = MININBUFS; status->bufInfo.minNumOutBufs = MINOUTBUFS; status->bufInfo.minInBufSize[0] = MININBUFSIZE; status->bufInfo.minOutBufSize[0] = MINOUTBUFSIZE; retVal = IVIDENC_EOK; break; case XDM_SETPARAMS: case XDM_SETDEFAULT: case XDM_RESET: case XDM_FLUSH: /* TODO - for now just return success. */ retVal = IVIDENC_EOK; break; default: /* unsupported cmd */ retVal = IVIDENC_EFAIL; break; } return (retVal); }
/* * ======== KFILE_Read ======== * Purpose: * Reads a specified number of bytes into a buffer. */ s32 KFILE_Read(void __user*pBuffer, s32 cSize, s32 cCount, struct KFILE_FileObj *hFile) { u32 dwBytesRead = 0; s32 cRetVal = 0; mm_segment_t fs; DBC_Require(pBuffer != NULL); GT_4trace(KFILE_debugMask, GT_4CLASS, "KFILE_Read: buffer 0x%x, cSize 0x%x," "cCount 0x%x, hFile 0x%x\n", pBuffer, cSize, cCount, hFile); /* check for valid file handle */ if (MEM_IsValidHandle(hFile, SIGNATURE)) { if ((cSize > 0) && (cCount > 0) && pBuffer) { /* read from file */ fs = get_fs(); set_fs(get_ds()); dwBytesRead = hFile->fileDesc->f_op->read(hFile-> fileDesc, pBuffer, cSize *cCount, &(hFile->fileDesc->f_pos)); set_fs(fs); if (dwBytesRead) { cRetVal = dwBytesRead / cSize; hFile->curPos += dwBytesRead; DBC_Assert((dwBytesRead / cSize) <= \ (u32)cCount); } else { cRetVal = E_KFILE_ERROR; GT_0trace(KFILE_debugMask, GT_6CLASS, "KFILE_Read: sys_read() failed\n"); } } else { cRetVal = DSP_EINVALIDARG; GT_0trace(KFILE_debugMask, GT_6CLASS, "KFILE_Read: Invalid argument(s)\n"); } } else { cRetVal = E_KFILE_INVALIDHANDLE; GT_0trace(KFILE_debugMask, GT_6CLASS, "KFILE_Read: invalid file handle\n"); } return cRetVal; }
/* Allocates the specified number of bytes. */ Ptr Memory_alloc (IHeap_Handle heap, SizeT size, SizeT align, Ptr eb) { Ptr buffer = NULL; GT_4trace (curTrace, GT_ENTER, "Memory_alloc", heap, size, align, eb); /* check whether the right paramaters are passed or not.*/ GT_assert (curTrace, (size > 0)); (Void) eb; /* Not used. */ if (heap == NULL) { /* Call the kernel API for memory allocation */ buffer = MemoryOS_alloc (size, align, 0); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { GT_setFailureReason (curTrace, GT_4CLASS, "Memory_alloc", Memory_E_MEMORY, "Failed to allocate memory!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } else { /* if align == 0, use default alignment */ if (align == 0) { align = Memory_getMaxDefaultTypeAlign (); } buffer = IHeap_alloc (heap, size, align); #if !defined(SYSLINK_BUILD_OPTIMIZE) if (buffer == NULL) { /*! @retval NULL Heap_alloc failed */ GT_setFailureReason (curTrace, GT_4CLASS, "Memory_alloc", Memory_E_MEMORY, "IHeap_alloc failed!"); } #endif /* #if !defined(SYSLINK_BUILD_OPTIMIZE) */ } GT_1trace (curTrace, GT_LEAVE, "Memory_alloc", buffer); return buffer; }
/* Function to invalidate the Cache module */ Void Cache_inv(Ptr blockPtr, UInt32 byteCnt, Bits16 type, Bool wait) { GT_4trace (curTrace, GT_ENTER, "Cache_inv", blockPtr, byteCnt, type, wait); #ifdef USE_CACHE_VOID_ARG #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) dmac_map_area(blockPtr, (size_t)byteCnt, DMA_FROM_DEVICE); outer_inv_range(__pa((UInt32)blockPtr), __pa((UInt32)(blockPtr + byteCnt)) ); #else dmac_inv_range(blockPtr, (blockPtr + byteCnt) ); #endif #else dmac_inv_range( (UInt32)blockPtr, (UInt32)(blockPtr + byteCnt) ); #endif GT_0trace (curTrace, GT_LEAVE, "Cache_inv"); }
/* * ======== ACPY3_deInitEnv ======== */ static Bool ACPY3_deInitEnv(IDMA3_Handle handle) { Void *scratchEnv; GT_1trace(ti_sdo_fc_acpy3_GTMask, GT_ENTER, "ACPY3_deInitEnv > Enter (handle=0x%x)\n", handle); DBC_require(handle->protocol == &ACPY3_PROTOCOL); scratchEnv = ((ACPY3_MoreEnv *)(handle->env))->scratchEnv; if (scratchEnv != NULL) { scratchEnv = (Void *)((Uns)scratchEnv - handle->numPaRams * PARAMSIZE); GT_1trace(ti_sdo_fc_acpy3_GTMask, GT_2CLASS, "ACPY3_deInitEnv> " "ScratchEnv is 0x%x\n", scratchEnv); } /* * Restore original values of numTccs and numPaRams, since * ACPY3_setFinal() may have changed them. */ handle->numTccs = ((ACPY3_MoreEnv *)(handle->env))->numTccs; handle->numPaRams = ((ACPY3_MoreEnv *)(handle->env))->numPaRams; /* Restore env pointer */ handle->env = (Void *)((Uns)handle->env - handle->numPaRams * PARAMSIZE); /* Restore scratch env pointer */ *((unsigned *)(handle->env)) = (unsigned)scratchEnv; GT_4trace(ti_sdo_fc_acpy3_GTMask, GT_2CLASS, "ACPY3_deInitEnv> Restoring " "original values in IDMA3 handle back to %d Tccs %d PaRams, " "env 0x%x scratch env 0x%x\n", handle->numTccs, handle->numPaRams, handle->env, scratchEnv); _ACPY3_exit(); GT_0trace(ti_sdo_fc_acpy3_GTMask, GT_ENTER, "ACPY3_deInitEnv > Enter " "(status=TRUE)\n"); return (TRUE); }
/* * ======== ACPY3_fastConfigure32b ======== */ Void ACPY3_fastConfigure32b(IDMA3_Handle restrict handle, ACPY3_ParamField32b fieldId, Uns value, short transferNo) { ACPY3_PaRamRegs * paRamCache; #ifndef _ACPY3_CPUCOPY_ UInt32 physVal; Int size; #endif GT_assert(CURTRACE, handle != NULL); GT_assert(CURTRACE, handle->protocol == &ACPY3_PROTOCOL); GT_assert(CURTRACE, transferNo >= 0); GT_assert(CURTRACE, transferNo < ((ACPY3_MoreEnv *)(handle->env))->numPaRams); GT_assert(CURTRACE, !handle->transferPending); GT_4trace(CURTRACE, GT_ENTER, "ACPY3_fastConfigure32b> " "Enter (handle=0x%x, fieldId=0x%x, value=0x%x, transferNo=%d)\n", handle, fieldId, value, transferNo); paRamCache = (ACPY3_PaRamRegs *)ACPY3_getPaRamCache(handle, transferNo); #ifndef _ACPY3_CPUCOPY_ /* Address fields must be converted to physical address */ size = 4; /* Otherwise we have to read the registers */ if ((fieldId == ACPY3_PARAMFIELD_SRCADDR) || (fieldId == ACPY3_PARAMFIELD_DSTADDR)) { physVal = (UInt32)MEMUTILS_getPhysicalAddr((Ptr)value); *((Uns *)((Uns)paRamCache + fieldId)) = physVal; } else { /* Non-address field */ *((Uns *)((Uns)paRamCache + fieldId)) = value; } #else *((Uns *)((Uns)paRamCache + fieldId)) = value; #endif GT_0trace(CURTRACE, GT_ENTER, "ACPY3_fastConfigure32b> Exit\n"); }
/* * ======== COD_Open ======== * Open library for reading sections. */ DSP_STATUS COD_Open(struct COD_MANAGER *hMgr, IN char *pszCoffPath, COD_FLAGS flags, struct COD_LIBRARYOBJ **pLib) { DSP_STATUS status = DSP_SOK; struct COD_LIBRARYOBJ *lib = NULL; DBC_Require(cRefs > 0); DBC_Require(IsValid(hMgr)); DBC_Require(pszCoffPath != NULL); DBC_Require(flags == COD_NOLOAD || flags == COD_SYMB); DBC_Require(pLib != NULL); GT_4trace(COD_debugMask, GT_ENTER, "Entered COD_Open, hMgr: 0x%x\n\t " "pszCoffPath: 0x%x\tflags: 0x%x\tlib: 0x%x\n", hMgr, pszCoffPath, flags, pLib); *pLib = NULL; lib = MEM_Calloc(sizeof(struct COD_LIBRARYOBJ), MEM_NONPAGED); if (lib == NULL) { GT_0trace(COD_debugMask, GT_7CLASS, "COD_Open: Out Of Memory\n"); status = DSP_EMEMORY; } if (DSP_SUCCEEDED(status)) { lib->hCodMgr = hMgr; status = hMgr->fxns.openFxn(hMgr->target, pszCoffPath, flags, &lib->dbllLib); if (DSP_FAILED(status)) { GT_1trace(COD_debugMask, GT_7CLASS, "COD_Open failed: 0x%x\n", status); } else { *pLib = lib; } } return status; }
/* * ======== COD_GetSection ======== * Purpose: * Retrieve the starting address and length of a section in the COFF file * given the section name. */ DSP_STATUS COD_GetSection(struct COD_LIBRARYOBJ *lib, IN char *pstrSect, OUT u32 *puAddr, OUT u32 *puLen) { struct COD_MANAGER *hManager; DSP_STATUS status = DSP_SOK; DBC_Require(cRefs > 0); DBC_Require(lib != NULL); DBC_Require(IsValid(lib->hCodMgr)); DBC_Require(pstrSect != NULL); DBC_Require(puAddr != NULL); DBC_Require(puLen != NULL); GT_4trace(COD_debugMask, GT_ENTER, "Entered COD_GetSection Args \t\n lib: " "0x%x\t\npstrsect: 0x%x\t\npuAddr: 0x%x\t\npuLen: 0x%x\n", lib, pstrSect, puAddr, puLen); *puAddr = 0; *puLen = 0; if (lib != NULL) { hManager = lib->hCodMgr; status = hManager->fxns.getSectFxn(lib->dbllLib, pstrSect, puAddr, puLen); if (DSP_FAILED(status)) { GT_1trace(COD_debugMask, GT_7CLASS, "COD_GetSection: Section %s not" "found\n", pstrSect); } } else { status = COD_E_NOSYMBOLSLOADED; GT_0trace(COD_debugMask, GT_7CLASS, "COD_GetSection:No Symbols loaded\n"); } DBC_Ensure(DSP_SUCCEEDED(status) || ((*puAddr == 0) && (*puLen == 0))); return status; }
/* * ======== STRM_RegisterNotify ======== * Purpose: * Register to be notified on specific events for this stream. */ DSP_STATUS STRM_RegisterNotify(struct STRM_OBJECT *hStrm, u32 uEventMask, u32 uNotifyType, struct DSP_NOTIFICATION *hNotification) { struct WMD_DRV_INTERFACE *pIntfFxns; DSP_STATUS status = DSP_SOK; DBC_Require(cRefs > 0); DBC_Require(hNotification != NULL); GT_4trace(STRM_debugMask, GT_ENTER, "STRM_RegisterNotify: hStrm: 0x%x\t" "uEventMask: 0x%x\tuNotifyType: 0x%x\thNotification: 0x%x\n", hStrm, uEventMask, uNotifyType, hNotification); if (!MEM_IsValidHandle(hStrm, STRM_SIGNATURE)) { status = DSP_EHANDLE; } else if ((uEventMask & ~((DSP_STREAMIOCOMPLETION) | DSP_STREAMDONE)) != 0) { status = DSP_EVALUE; } else { if (uNotifyType != DSP_SIGNALEVENT) status = DSP_ENOTIMPL; } if (DSP_SUCCEEDED(status)) { pIntfFxns = hStrm->hStrmMgr->pIntfFxns; status = (*pIntfFxns->pfnChnlRegisterNotify)(hStrm->hChnl, uEventMask, uNotifyType, hNotification); } /* ensure we return a documented return code */ DBC_Ensure(DSP_SUCCEEDED(status) || status == DSP_EHANDLE || status == DSP_ETIMEOUT || status == DSP_ETRANSLATE || status == DSP_ENOTIMPL || status == DSP_EFAIL); return status; }
/* * ======== STRM_Select ======== * Purpose: * Selects a ready stream. */ DSP_STATUS STRM_Select(IN struct STRM_OBJECT **aStrmTab, u32 nStrms, OUT u32 *pMask, u32 uTimeout) { u32 uIndex; struct CHNL_INFO chnlInfo; struct WMD_DRV_INTERFACE *pIntfFxns; struct SYNC_OBJECT **hSyncEvents = NULL; u32 i; DSP_STATUS status = DSP_SOK; DBC_Require(cRefs > 0); DBC_Require(aStrmTab != NULL); DBC_Require(pMask != NULL); DBC_Require(nStrms > 0); GT_4trace(STRM_debugMask, GT_ENTER, "STRM_Select: aStrmTab: 0x%x \tnStrms: " "0x%x\tpMask: 0x%x\tuTimeout: 0x%x\n", aStrmTab, nStrms, pMask, uTimeout); *pMask = 0; for (i = 0; i < nStrms; i++) { if (!MEM_IsValidHandle(aStrmTab[i], STRM_SIGNATURE)) { status = DSP_EHANDLE; break; } } if (DSP_FAILED(status)) goto func_end; /* Determine which channels have IO ready */ for (i = 0; i < nStrms; i++) { pIntfFxns = aStrmTab[i]->hStrmMgr->pIntfFxns; status = (*pIntfFxns->pfnChnlGetInfo)(aStrmTab[i]->hChnl, &chnlInfo); if (DSP_FAILED(status)) { break; } else { if (chnlInfo.cIOCs > 0) *pMask |= (1 << i); } } if (DSP_SUCCEEDED(status) && uTimeout > 0 && *pMask == 0) { /* Non-zero timeout */ hSyncEvents = (struct SYNC_OBJECT **)MEM_Alloc(nStrms * sizeof(struct SYNC_OBJECT *), MEM_PAGED); if (hSyncEvents == NULL) { status = DSP_EMEMORY; } else { for (i = 0; i < nStrms; i++) { pIntfFxns = aStrmTab[i]->hStrmMgr->pIntfFxns; status = (*pIntfFxns->pfnChnlGetInfo) (aStrmTab[i]->hChnl, &chnlInfo); if (DSP_FAILED(status)) break; else hSyncEvents[i] = chnlInfo.hSyncEvent; } } if (DSP_SUCCEEDED(status)) { status = SYNC_WaitOnMultipleEvents(hSyncEvents, nStrms, uTimeout, &uIndex); if (DSP_SUCCEEDED(status)) { /* Since we waited on the event, we have to * reset it */ SYNC_SetEvent(hSyncEvents[uIndex]); *pMask = 1 << uIndex; } } } func_end: if (hSyncEvents) MEM_Free(hSyncEvents); DBC_Ensure((DSP_SUCCEEDED(status) && (*pMask != 0 || uTimeout == 0)) || (DSP_FAILED(status) && *pMask == 0)); return status; }
/* * ======== STRM_Reclaim ======== * Purpose: * Relcaims a buffer from a stream. */ DSP_STATUS STRM_Reclaim(struct STRM_OBJECT *hStrm, OUT u8 **pBufPtr, u32 *pulBytes, u32 *pulBufSize, u32 *pdwArg) { struct WMD_DRV_INTERFACE *pIntfFxns; struct CHNL_IOC chnlIOC; DSP_STATUS status = DSP_SOK; void *pTmpBuf = NULL; DBC_Require(cRefs > 0); DBC_Require(pBufPtr != NULL); DBC_Require(pulBytes != NULL); DBC_Require(pdwArg != NULL); GT_4trace(STRM_debugMask, GT_ENTER, "STRM_Reclaim: hStrm: 0x%x\tpBufPtr: 0x%x" "\tpulBytes: 0x%x\tpdwArg: 0x%x\n", hStrm, pBufPtr, pulBytes, pdwArg); if (!MEM_IsValidHandle(hStrm, STRM_SIGNATURE)) { status = DSP_EHANDLE; goto func_end; } pIntfFxns = hStrm->hStrmMgr->pIntfFxns; status = (*pIntfFxns->pfnChnlGetIOC)(hStrm->hChnl, hStrm->uTimeout, &chnlIOC); if (DSP_FAILED(status)) { GT_1trace(STRM_debugMask, GT_6CLASS, "STRM_Reclaim: GetIOC failed! " "Status = 0x%x\n", status); } else { *pulBytes = chnlIOC.cBytes; if (pulBufSize) *pulBufSize = chnlIOC.cBufSize; *pdwArg = chnlIOC.dwArg; if (!CHNL_IsIOComplete(chnlIOC)) { if (CHNL_IsTimedOut(chnlIOC)) { status = DSP_ETIMEOUT; } else { /* Allow reclaims after idle to succeed */ if (!CHNL_IsIOCancelled(chnlIOC)) status = DSP_EFAIL; } } /* Translate zerocopy buffer if channel not canceled. */ if (DSP_SUCCEEDED(status) && (!CHNL_IsIOCancelled(chnlIOC)) && (hStrm->lMode == STRMMODE_ZEROCOPY)) { /* * This is a zero-copy channel so chnlIOC.pBuf * contains the DSP address of SM. We need to * translate it to a virtual address for the user * thread to access. * Note: Could add CMM_DSPPA2VA to CMM in the future. */ pTmpBuf = CMM_XlatorTranslate(hStrm->hXlator, chnlIOC.pBuf, CMM_DSPPA2PA); if (pTmpBuf != NULL) { /* now convert this GPP Pa to Va */ pTmpBuf = CMM_XlatorTranslate(hStrm->hXlator, pTmpBuf, CMM_PA2VA); } if (pTmpBuf == NULL) { GT_0trace(STRM_debugMask, GT_7CLASS, "STRM_Reclaim: Failed " "SM translation!\n"); status = DSP_ETRANSLATE; } chnlIOC.pBuf = pTmpBuf; } *pBufPtr = chnlIOC.pBuf; } func_end: /* ensure we return a documented return code */ DBC_Ensure(DSP_SUCCEEDED(status) || status == DSP_EHANDLE || status == DSP_ETIMEOUT || status == DSP_ETRANSLATE || status == DSP_EFAIL); return status; }
/* * ======== STRM_AllocateBuffer ======== * Purpose: * Allocates buffers for a stream. */ DSP_STATUS STRM_AllocateBuffer(struct STRM_OBJECT *hStrm, u32 uSize, OUT u8 **apBuffer, u32 uNumBufs) { DSP_STATUS status = DSP_SOK; u32 uAllocated = 0; u32 i; #ifndef RES_CLEANUP_DISABLE DSP_STATUS res_status = DSP_SOK; u32 hProcess; HANDLE pCtxt = NULL; HANDLE hDrvObject; HANDLE hSTRMRes; #endif DBC_Require(cRefs > 0); DBC_Require(apBuffer != NULL); GT_4trace(STRM_debugMask, GT_ENTER, "STRM_AllocateBuffer: hStrm: 0x%x\t" "uSize: 0x%x\tapBuffer: 0x%x\tuNumBufs: 0x%x\n", hStrm, uSize, apBuffer, uNumBufs); if (MEM_IsValidHandle(hStrm, STRM_SIGNATURE)) { /* * Allocate from segment specified at time of stream open. */ if (uSize == 0) status = DSP_ESIZE; } if (DSP_FAILED(status)) { status = DSP_EHANDLE; goto func_end; } for (i = 0; i < uNumBufs; i++) { DBC_Assert(hStrm->hXlator != NULL); (void)CMM_XlatorAllocBuf(hStrm->hXlator, &apBuffer[i], uSize); if (apBuffer[i] == NULL) { GT_0trace(STRM_debugMask, GT_7CLASS, "STRM_AllocateBuffer: " "DSP_FAILED to alloc shared memory.\n"); status = DSP_EMEMORY; uAllocated = i; break; } } if (DSP_FAILED(status)) STRM_FreeBuffer(hStrm, apBuffer, uAllocated); #ifndef RES_CLEANUP_DISABLE if (DSP_FAILED(status)) goto func_end; /* Return PID instead of process handle */ hProcess = current->pid; res_status = CFG_GetObject((u32 *)&hDrvObject, REG_DRV_OBJECT); if (DSP_FAILED(res_status)) goto func_end; DRV_GetProcContext(hProcess, (struct DRV_OBJECT *)hDrvObject, &pCtxt, NULL, 0); if (pCtxt != NULL) { if (DRV_GetSTRMResElement(hStrm, &hSTRMRes, pCtxt) != DSP_ENOTFOUND) { DRV_ProcUpdateSTRMRes(uNumBufs, hSTRMRes, pCtxt); } } #endif func_end: return status; }
/* * ======== procCreate ======== */ static Bool procCreate(Processor_Handle proc) { DSP_STATUS status = DSP_SOK; ZcpyMqtAttrs mqtAttrs; Bool retVal; GT_1trace(curTrace, GT_ENTER, "Processor_create_d> Enter(proc=0x%x)\n", proc); /* TODO:L ignoring cpuId string, using 0 for cpuId */ proc->cpuId = 0; /* call power on function -- either the real one, or the empty * stub defined by Global.xdt if power is not used. */ if (Power_on(&proc->powerHandle) == Power_EFAIL) { retVal = FALSE; GT_0trace(curTrace, GT_6CLASS, "Processor_create_d> Power_on failed.\n"); goto procCreate_return; } /* if using LAD: connect to LAD, startup DSP, attach with Link */ if (Global_useLinkArbiter) { /* connect to LAD */ ladStatus = LAD_connect(&handle); GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> " "LAD_connect status = %x, handle = %x\n", ladStatus, handle); if (ladStatus != LAD_SUCCESS) { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "LAD_connect FAILED, status = [0x%x]\n", ladStatus); goto ladfail; } /* startup the DSP (if it isn't already started) */ GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> " "Loading %s on DSP, linkConfigName= %s ...\n", proc->imageName, proc->linkConfigName); ladStatus = LAD_startupDsp(handle, proc->cpuId, proc->linkConfigName, proc->imageName); GT_1trace(curTrace, GT_2CLASS, "Processor_create_d> " "LAD_startupDsp status = %x\n", ladStatus); /* on success, continue */ if ((ladStatus == LAD_SUCCESS) || (ladStatus == LAD_ALREADYRUNNING)) { #ifndef WIN32 /* * Must still call PROC_Attach from this app's process. (For * WinCE, LAD runs in the same process, so PROC_Attach() returns * an error.) */ status = PROC_Attach(proc->cpuId, NULL); if (!DSP_SUCCEEDED(status)) { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "PROC_Attach following LAD_startupDsp FAILED, " "status=[0x%x]\n", (Uns) status); goto ladfail; } /* must still call POOL_Open from this app (NULL attributes) */ status = POOL_Open (Global_cePoolId, NULL) ; if (!DSP_SUCCEEDED(status)) { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "POOL_Open following LAD_startupDsp FAILED, " "status=[0x%x]\n", (Uns) status); } #endif } /* else, on fail, abort */ else { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "LAD_startupDsp FAILED, status = [0x%x]\n", ladStatus); goto ladfail; } } /* end of 'if using LAD' */ /* else, if no LAD, call Link's startup APIs directly */ else { /* * Create and initialize the PROC object. */ GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> " "Initializing DSP PROC...\n"); modifyDefaultLinkCfgObjectForCENeeds(); modifyDefaultLinkCfgObjectBasedOnUserCfgData(proc->imageName); dumpLinkCfgObj(&ti_sdo_ce_ipc_Processor_linkcfg); status = PROC_setup( &ti_sdo_ce_ipc_Processor_linkcfg ); if (!DSP_SUCCEEDED(status)) { goto fail; } /* * Attach the Dsp. */ GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> " "Attaching to DSP PROC...\n"); status = PROC_Attach(proc->cpuId, NULL); if (!DSP_SUCCEEDED(status)) { goto fail; } /* * Open a pool with buffers for both the control messages use by the * transport and the application. */ GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> " "Opening MSGQ pool...\n"); status = POOL_Open(Global_cePoolId, &Global_cePoolAttrs); if (!DSP_SUCCEEDED(status)) { goto fail; } /* * Load the executable on the DSP. */ GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> " "Loading %s on DSP (%d args)...\n", proc->imageName, proc->attrs.argc); status = PROC_Load(proc->cpuId, proc->imageName, proc->attrs.argc, proc->attrs.argv); if (!DSP_SUCCEEDED(status)) { goto fail; } /* * Start execution on DSP. */ GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> " "Starting DSP PROC...\n"); status = PROC_Start(proc->cpuId); if (!DSP_SUCCEEDED(status)) { goto fail; } /* * Open the remote transport to the DSP. */ GT_0trace(curTrace, GT_2CLASS, "Processor_create_d> " "Opening remote transport...\n"); /* tell the transport which open pool id to use for ctrl messages */ mqtAttrs.poolId = Global_cePoolId; status = MSGQ_TransportOpen(proc->cpuId, &mqtAttrs); if (!DSP_SUCCEEDED(status)) { goto fail; } } /* end of else to using LAD */ /* * Connect to the Power on the DSP */ if (Power_connect(proc->powerHandle) == Power_EFAIL) { goto fail; } proc->connected = TRUE; if (Global_getenv("CE_DSPDEBUG") != NULL) { printf("Codec Engine system message (b/c CE_DSPDEBUG=1) : DSP image " "loaded and started, press Enter to continue: "); getchar(); } retVal = TRUE; goto procCreate_return; /* TODO:[4] should try those asyncErrorHandlers that link supports? * (MSGQ_SetErrorHandler) */ fail: GT_4trace(curTrace, GT_7CLASS, "Processor_create_d> " "Loading and starting DSP server '%s' FAILED, status=[0x%x] " "(look for error code 'DSP_EBASE + 0x%x' in " "dsplink*/packages/dsplink/gpp/inc/usr/errbase.h) %s\n", proc->imageName, status, status & 0x7fff, status == DSP_ERANGE ? "This error code typically indicates a problem with the DSP memory " "map, i.e. it is different from what the Arm side specified; check " "the DSP server's memory map in your Arm application .cfg script, " "and make sure you have set 'armDspLinkConfig' " "configuration variable correctly (for details, refer to the " "documentation for ti.sdo.ce.Engine.xdc). Also, verify that " "the DSPLINKMEM segment on the DSP is large enough. " : "" ); ladfail: procDelete(proc); retVal = FALSE; procCreate_return: GT_1trace(curTrace, GT_2CLASS, "Processor_create_d> return (%d)\n", retVal); return retVal; }
/* * ======== modifyDefaultLinkCfgObjectBasedOnUserCfgData ======== */ static Void modifyDefaultLinkCfgObjectBasedOnUserCfgData( String serverName ) { LINKCFG_MemEntry * linkcfgMemTable; LINKCFG_MemEntry * e; static LINKCFG_MemEntry * linkcfgMemTables[] = { NULL /* to be set */ }; Global_ArmDspLinkConfig * armDspLinkConfig = NULL; Global_ArmDspLinkConfigMemTableEntry *mte; DSP_BootMode staticCfgDspCtl; DSP_BootMode newCfgDspCtl; Int serverNameIndex; UInt32 cmemPhysBase; size_t cmemSize; Int status; /* MODIFY MEMORY CONFIGURATION */ CMEM_BlockAttrs blockAttrs; Int numMemTableEntries, i = 0; Int numMemEntries = 0; Int memEntryIdx; Int numCmemBlocks = 0; Bool addCmemBlocks = FALSE; /* first locate our server in the list of server names */ for (serverNameIndex = 0;;serverNameIndex++) { if (!strcmp(ti_sdo_ce_ipc_armDspLinkConfigServerNames[serverNameIndex], serverName)) { break; } if (ti_sdo_ce_ipc_armDspLinkConfigServerNames[serverNameIndex] == NULL ) { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "ERROR: Cannot find DspLink configuration data for the server " "named '%s' -- verify that the name was specified correctly in " "the application configuration file.\n", serverName); return; } } GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> " "Using DspLink config data for entry #%d [server '%s']\n", serverNameIndex, serverName ); armDspLinkConfig = ti_sdo_ce_ipc_armDspLinkConfigs[ serverNameIndex ]; ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->memTables = linkcfgMemTables; ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->memTables[0] = NULL; /* * Count the number of CMEM blocks, so we can add entries for these, * if needed. */ status = CMEM_getNumBlocks(&numCmemBlocks); if (status != 0) { /* TODO: Is this always an error? */ GT_0trace(curTrace, GT_6CLASS, "Processor_create_d> " "CMEM_getNumBlocks() failed!"); numCmemBlocks = 0; } else { GT_1trace(curTrace, GT_2CLASS, "Processor_create_d> Number of CMEM " "blocks: %d\n", numCmemBlocks); } for (;armDspLinkConfig->memTable[i].segmentName != NULL; i++); /* * Add a few extra entries in case we need to map CMEM blocks. The * app's config will have at most one CMEM entry with base and length * set to 0. We'll use CMEM_getBlockAttrs to get the base and length * of all CMEM blocks. (Note: We will allocate at least one more entry * then is actually needed, but this is easier than checking the * memTable for "CMEM", and subtracting '1' from the nuber to allocate * if "CMEM" is found.) */ numMemEntries = i; numMemTableEntries = numMemEntries + numCmemBlocks; /* anything allocated here must be deallocated in procDelete */ linkcfgMemTable = (LINKCFG_MemEntry *) Memory_alloc( sizeof(LINKCFG_MemEntry) * numMemTableEntries, NULL); if (linkcfgMemTable == NULL) { GT_0trace(curTrace, GT_7CLASS, "Processor_create_d> " "ERROR: Memory_alloc failed\n"); return; } /* point link config memTables only entry to our list of memTable entries */ ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->memTables[0] = linkcfgMemTable; for (i = 0, memEntryIdx = 0; i < numMemEntries; i++) { e = &linkcfgMemTable[memEntryIdx]; mte = &armDspLinkConfig->memTable[i]; GT_4trace(curTrace, GT_2CLASS, "Processor_create_d> Adding memTable " "entry for %s, physAddr = 0x%x, dspAddr = 0x%x, size = 0x%x\n", mte->segmentName, mte->gppAddress, mte->startAddress, mte->sizeInBytes); if (!strcmp("CMEM", mte->segmentName)) { /* Skip CMEM entry, we'll add CMEM blocks later */ addCmemBlocks = TRUE; continue; } e->entry = memEntryIdx; //i; strncpy( e->name, mte->segmentName, DSP_MAX_STRLEN ); e->physAddr = mte->gppAddress; // gpp physical address e->dspVirtAddr = mte->startAddress; // dsp view (physical or virtual) e->gppVirtAddr = (UInt32)-1; e->size = mte->sizeInBytes; e->shared = mte->shared; e->syncd = mte->syncd; memEntryIdx++; GT_6trace(curTrace, GT_2CLASS, "Processor_create_d> " "Adding DSP segment #%d to Link configuration: " "name='%s', startAddress=0x%x, sizeInBytes=0x%x, shared=%d, " "syncd=%d\n", i, e->name, e->physAddr, e->size, e->shared, e->syncd); } /* Now add the CMEM blocks if needed */ if (addCmemBlocks) { for (i = 0; i < numCmemBlocks; i++) { e = &linkcfgMemTable[memEntryIdx]; status = CMEM_getBlockAttrs(i, &blockAttrs); if (status != 0) { GT_1trace(curTrace, GT_7CLASS, "Processor_create_d> " "ERROR: failed to get CMEM attrs of block %d\n", i); break; } sprintf(e->name, "CMEM_BLOCK%d", i); e->physAddr = blockAttrs.phys_base; e->dspVirtAddr = blockAttrs.phys_base; e->size = blockAttrs.size; memEntryIdx++; } } /* set number of memTable entries */ ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].memEntries = memEntryIdx; //numMemTableEntries; /* RESET vector is always #3 in the list (that's how Global.xdt arranges it; * read its start address and size and adjust some other params in the * dsplink config object. (Note: third in the list is index [2]. */ ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].resumeAddr = armDspLinkConfig->memTable[2].startAddress + 0x20; ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].resetVector = armDspLinkConfig->memTable[2].startAddress; ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].resetCodeSize = armDspLinkConfig->memTable[2].sizeInBytes; /* SET DOPOWERCONTROL PER CE CONFIGURATION */ staticCfgDspCtl = ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].doDspCtrl; if (armDspLinkConfig->doDspCtrl == BootNoPwr) { newCfgDspCtl = DSP_BootMode_Boot_NoPwr; } else if (armDspLinkConfig->doDspCtrl == BootPwr) { newCfgDspCtl = DSP_BootMode_Boot_Pwr; } else if (armDspLinkConfig->doDspCtrl == NoLoadNoPwr) { newCfgDspCtl = DSP_BootMode_NoLoad_NoPwr; } else if (armDspLinkConfig->doDspCtrl == NoLoadPwr) { newCfgDspCtl = DSP_BootMode_NoLoad_Pwr; } else { /* NoBoot */ newCfgDspCtl = DSP_BootMode_NoBoot; } ti_sdo_ce_ipc_Processor_linkcfg.dspConfigs[0]->dspObject[0].doDspCtrl = newCfgDspCtl; GT_2trace(curTrace, GT_2CLASS, "Processor_create_d> " "DODSPCTRL was=%d; now=%d\n", staticCfgDspCtl, newCfgDspCtl); }