mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 12:05:39 +01:00
Kernel: Centralize error definitions in errors.h
This commit is contained in:
parent
743d18f0e4
commit
2cdb40d709
@ -230,6 +230,7 @@ set(HEADERS
|
|||||||
hle/kernel/address_arbiter.h
|
hle/kernel/address_arbiter.h
|
||||||
hle/kernel/client_port.h
|
hle/kernel/client_port.h
|
||||||
hle/kernel/client_session.h
|
hle/kernel/client_session.h
|
||||||
|
hle/kernel/errors.h
|
||||||
hle/kernel/event.h
|
hle/kernel/event.h
|
||||||
hle/kernel/kernel.h
|
hle/kernel/kernel.h
|
||||||
hle/kernel/memory.h
|
hle/kernel/memory.h
|
||||||
|
@ -53,7 +53,7 @@ void Wrap() {
|
|||||||
FuncReturn(retval);
|
FuncReturn(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <ResultCode func(u32*, s32, u32, u32, u32, s32)>
|
template <ResultCode func(u32*, u32, u32, u32, u32, s32)>
|
||||||
void Wrap() {
|
void Wrap() {
|
||||||
u32 param_1 = 0;
|
u32 param_1 = 0;
|
||||||
u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
|
u32 retval = func(¶m_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)).raw;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
@ -43,6 +44,12 @@ inline u32* GetStaticBuffers(const int offset = 0) {
|
|||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
|
// These errors are commonly returned by invalid IPC translations, so alias them here for
|
||||||
|
// convenience.
|
||||||
|
// TODO(yuriks): These will probably go away once translation is implemented inside the kernel.
|
||||||
|
using Kernel::ERR_INVALID_BUFFER_DESCRIPTOR;
|
||||||
|
constexpr auto ERR_INVALID_HANDLE = Kernel::ERR_INVALID_HANDLE_OS;
|
||||||
|
|
||||||
enum DescriptorType : u32 {
|
enum DescriptorType : u32 {
|
||||||
// Buffer related desciptors types (mask : 0x0F)
|
// Buffer related desciptors types (mask : 0x0F)
|
||||||
StaticBuffer = 0x02,
|
StaticBuffer = 0x02,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/hle/kernel/address_arbiter.h"
|
#include "core/hle/kernel/address_arbiter.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
@ -74,8 +75,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Kernel, "unknown type=%d", type);
|
LOG_ERROR(Kernel, "unknown type=%d", type);
|
||||||
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
|
return ERR_INVALID_ENUM_VALUE_FND;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The calls that use a timeout seem to always return a Timeout error even if they did not put
|
// The calls that use a timeout seem to always return a Timeout error even if they did not put
|
||||||
@ -83,8 +83,7 @@ ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address,
|
|||||||
if (type == ArbitrationType::WaitIfLessThanWithTimeout ||
|
if (type == ArbitrationType::WaitIfLessThanWithTimeout ||
|
||||||
type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) {
|
type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) {
|
||||||
|
|
||||||
return ResultCode(ErrorDescription::Timeout, ErrorModule::OS, ErrorSummary::StatusChanged,
|
return RESULT_TIMEOUT;
|
||||||
ErrorLevel::Info);
|
|
||||||
}
|
}
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "core/hle/kernel/client_port.h"
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/server_port.h"
|
#include "core/hle/kernel/server_port.h"
|
||||||
#include "core/hle/kernel/server_session.h"
|
#include "core/hle/kernel/server_session.h"
|
||||||
@ -19,8 +20,7 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
|
|||||||
// AcceptSession before returning from this call.
|
// AcceptSession before returning from this call.
|
||||||
|
|
||||||
if (active_sessions >= max_sessions) {
|
if (active_sessions >= max_sessions) {
|
||||||
return ResultCode(ErrorDescription::MaxConnectionsReached, ErrorModule::OS,
|
return ERR_MAX_CONNECTIONS_REACHED;
|
||||||
ErrorSummary::WouldBlock, ErrorLevel::Temporary);
|
|
||||||
}
|
}
|
||||||
active_sessions++;
|
active_sessions++;
|
||||||
|
|
||||||
|
@ -30,8 +30,7 @@ ResultCode ClientSession::SendSyncRequest() {
|
|||||||
if (parent->server)
|
if (parent->server)
|
||||||
return parent->server->HandleSyncRequest();
|
return parent->server->HandleSyncRequest();
|
||||||
|
|
||||||
return ResultCode(ErrorDescription::SessionClosedByRemote, ErrorModule::OS,
|
return ERR_SESSION_CLOSED_BY_REMOTE;
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
98
src/core/hle/kernel/errors.h
Normal file
98
src/core/hle/kernel/errors.h
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright 2017 Citra Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
|
||||||
|
namespace ErrCodes {
|
||||||
|
enum {
|
||||||
|
OutOfHandles = 19,
|
||||||
|
SessionClosedByRemote = 26,
|
||||||
|
PortNameTooLong = 30,
|
||||||
|
WrongPermission = 46,
|
||||||
|
InvalidBufferDescriptor = 48,
|
||||||
|
MaxConnectionsReached = 52,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always
|
||||||
|
// double check that the code matches before re-using the constant.
|
||||||
|
|
||||||
|
constexpr ResultCode ERR_OUT_OF_HANDLES(ErrCodes::OutOfHandles, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::OutOfResource,
|
||||||
|
ErrorLevel::Permanent); // 0xD8600413
|
||||||
|
constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrCodes::SessionClosedByRemote, ErrorModule::OS,
|
||||||
|
ErrorSummary::Canceled,
|
||||||
|
ErrorLevel::Status); // 0xC920181A
|
||||||
|
constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrCodes::PortNameTooLong, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E0181E
|
||||||
|
constexpr ResultCode ERR_WRONG_PERMISSION(ErrCodes::WrongPermission, ErrorModule::OS,
|
||||||
|
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
||||||
|
constexpr ResultCode ERR_INVALID_BUFFER_DESCRIPTOR(ErrCodes::InvalidBufferDescriptor,
|
||||||
|
ErrorModule::OS, ErrorSummary::WrongArgument,
|
||||||
|
ErrorLevel::Permanent);
|
||||||
|
constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrCodes::MaxConnectionsReached, ErrorModule::OS,
|
||||||
|
ErrorSummary::WouldBlock,
|
||||||
|
ErrorLevel::Temporary); // 0xD0401834
|
||||||
|
|
||||||
|
constexpr ResultCode ERR_NOT_AUTHORIZED(ErrorDescription::NotAuthorized, ErrorModule::OS,
|
||||||
|
ErrorSummary::WrongArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD9001BEA
|
||||||
|
constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD8E007ED
|
||||||
|
constexpr ResultCode ERR_INVALID_ENUM_VALUE_FND(ErrorDescription::InvalidEnumValue,
|
||||||
|
ErrorModule::FND, ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD8E093ED
|
||||||
|
constexpr ResultCode ERR_INVALID_COMBINATION(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BEE
|
||||||
|
constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorDescription::InvalidCombination,
|
||||||
|
ErrorModule::Kernel,
|
||||||
|
ErrorSummary::WrongArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD90007EE
|
||||||
|
constexpr ResultCode ERR_MISALIGNED_ADDRESS(ErrorDescription::MisalignedAddress, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BF1
|
||||||
|
constexpr ResultCode ERR_MISALIGNED_SIZE(ErrorDescription::MisalignedSize, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BF2
|
||||||
|
constexpr ResultCode ERR_OUT_OF_MEMORY(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::OutOfResource,
|
||||||
|
ErrorLevel::Permanent); // 0xD86007F3
|
||||||
|
constexpr ResultCode ERR_NOT_IMPLEMENTED(ErrorDescription::NotImplemented, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BF4
|
||||||
|
constexpr ResultCode ERR_INVALID_ADDRESS(ErrorDescription::InvalidAddress, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BF5
|
||||||
|
constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorDescription::InvalidAddress, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidState,
|
||||||
|
ErrorLevel::Usage); // 0xE0A01BF5
|
||||||
|
constexpr ResultCode ERR_INVALID_POINTER(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD8E007F6
|
||||||
|
constexpr ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD8E007F7
|
||||||
|
/// Alternate code returned instead of ERR_INVALID_HANDLE in some code paths.
|
||||||
|
constexpr ResultCode ERR_INVALID_HANDLE_OS(ErrorDescription::InvalidHandle, ErrorModule::OS,
|
||||||
|
ErrorSummary::WrongArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD9001BF7
|
||||||
|
constexpr ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
|
||||||
|
constexpr ResultCode ERR_OUT_OF_RANGE(ErrorDescription::OutOfRange, ErrorModule::OS,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Usage); // 0xE0E01BFD
|
||||||
|
constexpr ResultCode ERR_OUT_OF_RANGE_KERNEL(ErrorDescription::OutOfRange, ErrorModule::Kernel,
|
||||||
|
ErrorSummary::InvalidArgument,
|
||||||
|
ErrorLevel::Permanent); // 0xD8E007FD
|
||||||
|
constexpr ResultCode RESULT_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS,
|
||||||
|
ErrorSummary::StatusChanged, ErrorLevel::Info);
|
||||||
|
|
||||||
|
} // namespace Kernel
|
@ -6,6 +6,7 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/hle/config_mem.h"
|
#include "core/hle/config_mem.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
|
@ -19,13 +19,6 @@ using Handle = u32;
|
|||||||
|
|
||||||
class Thread;
|
class Thread;
|
||||||
|
|
||||||
// TODO: Verify code
|
|
||||||
const ResultCode ERR_OUT_OF_HANDLES(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
|
|
||||||
ErrorSummary::OutOfResource, ErrorLevel::Temporary);
|
|
||||||
// TOOD: Verify code
|
|
||||||
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::Kernel,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
||||||
|
|
||||||
enum KernelHandle : Handle {
|
enum KernelHandle : Handle {
|
||||||
CurrentThread = 0xFFFF8000,
|
CurrentThread = 0xFFFF8000,
|
||||||
CurrentProcess = 0xFFFF8001,
|
CurrentProcess = 0xFFFF8001,
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/kernel/process.h"
|
#include "core/hle/kernel/process.h"
|
||||||
#include "core/hle/kernel/resource_limit.h"
|
#include "core/hle/kernel/resource_limit.h"
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/semaphore.h"
|
#include "core/hle/kernel/semaphore.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
@ -16,8 +17,7 @@ ResultVal<SharedPtr<Semaphore>> Semaphore::Create(s32 initial_count, s32 max_cou
|
|||||||
std::string name) {
|
std::string name) {
|
||||||
|
|
||||||
if (initial_count > max_count)
|
if (initial_count > max_count)
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::Kernel,
|
return ERR_INVALID_COMBINATION_KERNEL;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
|
||||||
|
|
||||||
SharedPtr<Semaphore> semaphore(new Semaphore);
|
SharedPtr<Semaphore> semaphore(new Semaphore);
|
||||||
|
|
||||||
@ -42,8 +42,7 @@ void Semaphore::Acquire(Thread* thread) {
|
|||||||
|
|
||||||
ResultVal<s32> Semaphore::Release(s32 release_count) {
|
ResultVal<s32> Semaphore::Release(s32 release_count) {
|
||||||
if (max_count - available_count < release_count)
|
if (max_count - available_count < release_count)
|
||||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel,
|
return ERR_OUT_OF_RANGE_KERNEL;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
||||||
|
|
||||||
s32 previous_count = available_count;
|
s32 previous_count = available_count;
|
||||||
available_count += release_count;
|
available_count += release_count;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/kernel/shared_memory.h"
|
#include "core/hle/kernel/shared_memory.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
@ -102,24 +103,21 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
|||||||
|
|
||||||
// Automatically allocated memory blocks can only be mapped with other_permissions = DontCare
|
// Automatically allocated memory blocks can only be mapped with other_permissions = DontCare
|
||||||
if (base_address == 0 && other_permissions != MemoryPermission::DontCare) {
|
if (base_address == 0 && other_permissions != MemoryPermission::DontCare) {
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
return ERR_INVALID_COMBINATION;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error out if the requested permissions don't match what the creator process allows.
|
// Error out if the requested permissions don't match what the creator process allows.
|
||||||
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
|
if (static_cast<u32>(permissions) & ~static_cast<u32>(own_other_permissions)) {
|
||||||
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
||||||
GetObjectId(), address, name.c_str());
|
GetObjectId(), address, name.c_str());
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
return ERR_INVALID_COMBINATION;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare
|
// Heap-backed memory blocks can not be mapped with other_permissions = DontCare
|
||||||
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
|
if (base_address != 0 && other_permissions == MemoryPermission::DontCare) {
|
||||||
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
||||||
GetObjectId(), address, name.c_str());
|
GetObjectId(), address, name.c_str());
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
return ERR_INVALID_COMBINATION;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error out if the provided permissions are not compatible with what the creator process needs.
|
// Error out if the provided permissions are not compatible with what the creator process needs.
|
||||||
@ -127,8 +125,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
|||||||
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
|
static_cast<u32>(this->permissions) & ~static_cast<u32>(other_permissions)) {
|
||||||
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, permissions don't match",
|
||||||
GetObjectId(), address, name.c_str());
|
GetObjectId(), address, name.c_str());
|
||||||
return ResultCode(ErrorDescription::WrongPermission, ErrorModule::OS,
|
return ERR_WRONG_PERMISSION;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(Subv): Check for the Shared Device Mem flag in the creator process.
|
// TODO(Subv): Check for the Shared Device Mem flag in the creator process.
|
||||||
@ -144,8 +141,7 @@ ResultCode SharedMemory::Map(Process* target_process, VAddr address, MemoryPermi
|
|||||||
if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
|
if (address < Memory::HEAP_VADDR || address + size >= Memory::SHARED_MEMORY_VADDR_END) {
|
||||||
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, invalid address",
|
LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X name=%s, invalid address",
|
||||||
GetObjectId(), address, name.c_str());
|
GetObjectId(), address, name.c_str());
|
||||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS,
|
return ERR_INVALID_ADDRESS;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "core/arm/skyeye_common/armstate.h"
|
#include "core/arm/skyeye_common/armstate.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/kernel/mutex.h"
|
#include "core/hle/kernel/mutex.h"
|
||||||
@ -241,9 +242,7 @@ static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) {
|
|||||||
for (auto& object : thread->wait_objects)
|
for (auto& object : thread->wait_objects)
|
||||||
object->RemoveWaitingThread(thread.get());
|
object->RemoveWaitingThread(thread.get());
|
||||||
thread->wait_objects.clear();
|
thread->wait_objects.clear();
|
||||||
thread->SetWaitSynchronizationResult(ResultCode(ErrorDescription::Timeout, ErrorModule::OS,
|
thread->SetWaitSynchronizationResult(RESULT_TIMEOUT);
|
||||||
ErrorSummary::StatusChanged,
|
|
||||||
ErrorLevel::Info));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->ResumeFromWait();
|
thread->ResumeFromWait();
|
||||||
@ -351,10 +350,20 @@ static void ResetThreadContext(ARM_Interface::ThreadContext& context, u32 stack_
|
|||||||
context.cpsr = USER32MODE | ((entry_point & 1) << 5); // Usermode and THUMB mode
|
context.cpsr = USER32MODE | ((entry_point & 1) << 5); // Usermode and THUMB mode
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority,
|
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, u32 priority,
|
||||||
u32 arg, s32 processor_id, VAddr stack_top) {
|
u32 arg, s32 processor_id, VAddr stack_top) {
|
||||||
ASSERT_MSG(priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST,
|
// Check if priority is in ranged. Lowest priority -> highest priority id.
|
||||||
"Invalid thread priority");
|
if (priority > THREADPRIO_LOWEST) {
|
||||||
|
LOG_ERROR(Kernel_SVC, "Invalid thread priority: %d", priority);
|
||||||
|
return ERR_OUT_OF_RANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processor_id > THREADPROCESSORID_MAX) {
|
||||||
|
LOG_ERROR(Kernel_SVC, "Invalid processor id: %d", processor_id);
|
||||||
|
return ERR_OUT_OF_RANGE_KERNEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(yuriks): Other checks, returning 0xD9001BEA
|
||||||
|
|
||||||
if (!Memory::IsValidVirtualAddress(entry_point)) {
|
if (!Memory::IsValidVirtualAddress(entry_point)) {
|
||||||
LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point);
|
LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point);
|
||||||
@ -399,8 +408,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
|
|||||||
if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) {
|
if (linheap_memory->size() + Memory::PAGE_SIZE > memory_region->size) {
|
||||||
LOG_ERROR(Kernel_SVC,
|
LOG_ERROR(Kernel_SVC,
|
||||||
"Not enough space in region to allocate a new TLS page for thread");
|
"Not enough space in region to allocate a new TLS page for thread");
|
||||||
return ResultCode(ErrorDescription::OutOfMemory, ErrorModule::Kernel,
|
return ERR_OUT_OF_MEMORY;
|
||||||
ErrorSummary::OutOfResource, ErrorLevel::Permanent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 offset = linheap_memory->size();
|
u32 offset = linheap_memory->size();
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
* @param stack_top The address of the thread's stack top
|
* @param stack_top The address of the thread's stack top
|
||||||
* @return A shared pointer to the newly created thread
|
* @return A shared pointer to the newly created thread
|
||||||
*/
|
*/
|
||||||
static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority,
|
static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority,
|
||||||
u32 arg, s32 processor_id, VAddr stack_top);
|
u32 arg, s32 processor_id, VAddr stack_top);
|
||||||
|
|
||||||
std::string GetName() const override {
|
std::string GetName() const override {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/vm_manager.h"
|
#include "core/hle/kernel/vm_manager.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "core/memory_setup.h"
|
#include "core/memory_setup.h"
|
||||||
|
@ -13,14 +13,6 @@
|
|||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
const ResultCode ERR_INVALID_ADDRESS{// 0xE0E01BF5
|
|
||||||
ErrorDescription::InvalidAddress, ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage};
|
|
||||||
|
|
||||||
const ResultCode ERR_INVALID_ADDRESS_STATE{// 0xE0A01BF5
|
|
||||||
ErrorDescription::InvalidAddress, ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Usage};
|
|
||||||
|
|
||||||
enum class VMAType : u8 {
|
enum class VMAType : u8 {
|
||||||
/// VMA represents an unmapped region of the address space.
|
/// VMA represents an unmapped region of the address space.
|
||||||
Free,
|
Free,
|
||||||
|
@ -21,12 +21,6 @@
|
|||||||
enum class ErrorDescription : u32 {
|
enum class ErrorDescription : u32 {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
|
|
||||||
SessionClosedByRemote = 26,
|
|
||||||
WrongPermission = 46,
|
|
||||||
OS_InvalidBufferDescriptor = 48,
|
|
||||||
MaxConnectionsReached = 52,
|
|
||||||
WrongAddress = 53,
|
|
||||||
|
|
||||||
// Codes 1000 and above are considered "well-known" and have common values between all modules.
|
// Codes 1000 and above are considered "well-known" and have common values between all modules.
|
||||||
InvalidSection = 1000,
|
InvalidSection = 1000,
|
||||||
TooLarge = 1001,
|
TooLarge = 1001,
|
||||||
|
@ -24,9 +24,7 @@ void InitializeSession(Service::Interface* self) {
|
|||||||
|
|
||||||
if (translation != IPC::CallingPidDesc()) {
|
if (translation != IPC::CallingPidDesc()) {
|
||||||
cmd_buff[0] = IPC::MakeHeader(0, 0x1, 0); // 0x40
|
cmd_buff[0] = IPC::MakeHeader(0, 0x1, 0); // 0x40
|
||||||
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
|
cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
|
|
||||||
.raw;
|
|
||||||
LOG_ERROR(Service_BOSS, "The translation was invalid, translation=0x%08X", translation);
|
LOG_ERROR(Service_BOSS, "The translation was invalid, translation=0x%08X", translation);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -289,9 +289,7 @@ static void WriteProcessPipe(Service::Interface* self) {
|
|||||||
"size=0x%X, buffer=0x%08X",
|
"size=0x%X, buffer=0x%08X",
|
||||||
cmd_buff[3], pipe_index, size, buffer);
|
cmd_buff[3], pipe_index, size, buffer);
|
||||||
cmd_buff[0] = IPC::MakeHeader(0, 1, 0);
|
cmd_buff[0] = IPC::MakeHeader(0, 1, 0);
|
||||||
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
|
cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
|
|
||||||
.raw;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,9 +801,7 @@ static void InitializeWithSdkVersion(Service::Interface* self) {
|
|||||||
cmd_buff[1] = RESULT_SUCCESS.raw;
|
cmd_buff[1] = RESULT_SUCCESS.raw;
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Service_FS, "ProcessId Header must be 0x20");
|
LOG_ERROR(Service_FS, "ProcessId Header must be 0x20");
|
||||||
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
|
cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
|
|
||||||
.raw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,8 +267,7 @@ static void InitializeIrNopShared(Interface* self) {
|
|||||||
shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
|
shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
|
||||||
if (!shared_memory) {
|
if (!shared_memory) {
|
||||||
LOG_CRITICAL(Service_IR, "invalid shared memory handle 0x%08X", handle);
|
LOG_CRITICAL(Service_IR, "invalid shared memory handle 0x%08X", handle);
|
||||||
rb.Push(ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS,
|
rb.Push(IPC::ERR_INVALID_HANDLE);
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shared_memory->name = "IR_USER: shared memory";
|
shared_memory->name = "IR_USER: shared memory";
|
||||||
|
@ -30,9 +30,7 @@ static void RegisterClient(Interface* self) {
|
|||||||
|
|
||||||
if (cmd_buff[1] != IPC::CallingPidDesc()) {
|
if (cmd_buff[1] != IPC::CallingPidDesc()) {
|
||||||
cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40
|
cmd_buff[0] = IPC::MakeHeader(0x0, 0x1, 0); // 0x40
|
||||||
cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,
|
cmd_buff[1] = IPC::ERR_INVALID_BUFFER_DESCRIPTOR.raw;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent)
|
|
||||||
.raw;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040
|
cmd_buff[0] = IPC::MakeHeader(0x1, 0x1, 0); // 0x10040
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "core/hle/kernel/address_arbiter.h"
|
#include "core/hle/kernel/address_arbiter.h"
|
||||||
#include "core/hle/kernel/client_port.h"
|
#include "core/hle/kernel/client_port.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
|
#include "core/hle/kernel/errors.h"
|
||||||
#include "core/hle/kernel/event.h"
|
#include "core/hle/kernel/event.h"
|
||||||
#include "core/hle/kernel/memory.h"
|
#include "core/hle/kernel/memory.h"
|
||||||
#include "core/hle/kernel/mutex.h"
|
#include "core/hle/kernel/mutex.h"
|
||||||
@ -37,25 +38,6 @@ using Kernel::ERR_INVALID_HANDLE;
|
|||||||
|
|
||||||
namespace SVC {
|
namespace SVC {
|
||||||
|
|
||||||
const ResultCode ERR_NOT_FOUND(ErrorDescription::NotFound, ErrorModule::Kernel,
|
|
||||||
ErrorSummary::NotFound, ErrorLevel::Permanent); // 0xD88007FA
|
|
||||||
const ResultCode ERR_PORT_NAME_TOO_LONG(ErrorDescription(30), ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidArgument,
|
|
||||||
ErrorLevel::Usage); // 0xE0E0181E
|
|
||||||
|
|
||||||
const ResultCode ERR_SYNC_TIMEOUT(ErrorDescription::Timeout, ErrorModule::OS,
|
|
||||||
ErrorSummary::StatusChanged, ErrorLevel::Info);
|
|
||||||
|
|
||||||
const ResultCode ERR_MISALIGNED_ADDRESS{// 0xE0E01BF1
|
|
||||||
ErrorDescription::MisalignedAddress, ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage};
|
|
||||||
const ResultCode ERR_MISALIGNED_SIZE{// 0xE0E01BF2
|
|
||||||
ErrorDescription::MisalignedSize, ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage};
|
|
||||||
const ResultCode ERR_INVALID_COMBINATION{// 0xE0E01BEE
|
|
||||||
ErrorDescription::InvalidCombination, ErrorModule::OS,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage};
|
|
||||||
|
|
||||||
enum ControlMemoryOperation {
|
enum ControlMemoryOperation {
|
||||||
MEMOP_FREE = 1,
|
MEMOP_FREE = 1,
|
||||||
MEMOP_RESERVE = 2, // This operation seems to be unsupported in the kernel
|
MEMOP_RESERVE = 2, // This operation seems to be unsupported in the kernel
|
||||||
@ -195,8 +177,7 @@ static ResultCode MapMemoryBlock(Kernel::Handle handle, u32 addr, u32 permission
|
|||||||
LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions);
|
LOG_ERROR(Kernel_SVC, "unknown permissions=0x%08X", permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
return Kernel::ERR_INVALID_COMBINATION;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {
|
static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {
|
||||||
@ -216,16 +197,16 @@ static ResultCode UnmapMemoryBlock(Kernel::Handle handle, u32 addr) {
|
|||||||
/// Connect to an OS service given the port name, returns the handle to the port to out
|
/// Connect to an OS service given the port name, returns the handle to the port to out
|
||||||
static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) {
|
static ResultCode ConnectToPort(Kernel::Handle* out_handle, const char* port_name) {
|
||||||
if (port_name == nullptr)
|
if (port_name == nullptr)
|
||||||
return ERR_NOT_FOUND;
|
return Kernel::ERR_NOT_FOUND;
|
||||||
if (std::strlen(port_name) > 11)
|
if (std::strlen(port_name) > 11)
|
||||||
return ERR_PORT_NAME_TOO_LONG;
|
return Kernel::ERR_PORT_NAME_TOO_LONG;
|
||||||
|
|
||||||
LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name);
|
LOG_TRACE(Kernel_SVC, "called port_name=%s", port_name);
|
||||||
|
|
||||||
auto it = Service::g_kernel_named_ports.find(port_name);
|
auto it = Service::g_kernel_named_ports.find(port_name);
|
||||||
if (it == Service::g_kernel_named_ports.end()) {
|
if (it == Service::g_kernel_named_ports.end()) {
|
||||||
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name);
|
LOG_WARNING(Kernel_SVC, "tried to connect to unknown port: %s", port_name);
|
||||||
return ERR_NOT_FOUND;
|
return Kernel::ERR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto client_port = it->second;
|
auto client_port = it->second;
|
||||||
@ -275,7 +256,7 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds)
|
|||||||
if (object->ShouldWait(thread)) {
|
if (object->ShouldWait(thread)) {
|
||||||
|
|
||||||
if (nano_seconds == 0)
|
if (nano_seconds == 0)
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
|
|
||||||
thread->wait_objects = {object};
|
thread->wait_objects = {object};
|
||||||
object->AddWaitingThread(thread);
|
object->AddWaitingThread(thread);
|
||||||
@ -289,7 +270,7 @@ static ResultCode WaitSynchronization1(Kernel::Handle handle, s64 nano_seconds)
|
|||||||
// Note: The output of this SVC will be set to RESULT_SUCCESS if the thread
|
// Note: The output of this SVC will be set to RESULT_SUCCESS if the thread
|
||||||
// resumes due to a signal in its wait objects.
|
// resumes due to a signal in its wait objects.
|
||||||
// Otherwise we retain the default value of timeout.
|
// Otherwise we retain the default value of timeout.
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
object->Acquire(thread);
|
object->Acquire(thread);
|
||||||
@ -304,8 +285,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
|
|
||||||
// Check if 'handles' is invalid
|
// Check if 'handles' is invalid
|
||||||
if (handles == nullptr)
|
if (handles == nullptr)
|
||||||
return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel,
|
return Kernel::ERR_INVALID_POINTER;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
||||||
|
|
||||||
// NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
|
// NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
|
||||||
// this happens, the running application will crash.
|
// this happens, the running application will crash.
|
||||||
@ -313,8 +293,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
|
|
||||||
// Check if 'handle_count' is invalid
|
// Check if 'handle_count' is invalid
|
||||||
if (handle_count < 0)
|
if (handle_count < 0)
|
||||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
|
return Kernel::ERR_OUT_OF_RANGE;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
|
|
||||||
using ObjectPtr = Kernel::SharedPtr<Kernel::WaitObject>;
|
using ObjectPtr = Kernel::SharedPtr<Kernel::WaitObject>;
|
||||||
std::vector<ObjectPtr> objects(handle_count);
|
std::vector<ObjectPtr> objects(handle_count);
|
||||||
@ -344,7 +323,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
// If a timeout value of 0 was provided, just return the Timeout error code instead of
|
// If a timeout value of 0 was provided, just return the Timeout error code instead of
|
||||||
// suspending the thread.
|
// suspending the thread.
|
||||||
if (nano_seconds == 0)
|
if (nano_seconds == 0)
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
|
|
||||||
// Put the thread to sleep
|
// Put the thread to sleep
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ALL;
|
thread->status = THREADSTATUS_WAIT_SYNCH_ALL;
|
||||||
@ -365,7 +344,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
*out = -1;
|
*out = -1;
|
||||||
// Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to
|
// Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to
|
||||||
// a signal in one of its wait objects.
|
// a signal in one of its wait objects.
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
// Find the first object that is acquirable in the provided list of objects
|
// Find the first object that is acquirable in the provided list of objects
|
||||||
auto itr = std::find_if(objects.begin(), objects.end(), [thread](const ObjectPtr& object) {
|
auto itr = std::find_if(objects.begin(), objects.end(), [thread](const ObjectPtr& object) {
|
||||||
@ -385,7 +364,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
// If a timeout value of 0 was provided, just return the Timeout error code instead of
|
// If a timeout value of 0 was provided, just return the Timeout error code instead of
|
||||||
// suspending the thread.
|
// suspending the thread.
|
||||||
if (nano_seconds == 0)
|
if (nano_seconds == 0)
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
|
|
||||||
// Put the thread to sleep
|
// Put the thread to sleep
|
||||||
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
thread->status = THREADSTATUS_WAIT_SYNCH_ANY;
|
||||||
@ -411,7 +390,7 @@ static ResultCode WaitSynchronizationN(s32* out, Kernel::Handle* handles, s32 ha
|
|||||||
// Otherwise we retain the default value of timeout, and -1 in the out parameter
|
// Otherwise we retain the default value of timeout, and -1 in the out parameter
|
||||||
thread->wait_set_output = true;
|
thread->wait_set_output = true;
|
||||||
*out = -1;
|
*out = -1;
|
||||||
return ERR_SYNC_TIMEOUT;
|
return Kernel::RESULT_TIMEOUT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,22 +499,20 @@ static ResultCode GetResourceLimitLimitValues(s64* values, Kernel::Handle resour
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new thread
|
/// Creates a new thread
|
||||||
static ResultCode CreateThread(Kernel::Handle* out_handle, s32 priority, u32 entry_point, u32 arg,
|
static ResultCode CreateThread(Kernel::Handle* out_handle, u32 priority, u32 entry_point, u32 arg,
|
||||||
u32 stack_top, s32 processor_id) {
|
u32 stack_top, s32 processor_id) {
|
||||||
using Kernel::Thread;
|
using Kernel::Thread;
|
||||||
|
|
||||||
std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point);
|
std::string name = Common::StringFromFormat("unknown-%08" PRIX32, entry_point);
|
||||||
|
|
||||||
if (priority > THREADPRIO_LOWEST) {
|
if (priority > THREADPRIO_LOWEST) {
|
||||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
|
return Kernel::ERR_OUT_OF_RANGE;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using Kernel::ResourceLimit;
|
using Kernel::ResourceLimit;
|
||||||
Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
|
Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
|
||||||
if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
|
if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
|
||||||
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS,
|
return Kernel::ERR_NOT_AUTHORIZED;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (processor_id) {
|
switch (processor_id) {
|
||||||
@ -605,8 +582,7 @@ static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) {
|
|||||||
/// Sets the priority for the specified thread
|
/// Sets the priority for the specified thread
|
||||||
static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
|
static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
|
||||||
if (priority > THREADPRIO_LOWEST) {
|
if (priority > THREADPRIO_LOWEST) {
|
||||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
|
return Kernel::ERR_OUT_OF_RANGE;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
|
SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
|
||||||
@ -618,8 +594,7 @@ static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
|
|||||||
// the one from the thread owner's resource limit.
|
// the one from the thread owner's resource limit.
|
||||||
Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
|
Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
|
||||||
if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
|
if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
|
||||||
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS,
|
return Kernel::ERR_NOT_AUTHORIZED;
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->SetPriority(priority);
|
thread->SetPriority(priority);
|
||||||
@ -743,8 +718,7 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* page_inf
|
|||||||
auto vma = process->vm_manager.FindVMA(addr);
|
auto vma = process->vm_manager.FindVMA(addr);
|
||||||
|
|
||||||
if (vma == Kernel::g_current_process->vm_manager.vma_map.end())
|
if (vma == Kernel::g_current_process->vm_manager.vma_map.end())
|
||||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS,
|
return Kernel::ERR_INVALID_ADDRESS;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
|
|
||||||
memory_info->base_address = vma->second.base;
|
memory_info->base_address = vma->second.base;
|
||||||
memory_info->permission = static_cast<u32>(vma->second.permissions);
|
memory_info->permission = static_cast<u32>(vma->second.permissions);
|
||||||
@ -842,8 +816,7 @@ static ResultCode SetTimer(Kernel::Handle handle, s64 initial, s64 interval) {
|
|||||||
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
|
LOG_TRACE(Kernel_SVC, "called timer=0x%08X", handle);
|
||||||
|
|
||||||
if (initial < 0 || interval < 0) {
|
if (initial < 0 || interval < 0) {
|
||||||
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::Kernel,
|
return Kernel::ERR_OUT_OF_RANGE_KERNEL;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
SharedPtr<Timer> timer = Kernel::g_handle_table.Get<Timer>(handle);
|
||||||
@ -902,8 +875,7 @@ static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 si
|
|||||||
using Kernel::SharedMemory;
|
using Kernel::SharedMemory;
|
||||||
|
|
||||||
if (size % Memory::PAGE_SIZE != 0)
|
if (size % Memory::PAGE_SIZE != 0)
|
||||||
return ResultCode(ErrorDescription::MisalignedSize, ErrorModule::OS,
|
return Kernel::ERR_MISALIGNED_SIZE;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
|
|
||||||
SharedPtr<SharedMemory> shared_memory = nullptr;
|
SharedPtr<SharedMemory> shared_memory = nullptr;
|
||||||
|
|
||||||
@ -924,16 +896,14 @@ static ResultCode CreateMemoryBlock(Kernel::Handle* out_handle, u32 addr, u32 si
|
|||||||
|
|
||||||
if (!VerifyPermissions(static_cast<MemoryPermission>(my_permission)) ||
|
if (!VerifyPermissions(static_cast<MemoryPermission>(my_permission)) ||
|
||||||
!VerifyPermissions(static_cast<MemoryPermission>(other_permission)))
|
!VerifyPermissions(static_cast<MemoryPermission>(other_permission)))
|
||||||
return ResultCode(ErrorDescription::InvalidCombination, ErrorModule::OS,
|
return Kernel::ERR_INVALID_COMBINATION;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
|
|
||||||
// TODO(Subv): Processes with memory type APPLICATION are not allowed
|
// TODO(Subv): Processes with memory type APPLICATION are not allowed
|
||||||
// to create memory blocks with addr = 0, any attempts to do so
|
// to create memory blocks with addr = 0, any attempts to do so
|
||||||
// should return error 0xD92007EA.
|
// should return error 0xD92007EA.
|
||||||
if ((addr < Memory::PROCESS_IMAGE_VADDR || addr + size > Memory::SHARED_MEMORY_VADDR_END) &&
|
if ((addr < Memory::PROCESS_IMAGE_VADDR || addr + size > Memory::SHARED_MEMORY_VADDR_END) &&
|
||||||
addr != 0) {
|
addr != 0) {
|
||||||
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::OS,
|
return Kernel::ERR_INVALID_ADDRESS;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When trying to create a memory block with address = 0,
|
// When trying to create a memory block with address = 0,
|
||||||
@ -1035,7 +1005,7 @@ static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 ty
|
|||||||
*out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
|
*out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
|
||||||
if (*out % Memory::PAGE_SIZE != 0) {
|
if (*out % Memory::PAGE_SIZE != 0) {
|
||||||
LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned");
|
LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned");
|
||||||
return ERR_MISALIGNED_SIZE;
|
return Kernel::ERR_MISALIGNED_SIZE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -1051,19 +1021,15 @@ static ResultCode GetProcessInfo(s64* out, Kernel::Handle process_handle, u32 ty
|
|||||||
case 20:
|
case 20:
|
||||||
*out = Memory::FCRAM_PADDR - process->GetLinearHeapBase();
|
*out = Memory::FCRAM_PADDR - process->GetLinearHeapBase();
|
||||||
break;
|
break;
|
||||||
|
case 21:
|
||||||
|
case 22:
|
||||||
|
case 23:
|
||||||
|
// These return a different error value than higher invalid values
|
||||||
|
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type);
|
||||||
|
return Kernel::ERR_NOT_IMPLEMENTED;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type);
|
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type);
|
||||||
|
return Kernel::ERR_INVALID_ENUM_VALUE;
|
||||||
if (type >= 21 && type <= 23) {
|
|
||||||
return ResultCode( // 0xE0E01BF4
|
|
||||||
ErrorDescription::NotImplemented, ErrorModule::OS, ErrorSummary::InvalidArgument,
|
|
||||||
ErrorLevel::Usage);
|
|
||||||
} else {
|
|
||||||
return ResultCode( // 0xD8E007ED
|
|
||||||
ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
|
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
|
Loading…
Reference in New Issue
Block a user