Beispiel #1
0
/*
 *  ======== Memory_getBufferPhysicalAddress ========
 *  Note, in this implementation, the first arg "virtualAddress" is
 *  a multicore device's 'localAddr'.
 */
UInt32 Memory_getBufferPhysicalAddress(Ptr virtualAddress, Int sizeInBytes,
    Bool *isContiguous)
{
    Log_print3(Diags_ENTRY,
            "[+E] Memory_getBufferPhysicalAddress(0x%x, 0x%x, 0x%x)",
            (IArg)virtualAddress, (IArg)sizeInBytes, (IArg)isContiguous);

    if (isContiguous != NULL) {
        *isContiguous = TRUE;
    }
    return (Memory_LOC_TO_GLOB((UInt32)virtualAddress));
}
/*
 *  ======== Processor_create ========
 */
Processor_Handle Processor_create(String imageName, String memMap,
    Processor_Attrs *attrs)
{
    Processor_Handle proc = NULL;
    struct stat statBuf;

    Assert_isTrue(curInit == TRUE, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY, "[+E] Processor_create> "
            "Enter(imageName='%s', memMap='%s', attrs=0x%x)",
            (IArg)imageName, (IArg)memMap, (IArg)attrs);

    if (attrs == NULL) {
        attrs = &Processor_ATTRS;
    }

    if (stat(imageName, &statBuf) != 0) {
        Log_print1(Diags_USER7, "[+7] Processor_create> "
                "ERROR: cannot access file %s", (IArg)imageName);
        return (NULL);
    }

    proc = Memory_alloc(sizeof(Processor_Obj), NULL);
    if (proc == NULL) {
        Log_print0(Diags_USER7, "[+7] Processor_create> "
                "ERROR: Memory_alloc failed");
        return (NULL);
    }

    proc->attrs = *attrs;
    proc->imageName = imageName;
    proc->memMapName = memMap;
    proc->loaded = FALSE;
    proc->fileId = 0xffffffff;
    proc->heapH = NULL;
    proc->procMgrH = NULL;
    proc->heapId = Processor_INVALID;
    proc->loadCallBackStatus = -1;
    proc->startCallBackStatus = -1;
    proc->useExtLoader = attrs->useExtLoader;

    if (doCmd(CREATE, proc) != SUCCESS) {
        Processor_delete(proc);
        return (NULL);
    }
    proc->loaded = TRUE;

    Log_print1(Diags_EXIT, "[+X] Processor_create> return (0x%x)", (IArg)proc);

    return (proc);
}
/*
 *  ======== VIDDEC2BACK_process ========
 *  This method must be the same for both local and remote invocation;
 *  each call site in the client might be calling different implementations
 *  (one that marshalls & sends and one that simply calls).  This API
 *  abstracts *all* video decoders (both high and low complexity
 *  decoders are envoked using this method).
 */
XDAS_Int32 VIDDEC2BACK_process(VIDDEC2BACK_Handle handle,
        XDM_Context *context, VIDDEC2_OutArgs *outArgs)
{
    XDAS_Int32 retVal = VIDDEC2_EFAIL;

    /*
     * Note, we do this because someday we may allow dynamically changing
     * the global 'VISA_isChecked()' value on the fly.  If we allow that,
     * we need to ensure the value stays consistent in the context of this call.
     */
    Bool checked = VISA_isChecked();

    Log_print3(Diags_ENTRY, "[+E] VIDDEC2BACK_process> "
            "Enter (handle=0x%x, context=0x%x, outArgs=0x%x)",
            (IArg)handle, (IArg)context, (IArg)outArgs);

    if (handle) {
        IVIDDEC2BACK_Fxns *fxns =
            (IVIDDEC2BACK_Fxns *)VISA_getAlgFxns((VISA_Handle)handle);
        IVIDDEC2BACK_Handle alg = VISA_getAlgHandle((VISA_Handle)handle);

        if (fxns && (alg != NULL)) {
            //Log_printf(ti_sdo_ce_dvtLog, "%s", (Arg)"VIDDEC2BACK:process",
            //    (Arg)handle, (Arg)0);

            if (checked) {

                /*
                 * Validate inBufs and outBufs.
                 */
//                XdmUtils_validateSparseBufDesc1(inBufs, "inBufs");
//                XdmUtils_validateSparseBufDesc(outBufs, "outBufs");

            }

            VISA_enter((VISA_Handle)handle);
            retVal = fxns->process(alg, context, outArgs);
            VISA_exit((VISA_Handle)handle);

            if (checked) {
                /* TBD */
            }
        }
    }

    Log_print2(Diags_EXIT, "[+X] VIDDEC2BACK_process> "
            "Exit (handle=0x%x, retVal=0x%x)", (IArg)handle, (IArg)retVal);

    return (retVal);
}
Beispiel #4
0
Int RcmClient_alloc(RcmClient_Object *obj, UInt32 dataSize,
    RcmClient_Message **message)
{
    SizeT totalSize;
    RcmClient_Packet *packet;
    Int status = RcmClient_S_SUCCESS;


    Log_print3(Diags_ENTRY,
        "--> RcmClient_alloc: obj: 0x%x, dataSize: %d, message: 0x%x",
        (IArg)obj, (IArg)dataSize, (IArg)message);

    /* ensure minimum size of UInt32[1] */
    dataSize  = (dataSize < sizeof(UInt32) ? sizeof(UInt32) : dataSize);

    /* total memory size (in chars) needed for headers and payload */
    totalSize = sizeof(RcmClient_Packet) - sizeof(UInt32) + dataSize;

    /* allocate the message */
    packet = (RcmClient_Packet*)MessageQ_alloc(obj->heapId, totalSize);

    if (NULL == packet) {
        Log_error1(FXNN": could not allocate message, size = %u",
            (IArg)totalSize);
        status = RcmClient_E_MSGALLOCFAILED;
        goto leave;
    }

    /* Log_info() */
    Log_print2(Diags_INFO,
        FXNN": RcmMessage allocated: addr=0x%x, size=%u (total size)",
        (IArg)packet, (IArg)totalSize);

    /* initialize the packet structure */
    packet->desc = 0;
    packet->msgId = RcmClient_genMsgId_P(obj);
    packet->message.poolId = RcmClient_DEFAULTPOOLID;
    packet->message.jobId = RcmClient_DISCRETEJOBID;
    packet->message.fxnIdx = RcmClient_INVALIDFXNIDX;
    packet->message.result = 0;
    packet->message.dataSize = dataSize;

    /* set message pointer to start of the message struct */
    *message = (RcmClient_Message *)(&(packet->message));


leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}
/*
 *  ======== Memory_segAlloc ========
 */
Ptr Memory_segAlloc(Int segid, UInt size, UInt align)
{
    Ptr buf = malloc(size);

    Log_print3(Diags_ENTRY, "[+E] Memory_segAlloc(0x%lx, 0x%lx, 0x%lx)",
            (IArg)segid, (IArg)size, (IArg)align);

    if (buf == NULL) {
        return (NULL);
    }

    memset(buf, '\0', size);

    return (buf);
}
Beispiel #6
0
Int RcmClient_execDpc(RcmClient_Object *obj,
    RcmClient_Message *cmdMsg, RcmClient_Message **returnMsg)
{
    RcmClient_Packet *packet;
    RcmClient_Message *rtnMsg;
    MessageQ_Msg msgqMsg;
    UInt16 msgId;
    Int rval;
    Int status = RcmClient_S_SUCCESS;


    Log_print3(Diags_ENTRY,
        "--> %s: 0x%x, 0x%x", (IArg)FXNN, (IArg)obj, (IArg)returnMsg);

    /* classify this message */
    packet = RcmClient_getPacketAddr_P(cmdMsg);
    packet->desc |= RcmClient_Desc_DPC << RcmClient_Desc_TYPE_SHIFT;
    msgId = packet->msgId;

    /* set the return address to this instance's message queue */
    msgqMsg = (MessageQ_Msg)packet;
    MessageQ_setReplyQueue(obj->msgQue, msgqMsg);

    /* send the message to the server */
    rval = MessageQ_put((MessageQ_QueueId)obj->serverMsgQ, msgqMsg);

    if (rval < 0) {
        /* Log_error() */
        Log_error0(FXNN": unable to the send message to the server");
        status = RcmClient_E_EXECFAILED;
        goto leave;
    }

    /* get the return message from the server */
    rval = RcmClient_getReturnMsg_P(obj, msgId, &rtnMsg);

    if (rval < 0) {
        *returnMsg = NULL;
        status = rval;
        goto leave;
    }
    *returnMsg = rtnMsg;


leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}
/*
 *  ======== Memory_dumpKnownContigBufs ========
 */
Void Memory_dumpKnownContigBufsList()
{
    ContigBuf *cb;

    Log_print0(Diags_USER5, "[+5] Memory_dumpKnownContigBufsList> "
            "following buffers were translated/registered:");

    cb = contigBufList;

    while (cb != NULL) {
        Log_print3(Diags_USER5, "[+5]     [ virt: 0x%08lx, size: %08lu, "
                "phys: 0x%08lx ]",
                (IArg)(cb->virtualAddress), (IArg)(cb->sizeInBytes),
                (IArg)(cb->physicalAddress ));
        cb = cb->next;
    }
}
Beispiel #8
0
/*
 *  ======== IRESMAN_HDVICP_getProtocolRevision ========
 *  Function to return the revision of the protocol
 */
IRES_ProtocolRevision * IRESMAN_HDVICP_getProtocolRevision()
{
    IRES_ProtocolRevision * version;

    if (regInit)
    Log_print0(Diags_ENTRY, "[+E] IRESMAN_HDVICP_getProtocolRevision> Enter");

    version = IRESMAN_HDVICP_CONSTRUCTFXNS.getRevision();

    if (regInit)
    Log_print3(Diags_EXIT,
            "[+X] IRESMAN_HDVICP_getProtocolRevision> Exit(version=(%d.%d.%d))",
            (IArg)(version->Major), (IArg)(version->Source),
            (IArg)(version->Radius));

    return (version);
}
Beispiel #9
0
Int RcmClient_execAsync(RcmClient_Object *obj, RcmClient_Message *cmdMsg,
    RcmClient_CallbackFxn callback, Ptr appData)
{
    RcmClient_Packet *packet;
    MessageQ_Msg msgqMsg;
    Int rval;
    Int status = RcmClient_S_SUCCESS;


    Log_print3(Diags_ENTRY,
        "--> %s: 0x%x, 0x%x", (IArg)FXNN, (IArg)obj, (IArg)cmdMsg);

    /* cannot use this function if callback notification is false */
    if (!obj->cbNotify) {
        Log_error0(FXNN": asynchronous notification not enabled");
        status = RcmClient_E_EXECASYNCNOTENABLED;
        goto leave;
    }

    /* classify this message */
    packet = RcmClient_getPacketAddr_P(cmdMsg);
    packet->desc |= RcmClient_Desc_RCM_MSG << RcmClient_Desc_TYPE_SHIFT;

    /* set the return address to this instance's message queue */
    msgqMsg = (MessageQ_Msg)packet;
    MessageQ_setReplyQueue(obj->msgQue, msgqMsg);

    /* send the message to the server */
    rval = MessageQ_put((MessageQ_QueueId)obj->serverMsgQ, msgqMsg);

    if (rval < 0) {
        Log_error0(FXNN": unable to the send message to the server");
        status = RcmClient_E_EXECFAILED;
        goto leave;
    }

    /* TODO finish this function */

leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return(status);
}
Void SystemCfg_notifyCB(UInt16 procId, UInt16 lineId, UInt32 eventNum,
        UArg arg, UInt32 payload)
{
    SystemCfg_Object *  obj = (SystemCfg_Object *)arg;
    IArg                key;


    Log_print3(Diags_ENTRY,
        "--> "FXNN": (procId=%d, eventNum=%d, payload=0x%x)",
        (IArg)procId, (IArg)eventNum, (IArg)payload);
    Log_print1(Diags_INFO, FXNN": event=0x%x", (IArg)payload);

    key = GateH_enter(Mod_gate);

    /* latch the event */
    obj->event |= payload;
    Semaphore_post(obj->semH);

    GateH_leave(Mod_gate, key);

    Log_print0(Diags_EXIT, "<-- "FXNN":");
}
/*
 *  ======== removeContigBuf ========
 */
