Rename KMALLOC_* -> MEM_* [2/2]
[akaros.git] / kern / src / env.c
index 0bd26b4..6d2811a 100644 (file)
@@ -1,9 +1,5 @@
 /* See COPYRIGHT for copyright information. */
 
-#ifdef __SHARC__
-#pragma nosharc
-#endif
-
 #include <arch/arch.h>
 #include <arch/mmu.h>
 #include <bitmask.h>
@@ -37,10 +33,9 @@ atomic_t num_envs;
 //     -ENOMEM if page directory or table could not be allocated.
 //
 int env_setup_vm(env_t *e)
-WRITES(e->env_pgdir, e->env_cr3, e->procinfo, e->procdata)
 {
        int i, ret;
-       static page_t * RO shared_page = 0;
+       static page_t *shared_page = 0;
 
        if ((ret = arch_pgdir_setup(boot_pgdir, &e->env_pgdir)))
                return ret;
@@ -58,12 +53,18 @@ WRITES(e->env_pgdir, e->env_cr3, e->procinfo, e->procdata)
         * start the process without calling those. */
        for (int i = 0; i < PROCINFO_NUM_PAGES; i++) {
                if (page_insert(e->env_pgdir, kva2page((void*)e->procinfo + i *
-                               PGSIZE), (void*SNT)(UINFO + i*PGSIZE), PTE_USER_RO) < 0)
+                               PGSIZE), (void*)(UINFO + i*PGSIZE), PTE_USER_RO) < 0)
                        goto env_setup_vm_error;
        }
        for (int i = 0; i < PROCDATA_NUM_PAGES; i++) {
                if (page_insert(e->env_pgdir, kva2page((void*)e->procdata + i *
-                               PGSIZE), (void*SNT)(UDATA + i*PGSIZE), PTE_USER_RW) < 0)
+                               PGSIZE), (void*)(UDATA + i*PGSIZE), PTE_USER_RW) < 0)
+                       goto env_setup_vm_error;
+       }
+       for (int i = 0; i < PROCGINFO_NUM_PAGES; i++) {
+               if (page_insert(e->env_pgdir,
+                               kva2page((void*)&__proc_global_info + i * PGSIZE),
+                               (void*)(UGINFO + i * PGSIZE), PTE_USER_RO) < 0)
                        goto env_setup_vm_error;
        }
        /* Finally, set up the Global Shared Data page for all processes.  Can't be
@@ -108,7 +109,7 @@ void env_user_mem_free(env_t* e, void* start, size_t len)
        assert((uintptr_t)start + len <= UVPT); //since this keeps fucking happening
        int user_page_free(env_t* e, pte_t pte, void* va, void* arg)
        {
-               if (!pte_is_present(pte))
+               if (!pte_is_mapped(pte))
                        return 0;
                page_t *page = pa2page(pte_get_paddr(pte));
                pte_clear(pte);