[zion] Move memory syscalls to the new format

This commit is contained in:
Drew Galbraith 2023-06-20 14:26:06 -07:00
parent f755cd38fe
commit 1a70ce4855
10 changed files with 107 additions and 175 deletions

View file

@ -0,0 +1,26 @@
#include "syscall/address_space.h"
#include "scheduler/scheduler.h"
#include "syscall/syscall.h"
z_err_t AddressSpaceMap(ZAddressSpaceMapReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto vmas_cap = curr_proc.GetCapability(req->vmas_cap);
auto vmmo_cap = curr_proc.GetCapability(req->vmmo_cap);
RET_ERR(ValidateCap(vmas_cap, ZC_WRITE));
RET_ERR(ValidateCap(vmmo_cap, ZC_WRITE));
auto vmas = vmas_cap->obj<AddressSpace>();
auto vmmo = vmmo_cap->obj<MemoryObject>();
RET_IF_NULL(vmas);
RET_IF_NULL(vmmo);
// FIXME: Validation necessary.
if (req->vmas_offset != 0) {
vmas->MapInMemoryObject(req->vmas_offset, vmmo);
*req->vaddr = req->vmas_offset;
} else {
*req->vaddr = vmas->MapInMemoryObject(vmmo);
}
return Z_OK;
}