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