Removed REGION_WIRING_* and REGION_ADDR_* and replaced them by their
BeOS counterparts. Improved output of dump_region_list(). Cleanup. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7850 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+125
-131
@@ -20,7 +20,6 @@
|
|||||||
#include <vm_store_null.h>
|
#include <vm_store_null.h>
|
||||||
#include <vm_store_vnode.h>
|
#include <vm_store_vnode.h>
|
||||||
#include <memheap.h>
|
#include <memheap.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <int.h>
|
#include <int.h>
|
||||||
@@ -252,7 +251,8 @@ find_and_insert_region_slot(vm_virtual_map *map, addr_t start, addr_t size, addr
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (addr_type) {
|
switch (addr_type) {
|
||||||
case REGION_ADDR_ANY_ADDRESS:
|
case B_ANY_ADDRESS:
|
||||||
|
case B_ANY_KERNEL_ADDRESS:
|
||||||
// find a hole big enough for a new region
|
// find a hole big enough for a new region
|
||||||
if (!last_r) {
|
if (!last_r) {
|
||||||
// see if we can build it at the beginning of the virtual map
|
// see if we can build it at the beginning of the virtual map
|
||||||
@@ -282,7 +282,8 @@ find_and_insert_region_slot(vm_virtual_map *map, addr_t start, addr_t size, addr
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REGION_ADDR_EXACT_ADDRESS:
|
case B_EXACT_ADDRESS:
|
||||||
|
case B_EXACT_KERNEL_ADDRESS:
|
||||||
// see if we can create it exactly here
|
// see if we can create it exactly here
|
||||||
if (!last_r) {
|
if (!last_r) {
|
||||||
if(!next_r || (next_r->base >= start + size)) {
|
if(!next_r || (next_r->base >= start + size)) {
|
||||||
@@ -309,7 +310,9 @@ find_and_insert_region_slot(vm_virtual_map *map, addr_t start, addr_t size, addr
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(foundspot) {
|
if (!foundspot)
|
||||||
|
return ERR_VM_NO_REGION_SLOT;
|
||||||
|
|
||||||
region->size = size;
|
region->size = size;
|
||||||
if (last_r) {
|
if (last_r) {
|
||||||
region->aspace_next = last_r->aspace_next;
|
region->aspace_next = last_r->aspace_next;
|
||||||
@@ -320,16 +323,14 @@ find_and_insert_region_slot(vm_virtual_map *map, addr_t start, addr_t size, addr
|
|||||||
}
|
}
|
||||||
map->change_count++;
|
map->change_count++;
|
||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
} else {
|
|
||||||
return ERR_VM_NO_REGION_SLOT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// a ref to the cache holding this store must be held before entering here
|
// a ref to the cache holding this store must be held before entering here
|
||||||
static int map_backing_store(vm_address_space *aspace, vm_store *store,
|
static int
|
||||||
void **vaddr, off_t offset, addr_t size,
|
map_backing_store(vm_address_space *aspace, vm_store *store, void **vaddr,
|
||||||
int addr_type, int wiring, int lock, int mapping,
|
off_t offset, addr_t size, int addr_type, int wiring, int lock,
|
||||||
vm_region **_region, const char *region_name)
|
int mapping, vm_region **_region, const char *region_name)
|
||||||
{
|
{
|
||||||
vm_cache *cache;
|
vm_cache *cache;
|
||||||
vm_cache_ref *cache_ref;
|
vm_cache_ref *cache_ref;
|
||||||
@@ -345,7 +346,7 @@ static int map_backing_store(vm_address_space *aspace, vm_store *store,
|
|||||||
|
|
||||||
region = _vm_create_region_struct(aspace, region_name, wiring, lock);
|
region = _vm_create_region_struct(aspace, region_name, wiring, lock);
|
||||||
if (!region)
|
if (!region)
|
||||||
return ENOMEM;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
cache = store->cache;
|
cache = store->cache;
|
||||||
cache_ref = cache->ref;
|
cache_ref = cache->ref;
|
||||||
@@ -424,21 +425,24 @@ static int map_backing_store(vm_address_space *aspace, vm_store *store,
|
|||||||
{
|
{
|
||||||
addr_t search_addr, search_end;
|
addr_t search_addr, search_end;
|
||||||
|
|
||||||
if(addr_type == REGION_ADDR_EXACT_ADDRESS) {
|
switch (addr_type) {
|
||||||
|
case B_EXACT_ADDRESS:
|
||||||
|
case B_EXACT_KERNEL_ADDRESS:
|
||||||
search_addr = (addr_t)*vaddr;
|
search_addr = (addr_t)*vaddr;
|
||||||
search_end = (addr_t)*vaddr + size;
|
search_end = (addr_t)*vaddr + size;
|
||||||
} else if(addr_type == REGION_ADDR_ANY_ADDRESS) {
|
break;
|
||||||
|
case B_ANY_ADDRESS:
|
||||||
|
case B_ANY_KERNEL_ADDRESS:
|
||||||
search_addr = aspace->virtual_map.base;
|
search_addr = aspace->virtual_map.base;
|
||||||
search_end = aspace->virtual_map.base + (aspace->virtual_map.size - 1);
|
search_end = aspace->virtual_map.base + (aspace->virtual_map.size - 1);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
err = EINVAL;
|
err = EINVAL;
|
||||||
goto err1b;
|
goto err1b;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = find_and_insert_region_slot(&aspace->virtual_map,
|
err = find_and_insert_region_slot(&aspace->virtual_map, search_addr, size,
|
||||||
search_addr, size,
|
search_end, addr_type, region);
|
||||||
search_end, addr_type,
|
|
||||||
region);
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err1b;
|
goto err1b;
|
||||||
*vaddr = (addr_t *)region->base;
|
*vaddr = (addr_t *)region->base;
|
||||||
@@ -496,14 +500,33 @@ vm_create_anonymous_region(aspace_id aid, const char *name, void **address,
|
|||||||
TRACE(("create_anonymous_region: %s: size 0x%lx\n", name, size));
|
TRACE(("create_anonymous_region: %s: size 0x%lx\n", name, size));
|
||||||
|
|
||||||
/* check parameters */
|
/* check parameters */
|
||||||
if (addr_type != REGION_ADDR_ANY_ADDRESS && addr_type != REGION_ADDR_EXACT_ADDRESS)
|
switch (addr_type) {
|
||||||
|
case B_ANY_ADDRESS:
|
||||||
|
case B_EXACT_ADDRESS:
|
||||||
|
//case B_BASE_ADDRESS:
|
||||||
|
case B_ANY_KERNEL_ADDRESS:
|
||||||
|
case B_ANY_KERNEL_BLOCK_ADDRESS:
|
||||||
|
case B_EXACT_KERNEL_ADDRESS:
|
||||||
|
break;
|
||||||
|
case B_BASE_ADDRESS:
|
||||||
|
dprintf("create_area: B_BASE_ADDRESS demanded (switch to B_ANY_ADDRESS)!\n");
|
||||||
|
addr_type = B_ANY_ADDRESS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
switch (wiring) {
|
switch (wiring) {
|
||||||
case REGION_WIRING_WIRED:
|
case B_NO_LOCK:
|
||||||
case REGION_WIRING_WIRED_ALREADY:
|
case B_FULL_LOCK:
|
||||||
case REGION_WIRING_WIRED_CONTIG:
|
case B_LAZY_LOCK:
|
||||||
case REGION_WIRING_LAZY:
|
case B_CONTIGUOUS:
|
||||||
|
case B_ALREADY_WIRED:
|
||||||
|
break;
|
||||||
|
case B_LOMEM:
|
||||||
|
dprintf("B_LOMEM is not yet supported!\n");
|
||||||
|
wiring = B_FULL_LOCK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
@@ -528,12 +551,14 @@ vm_create_anonymous_region(aspace_id aid, const char *name, void **address,
|
|||||||
cache->temporary = 1;
|
cache->temporary = 1;
|
||||||
|
|
||||||
switch (wiring) {
|
switch (wiring) {
|
||||||
case REGION_WIRING_WIRED:
|
case B_LAZY_LOCK: // for now
|
||||||
case REGION_WIRING_WIRED_ALREADY:
|
case B_FULL_LOCK:
|
||||||
case REGION_WIRING_WIRED_CONTIG:
|
case B_CONTIGUOUS:
|
||||||
|
case B_ALREADY_WIRED:
|
||||||
cache->scan_skip = 1;
|
cache->scan_skip = 1;
|
||||||
break;
|
break;
|
||||||
case REGION_WIRING_LAZY:
|
case B_NO_LOCK:
|
||||||
|
//case B_LAZY_LOCK:
|
||||||
cache->scan_skip = 0;
|
cache->scan_skip = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -552,9 +577,11 @@ vm_create_anonymous_region(aspace_id aid, const char *name, void **address,
|
|||||||
|
|
||||||
cache_ref = store->cache->ref;
|
cache_ref = store->cache->ref;
|
||||||
switch (wiring) {
|
switch (wiring) {
|
||||||
case REGION_WIRING_LAZY:
|
case B_NO_LOCK:
|
||||||
|
case B_LAZY_LOCK:
|
||||||
break; // do nothing
|
break; // do nothing
|
||||||
case REGION_WIRING_WIRED: {
|
case B_FULL_LOCK:
|
||||||
|
{
|
||||||
// pages aren't mapped at this point, but we just simulate a fault on
|
// pages aren't mapped at this point, but we just simulate a fault on
|
||||||
// every page, which should allocate them
|
// every page, which should allocate them
|
||||||
addr_t va;
|
addr_t va;
|
||||||
@@ -565,7 +592,8 @@ vm_create_anonymous_region(aspace_id aid, const char *name, void **address,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REGION_WIRING_WIRED_ALREADY: {
|
case B_ALREADY_WIRED:
|
||||||
|
{
|
||||||
// the pages should already be mapped. This is only really useful during
|
// the pages should already be mapped. This is only really useful during
|
||||||
// boot time. Find the appropriate vm_page objects and stick them in
|
// boot time. Find the appropriate vm_page objects and stick them in
|
||||||
// the cache object.
|
// the cache object.
|
||||||
@@ -598,7 +626,7 @@ vm_create_anonymous_region(aspace_id aid, const char *name, void **address,
|
|||||||
mutex_unlock(&cache_ref->lock);
|
mutex_unlock(&cache_ref->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REGION_WIRING_WIRED_CONTIG: {
|
case B_CONTIGUOUS: {
|
||||||
addr_t va;
|
addr_t va;
|
||||||
addr_t phys_addr;
|
addr_t phys_addr;
|
||||||
int err;
|
int err;
|
||||||
@@ -1092,7 +1120,9 @@ display_mem(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_cache_ref(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_cache_ref(int argc, char **argv)
|
||||||
{
|
{
|
||||||
addr_t address;
|
addr_t address;
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
@@ -1126,7 +1156,9 @@ static int dump_cache_ref(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *page_state_to_text(int state)
|
|
||||||
|
static const char *
|
||||||
|
page_state_to_text(int state)
|
||||||
{
|
{
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case PAGE_STATE_ACTIVE:
|
case PAGE_STATE_ACTIVE:
|
||||||
@@ -1150,7 +1182,9 @@ static const char *page_state_to_text(int state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_cache(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_cache(int argc, char **argv)
|
||||||
{
|
{
|
||||||
addr_t address;
|
addr_t address;
|
||||||
vm_cache *cache;
|
vm_cache *cache;
|
||||||
@@ -1190,7 +1224,9 @@ static int dump_cache(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _dump_region(vm_region *region)
|
|
||||||
|
static void
|
||||||
|
_dump_region(vm_region *region)
|
||||||
{
|
{
|
||||||
dprintf("dump of region at %p:\n", region);
|
dprintf("dump of region at %p:\n", region);
|
||||||
dprintf("name: '%s'\n", region->name);
|
dprintf("name: '%s'\n", region->name);
|
||||||
@@ -1207,7 +1243,9 @@ static void _dump_region(vm_region *region)
|
|||||||
dprintf("cache_prev: %p\n", region->cache_prev);
|
dprintf("cache_prev: %p\n", region->cache_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_region(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_region(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// int i;
|
// int i;
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
@@ -1243,7 +1281,9 @@ static int dump_region(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
region_id find_region_by_address (addr_t vaddress)
|
|
||||||
|
region_id
|
||||||
|
find_region_by_address(addr_t vaddress)
|
||||||
{
|
{
|
||||||
vm_address_space *aspace;
|
vm_address_space *aspace;
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
@@ -1259,7 +1299,9 @@ region_id find_region_by_address (addr_t vaddress)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
region_id find_region_by_name(const char *name)
|
|
||||||
|
region_id
|
||||||
|
find_region_by_name(const char *name)
|
||||||
{
|
{
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
struct hash_iterator iter;
|
struct hash_iterator iter;
|
||||||
@@ -1273,23 +1315,27 @@ region_id find_region_by_name(const char *name)
|
|||||||
return B_NAME_NOT_FOUND;
|
return B_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_region_list(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_region_list(int argc, char **argv)
|
||||||
{
|
{
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
struct hash_iterator iter;
|
struct hash_iterator iter;
|
||||||
|
|
||||||
dprintf("addr\tid\t%32s\tbase\t\tsize\tlock\twiring\n", "name");
|
dprintf("addr\t id base\t\tsize\t\tprotect\tlock\tname\n");
|
||||||
|
|
||||||
hash_open(region_table, &iter);
|
hash_open(region_table, &iter);
|
||||||
while ((region = hash_next(region_table, &iter)) != NULL) {
|
while ((region = hash_next(region_table, &iter)) != NULL) {
|
||||||
dprintf("%p\t0x%lx\t%32s\t0x%lx\t\t0x%lx\t%d\t%d\n",
|
dprintf("%p %5lx %p\t%p\t%d\t%d\t%s\n", region, region->id, (void *)region->base,
|
||||||
region, region->id, region->name, region->base, region->size, region->lock, region->wiring);
|
(void *)region->size, region->lock, region->wiring, region->name);
|
||||||
}
|
}
|
||||||
hash_close(region_table, &iter, false);
|
hash_close(region_table, &iter, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _dump_aspace(vm_address_space *aspace)
|
|
||||||
|
static void
|
||||||
|
_dump_aspace(vm_address_space *aspace)
|
||||||
{
|
{
|
||||||
vm_region *region;
|
vm_region *region;
|
||||||
|
|
||||||
@@ -1315,7 +1361,9 @@ static void _dump_aspace(vm_address_space *aspace)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_aspace(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_aspace(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// int i;
|
// int i;
|
||||||
vm_address_space *aspace;
|
vm_address_space *aspace;
|
||||||
@@ -1351,7 +1399,9 @@ static int dump_aspace(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_aspace_list(int argc, char **argv)
|
|
||||||
|
static int
|
||||||
|
dump_aspace_list(int argc, char **argv)
|
||||||
{
|
{
|
||||||
vm_address_space *as;
|
vm_address_space *as;
|
||||||
struct hash_iterator iter;
|
struct hash_iterator iter;
|
||||||
@@ -1367,7 +1417,9 @@ static int dump_aspace_list(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_address_space *vm_get_kernel_aspace(void)
|
|
||||||
|
vm_address_space *
|
||||||
|
vm_get_kernel_aspace(void)
|
||||||
{
|
{
|
||||||
/* we can treat this one a little differently since it can't be deleted */
|
/* we can treat this one a little differently since it can't be deleted */
|
||||||
acquire_sem_etc(aspace_hash_sem, READ_COUNT, 0, 0);
|
acquire_sem_etc(aspace_hash_sem, READ_COUNT, 0, 0);
|
||||||
@@ -1376,27 +1428,35 @@ vm_address_space *vm_get_kernel_aspace(void)
|
|||||||
return kernel_aspace;
|
return kernel_aspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
aspace_id vm_get_kernel_aspace_id(void)
|
|
||||||
|
aspace_id
|
||||||
|
vm_get_kernel_aspace_id(void)
|
||||||
{
|
{
|
||||||
return kernel_aspace->id;
|
return kernel_aspace->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_address_space *vm_get_current_user_aspace(void)
|
|
||||||
|
vm_address_space *
|
||||||
|
vm_get_current_user_aspace(void)
|
||||||
{
|
{
|
||||||
return vm_get_aspace_by_id(vm_get_current_user_aspace_id());
|
return vm_get_aspace_by_id(vm_get_current_user_aspace_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
aspace_id vm_get_current_user_aspace_id(void)
|
|
||||||
|
aspace_id
|
||||||
|
vm_get_current_user_aspace_id(void)
|
||||||
{
|
{
|
||||||
struct thread *t = thread_get_current_thread();
|
struct thread *t = thread_get_current_thread();
|
||||||
|
|
||||||
if (t)
|
if (t)
|
||||||
return t->team->_aspace_id;
|
return t->team->_aspace_id;
|
||||||
else
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void vm_put_aspace(vm_address_space *aspace)
|
|
||||||
|
void
|
||||||
|
vm_put_aspace(vm_address_space *aspace)
|
||||||
{
|
{
|
||||||
// vm_region *region;
|
// vm_region *region;
|
||||||
bool removeit = false;
|
bool removeit = false;
|
||||||
@@ -1428,7 +1488,9 @@ void vm_put_aspace(vm_address_space *aspace)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aspace_id vm_create_aspace(const char *name, addr_t base, addr_t size, bool kernel)
|
|
||||||
|
aspace_id
|
||||||
|
vm_create_aspace(const char *name, addr_t base, addr_t size, bool kernel)
|
||||||
{
|
{
|
||||||
vm_address_space *aspace;
|
vm_address_space *aspace;
|
||||||
int err;
|
int err;
|
||||||
@@ -1530,6 +1592,7 @@ vm_delete_aspace(aspace_id aid)
|
|||||||
int
|
int
|
||||||
vm_resize_region(aspace_id aid, region_id rid, size_t newSize)
|
vm_resize_region(aspace_id aid, region_id rid, size_t newSize)
|
||||||
{
|
{
|
||||||
|
// ToDo: this is broken!
|
||||||
vm_cache_ref *myCacheRef;
|
vm_cache_ref *myCacheRef;
|
||||||
vm_region *myRegion,*current;
|
vm_region *myRegion,*current;
|
||||||
size_t oldSize;
|
size_t oldSize;
|
||||||
@@ -1628,13 +1691,13 @@ create_preloaded_image_areas(struct preloaded_image *image)
|
|||||||
memcpy(name, fileName, length);
|
memcpy(name, fileName, length);
|
||||||
strcpy(name + length, "_text");
|
strcpy(name + length, "_text");
|
||||||
address = (void *)ROUNDOWN(image->text_region.start, PAGE_SIZE);
|
address = (void *)ROUNDOWN(image->text_region.start, PAGE_SIZE);
|
||||||
image->text_region.id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, REGION_ADDR_EXACT_ADDRESS,
|
image->text_region.id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, B_EXACT_KERNEL_ADDRESS,
|
||||||
PAGE_ALIGN(image->text_region.size), REGION_WIRING_WIRED_ALREADY, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
PAGE_ALIGN(image->text_region.size), B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
|
||||||
strcpy(name + length, "_data");
|
strcpy(name + length, "_data");
|
||||||
address = (void *)ROUNDOWN(image->data_region.start, PAGE_SIZE);
|
address = (void *)ROUNDOWN(image->data_region.start, PAGE_SIZE);
|
||||||
image->data_region.id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, REGION_ADDR_EXACT_ADDRESS,
|
image->data_region.id = vm_create_anonymous_region(vm_get_kernel_aspace_id(), name, &address, B_EXACT_KERNEL_ADDRESS,
|
||||||
PAGE_ALIGN(image->data_region.size), REGION_WIRING_WIRED_ALREADY, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
PAGE_ALIGN(image->data_region.size), B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1706,8 +1769,8 @@ vm_init(kernel_args *ka)
|
|||||||
// allocate regions to represent stuff that already exists
|
// allocate regions to represent stuff that already exists
|
||||||
|
|
||||||
address = (void *)ROUNDOWN(heap_base, PAGE_SIZE);
|
address = (void *)ROUNDOWN(heap_base, PAGE_SIZE);
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_heap", &address, REGION_ADDR_EXACT_ADDRESS,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), "kernel_heap", &address, B_EXACT_KERNEL_ADDRESS,
|
||||||
HEAP_SIZE, REGION_WIRING_WIRED_ALREADY, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
HEAP_SIZE, B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
|
|
||||||
ka->kernel_image.name = "kernel";
|
ka->kernel_image.name = "kernel";
|
||||||
// the lazy boot loader currently doesn't set the kernel's name...
|
// the lazy boot loader currently doesn't set the kernel's name...
|
||||||
@@ -1724,12 +1787,12 @@ vm_init(kernel_args *ka)
|
|||||||
|
|
||||||
sprintf(temp, "idle_thread%d_kstack", i);
|
sprintf(temp, "idle_thread%d_kstack", i);
|
||||||
address = (void *)ka->cpu_kstack[i].start;
|
address = (void *)ka->cpu_kstack[i].start;
|
||||||
vm_create_anonymous_region(vm_get_kernel_aspace_id(), temp, &address, REGION_ADDR_EXACT_ADDRESS,
|
vm_create_anonymous_region(vm_get_kernel_aspace_id(), temp, &address, B_EXACT_KERNEL_ADDRESS,
|
||||||
ka->cpu_kstack[i].size, REGION_WIRING_WIRED_ALREADY, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
ka->cpu_kstack[i].size, B_ALREADY_WIRED, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
void *null;
|
void *null;
|
||||||
vm_map_physical_memory(vm_get_kernel_aspace_id(), "bootdir", &null, REGION_ADDR_ANY_ADDRESS,
|
vm_map_physical_memory(vm_get_kernel_aspace_id(), "bootdir", &null, B_ANY_KERNEL_ADDRESS,
|
||||||
ka->bootdir_addr.size, B_KERNEL_READ_AREA, ka->bootdir_addr.start);
|
ka->bootdir_addr.size, B_KERNEL_READ_AREA, ka->bootdir_addr.start);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2387,65 +2450,10 @@ resize_area(area_id area, size_t newSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
|
||||||
convertAddressSpec(uint32 *_spec)
|
|
||||||
{
|
|
||||||
switch (*_spec) {
|
|
||||||
case B_ANY_KERNEL_ADDRESS:
|
|
||||||
case B_ANY_ADDRESS:
|
|
||||||
*_spec = REGION_ADDR_ANY_ADDRESS;
|
|
||||||
break;
|
|
||||||
case B_EXACT_KERNEL_ADDRESS:
|
|
||||||
case B_EXACT_ADDRESS:
|
|
||||||
*_spec = REGION_ADDR_EXACT_ADDRESS;
|
|
||||||
break;
|
|
||||||
case B_BASE_ADDRESS:
|
|
||||||
dprintf("create_area: B_BASE_ADDRESS demanded (switch to B_ANY_ADDRESS)!\n");
|
|
||||||
*_spec = REGION_ADDR_ANY_ADDRESS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
dprintf("create_area: invalid address spec!\n");
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
|
||||||
convertLockToWiring(uint32 *_lock)
|
|
||||||
{
|
|
||||||
switch (*_lock) {
|
|
||||||
case B_ALREADY_WIRED:
|
|
||||||
*_lock = REGION_WIRING_WIRED_ALREADY;
|
|
||||||
break;
|
|
||||||
case B_LOMEM:
|
|
||||||
dprintf("create_area: asked for B_LOMEM - unsupported (switch to B_FULL_LOCK)!\n");
|
|
||||||
case B_FULL_LOCK:
|
|
||||||
case B_LAZY_LOCK: // ToDo: lazy lock is not supported by the VM yet
|
|
||||||
*_lock = REGION_WIRING_WIRED;
|
|
||||||
break;
|
|
||||||
case B_CONTIGUOUS:
|
|
||||||
*_lock = REGION_WIRING_WIRED_CONTIG;
|
|
||||||
break;
|
|
||||||
case B_NO_LOCK:
|
|
||||||
*_lock = REGION_WIRING_WIRED_CONTIG;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dprintf("create_area: invalid locking mode!\n");
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
area_id
|
area_id
|
||||||
map_physical_memory(const char *name, void *physicalAddress, size_t numBytes,
|
map_physical_memory(const char *name, void *physicalAddress, size_t numBytes,
|
||||||
uint32 addressSpec, uint32 protection, void **_virtualAddress)
|
uint32 addressSpec, uint32 protection, void **_virtualAddress)
|
||||||
{
|
{
|
||||||
if (convertAddressSpec(&addressSpec) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
if ((protection & B_KERNEL_PROTECTION) == 0)
|
if ((protection & B_KERNEL_PROTECTION) == 0)
|
||||||
protection |= B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
|
protection |= B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
|
||||||
|
|
||||||
@@ -2466,13 +2474,6 @@ area_id
|
|||||||
create_area_etc(struct team *team, const char *name, void **address, uint32 addressSpec,
|
create_area_etc(struct team *team, const char *name, void **address, uint32 addressSpec,
|
||||||
uint32 size, uint32 lock, uint32 protection)
|
uint32 size, uint32 lock, uint32 protection)
|
||||||
{
|
{
|
||||||
if (convertAddressSpec(&addressSpec) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
// create_area() "lock" is vm_create_anonymous_region() "wiring"
|
|
||||||
if (convertLockToWiring(&lock) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
return vm_create_anonymous_region(team->_aspace_id, (char *)name, address,
|
return vm_create_anonymous_region(team->_aspace_id, (char *)name, address,
|
||||||
addressSpec, size, lock, protection);
|
addressSpec, size, lock, protection);
|
||||||
}
|
}
|
||||||
@@ -2498,13 +2499,6 @@ create_area(const char *name, void **address, uint32 addressSpec, size_t size, u
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertAddressSpec(&addressSpec) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
// create_area() "lock" is vm_create_anonymous_region() "wiring"
|
|
||||||
if (convertLockToWiring(&lock) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
return vm_create_anonymous_region(areaSpace, (char *)name, address,
|
return vm_create_anonymous_region(areaSpace, (char *)name, address,
|
||||||
addressSpec, size, lock, protection);
|
addressSpec, size, lock, protection);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user