|
|
@ -622,7 +622,6 @@ static void Break(Core::System& system, u32 reason, u64 info1, u64 info2) { |
|
|
|
|
|
|
|
|
// Kill the current thread
|
|
|
// Kill the current thread
|
|
|
current_thread->Stop(); |
|
|
current_thread->Stop(); |
|
|
system.PrepareReschedule(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1004,6 +1003,7 @@ static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size |
|
|
/// Sets the thread activity
|
|
|
/// Sets the thread activity
|
|
|
static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 activity) { |
|
|
static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 activity) { |
|
|
LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", handle, activity); |
|
|
LOG_DEBUG(Kernel_SVC, "called, handle=0x{:08X}, activity=0x{:08X}", handle, activity); |
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
if (activity > static_cast<u32>(ThreadActivity::Paused)) { |
|
|
if (activity > static_cast<u32>(ThreadActivity::Paused)) { |
|
|
return ERR_INVALID_ENUM_VALUE; |
|
|
return ERR_INVALID_ENUM_VALUE; |
|
|
} |
|
|
} |
|
|
@ -1032,7 +1032,6 @@ static ResultCode SetThreadActivity(Core::System& system, Handle handle, u32 act |
|
|
|
|
|
|
|
|
thread->SetActivity(static_cast<ThreadActivity>(activity)); |
|
|
thread->SetActivity(static_cast<ThreadActivity>(activity)); |
|
|
|
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID()); |
|
|
|
|
|
return RESULT_SUCCESS; |
|
|
return RESULT_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1385,6 +1384,7 @@ static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_ha |
|
|
/// Exits the current process
|
|
|
/// Exits the current process
|
|
|
static void ExitProcess(Core::System& system) { |
|
|
static void ExitProcess(Core::System& system) { |
|
|
auto* current_process = system.Kernel().CurrentProcess(); |
|
|
auto* current_process = system.Kernel().CurrentProcess(); |
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
|
|
|
|
|
|
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); |
|
|
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessID()); |
|
|
ASSERT_MSG(current_process->GetStatus() == ProcessStatus::Running, |
|
|
ASSERT_MSG(current_process->GetStatus() == ProcessStatus::Running, |
|
|
@ -1394,8 +1394,6 @@ static void ExitProcess(Core::System& system) { |
|
|
|
|
|
|
|
|
// Kill the current thread
|
|
|
// Kill the current thread
|
|
|
system.CurrentScheduler().GetCurrentThread()->Stop(); |
|
|
system.CurrentScheduler().GetCurrentThread()->Stop(); |
|
|
|
|
|
|
|
|
system.PrepareReschedule(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// Creates a new thread
|
|
|
/// Creates a new thread
|
|
|
@ -1458,8 +1456,6 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e |
|
|
thread->SetName( |
|
|
thread->SetName( |
|
|
fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); |
|
|
fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); |
|
|
|
|
|
|
|
|
system.PrepareReschedule(thread->GetProcessorID()); |
|
|
|
|
|
|
|
|
|
|
|
return RESULT_SUCCESS; |
|
|
return RESULT_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1545,6 +1541,8 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add |
|
|
return ERR_INVALID_ADDRESS; |
|
|
return ERR_INVALID_ADDRESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
|
|
|
|
|
|
ASSERT(condition_variable_addr == Common::AlignDown(condition_variable_addr, 4)); |
|
|
ASSERT(condition_variable_addr == Common::AlignDown(condition_variable_addr, 4)); |
|
|
|
|
|
|
|
|
auto* const current_process = system.Kernel().CurrentProcess(); |
|
|
auto* const current_process = system.Kernel().CurrentProcess(); |
|
|
@ -1569,7 +1567,6 @@ static ResultCode WaitProcessWideKeyAtomic(Core::System& system, VAddr mutex_add |
|
|
|
|
|
|
|
|
// Note: Deliberately don't attempt to inherit the lock owner's priority.
|
|
|
// Note: Deliberately don't attempt to inherit the lock owner's priority.
|
|
|
|
|
|
|
|
|
system.PrepareReschedule(current_thread->GetProcessorID()); |
|
|
|
|
|
return RESULT_SUCCESS; |
|
|
return RESULT_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1580,6 +1577,8 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_ |
|
|
|
|
|
|
|
|
ASSERT(condition_variable_addr == Common::AlignDown(condition_variable_addr, 4)); |
|
|
ASSERT(condition_variable_addr == Common::AlignDown(condition_variable_addr, 4)); |
|
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
|
|
|
|
|
|
// Retrieve a list of all threads that are waiting for this condition variable.
|
|
|
// Retrieve a list of all threads that are waiting for this condition variable.
|
|
|
auto* const current_process = system.Kernel().CurrentProcess(); |
|
|
auto* const current_process = system.Kernel().CurrentProcess(); |
|
|
std::vector<std::shared_ptr<Thread>> waiting_threads = |
|
|
std::vector<std::shared_ptr<Thread>> waiting_threads = |
|
|
@ -1634,7 +1633,6 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_ |
|
|
thread->SetMutexWaitAddress(0); |
|
|
thread->SetMutexWaitAddress(0); |
|
|
thread->SetWaitHandle(0); |
|
|
thread->SetWaitHandle(0); |
|
|
thread->SetWaitSynchronizationResult(RESULT_SUCCESS); |
|
|
thread->SetWaitSynchronizationResult(RESULT_SUCCESS); |
|
|
system.PrepareReschedule(thread->GetProcessorID()); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
// The mutex is already owned by some other thread, make this thread wait on it.
|
|
|
// The mutex is already owned by some other thread, make this thread wait on it.
|
|
|
const Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); |
|
|
const Handle owner_handle = static_cast<Handle>(mutex_val & Mutex::MutexOwnerMask); |
|
|
@ -1646,7 +1644,6 @@ static void SignalProcessWideKey(Core::System& system, VAddr condition_variable_ |
|
|
thread->SetStatus(ThreadStatus::WaitMutex); |
|
|
thread->SetStatus(ThreadStatus::WaitMutex); |
|
|
|
|
|
|
|
|
owner->AddMutexWaiter(thread); |
|
|
owner->AddMutexWaiter(thread); |
|
|
system.PrepareReschedule(thread->GetProcessorID()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -1661,6 +1658,7 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, |
|
|
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", address, |
|
|
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, timeout={}", address, |
|
|
type, value, timeout); |
|
|
type, value, timeout); |
|
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
// If the passed address is a kernel virtual address, return invalid memory state.
|
|
|
// If the passed address is a kernel virtual address, return invalid memory state.
|
|
|
if (Core::Memory::IsKernelVirtualAddress(address)) { |
|
|
if (Core::Memory::IsKernelVirtualAddress(address)) { |
|
|
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
|
|
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
|
|
@ -1677,9 +1675,6 @@ static ResultCode WaitForAddress(Core::System& system, VAddr address, u32 type, |
|
|
auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter(); |
|
|
auto& address_arbiter = system.Kernel().CurrentProcess()->GetAddressArbiter(); |
|
|
const ResultCode result = |
|
|
const ResultCode result = |
|
|
address_arbiter.WaitForAddress(address, arbitration_type, value, timeout); |
|
|
address_arbiter.WaitForAddress(address, arbitration_type, value, timeout); |
|
|
if (result == RESULT_SUCCESS) { |
|
|
|
|
|
system.PrepareReschedule(); |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1689,6 +1684,8 @@ static ResultCode SignalToAddress(Core::System& system, VAddr address, u32 type, |
|
|
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", |
|
|
LOG_TRACE(Kernel_SVC, "called, address=0x{:X}, type=0x{:X}, value=0x{:X}, num_to_wake=0x{:X}", |
|
|
address, type, value, num_to_wake); |
|
|
address, type, value, num_to_wake); |
|
|
|
|
|
|
|
|
|
|
|
UNIMPLEMENTED(); |
|
|
|
|
|
|
|
|
// If the passed address is a kernel virtual address, return invalid memory state.
|
|
|
// If the passed address is a kernel virtual address, return invalid memory state.
|
|
|
if (Core::Memory::IsKernelVirtualAddress(address)) { |
|
|
if (Core::Memory::IsKernelVirtualAddress(address)) { |
|
|
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
|
|
LOG_ERROR(Kernel_SVC, "Address is a kernel virtual address, address={:016X}", address); |
|
|
@ -1945,7 +1942,6 @@ static ResultCode SignalEvent(Core::System& system, Handle handle) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
writable_event->Signal(); |
|
|
writable_event->Signal(); |
|
|
system.PrepareReschedule(); |
|
|
|
|
|
return RESULT_SUCCESS; |
|
|
return RESULT_SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|