Converted curenv calls into an opaque macro
[akaros.git] / include / env.h
index b21e66f..6a3012e 100644 (file)
@@ -21,9 +21,17 @@ error_t      env_incref(env_t* e);
 void   env_decref(env_t *SAFE e);
 env_t* env_create(uint8_t *COUNT(size) binary, size_t size);
 void   (IN_HANDLER env_destroy)(env_t *SAFE e);        // Does not return if e == curenv
+// Temporary scheduler function
+void   schedule(void);
+
+/*
+ * Allows the kernel to figure out what process is running on its core.
+ * Can be used just like a pointer to a struct process.
+ */
+#define current (curenvs[lapic_get_id()])
 
 int    envid2env(envid_t envid, env_t **env_store, bool checkperm);
-// The following two functions do not return
+// The following three functions do not return
 void   (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
 void   env_pop_tf(trapframe_t *tf) __attribute__((noreturn));
 void   env_pop_tf_sysexit(trapframe_t *tf) __attribute__((noreturn));
@@ -35,8 +43,10 @@ void run_env_handler(trapframe_t *tf, void* data);
 #define ENV_CREATE(x)                  ({                                             \
        extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
                _binary_obj_user_apps_##x##_size[];                                    \
-       env_create(_binary_obj_user_apps_##x##_start,                              \
+       env_t *e = env_create(_binary_obj_user_apps_##x##_start,                   \
                (int)_binary_obj_user_apps_##x##_size);                                \
+       e->env_status = ENV_RUNNABLE;                                              \
+       e;                                                                         \
 })
 
 #endif // !ROS_KERN_ENV_H