コード例 #1
0
ファイル: ping_tasks.c プロジェクト: glfernando/sysbios-rpmsg
Void copyTaskFxn(UArg arg0, UArg arg1)
{
    MessageQCopy_Handle    handle;
    Char                   buffer[128];
    UInt32                 myEndpoint = 0;
    UInt32                 remoteEndpoint;
    UInt16                 dstProc;
    UInt16                 len;
    Int                    i;

    System_printf("copyTask %d: Entered...:\n", arg0);

    dstProc = MultiProc_getId("HOST");

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

    NameMap_register("rpmsg-client-sample", arg0);

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

       buffer[len] = '\0';
       System_printf("copyTask %d: Received data: %s, len:%d\n", i + 1,
                      buffer, len);

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

    /* Teardown our side: */
    MessageQCopy_delete(&handle);
}
コード例 #2
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_disconnect(IpcResource_Handle handle)
{
    Int status;
    IpcResource_Req req;

    if (!handle) {
        System_printf("IpcResource_disconnect: handle is NULL\n");
    }

    req.resType = 0;
    req.reqType = IpcResource_REQ_TYPE_DISCONN;

    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                        handle->endPoint, &req, sizeof(req));
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_send "
                      "failed status %d\n", status);
        return status;
    }

    status = MessageQCopy_delete(&handle->msgq);
    if (status) {
        System_printf("IpcResource_disconnect: MessageQCopy_delete "
                      "failed status %d\n", status);
        return status;
    }

    Memory_free(NULL, handle, sizeof(*handle));

    return 0;
}
コード例 #3
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
Int IpcResource_release(IpcResource_Handle handle,
                        IpcResource_ResHandle resHandle)
{
    Int status;
    Char msg[sizeof(IpcResource_Req) + sizeof(IpcResource_FreeData)];
    IpcResource_Req *req = (Void *)msg;
    IpcResource_FreeData *rel = (Void *)req->data;

    if (!handle) {
        System_printf("IpcResource_release: handle is NULL\n");
        return IpcResource_E_INVALARGS;
    }

    req->reqType = IpcResource_ReqType_FREE;
    rel->resHandle = resHandle;

    status = MessageQCopy_send(MultiProc_getId("HOST"), handle->remote,
                      handle->endPoint, req, sizeof(msg));
    if (status) {
        System_printf("IpcResource_release: MessageQCopy_send "
                      "failed status %d\n", status);
    }

    return status;
}
コード例 #4
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_setConstraints(IpcResource_Handle handle,
                               IpcResource_ResHandle resHandle,
                               UInt32 action,
                               Void *constraints)
{
    Char msg[MAXMSGSIZE];
    IpcResource_Ack *ack = (Void *)msg;
    IpcResource_Req *req = (Void *)msg;
    UInt16 rlen = sizeof(IpcResource_ConstraintData);
    UInt16 alen = sizeof(*ack);
    UInt16 len;
    UInt32 remote;
    Int status;

    if (!handle) {
        System_printf("IpcResource_setConstraints: Invalid paramaters\n");
        return IpcResource_E_INVALARGS;
    }

    if (rlen && !constraints) {
        System_printf("IpcResource_setConstraints: needs parameters\n");
        return IpcResource_E_INVALARGS;
    }

    req->resType = 0;
    req->reqType = action;
    req->resHandle = resHandle;

    memcpy(req->resParams, constraints, rlen);
    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                        handle->endPoint, req, sizeof(*req) + rlen);
    if (status) {
        System_printf("IpcResource_setConstraints: MessageQCopy_send "
                      "failed status %d\n", status);
        status = IpcResource_E_FAIL;
        goto end;
    }

    if (action == IpcResource_REQ_TYPE_REL_CONSTRAINTS)
        goto end;

    status = MessageQCopy_recv(handle->msgq, ack, &len, &remote,
                               handle->timeout);
    if (status) {
        System_printf("IpcResource_setConstraints: MessageQCopy_recv "
                      "failed status %d\n", status);
        status = (status == MessageQCopy_E_TIMEOUT) ? IpcResource_E_TIMEOUT :
                 IpcResource_E_FAIL;
        goto end;
    }

    Assert_isTrue(len == (rlen + alen), NULL);

    status = _IpcResource_translateError(ack->status);

