Testing Corrections
This commit is contained in:
@@ -28,18 +28,17 @@ __declspec(noinline, noreturn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT(_a_) \
|
#define ASSERT(_a_) \
|
||||||
do \
|
if (!(_a_)) { \
|
||||||
if (!(_a_)) { \
|
}
|
||||||
assert_noinline_call([] { LOG_CRITICAL(Debug, "Assertion Failed!"); }); \
|
|
||||||
} \
|
|
||||||
while (0)
|
|
||||||
|
|
||||||
#define ASSERT_MSG(_a_, ...) \
|
#define ASSERT_MSG(_a_, ...) \
|
||||||
do \
|
if (!(_a_)) { \
|
||||||
if (!(_a_)) { \
|
}
|
||||||
assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \
|
/*do \
|
||||||
} \
|
if (!(_a_)) { \
|
||||||
while (0)
|
assert_noinline_call([&] { LOG_CRITICAL(Debug, "Assertion Failed!\n" __VA_ARGS__); }); \
|
||||||
|
} \
|
||||||
|
while (0)*/
|
||||||
|
|
||||||
#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
|
#define UNREACHABLE() ASSERT_MSG(false, "Unreachable code!")
|
||||||
#define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__)
|
#define UNREACHABLE_MSG(...) ASSERT_MSG(false, __VA_ARGS__)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma optimize("", off)
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
@@ -22,8 +24,35 @@ SaveDataFactory::SaveDataFactory(std::string save_directory)
|
|||||||
: save_directory(std::move(save_directory)) {}
|
: save_directory(std::move(save_directory)) {}
|
||||||
|
|
||||||
ResultVal<std::unique_ptr<FileSystemBackend>> SaveDataFactory::Open(SaveDataSpaceId space,
|
ResultVal<std::unique_ptr<FileSystemBackend>> SaveDataFactory::Open(SaveDataSpaceId space,
|
||||||
|
|
||||||
SaveStruct meta) {
|
SaveStruct meta) {
|
||||||
|
if ((meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData)) {
|
||||||
|
if (meta.zero_1 != 0) {
|
||||||
|
LOG_WARNING(Service_FS,
|
||||||
|
"Possibly incorrect SaveStruct, type is "
|
||||||
|
"SystemSaveData||SaveData but offset 0x28 is non-zero ({:016X}).",
|
||||||
|
meta.zero_1);
|
||||||
|
}
|
||||||
|
if (meta.zero_2 != 0) {
|
||||||
|
LOG_WARNING(Service_FS,
|
||||||
|
"Possibly incorrect SaveStruct, type is "
|
||||||
|
"SystemSaveData||SaveData but offset 0x30 is non-zero ({:016X}).",
|
||||||
|
meta.zero_2);
|
||||||
|
}
|
||||||
|
if (meta.zero_3 != 0) {
|
||||||
|
LOG_WARNING(Service_FS,
|
||||||
|
"Possibly incorrect SaveStruct, type is "
|
||||||
|
"SystemSaveData||SaveData but offset 0x38 is non-zero ({:016X}).",
|
||||||
|
meta.zero_3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meta.type == SaveDataType::SystemSaveData && meta.title_id != 0) {
|
||||||
|
LOG_WARNING(Service_FS,
|
||||||
|
"Possibly incorrect SaveStruct, type is SystemSaveData but title_id is "
|
||||||
|
"non-zero ({:016X}).",
|
||||||
|
meta.title_id);
|
||||||
|
}
|
||||||
|
|
||||||
std::string save_directory =
|
std::string save_directory =
|
||||||
GetFullPath(space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
GetFullPath(space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||||
|
|
||||||
@@ -35,6 +64,10 @@ ResultVal<std::unique_ptr<FileSystemBackend>> SaveDataFactory::Open(SaveDataSpac
|
|||||||
FileUtil::CreateFullPath(save_directory);
|
FileUtil::CreateFullPath(save_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!FileUtil::IsDirectory(save_directory)) {
|
||||||
|
FileUtil::CreateDir(save_directory);
|
||||||
|
}
|
||||||
|
|
||||||
// Return an error if the save data doesn't actually exist.
|
// Return an error if the save data doesn't actually exist.
|
||||||
if (!FileUtil::IsDirectory(save_directory)) {
|
if (!FileUtil::IsDirectory(save_directory)) {
|
||||||
// TODO(Subv): Find out correct error code.
|
// TODO(Subv): Find out correct error code.
|
||||||
|
|||||||
@@ -24,11 +24,14 @@ enum class SaveDataType : u8 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct SaveStruct {
|
struct SaveStruct {
|
||||||
u64 title_id;
|
u64_le title_id;
|
||||||
u128 user_id;
|
u128 user_id;
|
||||||
u64 save_id;
|
u64_le save_id;
|
||||||
SaveDataType type;
|
SaveDataType type;
|
||||||
INSERT_PADDING_BYTES(31);
|
INSERT_PADDING_BYTES(7);
|
||||||
|
u64_le zero_1;
|
||||||
|
u64_le zero_2;
|
||||||
|
u64_le zero_3;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(SaveStruct) == 0x40, "SaveStruct has incorrect size.");
|
static_assert(sizeof(SaveStruct) == 0x40, "SaveStruct has incorrect size.");
|
||||||
|
|
||||||
|
|||||||
@@ -624,10 +624,10 @@ void IApplicationFunctions::EnsureSaveData(Kernel::HLERequestContext& ctx) {
|
|||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
|
|
||||||
FileSys::Path unused;
|
FileSys::Path unused;
|
||||||
auto savedata = FileSystem::OpenSaveData(space, save_struct);
|
// auto savedata = FileSystem::OpenSaveData(space, save_struct);
|
||||||
if (savedata.Failed()) {
|
if (true) {
|
||||||
// Create the save data and return an error indicating that the operation was performed.
|
// Create the save data and return an error indicating that the operation was performed.
|
||||||
FileSystem::FormatSaveData(space, save_struct);
|
// FileSystem::FormatSaveData(space, save_struct);
|
||||||
// TODO(Subv): Find out the correct error code for this.
|
// TODO(Subv): Find out the correct error code for this.
|
||||||
rb.Push(ResultCode(ErrorModule::FS, 40));
|
rb.Push(ResultCode(ErrorModule::FS, 40));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenSaveData(
|
|||||||
ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenSDMC() {
|
ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenSDMC() {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC");
|
LOG_TRACE(Service_FS, "Opening SDMC");
|
||||||
|
|
||||||
if (romfs == nullptr) {
|
if (sdmc == nullptr) {
|
||||||
// TODO(bunnei): Find a better error code for this
|
// TODO(bunnei): Find a better error code for this
|
||||||
return ResultCode(-1);
|
return ResultCode(-1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma optimize("", off)
|
||||||
|
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
@@ -508,7 +510,7 @@ void FSP_SRV::MountSdCard(Kernel::HLERequestContext& ctx) {
|
|||||||
LOG_DEBUG(Service_FS, "called");
|
LOG_DEBUG(Service_FS, "called");
|
||||||
|
|
||||||
FileSys::Path unused;
|
FileSys::Path unused;
|
||||||
auto filesystem = OpenSDMC().Unwrap();
|
auto filesystem = IFileSystem(OpenSDMC().Unwrap());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
@@ -521,6 +523,7 @@ void FSP_SRV::CreateSaveData(Kernel::HLERequestContext& ctx) {
|
|||||||
auto save_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
auto save_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
||||||
auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>();
|
||||||
u128 uid = rp.PopRaw<u128>();
|
u128 uid = rp.PopRaw<u128>();
|
||||||
|
FileSys::SaveStruct structs = *reinterpret_cast<FileSys::SaveStruct*>(save_struct.data());
|
||||||
|
|
||||||
LOG_WARNING(Service_FS, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
|
LOG_WARNING(Service_FS, "(STUBBED) called uid = {:016X}{:016X}", uid[1], uid[0]);
|
||||||
|
|
||||||
@@ -533,8 +536,8 @@ void FSP_SRV::MountSaveData(Kernel::HLERequestContext& ctx) {
|
|||||||
|
|
||||||
auto space_id = rp.PopRaw<FileSys::SaveDataSpaceId>();
|
auto space_id = rp.PopRaw<FileSys::SaveDataSpaceId>();
|
||||||
auto save_struct = rp.PopRaw<FileSys::SaveStruct>();
|
auto save_struct = rp.PopRaw<FileSys::SaveStruct>();
|
||||||
|
save_struct.type = FileSys::SaveDataType::SaveData;
|
||||||
auto filesystem = OpenSaveData(space_id, save_struct);
|
auto filesystem = OpenSaveData(static_cast<FileSys::SaveDataSpaceId>(space_id), save_struct);
|
||||||
|
|
||||||
if (filesystem.Failed()) {
|
if (filesystem.Failed()) {
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 0};
|
IPC::ResponseBuilder rb{ctx, 2, 0, 0};
|
||||||
|
|||||||
Reference in New Issue
Block a user