1 /* Function prototypes. */
10 #include <minix/endpoint.h>
11 #include <minix/safecopies.h>
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
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
);
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
);
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
);
49 int do_fork(message
*msg
);
52 int do_brk(message
*msg
);
53 int real_brk(struct vmproc
*vmp
, vir_bytes v
);
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
);
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
);
71 void do_pagefaults(message
*m
);
73 char *pf_errstr(u32_t err
);
74 int handle_memory(struct vmproc
*vmp
, vir_bytes mem
, vir_bytes len
, int
77 /* $(ARCH)/pagetable.c */
79 void vm_freepages(vir_bytes vir
, int pages
);
80 void pt_init_mem(void);
81 void pt_check(struct vmproc
*vmp
);
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
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_allocpagedir(phys_bytes
*p
);
97 int pt_mapkernel(pt_t
*pt
);
98 void vm_pagelock(void *vir
, int lockflag
);
99 int vm_addrok(void *vir
, int write
);
100 int get_vm_self_pages(void);
103 void pt_sanitycheck(pt_t
*pt
, char *file
, int line
);
107 void *slaballoc(int bytes
);
108 void slabfree(void *mem
, int bytes
);
109 void slabstats(void);
110 void slab_sanitycheck(char *file
, int line
);
111 #define SLABALLOC(var) (var = slaballoc(sizeof(*var)))
112 #define SLABFREE(ptr) do { slabfree(ptr, sizeof(*(ptr))); (ptr) = NULL; } while(0)
115 void slabunlock(void *mem
, int bytes
);
116 void slablock(void *mem
, int bytes
);
117 int slabsane_f(char *file
, int line
, void *mem
, int bytes
);
121 void map_region_init(void);
122 struct vir_region
* map_page_region(struct vmproc
*vmp
, vir_bytes min
,
123 vir_bytes max
, vir_bytes length
, u32_t flags
, int mapflags
,
124 mem_type_t
*memtype
);
125 struct vir_region
* map_proc_kernel(struct vmproc
*dst
);
126 int map_region_extend(struct vmproc
*vmp
, struct vir_region
*vr
,
128 int map_region_extend_upto_v(struct vmproc
*vmp
, vir_bytes vir
);
129 int map_unmap_region(struct vmproc
*vmp
, struct vir_region
*vr
,
130 vir_bytes offset
, vir_bytes len
);
131 int map_free_proc(struct vmproc
*vmp
);
132 int map_proc_copy(struct vmproc
*dst
, struct vmproc
*src
);
133 int map_proc_copy_from(struct vmproc
*dst
, struct vmproc
*src
, struct
134 vir_region
*start_src_vr
);
135 struct vir_region
*map_lookup(struct vmproc
*vmp
, vir_bytes addr
,
136 struct phys_region
**pr
);
137 int map_pf(struct vmproc
*vmp
, struct vir_region
*region
, vir_bytes
139 int map_pin_memory(struct vmproc
*vmp
);
140 int map_handle_memory(struct vmproc
*vmp
, struct vir_region
*region
,
141 vir_bytes offset
, vir_bytes len
, int write
);
142 void map_printmap(struct vmproc
*vmp
);
143 int map_writept(struct vmproc
*vmp
);
144 void printregionstats(struct vmproc
*vmp
);
145 void map_setparent(struct vmproc
*vmp
);
146 int yielded_block_cmp(struct block_id
*, struct block_id
*);
147 struct phys_region
*map_clone_ph_block(struct vmproc
*vmp
,
148 struct vir_region
*region
, struct phys_region
*ph
, physr_iter
*iter
);
149 u32_t
vrallocflags(u32_t flags
);
150 int map_free(struct vir_region
*region
);
152 struct vir_region
* map_region_lookup_tag(struct vmproc
*vmp
, u32_t
154 void map_region_set_tag(struct vir_region
*vr
, u32_t tag
);
155 u32_t
map_region_get_tag(struct vir_region
*vr
);
156 int map_get_phys(struct vmproc
*vmp
, vir_bytes addr
, phys_bytes
*r
);
157 int map_get_ref(struct vmproc
*vmp
, vir_bytes addr
, u8_t
*cnt
);
158 int physregions(struct vir_region
*vr
);
160 void get_stats_info(struct vm_stats_info
*vsi
);
161 void get_usage_info(struct vmproc
*vmp
, struct vm_usage_info
*vui
);
162 void get_usage_info_kernel(struct vm_usage_info
*vui
);
163 int get_region_info(struct vmproc
*vmp
, struct vm_region_info
*vri
, int
164 count
, vir_bytes
*nextp
);
165 int copy_abs2region(phys_bytes abs
, struct vir_region
*destregion
,
166 phys_bytes offset
, phys_bytes len
);
168 void map_sanitycheck(char *file
, int line
);
169 void blockstats(void);
171 int do_forgetblocks(message
*m
);
172 int do_forgetblock(message
*m
);
173 int do_yieldblockgetblock(message
*m
);
174 vir_bytes
free_yielded(vir_bytes bytes
);
177 int do_rs_set_priv(message
*m
);
178 int do_rs_update(message
*m
);
179 int do_rs_memctl(message
*m
);
182 int do_query_exit(message
*m
);
183 int do_watch_exit(message
*m
);
184 int do_notify_sig(message
*m
);
185 void init_query_exit(void);
188 struct phys_block
*pb_new(phys_bytes phys
);
189 void pb_free(struct phys_block
*);
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
);
193 void pb_link(struct phys_region
*newphysr
, struct phys_block
*newpb
,
194 vir_bytes offset
, struct vir_region
*parent
);
196 /* mem_directphys.c */
197 void phys_setphys(struct vir_region
*vr
, phys_bytes startaddr
);
200 void shared_setsource(struct vir_region
*vr
, endpoint_t ep
, struct vir_region
*src
);