diff --git a/stratosphere/creport/source/creport_crash_report.cpp b/stratosphere/creport/source/creport_crash_report.cpp index 0314ecb2b..69f9f0c4c 100644 --- a/stratosphere/creport/source/creport_crash_report.cpp +++ b/stratosphere/creport/source/creport_crash_report.cpp @@ -112,7 +112,7 @@ namespace ams::creport { } } - void CrashReport::GetFatalContext(FatalContext *_out) const { + void CrashReport::GetFatalContext(::FatalCpuContext *_out) const { static_assert(sizeof(*_out) == sizeof(ams::fatal::CpuContext)); ams::fatal::CpuContext *out = reinterpret_cast(_out); std::memset(out, 0, sizeof(*out)); diff --git a/stratosphere/creport/source/creport_crash_report.hpp b/stratosphere/creport/source/creport_crash_report.hpp index 03f13bc0d..7f1081f9f 100644 --- a/stratosphere/creport/source/creport_crash_report.hpp +++ b/stratosphere/creport/source/creport_crash_report.hpp @@ -81,7 +81,7 @@ namespace ams::creport { } void BuildReport(os::ProcessId process_id, bool has_extra_info); - void GetFatalContext(FatalContext *out) const; + void GetFatalContext(::FatalCpuContext *out) const; void SaveReport(); private: void ProcessExceptions(); diff --git a/stratosphere/creport/source/creport_main.cpp b/stratosphere/creport/source/creport_main.cpp index 1f87dfcba..795e2112b 100644 --- a/stratosphere/creport/source/creport_main.cpp +++ b/stratosphere/creport/source/creport_main.cpp @@ -132,7 +132,7 @@ int main(int argc, char **argv) { } /* Throw fatal error. */ - FatalContext ctx; + ::FatalCpuContext ctx; g_crash_report.GetFatalContext(&ctx); - fatalWithContext(g_crash_report.GetResult().GetValue(), FatalType_ErrorScreen, &ctx); + fatalThrowWithContext(g_crash_report.GetResult().GetValue(), FatalPolicy_ErrorScreen, &ctx); } diff --git a/stratosphere/fatal/source/fatal_service.cpp b/stratosphere/fatal/source/fatal_service.cpp index b706d96fe..555f3ae26 100644 --- a/stratosphere/fatal/source/fatal_service.cpp +++ b/stratosphere/fatal/source/fatal_service.cpp @@ -49,23 +49,23 @@ namespace ams::fatal::srv { } Result ThrowFatal(Result result, os::ProcessId process_id) { - return this->ThrowFatalWithCpuContext(result, process_id, FatalType_ErrorReportAndErrorScreen, {}); + return this->ThrowFatalWithCpuContext(result, process_id, FatalPolicy_ErrorReportAndErrorScreen, {}); } - Result ThrowFatalWithPolicy(Result result, os::ProcessId process_id, FatalType policy) { + Result ThrowFatalWithPolicy(Result result, os::ProcessId process_id, FatalPolicy policy) { return this->ThrowFatalWithCpuContext(result, process_id, policy, {}); } - Result ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx); + Result ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalPolicy policy, const CpuContext &cpu_ctx); }; /* Context global. */ ServiceContext g_context; /* Throw implementation. */ - Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx) { + Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalPolicy policy, const CpuContext &cpu_ctx) { /* We don't support Error Report only fatals. */ - R_UNLESS(policy != FatalType_ErrorReport, ResultSuccess()); + R_UNLESS(policy != FatalPolicy_ErrorReport, ResultSuccess()); /* Note that we've thrown fatal. */ R_TRY(this->TrySetHasThrown()); @@ -100,7 +100,7 @@ namespace ams::fatal::srv { } /* Decide whether to generate a report. */ - this->context.generate_error_report = (policy == FatalType_ErrorReportAndErrorScreen); + this->context.generate_error_report = (policy == FatalPolicy_ErrorReportAndErrorScreen); /* Adjust error code (2000-0000 -> 2162-0002). */ if (R_SUCCEEDED(this->context.result)) { @@ -108,8 +108,8 @@ namespace ams::fatal::srv { } switch (policy) { - case FatalType_ErrorReportAndErrorScreen: - case FatalType_ErrorScreen: + case FatalPolicy_ErrorReportAndErrorScreen: + case FatalPolicy_ErrorScreen: /* Signal that we're throwing. */ this->event_manager.SignalEvents(); @@ -127,18 +127,18 @@ namespace ams::fatal::srv { } Result ThrowFatalForSelf(Result result) { - return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalType_ErrorScreen); + return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalPolicy_ErrorScreen); } Result UserService::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) { return g_context.ThrowFatal(result, client_pid.GetValue()); } - Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalType policy) { + Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy) { return g_context.ThrowFatalWithPolicy(result, client_pid.GetValue(), policy); } - Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx) { + Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx) { return g_context.ThrowFatalWithCpuContext(result, client_pid.GetValue(), policy, cpu_ctx); } diff --git a/stratosphere/fatal/source/fatal_service.hpp b/stratosphere/fatal/source/fatal_service.hpp index 52f28fce3..4f4f4baa1 100644 --- a/stratosphere/fatal/source/fatal_service.hpp +++ b/stratosphere/fatal/source/fatal_service.hpp @@ -28,8 +28,8 @@ namespace ams::fatal::srv { private: /* Actual commands. */ Result ThrowFatal(Result error, const sf::ClientProcessId &client_pid); - Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalType policy); - Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx); + Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy); + Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx); public: DEFINE_SERVICE_DISPATCH_TABLE { MAKE_SERVICE_COMMAND_META(ThrowFatal), diff --git a/stratosphere/fatal/source/fatal_task_screen.cpp b/stratosphere/fatal/source/fatal_task_screen.cpp index 7d1b098f4..6f0b34a15 100644 --- a/stratosphere/fatal/source/fatal_task_screen.cpp +++ b/stratosphere/fatal/source/fatal_task_screen.cpp @@ -137,7 +137,7 @@ namespace ams::fatal::srv { R_TRY(viOpenDefaultDisplay(&this->display)); /* Reset the display magnification to its default value. */ - u32 display_width, display_height; + s32 display_width, display_height; R_TRY(viGetDisplayLogicalResolution(&this->display, &display_width, &display_height)); /* viSetDisplayMagnification was added in 3.0.0. */ @@ -153,10 +153,10 @@ namespace ams::fatal::srv { /* Display a layer of 1280 x 720 at 1.5x magnification */ /* NOTE: N uses 2 (770x400) RGBA4444 buffers (tiled buffer + linear). */ /* We use a single 1280x720 tiled RGB565 buffer. */ - constexpr u32 raw_width = FatalScreenWidth; - constexpr u32 raw_height = FatalScreenHeight; - constexpr u32 layer_width = ((raw_width) * 3) / 2; - constexpr u32 layer_height = ((raw_height) * 3) / 2; + constexpr s32 raw_width = FatalScreenWidth; + constexpr s32 raw_height = FatalScreenHeight; + constexpr s32 layer_width = ((raw_width) * 3) / 2; + constexpr s32 layer_height = ((raw_height) * 3) / 2; const float layer_x = static_cast((display_width - layer_width) / 2); const float layer_y = static_cast((display_height - layer_height) / 2); diff --git a/stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp b/stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp index b42016d8f..717a632f0 100644 --- a/stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp +++ b/stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp @@ -25,16 +25,16 @@ namespace ams::pm::dmnt { } Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id) { - return pmdmntGetTitlePid(reinterpret_cast(out_process_id), static_cast(title_id)); + return pmdmntGetProcessId(reinterpret_cast(out_process_id), static_cast(title_id)); } Result GetApplicationProcessId(os::ProcessId *out_process_id) { - return pmdmntGetApplicationPid(reinterpret_cast(out_process_id)); + return pmdmntGetApplicationProcessId(reinterpret_cast(out_process_id)); } Result HookToCreateApplicationProcess(Handle *out_handle) { Event evt; - R_TRY(pmdmntEnableDebugForApplication(&evt)); + R_TRY(pmdmntHookToCreateApplicationProcess(&evt)); *out_handle = evt.revent; return ResultSuccess(); } diff --git a/stratosphere/libstratosphere/source/pm/pm_info_api.cpp b/stratosphere/libstratosphere/source/pm/pm_info_api.cpp index 8b6eeead6..d8c27d2a0 100644 --- a/stratosphere/libstratosphere/source/pm/pm_info_api.cpp +++ b/stratosphere/libstratosphere/source/pm/pm_info_api.cpp @@ -30,7 +30,7 @@ namespace ams::pm::info { Result GetTitleId(ncm::TitleId *out_title_id, os::ProcessId process_id) { std::scoped_lock lk(g_info_lock); - return pminfoGetTitleId(reinterpret_cast(out_title_id), static_cast(process_id)); + return pminfoGetProgramId(reinterpret_cast(out_title_id), static_cast(process_id)); } Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id) { diff --git a/stratosphere/libstratosphere/source/pm/pm_shell_api.cpp b/stratosphere/libstratosphere/source/pm/pm_shell_api.cpp index c71c6a917..513dc827f 100644 --- a/stratosphere/libstratosphere/source/pm/pm_shell_api.cpp +++ b/stratosphere/libstratosphere/source/pm/pm_shell_api.cpp @@ -19,7 +19,9 @@ namespace ams::pm::shell { /* Shell API. */ Result WEAK LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) { - return pmshellLaunchProcess(launch_flags, static_cast(loc.title_id), loc.storage_id, reinterpret_cast(out_process_id)); + static_assert(sizeof(ncm::TitleLocation) == sizeof(NcmProgramLocation)); + static_assert(alignof(ncm::TitleLocation) == alignof(NcmProgramLocation)); + return pmshellLaunchProgram(launch_flags, reinterpret_cast(&loc), reinterpret_cast(out_process_id)); } } diff --git a/stratosphere/libstratosphere/source/result/result_on_assertion.cpp b/stratosphere/libstratosphere/source/result/result_on_assertion.cpp index 848138fdc..5b3da6a6f 100644 --- a/stratosphere/libstratosphere/source/result/result_on_assertion.cpp +++ b/stratosphere/libstratosphere/source/result/result_on_assertion.cpp @@ -30,7 +30,7 @@ namespace ams::result::impl { AMS_ASSERT((ams::result::CallFatalOnResultAssertion)); /* TODO: ams::fatal:: */ - fatalSimple(result.GetValue()); + fatalThrow(result.GetValue()); while (true) { /* ... */ } } diff --git a/stratosphere/libstratosphere/source/updater/updater_api.cpp b/stratosphere/libstratosphere/source/updater/updater_api.cpp index 362424106..7072e9da7 100644 --- a/stratosphere/libstratosphere/source/updater/updater_api.cpp +++ b/stratosphere/libstratosphere/source/updater/updater_api.cpp @@ -149,10 +149,10 @@ namespace ams::updater { NcmContentMetaKey *records = reinterpret_cast(work_buffer); const auto title_type = GetNcmContentMetaType(mode); - u32 written_entries; - u32 total_entries; + s32 written_entries; + s32 total_entries; R_TRY(ncmContentMetaDatabaseList(&meta_db, &total_entries, &written_entries, records, MaxContentMetas * sizeof(*records), title_type, 0, 0, UINT64_MAX, NcmContentInstallType_Full)); - if (total_entries == 0) { + if (total_entries <= 0) { return ResultBootImagePackageNotFound(); } @@ -160,7 +160,7 @@ namespace ams::updater { /* Output is sorted, return the lowest valid exfat entry. */ if (total_entries > 1) { - for (size_t i = 0; i < total_entries; i++) { + for (size_t i = 0; i < size_t(total_entries); i++) { u8 attr; R_TRY(ncmContentMetaDatabaseGetAttributes(&meta_db, &records[i], &attr)); diff --git a/stratosphere/ro/source/impl/ro_service_impl.cpp b/stratosphere/ro/source/impl/ro_service_impl.cpp index 66938cef2..83ba5f2b1 100644 --- a/stratosphere/ro/source/impl/ro_service_impl.cpp +++ b/stratosphere/ro/source/impl/ro_service_impl.cpp @@ -86,8 +86,7 @@ namespace ams::ro::impl { R_ASSERT(svcGetInfo(&title_id.value, InfoType_TitleId, process_h, 0)); } else { /* 1.0.0-2.3.0: We're not inside loader, so ask pm. */ - os::ProcessId process_id = os::GetProcessId(process_h); - R_ASSERT(pminfoGetTitleId(&title_id.value, process_id.value)); + R_ASSERT(pm::info::GetTitleId(&title_id, os::GetProcessId(process_h))); } return title_id; }