xref: /haiku/headers/private/kernel/vm/vm_page.h (revision 1345706a9ff6ad0dc041339a02d4259998b0765d)
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 
16 struct kernel_args;
17 
18 extern int32 gMappedPagesCount;
19 
20 
21 struct vm_page_reservation {
22 	uint32	count;
23 };
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 void vm_page_init_num_pages(struct kernel_args *args);
31 status_t vm_page_init(struct kernel_args *args);
32 status_t vm_page_init_post_area(struct kernel_args *args);
33 status_t vm_page_init_post_thread(struct kernel_args *args);
34 
35 status_t vm_mark_page_inuse(page_num_t page);
36 status_t vm_mark_page_range_inuse(page_num_t startPage, page_num_t length);
37 void vm_page_free(struct VMCache *cache, struct vm_page *page);
38 void vm_page_set_state(struct vm_page *page, int state);
39 void vm_page_requeue(struct vm_page *page, bool tail);
40 
41 // get some data about the number of pages in the system
42 page_num_t vm_page_num_pages(void);
43 page_num_t vm_page_num_free_pages(void);
44 page_num_t vm_page_num_available_pages(void);
45 page_num_t vm_page_num_unused_pages(void);
46 void vm_page_get_stats(system_info *info);
47 phys_addr_t vm_page_max_address();
48 
49 status_t vm_page_write_modified_page_range(struct VMCache *cache,
50 	uint32 firstPage, uint32 endPage);
51 status_t vm_page_write_modified_pages(struct VMCache *cache);
52 void vm_page_schedule_write_page(struct vm_page *page);
53 void vm_page_schedule_write_page_range(struct VMCache *cache,
54 	uint32 firstPage, uint32 endPage);
55 
56 void vm_page_unreserve_pages(vm_page_reservation* reservation);
57 void vm_page_reserve_pages(vm_page_reservation* reservation, uint32 count,
58 	int priority);
59 bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
60 	int priority);
61 
62 struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
63 	uint32 flags);
64 struct vm_page *vm_page_allocate_page_run(uint32 flags, page_num_t length,
65 	const physical_address_restrictions* restrictions, int priority);
66 struct vm_page *vm_page_at_index(int32 index);
67 struct vm_page *vm_lookup_page(page_num_t pageNumber);
68 bool vm_page_is_dummy(struct vm_page *page);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif	/* _KERNEL_VM_VM_PAGE_H */
75