Kernel and roslib now use newlib's queue.h
[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 *COUNT(NENV) 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, Env);               // Declares 'struct env_list'
15 typedef struct env_list env_list_t;
16
17 void    env_init(void);
18 int             env_alloc(env_t **e, envid_t parent_id);
19 void    env_free(env_t *SAFE e);
20 error_t env_incref(env_t* e);
21 void    env_decref(env_t *SAFE e);
22 env_t*  env_create(uint8_t *COUNT(size) binary, size_t size);
23 void    (IN_HANDLER env_destroy)(env_t *SAFE e);        // Does not return if e == curenv
24
25 int     envid2env(envid_t envid, env_t **env_store, bool checkperm);
26 // The following two functions do not return
27 void    (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
28 void    env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
29
30 /* Helper handler for smp_call to dispatch jobs to other cores */
31 void run_env_handler(trapframe_t *tf, void* data);
32
33 #define ENV_CREATE(x)                   ({                                             \
34         extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
35                 _binary_obj_user_apps_##x##_size[];                                    \
36         env_create(_binary_obj_user_apps_##x##_start,                              \
37                 (int)_binary_obj_user_apps_##x##_size);                                \
38 })
39
40 #endif // !ROS_KERN_ENV_H