static Void startExchange(Uint32 arg)
{
	MessageQCopy_Handle    handle;
	Char                   buffer[128];
	UInt32                 myEndpoint = 0;
	UInt32                 remoteEndpoint;
	UInt16                 len;
	UInt16				   dstProc;
	Int                    i;

	sb_printf("copyTask %d: Entered...:\n", arg);

	dstProc = MultiProc_getId("HOST");

	MessageQCopy_init(dstProc);

    /* Create the messageQ for receiving (and get our endpoint for sending). */
	handle = MessageQCopy_create(arg, &myEndpoint);

	NameMap_register("fuckit-all", arg);

	for (i = 0; i < APP_NUM_ITERATIONS; i++) {
		/* Await a character message: */
		MessageQCopy_recv(handle, (Ptr)buffer, &len, &remoteEndpoint,
							MessageQCopy_FOREVER);

		buffer[len] = '\0';

		len = 8;
		memcpy((Ptr)buffer, "response", 8);
		/* Send data back to remote endpoint: */
		MessageQCopy_send(dstProc, remoteEndpoint, myEndpoint,
							(Ptr)buffer, len);
	}

	/* Teardown our side: */
	MessageQCopy_delete(&handle);

	/* Free MessageQCopy module wide resources: */
	MessageQCopy_finalize();
}
Beispiel #2
0
Void OmxSrvMgr_taskFxn(UArg arg0, UArg arg1)
{
    MessageQCopy_Handle msgq;
    UInt32 local;
    UInt32 remote;
    Char msg[HDRSIZE + sizeof(struct omx_connect_req)];
    struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)msg;
    struct omx_connect_rsp * rsp = (struct omx_connect_rsp *)hdr->data;
    struct omx_connect_req * req = (struct omx_connect_req *)hdr->data;
    struct omx_disc_req * disc_req = (struct omx_disc_req *)hdr->data;
    struct omx_disc_rsp * disc_rsp = (struct omx_disc_rsp *)hdr->data;
    UInt16 dstProc;
    UInt16 len;
    UInt32 newAddr = 0;

#ifdef BIOS_ONLY_TEST
    dstProc = MultiProc_self();
#else
    dstProc = MultiProc_getId("HOST");
#endif

    MessageQCopy_init(dstProc);

    msgq = MessageQCopy_create(OMX_MGR_PORT, &local);

    System_printf("OmxSrvMgr: started on port: %d\n", OMX_MGR_PORT);

#ifdef SMP
    NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
    System_printf("OmxSrvMgr: Proc#%d sending BOOTINIT_DONE\n",
                        MultiProc_self());
    VirtQueue_postInitDone();
#else
    if (MultiProc_self() == MultiProc_getId("CORE0")) {
        NameMap_register("rpmsg-omx0", OMX_MGR_PORT);
    }
    if (MultiProc_self() == MultiProc_getId("CORE1")) {
        NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
    }
    if (MultiProc_self() == MultiProc_getId("DSP")) {
        NameMap_register("rpmsg-omx2", OMX_MGR_PORT);
    }

    if ((MultiProc_self() == MultiProc_getId("CORE1")) ||
        (MultiProc_self() == MultiProc_getId("DSP"))) {
        System_printf("OmxSrvMgr: Proc#%d sending BOOTINIT_DONE\n",
                        MultiProc_self());
        VirtQueue_postInitDone();
    }
#endif

    while (1) {
       MessageQCopy_recv(msgq, (Ptr)msg, &len, &remote, MessageQCopy_FOREVER);
       System_printf("OmxSrvMgr: received msg type: %d from addr: %d\n",
                      hdr->type, remote);
       switch (hdr->type) {
           case OMX_CONN_REQ:
            /* This is a request to create a new service, and return
             * it's connection endpoint.
             */
            System_printf("OmxSrvMgr: CONN_REQ: len: %d, name: %s\n",
                 hdr->len, req->name);

            rsp->status = ServiceMgr_createService(req->name, &newAddr);

            hdr->type = OMX_CONN_RSP;
            rsp->addr = newAddr;
            hdr->len = sizeof(struct omx_connect_rsp);
            len = HDRSIZE + hdr->len;
            break;

           case OMX_DISC_REQ:
            /* Destroy the service instance at given service addr: */
            System_printf("OmxSrvMgr: OMX_DISCONNECT: len %d, addr: %d\n",
                 hdr->len, disc_req->addr);

            disc_rsp->status = ServiceMgr_deleteService(disc_req->addr);

            /* currently, no response expected from rpmsg_omx: */
            continue;
#if 0       // rpmsg_omx is not listening for this ... yet.
            hdr->type = OMX_DISC_RSP;
            hdr->len = sizeof(struct omx_disc_rsp);
            len = HDRSIZE + hdr->len;
            break;
#endif

           default:
            System_printf("unexpected msg type: %d\n", hdr->type);
            hdr->type = OMX_NOTSUPP;
            break;
       }

       System_printf("OmxSrvMgr: Replying with msg type: %d to addr: %d "
                      " from: %d\n",
                      hdr->type, remote, local);
       MessageQCopy_send(dstProc, remote, local, msg, len);
    }
}
Beispiel #3
0
IpcResource_Handle IpcResource_connect(UInt timeout)
{
    UInt16 dstProc;
    UInt16 len;
    IpcResource_Handle handle;
    IpcResource_Ack ack;
    Int status;

    handle = Memory_alloc(NULL, sizeof(*handle), 0, NULL);
    if (!handle) {
        System_printf("IpcResource_connect: No memory");
        return NULL;
    }

    handle->timeout = (!timeout) ? DEFAULT_TIMEOUT :
                      (timeout == IpcResource_FOREVER) ? MessageQCopy_FOREVER :
                      timeout;

    dstProc = MultiProc_getId("HOST");
    handle->sem = Semaphore_create(1, NULL, NULL);

    MessageQCopy_init(dstProc);
    handle->msgq= MessageQCopy_create(MessageQCopy_ASSIGN_ANY,
                                      &handle->endPoint);
    if (!handle->msgq) {
        System_printf("IpcResource_connect: MessageQCopy_create failed\n");
        goto err;
    }

    NameMap_register("rpmsg-resmgr", handle->endPoint);

    /* Wait for the connection ack from the host */
    status = MessageQCopy_recv(handle->msgq, &ack, &len, &handle->remote,
                               handle->timeout);
    if (status) {
        System_printf("IpcResource_connect: MessageQCopy_recv "
                      "failed status %d\n", status);
        goto err_disc;
    }

    if (len < sizeof(ack)) {
        System_printf("IpcResource_connect: Bad ack message len = %d\n", len);
        goto err_disc;
    }

    status = _IpcResource_translateError(ack.status);
    if (status) {
        System_printf("IpcResource_connect: A9 Resource Manager "
                      "failed status %d\n", status);
        goto err_disc;
    }

    return handle;

err_disc:
    NameMap_unregister("rpmsg-resmgr", handle->endPoint);
    MessageQCopy_delete(&handle->msgq);
err:
    Memory_free(NULL, handle, sizeof(*handle));
    return NULL;
}
Beispiel #4
0
/*
 *  ======== HdmiWa_taskFxn ========
 */
