use the -newos toolchain even if -elf is present.
[newos.git] / include / kernel / vm_priv.h
blob1369951950135a3370bec2007679906b693dcae3
1 /*
2 ** Copyright 2001-2004, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #ifndef _KERNEL_VM_PRIV_H
6 #define _KERNEL_VM_PRIV_H
8 #include <kernel/vm.h>
9 #include <kernel/khash.h>
11 /* should make these scale with the system */
12 #define DEFAULT_KERNEL_WORKING_SET 1024
13 #define DEFAULT_WORKING_SET 256
14 #define DEFAULT_MAX_WORKING_SET 65536
15 #define DEFAULT_MIN_WORKING_SET 64
17 #define WORKING_SET_INCREMENT 32
18 #define WORKING_SET_DECREMENT 32
20 #define PAGE_DAEMON_INTERVAL 5000000
21 #define PAGE_SCAN_QUANTUM 500
22 #define WORKING_SET_ADJUST_INTERVAL 5000000
23 #define MAX_FAULTS_PER_SECOND 100
24 #define MIN_FAULTS_PER_SECOND 10
26 #define WRITE_COUNT 1024
27 #define READ_COUNT 1
29 // page attributes
30 #define PAGE_MODIFIED 0x04
31 #define PAGE_ACCESSED 0x08
32 #define PAGE_PRESENT 0x10
34 // Should only be used by vm internals
35 int vm_page_fault(addr_t address, addr_t fault_address, bool is_write, bool is_user, addr_t *newip);
36 void vm_increase_max_commit(addr_t delta);
37 int vm_daemon_init(void);
39 // used by the page daemon to walk the list of address spaces
40 int vm_aspace_walk_start(struct hash_iterator *i);
41 vm_address_space *vm_aspace_walk_next(struct hash_iterator *i);
43 // get some data about the number of pages in the system
44 addr_t vm_page_num_pages(void);
45 addr_t vm_page_num_free_pages(void);
47 // allocates memory from the ka structure
48 addr_t vm_alloc_from_ka_struct(kernel_args *ka, unsigned int size, int lock);
49 addr_t vm_alloc_ppage_from_kernel_struct(kernel_args *ka);
51 // a global structure holding data about the vm for informational purposes
52 extern vm_info_t vm_info;
54 // minimal consistency checks
55 #define VERIFY_VM_PAGE(page) ASSERT((page) && (page)->magic == VM_PAGE_MAGIC)
56 #define VERIFY_VM_CACHE_REF(ref) ASSERT((ref) && (ref)->magic == VM_CACHE_REF_MAGIC && (ref)->ref_count >= 0)
57 #define VERIFY_VM_CACHE(cache) ASSERT((cache) && (cache)->magic == VM_CACHE_MAGIC)
58 #define VERIFY_VM_REGION(region) ASSERT((region) && (region)->magic == VM_REGION_MAGIC && (region)->ref_count >= 0)
59 #define VERIFY_VM_ASPACE(aspace) ASSERT((aspace) && (aspace)->magic == VM_ASPACE_MAGIC && (aspace)->ref_count >= 0)
60 #define VERIFY_VM_STORE(store) ASSERT((store) && (store)->magic == VM_STORE_MAGIC)
62 #endif