pm: Use result definitions instead of magic numbers

This commit is contained in:
Michael Scire 2019-03-28 15:16:36 -07:00
parent db19fa0f7f
commit 696f66f620
6 changed files with 18 additions and 18 deletions

@ -1 +1 @@
Subproject commit 0359681475183bd9c519d8fa680641e185f4de8e
Subproject commit cd7f81f7b07a832258a7a8c4a39f1680f98bbecc

View file

@ -24,7 +24,7 @@
Result DebugMonitorService::GetUnknownStub(Out<u32> count, OutBuffer<u8> out_buf, u64 in_unk) {
/* This command seems stubbed. */
if (out_buf.num_elements >> 31) {
return 0xC0F;
return ResultPmInvalidSize;
}
count.SetValue(0);
return 0x0;
@ -32,7 +32,7 @@ Result DebugMonitorService::GetUnknownStub(Out<u32> count, OutBuffer<u8> out_buf
Result DebugMonitorService::GetDebugProcessIds(Out<u32> count, OutBuffer<u64> out_pids) {
if (out_pids.num_elements >> 31) {
return 0xC0F;
return ResultPmInvalidSize;
}
return Registration::GetDebugProcessIds(out_pids.buffer, out_pids.num_elements, count.GetPointer());
}
@ -49,7 +49,7 @@ Result DebugMonitorService::GetTitleProcessId(Out<u64> pid, u64 tid) {
pid.SetValue(proc->pid);
return 0;
}
return 0x20F;
return ResultPmProcessNotFound;
}
Result DebugMonitorService::EnableDebugForTitleId(Out<CopiedHandle> event, u64 tid) {
@ -64,7 +64,7 @@ Result DebugMonitorService::GetApplicationProcessId(Out<u64> pid) {
pid.SetValue(app_proc->pid);
return 0x0;
}
return 0x20F;
return ResultPmProcessNotFound;
}
Result DebugMonitorService::EnableDebugForApplication(Out<CopiedHandle> event) {
@ -83,7 +83,7 @@ Result DebugMonitorService::AtmosphereGetProcessInfo(Out<CopiedHandle> proc_hand
tid_sid.SetValue(proc->tid_sid);
return 0;
}
return 0x20F;
return ResultPmProcessNotFound;
}
Result DebugMonitorService::AtmosphereGetCurrentLimitInfo(Out<u64> cur_val, Out<u64> lim_val, u32 category, u32 resource) {

View file

@ -26,5 +26,5 @@ Result InformationService::GetTitleId(Out<u64> tid, u64 pid) {
tid.SetValue(proc->tid_sid.title_id);
return 0;
}
return 0x20F;
return ResultPmProcessNotFound;
}

View file

@ -80,7 +80,7 @@ void Registration::HandleProcessLaunch() {
/* Get the resource limit handle, ensure that we can launch the program. */
if ((program_info.application_type & 3) == 1 && HasApplicationProcess(NULL)) {
rc = 0xA0F;
rc = ResultPmApplicationRunning;
goto HANDLE_PROCESS_LAUNCH_END;
}
@ -190,11 +190,11 @@ Result Registration::LaunchDebugProcess(u64 pid) {
std::shared_ptr<Registration::Process> proc = GetProcess(pid);
if (proc == NULL) {
return 0x20F;
return ResultPmProcessNotFound;
}
if (proc->state >= ProcessState_Running) {
return 0x40F;
return ResultPmAlreadyStarted;
}
/* Check that this is a real program. */
@ -480,7 +480,7 @@ Result Registration::EnableDebugForTitleId(u64 tid, Handle *out) {
u64 old = g_debug_on_launch_tid.exchange(tid);
if (old) {
g_debug_on_launch_tid = old;
return 0x80F;
return ResultPmDebugHookInUse;
}
*out = g_debug_title_event->GetHandle();
return 0x0;

View file

@ -239,7 +239,7 @@ Handle ResourceLimitUtils::GetResourceLimitHandleByCategory(ResourceLimitCategor
Result ResourceLimitUtils::BoostSystemMemoryResourceLimit(u64 boost_size) {
Result rc = 0;
if (boost_size > g_memory_resource_limits[g_memory_limit_type][ResourceLimitCategory_Application]) {
return 0xC0F;
return ResultPmInvalidSize;
}
u64 app_size = g_memory_resource_limits[g_memory_limit_type][ResourceLimitCategory_Application] - boost_size;
if (kernelAbove500()) {

View file

@ -34,7 +34,7 @@ Result ShellService::TerminateProcessId(u64 pid) {
if (proc != nullptr) {
return svcTerminateProcess(proc->handle);
} else {
return 0x20F;
return ResultPmProcessNotFound;
}
}
@ -45,7 +45,7 @@ Result ShellService::TerminateTitleId(u64 tid) {
if (proc != NULL) {
return svcTerminateProcess(proc->handle);
} else {
return 0x20F;
return ResultPmProcessNotFound;
}
}
@ -62,9 +62,9 @@ Result ShellService::FinalizeExitedProcess(u64 pid) {
auto proc = Registration::GetProcess(pid);
if (proc == NULL) {
return 0x20F;
return ResultPmProcessNotFound;
} else if (proc->state != ProcessState_Exited) {
return 0x60F;
return ResultPmNotExited;
} else {
Registration::FinalizeExitedProcess(proc);
return 0x0;
@ -79,7 +79,7 @@ Result ShellService::ClearProcessNotificationFlag(u64 pid) {
proc->flags &= ~PROCESSFLAGS_CRASHED;
return 0x0;
} else {
return 0x20F;
return ResultPmProcessNotFound;
}
}
@ -98,7 +98,7 @@ Result ShellService::GetApplicationProcessId(Out<u64> pid) {
pid.SetValue(app_proc->pid);
return 0;
}
return 0x20F;
return ResultPmProcessNotFound;
}
Result ShellService::BoostSystemMemoryResourceLimit(u64 sysmem_size) {