summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar TheKoopaKingdom2017-03-08 20:21:31 -0500
committerGravatar TheKoopaKingdom2017-06-02 18:28:14 -0400
commit37bec598ea28662462dcaab65d5abd6db8372dbc (patch)
treee1aa020f3884d601182155791d9c474df04fd133 /src/core
parentAdded system for handling core errors in citra-qt. (diff)
downloadyuzu-37bec598ea28662462dcaab65d5abd6db8372dbc.tar.gz
yuzu-37bec598ea28662462dcaab65d5abd6db8372dbc.tar.xz
yuzu-37bec598ea28662462dcaab65d5abd6db8372dbc.zip
Made some changes from review comments:
- Made LoadKernelSystemMode return a pair consisting of a system mode and a result code (Could use review). - Deleted ErrorOpenGL error code in favor of just having ErrorVideoCore. - Made dialog messages more clear. - Compared archive ID in fs_user.cpp to ArchiveIdCode::NCCH as opposed to hex magic. - Cleaned up some other stuff.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.cpp22
-rw-r--r--src/core/core.h1
-rw-r--r--src/core/file_sys/archive_ncch.cpp3
-rw-r--r--src/core/hle/service/fs/archive.cpp8
-rw-r--r--src/core/hle/service/fs/fs_user.cpp7
-rw-r--r--src/core/loader/loader.h11
-rw-r--r--src/core/loader/ncch.cpp11
-rw-r--r--src/core/loader/ncch.h5
8 files changed, 33 insertions, 35 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 1861bfa9b..2a9664cb4 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -3,6 +3,9 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <memory> 5#include <memory>
6#include <utility>
7
8#include <boost/optional.hpp>
6 9
7#include "audio_core/audio_core.h" 10#include "audio_core/audio_core.h"
8#include "common/logging/log.h" 11#include "common/logging/log.h"
@@ -26,6 +29,7 @@ namespace Core {
26/*static*/ System System::s_instance; 29/*static*/ System System::s_instance;
27 30
28System::ResultStatus System::RunLoop(int tight_loop) { 31System::ResultStatus System::RunLoop(int tight_loop) {
32 this->status = ResultStatus::Success;
29 if (!cpu_core) { 33 if (!cpu_core) {
30 return ResultStatus::ErrorNotInitialized; 34 return ResultStatus::ErrorNotInitialized;
31 } 35 }
@@ -73,14 +77,14 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file
73 LOG_CRITICAL(Core, "Failed to obtain loader for %s!", filepath.c_str()); 77 LOG_CRITICAL(Core, "Failed to obtain loader for %s!", filepath.c_str());
74 return ResultStatus::ErrorGetLoader; 78 return ResultStatus::ErrorGetLoader;
75 } 79 }
76 boost::optional<u32> system_mode = boost::none; 80 std::pair<boost::optional<u32>, Loader::ResultStatus> system_mode =
81 app_loader->LoadKernelSystemMode();
77 82
78 Loader::ResultStatus load_result{app_loader->LoadKernelSystemMode(system_mode)}; 83 if (system_mode.second != Loader::ResultStatus::Success) {
79 if (!system_mode) { 84 LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", system_mode.second);
80 LOG_CRITICAL(Core, "Failed to determine system mode (Error %i)!", load_result);
81 System::Shutdown(); 85 System::Shutdown();
82 86
83 switch (load_result) { 87 switch (system_mode.second) {
84 case Loader::ResultStatus::ErrorEncrypted: 88 case Loader::ResultStatus::ErrorEncrypted:
85 return ResultStatus::ErrorLoader_ErrorEncrypted; 89 return ResultStatus::ErrorLoader_ErrorEncrypted;
86 case Loader::ResultStatus::ErrorInvalidFormat: 90 case Loader::ResultStatus::ErrorInvalidFormat:
@@ -90,15 +94,15 @@ System::ResultStatus System::Load(EmuWindow* emu_window, const std::string& file
90 } 94 }
91 } 95 }
92 96
93 ResultStatus init_result{Init(emu_window, system_mode.get())}; 97 ResultStatus init_result{Init(emu_window, system_mode.first.get())};
94 if (init_result != ResultStatus::Success) { 98 if (init_result != ResultStatus::Success) {
95 LOG_CRITICAL(Core, "Failed to initialize system (Error %i)!", init_result); 99 LOG_CRITICAL(Core, "Failed to initialize system (Error %i)!", init_result);
96 System::Shutdown(); 100 System::Shutdown();
97 return init_result; 101 return init_result;
98 } 102 }
99 103
100 load_result = app_loader->Load(); 104 Loader::ResultStatus load_result = app_loader->Load();
101 if (Loader::ResultStatus::Success != load_result) { 105 if (load_result != Loader::ResultStatus::Success) {
102 LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result); 106 LOG_CRITICAL(Core, "Failed to load ROM (Error %i)!", load_result);
103 System::Shutdown(); 107 System::Shutdown();
104 108
@@ -154,7 +158,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
154 GDBStub::Init(); 158 GDBStub::Init();
155 159
156 if (!VideoCore::Init(emu_window)) { 160 if (!VideoCore::Init(emu_window)) {
157 return ResultStatus::ErrorOpenGL; 161 return ResultStatus::ErrorVideoCore;
158 } 162 }
159 163
160 LOG_DEBUG(Core, "Initialized OK"); 164 LOG_DEBUG(Core, "Initialized OK");
diff --git a/src/core/core.h b/src/core/core.h
index 0963f273e..a7b4f8d62 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -43,7 +43,6 @@ public:
43 ErrorSystemFiles, ///< Error in finding system files 43 ErrorSystemFiles, ///< Error in finding system files
44 ErrorSharedFont, ///< Error in finding shared font 44 ErrorSharedFont, ///< Error in finding shared font
45 ErrorVideoCore, ///< Error in the video core 45 ErrorVideoCore, ///< Error in the video core
46 ErrorOpenGL, ///< Error when initializing OpenGL
47 ErrorUnknown ///< Any other error 46 ErrorUnknown ///< Any other error
48 }; 47 };
49 48
diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp
index 89455e39c..bf4e0916b 100644
--- a/src/core/file_sys/archive_ncch.cpp
+++ b/src/core/file_sys/archive_ncch.cpp
@@ -37,7 +37,8 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
37 auto file = std::make_shared<FileUtil::IOFile>(file_path, "rb"); 37 auto file = std::make_shared<FileUtil::IOFile>(file_path, "rb");
38 38
39 if (!file->IsOpen()) { 39 if (!file->IsOpen()) {
40 return ResultCode(-1); // TODO(Subv): Find the right error code 40 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
41 ErrorLevel::Status);
41 } 42 }
42 auto size = file->GetSize(); 43 auto size = file->GetSize();
43 44
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 632712f2c..6d1a49d92 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -257,11 +257,9 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
257 LOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code); 257 LOG_TRACE(Service_FS, "Opening archive with id code 0x%08X", id_code);
258 258
259 auto itr = id_code_map.find(id_code); 259 auto itr = id_code_map.find(id_code);
260 if (itr == id_code_map.end()) { 260 if (itr == id_code_map.end())
261 // TODO: Verify error against hardware 261 return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, ErrorSummary::NotFound,
262 return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, ErrorSummary::NotFound, 262 ErrorLevel::Status);
263 ErrorLevel::Permanent);
264 }
265 263
266 CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path)); 264 CASCADE_RESULT(std::unique_ptr<ArchiveBackend> res, itr->second->Open(archive_path));
267 265
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 5a4437123..0538ffc9c 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -133,12 +133,11 @@ static void OpenFileDirectly(Service::Interface* self) {
133 LOG_ERROR(Service_FS, 133 LOG_ERROR(Service_FS,
134 "failed to get a handle for archive archive_id=0x%08X archive_path=%s", 134 "failed to get a handle for archive archive_id=0x%08X archive_path=%s",
135 static_cast<u32>(archive_id), archive_path.DebugStr().c_str()); 135 static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
136 if (static_cast<u32>(archive_id) == 0x2345678A) {
137 Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles);
138 return;
139 }
140 cmd_buff[1] = archive_handle.Code().raw; 136 cmd_buff[1] = archive_handle.Code().raw;
141 cmd_buff[3] = 0; 137 cmd_buff[3] = 0;
138 if (static_cast<FS::ArchiveIdCode>(archive_id) == ArchiveIdCode::NCCH) {
139 Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles);
140 }
142 return; 141 return;
143 } 142 }
144 SCOPE_EXIT({ CloseArchive(*archive_handle); }); 143 SCOPE_EXIT({ CloseArchive(*archive_handle); });
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 21f73503e..0a2d4a10e 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -8,8 +8,11 @@
8#include <initializer_list> 8#include <initializer_list>
9#include <memory> 9#include <memory>
10#include <string> 10#include <string>
11#include <utility>
11#include <vector> 12#include <vector>
13
12#include <boost/optional.hpp> 14#include <boost/optional.hpp>
15
13#include "common/common_types.h" 16#include "common/common_types.h"
14#include "common/file_util.h" 17#include "common/file_util.h"
15 18
@@ -100,13 +103,11 @@ public:
100 * Loads the system mode that this application needs. 103 * Loads the system mode that this application needs.
101 * This function defaults to 2 (96MB allocated to the application) if it can't read the 104 * This function defaults to 2 (96MB allocated to the application) if it can't read the
102 * information. 105 * information.
103 * @param boost::optional<u32> Reference to Boost optional to store system mode. 106 * @return A pair with the system mode (If found) and the result.
104 * @ return Result of operation.
105 */ 107 */
106 virtual ResultStatus LoadKernelSystemMode(boost::optional<u32>& system_mode) { 108 virtual std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() {
107 // 96MB allocated to the application. 109 // 96MB allocated to the application.
108 system_mode = 2; 110 return std::make_pair(2, ResultStatus::Success);
109 return ResultStatus::Success;
110 } 111 }
111 112
112 /** 113 /**
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 1a20762e4..ffc019560 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -121,19 +121,16 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
121 return FileType::Error; 121 return FileType::Error;
122} 122}
123 123
124ResultStatus AppLoader_NCCH::LoadKernelSystemMode(boost::optional<u32>& system_mode) { 124std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {
125 if (!is_loaded) { 125 if (!is_loaded) {
126 ResultStatus res = LoadExeFS(); 126 ResultStatus res = LoadExeFS();
127 if (res != ResultStatus::Success) { 127 if (res != ResultStatus::Success) {
128 // Set the system mode as invalid. 128 return std::make_pair(boost::none, res);
129 system_mode = boost::none;
130 // Return the error code.
131 return res;
132 } 129 }
133 } 130 }
134 // Set the system mode as the one from the exheader. 131 // Set the system mode as the one from the exheader.
135 system_mode = exheader_header.arm11_system_local_caps.system_mode.Value(); 132 return std::make_pair(exheader_header.arm11_system_local_caps.system_mode.Value(),
136 return ResultStatus::Success; 133 ResultStatus::Success);
137} 134}
138 135
139ResultStatus AppLoader_NCCH::LoadExec() { 136ResultStatus AppLoader_NCCH::LoadExec() {
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 269fe4f49..712d496a4 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -179,10 +179,9 @@ public:
179 179
180 /** 180 /**
181 * Loads the Exheader and returns the system mode for this application. 181 * Loads the Exheader and returns the system mode for this application.
182 * @param boost::optional<u32> Reference to Boost optional to store system mode. 182 * @return A pair with the system mode (If found) and the result.
183 * @return Result of operation.
184 */ 183 */
185 ResultStatus LoadKernelSystemMode(boost::optional<u32>& system_mode) override; 184 std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
186 185
187 ResultStatus ReadCode(std::vector<u8>& buffer) override; 186 ResultStatus ReadCode(std::vector<u8>& buffer) override;
188 187