end:
    return status;
}
コード例 #5
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
IpcResource_Handle IpcResource_connect(UInt timeout)
{
    UInt16 dstProc;
    UInt16 len;
    UInt32 remote;
    IpcResource_Handle handle;
    IpcResource_Req req;
    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->msgq= MessageQCopy_create(MessageQCopy_ASSIGN_ANY,
                                      &handle->endPoint);
    req.resType = 0;
    req.reqType = IpcResource_REQ_TYPE_CONN;
    req.resHandle = 0;
    status = MessageQCopy_send(dstProc, IpcResource_server,
                      handle->endPoint, &req, sizeof(req));
    if (status) {
        System_printf("IpcResource_connect: MessageQCopy_send "
                      " failed status %d\n", status);
        goto err;
    }

    status = MessageQCopy_recv(handle->msgq, &ack, &len, &remote,
                               handle->timeout);
    if (status) {
        System_printf("IpcResource_connect: MessageQCopy_recv "
                      "failed status %d\n", status);
        goto err;
    }
    status = _IpcResource_translateError(ack.status);
    if (status) {
        System_printf("IpcResource_connect: A9 Resource Manager "
                      "failed status %d\n", status);
        goto err;
    }

    return handle;
err:
    Memory_free(NULL, handle, sizeof(*handle));
    return NULL;
}
コード例 #6
0
ファイル: ServiceMgr.c プロジェクト: robclark/sysbios-rpmsg
Void ServiceMgr_send(Service_Handle srvc, Ptr data, UInt16 len)
{
    UInt32 local;
    UInt32 remote;
    struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)data;
    UInt16 dstProc;

    /* Get reply endpoint and local address for sending: */
    remote  = RcmServer_getRemoteAddress(srvc);
    dstProc = RcmServer_getRemoteProc(srvc);
    local   = RcmServer_getLocalAddress(srvc);

    /* Set special rpmsg_omx header so Linux side can strip it off: */
    hdr->type    = OMX_RAW_MSG;
    hdr->len     = len;
    hdr->flags   = 0;

    /* Send it off (and no response expected): */
    MessageQCopy_send(dstProc, remote, local, data, HDRSIZE+len);
}
コード例 #7
0
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();
}
コード例 #8
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_release(IpcResource_Handle handle,
                        IpcResource_ResHandle resHandle)
{
    Int status;
    IpcResource_Req req;

    if (!handle) {
        System_printf("IpcResource_release: handle is NULL\n");
        return IpcResource_E_INVALARGS;
    }

    req.resType = 0;
    req.reqType = IpcResource_REQ_TYPE_FREE;
    req.resHandle = resHandle;

    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                      handle->endPoint, &req, sizeof(req));
    if (status) {
        System_printf("IpcResource_release: MessageQCopy_send "
                      "failed status %d\n", status);
    }

    return status;
}
コード例 #9
0
ファイル: OmxSrvMgr.c プロジェクト: Hashcode/sysbios-rpmsg
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);
    }
}
コード例 #10
0
ファイル: IpcResource.c プロジェクト: GAnthony/sysbios-rpmsg
Int IpcResource_request(IpcResource_Handle handle,
                        IpcResource_ResHandle *resHandle,
                        IpcResource_Type type, Void *resParams)
{
    Char msg[MAXMSGSIZE];
    IpcResource_Req *req = (Void *)msg;
    IpcResource_Ack *ack = (Void *)msg;
    UInt16 hlen = sizeof(*req);
    UInt16 alen = sizeof(*ack);
    UInt16 rlen = IpcResource_resLen(type);
    UInt16 len;
    UInt32 remote;
    Int status;

    if (!handle || !resHandle) {
        System_printf("IpcResource_request: Invalid paramaters\n");
        return IpcResource_E_INVALARGS;
    }

    if (rlen && !resParams) {
        System_printf("IpcResource_request: resource type %d "
                      "needs parameters\n", type);
        return IpcResource_E_INVALARGS;
    }

    req->resType = type;
    req->reqType = IpcResource_REQ_TYPE_ALLOC;

    memcpy(req->resParams, resParams, rlen);
    status = MessageQCopy_send(MultiProc_getId("HOST"), IpcResource_server,
                        handle->endPoint, req, hlen + rlen);
    if (status) {
        System_printf("IpcResource_request: MessageQCopy_send "
                      "failed status %d\n", status);
        status = IpcResource_E_FAIL;
        goto end;
    }

    status = MessageQCopy_recv(handle->msgq, ack, &len, &remote,
                               handle->timeout);
    if (status) {
        System_printf("IpcResource_request: MessageQCopy_recv "
                      "failed status %d\n", status);
        status = (status == MessageQCopy_E_TIMEOUT) ? IpcResource_E_TIMEOUT :
                 IpcResource_E_FAIL;
        goto end;
    }
    status = _IpcResource_translateError(ack->status);
    if (status) {
        System_printf("IpcResource_request: error from Host "
                      "failed status %d\n", status);
        goto end;
    }

    Assert_isTrue(len == (rlen + alen), NULL);

    *resHandle = ack->resHandle;
    memcpy(resParams, ack->resParams, rlen);
end:
    return status;
}
コード例 #11
0
ファイル: ServiceMgr.c プロジェクト: robclark/sysbios-rpmsg
void serviceMgrTaskFxn(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

    msgq = MessageQCopy_create(SERVICE_MGR_PORT, &local);

    System_printf("serviceMgr: started on port: %d\n", SERVICE_MGR_PORT);

    /*
     * Yeah, this is horrible.
     *
     * Without it, we might try to send a message before buffers are
     * available in the ring, and then the code just bluntly fails.
     *
     * The real fix is to pause initialization until buffers are available,
     * or allow users to get notified when a buffer is available after
     * they failed getting one.
     */
    Task_sleep(500);

    NameMap_register("rpmsg-omx", SERVICE_MGR_PORT);

    while (1) {
       MessageQCopy_recv(msgq, (Ptr)msg, &len, &remote, MessageQCopy_FOREVER);
       System_printf("serviceMgr: 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("serviceMgr: CONN_REQ: len: %d, name: %s\n",
                 hdr->len, req->name);

            rsp->status = 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("serviceMgr: OMX_DISCONNECT: len %d, addr: %d\n",
                 hdr->len, disc_req->addr);

            disc_rsp->status = 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("serviceMgr: Replying with msg type: %d to addr: %d "
                      " from: %d\n",
                      hdr->type, remote, local);
       MessageQCopy_send(dstProc, remote, local, msg, len);
    }
}
コード例 #12
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
Int IpcResource_setConstraints(IpcResource_Handle handle,
                               IpcResource_ResHandle resHandle,
                               UInt32 reqType,
                               IpcResource_ConstraintData *constraints)
{
    Char msg[MAXMSGSIZE];
    IpcResource_Ack *ack = (Void *)msg;
    IpcResource_Req *req = (Void *)msg;
    IpcResource_Constraint *c = (Void *)req->data;
    UInt16 rlen = sizeof(*c);
    UInt16 alen = sizeof(*ack);
    UInt16 len;
    UInt32 remote;
    Int status;

    if (!handle) {
        System_printf("IpcResource_setConstraints: Invalid paramaters\n");
        return IpcResource_E_INVALARGS;
    }

    if (!constraints) {
        System_printf("IpcResource_setConstraints: needs parameters\n");
        return IpcResource_E_INVALARGS;
    }

    req->reqType = reqType;
    c->resHandle = resHandle;
    c->cdata = *constraints;

    Semaphore_pend(handle->sem, BIOS_WAIT_FOREVER);
    status = MessageQCopy_send(MultiProc_getId("HOST"), handle->remote,
                        handle->endPoint, req, sizeof(*req) + rlen);
    if (status) {
        Semaphore_post(handle->sem);
        System_printf("IpcResource_setConstraints: MessageQCopy_send "
                      "failed status %d\n", status);
        status = IpcResource_E_FAIL;
        goto end;
    }

    if (reqType == IpcResource_ReqType_REL_CONSTRAINTS) {
        Semaphore_post(handle->sem);
        goto end;
    }

    status = MessageQCopy_recv(handle->msgq, ack, &len, &remote,
                               handle->timeout);
    Semaphore_post(handle->sem);
    if (status) {
        System_printf("IpcResource_setConstraints: MessageQCopy_recv "
                      "failed status %d\n", status);
        status = (status == MessageQCopy_E_TIMEOUT) ? IpcResource_E_TIMEOUT :
                 IpcResource_E_FAIL;
        goto end;
    }
    if (remote != handle->remote) {
        System_printf("IpcResource_setConstraints: MessageQCopy_recv "
                      "invalid message source %d, channel source %d\n",
                      remote, handle->remote);
        status = IpcResource_E_FAIL;
        goto end;
    }

    status = _IpcResource_translateError(ack->status);
    if (status) {
        System_printf("IpcResource_setConstraints: error from Host "
                      "failed status %d\n", status);
        goto end;
    }

    Assert_isTrue(len == (rlen + alen), NULL);

end:
    return status;
}
コード例 #13
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
Int IpcResource_requestData(IpcResource_Handle handle,
                            IpcResource_ResHandle resHandle,
                            IpcResource_ReqDataType dataType,
                            Void *data)
{
    Char msg[MAXMSGSIZE];
    IpcResource_Ack *ack = (Void *)msg;
    IpcResource_Req *req = (Void *)msg;
    IpcResource_ReqData *reqData = (Void *)req->data;
    UInt16 hlen = sizeof(*reqData);
    UInt16 alen = sizeof(*ack);
    UInt16 rlen = IpcResource_reqDataLen(dataType);
    UInt16 len;
    UInt32 remote;
    Int status;

    if (!handle) {
        System_printf("IpcResource_requestData: Invalid handle\n");
        return IpcResource_E_INVALARGS;
    }

    if (rlen && !data) {
        System_printf("IpcResource_requestData: needs data struct\n");
        return IpcResource_E_INVALARGS;
    }

    req->reqType = IpcResource_ReqType_REQ_DATA;
    reqData->resHandle = resHandle;
    reqData->type = dataType;

    Semaphore_pend(handle->sem, BIOS_WAIT_FOREVER);
    status = MessageQCopy_send(MultiProc_getId("HOST"), handle->remote,
                        handle->endPoint, req, sizeof(*req) + hlen + rlen);
    if (status) {
        Semaphore_post(handle->sem);
        System_printf("IpcResource_requestData: MessageQCopy_send "
                      "failed status %d\n", status);
        status = IpcResource_E_FAIL;
        goto end;
    }

    status = MessageQCopy_recv(handle->msgq, ack, &len, &remote,
                               handle->timeout);
    Semaphore_post(handle->sem);
    if (status) {
        System_printf("IpcResource_requestData: MessageQCopy_recv "
                      "failed status %d\n", status);
        status = (status == MessageQCopy_E_TIMEOUT) ? IpcResource_E_TIMEOUT :
                 IpcResource_E_FAIL;
        goto end;
    }

    status = _IpcResource_translateError(ack->status);
    if (status) {
        System_printf("IpcResource_requestData: error from Host "
                      "failed status %d\n", status);
        goto end;
    }

    Assert_isTrue(len == (rlen + alen), NULL);

    memcpy(data, ack->data, rlen);

end:
    return status;
}
コード例 #14
0
ファイル: IpcResource.c プロジェクト: mobiaqua/ti-rpmsg
Int IpcResource_request(IpcResource_Handle handle,
                        IpcResource_ResHandle *resHandle,
                        IpcResource_Type type, Void *resParams)
{
    Char msg[MAXMSGSIZE];
    IpcResource_Req *req = (Void *)msg;
    IpcResource_AllocData *rdata = (Void *)req->data;
    IpcResource_Ack *ack = (Void *)msg;
    IpcResource_AckData *adata = (Void *)ack->data;
    UInt16 hlen = sizeof(*rdata) + sizeof(*req);
    UInt16 alen = sizeof(*ack);
    UInt16 rlen = IpcResource_resLen(type);
    UInt16 len;
    UInt32 remote;
    Int status;
    Char *name;
    IpcResource_Processor rproc;

    if (!handle || !resHandle) {
        System_printf("IpcResource_request: Invalid paramaters\n");
        return IpcResource_E_INVALARGS;
    }

    name = IpcResource_toName(type);
    if (!name) {
        System_printf("IpcResource_request: resource type %d "
                      "is invalid\n", type);
        return IpcResource_E_INVALARGS;
    }

    if (rlen && !resParams) {
        System_printf("IpcResource_request: resource type %d "
                      "needs parameters\n", type);
        return IpcResource_E_INVALARGS;
    }

    strncpy(rdata->resName, name, 16);
    req->reqType = IpcResource_ReqType_ALLOC;

    switch(type) {
    case IpcResource_TYPE_IPU:
    case IpcResource_TYPE_DSP:
        strcpy(rproc.name, rdata->resName);
        strncpy(rdata->resName, "rproc", 16);
        resParams = &rproc;
        rlen = sizeof(rproc);
        break;

    default:
        break;
    }

    memcpy(rdata->resParams, resParams, rlen);
    Semaphore_pend(handle->sem, BIOS_WAIT_FOREVER);
    status = MessageQCopy_send(MultiProc_getId("HOST"), handle->remote,
                        handle->endPoint, req, hlen + rlen);
    if (status) {
        Semaphore_post(handle->sem);
        System_printf("IpcResource_request: MessageQCopy_send "
                      "failed status %d\n", status);
        status = IpcResource_E_FAIL;
        goto end;
    }

    status = MessageQCopy_recv(handle->msgq, ack, &len, &remote,
                               handle->timeout);
    Semaphore_post(handle->sem);
    if (status) {
        System_printf("IpcResource_request: MessageQCopy_recv "
                      "failed status %d\n", status);
        status = (status == MessageQCopy_E_TIMEOUT) ? IpcResource_E_TIMEOUT :
                 IpcResource_E_FAIL;
        goto end;
    }
    if (remote != handle->remote) {
        System_printf("IpcResource_request: MessageQCopy_recv "
                      "invalid message source %d, channel source %d\n",
                      remote, handle->remote);
        status = IpcResource_E_FAIL;
        goto end;
    }

    status = _IpcResource_translateError(ack->status);
    if (status) {
        System_printf("IpcResource_request: error from Host "
                      "failed status %d\n", status);
        goto end;
    }

    Assert_isTrue(len == rlen + alen + sizeof(*adata), NULL);

    *resHandle = adata->resHandle;
    memcpy(resParams, adata->resParams, rlen);

end:
    return status;
}
コード例 #15
0
ファイル: HdmiWa.c プロジェクト: mobiaqua/ti-rpmsg
/*
 *  ======== 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;
        }

    }
}