Loader: Fix (all?) remaining bugs in ldr:pm.
Loader now works when booted as a KIP1. NOTE: ldr:ro still needs debugging.
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
#include <switch.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_content_management.hpp"
|
||||
|
||||
static FsFileSystem g_CodeFileSystem = {0};
|
||||
|
||||
static std::vector<u64> g_created_titles;
|
||||
static bool g_has_initialized_fs_dev = false;
|
||||
|
||||
Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
|
||||
char path[FS_MAX_PATH] = {0};
|
||||
Result rc;
|
||||
|
||||
/* We defer SD card mounting, so if relevant ensure it is mounted. */
|
||||
TryMountSdCard();
|
||||
|
||||
if (R_FAILED(rc = GetContentPath(path, tid, sid))) {
|
||||
return rc;
|
||||
}
|
||||
@@ -99,4 +107,23 @@ Result ContentManagement::SetContentPath(const char *path, u64 tid, FsStorageId
|
||||
|
||||
Result ContentManagement::SetContentPathForTidSid(const char *path, Registration::TidSid *tid_sid) {
|
||||
return SetContentPath(path, tid_sid->title_id, tid_sid->storage_id);
|
||||
}
|
||||
|
||||
bool ContentManagement::HasCreatedTitle(u64 tid) {
|
||||
return std::find(g_created_titles.begin(), g_created_titles.end(), tid) != g_created_titles.end();
|
||||
}
|
||||
|
||||
void ContentManagement::SetCreatedTitle(u64 tid) {
|
||||
if (!HasCreatedTitle(tid)) {
|
||||
g_created_titles.push_back(tid);
|
||||
}
|
||||
}
|
||||
|
||||
void ContentManagement::TryMountSdCard() {
|
||||
/* Mount SD card, if psc, bus, and pcv have been created. */
|
||||
if (!g_has_initialized_fs_dev && HasCreatedTitle(0x0100000000000021) && HasCreatedTitle(0x010000000000000A) && HasCreatedTitle(0x010000000000001A)) {
|
||||
if (R_SUCCEEDED(fsdevMountSdmc())) {
|
||||
g_has_initialized_fs_dev = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user