|
|
@ -12,11 +12,15 @@ namespace Kernel {
|
|
|
|
SharedMemory::SharedMemory() {}
|
|
|
|
SharedMemory::SharedMemory() {}
|
|
|
|
SharedMemory::~SharedMemory() {}
|
|
|
|
SharedMemory::~SharedMemory() {}
|
|
|
|
|
|
|
|
|
|
|
|
SharedPtr<SharedMemory> SharedMemory::Create(std::string name) {
|
|
|
|
SharedPtr<SharedMemory> SharedMemory::Create(u32 size, MemoryPermission permissions,
|
|
|
|
|
|
|
|
MemoryPermission other_permissions, std::string name) {
|
|
|
|
SharedPtr<SharedMemory> shared_memory(new SharedMemory);
|
|
|
|
SharedPtr<SharedMemory> shared_memory(new SharedMemory);
|
|
|
|
|
|
|
|
|
|
|
|
shared_memory->name = std::move(name);
|
|
|
|
shared_memory->name = std::move(name);
|
|
|
|
shared_memory->base_address = 0x0;
|
|
|
|
shared_memory->base_address = 0x0;
|
|
|
|
|
|
|
|
shared_memory->size = size;
|
|
|
|
|
|
|
|
shared_memory->permissions = permissions;
|
|
|
|
|
|
|
|
shared_memory->other_permissions = other_permissions;
|
|
|
|
|
|
|
|
|
|
|
|
return shared_memory;
|
|
|
|
return shared_memory;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -24,7 +28,7 @@ SharedPtr<SharedMemory> SharedMemory::Create(std::string name) {
|
|
|
|
ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
|
|
|
|
ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
|
|
|
|
MemoryPermission other_permissions) {
|
|
|
|
MemoryPermission other_permissions) {
|
|
|
|
|
|
|
|
|
|
|
|
if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {
|
|
|
|
if (address < Memory::SHARED_MEMORY_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
|
|
|
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X outside of shared mem bounds!",
|
|
|
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X outside of shared mem bounds!",
|
|
|
|
GetObjectId(), address);
|
|
|
|
GetObjectId(), address);
|
|
|
|
// TODO: Verify error code with hardware
|
|
|
|
// TODO: Verify error code with hardware
|
|
|
@ -32,21 +36,19 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions,
|
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
|
|
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Test permissions
|
|
|
|
|
|
|
|
|
|
|
|
this->base_address = address;
|
|
|
|
this->base_address = address;
|
|
|
|
this->permissions = permissions;
|
|
|
|
|
|
|
|
this->other_permissions = other_permissions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
return RESULT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<u8*> SharedMemory::GetPointer(u32 offset) {
|
|
|
|
u8* SharedMemory::GetPointer(u32 offset) {
|
|
|
|
if (base_address != 0)
|
|
|
|
if (base_address != 0)
|
|
|
|
return MakeResult<u8*>(Memory::GetPointer(base_address + offset));
|
|
|
|
return Memory::GetPointer(base_address + offset);
|
|
|
|
|
|
|
|
|
|
|
|
LOG_ERROR(Kernel_SVC, "memory block id=%u not mapped!", GetObjectId());
|
|
|
|
LOG_ERROR(Kernel_SVC, "memory block id=%u not mapped!", GetObjectId());
|
|
|
|
// TODO(yuriks): Verify error code.
|
|
|
|
return nullptr;
|
|
|
|
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
|
|
|
|
|
|
|
|
ErrorSummary::InvalidState, ErrorLevel::Permanent);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|