Implement freeing ressource on uAS destroy

This commit is contained in:
Mathieu Maret 2024-02-05 23:46:17 +01:00 committed by Mathieu Maret
parent 205d174c8a
commit a4873a7d30

View File

@ -127,12 +127,21 @@ int uAddrSpaceDelete(struct uAddrSpace *addr)
struct uAddrVirtualReg *reg;
list_collapse_named(addr->listVirtualReg, reg, nextInAddrSpace, prevInAddrSpace) {
// TODO Implement me with real ressources
assertmsg(reg->res == NULL, "Unsupported mapper ressource");
if (reg->res == NULL) {
// This is memory allocated for the heap just unmap it to free it
pr_devel("Freeing heap 0x%lx for process %s\n", reg->addr, processGetName(addr->process));
pr_devel("Freeing heap 0x%lx for process %s\n", reg->addr,
processGetName(addr->process));
pageUnmap(reg->addr);
free(reg);
} else {
if(reg->res->ops){
if(reg->res->ops->unmap)
reg->res->ops->unmap(reg, reg->addr, reg->size);
if(reg->res->ops->close)
reg->res->ops->close(reg);
}
free(reg);
}
}
return mmuContextUnref(addr->ctx);
}
@ -387,7 +396,7 @@ int uAddrSpaceSolvePageFault(struct uAddrSpace *as, vaddr_t faultAddr, int isWri
return -EFAULT;
if (isWriteAccess && !(reg->right & PAGING_MEM_WRITE))
return -EFAULT;
return -EACCES;
if (isWriteAccess)
rights |= PAGING_MEM_WRITE;