2002-07-09 16:24:59 +04:00
|
|
|
/*
|
2004-12-14 01:04:26 +03:00
|
|
|
* Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. 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.
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _KERNEL_VM_H
|
|
|
|
#define _KERNEL_VM_H
|
|
|
|
|
2003-05-03 20:03:26 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <kernel.h>
|
|
|
|
#include <vm_types.h>
|
|
|
|
#include <arch/vm_translation_map.h>
|
|
|
|
|
2003-05-03 20:03:26 +04:00
|
|
|
struct kernel_args;
|
|
|
|
|
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
//void vm_dump_areas(vm_address_space *aspace);
|
2004-10-20 03:19:10 +04:00
|
|
|
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);
|
2004-10-07 21:11:54 +04:00
|
|
|
status_t vm_aspace_init(void);
|
|
|
|
status_t vm_aspace_init_post_sem(void);
|
2004-10-23 17:49:19 +04:00
|
|
|
void vm_free_kernel_args(kernel_args *args);
|
2004-10-20 03:19:10 +04:00
|
|
|
void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-10-10 18:55:36 +04:00
|
|
|
void vm_delete_aspace(vm_address_space *aspace);
|
2004-10-20 04:33:06 +04:00
|
|
|
status_t vm_create_aspace(const char *name, addr_t base, addr_t size, bool kernel, vm_address_space **_aspace);
|
2004-10-07 19:08:00 +04:00
|
|
|
status_t vm_delete_areas(struct vm_address_space *aspace);
|
2002-07-09 16:24:59 +04:00
|
|
|
vm_address_space *vm_get_kernel_aspace(void);
|
|
|
|
aspace_id vm_get_kernel_aspace_id(void);
|
|
|
|
vm_address_space *vm_get_current_user_aspace(void);
|
|
|
|
aspace_id vm_get_current_user_aspace_id(void);
|
|
|
|
vm_address_space *vm_get_aspace_by_id(aspace_id aid);
|
|
|
|
void vm_put_aspace(vm_address_space *aspace);
|
|
|
|
#define vm_aspace_swap(aspace) arch_vm_aspace_swap(aspace)
|
|
|
|
|
2003-08-19 18:11:58 +04:00
|
|
|
// private kernel only extension (should be moved somewhere else):
|
|
|
|
struct team;
|
2003-08-20 06:10:14 +04:00
|
|
|
area_id create_area_etc(struct team *team, const char *name, void **address, uint32 addressSpec,
|
2003-08-19 18:11:58 +04:00
|
|
|
uint32 size, uint32 lock, uint32 protection);
|
2003-08-19 21:22:47 +04:00
|
|
|
status_t delete_area_etc(struct team *team, area_id area);
|
2003-08-19 18:11:58 +04:00
|
|
|
|
2004-06-09 06:17:16 +04:00
|
|
|
status_t vm_unreserve_address_range(aspace_id aid, void *address, addr_t size);
|
2004-06-09 05:05:32 +04:00
|
|
|
status_t vm_reserve_address_range(aspace_id aid, void **_address, uint32 addressSpec, addr_t size);
|
2004-11-08 17:16:35 +03:00
|
|
|
area_id vm_create_anonymous_area(aspace_id aid, const char *name, void **address, uint32 addressSpec,
|
|
|
|
addr_t size, uint32 wiring, uint32 protection);
|
|
|
|
area_id vm_map_physical_memory(aspace_id aid, const char *name, void **address, uint32 addressSpec,
|
|
|
|
addr_t size, uint32 protection, addr_t phys_addr);
|
2004-11-08 22:23:29 +03:00
|
|
|
area_id vm_map_file(aspace_id aid, const char *name, void **address, uint32 addressSpec,
|
2004-11-08 17:16:35 +03:00
|
|
|
addr_t size, uint32 protection, uint32 mapping, const char *path, off_t offset);
|
2004-11-08 22:23:29 +03:00
|
|
|
area_id vm_create_null_area(aspace_id aid, const char *name, void **address, uint32 addressSpec, addr_t size);
|
2004-10-09 02:54:42 +04:00
|
|
|
area_id vm_copy_area(aspace_id addressSpaceID, const char *name, void **_address, uint32 addressSpec,
|
|
|
|
uint32 protection, area_id sourceID);
|
2004-11-08 22:23:29 +03:00
|
|
|
area_id vm_clone_area(aspace_id aid, const char *name, void **address, uint32 addressSpec,
|
2004-11-08 17:16:35 +03:00
|
|
|
uint32 protection, uint32 mapping, area_id sourceArea);
|
|
|
|
status_t vm_delete_area(aspace_id aid, area_id id);
|
2004-12-14 01:04:26 +03:00
|
|
|
status_t vm_create_vnode_cache(void *vnode, vm_cache_ref **_cacheRef);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2004-10-20 04:33:06 +04:00
|
|
|
status_t vm_get_page_mapping(aspace_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_put_physical_page(addr_t vaddr);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-08-19 18:11:58 +04:00
|
|
|
area_id _user_create_area(const char *name, void **address, uint32 addressSpec,
|
2003-08-20 19:47:52 +04:00
|
|
|
size_t size, uint32 lock, uint32 protection);
|
2003-08-19 18:11:58 +04:00
|
|
|
status_t _user_delete_area(area_id area);
|
2004-11-08 17:16:35 +03:00
|
|
|
area_id _user_vm_map_file(const char *uname, void **uaddress, int addr_type,
|
2004-10-20 04:33:06 +04:00
|
|
|
addr_t size, int lock, int mapping, const char *upath, off_t offset);
|
2003-08-20 19:47:52 +04:00
|
|
|
area_id _user_area_for(void *address);
|
|
|
|
area_id _user_find_area(const char *name);
|
|
|
|
status_t _user_get_area_info(area_id area, area_info *info);
|
|
|
|
status_t _user_get_next_area_info(team_id team, int32 *cookie, area_info *info);
|
|
|
|
status_t _user_resize_area(area_id area, size_t newSize);
|
|
|
|
status_t _user_set_area_protection(area_id area, uint32 newProtection);
|
|
|
|
area_id _user_clone_area(const char *name, void **_address, uint32 addressSpec,
|
|
|
|
uint32 protection, area_id sourceArea);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-12-03 04:51:39 +03:00
|
|
|
// to protect code regions with interrupts turned on
|
|
|
|
void permit_page_faults(void);
|
|
|
|
void forbid_page_faults(void);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
// XXX remove later
|
|
|
|
void vm_test(void);
|
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#endif /* _KERNEL_VM_H */
|