/*
* Copyright (c) 2010, 2011, ETH Zurich.
+ * Copyright (c) 2014, HP Labs.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
*/
#ifndef LIBBARRELFISH_VSPACE_MMU_AWARE_H
/// Struct to support mmu_aware memory management
struct vspace_mmu_aware {
size_t size;
+ size_t alignment;
size_t consumed;
struct vregion vregion; ///< Needs just one vregion
struct memobj_anon memobj; ///< Needs just one memobj
};
errval_t vspace_mmu_aware_init(struct vspace_mmu_aware *state, size_t size);
+errval_t vspace_mmu_aware_init_aligned(struct vspace_mmu_aware *state,
+ size_t size, size_t alignment,
+ vregion_flags_t flags);
errval_t vspace_mmu_aware_map(struct vspace_mmu_aware *state,
struct capref frame, size_t req_size,
void **retbuf, size_t *retsize);
/*
* Copyright (c) 2007, 2008, 2009, 2010, 2011, ETH Zurich.
+ * Copyright (c) 2014, HP Labs.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
*/
#include <barrelfish/barrelfish.h>
thread_mutex_init(&state->mutex);
- err = vspace_mmu_aware_init(&state->mmu_state, HEAP_REGION);
+ err = vspace_mmu_aware_init_aligned(&state->mmu_state, HEAP_REGION,
+ BASE_PAGE_SIZE, VREGION_FLAGS_READ_WRITE);
if (err_is_fail(err)) {
return err_push(err, LIB_ERR_VSPACE_MMU_AWARE_INIT);
}
/*
* Copyright (c) 2010, ETH Zurich.
+ * Copyright (c) 2014, HP Labs.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
*/
#include <barrelfish/barrelfish.h>
err = mca->top->alloc(mca->top, &cap);
if (err_is_fail(err)) {
thread_mutex_unlock(&ca->mutex);
+ debug_printf("top allocator out of slots; can't refill\n");
return err_push(err, LIB_ERR_SLOT_ALLOC);
}
thread_mutex_unlock(&ca->mutex); // cnode_create_raw uses ram_alloc
/*
* Copyright (c) 2010, 2011, ETH Zurich.
+ * Copyright (c) 2014, HP Labs.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
- * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
+ * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
*/
#include <barrelfish/barrelfish.h>
*/
errval_t vspace_mmu_aware_init(struct vspace_mmu_aware *state, size_t size)
{
+ return vspace_mmu_aware_init_aligned(state, size, 0,
+ VREGION_FLAGS_READ_WRITE);
+}
+
+errval_t vspace_mmu_aware_init_aligned(struct vspace_mmu_aware *state,
+ size_t size, size_t alignment, vregion_flags_t flags)
+{
state->size = size;
state->consumed = 0;
+ state->alignment = alignment;
errval_t err;
return err_push(err, LIB_ERR_MEMOBJ_CREATE_ANON);
}
- err = vregion_map(&state->vregion, get_current_vspace(),
- &state->memobj.m, 0, size,
- VREGION_FLAGS_READ_WRITE);
+ err = vregion_map_aligned(&state->vregion, get_current_vspace(),
+ &state->memobj.m, 0, size,
+ flags, alignment);
if (err_is_fail(err)) {
return err_push(err, LIB_ERR_VREGION_MAP);
}