1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-22 20:06:40 +00:00

strat: fixes for compat with latest libnx

This commit is contained in:
Michael Scire 2019-10-27 15:57:30 -07:00 committed by SciresM
parent c6b9a0c4bf
commit 1636668762
12 changed files with 35 additions and 34 deletions

View file

@ -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<ams::fatal::CpuContext *>(_out);
std::memset(out, 0, sizeof(*out));

View file

@ -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();

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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),

View file

@ -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<float>((display_width - layer_width) / 2);
const float layer_y = static_cast<float>((display_height - layer_height) / 2);

View file

@ -25,16 +25,16 @@ namespace ams::pm::dmnt {
}
Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id) {
return pmdmntGetTitlePid(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
return pmdmntGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
}
Result GetApplicationProcessId(os::ProcessId *out_process_id) {
return pmdmntGetApplicationPid(reinterpret_cast<u64 *>(out_process_id));
return pmdmntGetApplicationProcessId(reinterpret_cast<u64 *>(out_process_id));
}
Result HookToCreateApplicationProcess(Handle *out_handle) {
Event evt;
R_TRY(pmdmntEnableDebugForApplication(&evt));
R_TRY(pmdmntHookToCreateApplicationProcess(&evt));
*out_handle = evt.revent;
return ResultSuccess();
}

View file

@ -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<u64 *>(out_title_id), static_cast<u64>(process_id));
return pminfoGetProgramId(reinterpret_cast<u64 *>(out_title_id), static_cast<u64>(process_id));
}
Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id) {

View file

@ -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<u64>(loc.title_id), loc.storage_id, reinterpret_cast<u64 *>(out_process_id));
static_assert(sizeof(ncm::TitleLocation) == sizeof(NcmProgramLocation));
static_assert(alignof(ncm::TitleLocation) == alignof(NcmProgramLocation));
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out_process_id));
}
}

View file

@ -30,7 +30,7 @@ namespace ams::result::impl {
AMS_ASSERT((ams::result::CallFatalOnResultAssertion));
/* TODO: ams::fatal:: */
fatalSimple(result.GetValue());
fatalThrow(result.GetValue());
while (true) { /* ... */ }
}

View file

@ -149,10 +149,10 @@ namespace ams::updater {
NcmContentMetaKey *records = reinterpret_cast<NcmContentMetaKey *>(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));

View file

@ -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;
}