1/*
2 * Copyright (c) 2016 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, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#include <barrelfish/barrelfish.h>
11#include <devif/queue_interface.h>
12#include <devif/queue_interface_backend.h>
13
14#include "region_pool.h"
15
16 /*
17 * ===========================================================================
18 * Device queue creation and destruction (General devif initalisation)
19 * ===========================================================================
20 */
21 /**
22  * @brief creates a queue
23  *
24  * @param q             Return pointer to the devq (handle)
25  * @param exp           If we keep track of no longer owned buffers
26  *                      or buffers that we own
27  *
28  * @returns error on failure or SYS_ERR_OK on success
29  */
30
31errval_t devq_init(struct devq *q, bool exp)
32{
33
34    errval_t err;
35    q->exp = exp;
36    err = region_pool_init(&(q->pool));
37
38    return err;
39}
40
41errval_t devq_add_region(struct devq* q, struct capref cap,
42                         regionid_t rid)
43{
44    errval_t err;
45
46    err = region_pool_add_region_with_id(q->pool, cap, rid);
47    return err;
48}
49
50errval_t devq_remove_region(struct devq* q, regionid_t rid)
51{
52    errval_t err;
53    struct capref cap;
54
55    err = region_pool_remove_region(q->pool, rid, &cap);
56    return err;
57}
58