[zion] Add a method for duplicating and scoping down VMMOs.

Use the AHCI section of the PCI config as an example POC of this.

We can now pass a memory capability instead of just the physical
address.
This commit is contained in:
Drew Galbraith 2023-08-01 17:46:26 -07:00
parent 8f84f8c3ca
commit 48c6e5b3a4
12 changed files with 62 additions and 18 deletions

View file

@ -29,3 +29,16 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) {
*req->paddr = paddr;
return glcr::OK;
}
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<MemoryObject>(vmmo_cap, ZC_WRITE));
ASSIGN_OR_RETURN(
glcr::RefPtr<MemoryObject> new_vmmo,
vmmo_cap->obj<MemoryObject>()->Duplicate(req->base_offset, req->length));
*req->new_vmmo_cap = curr_proc.AddNewCapability(new_vmmo, ZC_WRITE | ZC_READ);
return glcr::OK;
}

View file

@ -5,3 +5,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);

View file

@ -63,6 +63,7 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) {
CASE(MemoryObjectCreate);
CASE(MemoryObjectCreatePhysical);
CASE(MemoryObjectCreateContiguous);
CASE(MemoryObjectDuplicate);
// syscall/ipc.h
CASE(ChannelCreate);
CASE(ChannelSend);