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
38 // Special environment IDs
39 #define ENVID_BUFCACHE 0x1100
42 struct Env
*env_next
; // Next env on the free list
44 envid_t env_id
; // Unique environment identifier
45 envid_t env_parent_id
; // env_id of this env's parent
46 unsigned env_status
; // Status of the environment
48 pde_t
*env_pgdir
; // Kernel virtual address of page dir
49 struct Trapframe env_tf
; // Saved registers
50 uint32_t env_runs
; // Number of times environment has run
53 uintptr_t env_pgfault_upcall
; // page fault upcall entry point
56 bool env_ipc_recving
; // env is blocked receiving
57 uintptr_t env_ipc_dstva
; // va at which to map received page
58 uint32_t env_ipc_value
; // data value sent to us
59 envid_t env_ipc_from
; // envid of the sender
60 int env_ipc_perm
; // perm of page mapping received
63 #endif // !JOS_INC_ENV_H