From c0798031896d7c2b746d1ba052af745947a6bff3 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 27 Jul 2018 02:37:45 -0700 Subject: [PATCH] PM: Use enum in EmbeddedBoot2 --- stratosphere/pm/source/pm_boot2.cpp | 98 ++++++++++++++--------------- stratosphere/pm/source/pm_boot2.hpp | 62 +++++++++++++++++- 2 files changed, 109 insertions(+), 51 deletions(-) diff --git a/stratosphere/pm/source/pm_boot2.cpp b/stratosphere/pm/source/pm_boot2.cpp index f3995ebaa..b40200b14 100644 --- a/stratosphere/pm/source/pm_boot2.cpp +++ b/stratosphere/pm/source/pm_boot2.cpp @@ -8,10 +8,10 @@ #include "pm_boot2.hpp" #include "pm_registration.hpp" -static void LaunchTitle(u64 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; - Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{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) { case 0xCE01: /* Out of resource! */ @@ -39,69 +39,69 @@ static bool ShouldForceMaintenanceMode() { return false; } -static const std::tuple g_additional_launch_programs[] = { - {0x0100000000000023, true}, /* am */ - {0x0100000000000019, true}, /* nvservices */ - {0x010000000000001C, true}, /* nvnflinger */ - {0x010000000000002D, true}, /* vi */ - {0x010000000000001F, true}, /* ns */ - {0x0100000000000015, true}, /* lm */ - {0x010000000000001B, true}, /* ppc */ - {0x0100000000000010, true}, /* ptm */ - {0x0100000000000013, true}, /* hid */ - {0x0100000000000014, true}, /* audio */ - {0x0100000000000029, true}, /* lbl */ - {0x0100000000000016, true}, /* wlan */ - {0x010000000000000B, true}, /* bluetooth */ - {0x0100000000000012, true}, /* bsdsockets */ - {0x010000000000000F, true}, /* nifm */ - {0x0100000000000018, true}, /* ldn */ - {0x010000000000001E, true}, /* account */ - {0x010000000000000E, false}, /* friends */ - {0x0100000000000020, true}, /* nfc */ - {0x010000000000003C, true}, /* jpegdec */ - {0x0100000000000022, true}, /* capsrv */ - {0x0100000000000024, true}, /* ssl */ - {0x0100000000000025, true}, /* nim */ - {0x010000000000000C, false}, /* bcat */ - {0x010000000000002B, true}, /* erpt */ - {0x0100000000000033, true}, /* es */ - {0x010000000000002E, true}, /* pctl */ - {0x010000000000002A, true}, /* btm */ - {0x0100000000000030, false}, /* eupld */ - {0x0100000000000031, true}, /* glue */ - {0x0100000000000032, true}, /* eclct */ - {0x010000000000002F, false}, /* npns */ - {0x0100000000000034, true}, /* fatal */ - {0x0100000000000037, true}, /* ro */ - {0x0100000000000038, true}, /* doesn't exist on retail systems */ - {0x0100000000000039, true}, /* sdb */ - {0x010000000000003A, true}, /* migration */ - {0x0100000000000035, true}, /* grc */ +static const std::tuple g_additional_launch_programs[] = { + {Boot2KnownTitleId::am, true}, /* am */ + {Boot2KnownTitleId::nvservices, true}, /* nvservices */ + {Boot2KnownTitleId::nvnflinger, true}, /* nvnflinger */ + {Boot2KnownTitleId::vi, true}, /* vi */ + {Boot2KnownTitleId::ns, true}, /* ns */ + {Boot2KnownTitleId::lm, true}, /* lm */ + {Boot2KnownTitleId::ppc, true}, /* ppc */ + {Boot2KnownTitleId::ptm, true}, /* ptm */ + {Boot2KnownTitleId::hid, true}, /* hid */ + {Boot2KnownTitleId::audio, true}, /* audio */ + {Boot2KnownTitleId::lbl, true}, /* lbl */ + {Boot2KnownTitleId::wlan, true}, /* wlan */ + {Boot2KnownTitleId::bluetooth, true}, /* bluetooth */ + {Boot2KnownTitleId::bsdsockets, true}, /* bsdsockets */ + {Boot2KnownTitleId::nifm, true}, /* nifm */ + {Boot2KnownTitleId::ldn, true}, /* ldn */ + {Boot2KnownTitleId::account, true}, /* account */ + {Boot2KnownTitleId::friends, false}, /* friends */ + {Boot2KnownTitleId::nfc, true}, /* nfc */ + {Boot2KnownTitleId::jpegdec, true}, /* jpegdec */ + {Boot2KnownTitleId::capsrv, true}, /* capsrv */ + {Boot2KnownTitleId::ssl, true}, /* ssl */ + {Boot2KnownTitleId::nim, true}, /* nim */ + {Boot2KnownTitleId::bcat, false}, /* bcat */ + {Boot2KnownTitleId::erpt, true}, /* erpt */ + {Boot2KnownTitleId::es, true}, /* es */ + {Boot2KnownTitleId::pctl, true}, /* pctl */ + {Boot2KnownTitleId::btm, true}, /* btm */ + {Boot2KnownTitleId::eupld, false}, /* eupld */ + {Boot2KnownTitleId::glue, true}, /* glue */ + {Boot2KnownTitleId::eclct, true}, /* eclct */ + {Boot2KnownTitleId::npns, false}, /* npns */ + {Boot2KnownTitleId::fatal, true}, /* fatal */ + {Boot2KnownTitleId::ro, true}, /* ro */ + {Boot2KnownTitleId::profiler, true}, /* profiler */ + {Boot2KnownTitleId::sdb, true}, /* sdb */ + {Boot2KnownTitleId::migration, true}, /* migration */ + {Boot2KnownTitleId::grc, true}, /* grc */ }; void EmbeddedBoot2::Main() { /* TODO: Modify initial program launch order, to get SD card mounted faster. */ /* Launch psc. */ - LaunchTitle(0x0100000000000021, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::psc, FsStorageId_NandSystem, 0, NULL); /* Launch settings. */ - LaunchTitle(0x0100000000000009, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::settings, FsStorageId_NandSystem, 0, NULL); /* Launch usb. */ - LaunchTitle(0x0100000000000006, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::usb, FsStorageId_NandSystem, 0, NULL); /* Launch pcie. */ - LaunchTitle(0x010000000000001D, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::pcie, FsStorageId_NandSystem, 0, NULL); /* Launch bus. */ - LaunchTitle(0x010000000000000A, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::bus, FsStorageId_NandSystem, 0, NULL); /* Launch tma. */ - LaunchTitle(0x0100000000000007, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::tma, FsStorageId_NandSystem, 0, NULL); /* Launch pcv. */ - LaunchTitle(0x010000000000001A, FsStorageId_NandSystem, 0, NULL); + LaunchTitle(Boot2KnownTitleId::pcv, FsStorageId_NandSystem, 0, NULL); bool maintenance = ShouldForceMaintenanceMode(); for (auto &launch_program : g_additional_launch_programs) { if (!maintenance || std::get(launch_program)) { - LaunchTitle(std::get(launch_program), FsStorageId_NandSystem, 0, NULL); + LaunchTitle(std::get(launch_program), FsStorageId_NandSystem, 0, NULL); } } } diff --git a/stratosphere/pm/source/pm_boot2.hpp b/stratosphere/pm/source/pm_boot2.hpp index 20d2a19b5..2aa1e593e 100644 --- a/stratosphere/pm/source/pm_boot2.hpp +++ b/stratosphere/pm/source/pm_boot2.hpp @@ -1,7 +1,65 @@ #pragma once -enum class TitleId : u64 { - x = 0UL, +enum class Boot2KnownTitleId : u64 { + fs = 0x0100000000000000UL, + loader = 0x0100000000000001UL, + ncm = 0x0100000000000002UL, + pm = 0x0100000000000003UL, + sm = 0x0100000000000004UL, + boot = 0x0100000000000005UL, + usb = 0x0100000000000006UL, + tma = 0x0100000000000007UL, + boot2 = 0x0100000000000008UL, + settings = 0x0100000000000009UL, + bus = 0x010000000000000AUL, + bluetooth = 0x010000000000000BUL, + bcat = 0x010000000000000CUL, + dmnt = 0x010000000000000DUL, + friends = 0x010000000000000EUL, + nifm = 0x010000000000000FUL, + ptm = 0x0100000000000010UL, + shell = 0x0100000000000011UL, + bsdsockets = 0x0100000000000012UL, + hid = 0x0100000000000013UL, + audio = 0x0100000000000014UL, + lm = 0x0100000000000015UL, + wlan = 0x0100000000000016UL, + cs = 0x0100000000000017UL, + ldn = 0x0100000000000018UL, + nvservices = 0x0100000000000019UL, + pcv = 0x010000000000001AUL, + ppc = 0x010000000000001BUL, + nvnflinger = 0x010000000000001CUL, + pcie = 0x010000000000001DUL, + account = 0x010000000000001EUL, + ns = 0x010000000000001FUL, + nfc = 0x0100000000000020UL, + psc = 0x0100000000000021UL, + capsrv = 0x0100000000000022UL, + am = 0x0100000000000023UL, + ssl = 0x0100000000000024UL, + nim = 0x0100000000000025UL, + spl = 0x0100000000000028UL, + lbl = 0x0100000000000029UL, + btm = 0x010000000000002AUL, + erpt = 0x010000000000002BUL, + vi = 0x010000000000002DUL, + pctl = 0x010000000000002EUL, + npns = 0x010000000000002FUL, + eupld = 0x0100000000000030UL, + glue = 0x0100000000000031UL, + eclct = 0x0100000000000032UL, + es = 0x0100000000000033UL, + fatal = 0x0100000000000034UL, + grc = 0x0100000000000035UL, + creport = 0x0100000000000036UL, + ro = 0x0100000000000037UL, + profiler = 0x0100000000000038UL, + sdb = 0x0100000000000039UL, + migration = 0x010000000000003AUL, + jit = 0x010000000000003BUL, + jpegdec = 0x010000000000003CUL, + safemode = 0x010000000000003DUL, }; class EmbeddedBoot2 {