1/**
2 * \file
3 * \brief Queue for stack-ripped inter-monitor code
4 */
5
6/*
7 * Copyright (c) 2009, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef QUEUE_H
16#define QUEUE_H
17
18#include <if/intermon_defs.h>
19
20struct msg_queue {
21    struct msg_queue_elem *head, *tail;
22};
23
24struct msg_queue_elem {
25    struct msg_queue_elem *next;
26};
27
28static inline bool msg_queue_is_empty(struct msg_queue *q)
29{
30    return (q->head == NULL);
31}
32
33struct intermon_msg_queue_elem;
34typedef void (*intermon_msg_cont_handler_fn)(struct intermon_binding *b,
35                                             struct intermon_msg_queue_elem *);
36
37struct intermon_msg_queue_elem {
38    struct msg_queue_elem queue;
39    intermon_msg_cont_handler_fn cont;
40};
41
42errval_t intermon_enqueue_send(struct intermon_binding *b, struct msg_queue *q,
43                               struct waitset *ws, struct msg_queue_elem *ms);
44
45errval_t intermon_enqueue_send_at_front(struct intermon_binding *b, struct msg_queue *q,
46                               struct waitset *ws, struct msg_queue_elem *ms);
47
48struct monitor_msg_queue_elem;
49typedef void (*monitor_msg_cont_handler_fn)(struct monitor_binding *b,
50                                            struct monitor_msg_queue_elem *);
51
52struct monitor_msg_queue_elem {
53    struct msg_queue_elem queue;
54    monitor_msg_cont_handler_fn cont;
55};
56
57errval_t monitor_enqueue_send(struct monitor_binding *b, struct msg_queue *q,
58                              struct waitset *ws, struct msg_queue_elem *ms);
59
60errval_t monitor_enqueue_send_at_front(struct monitor_binding *b, struct msg_queue *q,
61                              struct waitset *ws, struct msg_queue_elem *ms);
62
63
64void destroy_outgoing_cap(void *arg);
65struct capref *caprefdup(struct capref cap);
66
67#endif
68