Remove building with NOCRYPTO option
[minix3.git] / minix / servers / vm / proto.h
blobba06f05ceb033448d0a2b6fe7e04870e55f4038b
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 <minix/timers.h>
14 #include <stdio.h>
16 #include "pt.h"
17 #include "vm.h"
19 /* acl.c */
20 void acl_init(void);
21 int acl_check(struct vmproc *vmp, int call);
22 void acl_set(struct vmproc *vmp, bitchunk_t *mask, int sys_proc);
23 void acl_fork(struct vmproc *vmp);
24 void acl_clear(struct vmproc *vmp);
26 /* alloc.c */
27 void *reservedqueue_new(int, int, int, int);
28 int reservedqueue_alloc(void *, phys_bytes *, void **);
29 void reservedqueue_add(void *, void *, phys_bytes);
30 void alloc_cycle(void);
31 void mem_sanitycheck(const char *file, int line);
32 phys_clicks alloc_mem(phys_clicks clicks, u32_t flags);
33 void memstats(int *nodes, int *pages, int *largest);
34 void printmemstats(void);
35 void usedpages_reset(void);
36 int usedpages_add_f(phys_bytes phys, phys_bytes len, const char *file, int
37 line);
38 void free_mem(phys_clicks base, phys_clicks clicks);
39 void mem_add_total_pages(int pages);
40 #define usedpages_add(a, l) usedpages_add_f(a, l, __FILE__, __LINE__)
42 void mem_init(struct memory *chunks);
44 /* utility.c */
45 void get_mem_chunks(struct memory *mem_chunks);
46 int vm_isokendpt(endpoint_t ep, int *proc);
47 int get_stack_ptr(int proc_nr, vir_bytes *sp);
48 int do_info(message *);
49 int swap_proc_slot(struct vmproc *src_vmp, struct vmproc *dst_vmp);
50 int swap_proc_dyn_data(struct vmproc *src_vmp, struct vmproc *dst_vmp,
51 int sys_upd_flags);
52 int map_proc_dyn_data(struct vmproc *src_vmp, struct vmproc *dst_vmp);
53 void adjust_proc_refs(void);
54 int do_getrusage(message *m);
56 /* exit.c */
57 void clear_proc(struct vmproc *vmp);
58 int do_exit(message *msg);
59 int do_willexit(message *msg);
60 int do_procctl(message *msg, int transid);
61 void free_proc(struct vmproc *vmp);
63 /* fork.c */
64 int do_fork(message *msg);
66 /* break.c */
67 int do_brk(message *msg);
68 int real_brk(struct vmproc *vmp, vir_bytes v);
70 /* map_mem.c */
71 int map_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
72 vir_bytes virt_d, vir_bytes length, int flag);
73 int unmap_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
74 vir_bytes virt_d, vir_bytes length, int flag);
76 /* mmap.c */
77 int do_mmap(message *msg);
78 int do_munmap(message *msg);
79 int do_map_phys(message *msg);
80 int do_unmap_phys(message *msg);
81 int do_remap(message *m);
82 int do_get_phys(message *m);
83 int do_get_refcount(message *m);
84 int do_vfs_mmap(message *m);
86 /* pagefaults.c */
87 void do_pagefaults(message *m);
88 void do_memory(void);
89 char *pf_errstr(u32_t err);
90 int handle_memory_start(struct vmproc *vmp, vir_bytes mem, vir_bytes len,
91 int wrflag, endpoint_t caller, endpoint_t requestor, int transid,
92 int vfs_avail);
93 int handle_memory_once(struct vmproc *vmp, vir_bytes mem, vir_bytes len,
94 int wrflag);
96 /* $(ARCH)/pagetable.c */
97 void pt_init(void);
98 void vm_freepages(vir_bytes vir, int pages);
99 void pt_init_mem(void);
100 void pt_check(struct vmproc *vmp);
101 int pt_new(pt_t *pt);
102 void pt_free(pt_t *pt);
103 int pt_map_in_range(struct vmproc *src_vmp, struct vmproc *dst_vmp,
104 vir_bytes start, vir_bytes end);
105 int pt_ptmap(struct vmproc *src_vmp, struct vmproc *dst_vmp);
106 int pt_ptalloc_in_range(pt_t *pt, vir_bytes start, vir_bytes end, u32_t
107 flags, int verify);
108 void pt_clearmapcache(void);
109 int pt_writemap(struct vmproc * vmp, pt_t *pt, vir_bytes v, phys_bytes
110 physaddr, size_t bytes, u32_t flags, u32_t writemapflags);
111 int pt_checkrange(pt_t *pt, vir_bytes v, size_t bytes, int write);
112 int pt_bind(pt_t *pt, struct vmproc *who);
113 void *vm_mappages(phys_bytes p, int pages);
114 void *vm_allocpage(phys_bytes *p, int cat);
115 void *vm_allocpages(phys_bytes *p, int cat, int pages);
116 void *vm_allocpagedir(phys_bytes *p);
117 int pt_mapkernel(pt_t *pt);
118 void vm_pagelock(void *vir, int lockflag);
119 int vm_addrok(void *vir, int write);
120 int get_vm_self_pages(void);
121 int pt_writable(struct vmproc *vmp, vir_bytes v);
122 void pt_assert(pt_t *pt);
124 #if SANITYCHECKS
125 void pt_sanitycheck(pt_t *pt, const char *file, int line);
126 #endif
128 /* slaballoc.c */
129 void *slaballoc(int bytes);
130 void slabfree(void *mem, int bytes);
131 void slabstats(void);
132 void slab_sanitycheck(const char *file, int line);
133 #define SLABALLOC(var) (var = slaballoc(sizeof(*var)))
134 #define SLABFREE(ptr) do { slabfree(ptr, sizeof(*(ptr))); (ptr) = NULL; } while(0)
135 #if SANITYCHECKS
137 void slabunlock(void *mem, int bytes);
138 void slablock(void *mem, int bytes);
139 int slabsane_f(const char *file, int line, void *mem, int bytes);
140 #endif
142 /* region.c */
143 void map_region_init(void);
144 struct vir_region * map_page_region(struct vmproc *vmp, vir_bytes min,
145 vir_bytes max, vir_bytes length, u32_t flags, int mapflags,
146 mem_type_t *memtype);
147 struct vir_region * map_proc_kernel(struct vmproc *dst);
148 int map_region_extend(struct vmproc *vmp, struct vir_region *vr,
149 vir_bytes delta);
150 int map_region_extend_upto_v(struct vmproc *vmp, vir_bytes vir);
151 int map_unmap_region(struct vmproc *vmp, struct vir_region *vr,
152 vir_bytes offset, vir_bytes len);
153 int map_unmap_range(struct vmproc *vmp, vir_bytes, vir_bytes);
154 int map_free_proc(struct vmproc *vmp);
155 int map_proc_copy(struct vmproc *dst, struct vmproc *src);
156 int map_proc_copy_range(struct vmproc *dst, struct vmproc *src, struct
157 vir_region *start_src_vr, struct vir_region *end_src_vr);
158 struct vir_region *map_lookup(struct vmproc *vmp, vir_bytes addr,
159 struct phys_region **pr);
160 int map_pf(struct vmproc *vmp, struct vir_region *region, vir_bytes
161 offset, int write, vfs_callback_t pf_callback, void *state, int len,
162 int *io);
163 int map_pin_memory(struct vmproc *vmp);
164 int map_handle_memory(struct vmproc *vmp, struct vir_region *region,
165 vir_bytes offset, vir_bytes len, int write, vfs_callback_t cb,
166 void *state, int statelen);
167 void map_printmap(struct vmproc *vmp);
168 int map_writept(struct vmproc *vmp);
169 void printregionstats(struct vmproc *vmp);
170 void map_setparent(struct vmproc *vmp);
171 u32_t vrallocflags(u32_t flags);
172 int map_free(struct vir_region *region);
173 struct phys_region *physblock_get(struct vir_region *region, vir_bytes offset);
174 void physblock_set(struct vir_region *region, vir_bytes offset,
175 struct phys_region *newphysr);
176 int map_ph_writept(struct vmproc *vmp, struct vir_region *vr,
177 struct phys_region *pr);
179 struct vir_region* map_region_lookup_type(struct vmproc *vmp, u32_t flags);
180 int map_get_phys(struct vmproc *vmp, vir_bytes addr, phys_bytes *r);
181 int map_get_ref(struct vmproc *vmp, vir_bytes addr, u8_t *cnt);
182 unsigned int physregions(struct vir_region *vr);
184 void get_usage_info(struct vmproc *vmp, struct vm_usage_info *vui);
185 void get_usage_info_kernel(struct vm_usage_info *vui);
186 int get_region_info(struct vmproc *vmp, struct vm_region_info *vri, int
187 count, vir_bytes *nextp);
188 int copy_abs2region(phys_bytes abs, struct vir_region *destregion,
189 phys_bytes offset, phys_bytes len);
190 #if SANITYCHECKS
191 void map_sanitycheck(const char *file, int line);
192 #endif
194 /* rs.c */
195 int do_rs_set_priv(message *m);
196 int do_rs_prepare(message *m);
197 int do_rs_update(message *m);
198 int do_rs_memctl(message *m);
200 /* pb.c */
201 struct phys_block *pb_new(phys_bytes phys);
202 void pb_free(struct phys_block *);
203 struct phys_region *pb_reference(struct phys_block *newpb,
204 vir_bytes offset, struct vir_region *region, mem_type_t *);
205 void pb_unreferenced(struct vir_region *region, struct phys_region *pr, int rm);
206 void pb_link(struct phys_region *newphysr, struct phys_block *newpb,
207 vir_bytes offset, struct vir_region *parent);
208 int mem_cow(struct vir_region *region,
209 struct phys_region *ph, phys_bytes new_page_cl, phys_bytes new_page);
211 /* mem_directphys.c */
212 void phys_setphys(struct vir_region *vr, phys_bytes startaddr);
214 /* mem_shared.c */
215 void shared_setsource(struct vir_region *vr, endpoint_t ep, struct vir_region *src);
217 /* mem_cache.c */
218 int do_mapcache(message *m);
219 int do_setcache(message *m);
220 int do_forgetcache(message *m);
221 int do_clearcache(message *m);
223 /* cache.c */
224 struct cached_page *find_cached_page_bydev(dev_t dev, u64_t dev_off,
225 ino_t ino, u64_t ino_off, int touchlru);
226 struct cached_page *find_cached_page_byino(dev_t dev, ino_t ino, u64_t ino_off, int touchlru);
227 int addcache(dev_t dev, u64_t def_off, ino_t ino, u64_t ino_off, int flags,
228 struct phys_block *pb);
229 void cache_sanitycheck_internal(void);
230 int cache_freepages(int pages);
231 void get_stats_info(struct vm_stats_info *vsi);
232 void cache_lru_touch(struct cached_page *hb);
233 void rmcache(struct cached_page *cp);
234 void clear_cache_bydev(dev_t dev);
236 /* vfs.c */
237 int vfs_request(int reqno, int fd, struct vmproc *vmp, u64_t offset,
238 u32_t len, vfs_callback_t reply_callback, void *cbarg, void *state,
239 int statelen);
240 int do_vfs_reply(message *m);
242 /* mem_file.c */
243 int mappedfile_setfile(struct vmproc *owner, struct vir_region *region,
244 int fd, u64_t offset,
245 dev_t dev, ino_t ino, u16_t clearend, int prefill, int mayclose);
247 /* fdref.c */
248 struct fdref *fdref_new(struct vmproc *owner, ino_t ino, dev_t dev, int fd);
249 struct fdref *fdref_dedup_or_new(struct vmproc *owner, ino_t ino, dev_t dev,
250 int fd, int mayclose);
251 void fdref_ref(struct fdref *ref, struct vir_region *region);
252 void fdref_deref(struct vir_region *region);
253 void fdref_sanitycheck(void);