kern: add hardware single step extension

This commit is contained in:
Michael Scire 2021-07-27 05:34:40 -07:00 committed by SciresM
parent 904ab19823
commit 4075d24e0c
10 changed files with 226 additions and 4 deletions

View file

@ -186,7 +186,24 @@ namespace ams::kern::svc {
R_UNLESS(KTargetSystem::IsDebugMode(), svc::ResultNotImplemented());
/* Validate the context flags. */
R_UNLESS((context_flags | ams::svc::ThreadContextFlag_All) == ams::svc::ThreadContextFlag_All, svc::ResultInvalidEnumValue());
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
{
/* Check that the flags are a subset of the allowable. */
constexpr u32 AllFlagsMask = ams::svc::ThreadContextFlag_All | ams::svc::ThreadContextFlag_SetSingleStep | ams::svc::ThreadContextFlag_ClearSingleStep;
R_UNLESS((context_flags | AllFlagsMask) == AllFlagsMask, svc::ResultInvalidEnumValue());
/* Check that thread isn't both setting and clearing single step. */
const bool set_ss = (context_flags & ams::svc::ThreadContextFlag_SetSingleStep) != 0;
const bool clear_ss = (context_flags & ams::svc::ThreadContextFlag_ClearSingleStep) != 0;
R_UNLESS(!(set_ss && clear_ss), svc::ResultInvalidEnumValue());
}
#else
{
/* Check that the flags are a subset of the allowable. */
R_UNLESS((context_flags | ams::svc::ThreadContextFlag_All) == ams::svc::ThreadContextFlag_All, svc::ResultInvalidEnumValue());
}
#endif
/* Copy the thread context from userspace. */
ams::svc::ThreadContext context;