static Int removeContigBuf(UInt32 virtualAddress, UInt32 sizeInBytes)
{
    int rv = 0;
    ContigBuf *cb, *prevCb;

    Log_print2(Diags_USER1, "[+1] Memory__removeContigBuf> "
            "Enter(virtAddr=0x%x, size=0x%x)",
            (IArg)virtualAddress, (IArg)sizeInBytes);

    cb = contigBufList;
    prevCb = NULL;

    while (cb != NULL) {
        if (cb->virtualAddress == virtualAddress &&
            cb->sizeInBytes    == sizeInBytes) {
            Log_print3(Diags_USER1, "[+1] Memory__removeContigBuf> "
                    "removing cb->phys=0x%x, cb->size=0x%x, cb->virt=0x%x",
                    (IArg)(cb->physicalAddress), (IArg)(cb->sizeInBytes),
                    (IArg)(cb->virtualAddress));
            if (prevCb == NULL) {
                contigBufList = cb->next;
            } else {
                prevCb->next =  cb->next;
            }
            free(cb);
            break;
        }
        prevCb = cb;
        cb = cb->next;
    }

    if (cb == NULL) {
        Log_print0(Diags_USER1, "[+1] Memory__removeContigBuf> "
                "ERROR: Failed to find matching cb.");
        rv = -1;
    }

    return rv;
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Status IRES_SDMA_getMemRecs(IRES_Handle handle,
        IRES_ProtocolArgs * resProtocolArgs, IALG_MemRec *memRecs)
{

    Log_print3(Diags_ENTRY,
            "[+E] _IRES_SDMA_getMemRecs> Enter (handle=0x%x, "
            "resProtocolArgs=0x%x, memRecs=0x%x)",
            (IArg)handle, (IArg)resProtocolArgs, (IArg)memRecs);

    Assert_isTrue(memRecs != NULL, (Assert_Id)NULL);
    Assert_isTrue(resProtocolArgs != NULL, (Assert_Id)NULL);

    memRecs[0].alignment = 4;

    /*
     * IALG_EXTERNAL because we don't care where this memory is allocated
     */
    memRecs[0].space = IALG_ESDATA;

    /*
     * Memory should be persistent.
     */
    memRecs[0].attrs = IALG_PERSIST;

    /*
     * Size of this handle depends on number of Logical Channels requested
     */
    memRecs[0].size = (sizeof(IRES_SDMA_Obj) + sizeof(SDMA_ChannelDescriptor));

    Log_print2(Diags_USER4,
            "[+4] _IRES_SDMA_getMemRecs> Requesting memory of size 0x%x, "
            "alignment 0x%x, space IALG_ESDATA, attrs IALG_PERSIST)",
            (IArg)(memRecs[0].size), (IArg)(memRecs[0].alignment));

    Log_print0(Diags_EXIT, "[+X] _IRES_SDMA_getMemRecs> Exit (status=IRES_OK)" );

    return (IRES_OK); /* number of MemRecs */
}
/*
 *  ======== Comm_alloc ========
 */
Int Comm_alloc(UInt16 poolId, Comm_Msg *msg, UInt16 size)
{
    Comm_Msg   mbuf;
    Int        retVal = Comm_EFAIL;    /* pessimistic */

    Assert_isTrue(curInit > 0, (Assert_Id)NULL);
    Assert_isTrue(msg != NULL, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY, "[+E] Comm_alloc> "
            "Enter(poolId=0x%x, msg=0x%x, size=%d)",
            (IArg)poolId, (IArg)msg, (IArg)size);

    if ((mbuf = (Comm_Msg)Memory_alloc(NULL, size, 0, NULL)) != NULL) {
        mbuf->size = size;
        *((long *)mbuf) = MSGTYPE; /* must be > 0 */
        *msg = mbuf;
        retVal = Comm_EOK;
    }

    Log_print2(Diags_EXIT, "[+X] Comm_alloc> msg=0x%x, returning (%d)",
            (IArg)(*msg), (IArg)retVal);

    return (retVal);
}
Beispiel #14
0
/*
 *  ======== Memory_free ========
 */
Bool Memory_free(Ptr addr, UInt size, Memory_AllocParams *params)
{
    Bool retVal;

    Log_print3(Diags_ENTRY, "[+E] Memory_free> "
            "Enter(addr=0x%x, size=0x%x, params=0x%x)",
            (IArg)addr, (IArg)size, (IArg)params);

    if (params == NULL) {
        params = &Memory_DEFAULTPARAMS;
    }

    /*
     * TODO:M  Is there a way to validate that params->seg is valid?
     * If so, we should validate and set retVal accordingly
     */
    retVal = TRUE;

    segFree((IHeap_Handle)params->seg, addr, size);

    Log_print0(Diags_EXIT, "[+X] Memory_free> Exit");

    return (retVal);
}
/*
 *  ======== Processor_create ========
 */
Processor_Handle Processor_create(String imageName, String linkCfg,
    Processor_Attrs *attrs)
{
    Processor_Handle proc = NULL;

    Log_print3(Diags_ENTRY, "[+E] Processor_create> "
            "Enter(imageName='%s', linkCfg='%s', attrs=0x%x)",
            (IArg)imageName, (IArg)linkCfg, (IArg)attrs);

#if MESSAGEQ_ENABLED
    /* This implementation requires attrs->name to be provided */
    if ((attrs == NULL) || (attrs->cpuId == NULL)) {
        Log_print0(Diags_USER7, "[+7] Processor_create> ERROR: invalid attrs");
        return (NULL);
    }

    if ((proc = xdc_runtime_Memory_alloc(NULL, sizeof(Processor_Obj),
            0, NULL)) == NULL) {
        Log_print0(Diags_USER7, "[+7] Processor_create> "
                "ERROR: Memory_alloc failed");
        return (NULL);
    }

    proc->hHeap = NULL;
    proc->heapId = (UInt16)Processor_INVALID;

    if (!procCreate(proc, attrs->cpuId)) {
        Processor_delete(proc);
        return (NULL);
    }
#endif

    Log_print1(Diags_EXIT, "[+X] Processor_create> return (0x%x)", (IArg)proc);

    return (proc);
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Handle IRES_EDMA3CHAN_constructHandle(
        IRES_ProtocolArgs * resProtocolArgs, 
        IALG_MemRec *memRecs, 
        IRESMAN_ConstructArgs * constructHandleArgs, 
        IRES_Status *status)
{
    int numPaRams = 0;
    int numTccs = 0;
    int i = 0;
    IRES_EDMA3CHAN_PaRamStruct * shadowPaRamsPtr = 0x0;
    unsigned int * paRamAddressPtr = 0x0;
    short * paRamIndexPtr = 0x0;
    short * tccIndexPtr = 0x0;
    short * actualPaRamIndex = 0x0;
    short edmaChannel;
    unsigned int paRamBase;
    IRES_EDMA3CHAN2_Handle handle = (IRES_EDMA3CHAN2_Handle)memRecs[0].base;

    IRESMAN_EDMA3CHAN_ConstructHandleArgs * constructArgs =
        (IRESMAN_EDMA3CHAN_ConstructHandleArgs *)constructHandleArgs;
    Bool shadow = ((IRES_EDMA3CHAN_ProtocolArgs *)resProtocolArgs)
            ->shadowPaRamsAllocation;

    Assert_isTrue(resProtocolArgs != NULL, (Assert_Id)NULL);
    Assert_isTrue(memRecs != NULL, (Assert_Id)NULL);
    Assert_isTrue(constructHandleArgs != NULL, (Assert_Id)NULL);
    Assert_isTrue(status != NULL, (Assert_Id)NULL);


    Log_print3(Diags_ENTRY,
            "[+E] IRES_EDMA3CHAN_constructHandle> Enter (protArgs=0x%x, "
            "memRecs=0x%x, constructHandleArgs=0x%x)",
            (IArg)resProtocolArgs, (IArg)memRecs, (IArg)constructHandleArgs);
    
    if (handle == NULL) {

        *status = IRES_ENORESOURCE;

        Log_print0(Diags_USER7,
                "[+7] IRES_EDMA3CHAN_constructHandle> NULL handle returned through "
                "memRecs");

        Log_print0(Diags_EXIT,
                "[+X] IRES_EDMA3CHAN_constructHandle> Exit (handle=NULL)");

        return ((IRES_Handle)NULL);
    }

    /*
     * Assign the proper IRES_Obj properties to the handle first 
     */
    (handle->ires).getStaticProperties = IRES_EDMA3CHAN_getStaticProperties; 
    (handle->ires).persistent = TRUE; 

    internalState.edma3BaseAddress = constructArgs->edma3CCBaseAddress;

    paRamBase = internalState.edma3BaseAddress + IRES_EDMA3CHAN_PARAMBASEOFFSET;

    actualPaRamIndex = constructArgs->paRamIndex;

    numPaRams = constructArgs->numPaRams;

    numTccs = constructArgs->numTccs;

    /*
     * Point the shadowPaRamsPtr to the address of space allocated for 
     * shadow params .
     * The space gets allocated immediately following the IRES_EDMA3CHAN2_Obj
     * structure. The initialization of the shadow, param and tcc arrays
     * remains compatible for both revs 1 and  2 of the IRES EDMA3CHAN protocol
     */
    shadowPaRamsPtr = (IRES_EDMA3CHAN_PaRamStruct *)((UInt8 *)handle + 
            sizeof(IRES_EDMA3CHAN2_Obj));

    /*
     * Point the paRamAddress pointer to the address of space allocated in 
     * param addresses
     */
    if (shadow) {
        paRamAddressPtr = (unsigned int *)((UInt8 *)shadowPaRamsPtr + 
                (numPaRams * sizeof(IRES_EDMA3CHAN_PaRamStruct)));
    } 
    else {
        paRamAddressPtr =  (unsigned int *)shadowPaRamsPtr;
                shadowPaRamsPtr = NULL;
    }
    /*
     * Point the paRamIndexPtr to the address of space allocated for 
     * paRam indices.
     */
    paRamIndexPtr = (short *)((UInt8 *)paRamAddressPtr + (numPaRams * 
            sizeof(unsigned int)));

    tccIndexPtr = (short *)((UInt8 *)paRamIndexPtr + (numPaRams * 
            sizeof(unsigned short)));

    edmaChannel = constructArgs->edma3Chan;

    /*
     * Use the constructHandleargs to populate the TCC index array 
     */
    for (i = 0; i < numTccs; i++) {
        tccIndexPtr[i] = constructArgs->tccIndex[i];
    } 

    /*
     * Use the constructHandleargs to populate the ShadowPaRams with the 
     * correct link
     */
    if (numPaRams != 0) { 
    
        paRamAddressPtr[0] = paRamBase + ((unsigned int)actualPaRamIndex[0] * 
                sizeof(IRES_EDMA3CHAN_PaRamStruct));
    
        paRamIndexPtr[0] = actualPaRamIndex[0]; 
    
        Log_print6(Diags_USER2,
                "[+2] IRES_EDMA3CHAN_constructHandle> Address of handle 0x%x, "
                "paRamIndices 0x%x, paRamAddresses 0x%x, shadowParams 0x%x,"
                " tccIndices 0x%x, edmaChannel %d",
                (IArg)handle, (IArg)paRamIndexPtr, (IArg)paRamAddressPtr,
                (IArg)shadowPaRamsPtr, (IArg)tccIndexPtr, (IArg)edmaChannel);
    
        for (i = 0 ; i < numPaRams-1; i++) {
    
            /*
             * Copy the actual Param indices to the handle memory
             */
            paRamAddressPtr[i+1] = paRamBase + (actualPaRamIndex[i+1] * 
                    sizeof(IRES_EDMA3CHAN_PaRamStruct));
    
            paRamIndexPtr[i+1] = actualPaRamIndex[i+1]; 
    
            if (shadow) {
                /* First some clean index values */
                (shadowPaRamsPtr[i]).src = 0x0;
                (shadowPaRamsPtr[i]).dst = 0x0;
                (shadowPaRamsPtr[i]).srcElementIndex = 0x0;
                (shadowPaRamsPtr[i]).dstElementIndex = 0x0;
                (shadowPaRamsPtr[i]).srcFrameIndex = 0x0;
                (shadowPaRamsPtr[i]).dstFrameIndex = 0x0;
                (shadowPaRamsPtr[i]).acnt = 0x1;
                (shadowPaRamsPtr[i]).bcnt = 0x1;
                (shadowPaRamsPtr[i]).bCntrld = 0x1;
    
                /*
                 * ccnt is the trigger word, don't write to it
                 */
    
                /*
                 * For each PaRam index (except the last), construct a 
                 * shadowPaRam entry with link to the next PaRam 
                 */
                (shadowPaRamsPtr[i]).link = 
                        ((sizeof(IRES_EDMA3CHAN_PaRamStruct)) * 
                        actualPaRamIndex[i+1]) + IRES_EDMA3CHAN_PARAMBASEOFFSET;
    
                Log_print2(Diags_USER2,
                        "[+2] IRES_EDMA3CHAN_constructHandle> "
                        "shadowPaRamsPtr[%d].link = 0x%x",
                        (IArg)i, (IArg)(shadowPaRamsPtr[i].link));
    
                /*
                 * Set up the OPT, AB_SYNC for all PaRams
                 */
                (shadowPaRamsPtr[i]).opt = 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_ABSYNC; 
            }
        }

        /*
         * Set up the last paRam
         */
        if (shadow ) {
            /* First some clean index values */
            (shadowPaRamsPtr[numPaRams - 1]).src = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).dst = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).srcElementIndex = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).dstElementIndex = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).srcFrameIndex = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).dstFrameIndex = 0x0;
            (shadowPaRamsPtr[numPaRams - 1]).acnt = 0x1;
            (shadowPaRamsPtr[numPaRams - 1]).bcnt = 0x1;
            (shadowPaRamsPtr[i]).bCntrld = 0x1;
    
            /*
             * Link to a null PaRam
             */
            (shadowPaRamsPtr[numPaRams - 1]).link = 
                    IRES_EDMA3CHAN_PARAMSTRUCT_NULLLINK;
    
            Log_print2(Diags_USER2,
                    "[+2] IRES_EDMA3CHAN_constructHandle> shadowPaRamsPtr[%d].link ="
                    " 0x%x",
                    (IArg)((numPaRams -1)),
                    (IArg)(shadowPaRamsPtr[numPaRams -1].link));
    
            /*
             * Set OPT for last paRam
             * Static field, interrupt enabled
             * If TCCs requested, use tcc[0] as OPT bit.   
             */
            if (numTccs > 0) {
                (shadowPaRamsPtr[numPaRams - 1]).opt = 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_ABSYNC | 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_TCCINTEN | 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_TCCSTATIC | 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_TCCBITS(tccIndexPtr[0]);
            }
            else {
                (shadowPaRamsPtr[numPaRams - 1]).opt = 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_ABSYNC | 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_TCCINTEN | 
                        IRES_EDMA3CHAN_PARAMSTRUCT_OPT_TCCSTATIC;
            }
        }
    }
    else {
        paRamAddressPtr =  NULL;
                shadowPaRamsPtr = NULL;
        paRamIndexPtr = NULL;
    }

    if (numTccs ==0) {
        tccIndexPtr = NULL;
    }

    /*
     * Populate other fields of handle
     */
    handle->assignedNumPaRams = numPaRams; 
    handle->assignedNumTccs = numTccs;

    handle->assignedQdmaChannelIndex = constructArgs->qdmaChan; 
    handle->assignedEdmaChannelIndex = edmaChannel; 

    Log_print4(Diags_USER2,
            "[+2] IRES_EDMA3CHAN_constructHandle> Num params %d, Num Tccs %d, "
            "Qdma channel %d Edma channel %d",
            (IArg)(handle->assignedNumPaRams), (IArg)(handle->assignedNumTccs),
            (IArg)(handle->assignedQdmaChannelIndex),
            (IArg)(handle->assignedEdmaChannelIndex));

     if (IRES_EDMA3CHAN_CHAN_NONE != edmaChannel) {
         /*
          * Edma channel is assigned, configure ESR correctly
          */
         if ( edmaChannel < 32) {
             handle->esrBitMaskL |= (0x1 << edmaChannel);
             handle->esrBitMaskH = 0x0;
         }
         else {
             handle->esrBitMaskH |= (0x1 <<(edmaChannel -32));
             handle->esrBitMaskL = 0x0;
         }
     }
         else {
                handle->esrBitMaskL = 0x0;
                handle->esrBitMaskH = 0x0;
         }
      
    if (numTccs > 0) {
        if (tccIndexPtr[0] < 32) {
            handle->iprBitMaskH = 0x0;
            handle->iprBitMaskL |= (0x1 << tccIndexPtr[0]);
        }
        else {
            handle->iprBitMaskL = 0x0;
            handle->iprBitMaskH |= (0x1 <<(tccIndexPtr[0] - 32));
        }
    }
        else {
                handle->iprBitMaskL = 0x0;
                handle->iprBitMaskH = 0x0;
        }

    Log_print4(Diags_USER2,
            "[+2] IRES_EDMA3CHAN_constructHandle> ESR 0x%x: 0x%x IPR 0x%x: 0x%x ",
            (IArg)(handle->esrBitMaskH), (IArg)(handle->esrBitMaskL),
            (IArg)(handle->iprBitMaskH), (IArg)(handle->iprBitMaskL));

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

    /* 
     * Adjust the pointers in the IRES_EDMA3CHAN2_Obj to point to the paRam
     * indices and the shadow parameters
     */
    handle->assignedPaRamIndices = paRamIndexPtr;
    handle->shadowPaRams = shadowPaRamsPtr;
    handle->assignedPaRamAddresses = paRamAddressPtr;
    handle->assignedTccIndices = tccIndexPtr;

    *status = IRES_OK;

    Log_print2(Diags_EXIT,
            "[+X] IRES_EDMA3CHAN_constructHandle> Exit (status=%d, handle=0x%x)",
            (IArg)(*status), (IArg)handle);

    return ((IRES_Handle)handle);
}
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Status IRES_EDMA3CHAN_getMemRecs(IRES_Handle handle, 
        IRES_ProtocolArgs * resProtocolArgs, IALG_MemRec *memRecs)
{
    int size;
    int numPaRams; 
    int numTccs; 

    IRES_EDMA3CHAN_ProtocolArgs * protocolArgs = 
            (IRES_EDMA3CHAN_ProtocolArgs *)resProtocolArgs;

    Assert_isTrue(memRecs != NULL, (Assert_Id)NULL);
    Assert_isTrue(resProtocolArgs != NULL, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY,
            "[+E] IRES_EDMA3CHAN_getMemRecs> Enter (handle=0x%x, "
            "resProtocolArgs=0x%x, memRecs=0x%x)",
            (IArg)handle, (IArg)resProtocolArgs, (IArg)memRecs);

    /* Calculate size based on the number of params requested use protocolArgs 
     * from the resourceDescriptor */
    numPaRams = protocolArgs->numPaRams;
    numTccs = protocolArgs->numTccs;

    /*
     * Amount of memory required is basically size of the paRamArray and size
     * of the shadow params (if requested), the tcc Array,
     * param Addresses plus the size of IRES_EDMA3CHAN2_OBJ
     */
    if (protocolArgs->shadowPaRamsAllocation) {
        size = numPaRams * (sizeof(short) + sizeof(IRES_EDMA3CHAN_PaRamStruct)
                + sizeof(unsigned int));
    } 
    else {
        size = numPaRams * ( sizeof(short) + sizeof(unsigned int));
    }
    size += numTccs * ( sizeof(short));
    size += sizeof(IRES_EDMA3CHAN2_Obj);

    memRecs[0].size = size; 

    memRecs[0].alignment = 4;

    /*
     * IALG_EXTERNAL because we don't care where this memory is allocated
     */
    memRecs[0].space = IALG_EXTERNAL;

    /*
     * Memory should be persistent. 
     */
    memRecs[0].attrs = IALG_PERSIST;

    Log_print2(Diags_USER4,
            "[+4] IRES_EDMA3CHAN_getMemRecs> Amount of memory requested 0x%x, "
            "alignment 0x%x, space IALG_EXTERNAL attrs IALG_PERSIST",
            (IArg)(memRecs[0].size), (IArg)(memRecs[0].alignment));


    Log_print0(Diags_EXIT,
            "[+X] IRES_EDMA3CHAN_getMemRecs> Exit (status=IRES_EOK)");

    return (IRES_OK); /* number of MemRecs */
}
Beispiel #18
0
/*  ARGSUSED - this line tells the compiler not to warn about unused args */
IRES_Status IRESMAN_HDVICP_freeHandles(IALG_Handle algHandle,
        IRES_Handle algResourceHandle, IRES_ResourceDescriptor * resDesc,
        Int scratchGroupId)
{
    IALG_MemRec resourceMemRecs[IRES_HDVICP_MAXRESOURCES];
    Int numMemRecs;
    IRES_Status status = IRES_OK;
    Int Id = -1;
    IRES_ProtocolArgs * protocolArgs = resDesc->protocolArgs;
    IRES_HDVICP_Handle resourceHandle = (IRES_HDVICP_Handle)
            algResourceHandle;
    /*
     * Cast the protocolArgs
     */
    IRES_HDVICP_ProtocolArgs * configArgs =
            (IRES_HDVICP_ProtocolArgs *) protocolArgs;

    Assert_isTrue(protocolArgs, (Assert_Id)NULL);
    Assert_isTrue(algResourceHandle, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY,
            "[+E] IRESMAN_HDVICP_freeHandle> Enter (handle=0x%x, "
            "protocolArgs=0x%x, scratchGroupId=%d)",
            (IArg)algResourceHandle, (IArg)protocolArgs,
            (IArg)scratchGroupId);

    if (_initialized != 1) {
        Log_print0(Diags_USER7,
                "[+7] IRESMAN_HDVICP_freeHandles> RMAN register for HDVICP resource "
                "not happened successfully. Please call RMAN_register before "
                "trying to assign or release resources");

        status =  IRES_ENORESOURCE;

        Log_print0(Diags_EXIT,
                "[+X] IRESMAN_HDVICP_freeHandles> Exit (status=IRES_ENORESOURCE)");

        return (status);
    }

    if (configArgs->base.mode == IRES_PERSISTENT) {
        scratchGroupId = -1;
    }

    /*
     * Use the protocolArgs to determine which resource to free
     */
    Id = resourceHandle->id;

    if ((Id >= _resmanInternalState->numResources) ||
            (_resmanInternalState->resourceBusy[Id] != scratchGroupId)) {

        Log_print0(Diags_USER7,
                "[+7] IRESMAN_HDVICP_freeHandles> Error freeing HDVICP resource. "
                "Resource already free");

        Log_print0(Diags_EXIT,
                "[+X] IRESMAN_HDVICP_freeHandles> Exit (status=IRES_ENORESOURCE)");

        return (IRES_ENORESOURCE);
    }
    else {
        _resmanInternalState->refCount[Id]-- ;

        if ( 0 == _resmanInternalState->refCount[Id]) {
            _resmanInternalState->resourceBusy[Id] =
                    IRESMAN_HDVICP_RESOURCEFREE;
        }
    }

    /*
     * Obtain memory resources to free and free them
     */
    numMemRecs = IRESMAN_HDVICP_CONSTRUCTFXNS.getNumMemRecs
         ( (IRES_ProtocolArgs *)protocolArgs);

    IRESMAN_HDVICP_CONSTRUCTFXNS.getMemRecs((IRES_Handle)NULL,
            (IRES_ProtocolArgs *) protocolArgs, resourceMemRecs);

    resourceMemRecs[0].base = algResourceHandle;

    /*
     * Use IRES_HDVICP_RESOURCEPROTOCOL to de-init the resource protocol
     * if required
     */
    IRESMAN_HDVICP_CONSTRUCTFXNS.destructHandle(algResourceHandle);

    /*
     * Free the memory for the handles
     */
    freeFxn(resourceMemRecs, numMemRecs);

    Log_print1(Diags_EXIT, "[+X] IRESMAN_HDVICP_freeHandles> Exit (status=%d)",
            (IArg)status);

    return (status);
}
Beispiel #19
0
/*
 *  ======== processLoop ========
 */
static Void processLoop(UNIVERSAL_Handle hUniversal, FILE *in, FILE *out,
        XDAS_Int8 *inBuf, XDAS_Int8 *outBuf, XDAS_Int8 *versionBuf)
{
    Int                         n;
    Int32                       status;

    UNIVERSAL_InArgs            universalInArgs;
    UNIVERSAL_OutArgs           universalOutArgs;
    UNIVERSAL_DynamicParams     universalDynParams;
    UNIVERSAL_Status            universalStatus;

    XDM1_BufDesc                universalInBufDesc;
    XDM1_BufDesc                universalOutBufDesc;

    /* initialize bufDescs */
    universalInBufDesc.numBufs = universalOutBufDesc.numBufs = 1;
    universalInBufDesc.descs[0].bufSize = universalOutBufDesc.descs[0].bufSize =
        NSAMPLES;

    universalInBufDesc.descs[0].buf = inBuf;
    universalOutBufDesc.descs[0].buf = outBuf;

    /* initialize all "sized" fields */
    universalInArgs.size    = sizeof(universalInArgs);
    universalOutArgs.size   = sizeof(universalOutArgs);
    universalDynParams.size = sizeof(universalDynParams);
    universalStatus.size    = sizeof(universalStatus);

    /* if the codecs support it, dump their versions */
    universalStatus.data.numBufs = 1;
    universalStatus.data.descs[0].buf = versionBuf;
    universalStatus.data.descs[0].bufSize = MAXVERSIONSIZE;
    universalStatus.data.descs[1].buf = NULL;

#ifdef CACHE_ENABLED
    /* invalidate versionBuf it before the alg fills it */
    Memory_cacheInv(versionBuf, MAXVERSIONSIZE);
#endif

    status = UNIVERSAL_control(hUniversal, XDM_GETVERSION, &universalDynParams,
        &universalStatus);
    Log_print1(Diags_USER1, "[+1] Alg version:  %s",
            (IArg)((status == UNIVERSAL_EOK ?
            ((char *)universalStatus.data.descs[0].buf) : "[unknown]")));

    /*
     * Read complete frames from in, process them, and write to out.
     */
    for (n = 0; fread(inBuf, IFRAMESIZE, 1, in) == 1; n++) {

#ifdef CACHE_ENABLED
#if defined(xdc_target__isaCompatible_64P) || \
    defined(xdc_target__isaCompatible_64T)
        /*
         *  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, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(outBuf, OFRAMESIZE);
#endif

        Log_print1(Diags_USER1, "[+1] App-> Processing frame %d...", (IArg)n);

        /*
         * Transcode the frame.
         *
         * Note, inputID == 0 is an error.  This example doesn't account
         * for the case where 'n + 1' wraps to zero.
         */
        status = UNIVERSAL_process(hUniversal, &universalInBufDesc,
                &universalOutBufDesc, NULL, &universalInArgs, &universalOutArgs);

        Log_print2(Diags_USER2,
                "[+2] App-> Alg frame %d process returned - 0x%x",
                (IArg)n, (IArg)status);

        if (status != UNIVERSAL_EOK) {
            Log_print3(Diags_USER7,
                    "[+7] App-> Alg frame %d processing FAILED, status = 0x%x, "
                    "extendedError = 0x%x",
                    (IArg)n, (IArg)status,
                    (IArg)(universalOutArgs.extendedError));
            break;
        }

#ifdef CACHE_ENABLED
        /*
         * Conditionally writeback the processed buf from the previous
         * call.  This [pessimistic] writeback illustrates the general
         * situation where the subsequent access of outBuf (fwrite(), in
         * this case), is not known to be via CPU/cache or DMA/physical mem.
         *
         * An optimized system, where the access mode of outBufs known,
         * may be able to eliminate this writeback.
         */
        if (XDM_ISACCESSMODE_WRITE(universalOutBufDesc.descs[0].accessMask)) {
            Memory_cacheWb(outBuf, OFRAMESIZE);
        }
#endif

        /* write to file */
        fwrite(outBuf, OFRAMESIZE, 1, out);
    }

    Log_print1(Diags_USER1, "[+1] %d frames processed", (IArg)n);
}
Beispiel #20
0
/*!
 * ======== VirtQueue_create ========
 */
VirtQueue_Object *VirtQueue_create(VirtQueue_callback callback,
                                   UInt16 remoteProcId, Int vqId)
{
    VirtQueue_Object *vq;
    Void *vringAddr;
    Error_Block eb;

    Error_init(&eb);

    vq = Memory_alloc(NULL, sizeof(VirtQueue_Object), 0, &eb);
    if (!vq) {
        return (NULL);
    }

    vq->callback = callback;
    vq->id = vqId;
    vq->procId = remoteProcId;
    vq->last_avail_idx = 0;

#ifndef SMP
    if (MultiProc_self() == appm3ProcId) {
        /* vqindices that belong to AppM3 should be next to SysM3.
         * Care must be taken to not collide with SysM3's virtqueues. */
        vq->id += 2;
    }
#endif

    switch (vq->id) {
        /* IPC transport vrings */
        case ID_SELF_TO_A9:
            /* IPU/DSP -> A9 */
            vringAddr = (struct vring *) IPC_MEM_VRING0;
            break;
        case ID_A9_TO_SELF:
            /* A9 -> IPU/DSP */
            vringAddr = (struct vring *) IPC_MEM_VRING1;
            break;
#ifndef SMP
        case ID_APPM3_TO_A9:
            /* APPM3 -> A9 */
            vringAddr = (struct vring *) IPC_MEM_VRING2;
            break;
        case ID_A9_TO_APPM3:
            /* A9 -> APPM3 */
            vringAddr = (struct vring *) IPC_MEM_VRING3;
            break;
#endif
    }

    Log_print3(Diags_USER1,
            "vring: %d 0x%x (0x%x)\n", vq->id, (IArg)vringAddr,
            RP_MSG_RING_SIZE);

    vring_init(&(vq->vring), RP_MSG_NUM_BUFS, vringAddr, RP_MSG_VRING_ALIGN);

    /*
     *  Don't trigger a mailbox message every time MPU makes another buffer
     *  available
     */
    if (vq->procId == hostProcId) {
        vq->vring.used->flags |= VRING_USED_F_NO_NOTIFY;
    }

    queueRegistry[vq->id] = vq;

    return (vq);
}
Beispiel #21
0
/*
 *  ======== VIDENCCOPY_TI_process ========
 */
