root/headers/private/kernel/vm/vm_priv.h
/*
 * Copyright 2002-2008, Haiku. All rights reserved.
 * Distributed under the terms of the MIT License.
 *
 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
 * Distributed under the terms of the NewOS License.
 */
#ifndef _KERNEL_VM_VM_PRIV_H
#define _KERNEL_VM_VM_PRIV_H


#include <vm/vm_types.h>


// reserved area definitions
#define RESERVED_AREA_ID -1
#define RESERVED_AVOID_BASE 0x01

// page attributes (in addition to B_READ_AREA etc.)
#define PAGE_MODIFIED 0x1000
#define PAGE_ACCESSED 0x2000
#define PAGE_PRESENT  0x4000


#ifdef __cplusplus

class VMAddressSpace;

// should only be used by VM internals

status_t vm_page_fault(addr_t address, addr_t faultAddress, bool isWrite,
        bool isExecute, bool isUser, addr_t *newip);
status_t vm_soft_fault(VMAddressSpace* addressSpace, addr_t address,
        bool isWrite, bool isExecute, bool isUser, vm_page** wirePage);

status_t vm_map_cache(VMAddressSpace* addressSpace,
        VMCache* cache, off_t offset, const char* areaName, addr_t size, int wiring,
        int protection, int protectionMax, int mapping, uint32 flags,
        const virtual_address_restrictions* addressRestrictions, bool kernel,
        VMArea** _area, void** _virtualAddress);

status_t vm_unmap_address_range(VMAddressSpace* addressSpace,
        addr_t address, addr_t size, bool kernel);

void vm_unreserve_memory(uint64 bytes);
status_t vm_try_reserve_memory(uint64 bytes, int priority, bigtime_t timeout);

void vm_unreserve_memory_or_swap(uint64 bytes);
status_t vm_try_reserve_memory_or_swap(uint64 bytes, int priority, bigtime_t timeout);

void vm_debug_init();
void vm_kernel_args_init_post_area(kernel_args* args);
status_t vm_daemon_init(void);

bool vm_page_should_do_active_paging();

const char *page_state_to_string(int state);
        // for debugging purposes only

#endif

#endif  /* _KERNEL_VM_VM_PRIV_H */