1 /* See COPYRIGHT for copyright information. */
9 #include <inc/memlayout.h>
11 typedef int32_t envid_t
;
13 // An environment ID 'envid_t' has three parts:
15 // +1+---------------21-----------------+--------10--------+
16 // |0| Uniqueifier | Environment |
18 // +------------------------------------+------------------+
21 // The environment index ENVX(eid) equals the environment's offset in the
22 // 'envs[]' array. The uniqueifier distinguishes environments that were
23 // created at different times, but share the same environment index.
25 // All real environments are greater than 0 (so the sign bit is zero).
26 // envid_ts less than 0 signify errors. The envid_t == 0 is special, and
27 // stands for the current environment.
30 #define NENV (1 << LOG2NENV)
31 #define ENVX(envid) ((envid) & (NENV - 1))
33 // Values of env_status in struct Env
35 #define ENV_RUNNABLE 1
36 #define ENV_NOT_RUNNABLE 2
39 struct Env
*env_next
; // Next env on the free list
41 envid_t env_id
; // Unique environment identifier
42 envid_t env_parent_id
; // env_id of this env's parent
43 unsigned env_status
; // Status of the environment
45 pde_t
*env_pgdir
; // Kernel virtual address of page dir
46 struct Trapframe env_tf
; // Saved registers
47 uint32_t env_runs
; // Number of times environment has run
50 uintptr_t env_pgfault_upcall
; // page fault upcall entry point
53 bool env_ipc_recving
; // env is blocked receiving
54 uintptr_t env_ipc_dstva
; // va at which to map received page
55 uint32_t env_ipc_value
; // data value sent to us
56 envid_t env_ipc_from
; // envid of the sender
57 int env_ipc_perm
; // perm of page mapping received
60 #endif // !JOS_INC_ENV_H