static Void HdmiWa_taskFxn(UArg arg0, UArg arg1)
{
    MessageQCopy_Handle    handle;
    UInt32                 myEndpoint = 0;
    UInt32                 remoteEndpoint;
    UInt16                 dstProc;
    UInt16                 len;
    UInt32                 temp;
    UInt32                 ctsInterval = 0;
    UInt32                 timerPeriod = 0;
    HdmiWa_PayloadData     payload;

    System_printf("HdmiWa_taskFxn Entered...:\n");
    dstProc = MultiProc_getId("HOST");

    MessageQCopy_init(dstProc);

    /* Create the messageQ for receiving (and get our endpoint for sending). */
    handle = MessageQCopy_create(70, &myEndpoint);

    NameMap_register("rpmsg-hdmiwa", 70);

    while (TRUE) {
        /* Await a character message: */
        MessageQCopy_recv(handle, (Ptr)&payload, &len, &remoteEndpoint,
                          MessageQCopy_FOREVER);

        if (!payload.trigger) {
            System_printf("HDMI payload received CTSInterval = %d, "
                          "ACRRate = %d, SysCLK = %d\n", payload.ctsInterval,
                          payload.acrRate, payload.sysClockFreq);
            if (!payload.ctsInterval || !payload.acrRate ||
                    !payload.sysClockFreq) {
                System_printf("Stop ACR WA, set auto reload timer to "
                              "default periodicity\n");
                module->waEnable = FALSE;
                timerPeriod = Clock_tickPeriod;
                goto set_timer;
            }

            /* ACR period in microseconds */
            timerPeriod = 1000000 / payload.acrRate;
            ctsInterval = TIME_IN_NS_TO_GPT_CYCLES(payload.ctsInterval,
                                                   payload.sysClockFreq);
            /* Set 1ms interval*/
            temp = ONE_MILLISECOND % payload.ctsInterval;
            if (temp < TEN_MICROSECONDS) {
                module->ctsIntervalDelta = 1;
            }
            else {
                module->ctsIntervalDelta =
                    TIME_IN_NS_TO_GPT_CYCLES(temp, payload.sysClockFreq);
            }
            /* Set ACR in SW mode */
            REG32(HDMI_ACR_CTRL) = HDMI_CTS_SEL_SW;

            REG32(HDMI_INTR2) = HDMI_CTS_CHG_INT;

            REG32(HDMI_FREQ_SVAL) = HDMI_FREQ_SVAL_MCLK_IS_1024_FS;
            while (REG32(HDMI_FREQ_SVAL) != HDMI_FREQ_SVAL_MCLK_IS_1024_FS);

            temp = module->pTmr->tcrr;
            temp += module->ctsIntervalDelta;

            while (module->pTmr->tcrr < temp);

            REG32(HDMI_FREQ_SVAL) = HDMI_FREQ_SVAL_MCLK_IS_128_FS;

            for (temp = 0; (temp < 100000) &&
                    ((REG32(HDMI_INTR2) & HDMI_CTS_CHG_INT) != HDMI_CTS_CHG_INT);
                    temp++);

            REG32(HDMI_INTR2) = HDMI_CTS_CHG_INT;

            module->gptTcrrHalfCts = ctsInterval / 2;
            module->gptTcrrFullCts = ctsInterval;

set_timer:
            System_printf("Autoreload timer to %d\n", timerPeriod);
            Timer_setPeriodMicroSecs(SysM3TickTmr, timerPeriod);
            Timer_start(SysM3TickTmr);
            MessageQCopy_send(dstProc, remoteEndpoint, myEndpoint,
                              (Ptr)&payload, len);
        }
        else {
            System_printf("Start HDMI ACRWA\n");
            module->waEnable = TRUE;
        }

    }
}