XDAS_Int32 VIDENCCOPY_TI_process(IVIDENC_Handle h, XDM_BufDesc *inBufs,XDM_BufDesc *outBufs, IVIDENC_InArgs *inArgs, IVIDENC_OutArgs *outArgs)
{
    XDAS_Int32 curBuf;
    XDAS_UInt32 minSamples;

#ifdef USE_ACPY3
    const Uint32 maxTransferChunkSize       = 0xffff;
    Uint32       thisTransferChunkSize      = 0x0;
    Uint32       remainingTransferChunkSize;
    Uint32       thisTransferSrcAddr, thisTransferDstAddr;

    ACPY3_Params params;
    VIDENCCOPY_TI_Obj *videncObj = (VIDENCCOPY_TI_Obj *)h;
#endif

    Log_print5(Diags_ENTRY, "[+E] VIDENCCOPY_TI_process(0x%x, 0x%x, 0x%x, "
            "0x%x, 0x%x)",
            (IArg)h, (IArg)inBufs, (IArg)outBufs, (IArg)inArgs, (IArg)outArgs);

    /* validate arguments - this codec only supports "base" xDM. */
    if ((inArgs->size != sizeof(*inArgs)) ||
        (outArgs->size != sizeof(*outArgs))) {

        Log_print2(Diags_ENTRY,
                "[+E] VIDENCCOPY_TI_process, unsupported size (0x%x, 0x%x)",
                (IArg)(inArgs->size), (IArg)(outArgs->size));

        return (IVIDENC_EFAIL);
    }

#ifdef USE_ACPY3
    /*
     * Activate Channel  scratch DMA channels.
     */
    //ACPY3_activate(videncObj->dmaHandle1D1D8B);
#endif

    /* outArgs->bytesGenerated reports the total number of bytes generated */
    outArgs->bytesGenerated = 0;

    /*
     * A couple constraints for this simple "copy" codec:
     *    - Video encoding presumes a single input buffer, so only one input
     *      buffer will be encoded, regardless of inBufs->numBufs.
     *    - Given a different size of an input and output buffers, only
     *      encode (i.e., copy) the lesser of the sizes.
     */



    for (curBuf = 0; (curBuf < inBufs->numBufs) &&
        (curBuf < outBufs->numBufs); curBuf++) {

        /* there's an available in and out buffer, how many samples? */
        minSamples = inBufs->bufSizes[curBuf] < outBufs->bufSizes[curBuf] ?
            inBufs->bufSizes[curBuf] : outBufs->bufSizes[curBuf];

#ifdef USE_ACPY3

#if 0
        thisTransferSrcAddr        = (Uint32)inBufs->bufs[curBuf];
        thisTransferDstAddr        = (Uint32)outBufs->bufs[curBuf];
        remainingTransferChunkSize = minSamples;

        while (remainingTransferChunkSize > 0) {

            if (remainingTransferChunkSize > maxTransferChunkSize) {
               thisTransferChunkSize = maxTransferChunkSize;
            }
            else {
               thisTransferChunkSize = remainingTransferChunkSize;
            }

            /* Configure the logical channel */
            params.transferType = ACPY3_1D1D;
            params.srcAddr      = (void *)thisTransferSrcAddr;
            params.dstAddr      = (void *)thisTransferDstAddr;
            params.elementSize  = thisTransferChunkSize;
            params.numElements  = 1;
            params.waitId       = 0;
            params.numFrames    = 1;

            remainingTransferChunkSize -= thisTransferChunkSize;
            thisTransferSrcAddr += thisTransferChunkSize;
            thisTransferDstAddr += thisTransferChunkSize;

            /* Configure logical dma channel */
            ACPY3_configure(videncObj->dmaHandle1D1D8B, &params, 0);

            /* Use DMA to copy data */
            ACPY3_start(videncObj->dmaHandle1D1D8B);

            /* wait for transfer to finish  */
            ACPY3_wait(videncObj->dmaHandle1D1D8B);
        }
        Log_print1(Diags_USER2, "[+2] VIDENCCOPY_TI_process> "
                "ACPY3 Processed %d bytes.", (IArg)minSamples);
#endif
#else
        Log_print3(Diags_USER2, "[+2] VIDENCCOPY_TI_process> "
                "memcpy (0x%x, 0x%x, %d)",
                (IArg)(outBufs->bufs[curBuf]), (IArg)(inBufs->bufs[curBuf]),
                (IArg)minSamples);

        /* process the data: read input, produce output */
        memcpy(outBufs->bufs[curBuf], inBufs->bufs[curBuf], minSamples);
#endif

        outArgs->bytesGenerated += minSamples;
    }


#ifdef USE_ACPY3
    /*
     * Deactivate Channel  scratch DMA channels.
     */
    //ACPY3_deactivate(videncObj->dmaHandle1D1D8B);

	//videncObj->p_data //avi mem

	runOnce(videncObj->p_data, videncObj->p_ddr_data, videncObj->p_DARAM0, videncObj->dmaHandle1D1D8B);
	DspModule(inBufs->bufs[0], outBufs->bufs[0]);

	//memcpy(outBufs->bufs[0] + 8,&(videncObj->p_DARAM0),4);
	runOver();

#endif


	

    /* Fill out the rest of the outArgs struct */
    outArgs->extendedError = 0;
    outArgs->encodedFrameType = 0;    /* TODO */
    outArgs->inputFrameSkip = IVIDEO_FRAME_ENCODED;
    outArgs->reconBufs.numBufs = 0;   /* important: indicate no reconBufs */
    return (IVIDENC_EOK);
}
Beispiel #22
0
/* ARGSUSED - this line tells the compiler not to warn about unused args. */
IRES_Handle IRES_HDVICP2_constructHandle(
        IRES_ProtocolArgs * resProtocolArgs,
        IALG_MemRec *memRecs,
        IRESMAN_ConstructArgs * constructHandleArgs,
        IRES_Status *status)
{
    IRES_HDVICP2_Handle handle = (IRES_HDVICP2_Handle)memRecs[0].base;

    IRESMAN_HDVICP2_ConstructHandleArgs * constructArgs =
        (IRESMAN_HDVICP2_ConstructHandleArgs *)constructHandleArgs;

    Assert_isTrue(resProtocolArgs != NULL, (Assert_Id)NULL);
    Assert_isTrue(memRecs != NULL, (Assert_Id)NULL);
    Assert_isTrue(constructHandleArgs != NULL, (Assert_Id)NULL);
    Assert_isTrue(status != NULL, (Assert_Id)NULL);

    Log_print3(Diags_ENTRY,
            "[+E] IRES_HDVICP2_constructHandle> Enter (protArgs=0x%x, memRecs=0x%x, "
            "constructHandleArgs=0x%x)",
            (IArg)resProtocolArgs, (IArg)memRecs, (IArg)constructHandleArgs);

    if (handle == NULL) {

        *status = IRES_ENORESOURCE;

        Log_print0(Diags_USER7,
                "[+7] IRES_HDVICP2_constructHandle> NULL handle returned through "
                "memRecs");

        Log_print0(Diags_EXIT,
                "[+X] IRES_HDVICP2_constructHandle> Exit (handle=NULL)");

        return ((IRES_Handle)NULL);
    }

    (handle->ires).getStaticProperties = IRES_HDVICP2_getStaticProperties;
    handle->configure = HDVICP2_PARAMS.configFxn;
    handle->wait = HDVICP2_PARAMS.waitFxn;
    handle->done = HDVICP2_PARAMS.doneFxn;
    handle->reset = HDVICP2_PARAMS.resetFxn;

    /*
     * Use the constructHandleargs to populate the handle withi the correct
     * id
     */
    /* This id will be LATE_ACQUIRE for late acquired (any or specific)handles*/
    handle->id = constructArgs->id;
    (handle->ires).persistent = constructArgs->persistent;

    ((IRES_HDVICP2_IntObj *)handle)->lateAcquire = constructArgs->lateAcquire;
    if (constructArgs->lateAcquire) {
        handle->acquire = IRESMAN_HDVICP2_JITacquire;
        handle->release = IRESMAN_HDVICP2_JITrelease;
        handle->reacquireIfOwner = IRESMAN_HDVICP2_JITreacquire;
    }
    else {
        handle->acquire = NULL;
        handle->release = NULL;
    }

    ((IRES_HDVICP2_IntObj *)handle)->scratchGroup = constructArgs->scratchGroup;
    /* This id will be LATEACQUIRE of late acquired any resources and "id" for
       late acquired specific resources */
    ((IRES_HDVICP2_IntObj *)handle)->reqId = constructArgs->reqId;

    if (handle->id != IRES_HDVICP2_ID_LATE_ACQUIRE) {
        handle->memoryBaseAddress =
                (void *)HDVICP2_PARAMS.memoryBaseAddress[handle->id];
        handle->registerBaseAddress =
                (void *)HDVICP2_PARAMS.registerBaseAddress[handle->id];
        handle->resetControlAddress =
                (void *)HDVICP2_PARAMS.resetControlAddress[handle->id];
    }
    else {
        handle->memoryBaseAddress = (void *)IRES_HDVICP2_INVALID_ADDR;
        handle->registerBaseAddress = (void *)IRES_HDVICP2_INVALID_ADDR;
        handle->resetControlAddress = (void *)IRES_HDVICP2_INVALID_ADDR;
    }

    *status = IRES_OK;

    Log_print2(Diags_EXIT,
            "[+X] IRES_HDVICP2_constructHandle> Exit (status=%d, handle=0x%x)",
            (IArg)(*status), (IArg)handle);

    return ((IRES_Handle)handle);
}
Beispiel #23
0
/**
 * @name   DomxTunnelMgr_registerHandle
 * @brief  Resgiter a component handle
 * @param  hComponentHandle           : Handle to component to register
 * @param  szCompName                 : Component name
 * @return none
 */
Void DomxTunnelMgr_registerHandle (OmxTypes_OMX_HANDLETYPE hComponentHandle,
                                   Char *szCompName)
{
  IArg key;
  OMX_CONFIG_DOMXPROXYCOMPINFO sDomxProxyInfo;
  OMX_ERRORTYPE eError;
  DomxCore_componentCoreInfoEntry *entry;
  Error_Block ebObj;
  Error_Block *eb = &ebObj;

  DOMX_UTL_TRACE_FUNCTION_ENTRY_LEVEL1 ();

  Log_print3 (Diags_USER1, "Entered: %s (0x%x, 0x%x)", (xdc_IArg) __FUNCTION__,
              (xdc_IArg) hComponentHandle, (xdc_IArg) szCompName);

  Error_init (eb);
  if (FALSE == DomxTunnelMgr_module->initDone)
  {
    domxtmgr_module_init ();
  }
  key = Gate_enterModule ();
  domxtmgr_map_component_name2info (szCompName, &entry, eb);
  if (NULL != entry)
  {
    if (entry->coreId == DomxCore_localCoreId)
    {
      domxtmgr_register_connection (hComponentHandle,
                                    szCompName,
                                    DomxCore_localCoreId,
                                    NULL,
                                    NULL,
                                    hComponentHandle, DomxCore_localCoreId, eb);
    }
    else
    {
      eError = OMX_GetConfig (hComponentHandle, (OMX_INDEXTYPE)
                              OMX_TI_IndexConfigGetDomxCompInfo,
                              &sDomxProxyInfo);
      if (OMX_ErrorNone == eError)
      {
        domxtmgr_register_connection (sDomxProxyInfo.hCompRealHandle,
                                      szCompName,
                                      entry->coreId,
                                      (OmxTypes_OMX_PTR) sDomxProxyInfo.
                                      nRpcSkelPtr,
                                      (OmxTypes_OMX_S8 *) sDomxProxyInfo.
                                      cComponentRcmSvrName, hComponentHandle,
                                      DomxCore_localCoreId, eb);
        /* Also register connenction on remote core */
        domxtmgr_register_connection (sDomxProxyInfo.hCompRealHandle,
                                      szCompName,
                                      entry->coreId,
                                      NULL,
                                      NULL,
                                      sDomxProxyInfo.hCompRealHandle,
                                      entry->coreId, eb);
      }
      else
      {
        DOMX_UTL_TRACE_FUNCTION_ASSERT ((OMX_ErrorNone == eError),
                                        "OMX_GetConfig returned error");
      }
    }
  }
  Gate_leaveModule (key);
  /* TODO: Component should return error code */
  DOMX_UTL_TRACE_FUNCTION_ASSERT ((FALSE == Error_check (eb)),
                                  "Error in DomxTunnelMgr_registerHandle");

  DOMX_UTL_TRACE_FUNCTION_EXIT_LEVEL1 (OMX_ErrorNone);
}
Beispiel #24
0
/*!
 * ======== VirtQueue_create ========
 */
