kernel/process: move current process to kernel instance

Two functional change:
QueryProcessMemory uses the process passed from handle instead current_process
Thread::Stop() uses TLS from owner_process instead of current_process
This commit is contained in:
Weiyi Wang 2018-10-17 15:23:56 -04:00
parent d9342622b0
commit 8fb3d8ff38
19 changed files with 96 additions and 55 deletions

View file

@ -258,7 +258,7 @@ ResultVal<AppletManager::InitializeResult> AppletManager::Initialize(AppletId ap
slot_data->applet_id = static_cast<AppletId>(app_id);
// Note: In the real console the title id of a given applet slot is set by the APT module when
// calling StartApplication.
slot_data->title_id = Kernel::g_current_process->codeset->program_id;
slot_data->title_id = system.Kernel().GetCurrentProcess()->codeset->program_id;
slot_data->attributes.raw = attributes.raw;
if (slot_data->applet_id == AppletId::Application ||

View file

@ -97,7 +97,7 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
if (path_type == CecDataPathType::MboxProgramId) {
std::vector<u8> program_id(8);
u64_le le_program_id = Kernel::g_current_process->codeset->program_id;
u64_le le_program_id = cecd->system.Kernel().GetCurrentProcess()->codeset->program_id;
std::memcpy(program_id.data(), &le_program_id, sizeof(u64));
session_data->file->Write(0, sizeof(u64), true, program_id.data());
session_data->file->Close();
@ -1351,7 +1351,7 @@ Module::SessionData::~SessionData() {
Module::Interface::Interface(std::shared_ptr<Module> cecd, const char* name, u32 max_session)
: ServiceFramework(name, max_session), cecd(std::move(cecd)) {}
Module::Module(Core::System& system) {
Module::Module(Core::System& system) : system(system) {
using namespace Kernel;
cecinfo_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "CECD::cecinfo_event");
change_state_event =

View file

@ -610,6 +610,8 @@ private:
Kernel::SharedPtr<Kernel::Event> cecinfo_event;
Kernel::SharedPtr<Kernel::Event> change_state_event;
Core::System& system;
};
/// Initialize CECD service(s)

View file

@ -188,11 +188,13 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
return ReportUnimplementedFunction(cmd_buf, info);
}
Kernel::SharedPtr<Kernel::Process> current_process =
Core::System::GetInstance().Kernel().GetCurrentProcess();
// TODO(yuriks): The kernel should be the one handling this as part of translation after
// everything else is migrated
Kernel::HLERequestContext context(std::move(server_session));
context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
Kernel::g_handle_table);
context.PopulateFromIncomingCommandBuffer(cmd_buf, *current_process, Kernel::g_handle_table);
LOG_TRACE(Service, "{}", MakeFunctionString(info->name, GetServiceName().c_str(), cmd_buf));
handler_invoker(this, info->handler_callback, context);
@ -204,8 +206,7 @@ void ServiceFrameworkBase::HandleSyncRequest(SharedPtr<ServerSession> server_ses
// the thread to sleep then the writing of the command buffer will be deferred to the wakeup
// callback.
if (thread->status == Kernel::ThreadStatus::Running) {
context.WriteToOutgoingCommandBuffer(cmd_buf, *Kernel::g_current_process,
Kernel::g_handle_table);
context.WriteToOutgoingCommandBuffer(cmd_buf, *current_process, Kernel::g_handle_table);
}
}