Kernel/Thread: move thread queue, current thread, and scheduling related function into the manager

As we touched it, remove IPC::GetCommandBuffer
This commit is contained in:
Weiyi Wang 2018-10-23 11:40:57 -04:00
parent 876729ab52
commit 0478bc3dee
14 changed files with 123 additions and 146 deletions

View file

@ -71,7 +71,8 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(buffer);
std::chrono::nanoseconds read_timeout_ns{backend->GetReadDelayNs(length)};
ctx.SleepClientThread(Kernel::GetCurrentThread(), "file::read", read_timeout_ns,
ctx.SleepClientThread(system.Kernel().GetThreadManager().GetCurrentThread(), "file::read",
read_timeout_ns,
[](Kernel::SharedPtr<Kernel::Thread> thread,
Kernel::HLERequestContext& ctx, Kernel::ThreadWakeupReason reason) {
// Nothing to do here

View file

@ -1231,7 +1231,8 @@ void NWM_UDS::ConnectToNetwork(Kernel::HLERequestContext& ctx) {
static constexpr std::chrono::nanoseconds UDSConnectionTimeout{300000000};
connection_event = ctx.SleepClientThread(
Kernel::GetCurrentThread(), "uds::ConnectToNetwork", UDSConnectionTimeout,
system.Kernel().GetThreadManager().GetCurrentThread(), "uds::ConnectToNetwork",
UDSConnectionTimeout,
[](Kernel::SharedPtr<Kernel::Thread> thread, Kernel::HLERequestContext& ctx,
Kernel::ThreadWakeupReason reason) {
// TODO(B3N30): Add error handling for host full and timeout

View file

@ -179,7 +179,10 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(u32* cmd_buf, const Funct
}
void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_session) {
u32* cmd_buf = Kernel::GetCommandBuffer();
Kernel::KernelSystem& kernel = Core::System::GetInstance().Kernel();
auto thread = kernel.GetThreadManager().GetCurrentThread();
// TODO(wwylele): avoid GetPointer
u32* cmd_buf = reinterpret_cast<u32*>(Memory::GetPointer(thread->GetCommandBufferAddress()));
u32 header_code = cmd_buf[0];
auto itr = handlers.find(header_code);
@ -188,8 +191,7 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
return ReportUnimplementedFunction(cmd_buf, info);
}
Kernel::SharedPtr<Kernel::Process> current_process =
Core::System::GetInstance().Kernel().GetCurrentProcess();
Kernel::SharedPtr<Kernel::Process> current_process = kernel.GetCurrentProcess();
// TODO(yuriks): The kernel should be the one handling this as part of translation after
// everything else is migrated
@ -199,7 +201,6 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
LOG_TRACE(Service, "{}", MakeFunctionString(info->name, GetServiceName().c_str(), cmd_buf));
handler_invoker(this, info->handler_callback, context);
auto thread = Kernel::GetCurrentThread();
ASSERT(thread->status == Kernel::ThreadStatus::Running ||
thread->status == Kernel::ThreadStatus::WaitHleEvent);
// Only write the response immediately if the thread is still running. If the HLE handler put

View file

@ -128,8 +128,8 @@ void SRV::GetServiceHandle(Kernel::HLERequestContext& ctx) {
if (wait_until_available && client_port.Code() == ERR_SERVICE_NOT_REGISTERED) {
LOG_INFO(Service_SRV, "called service={} delayed", name);
Kernel::SharedPtr<Kernel::Event> get_service_handle_event =
ctx.SleepClientThread(Kernel::GetCurrentThread(), "GetServiceHandle",
std::chrono::nanoseconds(-1), get_handle);
ctx.SleepClientThread(system.Kernel().GetThreadManager().GetCurrentThread(),
"GetServiceHandle", std::chrono::nanoseconds(-1), get_handle);
get_service_handle_delayed_map[name] = std::move(get_service_handle_event);
return;
} else {