コード例 #1
0
ファイル: main.c プロジェクト: BwRy/sel4test
static void
init_allocator(env_t env, test_init_data_t *init_data)
{
    UNUSED int error;
    UNUSED reservation_t virtual_reservation;

    /* initialise allocator */
    allocman_t *allocator = bootstrap_use_current_1level(init_data->root_cnode,
                                                         init_data->cspace_size_bits, init_data->free_slots.start,
                                                         init_data->free_slots.end, ALLOCATOR_STATIC_POOL_SIZE,
                                                         allocator_mem_pool);
    if (allocator == NULL) {
        ZF_LOGF("Failed to bootstrap allocator");
    }
    allocman_make_vka(&env->vka, allocator);

    /* fill the allocator with untypeds */
    seL4_CPtr slot;
    unsigned int size_bits_index;
    for (slot = init_data->untypeds.start, size_bits_index = 0;
            slot <= init_data->untypeds.end;
            slot++, size_bits_index++) {

        cspacepath_t path;
        vka_cspace_make_path(&env->vka, slot, &path);
        /* allocman doesn't require the paddr unless we need to ask for phys addresses,
         * which we don't. */
        uintptr_t fake_paddr = 0;
        size_t size_bits = init_data->untyped_size_bits_list[size_bits_index];
        error = allocman_utspace_add_uts(allocator, 1, &path, &size_bits, &fake_paddr);
        if (error) {
            ZF_LOGF("Failed to add untyped objects to allocator");
        }
    }

    /* create a vspace */
    void *existing_frames[init_data->stack_pages + 2];
    existing_frames[0] = (void *) init_data;
    existing_frames[1] = seL4_GetIPCBuffer();
    assert(init_data->stack_pages > 0);
    for (int i = 0; i < init_data->stack_pages; i++) {
        existing_frames[i + 2] = init_data->stack + (i * PAGE_SIZE_4K);
    }

    error = sel4utils_bootstrap_vspace(&env->vspace, &alloc_data, init_data->page_directory, &env->vka,                 NULL, NULL, existing_frames);

    /* switch the allocator to a virtual memory pool */
    void *vaddr;
    virtual_reservation = vspace_reserve_range(&env->vspace, ALLOCATOR_VIRTUAL_POOL_SIZE,
                                               seL4_AllRights, 1, &vaddr);
    if (virtual_reservation.res == 0) {
        ZF_LOGF("Failed to switch allocator to virtual memory pool");
    }

    bootstrap_configure_virtual_pool(allocator, vaddr, ALLOCATOR_VIRTUAL_POOL_SIZE,
                                     env->page_directory);

}
コード例 #2
0
ファイル: ipc.c プロジェクト: seL4/camkes-tool
void ffiseL4_Send(unsigned char *c, long clen, unsigned char *a, long alen) {
    seL4_CPtr ep;
    int offset = 1;
    memcpy(&ep, a + offset, sizeof(ep));
    offset += sizeof(ep);
    seL4_Word len;
    memcpy(&len, a + offset, sizeof(len));
    offset += sizeof(len);
    memcpy(&seL4_GetIPCBuffer()->msg[0], a + offset, len);
    seL4_Send(
        ep,
        seL4_MessageInfo_new(0, 0, 0, ROUND_UP_UNSAFE(len, sizeof(seL4_Word)) / sizeof(seL4_Word)));
    a[0] = FFI_SUCCESS;
}
コード例 #3
0
ファイル: ipc.c プロジェクト: seL4/camkes-tool
void ffiseL4_Recv(unsigned char *c, long clen, unsigned char *a, long alen) {
    seL4_CPtr ep;
    memcpy(&ep, a + 1, sizeof(ep));
    seL4_Word badge;
    seL4_MessageInfo_t info = seL4_Recv(ep, &badge);
    seL4_Word len = seL4_MessageInfo_get_length(info) * sizeof(seL4_Word);
    int offset = 1;
	memcpy(a + offset, &len, sizeof(len));
	offset += sizeof(len);
    memcpy(a + offset, &badge, sizeof(badge));
	offset += sizeof(badge);
    memcpy(a + offset, &seL4_GetIPCBuffer()->msg[0], len);
	a[0] = FFI_SUCCESS;
}
コード例 #4
0
ファイル: ipc.c プロジェクト: seL4/camkes-tool
void ffiseL4_ReplyRecv(unsigned char *c, long clen, unsigned char *a, long alen) {
    seL4_CPtr ep;
    int offset = 1;
    memcpy(&ep, a + offset, sizeof(ep));
    offset += sizeof(ep);
    seL4_Word len;
    memcpy(&len, a + offset, sizeof(len));
    offset += sizeof(len);
    seL4_Word badge;
    memcpy(&seL4_GetIPCBuffer()->msg[0], a + offset, len);
    seL4_MessageInfo_t info = seL4_ReplyRecv(
        ep,
        seL4_MessageInfo_new(0, 0, 0, ROUND_UP_UNSAFE(len, sizeof(seL4_Word)) / sizeof(seL4_Word)),
        &badge);
    len = seL4_MessageInfo_get_length(info) * sizeof(seL4_Word);
    offset = 1;
    memcpy(a + offset, &len, sizeof(len));
    offset += sizeof(len);
    memcpy(a + offset, &badge, sizeof(badge));
    offset += sizeof(badge);
    memcpy(a + offset, &seL4_GetIPCBuffer()->msg[0], len);
    a[0] = FFI_SUCCESS;
}
コード例 #5
0
ファイル: ttyout.c プロジェクト: thumphries/aos
/* Attempt single write, without retrying */
size_t _sos_write(void *vData, size_t count) {
    seL4_Word *realdata = (seL4_Word*) vData;
    seL4_IPCBuffer *buf = seL4_GetIPCBuffer();
    seL4_Word len = 2 + DIVROUND(count, 4);
    seL4_Word real_len = MIN(seL4_MsgMaxLength, len);
    size_t real_count  = MIN(count, (seL4_MsgMaxLength - 2) * 4);

    /* Set up syscall parameters */
    buf->msg[0] = SOS_SYSCALL_WRITE_CONSOLE;
    buf->msg[1] = real_count;

    int i;
    for (i = 2; i < len; i++) {
      buf->msg[i] = realdata[i - 2];
    }

    /* Fire off syscall and wait for reply */
    seL4_MessageInfo_t tag = seL4_MessageInfo_new(0, 0, 0, real_len);
    seL4_Call(SYSCALL_ENDPOINT_SLOT, tag);

    return seL4_GetMR(0);
}