[Zion] Add a AddressSpaceUnmap syscall to free memory.
This commit is contained in:
parent
e668428d9d
commit
30b6511467
9 changed files with 60 additions and 18 deletions
|
|
@ -15,10 +15,19 @@ z_err_t AddressSpaceMap(ZAddressSpaceMapReq* req) {
|
|||
|
||||
// FIXME: Validation necessary.
|
||||
if (req->vmas_offset != 0) {
|
||||
vmas->MapInMemoryObject(req->vmas_offset, vmmo);
|
||||
RET_ERR(vmas->MapInMemoryObject(req->vmas_offset, vmmo));
|
||||
*req->vaddr = req->vmas_offset;
|
||||
} else {
|
||||
*req->vaddr = vmas->MapInMemoryObject(vmmo);
|
||||
ASSIGN_OR_RETURN(*req->vaddr, vmas->MapInMemoryObject(vmmo));
|
||||
}
|
||||
return glcr::OK;
|
||||
}
|
||||
|
||||
z_err_t AddressSpaceUnmap(ZAddressSpaceUnmapReq* req) {
|
||||
auto& curr_proc = gScheduler->CurrentProcess();
|
||||
auto vmas_cap = curr_proc.GetCapability(req->vmas_cap);
|
||||
RET_ERR(ValidateCapability<AddressSpace>(vmas_cap, kZionPerm_Write));
|
||||
|
||||
auto vmas = vmas_cap->obj<AddressSpace>();
|
||||
return vmas->FreeAddressRange(req->lower_addr, req->upper_addr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@
|
|||
#include "include/zcall.h"
|
||||
|
||||
z_err_t AddressSpaceMap(ZAddressSpaceMapReq* req);
|
||||
z_err_t AddressSpaceUnmap(ZAddressSpaceUnmapReq* req);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ extern "C" z_err_t SyscallHandler(uint64_t call_id, void* req) {
|
|||
CASE(ThreadWait);
|
||||
// syscall/address_space.h
|
||||
CASE(AddressSpaceMap);
|
||||
CASE(AddressSpaceUnmap);
|
||||
// syscall/memory_object.h
|
||||
CASE(MemoryObjectCreate);
|
||||
CASE(MemoryObjectCreatePhysical);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue