Add spawn, spawn_with_caps and span calls to the Process Manager API.
[barrelfish] / include / barrelfish / domain.h
1 /**
2  * \file
3  * \brief
4  */
5
6 /*
7  * Copyright (c) 2009, 2010, 2011, 2012, 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, CAB F.78, Universitaetstr. 6, CH-8092 Zurich,
13  * Attn: Systems Group.
14  */
15
16 #ifndef BARRELFISH_DOMAIN_H
17 #define BARRELFISH_DOMAIN_H
18
19 #include <sys/cdefs.h>
20 #include <barrelfish/event_queue.h>
21 #include <barrelfish/threads.h>
22
23 __BEGIN_DECLS
24
25 typedef void (*domain_spanned_callback_t)(void *arg, errval_t err);
26
27 ///< Struct for spanning domains state machine
28 struct span_domain_state {
29     struct thread *thread;              ///< Thread to run on remote core
30     uint8_t core_id;                    ///< Id of the remote core
31     errval_t err;                       ///< To propagate error value
32     domain_spanned_callback_t callback; ///< Callback for when domain has spanned
33     void *callback_arg;                 ///< Optional argument to pass with callback
34     struct capref frame;                ///< Dispatcher frame
35     struct capref vroot;                ///< VRoot cap
36     struct event_queue_node event_qnode;       ///< Event queue node
37     struct waitset_chanstate initev;    ///< Dispatcher initialized event
38     bool initialized;                   ///< True if remote initialized
39 };
40
41 struct mem_binding;
42 struct octopus_binding;
43 struct monitor_binding;
44 struct monitor_blocking_binding;
45 struct waitset;
46 struct spawn_binding;
47 struct arrakis_binding;
48 struct proc_mgmt_binding;
49
50 struct waitset *get_default_waitset(void);
51 void disp_set_core_id(coreid_t core_id);
52 coreid_t disp_get_core_id(void);
53 coreid_t disp_get_current_core_id(void);
54 void disp_get_eh_frame(lvaddr_t *eh_frame, size_t *eh_frame_size);
55 void disp_get_eh_frame_hdr(lvaddr_t *eh_frame_hdr, size_t *eh_frame_hdr_size);
56 domainid_t disp_get_domain_id(void);
57 coreid_t disp_handle_get_core_id(dispatcher_handle_t handle);
58 void set_monitor_binding(struct monitor_binding *b);
59 struct monitor_binding *get_monitor_binding(void);
60 struct waitset_chanstate *get_monitor_binding_chanstate(void);
61 void set_monitor_blocking_binding(struct monitor_blocking_binding *st);
62 struct monitor_blocking_binding *get_monitor_blocking_binding(void);
63 void set_mem_client(struct mem_binding *st);
64 struct mem_binding *get_mem_client(void);
65 struct pinned_state *get_current_pinned_state(void);
66 struct vspace *get_current_vspace(void);
67 struct pmap *get_current_pmap(void);
68 struct morecore_state *get_morecore_state(void);
69 struct ram_alloc_state *get_ram_alloc_state(void);
70 void set_octopus_binding(struct octopus_binding *st);
71 struct octopus_binding *get_octopus_binding(void);
72 void set_spawn_binding(coreid_t core, struct spawn_binding *st);
73 void set_arrakis_binding(coreid_t core, struct arrakis_binding *st);
74 struct spawn_binding *get_spawn_binding(coreid_t core);
75 struct arrakis_binding *get_arrakis_binding(coreid_t core);
76 struct terminal_state *get_terminal_state(void);
77 void set_terminal_state(struct terminal_state *st);
78 struct domain_state *get_domain_state(void);
79 void set_domain_state(struct domain_state *st);
80 struct spawn_state *get_spawn_state(void);
81 void set_spawn_state(struct spawn_state *st);
82 struct slot_alloc_state *get_slot_alloc_state(void);
83 struct skb_state *get_skb_state(void);
84 struct proc_mgmt_binding *get_proc_mgmt_binding(void);
85 void set_proc_mgmt_binding(struct proc_mgmt_binding *st);
86
87 errval_t domain_init(void);
88 errval_t domain_new_dispatcher(coreid_t core_id,
89                                domain_spanned_callback_t callback,
90                                void *callback_arg);
91 errval_t domain_new_dispatcher_setup_only(coreid_t core_id,
92                                           struct span_domain_state **ret_state);
93 errval_t domain_thread_create_on(coreid_t core_id, thread_func_t start_func,
94                                  void *arg, struct thread **newthread);
95 errval_t domain_thread_create_on_varstack(coreid_t core_id,
96                                           thread_func_t start_func,
97                                           void *arg, size_t stacksize,
98                                           struct thread **newthread);
99 errval_t domain_thread_join(struct thread *thread, int *retval);
100 errval_t domain_send_cap(coreid_t core_id, struct capref cap);
101 errval_t domain_wakeup_on(dispatcher_handle_t disp, struct thread *thread);
102 errval_t domain_wakeup_on_disabled(dispatcher_handle_t disp,
103                                    struct thread *thread,
104                                    dispatcher_handle_t mydisp);
105 errval_t domain_thread_move_to(struct thread *thread, coreid_t core_id);
106
107 __END_DECLS
108
109 #endif