aboutsummaryrefslogtreecommitdiff
path: root/include/apos
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-12-02 21:12:11 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-12-02 21:12:11 +0200
commit10ae2e6ebc7e9776b9f124c9fc530c79f5e84460 (patch)
tree6687cf98db623f8c38c5d5aea234014a27302e10 /include/apos
parent131af4eec38752a27e6e56579fbf76178e022ec1 (diff)
downloadkmi-10ae2e6ebc7e9776b9f124c9fc530c79f5e84460.tar.gz
kmi-10ae2e6ebc7e9776b9f124c9fc530c79f5e84460.zip
initial shared memory working
Diffstat (limited to 'include/apos')
-rw-r--r--include/apos/mem_regions.h18
-rw-r--r--include/apos/uapi.h16
-rw-r--r--include/apos/vmem.h16
3 files changed, 28 insertions, 22 deletions
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;
@@ -125,6 +128,21 @@ 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.
* \note The address returned might not be the address requested, and the caller
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
@@ -374,22 +374,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.
*
* Frees the memory region pointed to.
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.