Ejemplo n.º 1
0
seL4_CPtr
proc_get_mem_window_dspace_handler(void *rpc_userptr , seL4_CPtr rpc_window ,
                                   refos_err_t* rpc_errno)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    struct procserv_msg *m = (struct procserv_msg*) pcb->rpcClient.userptr;
    assert(pcb && pcb->magic == REFOS_PCB_MAGIC);

    if (!check_dispatch_caps(m, 0x00000001, 1)) {
        SET_ERRNO_PTR(rpc_errno, EINVALIDWINDOW);
        return 0;
    }

    if (!dispatcher_badge_window(rpc_window)) {
        SET_ERRNO_PTR(rpc_errno, EINVALIDWINDOW);
        return 0;
    }
    
    /* Retrieve the window from global window list. */
    struct w_window *window = w_get_window(&procServ.windowList, rpc_window - W_BADGE_BASE);
    if (!window) {
        ROS_ERROR("Failed to find associated window in global list. Procserv book-keeping bug.");
        SET_ERRNO_PTR(rpc_errno, EINVALIDWINDOW);
        return 0;
    }

    if (window->mode != W_MODE_ANONYMOUS) {
        SET_ERRNO_PTR(rpc_errno, ESUCCESS);
        return 0;
    }
    assert(window->ramDataspace && window->ramDataspace->magic == RAM_DATASPACE_MAGIC);

    SET_ERRNO_PTR(rpc_errno, ESUCCESS);
    return window->ramDataspace->capability.capPtr;
}
Ejemplo n.º 2
0
/*! @brief Handles sync endpoint creation syscalls. */
seL4_CPtr
proc_new_endpoint_internal_handler(void *rpc_userptr , refos_err_t* rpc_errno)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    assert(pcb->magic == REFOS_PCB_MAGIC);
    dprintf("Process server creating endpoint!\n");
    seL4_CPtr ep = proc_syscall_allocate_endpoint(pcb, KOBJECT_ENDPOINT_SYNC);
    if (!ep) {
        SET_ERRNO_PTR(rpc_errno, ENOMEM);
        return 0;
    }
    SET_ERRNO_PTR(rpc_errno, ESUCCESS);
    return ep;
}
Ejemplo n.º 3
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;

}
Ejemplo n.º 4
0
seL4_CPtr
data_open_handler(void *rpc_userptr , char* rpc_name , int rpc_flags , int rpc_mode , int rpc_size ,
                  int* rpc_errno)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    assert(pcb && pcb->magic == REFOS_PCB_MAGIC);

    (void) pcb;
    (void) rpc_mode;

    if (rpc_size <= 0) {
        SET_ERRNO_PTR(rpc_errno, EINVALIDPARAM);
        return 0;
    }

    /* Name must either be NULL, empty string or anon. */
    if (rpc_name != NULL) {
        if (strlen(rpc_name) > 0 && strcmp(rpc_name, "anon") != 0) {
            SET_ERRNO_PTR(rpc_errno, EFILENOTFOUND);
            return 0;
        }
    }

    /* Create a ram dataspace of the given size. */
    struct ram_dspace *newDataspace = ram_dspace_create(&procServ.dspaceList, rpc_size);
    if (!newDataspace) {
        ROS_ERROR("Failed to create new_dataspace.\n");
        SET_ERRNO_PTR(rpc_errno, ENOMEM);
        return 0;
    }

    /* Set physical address mode, if required. */
    if ((rpc_flags & PROCSERV_DSPACE_FLAG_DEVICE_PADDR) != 0) {
        int error = EACCESSDENIED;
        if (pcb->systemCapabilitiesMask & PROCESS_PERMISSION_DEVICE_MAP) {
            error = ram_dspace_set_to_paddr(newDataspace, (uint32_t) rpc_mode);
        }
        if (error) {
            ram_dspace_unref(&procServ.dspaceList, newDataspace->ID);
            SET_ERRNO_PTR(rpc_errno, error);
            return 0;
        }
    }

    SET_ERRNO_PTR(rpc_errno, ESUCCESS);
    assert(newDataspace->magic == RAM_DATASPACE_MAGIC);
    return newDataspace->capability.capPtr;
}
Ejemplo n.º 5
0
Archivo: dspace.c Proyecto: Zolok/refos
seL4_CPtr
data_open_handler(void *rpc_userptr , char* rpc_name , int rpc_flags , int rpc_mode , int rpc_size ,
                  int* rpc_errno)
{
    if (!rpc_name) {
        SET_ERRNO_PTR(rpc_errno, EFILENOTFOUND);
        return 0;
    }

    /* Handle timer dataspace open requests. */
    if (strcmp(rpc_name, "timer") == 0 || strcmp(rpc_name, "time") == 0) {
        return timer_open_handler(rpc_userptr, rpc_name, rpc_flags, rpc_mode, rpc_size, rpc_errno);
    }

    SET_ERRNO_PTR(rpc_errno, EFILENOTFOUND);
    return 0;
}
Ejemplo n.º 6
0
seL4_CPtr
timer_open_handler(void *rpc_userptr , char* rpc_name , int rpc_flags , int rpc_mode ,
                              int rpc_size , int* rpc_errno)
{
    /* Return the timer dataspace badged EP. */
    assert(timeServ.timerBadgeEP);
    SET_ERRNO_PTR(rpc_errno, ESUCCESS);
    return timeServ.timerBadgeEP;
}
Ejemplo n.º 7
0
/*! @brief Handles memory window creation syscalls.

    The window must not be overlapping with an existing window in the client's VSpace, or
    EINVALIDPARAM will be the returned.
    
    When mapping a dataspace to a non-page aligned window, the dataspace will actually be mapped to
    the page-aligned address of the window base due to technical restrictions. Thus, the first B -
    PAGE_ALIGN(B) bytes of the mapped dataspace is unaccessible. This can have unintended effects
    when two processes map the same dataspace for sharing purposes. In other words, when sharing
    dataspaces, it's easiest for the window bases for BOTH processes to be page-aligned.
 */
