HLE/SVC: Implement UnmapMemoryBlock.
This implementation will need to be (almost completely) changed when we implement multiprocess support.
This commit is contained in:
parent
82087672b7
commit
d90d5a0ee6
5 changed files with 60 additions and 5 deletions
|
@ -39,6 +39,12 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
|
|||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
||||
}
|
||||
|
||||
// TODO(Subv): Return E0E01BEE when permissions and other_permissions don't
|
||||
// match what was specified when the memory block was created.
|
||||
|
||||
// TODO(Subv): Return E0E01BEE when address should be 0.
|
||||
// Note: Find out when that's the case.
|
||||
|
||||
if (fixed_address != 0) {
|
||||
if (address != 0 && address != fixed_address) {
|
||||
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s: fixed_addres is 0x%08X!",
|
||||
|
@ -74,6 +80,21 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
|
|||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ResultCode SharedMemory::Unmap(VAddr address) {
|
||||
if (base_address == 0) {
|
||||
// TODO(Subv): Verify what actually happens when you want to unmap a memory block that
|
||||
// was originally mapped with address = 0
|
||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||
}
|
||||
|
||||
if (base_address != address)
|
||||
return ResultCode(ErrorDescription::WrongAddress, ErrorModule::OS, ErrorSummary::InvalidState, ErrorLevel::Usage);
|
||||
|
||||
base_address = 0;
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
u8* SharedMemory::GetPointer(u32 offset) {
|
||||
if (base_address != 0)
|
||||
return Memory::GetPointer(base_address + offset);
|
||||
|
|
|
@ -52,6 +52,13 @@ public:
|
|||
*/
|
||||
ResultCode Map(VAddr address, MemoryPermission permissions, MemoryPermission other_permissions);
|
||||
|
||||
/**
|
||||
* Unmaps a shared memory block from the specified address in system memory
|
||||
* @param address Address in system memory where the shared memory block is mapped
|
||||
* @return Result code of the unmap operation
|
||||
*/
|
||||
ResultCode Unmap(VAddr address);
|
||||
|
||||
/**
|
||||
* Gets a pointer to the shared memory block
|
||||
* @param offset Offset from the start of the shared memory block to get pointer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue