diff options
| author | 2019-04-19 19:09:20 -0400 | |
|---|---|---|
| committer | 2019-04-19 19:09:20 -0400 | |
| commit | 40dc893c372c81c687eca2d0b964220a8f8aeab4 (patch) | |
| tree | 1c05675d446978752a749f2cb18a797c6b737998 /src/core/core.cpp | |
| parent | Merge pull request #2397 from lioncash/thread-unused (diff) | |
| parent | core/core: Move process execution start to System's Load() (diff) | |
| download | yuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.tar.gz yuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.tar.xz yuzu-40dc893c372c81c687eca2d0b964220a8f8aeab4.zip | |
Merge pull request #2374 from lioncash/pagetable
core: Reorganize boot order
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index bc9e887b6..175a5f2ea 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -3,9 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <map> | ||
| 7 | #include <memory> | 6 | #include <memory> |
| 8 | #include <thread> | ||
| 9 | #include <utility> | 7 | #include <utility> |
| 10 | 8 | ||
| 11 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| @@ -38,8 +36,6 @@ | |||
| 38 | #include "frontend/applets/software_keyboard.h" | 36 | #include "frontend/applets/software_keyboard.h" |
| 39 | #include "frontend/applets/web_browser.h" | 37 | #include "frontend/applets/web_browser.h" |
| 40 | #include "video_core/debug_utils/debug_utils.h" | 38 | #include "video_core/debug_utils/debug_utils.h" |
| 41 | #include "video_core/gpu_asynch.h" | ||
| 42 | #include "video_core/gpu_synch.h" | ||
| 43 | #include "video_core/renderer_base.h" | 39 | #include "video_core/renderer_base.h" |
| 44 | #include "video_core/video_core.h" | 40 | #include "video_core/video_core.h" |
| 45 | 41 | ||
| @@ -81,7 +77,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 81 | return vfs->OpenFile(path, FileSys::Mode::Read); | 77 | return vfs->OpenFile(path, FileSys::Mode::Read); |
| 82 | } | 78 | } |
| 83 | struct System::Impl { | 79 | struct System::Impl { |
| 84 | explicit Impl(System& system) : kernel{system} {} | 80 | explicit Impl(System& system) : kernel{system}, cpu_core_manager{system} {} |
| 85 | 81 | ||
| 86 | Cpu& CurrentCpuCore() { | 82 | Cpu& CurrentCpuCore() { |
| 87 | return cpu_core_manager.GetCurrentCore(); | 83 | return cpu_core_manager.GetCurrentCore(); |
| @@ -99,6 +95,7 @@ struct System::Impl { | |||
| 99 | LOG_DEBUG(HW_Memory, "initialized OK"); | 95 | LOG_DEBUG(HW_Memory, "initialized OK"); |
| 100 | 96 | ||
| 101 | core_timing.Initialize(); | 97 | core_timing.Initialize(); |
| 98 | cpu_core_manager.Initialize(); | ||
| 102 | kernel.Initialize(); | 99 | kernel.Initialize(); |
| 103 | 100 | ||
| 104 | const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( | 101 | const auto current_time = std::chrono::duration_cast<std::chrono::seconds>( |
| @@ -120,9 +117,6 @@ struct System::Impl { | |||
| 120 | if (web_browser == nullptr) | 117 | if (web_browser == nullptr) |
| 121 | web_browser = std::make_unique<Core::Frontend::DefaultWebBrowserApplet>(); | 118 | web_browser = std::make_unique<Core::Frontend::DefaultWebBrowserApplet>(); |
| 122 | 119 | ||
| 123 | auto main_process = Kernel::Process::Create(system, "main"); | ||
| 124 | kernel.MakeCurrentProcess(main_process.get()); | ||
| 125 | |||
| 126 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 120 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| 127 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | 121 | service_manager = std::make_shared<Service::SM::ServiceManager>(); |
| 128 | 122 | ||
| @@ -134,15 +128,9 @@ struct System::Impl { | |||
| 134 | return ResultStatus::ErrorVideoCore; | 128 | return ResultStatus::ErrorVideoCore; |
| 135 | } | 129 | } |
| 136 | 130 | ||
| 137 | is_powered_on = true; | 131 | gpu_core = VideoCore::CreateGPU(system); |
| 138 | |||
| 139 | if (Settings::values.use_asynchronous_gpu_emulation) { | ||
| 140 | gpu_core = std::make_unique<VideoCommon::GPUAsynch>(system, *renderer); | ||
| 141 | } else { | ||
| 142 | gpu_core = std::make_unique<VideoCommon::GPUSynch>(system, *renderer); | ||
| 143 | } | ||
| 144 | 132 | ||
| 145 | cpu_core_manager.Initialize(system); | 133 | is_powered_on = true; |
| 146 | 134 | ||
| 147 | LOG_DEBUG(Core, "Initialized OK"); | 135 | LOG_DEBUG(Core, "Initialized OK"); |
| 148 | 136 | ||
| @@ -179,7 +167,8 @@ struct System::Impl { | |||
| 179 | return init_result; | 167 | return init_result; |
| 180 | } | 168 | } |
| 181 | 169 | ||
| 182 | const Loader::ResultStatus load_result{app_loader->Load(*kernel.CurrentProcess())}; | 170 | auto main_process = Kernel::Process::Create(system, "main"); |
| 171 | const auto [load_result, load_parameters] = app_loader->Load(*main_process); | ||
| 183 | if (load_result != Loader::ResultStatus::Success) { | 172 | if (load_result != Loader::ResultStatus::Success) { |
| 184 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); | 173 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); |
| 185 | Shutdown(); | 174 | Shutdown(); |
| @@ -187,6 +176,16 @@ struct System::Impl { | |||
| 187 | return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + | 176 | return static_cast<ResultStatus>(static_cast<u32>(ResultStatus::ErrorLoader) + |
| 188 | static_cast<u32>(load_result)); | 177 | static_cast<u32>(load_result)); |
| 189 | } | 178 | } |
| 179 | kernel.MakeCurrentProcess(main_process.get()); | ||
| 180 | |||
| 181 | // Main process has been loaded and been made current. | ||
| 182 | // Begin GPU and CPU execution. | ||
| 183 | gpu_core->Start(); | ||
| 184 | cpu_core_manager.StartThreads(); | ||
| 185 | |||
| 186 | // All threads are started, begin main process execution, now that we're in the clear. | ||
| 187 | main_process->Run(load_parameters->main_thread_priority, | ||
| 188 | load_parameters->main_thread_stack_size); | ||
| 190 | 189 | ||
| 191 | status = ResultStatus::Success; | 190 | status = ResultStatus::Success; |
| 192 | return status; | 191 | return status; |