xref: /haiku/headers/private/kernel/vm/vm_page.h (revision 0de25abadc86e260328c6f7c4255acbee8f70d4e)
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_etc(VMCache* cache, vm_page* page,
38 	vm_page_reservation* reservation);
39 
40 void vm_page_set_state(struct vm_page *page, int state);
41 void vm_page_requeue(struct vm_page *page, bool tail);
42 
43 // get some data about the number of pages in the system
44 page_num_t vm_page_num_pages(void);
45 page_num_t vm_page_num_free_pages(void);
46 page_num_t vm_page_num_available_pages(void);
47 page_num_t vm_page_num_unused_pages(void);
48 void vm_page_get_stats(system_info *info);
49 phys_addr_t vm_page_max_address();
50 
51 status_t vm_page_write_modified_page_range(struct VMCache *cache,
52 	uint32 firstPage, uint32 endPage);
53 status_t vm_page_write_modified_pages(struct VMCache *cache);
54 void vm_page_schedule_write_page(struct vm_page *page);
55 void vm_page_schedule_write_page_range(struct VMCache *cache,
56 	uint32 firstPage, uint32 endPage);
57 
58 void vm_page_unreserve_pages(vm_page_reservation* reservation);
59 void vm_page_reserve_pages(vm_page_reservation* reservation, uint32 count,
60 	int priority);
61 bool vm_page_try_reserve_pages(vm_page_reservation* reservation, uint32 count,
62 	int priority);
63 
64 struct vm_page *vm_page_allocate_page(vm_page_reservation* reservation,
65 	uint32 flags);
66 struct vm_page *vm_page_allocate_page_run(uint32 flags, page_num_t length,
67 	const physical_address_restrictions* restrictions, int priority);
68 struct vm_page *vm_page_at_index(int32 index);
69 struct vm_page *vm_lookup_page(page_num_t pageNumber);
70 bool vm_page_is_dummy(struct vm_page *page);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 
77 static inline void
78 vm_page_free(struct VMCache *cache, struct vm_page *page)
79 {
80 	vm_page_free_etc(cache, page, NULL);
81 }
82 
83 
84 #endif	/* _KERNEL_VM_VM_PAGE_H */
85