1/*
2 * Copyright 2002-2009, Axel D��rfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 *
5 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6 * Distributed under the terms of the NewOS License.
7 */
8#ifndef _KERNEL_VM_VM_PAGE_H
9#define _KERNEL_VM_VM_PAGE_H
10
11
12#include <vm/vm.h>
13#include <vm/vm_types.h>
14
15
16struct kernel_args;
17
18extern int32 gMappedPagesCount;
19
20
21struct vm_page_reservation {
22	uint32	count;
23};
24
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30void vm_page_init_num_pages(struct kernel_args *args);
31status_t vm_page_init(struct kernel_args *args);
32status_t vm_page_init_post_area(struct kernel_args *args);
33status_t vm_page_init_post_thread(struct kernel_args *args);
34
35status_t vm_mark_page_inuse(page_num_t page);
36status_t vm_mark_page_range_inuse(page_num_t startPage, page_num_t length);
37void vm_page_free(struct VMCache *cache, struct vm_page *page);
38void vm_page_set_state(struct vm_page *page, int state);
39void vm_page_requeue(struct vm_page *page, bool tail);
40
41// get some data about the number of pages in the system
42page_num_t vm_page_num_pages(void);
43page_num_t vm_page_num_free_pages(void);
44page_num_t vm_page_num_available_pages(void);
45page_num_t vm_page_num_unused_pages(void);
46void vm_page_get_stats(system_info *info);
47phys_addr_t vm_page_max_address();
48
49status_t vm_page_write_modified_page_range(struct VMCache *cache,
50	uint32 firstPage, uint32 endPage);
51status_t vm_page_write_modified_pages(struct VMCache *cache);
52void vm_page_schedule_write_page(struct vm_page *page);
53void vm_page_schedule_write_page_range(struct VMCache *cache,
54	uint32 firstPage, uint32 endPage);
55
56void vm_page_unreserve_pages(vm_page_reservation* reservation);
57void vm_page_reserve_pages(vm_page_reservation* reservation, uint32 count,
58	int priority);
59bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
60	int priority);
61
62struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
63	uint32 flags);
64struct vm_page *vm_page_allocate_page_run(uint32 flags, page_num_t length,
65	const physical_address_restrictions* restrictions, int priority);
66struct vm_page *vm_page_at_index(int32 index);
67struct vm_page *vm_lookup_page(page_num_t pageNumber);
68bool vm_page_is_dummy(struct vm_page *page);
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif	/* _KERNEL_VM_VM_PAGE_H */
75