diff --git a/zion/include/zcall.h b/zion/include/zcall.h index 1ea7558..a610454 100644 --- a/zion/include/zcall.h +++ b/zion/include/zcall.h @@ -30,6 +30,7 @@ SYS3(MemoryObjectCreateContiguous, uint64_t, size, z_cap_t*, vmmo_cap, SYS4(MemoryObjectDuplicate, z_cap_t, vmmo_cap, uint64_t, base_offset, uint64_t, length, z_cap_t*, new_vmmo_cap); +SYS2(MemoryObjectInspect, z_cap_t, vmmo_cap, uint64_t*, size); SYS2(ChannelCreate, z_cap_t*, channel1, z_cap_t*, channel2); SYS5(ChannelSend, z_cap_t, chan_cap, uint64_t, num_bytes, const void*, data, diff --git a/zion/include/ztypes.h b/zion/include/ztypes.h index a57cb6a..ebbb4c7 100644 --- a/zion/include/ztypes.h +++ b/zion/include/ztypes.h @@ -28,6 +28,7 @@ const uint64_t kZionMemoryObjectCreatePhysical = 0x31; const uint64_t kZionMemoryObjectCreateContiguous = 0x32; const uint64_t kZionMemoryObjectDuplicate = 0x38; +const uint64_t kZionMemoryObjectInspect = 0x39; // IPC Calls const uint64_t kZionChannelCreate = 0x40; diff --git a/zion/syscall/memory_object.cpp b/zion/syscall/memory_object.cpp index ae268c4..5457cb6 100644 --- a/zion/syscall/memory_object.cpp +++ b/zion/syscall/memory_object.cpp @@ -33,7 +33,6 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) { z_err_t MemoryObjectDuplicate(ZMemoryObjectDuplicateReq* req) { auto& curr_proc = gScheduler->CurrentProcess(); auto vmmo_cap = curr_proc.GetCapability(req->vmmo_cap); - // FIXME: Check a duplication permission here. RET_ERR(ValidateCapability(vmmo_cap, kZionPerm_Duplicate)); ASSIGN_OR_RETURN( @@ -43,3 +42,14 @@ z_err_t MemoryObjectDuplicate(ZMemoryObjectDuplicateReq* req) { curr_proc.AddNewCapability(new_vmmo, vmmo_cap->permissions()); return glcr::OK; } + +z_err_t MemoryObjectInspect(ZMemoryObjectInspectReq* req) { + auto& curr_proc = gScheduler->CurrentProcess(); + auto vmmo_cap = curr_proc.GetCapability(req->vmmo_cap); + RET_ERR(ValidateCapability(vmmo_cap, kZionPerm_Read)); + + auto vmmo = vmmo_cap->obj(); + *req->size = vmmo->size(); + + return glcr::OK; +} diff --git a/zion/syscall/memory_object.h b/zion/syscall/memory_object.h index 155be97..5805345 100644 --- a/zion/syscall/memory_object.h +++ b/zion/syscall/memory_object.h @@ -6,3 +6,4 @@ z_err_t MemoryObjectCreate(ZMemoryObjectCreateReq* req); z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req); z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req); z_err_t MemoryObjectDuplicate(ZMemoryObjectDuplicateReq* req); +z_err_t MemoryObjectInspect(ZMemoryObjectInspectReq* req); diff --git a/zion/syscall/syscall.cpp b/zion/syscall/syscall.cpp index d21392c..89ee5b8 100644 --- a/zion/syscall/syscall.cpp +++ b/zion/syscall/syscall.cpp @@ -66,6 +66,7 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) { CASE(MemoryObjectCreatePhysical); CASE(MemoryObjectCreateContiguous); CASE(MemoryObjectDuplicate); + CASE(MemoryObjectInspect); // syscall/ipc.h CASE(ChannelCreate); CASE(ChannelSend);