[Zion] Separate Memory "Views" to a separate MemoryObject.

This commit is contained in:
Drew Galbraith 2023-11-19 23:22:56 -08:00
parent a8ad225cf1
commit 12ca4e4e89
4 changed files with 35 additions and 16 deletions

View file

@ -14,8 +14,7 @@ z_err_t MemoryObjectCreate(ZMemoryObjectCreateReq* req) {
z_err_t MemoryObjectCreatePhysical(ZMemoryObjectCreatePhysicalReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
uint64_t paddr = req->paddr;
auto vmmo_ref =
glcr::MakeRefCounted<FixedMemoryObject>(paddr, req->size, false);
auto vmmo_ref = glcr::MakeRefCounted<ViewMemoryObject>(paddr, req->size);
*req->vmmo_cap =
curr_proc.AddNewCapability(StaticCastRefPtr<MemoryObject>(vmmo_ref));
return glcr::OK;
@ -25,8 +24,7 @@ z_err_t MemoryObjectCreateContiguous(ZMemoryObjectCreateContiguousReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
uint64_t num_pages = ((req->size - 1) / 0x1000) + 1;
uint64_t paddr = phys_mem::AllocateContinuous(num_pages);
auto vmmo_ref =
glcr::MakeRefCounted<FixedMemoryObject>(paddr, req->size, true);
auto vmmo_ref = glcr::MakeRefCounted<FixedMemoryObject>(paddr, req->size);
*req->vmmo_cap =
curr_proc.AddNewCapability(StaticCastRefPtr<MemoryObject>(vmmo_ref));
*req->paddr = paddr;