1 /* Function prototypes. */
10 #include <minix/endpoint.h>
11 #include <minix/safecopies.h>
15 #include <pagetable.h>
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
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
);
37 void get_mem_chunks(struct memory
*mem_chunks
);
38 int vm_isokendpt(endpoint_t ep
, int *proc
);
39 int get_stack_ptr(int proc_nr
, vir_bytes
*sp
);
40 int do_info(message
*);
41 int swap_proc_slot(struct vmproc
*src_vmp
, struct vmproc
*dst_vmp
);
42 int swap_proc_dyn_data(struct vmproc
*src_vmp
, struct vmproc
*dst_vmp
);
45 void clear_proc(struct vmproc
*vmp
);
46 int do_exit(message
*msg
);
47 int do_willexit(message
*msg
);
48 int do_procctl(message
*msg
);
49 void free_proc(struct vmproc
*vmp
);
52 int do_fork(message
*msg
);
55 int do_brk(message
*msg
);
56 int real_brk(struct vmproc
*vmp
, vir_bytes v
);
59 int map_memory(endpoint_t sour
, endpoint_t dest
, vir_bytes virt_s
,
60 vir_bytes virt_d
, vir_bytes length
, int flag
);
61 int unmap_memory(endpoint_t sour
, endpoint_t dest
, vir_bytes virt_s
,
62 vir_bytes virt_d
, vir_bytes length
, int flag
);
65 int do_mmap(message
*msg
);
66 int do_munmap(message
*msg
);
67 int do_map_phys(message
*msg
);
68 int do_unmap_phys(message
*msg
);
69 int do_remap(message
*m
);
70 int do_get_phys(message
*m
);
71 int do_shared_unmap(message
*m
);
72 int do_get_refcount(message
*m
);
75 void do_pagefaults(message
*m
);
77 char *pf_errstr(u32_t err
);
78 int handle_memory(struct vmproc
*vmp
, vir_bytes mem
, vir_bytes len
, int
81 /* $(ARCH)/pagetable.c */
83 void vm_freepages(vir_bytes vir
, int pages
);
84 void pt_init_mem(void);
85 void pt_check(struct vmproc
*vmp
);
87 void pt_free(pt_t
*pt
);
88 int pt_map_in_range(struct vmproc
*src_vmp
, struct vmproc
*dst_vmp
,
89 vir_bytes start
, vir_bytes end
);
90 int pt_ptmap(struct vmproc
*src_vmp
, struct vmproc
*dst_vmp
);
91 int pt_ptalloc_in_range(pt_t
*pt
, vir_bytes start
, vir_bytes end
, u32_t
93 void pt_clearmapcache(void);
94 int pt_writemap(struct vmproc
* vmp
, pt_t
*pt
, vir_bytes v
, phys_bytes
95 physaddr
, size_t bytes
, u32_t flags
, u32_t writemapflags
);
96 int pt_checkrange(pt_t
*pt
, vir_bytes v
, size_t bytes
, int write
);
97 int pt_bind(pt_t
*pt
, struct vmproc
*who
);
98 void *vm_allocpage(phys_bytes
*p
, int cat
);
100 int pt_mapkernel(pt_t
*pt
);
101 void vm_pagelock(void *vir
, int lockflag
);
102 int vm_addrok(void *vir
, int write
);
103 int get_vm_self_pages(void);
106 void pt_sanitycheck(pt_t
*pt
, char *file
, int line
);
110 void *slaballoc(int bytes
);
111 void slabfree(void *mem
, int bytes
);
112 void slabstats(void);
113 void slab_sanitycheck(char *file
, int line
);
114 #define SLABALLOC(var) (var = slaballoc(sizeof(*var)))
115 #define SLABFREE(ptr) do { slabfree(ptr, sizeof(*(ptr))); (ptr) = NULL; } while(0)
118 void slabunlock(void *mem
, int bytes
);
119 void slablock(void *mem
, int bytes
);
120 int slabsane_f(char *file
, int line
, void *mem
, int bytes
);
124 void map_region_init(void);
125 struct vir_region
* map_page_region(struct vmproc
*vmp
, vir_bytes min
,
126 vir_bytes max
, vir_bytes length
, vir_bytes what
, u32_t flags
, int
128 struct vir_region
* map_proc_kernel(struct vmproc
*dst
);
129 int map_region_extend(struct vmproc
*vmp
, struct vir_region
*vr
,
131 int map_region_extend_upto_v(struct vmproc
*vmp
, vir_bytes vir
);
132 int map_region_shrink(struct vir_region
*vr
, vir_bytes delta
);
133 int map_unmap_region(struct vmproc
*vmp
, struct vir_region
*vr
,
134 vir_bytes offset
, vir_bytes len
);
135 int map_free_proc(struct vmproc
*vmp
);
136 int map_proc_copy(struct vmproc
*dst
, struct vmproc
*src
);
137 int map_proc_copy_from(struct vmproc
*dst
, struct vmproc
*src
, struct
138 vir_region
*start_src_vr
);
139 struct vir_region
*map_lookup(struct vmproc
*vmp
, vir_bytes addr
,
140 struct phys_region
**pr
);
141 int map_pf(struct vmproc
*vmp
, struct vir_region
*region
, vir_bytes
143 int map_pin_memory(struct vmproc
*vmp
);
144 int map_handle_memory(struct vmproc
*vmp
, struct vir_region
*region
,
145 vir_bytes offset
, vir_bytes len
, int write
);
146 void map_printmap(struct vmproc
*vmp
);
147 int map_writept(struct vmproc
*vmp
);
148 void printregionstats(struct vmproc
*vmp
);
149 void map_setparent(struct vmproc
*vmp
);
150 int yielded_block_cmp(struct block_id
*, struct block_id
*);
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_remap(struct vmproc
*dvmp
, vir_bytes da
, size_t size
, struct
157 vir_region
*region
, vir_bytes
*r
, int ro
);
158 int map_get_phys(struct vmproc
*vmp
, vir_bytes addr
, phys_bytes
*r
);
159 int map_get_ref(struct vmproc
*vmp
, vir_bytes addr
, u8_t
*cnt
);
161 void get_stats_info(struct vm_stats_info
*vsi
);
162 void get_usage_info(struct vmproc
*vmp
, struct vm_usage_info
*vui
);
163 void get_usage_info_kernel(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
);
169 void map_sanitycheck(char *file
, int line
);
170 void blockstats(void);
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
);
178 int do_rs_set_priv(message
*m
);
179 int do_rs_update(message
*m
);
180 int do_rs_memctl(message
*m
);
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);
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
);