2002-07-09 16:24:59 +04:00
|
|
|
/*
|
2008-03-25 14:51:45 +03:00
|
|
|
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
2004-12-14 01:04:26 +03:00
|
|
|
* 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
|
|
|
|
|
2008-05-14 07:55:16 +04:00
|
|
|
#include <OS.h>
|
2003-05-03 20:03:26 +04:00
|
|
|
|
2005-12-21 15:38:31 +03:00
|
|
|
#include <arch/vm.h>
|
2008-05-14 07:55:16 +04:00
|
|
|
#include <vm_defs.h>
|
2007-09-27 16:21:33 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-05-03 20:03:26 +04:00
|
|
|
struct kernel_args;
|
2005-12-20 18:54:45 +03:00
|
|
|
struct team;
|
2007-09-27 16:21:33 +04:00
|
|
|
struct vm_page;
|
2008-07-23 00:36:32 +04:00
|
|
|
struct VMCache;
|
2007-09-27 16:21:33 +04:00
|
|
|
struct vm_area;
|
|
|
|
struct vm_address_space;
|
2007-09-26 04:20:23 +04:00
|
|
|
struct vnode;
|
2003-05-03 20:03:26 +04:00
|
|
|
|
|
|
|
|
2003-06-27 06:27:43 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-02-27 22:26:40 +03:00
|
|
|
// startup only
|
2007-09-27 16:21:33 +04:00
|
|
|
status_t vm_init(struct kernel_args *args);
|
2004-10-20 03:19:10 +04:00
|
|
|
status_t vm_init_post_sem(struct kernel_args *args);
|
|
|
|
status_t vm_init_post_thread(struct kernel_args *args);
|
The short story: we now have MTRR support on Intel and AMD CPUs (the latter
has not yet been tested, though - I'll do this after this commit):
* Removed the arch_memory_type stuff from vm_area; since there are only 8 memory
ranges on x86, it's simply overkill. The MTRR code now remembers the area ID
and finds the MTRR that way (it could also iterate over the existing MTRRs).
* Introduced some post_modules() init functions.
* If the other x86 CPUs out there don't differ a lot, MTRR functionality might
be put back into the kernel.
* x86_write_msr() was broken, it wrote the 64 bit number with the 32 bit words
switched - it took me some time (and lots of #GPs) to figure that one out.
* Removed the macro read_ebp() and introduced a function x86_read_ebp()
(it's not really a time critical call).
* Followed the Intel docs on how to change MTRRs (symmetrically on all CPUs
with caches turned off).
* Asking for memory types will automatically change the requested length to
a power of two - note that BeOS seems to behave in the same, although that's
not really very clean.
* fixed MTRRs are ignored for now - we should make sure at least, though,
that they are identical on all CPUs (or turn them off, even though I'd
prefer the BIOS stuff to be uncacheable, which we don't enforce yet, though).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-13 19:34:29 +03:00
|
|
|
status_t vm_init_post_modules(struct kernel_args *args);
|
2007-09-27 16:21:33 +04:00
|
|
|
void vm_free_kernel_args(struct kernel_args *args);
|
2004-10-20 03:19:10 +04:00
|
|
|
void vm_free_unused_boot_loader_range(addr_t start, addr_t end);
|
2007-09-27 16:21:33 +04:00
|
|
|
addr_t vm_allocate_early(struct kernel_args *args, size_t virtualSize,
|
2007-02-27 22:26:40 +03:00
|
|
|
size_t physicalSize, uint32 attributes);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-04-30 02:58:46 +04:00
|
|
|
void slab_init(struct kernel_args *args, addr_t initialBase,
|
|
|
|
size_t initialSize);
|
2007-04-29 06:23:37 +04:00
|
|
|
void slab_init_post_sem();
|
|
|
|
|
2005-12-20 18:54:45 +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
|
|
|
|
2003-08-19 18:11:58 +04:00
|
|
|
// private kernel only extension (should be moved somewhere else):
|
2008-07-17 02:55:17 +04:00
|
|
|
area_id create_area_etc(team_id team, const char *name, void **address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, uint32 size, uint32 lock, uint32 protection);
|
2003-08-19 18:11:58 +04:00
|
|
|
|
2005-12-20 18:54:45 +03:00
|
|
|
status_t vm_unreserve_address_range(team_id team, void *address, addr_t size);
|
2008-04-02 16:30:06 +04:00
|
|
|
status_t vm_reserve_address_range(team_id team, void **_address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, addr_t size, uint32 flags);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_create_anonymous_area(team_id team, const char *name, void **address,
|
2008-04-14 02:52:11 +04:00
|
|
|
uint32 addressSpec, addr_t size, uint32 wiring, uint32 protection,
|
2008-05-11 20:02:13 +04:00
|
|
|
bool unmapAddressRange, bool kernel);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_map_physical_memory(team_id team, const char *name, void **address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, addr_t size, uint32 protection, addr_t phys_addr);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_map_file(team_id aid, const char *name, void **address,
|
|
|
|
uint32 addressSpec, addr_t size, uint32 protection, uint32 mapping,
|
2008-04-14 02:52:11 +04:00
|
|
|
int fd, off_t offset);
|
2008-07-23 00:36:32 +04:00
|
|
|
struct VMCache *vm_area_get_locked_cache(struct vm_area *area);
|
|
|
|
void vm_area_put_locked_cache(struct VMCache *cache);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_create_null_area(team_id team, const char *name, void **address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, addr_t size);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_copy_area(team_id team, const char *name, void **_address,
|
2005-05-15 19:56:55 +04:00
|
|
|
uint32 addressSpec, uint32 protection, area_id sourceID);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id vm_clone_area(team_id team, const char *name, void **address,
|
|
|
|
uint32 addressSpec, uint32 protection, uint32 mapping,
|
2008-05-11 20:02:13 +04:00
|
|
|
area_id sourceArea, bool kernel);
|
|
|
|
status_t vm_delete_area(team_id teamID, area_id areaID, bool kernel);
|
2008-07-23 00:36:32 +04:00
|
|
|
status_t vm_create_vnode_cache(struct vnode *vnode, struct VMCache **_cache);
|
2007-09-27 16:21:33 +04:00
|
|
|
struct vm_area *vm_area_lookup(struct vm_address_space *addressSpace,
|
|
|
|
addr_t address);
|
2005-12-13 03:06:52 +03:00
|
|
|
status_t vm_set_area_memory_type(area_id id, addr_t physicalBase, uint32 type);
|
2005-12-20 18:54:45 +03:00
|
|
|
status_t vm_get_page_mapping(team_id team, addr_t vaddr, addr_t *paddr);
|
2007-09-28 19:50:26 +04:00
|
|
|
bool vm_test_map_modification(struct vm_page *page);
|
2007-09-27 16:21:33 +04:00
|
|
|
int32 vm_test_map_activation(struct vm_page *page, bool *_modified);
|
2007-09-28 19:50:26 +04:00
|
|
|
void vm_clear_map_flags(struct vm_page *page, uint32 flags);
|
2007-10-04 20:36:35 +04:00
|
|
|
void vm_remove_all_page_mappings(struct vm_page *page, uint32 *_flags);
|
2007-10-09 15:05:50 +04:00
|
|
|
status_t vm_unmap_pages(struct vm_area *area, addr_t base, size_t length,
|
|
|
|
bool preserveModified);
|
2007-09-27 16:21:33 +04:00
|
|
|
status_t vm_map_page(struct vm_area *area, struct vm_page *page, addr_t address,
|
2007-02-28 16:24:53 +03:00
|
|
|
uint32 protection);
|
2005-12-20 18:54:45 +03:00
|
|
|
status_t vm_get_physical_page(addr_t paddr, addr_t *vaddr, uint32 flags);
|
2004-10-20 04:33:06 +04:00
|
|
|
status_t vm_put_physical_page(addr_t vaddr);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-04-02 16:30:06 +04:00
|
|
|
off_t vm_available_memory(void);
|
2008-07-23 00:36:32 +04:00
|
|
|
off_t vm_available_not_needed_memory(void);
|
2008-03-25 14:51:45 +03:00
|
|
|
|
2005-12-20 18:54:45 +03:00
|
|
|
// user syscalls
|
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);
|
2008-04-14 02:52:11 +04:00
|
|
|
area_id _user_map_file(const char *uname, void **uaddress, int addressSpec,
|
|
|
|
addr_t size, int protection, int mapping, int fd, off_t offset);
|
|
|
|
status_t _user_unmap_memory(void *address, addr_t size);
|
2008-05-23 01:51:12 +04:00
|
|
|
status_t _user_sync_memory(void *address, addr_t size, int flags);
|
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);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id _user_transfer_area(area_id area, void **_address, uint32 addressSpec,
|
2005-05-15 19:56:55 +04:00
|
|
|
team_id target);
|
2003-08-20 19:47:52 +04:00
|
|
|
status_t _user_set_area_protection(area_id area, uint32 newProtection);
|
2008-04-02 16:30:06 +04:00
|
|
|
area_id _user_clone_area(const char *name, void **_address, uint32 addressSpec,
|
2003-08-20 19:47:52 +04:00
|
|
|
uint32 protection, area_id sourceArea);
|
2006-03-18 15:52:01 +03:00
|
|
|
status_t _user_reserve_heap_address_range(addr_t* userAddress, uint32 addressSpec,
|
|
|
|
addr_t size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
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 */
|