Renamed vm.c to vm.cpp and made all the changes to let it compile without
errors. Also made the VM headers C++ safe. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12694 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8f8d46a3ff
commit
62d6961672
@ -38,6 +38,11 @@
|
||||
#define PAGE_ACCESSED 0x2000
|
||||
#define PAGE_PRESENT 0x4000
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Should only be used by vm internals
|
||||
status_t vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite, bool isUser, addr_t *newip);
|
||||
void vm_unreserve_memory(size_t bytes);
|
||||
@ -51,5 +56,9 @@ vm_address_space *vm_aspace_walk_next(struct hash_iterator *i);
|
||||
// allocates memory from the kernel_args structure
|
||||
addr_t vm_alloc_from_kernel_args(kernel_args *args, size_t size, uint32 lock);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL_VM_PRIV_H */
|
||||
|
||||
|
@ -1,13 +1,20 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_VM_STORE_DEVICE_H
|
||||
#define _KERNEL_VM_STORE_DEVICE_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <vm.h>
|
||||
|
||||
#include <vm_types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
vm_store *vm_store_create_device(addr_t base_addr);
|
||||
|
||||
#endif
|
||||
#endif /* _KERNEL_VM_STORE_DEVICE_H */
|
||||
|
@ -1,14 +1,20 @@
|
||||
/*
|
||||
** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
** Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
* Copyright 2005, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
#ifndef _KERNEL_VM_STORE_NULL_H
|
||||
#define _KERNEL_VM_STORE_NULL_H
|
||||
|
||||
#include <kernel.h>
|
||||
#include <vm.h>
|
||||
|
||||
#include <vm_types.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
vm_store *vm_store_create_null(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL_VM_STORE_NULL_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
SubDir OBOS_TOP src system kernel vm ;
|
||||
|
||||
KernelMergeObject kernel_vm.o :
|
||||
vm.c
|
||||
vm.cpp
|
||||
vm_address_space.c
|
||||
vm_cache.c
|
||||
vm_daemons.c
|
||||
|
@ -58,7 +58,7 @@ extern vm_address_space *kernel_aspace;
|
||||
|
||||
#define REGION_HASH_TABLE_SIZE 1024
|
||||
static area_id sNextAreaID;
|
||||
static void *sAreaHash;
|
||||
static hash_table *sAreaHash;
|
||||
static sem_id sAreaHashLock;
|
||||
|
||||
static off_t sAvailableMemory;
|
||||
@ -74,12 +74,12 @@ static bool vm_put_area(vm_area *area);
|
||||
|
||||
|
||||
static int
|
||||
area_compare(void *_r, const void *key)
|
||||
area_compare(void *_area, const void *key)
|
||||
{
|
||||
vm_area *r = _r;
|
||||
const area_id *id = key;
|
||||
vm_area *area = (vm_area *)_area;
|
||||
const area_id *id = (const area_id *)key;
|
||||
|
||||
if (r->id == *id)
|
||||
if (area->id == *id)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
@ -87,13 +87,13 @@ area_compare(void *_r, const void *key)
|
||||
|
||||
|
||||
static uint32
|
||||
area_hash(void *_r, const void *key, uint32 range)
|
||||
area_hash(void *_area, const void *key, uint32 range)
|
||||
{
|
||||
vm_area *r = _r;
|
||||
const area_id *id = key;
|
||||
vm_area *area = (vm_area *)_area;
|
||||
const area_id *id = (const area_id *)key;
|
||||
|
||||
if (r != NULL)
|
||||
return r->id % range;
|
||||
if (area != NULL)
|
||||
return area->id % range;
|
||||
|
||||
return *id % range;
|
||||
}
|
||||
@ -106,8 +106,8 @@ vm_get_area(area_id id)
|
||||
|
||||
acquire_sem_etc(sAreaHashLock, READ_COUNT, 0, 0);
|
||||
|
||||
area = hash_lookup(sAreaHash, &id);
|
||||
if (area)
|
||||
area = (vm_area *)hash_lookup(sAreaHash, &id);
|
||||
if (area != NULL)
|
||||
atomic_add(&area->ref_count, 1);
|
||||
|
||||
release_sem_etc(sAreaHashLock, READ_COUNT, 0);
|
||||
@ -119,7 +119,7 @@ vm_get_area(area_id id)
|
||||
static vm_area *
|
||||
_vm_create_reserved_region_struct(vm_virtual_map *map, uint32 flags)
|
||||
{
|
||||
vm_area *reserved = malloc(sizeof(vm_area));
|
||||
vm_area *reserved = (vm_area *)malloc(sizeof(vm_area));
|
||||
if (reserved == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -652,7 +652,8 @@ out:
|
||||
|
||||
|
||||
status_t
|
||||
vm_reserve_address_range(aspace_id aid, void **_address, uint32 addressSpec, addr_t size, uint32 flags)
|
||||
vm_reserve_address_range(aspace_id aid, void **_address, uint32 addressSpec,
|
||||
addr_t size, uint32 flags)
|
||||
{
|
||||
vm_address_space *addressSpace;
|
||||
vm_area *area;
|
||||
@ -1633,7 +1634,7 @@ display_mem(int argc, char **argv)
|
||||
}
|
||||
|
||||
dprintf("[0x%lx] '", address);
|
||||
for (j = 0; j < min(display_width, num) * item_size; j++) {
|
||||
for (j = 0; j < min_c(display_width, num) * item_size; j++) {
|
||||
char c = *((char *)address + j);
|
||||
if (!isalnum(c)) {
|
||||
c = '.';
|
||||
@ -1644,7 +1645,7 @@ display_mem(int argc, char **argv)
|
||||
for (i = 0; i < num; i++) {
|
||||
if ((i % display_width) == 0 && i != 0) {
|
||||
dprintf("\n[0x%lx] '", address + i * item_size);
|
||||
for (j = 0; j < min(display_width, (num-i)) * item_size; j++) {
|
||||
for (j = 0; j < min_c(display_width, (num-i)) * item_size; j++) {
|
||||
char c = *((char *)address + i * item_size + j);
|
||||
if (!isalnum(c)) {
|
||||
c = '.';
|
||||
@ -1760,18 +1761,20 @@ dump_cache(int argc, char **argv)
|
||||
dprintf("store: %p\n", cache->store);
|
||||
// XXX 64-bit
|
||||
dprintf("virtual_size: 0x%Lx\n", cache->virtual_size);
|
||||
dprintf("temporary: %d\n", cache->temporary);
|
||||
dprintf("scan_skip: %d\n", cache->scan_skip);
|
||||
dprintf("temporary: %ld\n", cache->temporary);
|
||||
dprintf("scan_skip: %ld\n", cache->scan_skip);
|
||||
dprintf("page_list:\n");
|
||||
for(page = cache->page_list; page != NULL; page = page->cache_next) {
|
||||
for (page = cache->page_list; page != NULL; page = page->cache_next) {
|
||||
// XXX offset is 64-bit
|
||||
if(page->type == PAGE_TYPE_PHYSICAL)
|
||||
dprintf(" %p ppn 0x%lx offset 0x%Lx type %d state %d (%s) ref_count %ld\n",
|
||||
page, page->ppn, page->offset, page->type, page->state, page_state_to_text(page->state), page->ref_count);
|
||||
else if(page->type == PAGE_TYPE_DUMMY)
|
||||
dprintf(" %p DUMMY PAGE state %d (%s)\n", page, page->state, page_state_to_text(page->state));
|
||||
else
|
||||
dprintf(" %p UNKNOWN PAGE type %d\n", page, page->type);
|
||||
if (page->type == PAGE_TYPE_PHYSICAL) {
|
||||
dprintf(" %p ppn 0x%lx offset 0x%Lx type %ld state %ld (%s) ref_count %ld\n",
|
||||
page, page->ppn, page->offset, page->type, page->state,
|
||||
page_state_to_text(page->state), page->ref_count);
|
||||
} else if(page->type == PAGE_TYPE_DUMMY) {
|
||||
dprintf(" %p DUMMY PAGE state %ld (%s)\n",
|
||||
page, page->state, page_state_to_text(page->state));
|
||||
} else
|
||||
dprintf(" %p UNKNOWN PAGE type %ld\n", page, page->type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -1809,10 +1812,10 @@ dump_area(int argc, char **argv)
|
||||
|
||||
// if the argument looks like a hex number, treat it as such
|
||||
if (strlen(argv[1]) > 2 && argv[1][0] == '0' && argv[1][1] == 'x') {
|
||||
unsigned long num = strtoul(argv[1], NULL, 16);
|
||||
uint32 num = strtoul(argv[1], NULL, 16);
|
||||
area_id id = num;
|
||||
|
||||
area = hash_lookup(sAreaHash, &id);
|
||||
area = (vm_area *)hash_lookup(sAreaHash, &id);
|
||||
if (area == NULL) {
|
||||
dprintf("invalid area id\n");
|
||||
} else {
|
||||
@ -1824,7 +1827,7 @@ dump_area(int argc, char **argv)
|
||||
struct hash_iterator iter;
|
||||
|
||||
hash_open(sAreaHash, &iter);
|
||||
while ((area = hash_next(sAreaHash, &iter)) != NULL) {
|
||||
while ((area = (vm_area *)hash_next(sAreaHash, &iter)) != NULL) {
|
||||
if (area->name != NULL && strcmp(argv[1], area->name) == 0) {
|
||||
_dump_area(area);
|
||||
}
|
||||
@ -1843,7 +1846,7 @@ dump_area_list(int argc, char **argv)
|
||||
dprintf("addr\t id base\t\tsize\t\tprotect\tlock\tname\n");
|
||||
|
||||
hash_open(sAreaHash, &iter);
|
||||
while ((area = hash_next(sAreaHash, &iter)) != NULL) {
|
||||
while ((area = (vm_area *)hash_next(sAreaHash, &iter)) != NULL) {
|
||||
dprintf("%p %5lx %p\t%p\t%ld\t%ld\t%s\n", area, area->id, (void *)area->base,
|
||||
(void *)area->size, area->protection, area->wiring, area->name);
|
||||
}
|
||||
@ -2863,7 +2866,7 @@ get_memory_map(const void *address, ulong numBytes, physical_entry *table, long
|
||||
(*addressSpace->translation_map.ops->lock)(&addressSpace->translation_map);
|
||||
|
||||
while (offset < numBytes) {
|
||||
addr_t bytes = min(numBytes - offset, B_PAGE_SIZE);
|
||||
addr_t bytes = min_c(numBytes - offset, B_PAGE_SIZE);
|
||||
|
||||
status = (*addressSpace->translation_map.ops->query)(&addressSpace->translation_map,
|
||||
(addr_t)address + offset, &physicalAddress, &flags);
|
||||
@ -2929,7 +2932,7 @@ find_area(const char *name)
|
||||
acquire_sem_etc(sAreaHashLock, READ_COUNT, 0, 0);
|
||||
hash_open(sAreaHash, &iterator);
|
||||
|
||||
while ((area = hash_next(sAreaHash, &iterator)) != NULL) {
|
||||
while ((area = (vm_area *)hash_next(sAreaHash, &iterator)) != NULL) {
|
||||
if (area->id == RESERVED_AREA_ID)
|
||||
continue;
|
||||
|
||||
@ -3321,7 +3324,7 @@ delete_area(area_id area)
|
||||
status_t
|
||||
_user_init_heap_address_range(addr_t base, addr_t size)
|
||||
{
|
||||
return vm_reserve_address_range(vm_get_current_user_aspace_id(), (void *)&base,
|
||||
return vm_reserve_address_range(vm_get_current_user_aspace_id(), (void **)&base,
|
||||
B_EXACT_ADDRESS, size, RESERVED_AVOID_BASE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user