* All things processes! As we move away from the old envs to processes,
* we'll move things into here that are designed for multicore processes. */
-#ifndef ROS_KERN_PROCESS_H
-#define ROS_KERN_PROCESS_H
+#pragma once
#include <ros/common.h>
#include <ros/event.h>
(state)==PROC_RUNNING_M ? "RUNNING_M" : \
"UNKNOWN")
+#define DEFAULT_PROGNAME ""
+
#include <env.h>
+struct process_set {
+ size_t num_processes;
+ size_t size;
+ struct proc **procs;
+};
+
/* Can use a htable iterator to iterate through all active procs */
extern struct hashtable *pid_hash;
extern spinlock_t pid_hash_lock;
/* Initialization */
void proc_init(void);
+void proc_set_progname(struct proc *p, char *name);
+void proc_replace_binary_path(struct proc *p, char *path);
+void proc_init_procinfo(struct proc* p);
+void proc_init_procdata(struct proc* p);
/* Process management: */
-error_t proc_alloc(struct proc **pp, struct proc *parent);
+struct proc *pid_nth(unsigned int n);
+error_t proc_alloc(struct proc **pp, struct proc *parent, int flags);
void __proc_ready(struct proc *p);
struct proc *proc_create(struct file *prog, char **argv, char **envp);
-int __proc_set_state(struct proc *p, uint32_t state) WRITES(p->state);
+int __proc_set_state(struct proc *p, uint32_t state);
struct proc *pid2proc(pid_t pid);
-bool proc_controls(struct proc *SAFE actor, struct proc *SAFE target);
+bool proc_controls(struct proc *actor, struct proc *target);
void proc_incref(struct proc *p, unsigned int val);
void proc_decref(struct proc *p);
void proc_run_s(struct proc *p);
void __proc_run_m(struct proc *p);
+void __proc_startcore(struct proc *p, struct user_context *ctx);
void proc_restartcore(void);
-bool __proc_destroy(struct proc *p, uint32_t *pc_arr, uint32_t *nr_revoked);
-int __proc_change_to_m(struct proc *p);
-void __proc_save_context_s(struct proc *p, struct trapframe *tf);
-void proc_yield(struct proc *SAFE p, bool being_nice);
+void proc_destroy(struct proc *p);
+void proc_signal_parent(struct proc *child);
+int __proc_disown_child(struct proc *parent, struct proc *child);
+int proc_change_to_m(struct proc *p);
+void __proc_save_fpu_s(struct proc *p);
+void __proc_save_context_s(struct proc *p);
+void proc_yield(struct proc *p, bool being_nice);
void proc_notify(struct proc *p, uint32_t vcoreid);
-void __proc_wakeup(struct proc *p);
+void proc_wakeup(struct proc *p);
bool __proc_is_mcp(struct proc *p);
-void proc_change_to_vcore(struct proc *p, uint32_t new_vcoreid,
- bool enable_my_notif);
+bool proc_is_vcctx_ready(struct proc *p);
+int proc_change_to_vcore(struct proc *p, uint32_t new_vcoreid,
+ bool enable_my_notif);
+void proc_get_set(struct process_set *pset);
+void proc_free_set(struct process_set *pset);
/* Vcoremap info: */
-uint32_t proc_get_vcoreid(struct proc *SAFE p, uint32_t pcoreid);
+uint32_t proc_get_vcoreid(struct proc *p);
/* TODO: make all of these inline once we gut the Env crap */
bool vcore_is_mapped(struct proc *p, uint32_t vcoreid);
uint32_t vcore2vcoreid(struct proc *p, struct vcore *vc);
/* Takes all cores, returns the count, fills in pc_arr with their pcoreid */
uint32_t __proc_take_allcores(struct proc *p, uint32_t *pc_arr, bool preempt);
-/* Exposed for kern/src/resource.c for now */
+/* Exposed for now for convenience */
void __map_vcore(struct proc *p, uint32_t vcoreid, uint32_t pcoreid);
void __unmap_vcore(struct proc *p, uint32_t vcoreid);
+void vcore_account_online(struct proc *p, uint32_t vcoreid);
+void vcore_account_offline(struct proc *p, uint32_t vcoreid);
+uint64_t vcore_account_gettotal(struct proc *p, uint32_t vcoreid);
/* Preemption management. Some of these will change */
void __proc_preempt_warn(struct proc *p, uint32_t vcoreid, uint64_t when);
void __proc_preempt_warnall(struct proc *p, uint64_t when);
void __proc_preempt_core(struct proc *p, uint32_t pcoreid);
uint32_t __proc_preempt_all(struct proc *p, uint32_t *pc_arr);
-void proc_preempt_core(struct proc *p, uint32_t pcoreid, uint64_t usec);
+bool proc_preempt_core(struct proc *p, uint32_t pcoreid, uint64_t usec);
void proc_preempt_all(struct proc *p, uint64_t usec);
/* Current / cr3 / context management */
-struct proc *switch_to(struct proc *new_p);
-void switch_back(struct proc *new_p, struct proc *old_proc);
+uintptr_t switch_to(struct proc *new_p);
+void switch_back(struct proc *new_p, uintptr_t old_ret);
void abandon_core(void);
void clear_owning_proc(uint32_t coreid);
void proc_tlbshootdown(struct proc *p, uintptr_t start, uintptr_t end);
/* Kernel message handlers for process management */
-void __startcore(struct trapframe *tf, uint32_t srcid, long a0, long a1,
- long a2);
-void __notify(struct trapframe *tf, uint32_t srcid, long a0, long a1, long a2);
-void __preempt(trapframe_t *tf, uint32_t srcid, long a0, long a1, long a2);
-void __death(struct trapframe *tf, uint32_t srcid, long a0, long a1, long a2);
-void __tlbshootdown(struct trapframe *tf, uint32_t srcid, long a0, long a1,
- long a2);
+void __startcore(uint32_t srcid, long a0, long a1, long a2);
+void __set_curctx(uint32_t srcid, long a0, long a1, long a2);
+void __notify(uint32_t srcid, long a0, long a1, long a2);
+void __preempt(uint32_t srcid, long a0, long a1, long a2);
+void __death(uint32_t srcid, long a0, long a1, long a2);
+void __tlbshootdown(uint32_t srcid, long a0, long a1, long a2);
/* Arch Specific */
-void proc_init_trapframe(trapframe_t *SAFE tf, uint32_t vcoreid,
- uintptr_t entryp, uintptr_t stack_top);
-void proc_secure_trapframe(struct trapframe *tf);
+void proc_pop_ctx(struct user_context *ctx) __attribute__((noreturn));
+void proc_init_ctx(struct user_context *ctx, uint32_t vcoreid, uintptr_t entryp,
+ uintptr_t stack_top, uintptr_t tls_desc);
+void proc_secure_ctx(struct user_context *ctx);
void __abandon_core(void);
/* Degubbing */
void print_allpids(void);
void print_proc_info(pid_t pid);
-
-#endif /* !ROS_KERN_PROCESS_H */