From 1867bc1264e050d2d20d4049cbca5fca5700ddb8 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 26 Jun 2020 11:36:38 -0700 Subject: [PATCH] sysupdater: Add ValidateUpdate, begin implementing Async logic --- libstratosphere/include/stratosphere.hpp | 1 + .../impl/ams_system_thread_definitions.hpp | 2 + libstratosphere/include/stratosphere/err.hpp | 19 ++++++++ .../stratosphere/err/err_error_context.hpp | 45 +++++++++++++++++++ .../stratosphere/ncm/ncm_content_meta.hpp | 2 +- .../stratosphere/os/os_thread_common.hpp | 2 + .../stratosphere/sf/sf_buffer_tags.hpp | 1 - libvapours/include/vapours/results.hpp | 4 +- .../include/vapours/results/nim_results.hpp | 26 +++++++++++ .../include/vapours/results/ns_results.hpp | 27 +++++++++++ 10 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 libstratosphere/include/stratosphere/err.hpp create mode 100644 libstratosphere/include/stratosphere/err/err_error_context.hpp create mode 100644 libvapours/include/vapours/results/nim_results.hpp create mode 100644 libvapours/include/vapours/results/ns_results.hpp diff --git a/libstratosphere/include/stratosphere.hpp b/libstratosphere/include/stratosphere.hpp index 81f1e237..7a51e59e 100644 --- a/libstratosphere/include/stratosphere.hpp +++ b/libstratosphere/include/stratosphere.hpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp b/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp index 3db6c394..7d60ab72 100644 --- a/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp +++ b/libstratosphere/include/stratosphere/ams/impl/ams_system_thread_definitions.hpp @@ -62,6 +62,7 @@ namespace ams::impl { AMS_DEFINE_SYSTEM_THREAD(16, mitm_fs, RomFileSystemInitializeThread); AMS_DEFINE_SYSTEM_THREAD(21, mitm, DebugThrowThread); AMS_DEFINE_SYSTEM_THREAD(21, mitm_sysupdater, IpcServer); + AMS_DEFINE_SYSTEM_THREAD(21, mitm_sysupdater, AsyncPrepareSdCardUpdateTask); /* boot2. */ AMS_DEFINE_SYSTEM_THREAD(20, boot2, Main); @@ -94,6 +95,7 @@ namespace ams::impl { /* ns.*/ AMS_DEFINE_SYSTEM_THREAD(21, ns, ApplicationManagerIpcSession); + AMS_DEFINE_SYSTEM_THREAD(21, nssrv, AsyncPrepareCardUpdateTask); /* settings. */ AMS_DEFINE_SYSTEM_THREAD(21, settings, Main); diff --git a/libstratosphere/include/stratosphere/err.hpp b/libstratosphere/include/stratosphere/err.hpp new file mode 100644 index 00000000..c8cb979a --- /dev/null +++ b/libstratosphere/include/stratosphere/err.hpp @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include diff --git a/libstratosphere/include/stratosphere/err/err_error_context.hpp b/libstratosphere/include/stratosphere/err/err_error_context.hpp new file mode 100644 index 00000000..df40e82b --- /dev/null +++ b/libstratosphere/include/stratosphere/err/err_error_context.hpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include + +namespace ams::err { + + enum class ErrorContextType : u8 { + None = 0, + Http = 1, + FileSystem = 2, + WebMediaPlayer = 3, + LocalContentShare = 4, + }; + + struct PaddingErrorContext { + u8 padding[0x200 - 8]; + }; + + struct ErrorContext : public sf::LargeData, public sf::PrefersMapAliasTransferMode { + ErrorContextType type; + u8 reserved[7]; + + union { + PaddingErrorContext padding; + }; + }; + static_assert(sizeof(ErrorContext) == 0x200); + static_assert(util::is_pod::value); + +} diff --git a/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp b/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp index 3f015e80..9810b765 100644 --- a/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp +++ b/libstratosphere/include/stratosphere/ncm/ncm_content_meta.hpp @@ -45,7 +45,7 @@ namespace ams::ncm { }; } - constexpr ContentMetaKey ToKey() { + constexpr ContentMetaKey ToKey() const { return ContentMetaKey::Make(this->id, this->version, this->type); } }; diff --git a/libstratosphere/include/stratosphere/os/os_thread_common.hpp b/libstratosphere/include/stratosphere/os/os_thread_common.hpp index 8e634dc9..8c9373fc 100644 --- a/libstratosphere/include/stratosphere/os/os_thread_common.hpp +++ b/libstratosphere/include/stratosphere/os/os_thread_common.hpp @@ -27,6 +27,8 @@ namespace ams::os { constexpr inline s32 DefaultThreadPriority = ThreadPriorityRangeSize / 2; constexpr inline s32 LowestThreadPriority = ThreadPriorityRangeSize - 1; + constexpr inline s32 InvalidThreadPriority = 127; + constexpr inline s32 LowestSystemThreadPriority = 35; constexpr inline s32 HighestSystemThreadPriority = -12; diff --git a/libstratosphere/include/stratosphere/sf/sf_buffer_tags.hpp b/libstratosphere/include/stratosphere/sf/sf_buffer_tags.hpp index 985a4277..4467e177 100644 --- a/libstratosphere/include/stratosphere/sf/sf_buffer_tags.hpp +++ b/libstratosphere/include/stratosphere/sf/sf_buffer_tags.hpp @@ -13,7 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #pragma once namespace ams::sf { diff --git a/libvapours/include/vapours/results.hpp b/libvapours/include/vapours/results.hpp index fbebb06b..4d4c41a5 100644 --- a/libvapours/include/vapours/results.hpp +++ b/libvapours/include/vapours/results.hpp @@ -37,8 +37,10 @@ #include #include #include -#include #include +#include +#include +#include #include #include #include diff --git a/libvapours/include/vapours/results/nim_results.hpp b/libvapours/include/vapours/results/nim_results.hpp new file mode 100644 index 00000000..c0607726 --- /dev/null +++ b/libvapours/include/vapours/results/nim_results.hpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include + +namespace ams::nim { + + R_DEFINE_NAMESPACE_RESULT_MODULE(137); + + R_DEFINE_ERROR_RESULT(HttpConnectionCanceled, 70); + +} diff --git a/libvapours/include/vapours/results/ns_results.hpp b/libvapours/include/vapours/results/ns_results.hpp new file mode 100644 index 00000000..557b03c8 --- /dev/null +++ b/libvapours/include/vapours/results/ns_results.hpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +#include + +namespace ams::ns { + + R_DEFINE_NAMESPACE_RESULT_MODULE(16); + + R_DEFINE_ERROR_RESULT(Canceled, 90); + R_DEFINE_ERROR_RESULT(OutOfMaxRunningTask, 110); + +}