VirtQueue_Handle VirtQueue_create(UInt16 remoteProcId, VirtQueue_Params *params,
                                  Error_Block *eb)
{
    VirtQueue_Object *vq;
    Void *vringAddr;

    /* Perform initialization we can't do in Instance_init (being non-XDC): */
    _VirtQueue_init();

    vq = Memory_alloc(NULL, sizeof(VirtQueue_Object), 0, eb);
    if (NULL == vq) {
        return (NULL);
    }

    /* Create the thread protection gate */
    vq->gateH = GateHwi_create(NULL, eb);
    if (Error_check(eb)) {
        Log_error0("VirtQueue_create: could not create gate object");
        Memory_free(NULL, vq, sizeof(VirtQueue_Object));
        return (NULL);
    }

    vq->callback = params->callback;
    vq->id = params->vqId;
    vq->procId = remoteProcId;
    vq->last_avail_idx = 0;

#ifndef SMP
    if (MultiProc_self() == appm3ProcId) {
        /* vqindices that belong to AppM3 should be big so they don't
         * collide with SysM3's virtqueues */
         vq->id += 2;
    }
#endif

    switch (vq->id) {
        /* IPC transport vrings */
        case ID_SELF_TO_A9:
            /* IPU/DSP -> A9 */
            vringAddr = (struct vring *) IPC_MEM_VRING0;
            break;
        case ID_A9_TO_SELF:
            /* A9 -> IPU/DSP */
            vringAddr = (struct vring *) IPC_MEM_VRING1;
            break;
#ifndef SMP
        case ID_APPM3_TO_A9:
            /* APPM3 -> A9 */
            vringAddr = (struct vring *) IPC_MEM_VRING2;
            break;
        case ID_A9_TO_APPM3:
            /* A9 -> APPM3 */
            vringAddr = (struct vring *) IPC_MEM_VRING3;
            break;
#endif
        default:
            GateHwi_delete(&vq->gateH);
            Memory_free(NULL, vq, sizeof(VirtQueue_Object));
            return (NULL);
    }

    Log_print3(Diags_USER1,
            "vring: %d 0x%x (0x%x)\n", vq->id, (IArg)vringAddr,
            RP_MSG_RING_SIZE);

    /* See coverity related comment in vring_init() */
    /* coverity[overrun-call] */
    vring_init(&(vq->vring), RP_MSG_NUM_BUFS, vringAddr, RP_MSG_VRING_ALIGN);

    /*
     *  Don't trigger a mailbox message every time MPU makes another buffer
     *  available
     */
    if (vq->procId == hostProcId) {
        vq->vring.used->flags &= ~VRING_USED_F_NO_NOTIFY;
    }

    queueRegistry[vq->id] = vq;

    return (vq);
}
Void AppMain_main__P(UArg arg0, UArg arg1)
{
    Error_Block eb;
    Int status = 0;


    Log_print3(Diags_ENTRY,
        "--> %s: (arg0: 0x%x, arg1: 0x%x)", (IArg)FXNN, (IArg)arg0, (IArg)arg1);


    /* initialize used modules */
    SystemCfg_init();
    Error_init(&eb);

    /* start acknowledgement */
    status = SystemCfg_startAck();

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: SystemCfg_startAck() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* system and application configuration */
    status = SystemCfg_createLocalResources();

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: "
            "SystemCfg_createLocalResources() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* open shared resources */
    status = SystemCfg_openSharedResources(App_startup, NULL);

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: "
            "SystemCfg_openSharedResources() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* invoke the application entry point */
    status = App_exec(NULL);

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: App_exec() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* start the shutdown process */
    status = SystemCfg_closeSharedResources(App_shutdown, NULL);

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: "
            "SystemCfg_closeSharedResources() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    status = SystemCfg_deleteLocalResources();

    if (status < 0) {
        /* Log_error() */
        Log_print4(Diags_USER8,
            "Error: %s, line %d: %s: "
            "SystemCfg_deleteLocalResources() returned error %d",
            (IArg)__FILE__, (IArg)__LINE__, (IArg)FXNN, (IArg)status);
        goto leave;
    }

    /* finalize used modules */
    SystemCfg_exit();


leave:
    Log_print2(Diags_EXIT, "<-- %s: %d", (IArg)FXNN, (IArg)status);
    return;
}
Beispiel #26
0
/* ARGSUSED */
static IRES_Handle getBuf(IALG_Handle alg, IRES_ResourceDescriptor *resDesc,
        Int scratchId, IRES_Status *pStatus)
{
    BUFRES_ConstructArgs cArgs;
    BUFRES_Handle        res = NULL;
    IALG_MemRec          memRecs[MAXRECS];
    Int                  nRecs;
    Int                  length;
    Int                  align;
    Void                *base = NULL;
    IRES_RequestMode     mode;
    IRES_Status          status = IRES_OK;
    IRES_Status          retVal;
    IRES_ProtocolArgs    *args = resDesc->protocolArgs;

    Log_print0(Diags_ENTRY, "[+E] BUFRES getBuf> entered>");

    Assert_isTrue(pStatus != NULL, (Assert_Id)NULL);
    Assert_isTrue(args != NULL, (Assert_Id)NULL);

    length = ((BUFRES_Args *)args)->length;
    align = ((BUFRES_Args *)args)->align;
    mode = args->mode; /* IRES_SCRATCH or IRES_PERSISTENT */

    Log_print3(Diags_ENTRY, "[+E] BUFRES getBuf> length [0x%x], "
            "align [0x%x], mode = %s>", (IArg)length, (IArg)align,
            (IArg)((mode == IRES_PERSISTENT) ? "IRES_PERSISTENT" :
                    "IRES_SCRATCH"));

    if (curInit == 0) {
        *pStatus = IRES_ENOINIT;
        return (NULL);
    }

    /* TODO: acquire a lock */

    /*
     *  The buffer can be used for the resource request if it is currently
     *  being used by another algorithm with the same scratchId, or if
     *  the buffer is not currently being used. The memory chunk of the
     *  requested size and alignment must also fit in the buffer.
     */
    if (((mode == IRES_SCRATCH) && (mode == buffer.mode) &&
                (scratchId == buffer.scratchId)) ||
            (buffer.refCount == 0)) {
        if ((base = bufAlloc(0, length, align)) == NULL) {
            /* The requested memory will not fit in the buffer */
            Log_print0(Diags_USER6, "[+6] BUFRES getBuf> buffer resource"
                    " allocation failed.");
            status = IRES_ENORESOURCE;
        }
    }
    else {
        /* Buffer is in use */
        status = IRES_ENORESOURCE;
    }

    if (status == IRES_OK) {
        /*
         *  Found available resource, now allocate memory to construct
         *  a BUFRES handle to pass back to the algorithm.
         */
        /* Number of buffers needed to construct a BUFRES object */
        nRecs = getNumRecs(args);

        if (nRecs > MAXRECS) {
            /* Error: Weren't expecting to allocate this many buffers */
            status = IRES_EFAIL;
        }
        else {
            /*
             *  Fill in memRecs[] with memory requirements to allocate the
             *  BUFRES object.
             */
            retVal = getMemRecs(NULL, args, memRecs);
            if (retVal != IRES_OK) {
                status = IRES_ENOMEM;
            }
            else {
                /* Now allocate memory used to construct the BUFRES object */
                if (!allocFxn(memRecs, nRecs)) {
                    status = IRES_ENOMEM;
                }
            }
        }
    }

    if (status == IRES_OK) {
        /* Init cArgs with whatever is necessary to construct BUFRES object */
        cArgs.size = sizeof(BUFRES_ConstructArgs);
        cArgs.base = base;

        /* Initialize the buffers */
        res = (BUFRES_Handle)constructHandle(args, memRecs,
                (IRESMAN_ConstructArgs *)&cArgs, &retVal);

        if (retVal != IRES_OK) {
            freeFxn(memRecs, nRecs);
            status = IRES_EFAIL;
        }
        else {
            /*
             *  Increment the reference count on the buffer and set
             *  scratchId, mode
             */
            buffer.refCount++;
            buffer.scratchId = scratchId;
            buffer.mode = mode;
            resDesc->handle = (IRES_Handle)res;
        }
    }

    /* TODO: release lock */

    *pStatus = status;

    Log_print1(Diags_EXIT, "[+X] BUFRES getBuf> returning handle 0x%x",
            (IArg)res);

    resDesc->handle = (IRES_Handle)res;

    (resDesc->revision)->Major = 1;
    (resDesc->revision)->Source = 0;
    (resDesc->revision)->Radius = 0;

    return ((IRES_Handle)res);
}
Beispiel #27
0
/*
 *  ======== encode_decode ========
 */
