Measurement infrastructure and tests
[akaros.git] / include / env.h
1 /* See COPYRIGHT for copyright information. */
2
3 #ifndef ROS_KERN_ENV_H
4 #define ROS_KERN_ENV_H
5
6 #include <arch/x86.h>
7 #include <ros/env.h>
8 #include <ros/error.h>
9
10 extern env_t *envs;             // All environments
11 extern uint32_t num_envs;               // Number of envs
12 extern env_t* NORACE curenvs[MAX_NUM_CPUS];
13
14 LIST_HEAD(env_list_t, env_t);           // Declares 'struct Env_list'
15
16 void    env_init(void);
17 int             env_alloc(env_t **e, envid_t parent_id);
18 void    env_free(env_t *e);
19 error_t env_incref(env_t* e);
20 void    env_decref(env_t* e);
21 env_t*  env_create(uint8_t *binary, size_t size);
22 void    (IN_HANDLER env_destroy)(env_t *e);     // Does not return if e == curenv
23
24 int     envid2env(envid_t envid, env_t **env_store, bool checkperm);
25 // The following two functions do not return
26 void    (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
27 void    env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
28
29 /* Helper handler for smp_call to dispatch jobs to other cores */
30 void run_env_handler(trapframe_t *tf, void* data);
31
32 #define ENV_CREATE(x)                   ({                                             \
33         extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
34                 _binary_obj_user_apps_##x##_size[];                                    \
35         env_create(_binary_obj_user_apps_##x##_start,                              \
36                 (int)_binary_obj_user_apps_##x##_size);                                \
37 })
38
39 #endif // !ROS_KERN_ENV_H