Minor touchups after rebase to make it work
[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 <error.h>
9
10 extern env_t *envs;             // All environments
11 extern env_t* NORACE curenvs[MAX_NUM_CPUS];
12
13 LIST_HEAD(env_list_t, env_t);           // Declares 'struct Env_list'
14
15 void    env_init(void);
16 int             env_alloc(env_t **e, envid_t parent_id);
17 void    env_free(env_t *e);
18 error_t env_incref(env_t* e);
19 void    env_decref(env_t* e);
20 env_t*  env_create(uint8_t *binary, size_t size);
21 void    (IN_HANDLER env_destroy)(env_t *e);     // Does not return if e == curenv
22
23 int     envid2env(envid_t envid, env_t **env_store, bool checkperm);
24 // The following two functions do not return
25 void    (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
26 void    env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
27
28 #define ENV_CREATE(x)                   ({                                             \
29         extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
30                 _binary_obj_user_apps_##x##_size[];                                    \
31         env_create(_binary_obj_user_apps_##x##_start,                              \
32                 (int)_binary_obj_user_apps_##x##_size);                                \
33 })
34
35 #endif // !ROS_KERN_ENV_H