mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-22 20:06:40 +00:00
pm: Don't launch titles twice due to boot2.flag
This commit is contained in:
parent
907f6fa72d
commit
8a92a63a64
2 changed files with 31 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -42,6 +42,8 @@ dist: all
|
||||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000036
|
||||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000034
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000034
|
||||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000032
|
||||||
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/010000000000000D
|
||||||
|
mkdir -p atmosphere-$(AMSVER)/atmosphere/titles/0100000000000007
|
||||||
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
|
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
|
||||||
cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/BCT.ini
|
cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/BCT.ini
|
||||||
cp common/defaults/loader.ini atmosphere-$(AMSVER)/atmosphere/loader.ini
|
cp common/defaults/loader.ini atmosphere-$(AMSVER)/atmosphere/loader.ini
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "pm_boot2.hpp"
|
#include "pm_boot2.hpp"
|
||||||
#include "pm_registration.hpp"
|
#include "pm_registration.hpp"
|
||||||
|
|
||||||
|
static std::vector<Boot2KnownTitleId> g_launched_titles;
|
||||||
|
|
||||||
static bool IsHexadecimal(const char *str) {
|
static bool IsHexadecimal(const char *str) {
|
||||||
while (*str) {
|
while (*str) {
|
||||||
if (isxdigit(*str)) {
|
if (isxdigit(*str)) {
|
||||||
|
@ -37,22 +39,34 @@ static bool IsHexadecimal(const char *str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HasLaunchedTitle(Boot2KnownTitleId title_id) {
|
||||||
|
return std::find(g_launched_titles.begin(), g_launched_titles.end(), title_id) != g_launched_titles.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetLaunchedTitle(Boot2KnownTitleId title_id) {
|
||||||
|
g_launched_titles.push_back(title_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ClearLaunchedTitles() {
|
||||||
|
g_launched_titles.clear();
|
||||||
|
}
|
||||||
|
|
||||||
static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32 launch_flags, u64 *pid) {
|
static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32 launch_flags, u64 *pid) {
|
||||||
u64 local_pid;
|
u64 local_pid = 0;
|
||||||
|
|
||||||
Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{(u64)title_id, storage_id}, launch_flags, &local_pid);
|
Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{(u64)title_id, storage_id}, launch_flags, &local_pid);
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
case 0xCE01:
|
case 0xCE01:
|
||||||
/* Out of resource! */
|
/* Out of resource! */
|
||||||
/* TODO: Panic(). */
|
std::abort();
|
||||||
break;
|
break;
|
||||||
case 0xDE01:
|
case 0xDE01:
|
||||||
/* Out of memory! */
|
/* Out of memory! */
|
||||||
/* TODO: Panic(). */
|
std::abort();
|
||||||
break;
|
break;
|
||||||
case 0xD001:
|
case 0xD001:
|
||||||
/* Limit Reached! */
|
/* Limit Reached! */
|
||||||
/* TODO: Panic(). */
|
std::abort();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* We don't care about other issues. */
|
/* We don't care about other issues. */
|
||||||
|
@ -61,6 +75,8 @@ static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32
|
||||||
if (pid) {
|
if (pid) {
|
||||||
*pid = local_pid;
|
*pid = local_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetLaunchedTitle(title_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ShouldForceMaintenanceMode() {
|
static bool ShouldForceMaintenanceMode() {
|
||||||
|
@ -178,7 +194,10 @@ void EmbeddedBoot2::Main() {
|
||||||
if (titles_dir != NULL) {
|
if (titles_dir != NULL) {
|
||||||
while ((ent = readdir(titles_dir)) != NULL) {
|
while ((ent = readdir(titles_dir)) != NULL) {
|
||||||
if (strlen(ent->d_name) == 0x10 && IsHexadecimal(ent->d_name)) {
|
if (strlen(ent->d_name) == 0x10 && IsHexadecimal(ent->d_name)) {
|
||||||
u64 title_id = strtoul(ent->d_name, NULL, 16);
|
Boot2KnownTitleId title_id = (Boot2KnownTitleId)strtoul(ent->d_name, NULL, 16);
|
||||||
|
if (HasLaunchedTitle(title_id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
char title_path[FS_MAX_PATH] = {0};
|
char title_path[FS_MAX_PATH] = {0};
|
||||||
strcpy(title_path, "sdmc:/atmosphere/titles/");
|
strcpy(title_path, "sdmc:/atmosphere/titles/");
|
||||||
strcat(title_path, ent->d_name);
|
strcat(title_path, ent->d_name);
|
||||||
|
@ -186,7 +205,7 @@ void EmbeddedBoot2::Main() {
|
||||||
FILE *f_flag = fopen(title_path, "rb");
|
FILE *f_flag = fopen(title_path, "rb");
|
||||||
if (f_flag != NULL) {
|
if (f_flag != NULL) {
|
||||||
fclose(f_flag);
|
fclose(f_flag);
|
||||||
LaunchTitle((Boot2KnownTitleId)title_id, FsStorageId_None, 0, NULL);
|
LaunchTitle(title_id, FsStorageId_None, 0, NULL);
|
||||||
} else {
|
} else {
|
||||||
/* TODO: Deprecate this in the future. */
|
/* TODO: Deprecate this in the future. */
|
||||||
memset(title_path, 0, FS_MAX_PATH);
|
memset(title_path, 0, FS_MAX_PATH);
|
||||||
|
@ -196,13 +215,16 @@ void EmbeddedBoot2::Main() {
|
||||||
f_flag = fopen(title_path, "rb");
|
f_flag = fopen(title_path, "rb");
|
||||||
if (f_flag != NULL) {
|
if (f_flag != NULL) {
|
||||||
fclose(f_flag);
|
fclose(f_flag);
|
||||||
LaunchTitle((Boot2KnownTitleId)title_id, FsStorageId_None, 0, NULL);
|
LaunchTitle(title_id, FsStorageId_None, 0, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir(titles_dir);
|
closedir(titles_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free the memory used to track what boot2 launches. */
|
||||||
|
ClearLaunchedTitles();
|
||||||
|
|
||||||
/* We no longer need the SD card. */
|
/* We no longer need the SD card. */
|
||||||
fsdevUnmountAll();
|
fsdevUnmountAll();
|
||||||
|
|
Loading…
Reference in a new issue