|
|
@ -995,22 +995,11 @@ std::shared_ptr<Common::Fiber>& KThread::GetHostContext() {
|
|
|
|
return host_context;
|
|
|
|
return host_context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, ThreadType type_flags,
|
|
|
|
ResultVal<std::shared_ptr<KThread>> KThread::CreateThread(Core::System& system,
|
|
|
|
std::string name, VAddr entry_point,
|
|
|
|
ThreadType type_flags, std::string name,
|
|
|
|
u32 priority, u64 arg, s32 processor_id,
|
|
|
|
VAddr entry_point, u32 priority, u64 arg,
|
|
|
|
VAddr stack_top, Process* owner_process) {
|
|
|
|
s32 processor_id, VAddr stack_top,
|
|
|
|
std::function<void(void*)> init_func = Core::CpuManager::GetGuestThreadStartFunc();
|
|
|
|
Process* owner_process) {
|
|
|
|
void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater();
|
|
|
|
|
|
|
|
return Create(system, type_flags, name, entry_point, priority, arg, processor_id, stack_top,
|
|
|
|
|
|
|
|
owner_process, std::move(init_func), init_func_parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, ThreadType type_flags,
|
|
|
|
|
|
|
|
std::string name, VAddr entry_point,
|
|
|
|
|
|
|
|
u32 priority, u64 arg, s32 processor_id,
|
|
|
|
|
|
|
|
VAddr stack_top, Process* owner_process,
|
|
|
|
|
|
|
|
std::function<void(void*)>&& thread_start_func,
|
|
|
|
|
|
|
|
void* thread_start_parameter) {
|
|
|
|
|
|
|
|
auto& kernel = system.Kernel();
|
|
|
|
auto& kernel = system.Kernel();
|
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<KThread> thread = std::make_shared<KThread>(kernel);
|
|
|
|
std::shared_ptr<KThread> thread = std::make_shared<KThread>(kernel);
|
|
|
@ -1027,12 +1016,35 @@ ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, Thread
|
|
|
|
auto& scheduler = kernel.GlobalSchedulerContext();
|
|
|
|
auto& scheduler = kernel.GlobalSchedulerContext();
|
|
|
|
scheduler.AddThread(thread);
|
|
|
|
scheduler.AddThread(thread);
|
|
|
|
|
|
|
|
|
|
|
|
thread->host_context =
|
|
|
|
|
|
|
|
std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return MakeResult<std::shared_ptr<KThread>>(std::move(thread));
|
|
|
|
return MakeResult<std::shared_ptr<KThread>>(std::move(thread));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<std::shared_ptr<KThread>> KThread::CreateThread(
|
|
|
|
|
|
|
|
Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, u32 priority,
|
|
|
|
|
|
|
|
u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process,
|
|
|
|
|
|
|
|
std::function<void(void*)>&& thread_start_func, void* thread_start_parameter) {
|
|
|
|
|
|
|
|
auto thread_result = CreateThread(system, type_flags, name, entry_point, priority, arg,
|
|
|
|
|
|
|
|
processor_id, stack_top, owner_process);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (thread_result.Succeeded()) {
|
|
|
|
|
|
|
|
(*thread_result)->host_context =
|
|
|
|
|
|
|
|
std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return thread_result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultVal<std::shared_ptr<KThread>> KThread::CreateUserThread(
|
|
|
|
|
|
|
|
Core::System& system, ThreadType type_flags, std::string name, VAddr entry_point, u32 priority,
|
|
|
|
|
|
|
|
u64 arg, s32 processor_id, VAddr stack_top, Process* owner_process) {
|
|
|
|
|
|
|
|
std::function<void(void*)> init_func = Core::CpuManager::GetGuestThreadStartFunc();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CreateThread(system, type_flags, name, entry_point, priority, arg, processor_id,
|
|
|
|
|
|
|
|
stack_top, owner_process, std::move(init_func), init_func_parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KThread* GetCurrentThreadPointer(KernelCore& kernel) {
|
|
|
|
KThread* GetCurrentThreadPointer(KernelCore& kernel) {
|
|
|
|
return kernel.GetCurrentEmuThread();
|
|
|
|
return kernel.GetCurrentEmuThread();
|
|
|
|
}
|
|
|
|
}
|
|
|
|