kernel: restore setting KTS_NONE
[minix.git] / servers / vm / proto.h
blob1882cafe9a0daf0590e419d3ef3bcc368111ea6e
1 /* Function prototypes. */
3 struct vmproc;
4 struct stat;
5 struct memory;
6 struct vir_region;
7 struct phys_region;
9 #include <minix/ipc.h>
10 #include <minix/endpoint.h>
11 #include <minix/safecopies.h>
12 #include <minix/vm.h>
13 #include <timers.h>
14 #include <stdio.h>
16 #include "pt.h"
17 #include "vm.h"
18 #include "yielded.h"
20 /* alloc.c */
21 void mem_sanitycheck(char *file, int line);
22 phys_clicks alloc_mem(phys_clicks clicks, u32_t flags);
23 void memstats(int *nodes, int *pages, int *largest);
24 void printmemstats(void);
25 void usedpages_reset(void);
26 int usedpages_add_f(phys_bytes phys, phys_bytes len, char *file, int
27 line);
28 void free_mem(phys_clicks base, phys_clicks clicks);
29 #define usedpages_add(a, l) usedpages_add_f(a, l, __FILE__, __LINE__)
31 void mem_init(struct memory *chunks);
33 /* utility.c */
34 void get_mem_chunks(struct memory *mem_chunks);
35 int vm_isokendpt(endpoint_t ep, int *proc);
36 int get_stack_ptr(int proc_nr, vir_bytes *sp);
37 int do_info(message *);
38 int swap_proc_slot(struct vmproc *src_vmp, struct vmproc *dst_vmp);
39 int swap_proc_dyn_data(struct vmproc *src_vmp, struct vmproc *dst_vmp);
41 /* exit.c */
42 void clear_proc(struct vmproc *vmp);
43 int do_exit(message *msg);
44 int do_willexit(message *msg);
45 int do_procctl(message *msg);
46 void free_proc(struct vmproc *vmp);
48 /* fork.c */
49 int do_fork(message *msg);
51 /* break.c */
52 int do_brk(message *msg);
53 int real_brk(struct vmproc *vmp, vir_bytes v);
55 /* map_mem.c */
56 int map_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
57 vir_bytes virt_d, vir_bytes length, int flag);
58 int unmap_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
59 vir_bytes virt_d, vir_bytes length, int flag);
61 /* mmap.c */
62 int do_mmap(message *msg);
63 int do_munmap(message *msg);
64 int do_map_phys(message *msg);
65 int do_unmap_phys(message *msg);
66 int do_remap(message *m);
67 int do_get_phys(message *m);
68 int do_get_refcount(message *m);
70 /* pagefaults.c */
71 void do_pagefaults(message *m);
72 void do_memory(void);
73 char *pf_errstr(u32_t err);
74 int handle_memory(struct vmproc *vmp, vir_bytes mem, vir_bytes len, int
75 wrflag);
77 /* $(ARCH)/pagetable.c */
78 void pt_init();
79 void vm_freepages(vir_bytes vir, int pages);
80 void pt_init_mem(void);
81 void pt_check(struct vmproc *vmp);
82 int pt_new(pt_t *pt);
83 void pt_free(pt_t *pt);
84 int pt_map_in_range(struct vmproc *src_vmp, struct vmproc *dst_vmp,
85 vir_bytes start, vir_bytes end);
86 int pt_ptmap(struct vmproc *src_vmp, struct vmproc *dst_vmp);
87 int pt_ptalloc_in_range(pt_t *pt, vir_bytes start, vir_bytes end, u32_t
88 flags, int verify);
89 void pt_clearmapcache(void);
90 int pt_writemap(struct vmproc * vmp, pt_t *pt, vir_bytes v, phys_bytes
91 physaddr, size_t bytes, u32_t flags, u32_t writemapflags);
92 int pt_checkrange(pt_t *pt, vir_bytes v, size_t bytes, int write);
93 int pt_bind(pt_t *pt, struct vmproc *who);
94 void *vm_allocpage(phys_bytes *p, int cat);
95 void *vm_allocpages(phys_bytes *p, int cat, int pages);
96 void *vm_allocpagedir(phys_bytes *p);
97 void pt_cycle(void);
98 int pt_mapkernel(pt_t *pt);
99 void vm_pagelock(void *vir, int lockflag);
100 int vm_addrok(void *vir, int write);
101 int get_vm_self_pages(void);
103 #if SANITYCHECKS
104 void pt_sanitycheck(pt_t *pt, char *file, int line);
105 #endif
107 /* slaballoc.c */
108 void *slaballoc(int bytes);
109 void slabfree(void *mem, int bytes);
110 void slabstats(void);
111 void slab_sanitycheck(char *file, int line);
112 #define SLABALLOC(var) (var = slaballoc(sizeof(*var)))
113 #define SLABFREE(ptr) do { slabfree(ptr, sizeof(*(ptr))); (ptr) = NULL; } while(0)
114 #if SANITYCHECKS
116 void slabunlock(void *mem, int bytes);
117 void slablock(void *mem, int bytes);
118 int slabsane_f(char *file, int line, void *mem, int bytes);
119 #endif
121 /* region.c */
122 void map_region_init(void);
123 struct vir_region * map_page_region(struct vmproc *vmp, vir_bytes min,
124 vir_bytes max, vir_bytes length, u32_t flags, int mapflags,
125 mem_type_t *memtype);
126 struct vir_region * map_proc_kernel(struct vmproc *dst);
127 int map_region_extend(struct vmproc *vmp, struct vir_region *vr,
128 vir_bytes delta);
129 int map_region_extend_upto_v(struct vmproc *vmp, vir_bytes vir);
130 int map_unmap_region(struct vmproc *vmp, struct vir_region *vr,
131 vir_bytes offset, vir_bytes len);
132 int map_free_proc(struct vmproc *vmp);
133 int map_proc_copy(struct vmproc *dst, struct vmproc *src);
134 int map_proc_copy_from(struct vmproc *dst, struct vmproc *src, struct
135 vir_region *start_src_vr);
136 struct vir_region *map_lookup(struct vmproc *vmp, vir_bytes addr,
137 struct phys_region **pr);
138 int map_pf(struct vmproc *vmp, struct vir_region *region, vir_bytes
139 offset, int write);
140 int map_pin_memory(struct vmproc *vmp);
141 int map_handle_memory(struct vmproc *vmp, struct vir_region *region,
142 vir_bytes offset, vir_bytes len, int write);
143 void map_printmap(struct vmproc *vmp);
144 int map_writept(struct vmproc *vmp);
145 void printregionstats(struct vmproc *vmp);
146 void map_setparent(struct vmproc *vmp);
147 int yielded_block_cmp(struct block_id *, struct block_id *);
148 struct phys_region *map_clone_ph_block(struct vmproc *vmp,
149 struct vir_region *region, struct phys_region *ph);
150 u32_t vrallocflags(u32_t flags);
151 int map_free(struct vir_region *region);
152 struct phys_region *physblock_get(struct vir_region *region, vir_bytes offset);
153 void physblock_set(struct vir_region *region, vir_bytes offset,
154 struct phys_region *newphysr);
156 struct vir_region * map_region_lookup_tag(struct vmproc *vmp, u32_t
157 tag);
158 void map_region_set_tag(struct vir_region *vr, u32_t tag);
159 u32_t map_region_get_tag(struct vir_region *vr);
160 int map_get_phys(struct vmproc *vmp, vir_bytes addr, phys_bytes *r);
161 int map_get_ref(struct vmproc *vmp, vir_bytes addr, u8_t *cnt);
162 int physregions(struct vir_region *vr);
164 void get_stats_info(struct vm_stats_info *vsi);
165 void get_usage_info(struct vmproc *vmp, struct vm_usage_info *vui);
166 void get_usage_info_kernel(struct vm_usage_info *vui);
167 int get_region_info(struct vmproc *vmp, struct vm_region_info *vri, int
168 count, vir_bytes *nextp);
169 int copy_abs2region(phys_bytes abs, struct vir_region *destregion,
170 phys_bytes offset, phys_bytes len);
171 #if SANITYCHECKS
172 void map_sanitycheck(char *file, int line);
173 void blockstats(void);
174 #endif
175 int do_forgetblocks(message *m);
176 int do_forgetblock(message *m);
177 int do_yieldblockgetblock(message *m);
178 vir_bytes free_yielded(vir_bytes bytes);
180 /* rs.c */
181 int do_rs_set_priv(message *m);
182 int do_rs_update(message *m);
183 int do_rs_memctl(message *m);
185 /* queryexit.c */
186 int do_query_exit(message *m);
187 int do_watch_exit(message *m);
188 int do_notify_sig(message *m);
189 void init_query_exit(void);
191 /* pb.c */
192 struct phys_block *pb_new(phys_bytes phys);
193 void pb_free(struct phys_block *);
194 struct phys_region *pb_reference(struct phys_block *newpb,
195 vir_bytes offset, struct vir_region *region);
196 void pb_unreferenced(struct vir_region *region, struct phys_region *pr, int rm);
197 void pb_link(struct phys_region *newphysr, struct phys_block *newpb,
198 vir_bytes offset, struct vir_region *parent);
200 /* mem_directphys.c */
201 void phys_setphys(struct vir_region *vr, phys_bytes startaddr);
203 /* mem_shared.c */
204 void shared_setsource(struct vir_region *vr, endpoint_t ep, struct vir_region *src);