static Void encode_decode(VIDENC1_Handle enc, VIDDEC2_Handle dec, FILE *in,
    FILE *out)
{
    Int                         n;
    Int32                       status;

    VIDDEC2_InArgs              decInArgs;
    VIDDEC2_OutArgs             decOutArgs;
    VIDDEC2_DynamicParams       decDynParams;
    VIDDEC2_Status              decStatus;

    VIDENC1_InArgs              encInArgs;
    VIDENC1_OutArgs             encOutArgs;
    VIDENC1_DynamicParams       encDynParams;
    VIDENC1_Status              encStatus;

    IVIDEO1_BufDescIn           encInBufDesc;

    XDM_BufDesc                 encOutBufDesc;
    XDAS_Int8                  *encoded[XDM_MAX_IO_BUFFERS];
    XDAS_Int32                  encBufSizes[XDM_MAX_IO_BUFFERS];

    XDM1_BufDesc                decInBufDesc;

    XDM_BufDesc                 decOutBufDesc;
    XDAS_Int8                  *dst[XDM_MAX_IO_BUFFERS];
    XDAS_Int32                  outBufSizes[XDM_MAX_IO_BUFFERS];

    /* clear and initialize the buffer descriptors */
    memset(encoded, 0, sizeof(encoded[0]) * XDM_MAX_IO_BUFFERS);
    memset(dst,     0, sizeof(dst[0])     * XDM_MAX_IO_BUFFERS);

    encoded[0] = encodedBuf;
    dst[0]     = outBuf;

    encInBufDesc.numBufs = encOutBufDesc.numBufs = decInBufDesc.numBufs =
        decOutBufDesc.numBufs = 1;

    encOutBufDesc.bufSizes  = encBufSizes;
    decOutBufDesc.bufSizes  = outBufSizes;

    encInBufDesc.bufDesc[0].bufSize = encBufSizes[0] =
        decInBufDesc.descs[0].bufSize = outBufSizes[0] = NSAMPLES;

    encInBufDesc.bufDesc[0].buf = inBuf;
    encOutBufDesc.bufs = encoded;
    decInBufDesc.descs[0].buf = encoded[0];
    decOutBufDesc.bufs     = dst;

    encInBufDesc.frameWidth     = 0;  /* TODO */
    encInBufDesc.frameHeight    = 0;  /* TODO */
    encInBufDesc.framePitch     = 0;  /* TODO */

    /* initialize all "sized" fields */
    encInArgs.size    = sizeof(encInArgs);
    decInArgs.size    = sizeof(decInArgs);
    encOutArgs.size   = sizeof(encOutArgs);
    decOutArgs.size   = sizeof(decOutArgs);
    encDynParams.size = sizeof(encDynParams);
    decDynParams.size = sizeof(decDynParams);
    encStatus.size    = sizeof(encStatus);
    decStatus.size    = sizeof(decStatus);

    /*
     * Note that we use versionBuf in both the encoder and decoder.  In this
     * application, this is okay, as there is always only one user of
     * the buffer.  Not all applications can make this assumption.
     */
    encStatus.data.buf     = decStatus.data.buf     = versionBuf;
    encStatus.data.bufSize = decStatus.data.bufSize = MAXVERSIONSIZE;

    /* if the codecs support it, dump their versions */
    status = VIDDEC2_control(dec, XDM_GETVERSION, &decDynParams, &decStatus);
    Log_print1(Diags_USER1, "[+1] Decoder version:  %s",
            (IArg)((status == VIDDEC2_EOK ? ((char *)decStatus.data.buf) :
            "[unknown]")));

    status = VIDENC1_control(enc, XDM_GETVERSION, &encDynParams, &encStatus);
    Log_print1(Diags_USER1, "[+1] Encoder version:  %s",
            (IArg)((status == VIDENC1_EOK ? ((char *)encStatus.data.buf) :
            "[unknown]")));

    /*
     * This app expects the encoder to provide 1 buf in and get 1 buf out,
     * and the buf sizes of the in and out buffer must be able to handle
     * NSAMPLES bytes of data.
     */
    status = VIDENC1_control(enc, XDM_GETSTATUS, &encDynParams, &encStatus);
    if (status != VIDENC1_EOK) {
        /* failure, report error and exit */
        Log_print1(Diags_USER7, "[+7] encode control status = %ld",
                (IArg)status);
        return;
    }

    /* Validate this encoder codec will meet our buffer requirements */
    if ((encInBufDesc.numBufs < encStatus.bufInfo.minNumInBufs) ||
        (IFRAMESIZE < encStatus.bufInfo.minInBufSize[0]) ||
        (encOutBufDesc.numBufs < encStatus.bufInfo.minNumOutBufs) ||
        (EFRAMESIZE < encStatus.bufInfo.minOutBufSize[0])) {

        /* failure, report error and exit */
        Log_print0(Diags_USER7, "[+7] Error:  encoder codec feature conflict");
        return;
    }

    status = VIDDEC2_control(dec, XDM_GETSTATUS, &decDynParams, &decStatus);
    if (status != VIDDEC2_EOK) {
        /* failure, report error and exit */
        Log_print1(Diags_USER7, "[+7] decode control status = %ld",
                (IArg)status);
        return;
    }

    /* Validate this decoder codec will meet our buffer requirements */
    if ((decInBufDesc.numBufs < decStatus.bufInfo.minNumInBufs) ||
        (EFRAMESIZE < decStatus.bufInfo.minInBufSize[0]) ||
        (decOutBufDesc.numBufs < decStatus.bufInfo.minNumOutBufs) ||
        (OFRAMESIZE < decStatus.bufInfo.minOutBufSize[0])) {

        /* failure, report error and exit */
        Log_print0(Diags_USER7,
                "[+7] App-> ERROR: decoder does not meet buffer requirements.");
        return;
    }

    /*
     * Read complete frames from in, encode, decode, and write to out.
     */
    for (n = 0; fread(inBuf, IFRAMESIZE, 1, in) == 1; n++) {

#ifdef CACHE_ENABLED
#if defined(xdc_target__isaCompatible_64P) || \
    defined(xdc_target__isaCompatible_64T)
        /*
         *  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, IFRAMESIZE);
#else
#error Unvalidated config - add appropriate fread-related cache maintenance
#endif
        /* Per DMA Rule 7, our output buffer cache lines must be cleaned */
        Memory_cacheInv(encodedBuf, EFRAMESIZE);
#endif

        Log_print1(Diags_USER1, "[+1] App-> Processing frame %d...", (IArg)n);

        /*
         * Encode the frame.
         *
         * Note, inputID == 0 is an error.  This example doesn't account
         * for the case where 'n + 1' wraps to zero.
         */
        encInArgs.inputID = n + 1;
        status = VIDENC1_process(enc, &encInBufDesc, &encOutBufDesc, &encInArgs,
            &encOutArgs);

        Log_print2(Diags_USER2,
                "[+2] App-> Encoder frame %d process returned - 0x%x)",
                (IArg)n, (IArg)status);

        if (status != VIDENC1_EOK) {
            Log_print3(Diags_USER7,
                    "[+7] App-> Encoder frame %d processing FAILED, status = 0x%x, "
                    "extendedError = 0x%x",
                    (IArg)n, (IArg)status, (IArg)(encOutArgs.extendedError));
            break;
        }

        /*
         * So far, so good.  Validate our assumption that the encoder
         * provided encodedBuf as it's encOutArgs->encodedBuf.buf.  If
         * that's not the case, we may be dealing with a codec that's
         * giving us out of order frames... and this simple app
         * doesn't support that.
         */
        if (encOutArgs.encodedBuf.buf != encodedBuf) {
            Log_print0(Diags_USER7,
                    "[+7] App-> Internal error.  Unsupported encoder");
            break;
        }

#ifdef CACHE_ENABLED
        /*
         * Conditionally writeback the encoded buf from the previous
         * call.  Also, as encodedBuf is an inBuf to the next process
         * call, conditionally invalidate it as well.
         */
        if (XDM_ISACCESSMODE_WRITE(encOutArgs.encodedBuf.accessMask)) {
            Memory_cacheWbInv(encodedBuf, EFRAMESIZE);
        }

        /*
         * Per DMA Rule 7, our output buffer cache lines (for the
         * upcoming decoder) must be cleaned.
         */
        Memory_cacheInv(outBuf, OFRAMESIZE);
#endif

        /* decode the frame */
        decInArgs.numBytes = EFRAMESIZE;
        decInArgs.inputID = 1;  /* typically this varies by each frame */
        status = VIDDEC2_process(dec, &decInBufDesc, &decOutBufDesc,
            &decInArgs, &decOutArgs);

        Log_print2(Diags_USER2,
                "[+2] App-> Decoder frame %d process returned - 0x%x)",
                (IArg)n, (IArg)status);

        if (status != VIDDEC2_EOK) {
            Log_print2(Diags_USER7,
                    "[+7] App-> Decoder frame %d processing FAILED, status ="
                    " 0x%x", (IArg)n, (IArg)status);
            break;
        }

        /* again, validate our assumption that we don't get out-of-order bufs */
        if (decOutArgs.decodedBufs.bufDesc[0].buf != outBuf) {
            Log_print0(Diags_USER7,
                    "[+7] App-> Internal error.  Unsupported decoder");
            break;
        }

#ifdef CACHE_ENABLED
        /* Conditionally writeback the decoded buf */
        if (XDM_ISACCESSMODE_WRITE(
                decOutArgs.decodedBufs.bufDesc[0].accessMask)) {
            Memory_cacheWb(outBuf, OFRAMESIZE);
        }
#endif

        /* write to file */
        fwrite(dst[0], OFRAMESIZE, 1, out);
    }

    Log_print1(Diags_USER1, "[+1] %d frames encoded/decoded", (IArg)n);
}
/*
 *  ======== addContigBuf ========
 */
