btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / kernel / vm / vm_page.h
blob5b98398e5146f3119af8c6c2b6656c51323a869e
1 /*
2 * Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
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
12 #include <vm/vm.h>
13 #include <vm/vm_types.h>
16 struct kernel_args;
18 extern int32 gMappedPagesCount;
21 struct vm_page_reservation {
22 uint32 count;
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
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);
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);
40 void vm_page_set_state(struct vm_page *page, int state);
41 void vm_page_requeue(struct vm_page *page, bool tail);
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();
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);
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);
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);
72 #ifdef __cplusplus
74 #endif
77 static inline void
78 vm_page_free(struct VMCache *cache, struct vm_page *page)
80 vm_page_free_etc(cache, page, NULL);
84 #endif /* _KERNEL_VM_VM_PAGE_H */