1 /* See COPYRIGHT for copyright information. */
5 /* Note that the old include/ros/env.h is merged into this file */
7 #include <ros/memlayout.h>
8 #include <ros/syscall.h>
9 #include <ros/sysevent.h>
10 #include <ros/procinfo.h>
12 #include <ros/procdata.h>
13 #include <ros/procinfo.h>
14 #include <ros/resource.h>
16 #include <ros/common.h>
17 #include <arch/arch.h>
18 #include <sys/queue.h>
26 TAILQ_HEAD(vcore_tailq, vcore);
27 /* 'struct proc_list' declared in sched.h (not ideal...) */
29 // TODO: clean this up.
31 TAILQ_ENTRY(proc) proc_arsc_link;
32 TAILQ_ENTRY(proc) sibling_link;
34 struct user_context scp_ctx; /* context for an SCP. TODO: move to vc0 */
35 char user[64]; /* user name */
38 /* Tempting to add a struct proc *parent, but we'd need to protect the use
39 * of that reference from concurrent parent-death (letting init inherit
40 * children, etc), which is basically what we do when we do pid2proc. If we
41 * do add *parent, it'll be a weak ref, and you'll need to lock the child to
42 * kref_get or to remove the pointer. */
43 pid_t ppid; /* parent's pid, not a reference */
44 struct proc_list children; /* protected by the proc lock for now */
45 int exitcode; /* exit() param or main() return value */
46 struct cond_var child_wait; /* signal for dying or o/w waitable child */
47 uint32_t state; // Status of the process
48 struct kref p_kref; /* Refcnt */
52 struct vcore_tailq online_vcs;
53 struct vcore_tailq bulk_preempted_vcs;
54 struct vcore_tailq inactive_vcs;
55 /* Scheduler mgmt (info, data, whatever) */
56 struct sched_proc_data ksched_data;
58 /* Cache color map: bitmap of the cache colors currently allocated to this
60 uint8_t* cache_colors_map;
61 size_t next_cache_color;
63 /* Keeps track of this process's current memory allocation
64 * (i.e. its heap pointer) */
68 pde_t *COUNT(NPDENTRIES) env_pgdir; // Kernel virtual address of page dir
69 physaddr_t env_cr3; // Physical address of page dir
70 spinlock_t vmr_lock; /* Protects VMR tree (mem mgmt) */
71 spinlock_t pte_lock; /* Protects page tables (mem mgmt) */
72 struct vmr_tailq vm_regions;
75 // Per process info and data pages
76 procinfo_t *SAFE procinfo; // KVA of per-process shared info table (RO)
77 procdata_t *SAFE procdata; // KVA of per-process shared data table (RW)
79 // The backring pointers for processing asynchronous system calls from the user
80 // Note this is the actual backring, not a pointer to it somewhere else
81 syscall_back_ring_t syscallbackring;
83 // The front ring pointers for pushing asynchronous system events out to the user
84 // Note this is the actual frontring, not a pointer to it somewhere else
85 sysevent_front_ring_t syseventfrontring;
89 struct fs_struct fs_env;
90 struct files_struct open_files;
98 struct hashlock *ucq_hashlock;
99 struct small_hashlock ucq_hl_noref; /* don't reference directly */
101 struct proc_alarm_set alarmset;
102 struct cv_lookup_tailq abortable_sleepers;
103 spinlock_t abort_list_lock;
107 /* Til we remove all Env references */
109 typedef struct proc env_t;
112 #define PROC_TRANSITION_TO_M 0x0001
114 extern atomic_t num_envs; // Number of envs
116 int env_setup_vm(env_t *e);
117 void env_user_mem_free(env_t* e, void* start, size_t len);
118 void env_pagetable_free(env_t* e);
120 typedef int (*mem_walk_callback_t)(env_t* e, pte_t* pte, void* va, void* arg);
121 int env_user_mem_walk(env_t* e, void* start, size_t len, mem_walk_callback_t callback, void* arg);
123 #endif // !ROS_KERN_ENV_H