1/* 2 * \brief Domain 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 PROC_MGMT_DOMAIN_H 13#define PROC_MGMT_DOMAIN_H 14 15#include <barrelfish/barrelfish.h> 16#include <if/proc_mgmt_defs.h> 17 18#include "spawnd_state.h" 19 20#define EXIT_STATUS_KILLED 9 21 22enum domain_status { 23 DOMAIN_STATUS_NIL, 24 DOMAIN_STATUS_RUNNING, 25 DOMAIN_STATUS_STOP_PEND, 26 DOMAIN_STATUS_STOPPED, 27 DOMAIN_STATUS_CLEANED 28}; 29 30struct domain_waiter { 31 struct proc_mgmt_binding *b; 32 struct domain_waiter *next; 33}; 34 35struct domain_cap_node { 36 struct capref domain_cap; 37 uint64_t hash; 38 39 struct domain_cap_node *next; 40}; 41 42struct domain_entry { 43 struct domain_cap_node *cap_node; 44 enum domain_status status; // Current domain state. 45 46 struct spawnd_state *spawnds[MAX_COREID]; // Spawnds running this domain. 47 coreid_t num_spawnds_running; 48 coreid_t num_spawnds_resources; 49 50 51 struct domain_waiter *waiters; // Clients waiting after this domain. 52 53 /* Mainly used for ps like command (XXX currently duplicated also in spawnd) */ 54 domainid_t domainid; 55 char *argbuf; 56 size_t argbytes; 57 58 uint8_t exit_status; 59}; 60 61bool domain_should_refill_caps(void); 62errval_t domain_prealloc_caps(void); 63struct domain_cap_node *next_cap_node(void); 64errval_t domain_get_by_cap(struct capref domain_cap, 65 struct domain_entry **ret_entry); 66void domain_run_on_core(struct domain_entry *entry, coreid_t core_id); 67 68errval_t domain_new(struct domain_cap_node *cap_node, const char* argbuf, 69 size_t argbytes, struct domain_entry **ret_entry); 70errval_t domain_spawn(struct domain_cap_node *cap_node, coreid_t core_id, 71 const char* argbuf, size_t argbytes); 72errval_t domain_can_span(struct capref domain_cap, coreid_t core_id); 73errval_t domain_span(struct capref domain_cap, coreid_t core_id); 74void domain_get_all_ids(domainid_t** domains, size_t* len); 75static inline void domain_stop_pending(struct domain_entry *entry) 76{ 77 assert(entry != NULL); 78 entry->status = DOMAIN_STATUS_STOP_PEND; 79} 80 81errval_t domain_get_by_id(domainid_t, 82 struct domain_entry **ret_entry); 83 84 85#endif // PROC_MGMT_DOMAIN_H 86