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#ifndef DESCQ_H_
10#define DESCQ_H_ 1
11
12
13#include <barrelfish/barrelfish.h>
14
15#define DESCQ_DEFAULT_SIZE 2048
16#define DESCQ_ALIGNMENT 64
17
18struct descq;
19
20typedef errval_t (*descq_create_t) (struct descq *q, bool notifications, uint8_t role, uint64_t *queue_id);
21typedef errval_t (*descq_destroy_t) (struct descq *q);
22typedef errval_t (*descq_notify_t) (struct descq *q);
23typedef errval_t (*descq_register_t)(struct descq *q, struct capref cap,
24                                    regionid_t region_id);
25typedef errval_t (*descq_deregister_t)(struct descq *q, regionid_t region_id);
26typedef errval_t (*descq_control_t)(struct descq *q,
27                                   uint64_t request,
28                                   uint64_t value,
29                                   uint64_t *result);
30typedef errval_t (*descq_enqueued_t)(struct descq* q);
31
32struct descq_func_pointer {
33    descq_create_t create;
34    descq_destroy_t destroy;
35    descq_notify_t notify;
36    descq_register_t reg;
37    descq_deregister_t dereg;
38    descq_control_t control;
39};
40
41
42/**
43 * @brief initialized a descriptor queue
44 *
45 * @param q                     Return pointer to the descriptor queue
46 * @param slots                 Number of slots in the queue
47 * @param name                  Name of the exported/connected to channel
48 * @param exp                   Export desq_ctrl/descq_data flounder interface
49 *                              (At least one of the sides of the channel hast to do so)
50 * @param f                     Function pointers to be called on message recv
51 *
52 * @returns error on failure or SYS_ERR_OK on success
53 */
54errval_t descq_create(struct descq** q,
55                      size_t slots,
56                      char* name,
57                      bool exp,
58                      bool notifications,
59                      uint8_t role,
60                      uint64_t *queue_id,
61                      struct descq_func_pointer* f);
62
63
64#endif /* DESCQ_H_ */
65