1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-08 13:11:49 +00:00

loader: update for changes in 14.0.0

This commit is contained in:
Michael Scire 2022-04-17 20:11:05 -07:00
parent 70d67bb115
commit f5052b4bca
5 changed files with 100 additions and 447 deletions

View file

@ -176,7 +176,7 @@ namespace ams::ldr {
AcidFlag_DeprecatedUseSecureMemory = (1 << 2),
AcidFlag_PoolPartitionShift = 2,
AcidFlag_PoolPartitionMask = (3 << AcidFlag_PoolPartitionShift),
AcidFlag_PoolPartitionMask = (0xF << AcidFlag_PoolPartitionShift),
};
enum PoolPartition {
@ -198,7 +198,8 @@ namespace ams::ldr {
u32 magic;
u32 size;
u8 version;
u8 reserved_209[3];
u8 unknown_209;
u8 reserved_20A[2];
u32 flags;
ncm::ProgramId program_id_min;
ncm::ProgramId program_id_max;

View file

@ -1,399 +0,0 @@
/*
* Copyright (c) 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 <http://www.gnu.org/licenses/>.
*/
struct MinimumProgramVersion {
ncm::ProgramId program_id;
u32 version;
};
constexpr u32 MakeSystemVersion(u32 major, u32 minor, u32 micro) {
return (major << 26) | (minor << 20) | (micro << 16);
}
constexpr MinimumProgramVersion g_MinimumProgramVersions810[] = {
{ncm::SystemProgramId::Settings, 1},
{ncm::SystemProgramId::Bus, 1},
{ncm::SystemProgramId::Audio, 1},
{ncm::SystemProgramId::NvServices, 1},
{ncm::SystemProgramId::Ns, 1},
{ncm::SystemProgramId::Ssl, 1},
{ncm::SystemProgramId::Es, 1},
{ncm::SystemProgramId::Creport, 1},
{ncm::SystemProgramId::Ro, 1},
};
constexpr size_t g_MinimumProgramVersionsCount810 = util::size(g_MinimumProgramVersions810);
constexpr MinimumProgramVersion g_MinimumProgramVersions900[] = {
/* All non-Development System Modules. */
{ncm::SystemProgramId::Usb, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Tma, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Boot2, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Settings, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bus, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bcat, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Friends, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Nifm, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ptm, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::BsdSockets, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Hid, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Audio, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::LogManager, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Wlan, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Ldn, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::NvServices, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pcv, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ppc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pcie, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Account, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ns, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Nfc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Psc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::CapSrv, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Am, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ssl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Nim, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Lbl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Btm, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Erpt, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Time, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Vi, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pctl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Npns, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Eupld, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Glue, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Eclct, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Es, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Fatal, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Grc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Creport, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ro, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Sdb, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Migration, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::JpegDec, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::SafeMode, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Olsc, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Ngct, MakeSystemVersion(9, 0, 0)},
/* All Web Applets. */
{ncm::WebAppletId::Web, MakeSystemVersion(9, 0, 0)},
{ncm::WebAppletId::Shop, MakeSystemVersion(9, 0, 0)},
{ncm::WebAppletId::OfflineWeb, MakeSystemVersion(9, 0, 0)},
{ncm::WebAppletId::LoginShare, MakeSystemVersion(9, 0, 0)},
{ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(9, 0, 0)},
};
constexpr size_t g_MinimumProgramVersionsCount900 = util::size(g_MinimumProgramVersions900);
constexpr MinimumProgramVersion g_MinimumProgramVersions910[] = {
/* All non-Development System Modules. */
{ncm::SystemProgramId::Usb, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Tma, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Boot2, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Settings, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bus, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bluetooth, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Bcat, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Friends, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Nifm, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Ptm, MakeSystemVersion(9, 0, 0)},
/* {ncm::SystemProgramId::Shell, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::BsdSockets, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Hid, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Audio, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::LogManager, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Wlan, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Cs, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Ldn, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::NvServices, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pcv, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Ppc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pcie, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Account, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Ns, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Nfc, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Psc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::CapSrv, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Am, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Ssl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Nim, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Cec, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Tspm, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Spl, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Lbl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Btm, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Erpt, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Time, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Vi, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Pctl, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Npns, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Eupld, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Glue, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Eclct, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Es, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Fatal, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Grc, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Creport, MakeSystemVersion(9, 1, 0)},
{ncm::SystemProgramId::Ro, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Profiler, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Sdb, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Migration, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Jit, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::JpegDec, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::SafeMode, MakeSystemVersion(9, 0, 0)},
{ncm::SystemProgramId::Olsc, MakeSystemVersion(9, 1, 0)},
/* {ncm::SystemProgramId::Dt, MakeSystemVersion(9, 0, 0)}, */
/* {ncm::SystemProgramId::Nd, MakeSystemVersion(9, 0, 0)}, */
{ncm::SystemProgramId::Ngct, MakeSystemVersion(9, 1, 0)},
/* All Web Applets. */
{ncm::WebAppletId::Web, MakeSystemVersion(9, 1, 0)},
{ncm::WebAppletId::Shop, MakeSystemVersion(9, 1, 0)},
{ncm::WebAppletId::OfflineWeb, MakeSystemVersion(9, 1, 0)},
{ncm::WebAppletId::LoginShare, MakeSystemVersion(9, 1, 0)},
{ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(9, 1, 0)},
};
constexpr size_t g_MinimumProgramVersionsCount910 = util::size(g_MinimumProgramVersions910);
constexpr MinimumProgramVersion g_MinimumProgramVersions1000[] = {
/* All non-Development System Modules. */
{ncm::SystemProgramId::Usb, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Tma, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Boot2, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Settings, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Bus, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Bluetooth, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Bcat, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Friends, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Nifm, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ptm, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Shell, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::BsdSockets, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Hid, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Audio, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::LogManager, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Wlan, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Cs, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Ldn, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::NvServices, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Pcv, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ppc, MakeSystemVersion( 9, 0, 0)},
{ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Pcie, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Account, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ns, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Nfc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Psc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::CapSrv, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Am, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ssl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Nim, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Cec, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Tspm, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Spl, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Lbl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Btm, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Erpt, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Time, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Vi, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Pctl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Npns, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Eupld, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Glue, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Eclct, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Es, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Fatal, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Grc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Creport, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ro, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Profiler, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Sdb, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Migration, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Jit, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::JpegDec, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::SafeMode, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Olsc, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Dt, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Nd, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Ngct, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Pgl, MakeSystemVersion(10, 0, 0)}, */
/* All Web Applets. */
{ncm::WebAppletId::Web, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::Shop, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::OfflineWeb, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::LoginShare, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(10, 0, 0)},
};
constexpr size_t g_MinimumProgramVersionsCount1000 = util::size(g_MinimumProgramVersions1000);
constexpr MinimumProgramVersion g_MinimumProgramVersions1010[] = {
/* All non-Development System Modules. */
{ncm::SystemProgramId::Usb, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Tma, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Boot2, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Settings, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Bus, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Bluetooth, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Bcat, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Friends, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Nifm, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ptm, MakeSystemVersion(10, 0, 2)},
/* {ncm::SystemProgramId::Shell, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::BsdSockets, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Hid, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Audio, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::LogManager, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Wlan, MakeSystemVersion(10, 1, 0)},
/* {ncm::SystemProgramId::Cs, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Ldn, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::NvServices, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Pcv, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ppc, MakeSystemVersion( 9, 0, 0)},
{ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Pcie, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Account, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ns, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Nfc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Psc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::CapSrv, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Am, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Ssl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Nim, MakeSystemVersion(10, 1, 0)},
/* {ncm::SystemProgramId::Cec, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Tspm, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Spl, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Lbl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Btm, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Erpt, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Time, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Vi, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Pctl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Npns, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Eupld, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Glue, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Eclct, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Es, MakeSystemVersion(10, 1, 0)},
{ncm::SystemProgramId::Fatal, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Grc, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Creport, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Ro, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Profiler, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Sdb, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Migration, MakeSystemVersion(10, 1, 0)},
/* {ncm::SystemProgramId::Jit, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::JpegDec, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::SafeMode, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Olsc, MakeSystemVersion(10, 1, 0)},
/* {ncm::SystemProgramId::Dt, MakeSystemVersion(10, 0, 0)}, */
/* {ncm::SystemProgramId::Nd, MakeSystemVersion(10, 0, 0)}, */
{ncm::SystemProgramId::Ngct, MakeSystemVersion(10, 0, 0)},
/* {ncm::SystemProgramId::Pgl, MakeSystemVersion(10, 0, 0)}, */
/* All Web Applets. */
{ncm::WebAppletId::Web, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::Shop, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::OfflineWeb, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::LoginShare, MakeSystemVersion(10, 0, 0)},
{ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(10, 0, 0)},
};
constexpr size_t g_MinimumProgramVersionsCount1010 = util::size(g_MinimumProgramVersions1010);
constexpr MinimumProgramVersion g_MinimumProgramVersions1100[] = {
/* All non-Development System Modules. */
{ncm::SystemProgramId::Usb, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Tma, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Boot2, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Settings, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Bus, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Bluetooth, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Bcat, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Dmnt, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Friends, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Nifm, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Ptm, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Shell, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::BsdSockets, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Hid, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Audio, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::LogManager, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Wlan, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Cs, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Ldn, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::NvServices, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Pcv, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Ppc, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::NvnFlinger, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Pcie, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Account, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Ns, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Nfc, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Psc, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::CapSrv, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Am, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Ssl, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Nim, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Cec, MakeSystemVersion(11, 0, 0)}, */
/* {ncm::SystemProgramId::Tspm, MakeSystemVersion(11, 0, 0)}, */
/* {ncm::SystemProgramId::Spl, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Lbl, MakeSystemVersion(10, 0, 0)},
{ncm::SystemProgramId::Btm, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Erpt, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Time, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Vi, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Pctl, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Npns, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Eupld, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Glue, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Eclct, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Es, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Fatal, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Grc, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Creport, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Ro, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Profiler, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Sdb, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Migration, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Jit, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::JpegDec, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::SafeMode, MakeSystemVersion(11, 0, 0)},
{ncm::SystemProgramId::Olsc, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Dt, MakeSystemVersion(11, 0, 0)}, */
/* {ncm::SystemProgramId::Nd, MakeSystemVersion(11, 0, 0)}, */
{ncm::SystemProgramId::Ngct, MakeSystemVersion(11, 0, 0)},
/* {ncm::SystemProgramId::Pgl, MakeSystemVersion(11, 0, 0)}, */
/* All Web Applets. */
{ncm::WebAppletId::Web, MakeSystemVersion(11, 0, 0)},
{ncm::WebAppletId::Shop, MakeSystemVersion(11, 0, 0)},
{ncm::WebAppletId::OfflineWeb, MakeSystemVersion(11, 0, 0)},
{ncm::WebAppletId::LoginShare, MakeSystemVersion(11, 0, 0)},
{ncm::WebAppletId::WifiWebAuth, MakeSystemVersion(11, 0, 0)},
};
constexpr size_t g_MinimumProgramVersionsCount1100 = util::size(g_MinimumProgramVersions1100);

View file

@ -186,7 +186,7 @@ namespace ams::ldr {
);
enum class MemoryRegionType : u32 {
None = 0,
NoMapping = 0,
KernelTraceBuffer = 1,
OnMemoryBootImage = 2,
DTB = 3,
@ -200,17 +200,31 @@ namespace ams::ldr {
DEFINE_CAPABILITY_FIELD(Region2, ReadOnly1, 6, MemoryRegionType);
DEFINE_CAPABILITY_FIELD(ReadOnly2, Region2, 1, bool);
bool IsValid(const util::BitPack32 *kac, size_t kac_count) const {
static bool IsValidRegionType(const util::BitPack32 *kac, size_t kac_count, MemoryRegionType region_type, bool is_read_only) {
if (region_type != MemoryRegionType::NoMapping) {
for (size_t i = 0; i < kac_count; i++) {
if (GetCapabilityId(kac[i]) == Id) {
const auto restriction = Decode(kac[i]);
if (this->GetValue() == restriction.GetValue()) {
if ((restriction.GetRegion0() == region_type && (is_read_only || !restriction.GetReadOnly0())) ||
(restriction.GetRegion1() == region_type && (is_read_only || !restriction.GetReadOnly1())) ||
(restriction.GetRegion2() == region_type && (is_read_only || !restriction.GetReadOnly2())))
{
return true;
}
}
}
return false;
} else {
return true;
}
}
bool IsValid(const util::BitPack32 *kac, size_t kac_count) const {
return IsValidRegionType(kac, kac_count, this->GetRegion0(), this->GetReadOnly0()) &&
IsValidRegionType(kac, kac_count, this->GetRegion1(), this->GetReadOnly1()) &&
IsValidRegionType(kac, kac_count, this->GetRegion2(), this->GetReadOnly2());
}
);

View file

@ -89,6 +89,13 @@ namespace ams::ldr {
R_UNLESS((acid->flags & Acid::AcidFlag_Production) != 0, ldr::ResultInvalidMeta());
}
/* Validate that the acid version is correct. */
constexpr u8 MinimumValueForAcid209 = 14; /* TODO: What is the actual meaning of this value? */
if (acid->unknown_209 < MinimumValueForAcid209) {
R_UNLESS(acid->version == 0, ldr::ResultInvalidMeta());
R_UNLESS(acid->unknown_209 == 0, ldr::ResultInvalidMeta());
}
/* Validate Fac, Sac, Kac. */
R_TRY(ValidateSubregion(sizeof(Acid), size, acid->fac_offset, acid->fac_size));
R_TRY(ValidateSubregion(sizeof(Acid), size, acid->sac_offset, acid->sac_size));

View file

@ -81,9 +81,6 @@ namespace ams::ldr {
bool g_has_nso[Nso_Count];
NsoHeader g_nso_headers[Nso_Count];
/* Anti-downgrade. */
#include "ldr_anti_downgrade_tables.inc"
Result ValidateProgramVersion(ncm::ProgramId program_id, u32 version) {
/* No version verification is done before 8.1.0. */
R_SUCCEED_IF(hos::GetVersion() < hos::Version_8_1_0);
@ -91,40 +88,9 @@ namespace ams::ldr {
/* No verification is done if development. */
R_SUCCEED_IF(IsDevelopmentForAntiDowngradeCheck());
/* Do version-dependent validation, if compiled to do so. */
#ifdef LDR_VALIDATE_PROCESS_VERSION
const MinimumProgramVersion *entries = nullptr;
size_t num_entries = 0;
const auto hos_version = hos::GetVersion();
if (hos_version >= hos::Version_11_0_0) {
entries = g_MinimumProgramVersions1100;
num_entries = g_MinimumProgramVersionsCount1100;
} else if (hos_version >= hos::Version_10_1_0) {
entries = g_MinimumProgramVersions1010;
num_entries = g_MinimumProgramVersionsCount1010;
} else if (hos_version >= hos::Version_10_0_0) {
entries = g_MinimumProgramVersions1000;
num_entries = g_MinimumProgramVersionsCount1000;
} else if (hos_version >= hos::Version_9_1_0) {
entries = g_MinimumProgramVersions910;
num_entries = g_MinimumProgramVersionsCount910;
} else if (hos_version >= hos::Version_9_0_0) {
entries = g_MinimumProgramVersions900;
num_entries = g_MinimumProgramVersionsCount900;
} else if (hos_version >= hos::Version_8_1_0) {
entries = g_MinimumProgramVersions810;
num_entries = g_MinimumProgramVersionsCount810;
}
for (size_t i = 0; i < num_entries; i++) {
if (entries[i].program_id == program_id) {
R_UNLESS(entries[i].version <= version, ldr::ResultInvalidVersion());
}
}
#else
/* TODO: Anti-downgrade checking does not make very much sense for us. Should we do anything? */
AMS_UNUSED(program_id, version);
#endif
R_SUCCEED();
}
@ -216,6 +182,60 @@ namespace ams::ldr {
R_SUCCEED();
}
constexpr const ncm::ProgramId UnqualifiedApprovalProgramIds[] = {
{ 0x010003F003A34000 }, /* Pokemon: Let's Go, Pikachu! */
{ 0x0100152000022000 }, /* Mario Kart 8 Deluxe */
{ 0x0100165003504000 }, /* Nintendo Labo Toy-Con 04: VR Kit */
{ 0x0100187003A36000 }, /* Pokemon: Let's Go, Eevee! */
{ 0x01002E5008C56000 }, /* Pokemon Sword [Live Tournament] */
{ 0x01002FF008C24000 }, /* Ring Fit Adventure */
{ 0x010049900F546001 }, /* Super Mario 3D All-Stars: Super Mario 64 */
{ 0x010057D00ECE4000 }, /* Nintendo Switch Online (Nintendo 64) [for Japan] */
{ 0x01006F8002326000 }, /* Animal Crossing: New Horizons */
{ 0x01006FB00F50E000 }, /* [???] */
{ 0x010070300F50C000 }, /* [???] */
{ 0x010075100E8EC000 }, /* 马力欧卡丁车8 豪华版 [Mario Kart 8 Deluxe for China] */
{ 0x01008DB008C2C000 }, /* Pokemon Shield */
{ 0x01009AD008C4C000 }, /* Pokemon: Let's Go, Pikachu! [Kiosk] */
{ 0x0100A66003384000 }, /* Hulu */
{ 0x0100ABF008968000 }, /* Pokemon Sword */
{ 0x0100C9A00ECE6000 }, /* Nintendo Switch Online (Nintendo 64) [for America] */
{ 0x0100ED100BA3A000 }, /* Mario Kart Live: Home Circuit */
{ 0x0100F38011CFE000 }, /* Animal Crossing: New Horizons Island Transfer Tool */
{ 0x0100F6B011028000 }, /* 健身环大冒险 [Ring Fit Adventure for China] */
};
/* Check that the unqualified approval programs are sorted. */
static_assert([]() -> bool {
for (size_t i = 0; i < util::size(UnqualifiedApprovalProgramIds) - 1; ++i) {
if (UnqualifiedApprovalProgramIds[i].value >= UnqualifiedApprovalProgramIds[i + 1].value) {
return false;
}
}
return true;
}());
bool IsUnqualifiedApprovalProgramId(ncm::ProgramId program_id) {
/* Check if the program id is one with unqualified approval. */
return std::binary_search(std::begin(UnqualifiedApprovalProgramIds), std::end(UnqualifiedApprovalProgramIds), program_id);
}
bool IsUnqualifiedApproval(const Meta *meta) {
/* If the meta has unqualified approval flag, it's unqualified approval. */
if (meta->acid->flags & ldr::Acid::AcidFlag_UnqualifiedApproval) {
return true;
}
/* If the unqualified approval flag is not set, the program must be an application. */
if (!IsApplication(meta)) {
return false;
}
/* The program id must be a force unqualified approval program id. */
return IsUnqualifiedApprovalProgramId(meta->acid->program_id_min) && meta->acid->program_id_min == meta->acid->program_id_max;
}
Result ValidateMeta(const Meta *meta, const ncm::ProgramLocation &loc, const fs::CodeVerificationData &code_verification_data) {
/* Validate version. */
R_TRY(ValidateProgramVersion(loc.program_id, meta->npdm->version));
@ -228,7 +248,7 @@ namespace ams::ldr {
R_TRY(TestCapability(static_cast<const util::BitPack32 *>(meta->acid_kac), meta->acid->kac_size / sizeof(util::BitPack32), static_cast<const util::BitPack32 *>(meta->aci_kac), meta->aci->kac_size / sizeof(util::BitPack32)));
/* If we have data to validate, validate it. */
if (code_verification_data.has_data && meta->check_verification_data) {
if (meta->check_verification_data) {
const u8 *sig = code_verification_data.signature;
const size_t sig_size = sizeof(code_verification_data.signature);
const u8 *mod = static_cast<u8 *>(meta->modulus);
@ -239,7 +259,15 @@ namespace ams::ldr {
const size_t hsh_size = sizeof(code_verification_data.target_hash);
const bool is_signature_valid = crypto::VerifyRsa2048PssSha256WithHash(sig, sig_size, mod, mod_size, exp, exp_size, hsh, hsh_size);
R_UNLESS(is_signature_valid, ldr::ResultInvalidNcaSignature());
/* If the signature check fails, we need to check if this is allowable. */
if (!is_signature_valid) {
/* We have to enforce signature checks on prod and when we have a signature to check on dev. */
R_UNLESS(IsDevelopmentForAcidProductionCheck(), ldr::ResultInvalidNcaSignature());
R_UNLESS(!code_verification_data.has_data, ldr::ResultInvalidNcaSignature());
/* There was no signature to check on dev. Check if this is acceptable. */
R_UNLESS(IsUnqualifiedApproval(meta), ldr::ResultInvalidNcaSignature());
}
}
/* All good. */
@ -298,6 +326,8 @@ namespace ams::ldr {
/* 5.0.0+ Set Pool Partition. */
if (hos::GetVersion() >= hos::Version_5_0_0) {
/* TODO: Nintendo no longer accepts Applet when pool partition == application. Would this break hbl/anything else in the hb ecosystem? */
/* TODO: Nintendo uses a helper bool MakeSvcPoolPartitionFlag(u32 *out, Acid::PoolPartition partition); */
switch (GetPoolPartition(meta)) {
case Acid::PoolPartition_Application:
if (IsApplet(meta)) {