Exemple #1
0
struct srv_client*
srv_ctable_connect_direct_handler(srv_common_t *srv, srv_msg_t *m,
        seL4_CPtr liveness, int* _errno)
{
    assert(srv && srv->magic == SRV_MAGIC && m);

    /* Check that the liveness cap passed in correctly. */
    if(!srv_check_dispatch_caps(m, 0x00000000, 1)) {
        SET_ERRNO_PTR(_errno, EINVALIDPARAM);
        return NULL;
    }
    int error = ENOMEM;

    /* Copyout the liveness cap, create session cap cslot. Do not printf before the copyout. */
    seL4_CPtr livenessCP = rpc_copyout_cptr(liveness);
    if (!liveness || !livenessCP) {
        goto error0;
    }

    /* Allocate the client structure. */
    struct srv_client *c = client_alloc(&srv->clientTable, livenessCP);
    if (!c) {
        goto error1;
    }

    dprintf("Adding new %s client cID = %d. Hi! (:D)\n", srv->config.serverName, c->cID);
    assert(c->session);

    /* Authenticate the client to the process server, using its liveness cap. */
    error = proc_watch_client(c->liveness, srv->notifyClientFaultDeathAsyncEP, &c->deathID);
    if (error != ESUCCESS) {
        goto error2;
    }

    SET_ERRNO_PTR(_errno, ESUCCESS);
    return c;

    /* Exit stack. */
error2:
    client_queue_delete(&srv->clientTable, c->cID);
    client_table_postaction(&srv->clientTable);
error1:
    seL4_CNode_Delete(REFOS_CSPACE, livenessCP, REFOS_CDEPTH);
    csfree(livenessCP);
error0:
    SET_ERRNO_PTR(_errno, error);
    return NULL;

}
Exemple #2
0
refos_err_t
data_close_handler(void *rpc_userptr , seL4_CPtr rpc_dspace_fd)
{
    struct srv_client *c = (struct srv_client *) rpc_userptr;
    srv_msg_t *m = (srv_msg_t *) c->rpcClient.userptr;
    assert(c && (c->magic == TIMESERV_DISPATCH_ANON_CLIENT_MAGIC || c->magic == TIMESERV_CLIENT_MAGIC));

    if (!srv_check_dispatch_caps(m, 0x00000001, 1)) {
        return EINVALIDPARAM;
    }

    /* No need to close timer dataspaces. */
    if (rpc_dspace_fd == TIMESERV_DSPACE_BADGE_TIMER) {
        return ESUCCESS;
    }

    return EFILENOTFOUND;
}
Exemple #3
0
int
data_write_handler(void *rpc_userptr , seL4_CPtr rpc_dspace_fd , uint32_t rpc_offset ,
                   rpc_buffer_t rpc_buf , uint32_t rpc_count)
{
    struct srv_client *c = (struct srv_client *) rpc_userptr;
    srv_msg_t *m = (srv_msg_t *) c->rpcClient.userptr;
    assert(c && (c->magic == TIMESERV_DISPATCH_ANON_CLIENT_MAGIC || c->magic == TIMESERV_CLIENT_MAGIC));

    if (!srv_check_dispatch_caps(m, 0x00000001, 1)) {
        return -EINVALIDPARAM;
    }

    /* Handle write to timer dataspaces. */
    if (rpc_dspace_fd == TIMESERV_DSPACE_BADGE_TIMER) {
        return timer_write_handler(rpc_userptr, rpc_dspace_fd, rpc_offset, rpc_buf, rpc_count);
    }

    return -EFILENOTFOUND;
}
Exemple #4
0
refos_err_t
srv_ctable_set_param_buffer_handler(srv_common_t *srv, struct srv_client *c,
        srv_msg_t *m, seL4_CPtr parambufferDataspace, uint32_t parambufferSize)
{
    assert(srv && srv->magic == SRV_MAGIC);
    assert(c && m);

    /* Special case: unset the parameter buffer. */
    if (!parambufferDataspace && parambufferSize == 0) {
        seL4_CNode_Revoke(REFOS_CSPACE, c->paramBuffer, REFOS_CDEPTH);
        seL4_CNode_Delete(REFOS_CSPACE, c->paramBuffer, REFOS_CDEPTH);
        csfree(c->paramBuffer);
        c->paramBuffer = 0;
        c->paramBufferSize = 0;
        return ESUCCESS;
    }
 
    /* Sanity check parameters. */
    if (!srv_check_dispatch_caps(m, 0x00000000, 1)) {
        return EINVALIDPARAM;
    }
    if (parambufferSize == 0) {
        return EINVALIDPARAM;
    }

    /* Set the parameter buffer by copying out the given dspace cap.
       Do not printf before copyout. */
    c->paramBuffer = rpc_copyout_cptr(parambufferDataspace);
    if (!c->paramBuffer) {
        ROS_ERROR("Failed to copyout the cap.");
        return ENOMEM;
    }
    c->paramBufferSize = parambufferSize;
    dprintf("Set param buffer for client cID = %d...\n", c->cID);

    return ESUCCESS;

}