/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _AUDENC_Msg *msg  = (_AUDENC_Msg *)visaMsg;
    AUDENC_Handle handle = (AUDENC_Handle)visaHandle;
    Int i;
    XDM_BufDesc inBufs, outBufs;
    IAUDENC_OutArgs *pOutArgs;
    IAUDENC_Status *pStatus;

    /* perform the requested AUDENC operation by parsing message. */
    switch (msg->visa.cmd) {

        case _AUDENC_CPROCESS: {
            /* unmarshall inBufs and outBufs since they differ in shape
             * from what their flattened versions passed in the message
             */
            inBufs.bufs      = msg->cmd.process.inBufs;
            inBufs.numBufs   = msg->cmd.process.numInBufs;
            inBufs.bufSizes  = msg->cmd.process.inBufSizes;
            outBufs.bufs     = msg->cmd.process.outBufs;
            outBufs.numBufs  = msg->cmd.process.numOutBufs;
            outBufs.bufSizes = msg->cmd.process.outBufSizes;

            if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* invalidate cache for all input buffers */
                for (i = 0; i < inBufs.numBufs; i++) {
                    Memory_cacheInv(inBufs.bufs[i], inBufs.bufSizes[i]);
                }

                /* invalidate cache for all output buffers */
                for (i = 0; i < outBufs.numBufs; i++) {
                    Memory_cacheInv(outBufs.bufs[i], outBufs.bufSizes[i]);
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs = (IAUDENC_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                msg->cmd.process.inArgs.size);

            /* make the process call */
            msg->visa.status = AUDENC_process(handle,
                &inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* writeback cache for all output buffers  */
                for (i = 0; i < outBufs.numBufs; i++) {
                    Memory_cacheWb(outBufs.bufs[i], outBufs.bufSizes[i]);
                }
            }

            /*
             * Note that any changes to individual outBufs[i] values made by
             * the codec will automatically update msg->cmd.process.outBufs
             * as we pass the outBufs array by reference.
             */

            break;
        }

        case _AUDENC_CCONTROL: {
            /* unmarshall status based on the "size" of params */
            pStatus = (IAUDENC_Status *)((UInt)(&(msg->cmd.control.params)) +
                msg->cmd.control.params.size);

            msg->visa.status = AUDENC_control(handle, msg->cmd.control.id,
                &(msg->cmd.control.params), pStatus);

             break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _VIDTRANSCODE_Msg *msg  = (_VIDTRANSCODE_Msg *)visaMsg;
    VIDTRANSCODE_Handle handle = (VIDTRANSCODE_Handle)visaHandle;
    Int i;
    XDM1_BufDesc inBufs;
    XDM_BufDesc outBufs;
    IVIDTRANSCODE_OutArgs *pOutArgs;
    IVIDTRANSCODE_Status *pStatus;
    Int numBufs;

    /* perform the requested VIDTRANSCODE operation by parsing message. */
    switch (msg->visa.cmd) {

        case _VIDTRANSCODE_CPROCESS: {
            /* unmarshal inBufs and outBufs */
            inBufs           = msg->cmd.process.inBufs;

            outBufs.bufs     = msg->cmd.process.outBufs;
            outBufs.numBufs  = msg->cmd.process.numOutBufs;
            outBufs.bufSizes = msg->cmd.process.outBufSizes;

            if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* invalidate cache for all input buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (inBufs.descs[i].buf != NULL) {
                        /* valid member of sparse array, manage it */
                        Memory_cacheInv(inBufs.descs[i].buf,
                                inBufs.descs[i].bufSize);

                        if (++numBufs == inBufs.numBufs) {
                            break;
                        }
                    }
                }

                /* invalidate cache for all output buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (outBufs.bufs[i] != NULL) {
                        /* valid member of sparse array, manage it */
                        Memory_cacheInv(outBufs.bufs[i], outBufs.bufSizes[i]);

                        if (++numBufs == outBufs.numBufs) {
                            break;
                        }
                    }
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs = (IVIDTRANSCODE_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                msg->cmd.process.inArgs.size);

            /*
             * Note, there's no need to invalidate cache for
             * pOutArgs->encodedBuf bufs as they're
             * not _really_ OUT buffers.  Rather they're references to
             * the _real_ OUT buffers that are provided in outBufs - which
             * were already invalidated above.
             */

            /* make the process call */
            msg->visa.status = VIDTRANSCODE_process(handle,
                &inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* writeback cache for encoded buffers  */
                for (i = 0; i < IVIDTRANSCODE_MAXOUTSTREAMS; i++) {
                    if ((pOutArgs->outputID[0] != 0) &&
                            (pOutArgs->encodedBuf[i].buf != NULL) &&
                            XDM_ISACCESSMODE_WRITE(pOutArgs->encodedBuf[i].accessMask)) {

                        Memory_cacheWb(pOutArgs->encodedBuf[i].buf,
                                pOutArgs->encodedBuf[i].bufSize);

                        /*
                         * 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(
                         *         pOutArgs.encodedBuf[i].accessMask);
                         */
                    }
                }
            }

            /*
             * Note that any changes to individual outBufs[i] values made by
             * the codec will automatically update msg->cmd.process.outBufs
             * as we pass the outBufs array by reference.
             */

            break;
        }

        case _VIDTRANSCODE_CCONTROL: {
            /* unmarshall status based on the "size" of params */
            pStatus =
                (IVIDTRANSCODE_Status *)((UInt)(&(msg->cmd.control.dynParams)) +
                msg->cmd.control.dynParams.size);

            /* invalidate data buffer */
            if (pStatus->data.buf != NULL) {
                Memory_cacheInv(pStatus->data.buf, pStatus->data.bufSize);
            }

            msg->visa.status = VIDTRANSCODE_control(handle, msg->cmd.control.id,
                &(msg->cmd.control.dynParams), pStatus);

            /* writeback data buffer */
            if ((pStatus->data.buf != NULL) &&
                XDM_ISACCESSMODE_WRITE(pStatus->data.accessMask)) {

                Memory_cacheWb(pStatus->data.buf, pStatus->data.bufSize);

                /*
                 * 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(pStatus->data.accessMask);
                 */
            }

            break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _VIDDEC_Msg *msg  = (_VIDDEC_Msg *)visaMsg;
    VIDDEC_Handle handle = (VIDDEC_Handle)visaHandle;
    Int i;
    XDM_BufDesc inBufs, outBufs;
    IVIDDEC_OutArgs *pOutArgs;
    IVIDDEC_Status *pStatus;
    IVIDDEC_CodecClassConfig *codecClassConfig;

    /* get stub/skeleton config data; can be NULL (for old codecs) */
    codecClassConfig = (IVIDDEC_CodecClassConfig *)
                        VISA_getCodecClassConfig( visaHandle );

    /* perform the requested VIDDEC operation by parsing message. */
    switch (msg->visa.cmd) {

        case _VIDDEC_CPROCESS: {
            /* unmarshall inBufs and outBufs since they differ in shape
             * from what their flattened versions passed in the message
             */
            inBufs.bufs      = msg->cmd.process.inBufs;
            inBufs.numBufs   = msg->cmd.process.numInBufs;
            inBufs.bufSizes  = msg->cmd.process.inBufSizes;
            outBufs.bufs     = msg->cmd.process.outBufs;
            outBufs.numBufs  = msg->cmd.process.numOutBufs;
            outBufs.bufSizes = msg->cmd.process.outBufSizes;

            if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* invalidate cache for all input buffers */
                for (i = 0; i < inBufs.numBufs; i++) {
                    if (codecClassConfig != NULL && 
                            codecClassConfig->manageInBufsCache[i] == FALSE) {
                        continue;
                    }
                    Memory_cacheInv(inBufs.bufs[i], inBufs.bufSizes[i]);
                }

                /* invalidate cache for all output buffers */
                for (i = 0; i < outBufs.numBufs; i++) {
                    if (codecClassConfig != NULL && 
                        codecClassConfig->manageOutBufsCache[i] == FALSE) {
                        continue;
                    }
                    Memory_cacheInv(outBufs.bufs[i], outBufs.bufSizes[i]);
                }
            } /* SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB */

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs = (IVIDDEC_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                msg->cmd.process.inArgs.size);

            /* make the process call */
            msg->visa.status = VIDDEC_process(handle,
                &inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* flush cache for all output buffers and outArgs buffers 
                 * (unless...)
                 */
                for (i = 0; i < outBufs.numBufs; i++) {
                    if (codecClassConfig != NULL && 
                        codecClassConfig->manageOutBufsCache[i] == FALSE) {
                        continue;
                    }
                    Memory_cacheWb(outBufs.bufs[i], outBufs.bufSizes[i]);
                }
                for (i = 0; i < pOutArgs->displayBufs.numBufs; i++) {
                    if (codecClassConfig != NULL && 
                        codecClassConfig->manageDisplayBufsCache[i] == FALSE) {
                        continue;
                    }
                    Memory_cacheWbInv(pOutArgs->displayBufs.bufs[i],
                        pOutArgs->displayBufs.bufSizes[i]);
                }
            }

            /*
             * Note that any changes to individual outBufs[i] values made by
             * the codec will automatically update msg->cmd.process.outBufs
             * as we pass the outBufs array by reference.
             */

            break;
        }

        case _VIDDEC_CCONTROL: {
            /* unmarshall status based on the "size" of params */
            pStatus = (IVIDDEC_Status *)((UInt)(&(msg->cmd.control.params)) +
                msg->cmd.control.params.size);

            msg->visa.status = VIDDEC_control(handle, msg->cmd.control.id,
                &(msg->cmd.control.params), pStatus);

             break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _VIDDEC1_Msg *msg  = (_VIDDEC1_Msg *)visaMsg;
    VIDDEC1_Handle handle = (VIDDEC1_Handle)visaHandle;
    Int i, j;
    XDM1_BufDesc inBufs;
    XDM_BufDesc outBufs;
    IVIDDEC1_OutArgs *pOutArgs;
    IVIDDEC1_Status *pStatus;
    IVIDDEC1_CodecClassConfig *codecClassConfig;
    Int numBufs;

    /* get stub/skeleton config data; can be NULL (for old codecs) */
    codecClassConfig = (IVIDDEC1_CodecClassConfig *)
                        VISA_getCodecClassConfig( visaHandle );

    /* perform the requested VIDDEC1 operation by parsing message. */
    switch (msg->visa.cmd) {

        case _VIDDEC1_CPROCESS: {
            /* unmarshall inBufs and outBufs */
            inBufs           = msg->cmd.process.inBufs;

            outBufs.bufs     = msg->cmd.process.outBufs;
            outBufs.numBufs  = msg->cmd.process.numOutBufs;
            outBufs.bufSizes = msg->cmd.process.outBufSizes;

            if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* invalidate cache for all input buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (inBufs.descs[i].buf != NULL) {
                        /* valid member of sparse array,
                         * invalidate it unless user configured it not to
                         */
                        if (codecClassConfig != NULL &&
                                codecClassConfig->manageInBufsCache[i] == FALSE) {
                            /* do nothing, i.e. don't invalidate */
                        } else {
                            Memory_cacheInv(inBufs.descs[i].buf,
                                    inBufs.descs[i].bufSize);
                        }

                        if (++numBufs == inBufs.numBufs) {
                            break;
                        }
                    }
                }

                /* invalidate cache for all output buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (outBufs.bufs[i] != NULL) {
                        /* valid member of sparse array,
                         * invalidate it unless user configured it not to
                         */
                        if (codecClassConfig != NULL &&
                                codecClassConfig->manageOutBufsCache[i] == FALSE) {
                            /* do nothing, i.e. don't invalidate */
                        } else {
                            Memory_cacheInv(outBufs.bufs[i], outBufs.bufSizes[i]);
                        }

                        if (++numBufs == outBufs.numBufs) {
                            break;
                        }
                    }
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs = (IVIDDEC1_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                msg->cmd.process.inArgs.size);

            /*
             * Note, there's no need to invalidate cache for
             * pOutArgs->decodedBuf bufs nor pOutArgs->displayBufs
             * bufs as the app doesn't provide OUT buffers to the
             * algorithm via these fields.
             */

            /* make the process call */
            msg->visa.status = VIDDEC1_process(handle,
                &inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /*
                 * We probably should only be doing this if msg->visa.status
                 * is IVIDDEC2_EOK or _EFAIL and .extendedError is non-fatal.
                 */

                /*
                 * Writeback cache for all output buffers:
                 *   - .decodedBufs
                 *   - .displayBufs
                 *   - .mbDataBuf
                 */
                for (i = 0; (i < pOutArgs->decodedBufs.numBufs) &&
                         (i < IVIDEO_MAX_YUV_BUFFERS); i++) {
                    if ((pOutArgs->decodedBufs.bufDesc[i].buf != NULL) &&
                            (XDM_ISACCESSMODE_WRITE(
                            pOutArgs->decodedBufs.bufDesc[i].accessMask))) {
                        Memory_cacheWb(pOutArgs->decodedBufs.bufDesc[i].buf,
                                pOutArgs->decodedBufs.bufDesc[i].bufSize);
                    }

                    /*
                     * 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(
                     *         outArgs->decodedBufs.bufDesc[i].accessMask);
                     */
                }

                 for (i = 0; (pOutArgs->outputID[i] != 0) && (i < XDM_MAX_IO_BUFFERS); i++) {
                    for (j = 0; j < pOutArgs->displayBufs[i].numBufs; j++) {
                        if ((pOutArgs->displayBufs[i].bufDesc[j].buf != NULL) &&
                                (XDM_ISACCESSMODE_WRITE(pOutArgs->displayBufs[i].bufDesc[j].accessMask))) {

                            Memory_cacheWb(pOutArgs->displayBufs[i].bufDesc[j].buf,
                                    pOutArgs->displayBufs[i].bufDesc[j].bufSize);

                            /*
                             * 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(
                             *         outArgs->displayBufs.bufDesc[i].accessMask);
                             */
                        }
                    }
                }

                if ((pOutArgs->outputMbDataID != 0) &&
                        (pOutArgs->mbDataBuf.buf != NULL) &&
                        (XDM_ISACCESSMODE_WRITE(pOutArgs->mbDataBuf.accessMask))) {

                    Memory_cacheWb(pOutArgs->mbDataBuf.buf,
                            pOutArgs->mbDataBuf.bufSize);

                    /*
                     * 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(outArgs->mbDataBuf.accessMask);
                     */
                }
            }

            /*
             * Note that any changes to individual outBufs[i] values made by
             * the codec will automatically update msg->cmd.process.outBufs
             * as we pass the outBufs array by reference.
             */

            break;
        }

        case _VIDDEC1_CCONTROL: {
            /* unmarshall status based on the "size" of params */
            pStatus = (IVIDDEC1_Status *)((UInt)(&(msg->cmd.control.params)) +
                msg->cmd.control.params.size);

            /* invalidate data buffer */
            if (pStatus->data.buf != NULL) {
                Memory_cacheInv(pStatus->data.buf, pStatus->data.bufSize);
            }

            msg->visa.status = VIDDEC1_control(handle, msg->cmd.control.id,
                &(msg->cmd.control.params), pStatus);

            /* writeback data buffer */
            if ((pStatus->data.buf != NULL) &&
                XDM_ISACCESSMODE_WRITE(pStatus->data.accessMask)) {

                Memory_cacheWb(pStatus->data.buf, pStatus->data.bufSize);

                /*
                 * 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(pStatus->data.accessMask);
                 */
            }

            break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
Example #5
0
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _AUDENC1_Msg *msg  = (_AUDENC1_Msg *)visaMsg;
    AUDENC1_Handle handle = (AUDENC1_Handle)visaHandle;
    Int i;
    XDM1_BufDesc inBufs, outBufs;
    IAUDENC1_OutArgs *pOutArgs;
    IAUDENC1_Status *pStatus;
    Int numBufs;

    /* perform the requested AUDENC1 operation by parsing message. */
    switch (msg->visa.cmd) {

        case _AUDENC1_CPROCESS: {
            /* unmarshal inBufs and outBufs */
            inBufs = msg->cmd.process.inBufs;
            outBufs = msg->cmd.process.outBufs;
            if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* invalidate cache for all input buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (inBufs.descs[i].buf != NULL) {
                        /* valid member of sparse array, manage it */
                        Memory_cacheInv(inBufs.descs[i].buf,
                                inBufs.descs[i].bufSize);

                        if (++numBufs == inBufs.numBufs) {
                            break;
                        }
                    }
                }

                /* invalidate cache for buffers in inArgs */
                if (msg->cmd.process.inArgs.ancData.buf != NULL) {
                    Memory_cacheInv(msg->cmd.process.inArgs.ancData.buf,
                            msg->cmd.process.inArgs.ancData.bufSize);
                }

                /* invalidate cache for all output buffers */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if (outBufs.descs[i].buf != NULL) {
                        /* valid member of sparse array, manage it */
                        Memory_cacheInv(outBufs.descs[i].buf,
                                outBufs.descs[i].bufSize);

                        if (++numBufs == outBufs.numBufs) {
                            break;
                        }
                    }
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs = (IAUDENC1_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                msg->cmd.process.inArgs.size);

            /* make the process call */
            msg->visa.status = AUDENC1_process(handle,
                &inBufs, &outBufs, &(msg->cmd.process.inArgs), pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* writeback cache for all output buffers  */
                for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                    if ((outBufs.descs[i].buf != NULL) &&
                        XDM_ISACCESSMODE_WRITE(outBufs.descs[i].accessMask)) {

                        /* valid member of sparse array, written to via CPU */
                        Memory_cacheWb(outBufs.descs[i].buf,
                                outBufs.descs[i].bufSize);

                        /*
                         * 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(outBufs.descs[i].accessMask);
                         */

                        if (++numBufs == outBufs.numBufs) {
                            break;
                        }
                    }
                }
            }

            /*
             * Note that any changes to individual outBufs[i] values made by
             * the codec will automatically update msg->cmd.process.outBufs
             * as we pass the outBufs array by reference.
             */

            break;
        }

        case _AUDENC1_CCONTROL: {
            /* unmarshall status based on the "size" of params */
            pStatus = (IAUDENC1_Status *)((UInt)(&(msg->cmd.control.params)) +
                msg->cmd.control.params.size);

            /* invalidate data buffer */
            if (pStatus->data.buf != NULL) {
                Memory_cacheInv(pStatus->data.buf, pStatus->data.bufSize);
            }

            msg->visa.status = AUDENC1_control(handle, msg->cmd.control.id,
                &(msg->cmd.control.params), pStatus);

            /* writeback data buffer */
            if ((pStatus->data.buf != NULL) &&
                XDM_ISACCESSMODE_WRITE(pStatus->data.accessMask)) {

                Memory_cacheWb(pStatus->data.buf, pStatus->data.bufSize);

                /*
                 * 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(pStatus->data.accessMask);
                 */
            }

            break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}
Example #6
0
/*
 *  ======== call ========
 */
static VISA_Status call(VISA_Handle visaHandle, VISA_Msg visaMsg)
{
    _UNIVERSAL_Msg *msg  = (_UNIVERSAL_Msg *)visaMsg;
    UNIVERSAL_Handle handle = (UNIVERSAL_Handle)visaHandle;
    Int i;
    XDM1_BufDesc inBufs, *pInBufs = &inBufs;
    XDM1_BufDesc outBufs, *pOutBufs = &outBufs;
    XDM1_BufDesc inOutBufs, *pInOutBufs = &inOutBufs;
    IUNIVERSAL_OutArgs *pOutArgs;
    IUNIVERSAL_Status *pStatus;
    Int numBufs;

    /* perform the requested UNIVERSAL operation by parsing message. */
    switch (msg->visa.cmd) {

        case _UNIVERSAL_CPROCESS: {
            /* unmarshal buffers */
            if (msg->cmd.process.inBufs.numBufs == 0) {
                pInBufs = NULL;
            }
            else {
                inBufs = msg->cmd.process.inBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all input buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(inBufs.descs[i].buf,
                                    inBufs.descs[i].bufSize);

                            if (++numBufs == inBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            if (msg->cmd.process.outBufs.numBufs == 0) {
                pOutBufs = NULL;
            }
            else {
                outBufs = msg->cmd.process.outBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all output buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (outBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(outBufs.descs[i].buf,
                                    outBufs.descs[i].bufSize);

                            if (++numBufs == outBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            if (msg->cmd.process.inOutBufs.numBufs == 0) {
                pInOutBufs = NULL;
            }
            else {
                inOutBufs = msg->cmd.process.inOutBufs;

                if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                    /* invalidate cache for all in/out buffers */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inOutBufs.descs[i].buf != NULL) {
                            /* valid member of sparse array, manage it */
                            Memory_cacheInv(inOutBufs.descs[i].buf,
                                    inOutBufs.descs[i].bufSize);

                            if (++numBufs == inOutBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }

            /* unmarshall outArgs based on the "size" of inArgs */
            pOutArgs =
                (IUNIVERSAL_OutArgs *)((UInt)(&(msg->cmd.process.inArgs)) +
                        msg->cmd.process.inArgs.size);

            /* make the process call */
            msg->visa.status = UNIVERSAL_process(handle,
                    pInBufs, pOutBufs, pInOutBufs, &(msg->cmd.process.inArgs),
                    pOutArgs);

            if (SKEL_cachingPolicy == SKEL_WBINVALL) {
                Memory_cacheWbInvAll();
            }
            else if (SKEL_cachingPolicy == SKEL_LOCALBUFFERINVWB) {
                /* writeback cache for output buffers  */
                if (pOutBufs != NULL) {
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (outBufs.descs[i].buf != NULL) {
                            if (XDM_ISACCESSMODE_WRITE(outBufs.descs[i]
                                        .accessMask)) {

                                /* valid member of sparse array, written via CPU */
                                Memory_cacheWb(outBufs.descs[i].buf,
                                        outBufs.descs[i].bufSize);

                                /*
                                 * 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(outBufs.descs[i]
                                 *         .accessMask);
                                 */
                            }

                            if (++numBufs == outBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }

                if (pInOutBufs != NULL) {
                    /* writeback cache for in/out buffers  */
                    for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                        if (inOutBufs.descs[i].buf != NULL) {
                            if (XDM_ISACCESSMODE_WRITE(inOutBufs.descs[i]
                                        .accessMask)) {
                        
                                /* valid member of sparse array, written via CPU */
                                Memory_cacheWb(inOutBufs.descs[i].buf,
                                        inOutBufs.descs[i].bufSize);

                                /*
                                 * 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(inOutBufs.descs[i]
                                 *         .accessMask);
                                 */
                            }

                            if (++numBufs == inOutBufs.numBufs) {
                                break;
                            }
                        }
                    }
                }
            }
            break;
        }

        case _UNIVERSAL_CCONTROL: {
            /* unmarshall status based on the "size" of dynParams */
            pStatus =
                (IUNIVERSAL_Status *)((UInt)(&(msg->cmd.control.dynParams)) +
                msg->cmd.control.dynParams.size);

            /* invalidate data buffers */
            for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                if (pStatus->data.descs[i].buf != NULL) {
                    /* valid member of sparse array, manage it */
                    Memory_cacheInv(pStatus->data.descs[i].buf,
                            pStatus->data.descs[i].bufSize);

                    if (++numBufs == pStatus->data.numBufs) {
                        break;
                    }
                }
            }

            msg->visa.status = UNIVERSAL_control(handle, msg->cmd.control.id,
                    &(msg->cmd.control.dynParams), pStatus);

            /* writeback data buffers */
            for (i = 0, numBufs = 0; i < XDM_MAX_IO_BUFFERS; i++) {
                if (pStatus->data.descs[i].buf != NULL) {
                    if (XDM_ISACCESSMODE_WRITE(pStatus->data.descs[i]
                            .accessMask)) {

                        /* valid member of sparse array, manage it */
                        Memory_cacheWb(pStatus->data.descs[i].buf,
                                pStatus->data.descs[i].bufSize);

                        /*
                         * 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(pStatus->data.descs[i]
                         *         .accessMask);
                         */
                    }

                    if (++numBufs == pStatus->data.numBufs) {
                        break;
                    }
                }
            }

            break;
        }

        default: {
            msg->visa.status = VISA_EFAIL;

            break;
        }
    }
    return (VISA_EOK);
}