some coverity fixes.
[minix.git] / servers / vm / proto.h
blob968c7fda1d46301cb4a0edebea7148f48a397c96
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>
15 #include <pagetable.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 struct memlist *alloc_mem_in_list(phys_bytes bytes, u32_t flags, phys_bytes known);
24 void memstats(int *nodes, int *pages, int *largest);
25 void printmemstats(void);
26 void usedpages_reset(void);
27 int usedpages_add_f(phys_bytes phys, phys_bytes len, char *file, int
28 line);
29 void free_mem(phys_clicks base, phys_clicks clicks);
30 void free_mem_list(struct memlist *list, int all);
31 void print_mem_list(struct memlist *ml);
32 #define usedpages_add(a, l) usedpages_add_f(a, l, __FILE__, __LINE__)
34 void mem_init(struct memory *chunks);
36 /* utility.c */
37 void get_mem_chunks(struct memory *mem_chunks);
38 void reserve_proc_mem(struct memory *mem_chunks, struct mem_map
39 *map_ptr);
40 int vm_isokendpt(endpoint_t ep, int *proc);
41 int get_stack_ptr(int proc_nr, vir_bytes *sp);
42 int do_info(message *);
43 int swap_proc_slot(struct vmproc *src_vmp, struct vmproc *dst_vmp);
44 int swap_proc_dyn_data(struct vmproc *src_vmp, struct vmproc *dst_vmp);
46 /* exit.c */
47 void clear_proc(struct vmproc *vmp);
48 int do_exit(message *msg);
49 int do_willexit(message *msg);
50 int do_procctl(message *msg);
51 void free_proc(struct vmproc *vmp);
53 /* fork.c */
54 int do_fork(message *msg);
56 /* break.c */
57 int do_brk(message *msg);
58 int real_brk(struct vmproc *vmp, vir_bytes v);
60 /* map_mem.c */
61 int map_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
62 vir_bytes virt_d, vir_bytes length, int flag);
63 int unmap_memory(endpoint_t sour, endpoint_t dest, vir_bytes virt_s,
64 vir_bytes virt_d, vir_bytes length, int flag);
66 /* mmap.c */
67 int do_mmap(message *msg);
68 int do_munmap(message *msg);
69 int do_map_phys(message *msg);
70 int do_unmap_phys(message *msg);
71 int do_remap(message *m);
72 int do_get_phys(message *m);
73 int do_shared_unmap(message *m);
74 int do_get_refcount(message *m);
76 /* pagefaults.c */
77 void do_pagefaults(message *m);
78 void do_memory(void);
79 char *pf_errstr(u32_t err);
80 int handle_memory(struct vmproc *vmp, vir_bytes mem, vir_bytes len, int
81 wrflag);
83 /* $(ARCH)/pagetable.c */
84 void pt_init();
85 void vm_freepages(vir_bytes vir, int pages);
86 void pt_init_mem(void);
87 void pt_check(struct vmproc *vmp);
88 int pt_new(pt_t *pt);
89 void pt_free(pt_t *pt);
90 int pt_map_in_range(struct vmproc *src_vmp, struct vmproc *dst_vmp,
91 vir_bytes start, vir_bytes end);
92 int pt_ptmap(struct vmproc *src_vmp, struct vmproc *dst_vmp);
93 int pt_ptalloc_in_range(pt_t *pt, vir_bytes start, vir_bytes end, u32_t
94 flags, int verify);
95 void pt_clearmapcache(void);
96 int pt_writemap(struct vmproc * vmp, pt_t *pt, vir_bytes v, phys_bytes
97 physaddr, size_t bytes, u32_t flags, u32_t writemapflags);
98 int pt_checkrange(pt_t *pt, vir_bytes v, size_t bytes, int write);
99 int pt_bind(pt_t *pt, struct vmproc *who);
100 void *vm_allocpage(phys_bytes *p, int cat);
101 void pt_cycle(void);
102 int pt_mapkernel(pt_t *pt);
103 void vm_pagelock(void *vir, int lockflag);
104 int vm_addrok(void *vir, int write);
106 #if SANITYCHECKS
107 void pt_sanitycheck(pt_t *pt, char *file, int line);
108 #endif
110 /* slaballoc.c */
111 void *slaballoc(int bytes);
112 void slabfree(void *mem, int bytes);
113 void slabstats(void);
114 void slab_sanitycheck(char *file, int line);
115 #define SLABALLOC(var) (var = slaballoc(sizeof(*var)))
116 #define SLABFREE(ptr) do { slabfree(ptr, sizeof(*(ptr))); (ptr) = NULL; } while(0)
117 #if SANITYCHECKS
119 void slabunlock(void *mem, int bytes);
120 void slablock(void *mem, int bytes);
121 int slabsane_f(char *file, int line, void *mem, int bytes);
122 #endif
124 /* region.c */
125 void map_region_init(void);
126 struct vir_region * map_page_region(struct vmproc *vmp, vir_bytes min,
127 vir_bytes max, vir_bytes length, vir_bytes what, u32_t flags, int
128 mapflags);
129 struct vir_region * map_proc_kernel(struct vmproc *dst);
130 int map_region_extend(struct vmproc *vmp, struct vir_region *vr,
131 vir_bytes delta);
132 int map_region_extend_upto_v(struct vmproc *vmp, vir_bytes vir);
133 int map_region_shrink(struct vir_region *vr, vir_bytes delta);
134 int map_unmap_region(struct vmproc *vmp, struct vir_region *vr,
135 vir_bytes offset, vir_bytes len);
136 int map_free_proc(struct vmproc *vmp);
137 int map_proc_copy(struct vmproc *dst, struct vmproc *src);
138 int map_proc_copy_from(struct vmproc *dst, struct vmproc *src, struct
139 vir_region *start_src_vr);
140 struct vir_region *map_lookup(struct vmproc *vmp, vir_bytes addr,
141 struct phys_region **pr);
142 int map_pf(struct vmproc *vmp, struct vir_region *region, vir_bytes
143 offset, int write);
144 int map_pin_memory(struct vmproc *vmp);
145 int map_handle_memory(struct vmproc *vmp, struct vir_region *region,
146 vir_bytes offset, vir_bytes len, int write);
147 void map_printmap(struct vmproc *vmp);
148 int map_writept(struct vmproc *vmp);
149 void printregionstats(struct vmproc *vmp);
150 void map_setparent(struct vmproc *vmp);
151 int yielded_block_cmp(struct block_id *, struct block_id *);
153 struct vir_region * map_region_lookup_tag(struct vmproc *vmp, u32_t
154 tag);
155 void map_region_set_tag(struct vir_region *vr, u32_t tag);
156 u32_t map_region_get_tag(struct vir_region *vr);
157 int map_remap(struct vmproc *dvmp, vir_bytes da, size_t size, struct
158 vir_region *region, vir_bytes *r, int ro);
159 int map_get_phys(struct vmproc *vmp, vir_bytes addr, phys_bytes *r);
160 int map_get_ref(struct vmproc *vmp, vir_bytes addr, u8_t *cnt);
162 void get_stats_info(struct vm_stats_info *vsi);
163 void get_usage_info(struct vmproc *vmp, struct vm_usage_info *vui);
164 int get_region_info(struct vmproc *vmp, struct vm_region_info *vri, int
165 count, vir_bytes *nextp);
166 int copy_abs2region(phys_bytes abs, struct vir_region *destregion,
167 phys_bytes offset, phys_bytes len);
168 #if SANITYCHECKS
169 void map_sanitycheck(char *file, int line);
170 void blockstats(void);
171 #endif
172 int do_forgetblocks(message *m);
173 int do_forgetblock(message *m);
174 int do_yieldblockgetblock(message *m);
175 vir_bytes free_yielded(vir_bytes bytes);
177 /* rs.c */
178 int do_rs_set_priv(message *m);
179 int do_rs_update(message *m);
180 int do_rs_memctl(message *m);
182 /* queryexit.c */
183 int do_query_exit(message *m);
184 int do_watch_exit(message *m);
185 int do_notify_sig(message *m);
186 void init_query_exit(void);
188 /* pb.c */
189 struct phys_block *pb_new(phys_bytes phys);
190 struct phys_region *pb_reference(struct phys_block *newpb,
191 vir_bytes offset, struct vir_region *region);
192 void pb_unreferenced(struct vir_region *region, struct phys_region *pr, int rm);