static ContigBuf *addContigBuf(UInt32 virtualAddress, UInt32 sizeInBytes,
    UInt32 physicalAddress)
{
    ContigBuf *cb;
    Int        cbCount = 0;

    Log_print3(Diags_USER1, "[+1] Memory__addContigBuf> "
            "Enter(virtAddr=0x%x, size=0x%x, physAddr=0x%x)",
            (IArg)virtualAddress, (IArg)sizeInBytes, (IArg)physicalAddress);

    for (cb = contigBufList; cb != NULL; cb = cb->next) {

        /* check if the submitted contigbuf intersects current contigbuf;
         * (notation: { } is "current", [ ] is "submitted"
         * 1. if submitted cb is a subset of current cb, return current cb;
         * 2. if current cb is a subset of submitted cb, set current cb
         *    to submitted cb, return current cb
         * 3. if they intersect but neither is a subset of the other,
         *    set current cb to union of current and submitted, return cur
         */
        UInt32 startCurrent   = cb->physicalAddress;
        UInt32 endCurrent     = startCurrent + cb->sizeInBytes;
        UInt32 startSubmitted = physicalAddress;
        UInt32 endSubmitted   = physicalAddress + sizeInBytes;

        if (startCurrent <= startSubmitted &&
            endCurrent   >= endSubmitted) {    /* case 1:  { [      ] } */
            Log_print4(Diags_USER1, "[+1] Memory__addContigBuf> "
                    "case 1 (Sc=0x%x, Ec=0x%x, Ss=0x%x, Es=0x%x",
                    (IArg)startCurrent, (IArg)endCurrent, (IArg)startSubmitted,
                    (IArg)endSubmitted);
            cb->virtualAddress =
                virtualAddress - (startSubmitted - startCurrent);
            break;                             /* current: {          } */
        }

        if (startSubmitted <= startCurrent &&
            endSubmitted   >= endCurrent) {    /* case 2:  [ {      } ] */
            Log_print4(Diags_USER1, "[+1] Memory__addContigBuf> "
                    "case 2 (Sc=0x%x, Ec=0x%x, Ss=0x%x, Es=0x%x",
                    (IArg)startCurrent, (IArg)endCurrent, (IArg)startSubmitted,
                    (IArg)endSubmitted);
            cb->physicalAddress = physicalAddress;
            cb->sizeInBytes     = sizeInBytes;
            cb->virtualAddress  = virtualAddress;
            break;                             /* current: {          } */
        }

        if (startCurrent <= startSubmitted &&
            endCurrent   >  startSubmitted) {  /* case 3a: {  [     } ] */
            /* [dm] per fix for a bug noted in ce-b21: cb's should not be
             * merged if they merely *touch* -- only if they truly overlap;
             * adjacency in the virtual space doesn't guarantee adjacency
             * in physical space, and vice versa; so we merge only
             * if endCurrent > startSubmitted, not if >=.
             */
            Log_print4(Diags_USER1, "[+1] Memory__addContigBuf> "
                    "case 3a (Sc=0x%x, Ec=0x%x, Ss=0x%x, Es=0x%x",
                    (IArg)startCurrent, (IArg)endCurrent, (IArg)startSubmitted,
                    (IArg)endSubmitted);
            cb->sizeInBytes = endSubmitted - startCurrent;
            cb->virtualAddress =
                virtualAddress - (startSubmitted - startCurrent);
            break;                             /* current: {          } */
        }

        if (startSubmitted <= startCurrent &&
            endSubmitted   >  startCurrent) { /* case 3b: [  {     ] } */
            /* ... and here we merge only if endSubmitted > startCurrent. */
            Log_print4(Diags_USER1, "[+1] Memory__addContigBuf> "
                    "case 3b (Sc=0x%x, Ec=0x%x, Ss=0x%x, Es=0x%x",
                    (IArg)startCurrent, (IArg)endCurrent, (IArg)startSubmitted,
                    (IArg)endSubmitted);
            cb->physicalAddress = physicalAddress;
            cb->virtualAddress  = virtualAddress;
            cb->sizeInBytes     = endCurrent - startSubmitted;
            break;                             /* current: {          } */
        }

        /* else submitted and current cb are completely disjoint, so continue
         */

        /* delete any old elements; the caller has the lock acquired. */
        if ((++cbCount > Memory_maxCbListSize) && (cb->next != NULL)) {
            ContigBuf *cbNext = cb->next;
            cb->next = cbNext->next;
            free(cbNext);
        }

    }

    if (cb == NULL) {  /* either because it's the 1st or no match was found */
        Log_print0(Diags_USER1, "[+1] Memory__addContigBuf> "
                "creating new contigBuf object");
        cb = myMalloc(sizeof(ContigBuf));
        if (cb == NULL) {
            goto addContigBuf_return;
        }
        cb->virtualAddress  = virtualAddress;
        cb->sizeInBytes     = sizeInBytes;
        cb->physicalAddress = physicalAddress;

        cb->next = contigBufList;
        contigBufList = cb;
    }

addContigBuf_return:

    if (cb) {
        Log_print3(Diags_USER1, "[+1] Memory__addContigBuf> "
                "returning: cb->phys=0x%x, cb->size=0x%x, cb->virt=0x%x",
                (IArg)(cb->physicalAddress), (IArg)(cb->sizeInBytes),
                (IArg)(cb->virtualAddress));
    }
    else {
        Log_print0(Diags_USER7, "[+7] Memory__addContigBuf> out of Memory");
    }

    return (cb);
}
Beispiel #29
0
Int testNS(NameServer_Handle nsHandle, String name)
{
    Int32 status = 0;
    Ptr ptr;
    UInt32 val;
    char key[16];
    Int i;

    ptr = NameServer_addUInt32(nsHandle, name, 0xdeadbeef);
    if (ptr == NULL) {
        Log_print0(Diags_INFO, "Failed to NameServer_addUInt32()\n");
        return -1;
    }
    else {
        Log_print1(Diags_INFO, "NameServer_addUInt32() returned %p\n", (IArg)ptr);
    }

    Log_print0(Diags_INFO, "Trying to add same key (should fail)...\n");
    ptr = NameServer_addUInt32(nsHandle, name, 0xdeadc0de);
    if (ptr == NULL) {
        Log_print0(Diags_INFO, " ...got expected Failure from NameServer_addUInt32()\n");
    }
    else {
        Log_print1(Diags_INFO, "    Error: NameServer_addUInt32() returned non-NULL %p (but was expected to fail)\n", (IArg)ptr);
        return -1;
    }

    val = 0x00c0ffee;
    status = NameServer_getUInt32(nsHandle, name, &val, NULL);
    Log_print2(Diags_INFO, "NameServer_getUInt32() returned %d, val=0x%x (was 0x00c0ffee)\n", status, val);

    Log_print0(Diags_INFO, "Removing 0xdeadbeef w/ NameServer_remove()...\n");
    status = NameServer_remove(nsHandle, name);
    if (status < 0) {
        Log_print1(Diags_INFO, "NameServer_remove() failed: %d\n", status);
        return -1;
    }

    ptr = NameServer_addUInt32(nsHandle, name, 0xdeadc0de);
    if (ptr == NULL) {
        Log_print0(Diags_INFO, "Error: NameServer_addUInt32() failed\n");
        return -1;
    }
    else {
        Log_print0(Diags_INFO, "NameServer_addUInt32(0xdeadc0de) succeeded\n");
    }

    val = 0x00c0ffee;
    status = NameServer_getUInt32(nsHandle, name, &val, NULL);
    Log_print2(Diags_INFO, "NameServer_getUInt32() returned %d, val=0x%x (was 0x00c0ffee)\n", status, val);

    Log_print0(Diags_INFO, "Removing 0xdeadc0de w/ NameServer_removeEntry()...\n");
    status = NameServer_removeEntry(nsHandle, ptr);
    if (status < 0) {
        Log_print1(Diags_INFO, "NameServer_remove() failed: %d\n", status);
        return -1;
    }

    ptr = NameServer_addUInt32(nsHandle, name, 0x0badc0de);
    if (ptr == NULL) {
        Log_print0(Diags_INFO, "Error: NameServer_addUInt32() failed\n");
        return -1;
    }
    else {
        Log_print0(Diags_INFO, "NameServer_addUInt32(0x0badc0de) succeeded\n");
    }

    val = 0x00c0ffee;
    status = NameServer_getUInt32(nsHandle, name, &val, NULL);
    Log_print2(Diags_INFO, "NameServer_getUInt32() returned %d, val=0x%x (was 0x00c0ffee)\n", status, val);

    status = NameServer_remove(nsHandle, name);
    if (status < 0) {
        Log_print0(Diags_INFO, "Error: NameServer_remove() failed\n");
        return -1;
    }
    else {
        Log_print1(Diags_INFO, "NameServer_remove(%s) succeeded\n", (IArg)name);
    }

    for (i = 0; i < 10; i++) {
        sprintf(key, "foobar%d", i);

        ptr = NameServer_addUInt32(nsHandle, key, 0x0badc0de + i);
        if (ptr == NULL) {
            Log_print0(Diags_INFO, "Error: NameServer_addUInt32() failed\n");
            return -1;
        }
        else {
            Log_print2(Diags_INFO, "NameServer_addUInt32(%s, 0x%x) succeeded\n", (IArg)key, 0x0badc0de + i);
        }

        val = 0x00c0ffee;
        status = NameServer_getUInt32(nsHandle, key, &val, NULL);
        Log_print3(Diags_INFO, "NameServer_getUInt32(%s) returned %d, val=0x%x (was 0x00c0ffee)\n", (IArg)key, status, val);

        if (val != (0x0badc0de + i)) {
            Log_print2(Diags_INFO, "get val (0x%x) != add val (0x%x)!\n", val, 0x0badc0de + i);
        }
    }

    for (i = 0; i < 10; i++) {
        sprintf(key, "foobar%d", i);

        status = NameServer_remove(nsHandle, key);
        if (status < 0) {
            Log_print0(Diags_INFO, "Error: NameServer_remove() failed\n");
            return -1;
        }
        else {
            Log_print1(Diags_INFO, "NameServer_remove(%s) succeeded\n", (IArg)key);
        }
    }

    return 0;
}
Beispiel #30
0
static Bool writebackVideo2BufDesc(IVIDEO2_BufDesc *pBufDesc)
{
    Int i;

    /* Check for a spec violation - probably should be an assert! */
    if ((pBufDesc->numPlanes >=3) || (pBufDesc->numMetaPlanes >= 3)) {
        Log_print3(Diags_USER7,
            "[+7] ERROR> pBufDesc (0x%x) has invalid .numPlanes (0x%x) and/or "
            ".numMetaPlanes (0x%x) fields!", (IArg)pBufDesc,
            pBufDesc->numPlanes, pBufDesc->numMetaPlanes);
        return (FALSE);
    }

    for (i = 0; i < pBufDesc->numPlanes; i++) {
        if ((pBufDesc->planeDesc[i].buf != NULL) &&
                (XDM_ISACCESSMODE_WRITE(pBufDesc->planeDesc[i].accessMask))) {

            if (pBufDesc->planeDesc[i].memType == XDM_MEMTYPE_RAW) {
                Memory_cacheWb(pBufDesc->planeDesc[i].buf,
                        pBufDesc->planeDesc[i].bufSize.bytes);
            } else {
                /* TODO:H are tiled buffers cacheable? */
            }
        }

        /*
         * Since we've cacheWb this buffer, we arguably should reflect
         * this cache state and clear the WRITE bit in the .accessMask
         * field.  However, we know the stub doesn't propogate this
         * field to the calling app, so this extra buffer management
         * detail isn't necessary:
         *
         * XDM_CLEARACCESSMODE_WRITE(pBufDesc->planeDesc[i].accessMask);
         */
    }

    for (i = 0; i < pBufDesc->numMetaPlanes; i++) {
        if ((pBufDesc->metadataPlaneDesc[i].buf != NULL) &&
                (XDM_ISACCESSMODE_WRITE(
                    pBufDesc->metadataPlaneDesc[i].accessMask))) {

            if (pBufDesc->metadataPlaneDesc[i].memType == XDM_MEMTYPE_RAW) {
                Memory_cacheWb(pBufDesc->metadataPlaneDesc[i].buf,
                        pBufDesc->metadataPlaneDesc[i].bufSize.bytes);
            } else {
                /* TODO:H are tiled buffers cacheable? */
            }
        }

        /*
         * Since we've cacheWb this buffer, we arguably should
         * reflect this cache state and clear the WRITE bit in
         * the .accessMask field.  However, we know the stub
         * doesn't propogate this field to the calling app, so
         * this extra buffer management detail isn't necessary:
         *
         * XDM_CLEARACCESSMODE_WRITE(pBufDesc->metadataPlaneDesc[i].accessMask);
         */
    }
    return (TRUE);
}