seL4_CPtr
proc_create_mem_window_internal_handler(void *rpc_userptr , uint32_t rpc_vaddr , uint32_t rpc_size ,
                                        uint32_t rpc_permissions, uint32_t flags,
                                        refos_err_t* rpc_errno)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    assert(pcb && pcb->magic == REFOS_PCB_MAGIC);

    /* Check that this window does not override protected kernel memory. */
    if (rpc_vaddr >= PROCESS_KERNEL_RESERVED || PROCESS_KERNEL_RESERVED < (rpc_size + rpc_vaddr)) {
        dvprintf("memory window out of bounds, overlaps kernel reserved.\n");
        SET_ERRNO_PTR(rpc_errno, EINVALIDPARAM);
        return 0;
    }

    /* Create the window. */
    int windowID = W_INVALID_WINID;
    bool cached = (flags & W_FLAGS_UNCACHED) ? false : true;
    int error = vs_create_window(&pcb->vspace, rpc_vaddr, rpc_size, rpc_permissions, cached,
            &windowID);
    if (error != ESUCCESS || windowID == W_INVALID_WINID) {
        dvprintf("Could not create window.\n");
        SET_ERRNO_PTR(rpc_errno, error);
        return 0;
    }

    /* Find the window and return the window capability. */
    struct w_window* window = w_get_window(&procServ.windowList, windowID);
    if (!window) {
        assert(!"Successfully allocated window failed to be found. Process server bug.");
        /* Cannot recover from this situation cleanly. Shouldn't ever happen. */
        SET_ERRNO_PTR(rpc_errno, EINVALID);
        return 0;
    }

    assert(window->magic == W_MAGIC);
    assert(window->capability.capPtr);
    SET_ERRNO_PTR(rpc_errno, ESUCCESS);
    return window->capability.capPtr;
}
Ejemplo n.º 8
0
int
proc_clone2_internal_handler(void *rpc_userptr , seL4_Word rpc_entryPoint , seL4_Word rpc_childStack, int rpc_flags , seL4_Word rpc_arg , refos_err_t* rpc_errno)
{
    struct proc_pcb *pcb = (struct proc_pcb*) rpc_userptr;
    assert(pcb->magic == REFOS_PCB_MAGIC);

    int threadID = -1;
    printf("before call proc_clone function!\n");
    int error = proc_clone2(pcb, &threadID, (vaddr_t) rpc_childStack, (vaddr_t) rpc_entryPoint, (void *)rpc_arg);
    SET_ERRNO_PTR(rpc_errno, error);
    printf("after call proc_clone function!\n");
    return threadID;
}