Got rid of regions - we're now back in area-land.

Renamed vm_area::lock to vm_area::protection to be less confusing - wiring
is still called wiring, though (might be renamed to lock later, as that's
how BeOS calls it).
Renamed some global variables to match our naming scheme.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9860 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-11-08 14:25:09 +00:00
parent df9445ba48
commit 1c11f7ea8a
6 changed files with 483 additions and 473 deletions
+381 -381
View File
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -1,5 +1,5 @@
/* /*
** Copyright 2002-2004, The Haiku Team. All rights reserved. ** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. ** Distributed under the terms of the Haiku License.
** **
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -58,7 +58,7 @@ static sem_id aspace_hash_sem;
static void static void
_dump_aspace(vm_address_space *aspace) _dump_aspace(vm_address_space *aspace)
{ {
vm_region *region; vm_area *area;
dprintf("dump of address space at %p:\n", aspace); dprintf("dump of address space at %p:\n", aspace);
dprintf("name: '%s'\n", aspace->name); dprintf("name: '%s'\n", aspace->name);
@@ -71,14 +71,14 @@ _dump_aspace(vm_address_space *aspace)
dprintf("virtual_map.size: 0x%lx\n", aspace->virtual_map.size); dprintf("virtual_map.size: 0x%lx\n", aspace->virtual_map.size);
dprintf("virtual_map.change_count: 0x%x\n", aspace->virtual_map.change_count); dprintf("virtual_map.change_count: 0x%x\n", aspace->virtual_map.change_count);
dprintf("virtual_map.sem: 0x%lx\n", aspace->virtual_map.sem); dprintf("virtual_map.sem: 0x%lx\n", aspace->virtual_map.sem);
dprintf("virtual_map.region_hint: %p\n", aspace->virtual_map.region_hint); dprintf("virtual_map.region_hint: %p\n", aspace->virtual_map.area_hint);
dprintf("virtual_map.region_list:\n"); dprintf("virtual_map.region_list:\n");
for (region = aspace->virtual_map.region_list; region != NULL; region = region->aspace_next) { for (area = aspace->virtual_map.areas; area != NULL; area = area->aspace_next) {
dprintf(" region 0x%lx: ", region->id); dprintf(" region 0x%lx: ", area->id);
dprintf("base_addr = 0x%lx ", region->base); dprintf("base_addr = 0x%lx ", area->base);
dprintf("size = 0x%lx ", region->size); dprintf("size = 0x%lx ", area->size);
dprintf("name = '%s' ", region->name); dprintf("name = '%s' ", area->name);
dprintf("lock = 0x%x\n", region->lock); dprintf("protection = 0x%lx\n", area->protection);
} }
} }
@@ -322,8 +322,8 @@ vm_create_aspace(const char *name, addr_t base, addr_t size, bool kernel, vm_add
// initialize the virtual map // initialize the virtual map
aspace->virtual_map.base = base; aspace->virtual_map.base = base;
aspace->virtual_map.size = size; aspace->virtual_map.size = size;
aspace->virtual_map.region_list = NULL; aspace->virtual_map.areas = NULL;
aspace->virtual_map.region_hint = NULL; aspace->virtual_map.area_hint = NULL;
aspace->virtual_map.change_count = 0; aspace->virtual_map.change_count = 0;
aspace->virtual_map.sem = create_sem(WRITE_COUNT, "aspacelock"); aspace->virtual_map.sem = create_sem(WRITE_COUNT, "aspacelock");
aspace->virtual_map.aspace = aspace; aspace->virtual_map.aspace = aspace;
@@ -366,7 +366,7 @@ vm_aspace_init(void)
next_aspace_id = 0; next_aspace_id = 0;
aspace_hash_sem = -1; aspace_hash_sem = -1;
// create the region and address space hash tables // create the area and address space hash tables
{ {
vm_address_space *aspace; vm_address_space *aspace;
aspace_table = hash_init(ASPACE_HASH_TABLE_SIZE, (addr_t)&aspace->hash_next - (addr_t)aspace, aspace_table = hash_init(ASPACE_HASH_TABLE_SIZE, (addr_t)&aspace->hash_next - (addr_t)aspace,
+18 -14
View File
@@ -1,8 +1,12 @@
/* /*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
**
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#include <kernel.h> #include <kernel.h>
#include <vm.h> #include <vm.h>
#include <vm_priv.h> #include <vm_priv.h>
@@ -122,7 +126,7 @@ vm_cache_ref_create(vm_cache *cache)
ref->cache = cache; ref->cache = cache;
mutex_init(&ref->lock, "cache_ref_mutex"); mutex_init(&ref->lock, "cache_ref_mutex");
ref->region_list = NULL; ref->areas = NULL;
ref->ref_count = 0; ref->ref_count = 0;
cache->ref = ref; cache->ref = ref;
@@ -352,15 +356,15 @@ vm_cache_resize(vm_cache_ref *cacheRef, size_t newSize)
status_t status_t
vm_cache_insert_region(vm_cache_ref *cache_ref, vm_region *region) vm_cache_insert_area(vm_cache_ref *cache_ref, vm_area *area)
{ {
mutex_lock(&cache_ref->lock); mutex_lock(&cache_ref->lock);
region->cache_next = cache_ref->region_list; area->cache_next = cache_ref->areas;
if (region->cache_next) if (area->cache_next)
region->cache_next->cache_prev = region; area->cache_next->cache_prev = area;
region->cache_prev = NULL; area->cache_prev = NULL;
cache_ref->region_list = region; cache_ref->areas = area;
mutex_unlock(&cache_ref->lock); mutex_unlock(&cache_ref->lock);
return B_OK; return B_OK;
@@ -368,16 +372,16 @@ vm_cache_insert_region(vm_cache_ref *cache_ref, vm_region *region)
status_t status_t
vm_cache_remove_region(vm_cache_ref *cache_ref, vm_region *region) vm_cache_remove_area(vm_cache_ref *cache_ref, vm_area *area)
{ {
mutex_lock(&cache_ref->lock); mutex_lock(&cache_ref->lock);
if (region->cache_prev) if (area->cache_prev)
region->cache_prev->cache_next = region->cache_next; area->cache_prev->cache_next = area->cache_next;
if (region->cache_next) if (area->cache_next)
region->cache_next->cache_prev = region->cache_prev; area->cache_next->cache_prev = area->cache_prev;
if (cache_ref->region_list == region) if (cache_ref->areas == area)
cache_ref->region_list = region->cache_next; cache_ref->areas = area->cache_next;
mutex_unlock(&cache_ref->lock); mutex_unlock(&cache_ref->lock);
return B_OK; return B_OK;
+23 -23
View File
@@ -25,8 +25,8 @@ static addr_t free_memory_high_water;
static void static void
scan_pages(vm_address_space *aspace, addr_t free_target) scan_pages(vm_address_space *aspace, addr_t free_target)
{ {
vm_region *first_region; vm_area *firstArea;
vm_region *region; vm_area *area;
vm_page *page; vm_page *page;
addr_t va; addr_t va;
addr_t pa; addr_t pa;
@@ -38,30 +38,30 @@ scan_pages(vm_address_space *aspace, addr_t free_target)
acquire_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0, 0); acquire_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0, 0);
first_region = aspace->virtual_map.region_list; firstArea = aspace->virtual_map.areas;
while (first_region && (first_region->base + (first_region->size - 1)) < aspace->scan_va) while (firstArea && (firstArea->base + (firstArea->size - 1)) < aspace->scan_va)
first_region = first_region->aspace_next; firstArea = firstArea->aspace_next;
if (!first_region) if (!firstArea)
first_region = aspace->virtual_map.region_list; firstArea = aspace->virtual_map.areas;
if (!first_region) { if (!firstArea) {
release_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0); release_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0);
return; return;
} }
region = first_region; area = firstArea;
for (;;) { for (;;) {
// ignore reserved ranges // ignore reserved ranges
while (region != NULL && region->id == RESERVED_REGION_ID) while (area != NULL && area->id == RESERVED_REGION_ID)
region = region->aspace_next; area = area->aspace_next;
if (region == NULL) if (area == NULL)
break; break;
// scan the pages in this region // scan the pages in this area
mutex_lock(&region->cache_ref->lock); mutex_lock(&area->cache_ref->lock);
if (!region->cache_ref->cache->scan_skip) { if (!area->cache_ref->cache->scan_skip) {
for(va = region->base; va < (region->base + region->size); va += B_PAGE_SIZE) { for(va = area->base; va < (area->base + area->size); va += B_PAGE_SIZE) {
aspace->translation_map.ops->lock(&aspace->translation_map); aspace->translation_map.ops->lock(&aspace->translation_map);
aspace->translation_map.ops->query(&aspace->translation_map, va, &pa, &flags); aspace->translation_map.ops->query(&aspace->translation_map, va, &pa, &flags);
if ((flags & PAGE_PRESENT) == 0) { if ((flags & PAGE_PRESENT) == 0) {
@@ -117,17 +117,17 @@ scan_pages(vm_address_space *aspace, addr_t free_target)
break; break;
} }
} }
mutex_unlock(&region->cache_ref->lock); mutex_unlock(&area->cache_ref->lock);
// move to the next region, wrapping around and stopping if we get back to the first region // move to the next area, wrapping around and stopping if we get back to the first area
region = region->aspace_next ? region->aspace_next : aspace->virtual_map.region_list; area = area->aspace_next ? area->aspace_next : aspace->virtual_map.areas;
if (region == first_region) if (area == firstArea)
break; break;
if (quantum == 0) if (quantum == 0)
break; break;
} }
aspace->scan_va = region ? (first_region->base + first_region->size) : aspace->virtual_map.base; aspace->scan_va = area ? (firstArea->base + firstArea->size) : aspace->virtual_map.base;
release_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0); release_sem_etc(aspace->virtual_map.sem, READ_COUNT, 0);
// dprintf("exiting scan_pages\n"); // dprintf("exiting scan_pages\n");
@@ -217,8 +217,8 @@ vm_daemon_init()
// create a kernel thread to select pages for pageout // create a kernel thread to select pages for pageout
thread = spawn_kernel_thread(&page_daemon, "page daemon", B_FIRST_REAL_TIME_PRIORITY, NULL); thread = spawn_kernel_thread(&page_daemon, "page daemon", B_FIRST_REAL_TIME_PRIORITY, NULL);
resume_thread(thread); send_signal_etc(thread, SIGCONT, B_DO_NOT_RESCHEDULE);
return 0; return B_OK;
} }
+10 -7
View File
@@ -1,4 +1,7 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
**
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
@@ -65,7 +68,7 @@ device_fault(struct vm_store *_store, struct vm_address_space *aspace, off_t off
{ {
struct device_store *store = (struct device_store *)_store; struct device_store *store = (struct device_store *)_store;
vm_cache_ref *cache_ref = store->vm.cache->ref; vm_cache_ref *cache_ref = store->vm.cache->ref;
vm_region *region; vm_area *area;
// dprintf("device_fault: offset 0x%x 0x%x + base_addr 0x%x\n", offset, d->base_addr); // dprintf("device_fault: offset 0x%x 0x%x + base_addr 0x%x\n", offset, d->base_addr);
@@ -74,15 +77,15 @@ device_fault(struct vm_store *_store, struct vm_address_space *aspace, off_t off
(*aspace->translation_map.ops->lock)(&aspace->translation_map); (*aspace->translation_map.ops->lock)(&aspace->translation_map);
// cycle through all of the regions that map this cache and map the page in // cycle through all of the regions that map this cache and map the page in
for (region = cache_ref->region_list; region != NULL; region = region->cache_next) { for (area = cache_ref->areas; area != NULL; area = area->cache_next) {
// make sure this page in the cache that was faulted on is covered in this region // make sure this page in the cache that was faulted on is covered in this area
if (offset >= region->cache_offset && (offset - region->cache_offset) < region->size) { if (offset >= area->cache_offset && (offset - area->cache_offset) < area->size) {
// dprintf("device_fault: mapping paddr 0x%x to vaddr 0x%x\n", // dprintf("device_fault: mapping paddr 0x%x to vaddr 0x%x\n",
// (addr)(d->base_addr + offset), // (addr)(d->base_addr + offset),
// (addr)(region->base + (offset - region->cache_offset))); // (addr)(area->base + (offset - area->cache_offset)));
(*aspace->translation_map.ops->map)(&aspace->translation_map, (*aspace->translation_map.ops->map)(&aspace->translation_map,
region->base + (offset - region->cache_offset), area->base + (offset - area->cache_offset),
store->base_address + offset, region->lock); store->base_address + offset, area->protection);
} }
} }
+39 -36
View File
@@ -1,4 +1,7 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
**
** Copyright 2001, Travis Geiselbrecht. All rights reserved. ** Copyright 2001, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
@@ -22,10 +25,10 @@ vm_test(void)
#if 1 #if 1
dprintf("vm_test 1: creating anonymous region and writing to it\n"); dprintf("vm_test 1: creating anonymous region and writing to it\n");
{ {
region_id region; area_id region;
addr_t region_addr; addr_t region_addr;
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", (void **)&region_addr, region = vm_create_anonymous_area(vm_get_kernel_aspace_id(), "test_region", (void **)&region_addr,
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (region < 0) if (region < 0)
panic("vm_test 1: failed to create test region\n"); panic("vm_test 1: failed to create test region\n");
@@ -34,7 +37,7 @@ vm_test(void)
memset((void *)region_addr, 0, B_PAGE_SIZE * 16); memset((void *)region_addr, 0, B_PAGE_SIZE * 16);
dprintf("memsetted the region\n"); dprintf("memsetted the region\n");
if (vm_delete_region(vm_get_kernel_aspace_id(), region) < 0) if (vm_delete_area(vm_get_kernel_aspace_id(), region) < 0)
panic("vm_test 1: error deleting test region\n"); panic("vm_test 1: error deleting test region\n");
dprintf("deleted the region\n"); dprintf("deleted the region\n");
} }
@@ -42,14 +45,14 @@ vm_test(void)
#if 1 #if 1
dprintf("vm_test 2: creating physical region and writing and reading from it\n"); dprintf("vm_test 2: creating physical region and writing and reading from it\n");
{ {
region_id region; area_id region;
area_info info; area_info info;
char *ptr; char *ptr;
int i; int i;
region = vm_map_physical_memory(vm_get_kernel_aspace_id(), "test_physical_region", (void **)&ptr, region = vm_map_physical_memory(vm_get_kernel_aspace_id(), "test_physical_region", (void **)&ptr,
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0xb8000); B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, 0xb8000);
if(region < 0) if (region < 0)
panic("vm_test 2: failed to create test region\n"); panic("vm_test 2: failed to create test region\n");
get_area_info(region, &info); get_area_info(region, &info);
@@ -60,7 +63,7 @@ vm_test(void)
for(i=0; i<64; i++) { for(i=0; i<64; i++) {
ptr[i] = 'a'; ptr[i] = 'a';
} }
if(vm_delete_region(vm_get_kernel_aspace_id(), region) < 0) if (vm_delete_area(vm_get_kernel_aspace_id(), region) < 0)
panic("vm_test 2: error deleting test region\n"); panic("vm_test 2: error deleting test region\n");
dprintf("deleted the region\n"); dprintf("deleted the region\n");
} }
@@ -95,36 +98,36 @@ vm_test(void)
#if 1 #if 1
dprintf("vm_test 4: cloning vidmem and testing if it compares\n"); dprintf("vm_test 4: cloning vidmem and testing if it compares\n");
{ {
region_id region, region2; area_id region, region2;
area_info info; area_info info;
void *ptr; void *ptr;
int rc; int rc;
region = find_area("vid_mem"); region = find_area("vid_mem");
if(region < 0) if (region < 0)
panic("vm_test 4: error finding region 'vid_mem'\n"); panic("vm_test 4: error finding region 'vid_mem'\n");
dprintf("vid_mem region = 0x%lx\n", region); dprintf("vid_mem region = 0x%lx\n", region);
region2 = vm_clone_region(vm_get_kernel_aspace_id(), "vid_mem2", region2 = vm_clone_area(vm_get_kernel_aspace_id(), "vid_mem2",
&ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); &ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if(region2 < 0) if (region2 < 0)
panic("vm_test 4: error cloning region 'vid_mem'\n"); panic("vm_test 4: error cloning region 'vid_mem'\n");
dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr); dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr);
get_area_info(region, &info); get_area_info(region, &info);
rc = memcmp(ptr, (void *)info.address, info.size); rc = memcmp(ptr, (void *)info.address, info.size);
if(rc != 0) if (rc != 0)
panic("vm_test 4: regions are not identical\n"); panic("vm_test 4: regions are not identical\n");
else else
dprintf("vm_test 4: comparison ok\n"); dprintf("vm_test 4: comparison ok\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region2) < 0) if (vm_delete_area(vm_get_kernel_aspace_id(), region2) < 0)
panic("vm_test 4: error deleting cloned region\n"); panic("vm_test 4: error deleting cloned region\n");
} }
#endif #endif
#if 1 #if 1
dprintf("vm_test 5: cloning vidmem in RO and testing if it compares\n"); dprintf("vm_test 5: cloning vidmem in RO and testing if it compares\n");
{ {
region_id region, region2; area_id region, region2;
area_info info; area_info info;
void *ptr; void *ptr;
int rc; int rc;
@@ -134,32 +137,32 @@ vm_test(void)
panic("vm_test 5: error finding region 'vid_mem'\n"); panic("vm_test 5: error finding region 'vid_mem'\n");
dprintf("vid_mem region = 0x%lx\n", region); dprintf("vid_mem region = 0x%lx\n", region);
region2 = vm_clone_region(vm_get_kernel_aspace_id(), "vid_mem3", region2 = vm_clone_area(vm_get_kernel_aspace_id(), "vid_mem3",
&ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA); &ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA);
if(region2 < 0) if (region2 < 0)
panic("vm_test 5: error cloning region 'vid_mem'\n"); panic("vm_test 5: error cloning region 'vid_mem'\n");
dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr); dprintf("region2 = 0x%lx, ptr = %p\n", region2, ptr);
get_area_info(region, &info); get_area_info(region, &info);
rc = memcmp(ptr, (void *)info.address, info.size); rc = memcmp(ptr, (void *)info.address, info.size);
if(rc != 0) if (rc != 0)
panic("vm_test 5: regions are not identical\n"); panic("vm_test 5: regions are not identical\n");
else else
dprintf("vm_test 5: comparison ok\n"); dprintf("vm_test 5: comparison ok\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region2) < 0) if (vm_delete_area(vm_get_kernel_aspace_id(), region2) < 0)
panic("vm_test 5: error deleting cloned region\n"); panic("vm_test 5: error deleting cloned region\n");
} }
#endif #endif
#if 1 #if 1
dprintf("vm_test 6: creating anonymous region, cloning it, and testing if it compares\n"); dprintf("vm_test 6: creating anonymous region, cloning it, and testing if it compares\n");
{ {
region_id region, region2; area_id region, region2;
void *region_addr; void *region_addr;
void *ptr; void *ptr;
int rc; int rc;
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", &region_addr, region = vm_create_anonymous_area(vm_get_kernel_aspace_id(), "test_region", &region_addr,
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (region < 0) if (region < 0)
panic("vm_test 6: error creating test region\n"); panic("vm_test 6: error creating test region\n");
@@ -169,7 +172,7 @@ vm_test(void)
dprintf("memsetted the region\n"); dprintf("memsetted the region\n");
region2 = vm_clone_region(vm_get_kernel_aspace_id(), "test_region2", region2 = vm_clone_area(vm_get_kernel_aspace_id(), "test_region2",
&ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); &ptr, B_ANY_KERNEL_ADDRESS, region, REGION_NO_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if(region2 < 0) if(region2 < 0)
panic("vm_test 6: error cloning test region\n"); panic("vm_test 6: error cloning test region\n");
@@ -181,10 +184,10 @@ vm_test(void)
else else
dprintf("vm_test 6: comparison ok\n"); dprintf("vm_test 6: comparison ok\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region) < 0) if(vm_delete_area(vm_get_kernel_aspace_id(), region) < 0)
panic("vm_test 6: error deleting test region\n"); panic("vm_test 6: error deleting test region\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region2) < 0) if(vm_delete_area(vm_get_kernel_aspace_id(), region2) < 0)
panic("vm_test 6: error deleting cloned region\n"); panic("vm_test 6: error deleting cloned region\n");
} }
#endif #endif
@@ -192,7 +195,7 @@ vm_test(void)
dprintf("vm_test 7: mmaping a known file a few times and verifying they see the same data\n"); dprintf("vm_test 7: mmaping a known file a few times and verifying they see the same data\n");
{ {
void *ptr, *ptr2; void *ptr, *ptr2;
region_id rid, rid2; area_id rid, rid2;
// char *blah; // char *blah;
int fd; int fd;
@@ -208,8 +211,8 @@ vm_test(void)
dprintf("removing regions\n"); dprintf("removing regions\n");
vm_delete_region(vm_get_kernel_aspace_id(), rid); vm_delete_area(vm_get_kernel_aspace_id(), rid);
vm_delete_region(vm_get_kernel_aspace_id(), rid2); vm_delete_area(vm_get_kernel_aspace_id(), rid2);
dprintf("regions deleted\n"); dprintf("regions deleted\n");
@@ -221,14 +224,14 @@ vm_test(void)
#if 1 #if 1
dprintf("vm_test 8: creating anonymous region, cloning it with private mapping\n"); dprintf("vm_test 8: creating anonymous region, cloning it with private mapping\n");
{ {
region_id region, region2; area_id region, region2;
void *region_addr; void *region_addr;
void *ptr; void *ptr;
int rc; int rc;
dprintf("vm_test 8: creating test region...\n"); dprintf("vm_test 8: creating test region...\n");
region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "test_region", &region_addr, region = vm_create_anonymous_area(vm_get_kernel_aspace_id(), "test_region", &region_addr,
B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); B_ANY_KERNEL_ADDRESS, B_PAGE_SIZE * 16, B_NO_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if(region < 0) if(region < 0)
panic("vm_test 8: error creating test region\n"); panic("vm_test 8: error creating test region\n");
@@ -240,7 +243,7 @@ vm_test(void)
dprintf("vm_test 8: cloning test region with PRIVATE_MAP\n"); dprintf("vm_test 8: cloning test region with PRIVATE_MAP\n");
region2 = vm_clone_region(vm_get_kernel_aspace_id(), "test_region2", region2 = vm_clone_area(vm_get_kernel_aspace_id(), "test_region2",
&ptr, B_ANY_KERNEL_ADDRESS, region, REGION_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); &ptr, B_ANY_KERNEL_ADDRESS, region, REGION_PRIVATE_MAP, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if(region2 < 0) if(region2 < 0)
panic("vm_test 8: error cloning test region\n"); panic("vm_test 8: error cloning test region\n");
@@ -293,10 +296,10 @@ vm_test(void)
else else
panic("vm_test 8: comparison shows not private mapping\n"); panic("vm_test 8: comparison shows not private mapping\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region) < 0) if(vm_delete_area(vm_get_kernel_aspace_id(), region) < 0)
panic("vm_test 8: error deleting test region\n"); panic("vm_test 8: error deleting test region\n");
if(vm_delete_region(vm_get_kernel_aspace_id(), region2) < 0) if(vm_delete_area(vm_get_kernel_aspace_id(), region2) < 0)
panic("vm_test 8: error deleting cloned region\n"); panic("vm_test 8: error deleting cloned region\n");
} }
#endif #endif
@@ -304,7 +307,7 @@ vm_test(void)
dprintf("vm_test 9: mmaping a known file a few times, one with private mappings\n"); dprintf("vm_test 9: mmaping a known file a few times, one with private mappings\n");
{ {
void *ptr, *ptr2; void *ptr, *ptr2;
region_id rid, rid2; area_id rid, rid2;
int err; int err;
dprintf("vm_test 9: mapping /boot/kernel twice\n"); dprintf("vm_test 9: mapping /boot/kernel twice\n");
@@ -345,8 +348,8 @@ vm_test(void)
dprintf("vm_test 9: removing regions\n"); dprintf("vm_test 9: removing regions\n");
vm_delete_region(vm_get_kernel_aspace_id(), rid); vm_delete_area(vm_get_kernel_aspace_id(), rid);
vm_delete_region(vm_get_kernel_aspace_id(), rid2); vm_delete_area(vm_get_kernel_aspace_id(), rid2);
dprintf("vm_test 9: regions deleted\n"); dprintf("vm_test 9: regions deleted\n");
@@ -384,8 +387,8 @@ vm_test(void)
dprintf("vm_test 10: remove areas\n"); dprintf("vm_test 10: remove areas\n");
vm_delete_region(vm_get_kernel_aspace_id(), a); vm_delete_area(vm_get_kernel_aspace_id(), a);
vm_delete_region(vm_get_kernel_aspace_id(), b); vm_delete_area(vm_get_kernel_aspace_id(), b);
} }
dprintf("vm_test 10: passed\n"); dprintf("vm_test 10: passed\n");
#endif #endif
@@ -414,7 +417,7 @@ vm_test(void)
dprintf("vm_test 11: remove areas\n"); dprintf("vm_test 11: remove areas\n");
vm_delete_region(vm_get_kernel_aspace_id(), a); vm_delete_area(vm_get_kernel_aspace_id(), a);
} }
dprintf("vm_test 11: passed\n"); dprintf("vm_test 11: passed\n");
#endif #endif