* vm.h no longer includes vm_types.h - only those that actually need access

to the private VM types are including vm_types.h now.
* Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's
  cleaner this way, and the actual types are only used in C++ files now,
  anyway.
* And that caused changes in many files...
* Made commpage.h self-containing.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22329 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-09-27 12:21:33 +00:00
parent f98d60ae04
commit e6dc7903e4
28 changed files with 216 additions and 169 deletions
+13 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2005, Axel Dörfler, [email protected].
* Copyright 2002-2007, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -9,9 +9,15 @@
#define KERNEL_ARCH_VM_H
#include <vm.h>
#include <arch_vm.h>
#include <SupportDefs.h>
struct kernel_args;
struct vm_area;
struct vm_address_space;
#ifdef __cplusplus
extern "C" {
@@ -20,12 +26,13 @@ extern "C" {
status_t arch_vm_init(struct kernel_args *args);
status_t arch_vm_init_post_area(struct kernel_args *args);
status_t arch_vm_init_end(struct kernel_args *args);
status_t arch_vm_init_post_modules(kernel_args *args);
void arch_vm_aspace_swap(vm_address_space *aspace);
status_t arch_vm_init_post_modules(struct kernel_args *args);
void arch_vm_aspace_swap(struct vm_address_space *aspace);
bool arch_vm_supports_protection(uint32 protection);
status_t arch_vm_set_memory_type(vm_area *area, addr_t physicalBase, uint32 type);
void arch_vm_unset_memory_type(vm_area *area);
status_t arch_vm_set_memory_type(struct vm_area *area, addr_t physicalBase,
uint32 type);
void arch_vm_unset_memory_type(struct vm_area *area);
#ifdef __cplusplus
}
+7 -3
View File
@@ -5,7 +5,12 @@
#ifndef _KERNEL_ARCH_x86_COMMPAGE_H
#define _KERNEL_ARCH_x86_COMMPAGE_H
/* some systemwide commpage constants, used in the kernel and libroot */
/*! Some systemwide commpage constants, used in the kernel and libroot */
#ifndef _ASSEMBLER
# include <SupportDefs.h>
#endif
/* be careful what you put here, this file is included from assembly */
#define COMMPAGE_ENTRY_MAGIC 0
@@ -23,5 +28,4 @@
status_t commpage_init(void);
#endif
#endif
#endif /* _KERNEL_ARCH_x86_COMMPAGE_H */
+2 -2
View File
@@ -3,8 +3,8 @@
#ifndef _SYSCALL_ARGS_H
#define _SYSCALL_ARGS_H
#include <KernelExport.h>
#include <vm.h>
#include <kernel.h>
//#include <vm.h>
// Hack to be able to use the IS_USER_ADDRESS macro when compiling for R5.
#ifdef R5_MEMORY_LAYOUT
+21 -15
View File
@@ -9,12 +9,17 @@
#define _KERNEL_VM_H
#include <vm_types.h>
#include <arch/vm.h>
#include <arch/vm_translation_map.h>
#include <OS.h>
struct kernel_args;
struct team;
struct vm_page;
struct vm_cache;
struct vm_area;
struct vm_address_space;
struct vnode;
@@ -23,13 +28,13 @@ extern "C" {
#endif
// startup only
status_t vm_init(kernel_args *args);
status_t vm_init(struct 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);
void vm_free_kernel_args(kernel_args *args);
void vm_free_kernel_args(struct kernel_args *args);
void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
addr_t vm_allocate_early(kernel_args *args, size_t virtualSize,
addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize,
size_t physicalSize, uint32 attributes);
@@ -56,8 +61,8 @@ area_id vm_map_physical_memory(team_id team, const char *name, void **address,
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);
vm_cache *vm_area_get_locked_cache(vm_area *area);
void vm_area_put_locked_cache(vm_cache *cache);
struct vm_cache *vm_area_get_locked_cache(struct vm_area *area);
void vm_area_put_locked_cache(struct vm_cache *cache);
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 team, const char *name, void **_address,
@@ -65,16 +70,17 @@ area_id vm_copy_area(team_id team, 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);
status_t vm_create_vnode_cache(struct vnode *vnode, vm_cache **_cache);
vm_area *vm_area_lookup(vm_address_space *addressSpace, addr_t address);
status_t vm_delete_area(team_id teamID, area_id areaID);
status_t vm_create_vnode_cache(struct vnode *vnode, struct vm_cache **_cache);
struct vm_area *vm_area_lookup(struct vm_address_space *addressSpace,
addr_t address);
status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
int32 vm_test_map_activation(vm_page *page, bool *_modified);
void vm_clear_map_activation(vm_page *page);
void vm_remove_all_page_mappings(vm_page *page);
status_t vm_unmap_pages(vm_area *area, addr_t base, size_t length);
status_t vm_map_page(vm_area *area, vm_page *page, addr_t address,
int32 vm_test_map_activation(struct vm_page *page, bool *_modified);
void vm_clear_map_activation(struct vm_page *page);
void vm_remove_all_page_mappings(struct vm_page *page);
status_t vm_unmap_pages(struct vm_area *area, addr_t base, size_t length);
status_t vm_map_page(struct vm_area *area, struct vm_page *page, addr_t address,
uint32 protection);
status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, uint32 flags);
status_t vm_put_physical_page(addr_t vaddr);
+10 -9
View File
@@ -9,10 +9,11 @@
#define _KERNEL_VM_ADDRESS_SPACE_H
#include <vm_types.h>
#include <arch/vm.h>
#include <OS.h>
struct kernel_args;
struct vm_address_space;
#ifdef __cplusplus
@@ -22,17 +23,17 @@ extern "C" {
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);
void vm_delete_address_space(struct 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);
bool kernel, struct 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);
struct vm_address_space *vm_get_kernel_address_space(void);
struct 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);
struct 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);
struct vm_address_space *vm_get_address_space_by_id(team_id aid);
void vm_put_address_space(struct vm_address_space *aspace);
#define vm_swap_address_space(aspace) arch_vm_aspace_swap(aspace)
#ifdef __cplusplus
+20 -14
View File
@@ -12,28 +12,34 @@
#include <kernel.h>
#include <vm.h>
struct kernel_args;
//typedef struct vm_store vm_store;
#ifdef __cplusplus
extern "C" {
#endif
status_t vm_cache_init(struct kernel_args *args);
vm_cache *vm_cache_create(vm_store *store);
void vm_cache_acquire_ref(vm_cache *cache);
void vm_cache_release_ref(vm_cache *cache);
vm_cache *vm_cache_acquire_page_cache_ref(vm_page *page);
vm_page *vm_cache_lookup_page(vm_cache *cache, off_t page);
void vm_cache_insert_page(vm_cache *cache, vm_page *page, off_t offset);
void vm_cache_remove_page(vm_cache *cache, vm_page *page);
void vm_cache_remove_consumer(vm_cache *cache, vm_cache *consumer);
void vm_cache_add_consumer_locked(vm_cache *cache, vm_cache *consumer);
status_t vm_cache_write_modified(vm_cache *cache, bool fsReenter);
status_t vm_cache_set_minimal_commitment_locked(vm_cache *cache, off_t commitment);
status_t vm_cache_resize(vm_cache *cache, off_t newSize);
status_t vm_cache_insert_area_locked(vm_cache *cache, vm_area *area);
status_t vm_cache_remove_area(vm_cache *cache, vm_area *area);
struct vm_cache *vm_cache_create(struct vm_store *store);
void vm_cache_acquire_ref(struct vm_cache *cache);
void vm_cache_release_ref(struct vm_cache *cache);
struct vm_cache *vm_cache_acquire_page_cache_ref(struct vm_page *page);
struct vm_page *vm_cache_lookup_page(struct vm_cache *cache, off_t page);
void vm_cache_insert_page(struct vm_cache *cache, struct vm_page *page,
off_t offset);
void vm_cache_remove_page(struct vm_cache *cache, struct vm_page *page);
void vm_cache_remove_consumer(struct vm_cache *cache, struct vm_cache *consumer);
void vm_cache_add_consumer_locked(struct vm_cache *cache,
struct vm_cache *consumer);
status_t vm_cache_write_modified(struct vm_cache *cache, bool fsReenter);
status_t vm_cache_set_minimal_commitment_locked(struct vm_cache *cache,
off_t commitment);
status_t vm_cache_resize(struct vm_cache *cache, off_t newSize);
status_t vm_cache_insert_area_locked(struct vm_cache *cache, vm_area *area);
status_t vm_cache_remove_area(struct vm_cache *cache, struct vm_area *area);
#ifdef __cplusplus
}
+11 -10
View File
@@ -19,31 +19,32 @@ struct kernel_args;
extern "C" {
#endif
void vm_page_init_num_pages(kernel_args *args);
void vm_page_init_num_pages(struct kernel_args *args);
status_t vm_page_init(struct kernel_args *args);
status_t vm_page_init_post_area(struct kernel_args *args);
status_t vm_page_init_post_thread(struct kernel_args *args);
status_t vm_mark_page_inuse(addr_t page);
status_t vm_mark_page_range_inuse(addr_t startPage, addr_t length);
status_t vm_page_set_state(vm_page *page, int state);
status_t vm_page_set_state(struct vm_page *page, int state);
// get some data about the number of pages in the system
size_t vm_page_num_pages(void);
size_t vm_page_num_free_pages(void);
status_t vm_page_write_modified_page(vm_cache *cache, struct vm_page *page,
bool fsReenter);
status_t vm_page_write_modified_pages(vm_cache *cache, bool fsReenter);
status_t vm_page_write_modified_page(struct vm_cache *cache,
struct vm_page *page, bool fsReenter);
status_t vm_page_write_modified_pages(struct vm_cache *cache, bool fsReenter);
void vm_page_unreserve_pages(uint32 count);
void vm_page_reserve_pages(uint32 count);
vm_page *vm_page_allocate_page(int pageState, bool reserved);
status_t vm_page_allocate_pages(int pageState, vm_page **pages, uint32 numPages);
vm_page *vm_page_allocate_page_run(int state, addr_t length);
vm_page *vm_page_at_index(int32 index);
vm_page *vm_lookup_page(addr_t pageNumber);
struct vm_page *vm_page_allocate_page(int pageState, bool reserved);
status_t vm_page_allocate_pages(int pageState, struct vm_page **pages,
uint32 numPages);
struct vm_page *vm_page_allocate_page_run(int state, addr_t length);
struct vm_page *vm_page_at_index(int32 index);
struct vm_page *vm_lookup_page(addr_t pageNumber);
#ifdef __cplusplus
}
+3 -2
View File
@@ -8,8 +8,9 @@
#ifndef _KERNEL_VM_PRIV_H
#define _KERNEL_VM_PRIV_H
#include <vm.h>
#include <util/khash.h>
#include <vm_types.h>
/* should make these scale with the system */
#define DEFAULT_KERNEL_WORKING_SET 1024
+21 -31
View File
@@ -69,8 +69,7 @@ class DoublyLinkedAreaLink {
typedef class DoublyLinkedQueue<vm_page_mapping, DoublyLinkedPageLink> vm_page_mappings;
typedef class DoublyLinkedQueue<vm_page_mapping, DoublyLinkedAreaLink> vm_area_mappings;
// vm page
typedef struct vm_page {
struct vm_page {
struct vm_page *queue_prev;
struct vm_page *queue_next;
@@ -104,7 +103,7 @@ typedef struct vm_page {
uint16 wired_count;
int8 usage_count;
} vm_page;
};
enum {
PAGE_TYPE_PHYSICAL = 0,
@@ -134,8 +133,7 @@ struct vm_dummy_page : vm_page {
ConditionVariable<vm_page> busy_condition;
};
// vm_cache
typedef struct vm_cache {
struct vm_cache {
mutex lock;
struct vm_area *areas;
vint32 ref_count;
@@ -158,15 +156,14 @@ typedef struct vm_cache {
struct vm_cache* debug_previous;
struct vm_cache* debug_next;
#endif
} vm_cache;
};
#if DEBUG_CACHE_LIST
extern vm_cache* gDebugCacheList;
#endif
// vm area
typedef struct vm_area {
struct vm_area {
char *name;
area_id id;
addr_t base;
@@ -186,24 +183,18 @@ typedef struct vm_area {
struct vm_area *cache_next;
struct vm_area *cache_prev;
struct vm_area *hash_next;
} vm_area;
};
#else // !__cplusplus
// these are just opaque types in C
typedef struct vm_page vm_page;
typedef struct vm_cache vm_cache;
typedef struct vm_area vm_area;
#endif
#endif // __cplusplus
enum {
VM_ASPACE_STATE_NORMAL = 0,
VM_ASPACE_STATE_DELETION
};
// address space
typedef struct vm_address_space {
vm_area *areas;
vm_area *area_hint;
struct vm_address_space {
struct vm_area *areas;
struct vm_area *area_hint;
sem_id sem;
addr_t base;
addr_t size;
@@ -219,26 +210,24 @@ typedef struct vm_address_space {
addr_t min_working_set;
bigtime_t last_working_set_adjust;
struct vm_address_space *hash_next;
} vm_address_space;
};
// vm_store
typedef struct vm_store {
struct vm_store {
struct vm_store_ops *ops;
struct vm_cache *cache;
off_t committed_size;
} vm_store;
};
// vm_store_ops
typedef struct vm_store_ops {
void (*destroy)(struct vm_store *backing_store);
status_t (*commit)(struct vm_store *backing_store, off_t size);
bool (*has_page)(struct vm_store *backing_store, off_t offset);
status_t (*read)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
size_t count, size_t *_numBytes, bool fsReenter);
status_t (*write)(struct vm_store *backing_store, off_t offset, const iovec *vecs,
size_t count, size_t *_numBytes, bool fsReenter);
status_t (*fault)(struct vm_store *backing_store, struct vm_address_space *aspace,
off_t offset);
status_t (*read)(struct vm_store *backing_store, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
status_t (*write)(struct vm_store *backing_store, off_t offset,
const iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter);
status_t (*fault)(struct vm_store *backing_store,
struct vm_address_space *aspace, off_t offset);
void (*acquire_ref)(struct vm_store *backing_store);
void (*release_ref)(struct vm_store *backing_store);
} vm_store_ops;
@@ -291,6 +280,7 @@ enum {
// flags region in the protection field.
#define B_USER_AREA_FLAGS (B_USER_PROTECTION)
#define B_KERNEL_AREA_FLAGS (B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
#define B_KERNEL_AREA_FLAGS \
(B_KERNEL_PROTECTION | B_USER_CLONEABLE_AREA | B_OVERCOMMITTING_AREA)
#endif /* _KERNEL_VM_TYPES_H */