aboutsummaryrefslogtreecommitdiff
path: root/include/apos/vmem.h
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-05-12 15:52:25 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-05-12 15:52:25 +0300
commit1ea7d9dec1b460ab76dfd6270596c8138c9c2b40 (patch)
tree0e8799fe0d7a653e864bd90c65a29e4012026f71 /include/apos/vmem.h
parent42a1e087ce99f07b48aaea5552f8e1ce5219d228 (diff)
downloadkmi-1ea7d9dec1b460ab76dfd6270596c8138c9c2b40.tar.gz
kmi-1ea7d9dec1b460ab76dfd6270596c8138c9c2b40.zip
initial workings of shared memory
+ Should document this better but essentially a server requests a shared buffer, and chan then share this buffer to a thread. Freeing the buffer is done through normal means. MR_SHARED is used for buffers that are shared, and MR_OWNED tells whoever is freeing that region that it is allowed to free the physical memory behind the shared buffer.
Diffstat (limited to 'include/apos/vmem.h')
-rw-r--r--include/apos/vmem.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/apos/vmem.h b/include/apos/vmem.h
index 571b906..5b5037d 100644
--- a/include/apos/vmem.h
+++ b/include/apos/vmem.h
@@ -8,20 +8,28 @@
vm_t alloc_uvmem(struct tcb *r, size_t size, vmflags_t flags);
vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, vmflags_t flags);
+vm_t alloc_shared_uvmem(struct tcb *r, size_t size,
+ vmflags_t flags);
+vm_t ref_shared_uvmem(struct tcb *r1, struct tcb *r2, vm_t va, vmflags_t flags);
stat_t free_uvmem(struct tcb *r, vm_t a);
stat_t init_uvmem(struct tcb *r, vm_t base, vm_t top);
stat_t alloc_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr,
vmflags_t flags, enum mm_order order);
+stat_t alloc_shared_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr,
+ vmflags_t flags, enum mm_order order);
stat_t free_uvmem_wrapper(struct vm_branch *b, pm_t *offset, vm_t vaddr,
vmflags_t flags, enum mm_order order);
#define map_allocd_region(b, start, bytes, flags) \
map_fill_region(b, &alloc_uvmem_wrapper, 0, start, bytes, flags)
-#define unmap_freed_region(b, start, bytes) \
- map_fill_region(b, &free_uvmem_wrapper, 0, start, bytes, 0)
+#define map_shared_region(b, start, bytes, flags)\
+ map_fill_region(b, &alloc_shared_wrapper, 0, start, bytes, flags)
+
+#define unmap_freed_region(b, start, bytes, flags) \
+ map_fill_region(b, &free_uvmem_wrapper, 0, start, bytes, flags)
#define vm_flags(x) ((x) & ~0xff)
#define vp_flags(x) ((x)&0xff)