Separated vm_address_space.h from vm.h.
Some more cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15614 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+14
-31
@@ -14,6 +14,7 @@
|
||||
#include <arch/vm_translation_map.h>
|
||||
|
||||
struct kernel_args;
|
||||
struct team;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -25,45 +26,33 @@ status_t vm_init(kernel_args *args);
|
||||
status_t vm_init_post_sem(struct kernel_args *args);
|
||||
status_t vm_init_post_thread(struct kernel_args *args);
|
||||
status_t vm_init_post_modules(struct kernel_args *args);
|
||||
status_t vm_address_space_init(void);
|
||||
status_t vm_address_space_init_post_sem(void);
|
||||
void vm_free_kernel_args(kernel_args *args);
|
||||
void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
|
||||
|
||||
void vm_delete_address_space(vm_address_space *aspace);
|
||||
status_t vm_create_address_space(team_id id, addr_t base, addr_t size,
|
||||
bool kernel, vm_address_space **_aspace);
|
||||
status_t vm_delete_areas(struct vm_address_space *aspace);
|
||||
vm_address_space *vm_get_kernel_address_space(void);
|
||||
vm_address_space *vm_kernel_address_space(void);
|
||||
team_id vm_kernel_address_space_id(void);
|
||||
vm_address_space *vm_get_current_user_address_space(void);
|
||||
team_id vm_current_user_address_space_id(void);
|
||||
vm_address_space *vm_get_address_space_by_id(team_id aid);
|
||||
void vm_put_address_space(vm_address_space *aspace);
|
||||
#define vm_swap_address_space(aspace) arch_vm_aspace_swap(aspace)
|
||||
// to protect code regions with interrupts turned on
|
||||
void permit_page_faults(void);
|
||||
void forbid_page_faults(void);
|
||||
|
||||
// private kernel only extension (should be moved somewhere else):
|
||||
struct team;
|
||||
area_id create_area_etc(struct team *team, const char *name, void **address,
|
||||
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection);
|
||||
status_t delete_area_etc(struct team *team, area_id area);
|
||||
|
||||
status_t vm_unreserve_address_range(team_id aid, void *address, addr_t size);
|
||||
status_t vm_reserve_address_range(team_id aid, void **_address,
|
||||
status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
|
||||
status_t vm_reserve_address_range(team_id team, void **_address,
|
||||
uint32 addressSpec, addr_t size, uint32 flags);
|
||||
area_id vm_create_anonymous_area(team_id aid, const char *name, void **address,
|
||||
area_id vm_create_anonymous_area(team_id team, const char *name, void **address,
|
||||
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection);
|
||||
area_id vm_map_physical_memory(team_id aid, const char *name, void **address,
|
||||
area_id vm_map_physical_memory(team_id team, const char *name, void **address,
|
||||
uint32 addressSpec, addr_t size, uint32 protection, addr_t phys_addr);
|
||||
area_id vm_map_file(team_id aid, const char *name, void **address,
|
||||
uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping,
|
||||
const char *path, off_t offset);
|
||||
area_id vm_create_null_area(team_id aid, const char *name, void **address,
|
||||
area_id vm_create_null_area(team_id team, const char *name, void **address,
|
||||
uint32 addressSpec, addr_t size);
|
||||
area_id vm_copy_area(team_id addressSpaceID, const char *name, void **_address,
|
||||
area_id vm_copy_area(team_id team, const char *name, void **_address,
|
||||
uint32 addressSpec, uint32 protection, area_id sourceID);
|
||||
area_id vm_clone_area(team_id aid, const char *name, void **address,
|
||||
area_id vm_clone_area(team_id team, const char *name, void **address,
|
||||
uint32 addressSpec, uint32 protection, uint32 mapping,
|
||||
area_id sourceArea);
|
||||
status_t vm_delete_area(team_id aid, area_id id);
|
||||
@@ -71,10 +60,11 @@ status_t vm_create_vnode_cache(void *vnode, vm_cache_ref **_cacheRef);
|
||||
|
||||
status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
|
||||
|
||||
status_t vm_get_page_mapping(team_id aid, addr_t vaddr, addr_t *paddr);
|
||||
status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, int flags);
|
||||
status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
|
||||
status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, uint32 flags);
|
||||
status_t vm_put_physical_page(addr_t vaddr);
|
||||
|
||||
// user syscalls
|
||||
area_id _user_create_area(const char *name, void **address, uint32 addressSpec,
|
||||
size_t size, uint32 lock, uint32 protection);
|
||||
status_t _user_delete_area(area_id area);
|
||||
@@ -92,13 +82,6 @@ area_id _user_clone_area(const char *name, void **_address, uint32 addressSpec,
|
||||
uint32 protection, area_id sourceArea);
|
||||
status_t _user_init_heap_address_range(addr_t base, addr_t size);
|
||||
|
||||
// to protect code regions with interrupts turned on
|
||||
void permit_page_faults(void);
|
||||
void forbid_page_faults(void);
|
||||
|
||||
// XXX remove later
|
||||
void vm_test(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Axel Dörfler, [email protected]. All rights reserved.
|
||||
* 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_ADDRESS_SPACE_H
|
||||
#define _KERNEL_VM_ADDRESS_SPACE_H
|
||||
|
||||
|
||||
#include <vm_types.h>
|
||||
#include <arch/vm.h>
|
||||
|
||||
struct kernel_args;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
status_t vm_address_space_init(void);
|
||||
status_t vm_address_space_init_post_sem(void);
|
||||
|
||||
void vm_delete_address_space(vm_address_space *aspace);
|
||||
status_t vm_create_address_space(team_id id, addr_t base, addr_t size,
|
||||
bool kernel, vm_address_space **_aspace);
|
||||
status_t vm_delete_areas(struct vm_address_space *aspace);
|
||||
vm_address_space *vm_get_kernel_address_space(void);
|
||||
vm_address_space *vm_kernel_address_space(void);
|
||||
team_id vm_kernel_address_space_id(void);
|
||||
vm_address_space *vm_get_current_user_address_space(void);
|
||||
team_id vm_current_user_address_space_id(void);
|
||||
vm_address_space *vm_get_address_space_by_id(team_id aid);
|
||||
void vm_put_address_space(vm_address_space *aspace);
|
||||
#define vm_swap_address_space(aspace) arch_vm_aspace_swap(aspace)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL_VM_ADDRESS_SPACE_H */
|
||||
@@ -50,8 +50,8 @@ status_t vm_try_reserve_memory(size_t bytes);
|
||||
status_t vm_daemon_init(void);
|
||||
|
||||
// used by the page daemon to walk the list of address spaces
|
||||
int vm_aspace_walk_start(struct hash_iterator *i);
|
||||
vm_address_space *vm_aspace_walk_next(struct hash_iterator *i);
|
||||
void vm_address_space_walk_start(struct hash_iterator *i);
|
||||
vm_address_space *vm_address_space_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);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <Drivers.h>
|
||||
#include <ISA.h>
|
||||
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <console.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <kernel.h>
|
||||
#include <debug.h>
|
||||
#include <int.h>
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <tls.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <vm_page.h>
|
||||
#include <vm_priv.h>
|
||||
#include <smp.h>
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <util/AutoLock.h>
|
||||
#include <vm.h>
|
||||
//#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <vm_page.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <elf.h>
|
||||
#include <vfs.h>
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <thread.h>
|
||||
#include <team.h>
|
||||
#include <debug.h>
|
||||
|
||||
+12
-11
@@ -10,23 +10,24 @@
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <team.h>
|
||||
#include <defines.h>
|
||||
#include <elf.h>
|
||||
#include <file_cache.h>
|
||||
#include <int.h>
|
||||
#include <util/khash.h>
|
||||
#include <port.h>
|
||||
#include <sem.h>
|
||||
#include <user_runtime.h>
|
||||
#include <kernel.h>
|
||||
#include <kimage.h>
|
||||
#include <kscheduler.h>
|
||||
#include <elf.h>
|
||||
#include <syscalls.h>
|
||||
#include <port.h>
|
||||
#include <sem.h>
|
||||
#include <syscall_process_info.h>
|
||||
#include <syscalls.h>
|
||||
#include <team.h>
|
||||
#include <tls.h>
|
||||
#include <defines.h>
|
||||
#include <kernel.h>
|
||||
#include <vm.h>
|
||||
#include <user_runtime.h>
|
||||
#include <vfs.h>
|
||||
#include <file_cache.h>
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <util/khash.h>
|
||||
|
||||
#include <sys/wait.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -10,19 +10,20 @@
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <thread.h>
|
||||
#include <team.h>
|
||||
#include <int.h>
|
||||
#include <smp.h>
|
||||
#include <cpu.h>
|
||||
#include <arch/vm.h>
|
||||
#include <int.h>
|
||||
#include <kimage.h>
|
||||
#include <ksignal.h>
|
||||
#include <kscheduler.h>
|
||||
#include <ksignal.h>
|
||||
#include <smp.h>
|
||||
#include <syscalls.h>
|
||||
#include <team.h>
|
||||
#include <thread.h>
|
||||
#include <tls.h>
|
||||
#include <vfs.h>
|
||||
#include <user_runtime.h>
|
||||
#include <vfs.h>
|
||||
#include <vm_address_space.h>
|
||||
|
||||
#include <boot/kernel_args.h>
|
||||
#include <util/khash.h>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ KernelMergeObject kernel_vm.o :
|
||||
vm_store_anonymous_noswap.c
|
||||
vm_store_device.c
|
||||
vm_store_null.c
|
||||
vm_tests.c
|
||||
#vm_tests.c
|
||||
|
||||
: -fno-pic -Wno-unused
|
||||
;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <vm_priv.h>
|
||||
#include <vm_page.h>
|
||||
#include <vm_cache.h>
|
||||
@@ -2738,7 +2739,7 @@ vm_area_lookup(vm_address_space *addressSpace, addr_t address)
|
||||
|
||||
|
||||
status_t
|
||||
vm_get_physical_page(addr_t paddr, addr_t *_vaddr, int flags)
|
||||
vm_get_physical_page(addr_t paddr, addr_t *_vaddr, uint32 flags)
|
||||
{
|
||||
return (*kernel_aspace->translation_map.ops->get_physical_page)(paddr, _vaddr, flags);
|
||||
}
|
||||
|
||||
@@ -7,36 +7,17 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <OS.h>
|
||||
//#include <OS.h>
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <vm.h>
|
||||
#include <vm_address_space.h>
|
||||
#include <vm_priv.h>
|
||||
#include <vm_page.h>
|
||||
#include <vm_cache.h>
|
||||
#include <vm_store_anonymous_noswap.h>
|
||||
#include <vm_store_device.h>
|
||||
#include <vm_store_null.h>
|
||||
#include <file_cache.h>
|
||||
#include <memheap.h>
|
||||
#include <debug.h>
|
||||
#include <console.h>
|
||||
#include <int.h>
|
||||
#include <smp.h>
|
||||
#include <lock.h>
|
||||
#include <thread.h>
|
||||
#include <team.h>
|
||||
#include <util/khash.h>
|
||||
|
||||
#include <boot/stage2.h>
|
||||
#include <boot/elf.h>
|
||||
|
||||
#include <arch/cpu.h>
|
||||
#include <arch/vm.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
//#define TRACE_VM
|
||||
#ifdef TRACE_VM
|
||||
@@ -328,21 +309,20 @@ vm_create_address_space(team_id id, addr_t base, addr_t size,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
vm_aspace_walk_start(struct hash_iterator *i)
|
||||
void
|
||||
vm_address_space_walk_start(struct hash_iterator *iterator)
|
||||
{
|
||||
hash_open(aspace_table, i);
|
||||
return 0;
|
||||
hash_open(aspace_table, iterator);
|
||||
}
|
||||
|
||||
|
||||
vm_address_space *
|
||||
vm_aspace_walk_next(struct hash_iterator *i)
|
||||
vm_address_space_walk_next(struct hash_iterator *iterator)
|
||||
{
|
||||
vm_address_space *aspace;
|
||||
|
||||
acquire_sem_etc(aspace_hash_sem, READ_COUNT, 0, 0);
|
||||
aspace = hash_next(aspace_table, i);
|
||||
aspace = hash_next(aspace_table, iterator);
|
||||
if (aspace)
|
||||
atomic_add(&aspace->ref_count, 1);
|
||||
release_sem_etc(aspace_hash_sem, READ_COUNT, 0);
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <kernel.h>
|
||||
#include <thread.h>
|
||||
#include <debug.h>
|
||||
#include <OS.h>
|
||||
#include <arch/cpu.h>
|
||||
|
||||
#include <thread.h>
|
||||
#include <vm.h>
|
||||
#include <vm_priv.h>
|
||||
#include <vm_cache.h>
|
||||
#include <vm_page.h>
|
||||
#include <vm_address_space.h>
|
||||
|
||||
|
||||
bool trimming_cycle;
|
||||
@@ -153,8 +152,8 @@ page_daemon(void *unused)
|
||||
snooze(PAGE_DAEMON_INTERVAL);
|
||||
|
||||
// scan through all of the address spaces
|
||||
vm_aspace_walk_start(&i);
|
||||
aspace = vm_aspace_walk_next(&i);
|
||||
vm_address_space_walk_start(&i);
|
||||
aspace = vm_address_space_walk_next(&i);
|
||||
while (aspace) {
|
||||
mapped_size = aspace->translation_map.ops->get_mapped_size(&aspace->translation_map);
|
||||
|
||||
@@ -198,7 +197,7 @@ page_daemon(void *unused)
|
||||
// must hold a ref to the old aspace while we grab the next one,
|
||||
// otherwise the iterator becomes out of date.
|
||||
old_aspace = aspace;
|
||||
aspace = vm_aspace_walk_next(&i);
|
||||
aspace = vm_address_space_walk_next(&i);
|
||||
vm_put_address_space(old_aspace);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
#include <vm.h>
|
||||
#include <debug.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <vm_address_space.h>
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user