aboutsummaryrefslogtreecommitdiff
path: root/common/vmem.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-01-26 15:53:16 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-01-26 15:53:16 +0200
commit8a5e4cf53d981e793fca90d9b51bd395265cf4db (patch)
tree245aabe14f45aa717f4f3156bdcfc1afb0388131 /common/vmem.c
parent5dad7c7ecccaa1e11be23f53e3198af6933c9f60 (diff)
downloadkmi-8a5e4cf53d981e793fca90d9b51bd395265cf4db.tar.gz
kmi-8a5e4cf53d981e793fca90d9b51bd395265cf4db.zip
add req_page syscall
Diffstat (limited to 'common/vmem.c')
-rw-r--r--common/vmem.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/common/vmem.c b/common/vmem.c
index f1eed83..b28a3d6 100644
--- a/common/vmem.c
+++ b/common/vmem.c
@@ -200,6 +200,36 @@ vm_t alloc_uvmem(struct tcb *t, size_t size, vmflags_t flags)
return w;
}
+vm_t alloc_uvpage(struct tcb *t, size_t size, vmflags_t flags, size_t *asize,
+ pm_t *paddr)
+{
+ hard_assert(t && is_proc(t), ERR_INVAL);
+
+ enum mm_order order = nearest_order(size);
+ size_t actual_size = order_size(order);
+ stat_t status = OK;
+
+ const vm_t v = alloc_region(&t->sp_r, size, &size, flags);
+ const vm_t w = __addr(__page(v));
+
+ pm_t addr = alloc_page(order);
+ /** @todo should free region */
+ if (!addr)
+ return NULL;
+
+ status = map_vpage(t->proc.vmem, addr, w, flags, order);
+ if (is_rpc(t) && status == INFO_SEFF)
+ clone_rpc_maps(t);
+
+ if (asize)
+ *asize = actual_size;
+
+ if (paddr)
+ *paddr = addr;
+
+ return w;
+}
+
vm_t alloc_fixed_uvmem(struct tcb *t, vm_t start, size_t size, vmflags_t flags)
{
hard_assert(t && is_proc(t), ERR_INVAL);