mirror of
https://github.com/citra-emu/citra.git
synced 2025-02-20 13:30:06 +00:00
Added System::SystemIntegrityCheck; moved the Shared Font creation to SystemIntegrityCheck
This commit is contained in:
parent
b96e6eba37
commit
8775458054
@ -5,7 +5,10 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include "audio_core/audio_core.h"
|
#include "audio_core/audio_core.h"
|
||||||
|
#include "common/common_paths.h"
|
||||||
|
#include "common/file_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/string_util.h"
|
||||||
#include "core/arm/arm_interface.h"
|
#include "core/arm/arm_interface.h"
|
||||||
#include "core/arm/dynarmic/arm_dynarmic.h"
|
#include "core/arm/dynarmic/arm_dynarmic.h"
|
||||||
#include "core/arm/dyncom/arm_dyncom.h"
|
#include "core/arm/dyncom/arm_dyncom.h"
|
||||||
@ -14,6 +17,7 @@
|
|||||||
#include "core/gdbstub/gdbstub.h"
|
#include "core/gdbstub/gdbstub.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/thread.h"
|
#include "core/hle/kernel/thread.h"
|
||||||
|
#include "core/hle/service/fs/archive.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
#include "core/hw/hw.h"
|
#include "core/hw/hw.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
@ -22,6 +26,9 @@
|
|||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "video_core/video_core.h"
|
#include "video_core/video_core.h"
|
||||||
|
|
||||||
|
// System Archives
|
||||||
|
#include "../../dist/shared_font.app.romfs.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
/*static*/ System System::s_instance;
|
/*static*/ System System::s_instance;
|
||||||
@ -151,6 +158,7 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) {
|
|||||||
CoreTiming::Init();
|
CoreTiming::Init();
|
||||||
HW::Init();
|
HW::Init();
|
||||||
Kernel::Init(system_mode);
|
Kernel::Init(system_mode);
|
||||||
|
SystemIntegrityCheck();
|
||||||
Service::Init();
|
Service::Init();
|
||||||
AudioCore::Init();
|
AudioCore::Init();
|
||||||
GDBStub::Init();
|
GDBStub::Init();
|
||||||
@ -197,4 +205,37 @@ void System::Shutdown() {
|
|||||||
LOG_DEBUG(Core, "Shutdown OK");
|
LOG_DEBUG(Core, "Shutdown OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void System::SystemIntegrityCheck() {
|
||||||
|
|
||||||
|
// Shared Font
|
||||||
|
// TODO(B3N30): check/create font archive for region CHN/KOR/TWN
|
||||||
|
std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
|
||||||
|
const u32 shared_font_archive_id_low = 0x00014002;
|
||||||
|
const u32_le shared_font_archive_id_high = 0x0004009b;
|
||||||
|
std::string shared_font_path = Common::StringFromFormat(
|
||||||
|
"%s%s/title/%08x/%08x/content/00000000.app.romfs", nand_directory.c_str(), SYSTEM_ID,
|
||||||
|
shared_font_archive_id_high, shared_font_archive_id_low);
|
||||||
|
LOG_DEBUG(Core, "%s", shared_font_path.c_str());
|
||||||
|
auto file = std::make_shared<FileUtil::IOFile>(shared_font_path, "rb");
|
||||||
|
if (file->IsOpen()) {
|
||||||
|
file->Close();
|
||||||
|
LOG_INFO(Core, "SystemCheck: Shared Font exists.");
|
||||||
|
} else {
|
||||||
|
std::string shared_font_legacy_path = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
|
||||||
|
file = std::make_shared<FileUtil::IOFile>(shared_font_legacy_path, "rb");
|
||||||
|
if (file->IsOpen()) {
|
||||||
|
file->Close();
|
||||||
|
LOG_INFO(Core, "SystemCheck: Shared Font(legacy) exists.");
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Core, "SystemCheck: Shared Font missing.");
|
||||||
|
file = std::make_shared<FileUtil::IOFile>(shared_font_path, "w+b");
|
||||||
|
file->WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
|
||||||
|
file->Close();
|
||||||
|
LOG_DEBUG(Core, "SystemCheck: Created Shared Font.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(B3N30): Check if the other required system archives exists
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -132,6 +132,10 @@ private:
|
|||||||
/// Reschedule the core emulation
|
/// Reschedule the core emulation
|
||||||
void Reschedule();
|
void Reschedule();
|
||||||
|
|
||||||
|
/// Checks if required system files exist
|
||||||
|
/// If they don't exist, it will try to create them
|
||||||
|
void SystemIntegrityCheck();
|
||||||
|
|
||||||
/// AppLoader used to load the current executing application
|
/// AppLoader used to load the current executing application
|
||||||
std::unique_ptr<Loader::AppLoader> app_loader;
|
std::unique_ptr<Loader::AppLoader> app_loader;
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
#include "core/file_sys/ivfc_archive.h"
|
#include "core/file_sys/ivfc_archive.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
|
|
||||||
#include "../../dist/shared_font.app.romfs.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FileSys namespace
|
// FileSys namespace
|
||||||
|
|
||||||
@ -84,36 +82,6 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
|
|||||||
|
|
||||||
ResultCode ArchiveFactory_NCCH::Format(const Path& path,
|
ResultCode ArchiveFactory_NCCH::Format(const Path& path,
|
||||||
const FileSys::ArchiveFormatInfo& format_info) {
|
const FileSys::ArchiveFormatInfo& format_info) {
|
||||||
// TODO(B3N30): Take care of the format_info
|
|
||||||
auto vec = path.AsBinary();
|
|
||||||
const u32* data = reinterpret_cast<u32*>(vec.data());
|
|
||||||
u32 high = data[1];
|
|
||||||
u32 low = data[0];
|
|
||||||
std::string file_path = GetNCCHPath(mount_point, high, low);
|
|
||||||
|
|
||||||
// High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list).
|
|
||||||
constexpr u32 shared_data_archive = 0x0004009B;
|
|
||||||
|
|
||||||
// Low Title IDs.
|
|
||||||
constexpr u32 shared_font_archive = 0x00014002;
|
|
||||||
|
|
||||||
if (high == shared_data_archive) {
|
|
||||||
if (low == shared_font_archive) {
|
|
||||||
auto file = std::make_shared<FileUtil::IOFile>(file_path, "w+b");
|
|
||||||
if (!file->IsOpen()) {
|
|
||||||
LOG_ERROR(Service_FS, "Could not create shared font file.");
|
|
||||||
// TODO: Verify error code
|
|
||||||
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
|
|
||||||
ErrorSummary::NotSupported, ErrorLevel::Permanent);
|
|
||||||
}
|
|
||||||
file->WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
|
|
||||||
file->Close();
|
|
||||||
file.reset();
|
|
||||||
LOG_DEBUG(Service_FS, "Created shared font file.");
|
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_ERROR(Service_FS, "Attempted to format a NCCH archive.");
|
LOG_ERROR(Service_FS, "Attempted to format a NCCH archive.");
|
||||||
// TODO: Verify error code
|
// TODO: Verify error code
|
||||||
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
|
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
|
||||||
|
@ -982,18 +982,6 @@ static bool LoadLegacySharedFont() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FormatSharedFont() {
|
|
||||||
// TODO (B3N30): create different font archive for region CHN/KOR/TWN
|
|
||||||
const u64_le shared_font_archive_id_low = 0x0004009b00014002;
|
|
||||||
const u64_le shared_font_archive_id_high = 0x00000001ffffff00;
|
|
||||||
std::vector<u8> shared_font_archive_id(16);
|
|
||||||
std::memcpy(&shared_font_archive_id[0], &shared_font_archive_id_low, sizeof(u64));
|
|
||||||
std::memcpy(&shared_font_archive_id[8], &shared_font_archive_id_high, sizeof(u64));
|
|
||||||
FileSys::Path archive_path(shared_font_archive_id);
|
|
||||||
return Service::FS::FormatArchive(Service::FS::ArchiveIdCode::NCCH,
|
|
||||||
FileSys::ArchiveFormatInfo{}, archive_path) == RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
AddService(new APT_A_Interface);
|
AddService(new APT_A_Interface);
|
||||||
AddService(new APT_S_Interface);
|
AddService(new APT_S_Interface);
|
||||||
@ -1012,8 +1000,6 @@ void Init() {
|
|||||||
} else if (LoadLegacySharedFont()) {
|
} else if (LoadLegacySharedFont()) {
|
||||||
LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
|
LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
|
||||||
shared_font_loaded = true;
|
shared_font_loaded = true;
|
||||||
} else if (FormatSharedFont() && LoadSharedFont()) {
|
|
||||||
shared_font_loaded = true;
|
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING(Service_APT, "Unable to load shared font");
|
LOG_WARNING(Service_APT, "Unable to load shared font");
|
||||||
shared_font_loaded = false;
|
shared_font_loaded = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user