static int __zero_segment (int envid, u_int start, u_int sz) { u_int temp_pages; assert (!(start & PGMASK)); temp_pages = (u_int)__malloc(PGROUNDUP(sz)); if (temp_pages == 0) return -1; /* alloc pages for this segment and map into our address space writeable */ if (__vm_alloc_region (temp_pages, sz, 0, PG_P|PG_U|PG_W) < 0) { __free((void*)temp_pages); return -1; } /* and map them into the other address space */ if (__vm_share_region (temp_pages, sz, 0, 0, envid, start) < 0) { __free((void*)temp_pages); return -1; } /* zero the pages */ bzero ((void *)temp_pages, sz); /* and remove our mapping of the pages */ if (__vm_free_region (temp_pages, sz, 0) < 0) { __free((void*)temp_pages); return -1; } __free((void*)temp_pages); return 0; }
/* Makes the ash region shared */ void AllocAshShareRegion(void) { /* printf("AllocAshShareRegion sz: %d\n",sizeof(struct ash_sh_network)); */ if (__vm_alloc_region(ADD_UVA(ASH_PKT_DATA_ADDR), sizeof(struct ash_sh_network), 0, PG_SHARED|PG_P|PG_U|PG_W) < 0) { printf ("couldn't insert ash data pte's\n"); __die(); } }