1/*
2 * \brief Spawnd state internals for the process manager.
3 *
4 * Copyright (c) 2017, ETH Zurich.
5 * All rights reserved.
6 *
7 * This file is distributed under the terms in the attached LICENSE file.
8 * If you do not find this file, copies can be found by writing to:
9 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
10 */
11
12#ifndef SPAWND_STATE_H
13#define SPAWND_STATE_H
14
15#include <stdbool.h>
16
17#include <if/spawn_defs.h>
18#include <barrelfish/barrelfish.h>
19
20struct spawnd_state;
21struct msg_queue_elem;
22typedef bool (*msg_cont_handler_fn)(struct msg_queue_elem*);
23
24struct msg_queue_elem {
25	void *st;
26	msg_cont_handler_fn cont;
27
28    struct msg_queue_elem *next;
29};
30
31struct msg_queue {
32    struct msg_queue_elem *head, *tail;
33};
34
35struct spawnd_state {
36    coreid_t core_id;
37    struct spawn_binding *b;
38
39    struct msg_queue sendq;
40    struct msg_queue recvq;
41};
42
43errval_t spawnd_state_alloc(coreid_t core_id, struct spawn_binding *b);
44bool spawnd_state_exists(coreid_t core_id);
45struct spawnd_state *spawnd_state_get(coreid_t core_id);
46
47errval_t spawnd_state_enqueue_send(struct spawnd_state *spawnd,
48                                   struct msg_queue_elem *msg);
49void *spawnd_state_dequeue_recv(struct spawnd_state *spawnd);
50
51#endif  // SPAWND_STATE
52