Esempio n. 1
0
/*
 * Allocate a single object of the given type.
 */
seL4_CPtr
allocator_alloc_kobject(struct allocator *allocator,
                        seL4_Word item_type, seL4_Word item_size)
{
    unsigned long size_bits;
    seL4_CPtr untyped_memory;
    struct cap_range cap_range;
    int result;
    UNUSED_NDEBUG(result);
    /* Allocate an untyped memory item of the right size. */
    size_bits = vka_get_object_size(item_type, item_size);
    untyped_memory = allocator_alloc_untyped( allocator, size_bits);
    if (!untyped_memory) {
        return 0;
    }

    /* Allocate an object. */
    result = allocator_retype_untyped_memory(allocator, untyped_memory,
                                             item_type, item_size, 1, &cap_range);

    /* We should have gotten either zero items (if we ran out of caps), or one
     * item (if everything went well). If we get more than one, we
     * miscalculated our sizes. */
    assert((result == 0) || (result == 1));

    /* Return the first item (or zero if none were allocated. */
    return cap_range.first;
}
static void callback_destroy_surface(KHRN_POINTER_MAP_T *map, uint32_t key, void *value, void *data)
{
   EGL_SURFACE_T *surface = (EGL_SURFACE_T *)value;

   UNUSED(map);
   UNUSED(data);
   UNUSED_NDEBUG(key);

   vcos_assert( surface != NULL );
   vcos_assert((uintptr_t)key == (uintptr_t)surface->name);

   surface->is_destroyed = true;
   egl_surface_maybe_free(surface);
}
static void callback_destroy_context(KHRN_POINTER_MAP_T *map, uint32_t key, void *value, void *data)
{
   EGL_CONTEXT_T *context = (EGL_CONTEXT_T *)value;

   UNUSED(map);
   UNUSED(data);
   UNUSED_NDEBUG(key);

   vcos_assert( context != NULL );
   vcos_assert((uintptr_t)key == (uintptr_t)context->name);

   vcos_assert(!context->is_destroyed);

   context->is_destroyed = true;
   egl_context_maybe_free(context);
}