[zion] Move memory syscalls to the new format
This commit is contained in:
parent
f755cd38fe
commit
1a70ce4855
10 changed files with 107 additions and 175 deletions
26
zion/syscall/address_space.cpp
Normal file
26
zion/syscall/address_space.cpp
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue