From 10ae2e6ebc7e9776b9f124c9fc530c79f5e84460 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 2 Dec 2022 21:12:11 +0200 Subject: initial shared memory working --- include/apos/mem_regions.h | 18 ++++++++++++++++++ include/apos/uapi.h | 16 ---------------- include/apos/vmem.h | 16 ++++++++++------ 3 files changed, 28 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/apos/mem_regions.h b/include/apos/mem_regions.h index b94d15a..7231dbd 100644 --- a/include/apos/mem_regions.h +++ b/include/apos/mem_regions.h @@ -85,6 +85,9 @@ struct mem_region { * MR_SHARED, MR_OWNED, MR_COW, MR_KEEP. */ vmflags_t flags; + /** In shared regions, mark the other pid that shared the region. */ + id_t pid; + /** End address of memory region. */ vm_t end; @@ -124,6 +127,21 @@ stat_t destroy_region(struct mem_region_root *r); vm_t alloc_region(struct mem_region_root *r, size_t size, size_t *actual_size, vmflags_t flags); +/** + * Allocate memory region and associate it with some other process. + * Will allocate region of at least \c size bytes, with best possible location. + * + * @param r Memory region root. + * @param size Size of region to allocate. + * @param actual_size Size of region that was allocated. + * @param flags Memory flags. + * @param pid Process to associate with region. + * @return Address of allocated region on success, otherwise \c NULL. + */ +stat_t alloc_shared_region(struct mem_region_root *r, size_t size, + size_t *actual_size, + vmflags_t flags, id_t pid); + /** * Allocate fixed memory region. * Will allocate region that is at least \c size bytes, and includes \c start. diff --git a/include/apos/uapi.h b/include/apos/uapi.h index 7bd00bb..dda4391 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -373,22 +373,6 @@ SYSCALL_DECLARE3(req_fixmem, start, size, flags); */ SYSCALL_DECLARE4(req_sharedmem, tid, size, sflags, cflags); -/** - * Reference shared memory syscall. - * - * \see sys_req_sharedmem(). - * - * @param t Current tcb. - * @param tid Thread ID of owner of shared memory. - * @param va Start address of shared memory. - * @param flags Flags to use for reference. - * @param d Unused. - * @param e Unused. - * - * Returns \ref OK and start of shared memory. - */ -SYSCALL_DECLARE3(ref_sharedmem, tid, va, flags); - /** * Free memory syscall. * diff --git a/include/apos/vmem.h b/include/apos/vmem.h index 1e481fa..38bad16 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -46,14 +46,18 @@ vm_t alloc_fixed_uvmem(struct tcb *r, vm_t start, size_t size, vmflags_t flags); /** * Allocate shared user virtual memory. * - * Only callable by servers, who are the owners of the shared region. - * - * @param r Process to allocate memory in. + * @param s First process to allocate memory in. + * @param c Second process to allocate memory in. * @param size Minimum size of allocation. - * @param flags Flags of allocation. - * @return Start of allocation when succesful, \c NULL otherwise. + * @param sflags Flags of allocation for \p s. + * @param cflags Flags of allocation for \p c. + * @param sstart Start of allocation for \p s. + * @param cstart Start of allocation for \p c. + * @return Status of allocation. */ -vm_t alloc_shared_uvmem(struct tcb *r, size_t size, vmflags_t flags); +stat_t alloc_shared_uvmem(struct tcb *s, struct tcb *c, size_t size, + vmflags_t sflags, vmflags_t cflags, + vm_t *sstart, vm_t *cstart); /** * Reference shared user virtual memory. -- cgit v1.3