mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 23:59:49 -04:00
strat: use TitleId defs instead of magics.
This commit is contained in:
parent
4167dfea14
commit
9427a5cf46
13 changed files with 77 additions and 146 deletions
|
@ -27,7 +27,7 @@
|
|||
#include "pm_registration.hpp"
|
||||
#include "pm_boot_mode.hpp"
|
||||
|
||||
static std::vector<Boot2KnownTitleId> g_launched_titles;
|
||||
static std::vector<u64> g_launched_titles;
|
||||
|
||||
static bool IsHexadecimal(const char *str) {
|
||||
while (*str) {
|
||||
|
@ -40,11 +40,11 @@ static bool IsHexadecimal(const char *str) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool HasLaunchedTitle(Boot2KnownTitleId title_id) {
|
||||
static bool HasLaunchedTitle(u64 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) {
|
||||
static void SetLaunchedTitle(u64 title_id) {
|
||||
g_launched_titles.push_back(title_id);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ static void ClearLaunchedTitles() {
|
|||
g_launched_titles.clear();
|
||||
}
|
||||
|
||||
static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32 launch_flags, u64 *pid) {
|
||||
static void LaunchTitle(u64 title_id, FsStorageId storage_id, u32 launch_flags, u64 *pid) {
|
||||
u64 local_pid = 0;
|
||||
|
||||
/* Don't launch a title twice during boot2. */
|
||||
|
@ -60,7 +60,7 @@ static void LaunchTitle(Boot2KnownTitleId title_id, FsStorageId storage_id, u32
|
|||
return;
|
||||
}
|
||||
|
||||
Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{(u64)title_id, storage_id}, launch_flags, &local_pid);
|
||||
Result rc = Registration::LaunchProcessByTidSid(Registration::TidSid{title_id, storage_id}, launch_flags, &local_pid);
|
||||
switch (rc) {
|
||||
case ResultKernelResourceExhausted:
|
||||
/* Out of resource! */
|
||||
|
@ -125,46 +125,46 @@ static bool IsMaintenanceMode() {
|
|||
return false;
|
||||
}
|
||||
|
||||
static const std::tuple<Boot2KnownTitleId, bool> 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 */ /* Skip launching error collection in Atmosphere to lessen telemetry. */
|
||||
{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 */
|
||||
{Boot2KnownTitleId::olsc, true}, /* olsc */
|
||||
static const std::tuple<u64, bool> g_additional_launch_programs[] = {
|
||||
{TitleId_Am, true}, /* am */
|
||||
{TitleId_NvServices, true}, /* nvservices */
|
||||
{TitleId_NvnFlinger, true}, /* nvnflinger */
|
||||
{TitleId_Vi, true}, /* vi */
|
||||
{TitleId_Ns, true}, /* ns */
|
||||
{TitleId_LogManager, true}, /* lm */
|
||||
{TitleId_Ppc, true}, /* ppc */
|
||||
{TitleId_Ptm, true}, /* ptm */
|
||||
{TitleId_Hid, true}, /* hid */
|
||||
{TitleId_Audio, true}, /* audio */
|
||||
{TitleId_Lbl, true}, /* lbl */
|
||||
{TitleId_Wlan, true}, /* wlan */
|
||||
{TitleId_Bluetooth, true}, /* bluetooth */
|
||||
{TitleId_BsdSockets, true}, /* bsdsockets */
|
||||
{TitleId_Nifm, true}, /* nifm */
|
||||
{TitleId_Ldn, true}, /* ldn */
|
||||
{TitleId_Account, true}, /* account */
|
||||
{TitleId_Friends, false}, /* friends */
|
||||
{TitleId_Nfc, true}, /* nfc */
|
||||
{TitleId_JpegDec, true}, /* jpegdec */
|
||||
{TitleId_CapSrv, true}, /* capsrv */
|
||||
{TitleId_Ssl, true}, /* ssl */
|
||||
{TitleId_Nim, true}, /* nim */
|
||||
{TitleId_Bcat, false}, /* bcat */
|
||||
{TitleId_Erpt, true}, /* erpt */
|
||||
{TitleId_Es, true}, /* es */
|
||||
{TitleId_Pctl, true}, /* pctl */
|
||||
{TitleId_Btm, true}, /* btm */
|
||||
{TitleId_Eupld, false}, /* eupld */
|
||||
{TitleId_Glue, true}, /* glue */
|
||||
/* {TitleId_Eclct, true}, */ /* eclct */ /* Skip launching error collection in Atmosphere to lessen telemetry. */
|
||||
{TitleId_Npns, false}, /* npns */
|
||||
{TitleId_Fatal, true}, /* fatal */
|
||||
{TitleId_Ro, true}, /* ro */
|
||||
{TitleId_Profiler, true}, /* profiler */
|
||||
{TitleId_Sdb, true}, /* sdb */
|
||||
{TitleId_Migration, true}, /* migration */
|
||||
{TitleId_Grc, true}, /* grc */
|
||||
{TitleId_Olsc, true}, /* olsc */
|
||||
};
|
||||
|
||||
static void MountSdCard() {
|
||||
|
@ -206,15 +206,15 @@ void EmbeddedBoot2::Main() {
|
|||
/* psc, bus, pcv is the minimal set of required titles to get SD card. */
|
||||
/* bus depends on pcie, and pcv depends on settings. */
|
||||
/* Launch psc. */
|
||||
LaunchTitle(Boot2KnownTitleId::psc, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Psc, FsStorageId_NandSystem, 0, NULL);
|
||||
/* Launch pcie. */
|
||||
LaunchTitle(Boot2KnownTitleId::pcie, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Pcie, FsStorageId_NandSystem, 0, NULL);
|
||||
/* Launch bus. */
|
||||
LaunchTitle(Boot2KnownTitleId::bus, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Bus, FsStorageId_NandSystem, 0, NULL);
|
||||
/* Launch settings. */
|
||||
LaunchTitle(Boot2KnownTitleId::settings, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Settings, FsStorageId_NandSystem, 0, NULL);
|
||||
/* Launch pcv. */
|
||||
LaunchTitle(Boot2KnownTitleId::pcv, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Pcv, FsStorageId_NandSystem, 0, NULL);
|
||||
|
||||
/* At this point, the SD card can be mounted. */
|
||||
MountSdCard();
|
||||
|
@ -234,18 +234,18 @@ void EmbeddedBoot2::Main() {
|
|||
}
|
||||
|
||||
/* Launch usb. */
|
||||
LaunchTitle(Boot2KnownTitleId::usb, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Usb, FsStorageId_NandSystem, 0, NULL);
|
||||
|
||||
/* Launch tma. */
|
||||
LaunchTitle(Boot2KnownTitleId::tma, FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(TitleId_Tma, FsStorageId_NandSystem, 0, NULL);
|
||||
|
||||
/* Launch Atmosphere dmnt, using FsStorageId_None to force SD card boot. */
|
||||
LaunchTitle(Boot2KnownTitleId::dmnt, FsStorageId_None, 0, NULL);
|
||||
LaunchTitle(TitleId_Dmnt, FsStorageId_None, 0, NULL);
|
||||
|
||||
/* Launch default programs. */
|
||||
for (auto &launch_program : g_additional_launch_programs) {
|
||||
if (!maintenance || std::get<bool>(launch_program)) {
|
||||
LaunchTitle(std::get<Boot2KnownTitleId>(launch_program), FsStorageId_NandSystem, 0, NULL);
|
||||
LaunchTitle(std::get<u64>(launch_program), FsStorageId_NandSystem, 0, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ void EmbeddedBoot2::Main() {
|
|||
if (titles_dir != NULL) {
|
||||
while ((ent = readdir(titles_dir)) != NULL) {
|
||||
if (strlen(ent->d_name) == 0x10 && IsHexadecimal(ent->d_name)) {
|
||||
Boot2KnownTitleId title_id = (Boot2KnownTitleId)strtoul(ent->d_name, NULL, 16);
|
||||
u64 title_id = (u64)strtoul(ent->d_name, NULL, 16);
|
||||
if (HasLaunchedTitle(title_id)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -16,73 +16,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
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,
|
||||
olsc = 0x010000000000003EUL,
|
||||
|
||||
|
||||
/* atmosphere extensions */
|
||||
ams_set_mitm = 0x0100000000000032UL,
|
||||
};
|
||||
|
||||
class EmbeddedBoot2 {
|
||||
public:
|
||||
static void Main();
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include "pm_registration.hpp"
|
||||
|
||||
#define BOOT2_TITLE_ID (0x0100000000000008ULL)
|
||||
|
||||
enum ShellCmd {
|
||||
Shell_Cmd_LaunchProcess = 0,
|
||||
Shell_Cmd_TerminateProcessId = 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue