diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-07 21:47:14 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-07 21:47:14 +0300 |
| commit | 219c27d420fe0abe5515cefc2513c6fe60aafdf9 (patch) | |
| tree | 5cd0c38a971245c91fd7bc3539b4a37c8a08a7f1 /src/uapi/mem.c | |
| parent | fe4c623cb9320226866829317cea8ba0c49e7dbc (diff) | |
| download | kmi-219c27d420fe0abe5515cefc2513c6fe60aafdf9.tar.gz kmi-219c27d420fe0abe5515cefc2513c6fe60aafdf9.zip | |
add req_page back in as I realized it's useful
+ Can be used to pass contiguous memory regions to things like virtio
block devices for implementing disk drivers etc.
Diffstat (limited to 'src/uapi/mem.c')
| -rw-r--r-- | src/uapi/mem.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/uapi/mem.c b/src/uapi/mem.c index 17823a1..49370fc 100644 --- a/src/uapi/mem.c +++ b/src/uapi/mem.c @@ -106,6 +106,34 @@ SYSCALL_DEFINE3(req_pmem)(struct tcb *t, sys_arg_t paddr, sys_arg_t size, } /** + * Allocate some contiguous region in memory. + * Due to page allocation constraints, this is generally just one page that's + * larger than the \p size parameter. Should work fine for 4K - 2M allocations, + * which I assume is generally what is used, but we'll see if I have to + * implement an actually good page allocator at some point. + * + * @param t Current tcb. + * @param size Minimum size of mapping. + * @param flags Flags of mapping. Unsure why you'd want anything besides VM_W | + * VM_R, but eh. + * + * @return \see sys_req_page(). + */ +SYSCALL_DEFINE2(req_page)(struct tcb *t, sys_arg_t size, sys_arg_t flags) +{ + struct tcb *r = get_cproc(t); + + pm_t addr = 0; + vm_t start = 0; + size_t asize = 0; + flags = sanitize_uvflags(flags); + if (!(start = alloc_uvpage(r, size, flags, &addr, &asize))) + return_args1(t, ERR_OOMEM); + + return_args4(t, OK, start, addr, asize); +} + +/** * Request shared memory syscall handler. * * @param t Current tcb. |
