1/*
2 * Copyright (c) 2007-2011, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef HELPER_H_
11#define HELPER_H_
12
13#include <errors/errno.h>
14#include <barrelfish/barrelfish.h>
15#include <barrelfish/vregion.h>
16
17void* alloc_map_frame(vregion_flags_t attr, size_t size, struct capref *retcap);
18
19errval_t get_apicid_from_core(coreid_t cid, uint8_t *apicid);
20
21/* Simple bitmap-based allocator */
22#define BMALLOCATOR_BITS 8
23#define BMALLOCATOR_TYPE uint8_t
24struct bmallocator {
25    BMALLOCATOR_TYPE *bitmap;
26    size_t count;
27};
28
29/** Init allocator for n objects. */
30bool bmallocator_init(struct bmallocator *alloc, size_t n);
31/** Release memory associated with allocator. */
32void bmallocator_destroy(struct bmallocator *alloc);
33/** Allocate object, return index in *n if successful (return true). */
34bool bmallocator_alloc(struct bmallocator *alloc, size_t *n);
35/** Free object n, return value indicates if it was allocated before. */
36bool bmallocator_free(struct bmallocator *alloc, size_t n);
37
38#endif // ndef HELPER_H_
39