mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-01 02:37:27 +01:00
ams: initial support for 9.0.0
This commit is contained in:
parent
6ee8720028
commit
93d83c5bb9
Binary file not shown.
Binary file not shown.
@ -27,11 +27,12 @@
|
|||||||
#define ATMOSPHERE_TARGET_FIRMWARE_700 8
|
#define ATMOSPHERE_TARGET_FIRMWARE_700 8
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_800 9
|
#define ATMOSPHERE_TARGET_FIRMWARE_800 9
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_810 10
|
#define ATMOSPHERE_TARGET_FIRMWARE_810 10
|
||||||
|
#define ATMOSPHERE_TARGET_FIRMWARE_900 11
|
||||||
|
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_810
|
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_900
|
||||||
|
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE_100
|
#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE_100
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_810
|
#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_900
|
||||||
|
|
||||||
/* TODO: What should this be, for release? */
|
/* TODO: What should this be, for release? */
|
||||||
#define ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG ATMOSPHERE_TARGET_FIRMWARE_CURRENT
|
#define ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG ATMOSPHERE_TARGET_FIRMWARE_CURRENT
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#define ATMOSPHERE_RELEASE_VERSION_MINOR 9
|
#define ATMOSPHERE_RELEASE_VERSION_MINOR 9
|
||||||
#define ATMOSPHERE_RELEASE_VERSION_MICRO 3
|
#define ATMOSPHERE_RELEASE_VERSION_MICRO 3
|
||||||
|
|
||||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 8
|
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 9
|
||||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 1
|
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 0
|
||||||
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 0
|
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 0
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -85,6 +85,9 @@ void bootup_misc_mmio(void) {
|
|||||||
setup_dram_magic_numbers();
|
setup_dram_magic_numbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* On 9.0.0+, Nintendo writes random values to context save scratch here, and locks the SRK scratch. */
|
||||||
|
/* There's no real need for us to do this, so we won't. */
|
||||||
|
|
||||||
/* Mark TMR5, TMR6, TMR7, TMR8, WDT0, WDT1, WDT2 and WDT3 as secure. */
|
/* Mark TMR5, TMR6, TMR7, TMR8, WDT0, WDT1, WDT2 and WDT3 as secure. */
|
||||||
SHARED_TIMER_SECURE_CFG_0 = 0xF1E0;
|
SHARED_TIMER_SECURE_CFG_0 = 0xF1E0;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void i2c_init(I2CDevice id) {
|
|||||||
|
|
||||||
/* Wait a while until BUS_CLEAR_DONE is set. */
|
/* Wait a while until BUS_CLEAR_DONE is set. */
|
||||||
for (unsigned int i = 0; i < 10; i++) {
|
for (unsigned int i = 0; i < 10; i++) {
|
||||||
wait(20000);
|
wait(25);
|
||||||
if (regs->I2C_INTERRUPT_STATUS_REGISTER_0 & 0x800) {
|
if (regs->I2C_INTERRUPT_STATUS_REGISTER_0 & 0x800) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ static const uint8_t mkey_vectors_dev[MASTERKEY_REVISION_MAX][0x10] =
|
|||||||
{0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */
|
{0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */
|
||||||
{0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */
|
{0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 07 encrypted with Master key 08. */
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 07 encrypted with Master key 08. */
|
||||||
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 08 encrypted with Master key 09. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Retail unit keys. */
|
/* Retail unit keys. */
|
||||||
@ -57,6 +58,7 @@ static const uint8_t mkey_vectors[MASTERKEY_REVISION_MAX][0x10] =
|
|||||||
{0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */
|
{0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */
|
||||||
{0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */
|
{0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */
|
||||||
{0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29}, /* Master key 07 encrypted with Master key 08. */
|
{0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29}, /* Master key 07 encrypted with Master key 08. */
|
||||||
|
{0x4D, 0xD9, 0x98, 0x42, 0x45, 0x0D, 0xB1, 0x3C, 0x52, 0x0C, 0x9A, 0x44, 0xBB, 0xAD, 0xAF, 0x80}, /* Master key 08 encrypted with Master key 09. */
|
||||||
};
|
};
|
||||||
|
|
||||||
bool check_mkey_revision(unsigned int revision, bool is_retail) {
|
bool check_mkey_revision(unsigned int revision, bool is_retail) {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
/* This is glue code to enable master key support across versions. */
|
/* This is glue code to enable master key support across versions. */
|
||||||
|
|
||||||
/* TODO: Update to 0xA on release of new master key. */
|
/* TODO: Update to 0xB on release of new master key. */
|
||||||
#define MASTERKEY_REVISION_MAX 0x9
|
#define MASTERKEY_REVISION_MAX 0xA
|
||||||
|
|
||||||
#define MASTERKEY_REVISION_100_230 0x00
|
#define MASTERKEY_REVISION_100_230 0x00
|
||||||
#define MASTERKEY_REVISION_300 0x01
|
#define MASTERKEY_REVISION_300 0x01
|
||||||
@ -30,7 +30,8 @@
|
|||||||
#define MASTERKEY_REVISION_600_610 0x05
|
#define MASTERKEY_REVISION_600_610 0x05
|
||||||
#define MASTERKEY_REVISION_620 0x06
|
#define MASTERKEY_REVISION_620 0x06
|
||||||
#define MASTERKEY_REVISION_700_800 0x07
|
#define MASTERKEY_REVISION_700_800 0x07
|
||||||
#define MASTERKEY_REVISION_810_CURRENT 0x08
|
#define MASTERKEY_REVISION_810 0x08
|
||||||
|
#define MASTERKEY_REVISION_900_CURRENT 0x09
|
||||||
|
|
||||||
#define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410)
|
#define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410)
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ static const uint8_t new_device_key_sources[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x10]
|
|||||||
{0x70, 0x08, 0x1B, 0x97, 0x44, 0x64, 0xF8, 0x91, 0x54, 0x9D, 0xC6, 0x84, 0x8F, 0x1A, 0xB2, 0xE4}, /* 6.x New Device Key Source. */
|
{0x70, 0x08, 0x1B, 0x97, 0x44, 0x64, 0xF8, 0x91, 0x54, 0x9D, 0xC6, 0x84, 0x8F, 0x1A, 0xB2, 0xE4}, /* 6.x New Device Key Source. */
|
||||||
{0x8E, 0x09, 0x1F, 0x7A, 0xBB, 0xCA, 0x6A, 0xFB, 0xB8, 0x9B, 0xD5, 0xC1, 0x25, 0x9C, 0xA9, 0x17}, /* 6.2.0 New Device Key Source. */
|
{0x8E, 0x09, 0x1F, 0x7A, 0xBB, 0xCA, 0x6A, 0xFB, 0xB8, 0x9B, 0xD5, 0xC1, 0x25, 0x9C, 0xA9, 0x17}, /* 6.2.0 New Device Key Source. */
|
||||||
{0x8F, 0x77, 0x5A, 0x96, 0xB0, 0x94, 0xFD, 0x8D, 0x28, 0xE4, 0x19, 0xC8, 0x16, 0x1C, 0xDB, 0x3D}, /* 7.0.0 New Device Key Source. */
|
{0x8F, 0x77, 0x5A, 0x96, 0xB0, 0x94, 0xFD, 0x8D, 0x28, 0xE4, 0x19, 0xC8, 0x16, 0x1C, 0xDB, 0x3D}, /* 7.0.0 New Device Key Source. */
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: 8.1.0 New Device Key Source to be added on next change-of-keys. */
|
{0x67, 0x62, 0xD4, 0x8E, 0x55, 0xCF, 0xFF, 0x41, 0x31, 0x15, 0x3B, 0x24, 0x0C, 0x7C, 0x07, 0xAE}, /* 8.1.0 New Device Key Source. */
|
||||||
|
{0x4A, 0xC3, 0x4E, 0x14, 0x8B, 0x96, 0x4A, 0xD5, 0xD4, 0x99, 0x73, 0xC4, 0x45, 0xAB, 0x8B, 0x49}, /* 9.0.0 New Device Key Source. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t new_device_keygen_sources[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x10] = {
|
static const uint8_t new_device_keygen_sources[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x10] = {
|
||||||
@ -52,7 +53,8 @@ static const uint8_t new_device_keygen_sources[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x
|
|||||||
{0x99, 0xFA, 0x98, 0xBD, 0x15, 0x1C, 0x72, 0xFD, 0x7D, 0x9A, 0xD5, 0x41, 0x00, 0xFD, 0xB2, 0xEF}, /* 6.x New Device Keygen Source. */
|
{0x99, 0xFA, 0x98, 0xBD, 0x15, 0x1C, 0x72, 0xFD, 0x7D, 0x9A, 0xD5, 0x41, 0x00, 0xFD, 0xB2, 0xEF}, /* 6.x New Device Keygen Source. */
|
||||||
{0x81, 0x3C, 0x6C, 0xBF, 0x5D, 0x21, 0xDE, 0x77, 0x20, 0xD9, 0x6C, 0xE3, 0x22, 0x06, 0xAE, 0xBB}, /* 6.2.0 New Device Keygen Source. */
|
{0x81, 0x3C, 0x6C, 0xBF, 0x5D, 0x21, 0xDE, 0x77, 0x20, 0xD9, 0x6C, 0xE3, 0x22, 0x06, 0xAE, 0xBB}, /* 6.2.0 New Device Keygen Source. */
|
||||||
{0x86, 0x61, 0xB0, 0x16, 0xFA, 0x7A, 0x9A, 0xEA, 0xF6, 0xF5, 0xBE, 0x1A, 0x13, 0x5B, 0x6D, 0x9E}, /* 7.0.0 New Device Keygen Source. */
|
{0x86, 0x61, 0xB0, 0x16, 0xFA, 0x7A, 0x9A, 0xEA, 0xF6, 0xF5, 0xBE, 0x1A, 0x13, 0x5B, 0x6D, 0x9E}, /* 7.0.0 New Device Keygen Source. */
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: 8.1.0 New Device Key Source to be added on next change-of-keys. */
|
{0xA6, 0x81, 0x71, 0xE7, 0xB5, 0x23, 0x74, 0xB0, 0x39, 0x8C, 0xB7, 0xFF, 0xA0, 0x62, 0x9F, 0x8D}, /* 8.1.0 New Device Keygen Source. */
|
||||||
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: 9.0.0 New Device Keygen Source to be added on next change-of-keys. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t new_device_keygen_sources_dev[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x10] = {
|
static const uint8_t new_device_keygen_sources_dev[MASTERKEY_NUM_NEW_DEVICE_KEYS][0x10] = {
|
||||||
@ -61,7 +63,8 @@ static const uint8_t new_device_keygen_sources_dev[MASTERKEY_NUM_NEW_DEVICE_KEYS
|
|||||||
{0xF6, 0xD8, 0x59, 0x63, 0x8F, 0x47, 0xCB, 0x4A, 0xD8, 0x74, 0x05, 0x7F, 0x88, 0x92, 0x33, 0xA5}, /* 6.x New Device Keygen Source. */
|
{0xF6, 0xD8, 0x59, 0x63, 0x8F, 0x47, 0xCB, 0x4A, 0xD8, 0x74, 0x05, 0x7F, 0x88, 0x92, 0x33, 0xA5}, /* 6.x New Device Keygen Source. */
|
||||||
{0x20, 0xAB, 0xF2, 0x0F, 0x05, 0xE3, 0xDE, 0x2E, 0xA1, 0xFB, 0x37, 0x5E, 0x8B, 0x22, 0x1A, 0x38}, /* 6.2.0 New Device Keygen Source. */
|
{0x20, 0xAB, 0xF2, 0x0F, 0x05, 0xE3, 0xDE, 0x2E, 0xA1, 0xFB, 0x37, 0x5E, 0x8B, 0x22, 0x1A, 0x38}, /* 6.2.0 New Device Keygen Source. */
|
||||||
{0x60, 0xAE, 0x56, 0x68, 0x11, 0xE2, 0x0C, 0x99, 0xDE, 0x05, 0xAE, 0x68, 0x78, 0x85, 0x04, 0xAE}, /* 7.0.0 New Device Keygen Source. */
|
{0x60, 0xAE, 0x56, 0x68, 0x11, 0xE2, 0x0C, 0x99, 0xDE, 0x05, 0xAE, 0x68, 0x78, 0x85, 0x04, 0xAE}, /* 7.0.0 New Device Keygen Source. */
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: 8.1.0 New Device Key Source to be added on next change-of-keys. */
|
{0x94, 0xD6, 0xA8, 0xC0, 0x95, 0xAF, 0xD0, 0xA6, 0x27, 0x53, 0x5E, 0xE5, 0x8E, 0x70, 0x1F, 0x87}, /* 8.1.0 New Device Keygen Source. */
|
||||||
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: 9.0.0 New Device Keygen Source to be added on next change-of-keys. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void derive_new_device_keys(unsigned int keygen_keyslot) {
|
static void derive_new_device_keys(unsigned int keygen_keyslot) {
|
||||||
@ -141,6 +144,7 @@ static void setup_se(void) {
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
derive_new_device_keys(KEYSLOT_SWITCH_5XNEWDEVICEKEYGENKEY);
|
derive_new_device_keys(KEYSLOT_SWITCH_5XNEWDEVICEKEYGENKEY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -330,7 +334,7 @@ static bool validate_package2_metadata(package2_meta_t *metadata) {
|
|||||||
|
|
||||||
/* Perform version checks. */
|
/* Perform version checks. */
|
||||||
/* We will be compatible with all package2s released before current, but not newer ones. */
|
/* We will be compatible with all package2s released before current, but not newer ones. */
|
||||||
if (metadata->version_max >= PACKAGE2_MINVER_THEORETICAL && metadata->version_min < PACKAGE2_MAXVER_810_CURRENT) {
|
if (metadata->version_max >= PACKAGE2_MINVER_THEORETICAL && metadata->version_min < PACKAGE2_MAXVER_900_CURRENT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,6 +460,7 @@ static void copy_warmboot_bin_to_dram() {
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
warmboot_src = (uint8_t *)0x4003E000;
|
warmboot_src = (uint8_t *)0x4003E000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -532,6 +537,9 @@ void load_package2(coldboot_crt0_reloc_list_t *reloc_list) {
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
MAKE_REG32(PMC_BASE + 0x360) = 0x14A;
|
MAKE_REG32(PMC_BASE + 0x360) = 0x14A;
|
||||||
break;
|
break;
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
|
MAKE_REG32(PMC_BASE + 0x360) = 0x16B;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ static inline uintptr_t get_nx_bootloader_mailbox_base(unsigned int targetfw) {
|
|||||||
#define PACKAGE2_MAXVER_600_610 0x8
|
#define PACKAGE2_MAXVER_600_610 0x8
|
||||||
#define PACKAGE2_MAXVER_620 0x9
|
#define PACKAGE2_MAXVER_620 0x9
|
||||||
#define PACKAGE2_MAXVER_700_800 0xA
|
#define PACKAGE2_MAXVER_700_800 0xA
|
||||||
#define PACKAGE2_MAXVER_810_CURRENT 0xB
|
#define PACKAGE2_MAXVER_810 0xB
|
||||||
|
#define PACKAGE2_MAXVER_900_CURRENT 0xC
|
||||||
|
|
||||||
#define PACKAGE2_MINVER_100 0x3
|
#define PACKAGE2_MINVER_100 0x3
|
||||||
#define PACKAGE2_MINVER_200 0x4
|
#define PACKAGE2_MINVER_200 0x4
|
||||||
@ -82,7 +83,8 @@ static inline uintptr_t get_nx_bootloader_mailbox_base(unsigned int targetfw) {
|
|||||||
#define PACKAGE2_MINVER_600_610 0x9
|
#define PACKAGE2_MINVER_600_610 0x9
|
||||||
#define PACKAGE2_MINVER_620 0xA
|
#define PACKAGE2_MINVER_620 0xA
|
||||||
#define PACKAGE2_MINVER_700_800 0xB
|
#define PACKAGE2_MINVER_700_800 0xB
|
||||||
#define PACKAGE2_MINVER_810_CURRENT 0xC
|
#define PACKAGE2_MINVER_810 0xC
|
||||||
|
#define PACKAGE2_MINVER_900_CURRENT 0xD
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
|
@ -77,6 +77,7 @@ static void enable_lp0_wake_events(void) {
|
|||||||
|
|
||||||
static void notify_pmic_shutdown(void) {
|
static void notify_pmic_shutdown(void) {
|
||||||
clkrst_reboot(CARDEVICE_I2C5);
|
clkrst_reboot(CARDEVICE_I2C5);
|
||||||
|
i2c_init(I2C_5);
|
||||||
if (fuse_get_bootrom_patch_version() >= 0x7F) {
|
if (fuse_get_bootrom_patch_version() >= 0x7F) {
|
||||||
i2c_send_pmic_cpu_shutdown_cmd();
|
i2c_send_pmic_cpu_shutdown_cmd();
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,7 @@ void set_version_specific_smcs(void) {
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
/* No more LoadSecureExpModKey. */
|
/* No more LoadSecureExpModKey. */
|
||||||
g_smc_user_table[0xE].handler = NULL;
|
g_smc_user_table[0xE].handler = NULL;
|
||||||
g_smc_user_table[0xC].id = 0xC300D60C;
|
g_smc_user_table[0xC].id = 0xC300D60C;
|
||||||
|
@ -53,6 +53,7 @@ static bool is_user_keyslot_valid(unsigned int keyslot) {
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
default:
|
default:
|
||||||
return keyslot <= 5;
|
return keyslot <= 5;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,9 @@ typedef enum {
|
|||||||
FS_VER_8_1_0,
|
FS_VER_8_1_0,
|
||||||
FS_VER_8_1_0_EXFAT,
|
FS_VER_8_1_0_EXFAT,
|
||||||
|
|
||||||
|
FS_VER_9_0_0,
|
||||||
|
FS_VER_9_0_0_EXFAT,
|
||||||
|
|
||||||
FS_VER_MAX,
|
FS_VER_MAX,
|
||||||
} emummc_fs_ver_t;
|
} emummc_fs_ver_t;
|
||||||
|
|
||||||
|
@ -411,6 +411,9 @@ static const uint8_t g_fs_hashes[FS_VER_MAX][0x8] = {
|
|||||||
|
|
||||||
"\x6B\x09\xB6\x7B\x29\xC0\x20\x24", /* FS_VER_8_1_0 */
|
"\x6B\x09\xB6\x7B\x29\xC0\x20\x24", /* FS_VER_8_1_0 */
|
||||||
"\xB4\xCA\xE1\xF2\x49\x65\xD9\x2E", /* FS_VER_8_1_0_EXFAT */
|
"\xB4\xCA\xE1\xF2\x49\x65\xD9\x2E", /* FS_VER_8_1_0_EXFAT */
|
||||||
|
|
||||||
|
"\x46\x87\x40\x76\x1E\x19\x3E\xB7", /* FS_VER_9_0_0 */
|
||||||
|
"\x7C\x95\x13\x76\xE5\xC1\x2D\xF8", /* FS_VER_9_0_0_EXFAT */
|
||||||
};
|
};
|
||||||
|
|
||||||
kip1_header_t *apply_kip_ips_patches(kip1_header_t *kip, size_t kip_size, emummc_fs_ver_t *out_fs_ver) {
|
kip1_header_t *apply_kip_ips_patches(kip1_header_t *kip, size_t kip_size, emummc_fs_ver_t *out_fs_ver) {
|
||||||
|
@ -425,12 +425,68 @@ static const instruction_t MAKE_KERNEL_PATCH_NAME(800, proc_id_send)[] = {0xA9BF
|
|||||||
static const uint8_t MAKE_KERNEL_PATTERN_NAME(800, proc_id_recv)[] = {0x68, 0x03, 0x40, 0xF9, 0x08, 0x1D, 0x40, 0xF9, 0xE0, 0x03, 0x1B, 0xAA, 0x00, 0x01, 0x3F, 0xD6, 0xA9, 0x83, 0x50, 0xF8, 0xE8, 0x03, 0x16, 0x2A, 0xD6, 0x0A, 0x00, 0x11};
|
static const uint8_t MAKE_KERNEL_PATTERN_NAME(800, proc_id_recv)[] = {0x68, 0x03, 0x40, 0xF9, 0x08, 0x1D, 0x40, 0xF9, 0xE0, 0x03, 0x1B, 0xAA, 0x00, 0x01, 0x3F, 0xD6, 0xA9, 0x83, 0x50, 0xF8, 0xE8, 0x03, 0x16, 0x2A, 0xD6, 0x0A, 0x00, 0x11};
|
||||||
static const instruction_t MAKE_KERNEL_PATCH_NAME(800, proc_id_recv)[] = {0xA9BF2FEA, 0xF9404FEB, 0x2A1603EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF9400368, 0xF9401D08, 0xAA1B03E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0};
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(800, proc_id_recv)[] = {0xA9BF2FEA, 0xF9404FEB, 0x2A1603EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF9400368, 0xF9401D08, 0xAA1B03E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0};
|
||||||
|
|
||||||
|
/*
|
||||||
|
stp x10, x11, [sp, #-0x10]!
|
||||||
|
ldr x11, [sp, #0x68]
|
||||||
|
mov w10, w22
|
||||||
|
lsl x10, x10, #2
|
||||||
|
ldr x10, [x11, x10]
|
||||||
|
mov x9, #0x0000ffffffffffff
|
||||||
|
and x8, x10, x9
|
||||||
|
mov x9, #0xffff000000000000
|
||||||
|
and x10, x10, x9
|
||||||
|
mov x9, #0xfffe000000000000
|
||||||
|
cmp x10, x9
|
||||||
|
beq #0x20
|
||||||
|
|
||||||
|
stp x8, x9, [sp, #-0x10]!
|
||||||
|
ldr x8, [x23]
|
||||||
|
ldr x8, [x8, #0x38]
|
||||||
|
mov x0, x23
|
||||||
|
blr x8
|
||||||
|
ldp x8, x9, [sp],#0x10
|
||||||
|
mov x8, x0
|
||||||
|
|
||||||
|
ldp x10, x11, [sp],#0x10
|
||||||
|
mov x0, x8
|
||||||
|
*/
|
||||||
|
static const uint8_t MAKE_KERNEL_PATTERN_NAME(900, proc_id_send)[] = {0xE8, 0x02, 0x40, 0xF9, 0x08, 0x1D, 0x40, 0xF9, 0xE0, 0x03, 0x17, 0xAA, 0x00, 0x01, 0x3F, 0xD6, 0xE8, 0x03, 0x16, 0x2A, 0xD6, 0x0A, 0x00, 0x11, 0x08, 0xF5, 0x7E, 0xD3};
|
||||||
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(900, proc_id_send)[] = {0xA9BF2FEA, 0xF94037EB, 0x2A1603EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF94002E8, 0xF9401D08, 0xAA1703E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0};
|
||||||
|
/*
|
||||||
|
stp x10, x11, [sp, #-0x10]!
|
||||||
|
ldr x11, [sp, #0x90]
|
||||||
|
mov w10, w23
|
||||||
|
lsl x10, x10, #2
|
||||||
|
ldr x10, [x11, x10]
|
||||||
|
mov x9, #0x0000ffffffffffff
|
||||||
|
and x8, x10, x9
|
||||||
|
mov x9, #0xffff000000000000
|
||||||
|
and x10, x10, x9
|
||||||
|
mov x9, #0xfffe000000000000
|
||||||
|
cmp x10, x9
|
||||||
|
beq #0x20
|
||||||
|
|
||||||
|
stp x8, x9, [sp, #-0x10]!
|
||||||
|
ldr x8, [x27]
|
||||||
|
ldr x8, [x8, #0x38]
|
||||||
|
mov x0, x27
|
||||||
|
blr x8
|
||||||
|
ldp x8, x9, [sp],#0x10
|
||||||
|
mov x8, x0
|
||||||
|
|
||||||
|
ldp x10, x11, [sp],#0x10
|
||||||
|
mov x0, x8
|
||||||
|
*/
|
||||||
|
static const uint8_t MAKE_KERNEL_PATTERN_NAME(900, proc_id_recv)[] = {0x68, 0x03, 0x40, 0xF9, 0x08, 0x1D, 0x40, 0xF9, 0xE0, 0x03, 0x1B, 0xAA, 0x00, 0x01, 0x3F, 0xD6, 0xE8, 0x03, 0x17, 0x2A, 0xF7, 0x0A, 0x00, 0x11, 0x08, 0xF5, 0x7E, 0xD3};
|
||||||
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(900, proc_id_recv)[] = {0xA9BF2FEA, 0xF9404BEB, 0x2A1703EA, 0xD37EF54A, 0xF86A696A, 0x92FFFFE9, 0x8A090148, 0xD2FFFFE9, 0x8A09014A, 0xD2FFFFC9, 0xEB09015F, 0x54000100, 0xA9BF27E8, 0xF9400368, 0xF9401D08, 0xAA1B03E0, 0xD63F0100, 0xA8C127E8, 0xAA0003E8, 0xA8C12FEA, 0xAA0803E0};
|
||||||
|
|
||||||
/* svcControlCodeMemory Patches */
|
/* svcControlCodeMemory Patches */
|
||||||
/* b.eq -> nop */
|
/* b.eq -> nop */
|
||||||
static const instruction_t MAKE_KERNEL_PATCH_NAME(500, svc_control_codememory)[] = {MAKE_NOP};
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(500, svc_control_codememory)[] = {MAKE_NOP};
|
||||||
static const instruction_t MAKE_KERNEL_PATCH_NAME(600, svc_control_codememory)[] = {MAKE_NOP};
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(600, svc_control_codememory)[] = {MAKE_NOP};
|
||||||
static const instruction_t MAKE_KERNEL_PATCH_NAME(700, svc_control_codememory)[] = {MAKE_NOP};
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(700, svc_control_codememory)[] = {MAKE_NOP};
|
||||||
static const instruction_t MAKE_KERNEL_PATCH_NAME(800, svc_control_codememory)[] = {MAKE_NOP};
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(800, svc_control_codememory)[] = {MAKE_NOP};
|
||||||
|
static const instruction_t MAKE_KERNEL_PATCH_NAME(900, svc_control_codememory)[] = {MAKE_NOP};
|
||||||
|
|
||||||
/* Hook Definitions. */
|
/* Hook Definitions. */
|
||||||
static const kernel_patch_t g_kernel_patches_100[] = {
|
static const kernel_patch_t g_kernel_patches_100[] = {
|
||||||
@ -592,6 +648,7 @@ static const kernel_patch_t g_kernel_patches_700[] = {
|
|||||||
.patch_offset = 0x3C6E0,
|
.patch_offset = 0x3C6E0,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const kernel_patch_t g_kernel_patches_800[] = {
|
static const kernel_patch_t g_kernel_patches_800[] = {
|
||||||
{ /* Send Message Process ID Patch. */
|
{ /* Send Message Process ID Patch. */
|
||||||
.pattern_size = 0x1C,
|
.pattern_size = 0x1C,
|
||||||
@ -616,6 +673,30 @@ static const kernel_patch_t g_kernel_patches_800[] = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const kernel_patch_t g_kernel_patches_900[] = {
|
||||||
|
{ /* Send Message Process ID Patch. */
|
||||||
|
.pattern_size = 0x1C,
|
||||||
|
.pattern = MAKE_KERNEL_PATTERN_NAME(900, proc_id_send),
|
||||||
|
.pattern_hook_offset = 0x0,
|
||||||
|
.payload_num_instructions = sizeof(MAKE_KERNEL_PATCH_NAME(900, proc_id_send))/sizeof(instruction_t),
|
||||||
|
.branch_back_offset = 0x10,
|
||||||
|
.payload = MAKE_KERNEL_PATCH_NAME(900, proc_id_send)
|
||||||
|
},
|
||||||
|
{ /* Receive Message Process ID Patch. */
|
||||||
|
.pattern_size = 0x1C,
|
||||||
|
.pattern = MAKE_KERNEL_PATTERN_NAME(900, proc_id_recv),
|
||||||
|
.pattern_hook_offset = 0x0,
|
||||||
|
.payload_num_instructions = sizeof(MAKE_KERNEL_PATCH_NAME(900, proc_id_recv))/sizeof(instruction_t),
|
||||||
|
.branch_back_offset = 0x10,
|
||||||
|
.payload = MAKE_KERNEL_PATCH_NAME(900, proc_id_recv)
|
||||||
|
},
|
||||||
|
{ /* svcControlCodeMemory Patch. */
|
||||||
|
.payload_num_instructions = sizeof(MAKE_KERNEL_PATCH_NAME(900, svc_control_codememory))/sizeof(instruction_t),
|
||||||
|
.payload = MAKE_KERNEL_PATCH_NAME(900, svc_control_codememory),
|
||||||
|
.patch_offset = 0x43DFC,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#define KERNEL_PATCHES(vers) .num_patches = sizeof(g_kernel_patches_##vers)/sizeof(kernel_patch_t), .patches = g_kernel_patches_##vers,
|
#define KERNEL_PATCHES(vers) .num_patches = sizeof(g_kernel_patches_##vers)/sizeof(kernel_patch_t), .patches = g_kernel_patches_##vers,
|
||||||
|
|
||||||
/* Kernel Infos. */
|
/* Kernel Infos. */
|
||||||
@ -673,6 +754,15 @@ static const kernel_info_t g_kernel_infos[] = {
|
|||||||
.embedded_ini_ptr = 0x168,
|
.embedded_ini_ptr = 0x168,
|
||||||
.free_code_space_offset = 0x607F0,
|
.free_code_space_offset = 0x607F0,
|
||||||
KERNEL_PATCHES(800)
|
KERNEL_PATCHES(800)
|
||||||
|
},
|
||||||
|
{ /* 9.0.0. */
|
||||||
|
.hash = {0xD7, 0x95, 0x65, 0x3A, 0x49, 0x4C, 0x5A, 0x9E, 0x2E, 0x04, 0xD6, 0x30, 0x7D, 0x79, 0xE1, 0xEE, 0x10, 0x2B, 0x30, 0xE0, 0x3E, 0xDD, 0x9F, 0xB3, 0x8A, 0x3C, 0x5E, 0xD3, 0x9B, 0x30, 0x11, 0x9B},
|
||||||
|
.hash_offset = 0x1C0,
|
||||||
|
.hash_size = 0x90000 - 0x1C0,
|
||||||
|
.embedded_ini_offset = 0x90000,
|
||||||
|
.embedded_ini_ptr = 0x180,
|
||||||
|
.free_code_space_offset = 0x65780,
|
||||||
|
KERNEL_PATCHES(900)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,7 +154,9 @@ int derive_nx_keydata(uint32_t target_firmware, const nx_keyblob_t *keyblobs, ui
|
|||||||
desired_keyblob = MASTERKEY_REVISION_700_800;
|
desired_keyblob = MASTERKEY_REVISION_700_800;
|
||||||
break;
|
break;
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
desired_keyblob = MASTERKEY_REVISION_810_CURRENT;
|
desired_keyblob = MASTERKEY_REVISION_810;
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
|
desired_keyblob = MASTERKEY_REVISION_900_CURRENT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatal_error("Unknown target firmware: %02x!", target_firmware);
|
fatal_error("Unknown target firmware: %02x!", target_firmware);
|
||||||
@ -230,6 +232,7 @@ int derive_nx_keydata(uint32_t target_firmware, const nx_keyblob_t *keyblobs, ui
|
|||||||
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
case ATMOSPHERE_TARGET_FIRMWARE_700:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
case ATMOSPHERE_TARGET_FIRMWARE_800:
|
||||||
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
case ATMOSPHERE_TARGET_FIRMWARE_810:
|
||||||
|
case ATMOSPHERE_TARGET_FIRMWARE_900:
|
||||||
decrypt_data_into_keyslot(0xA, 0xF, devicekey_4x_seed, 0x10);
|
decrypt_data_into_keyslot(0xA, 0xF, devicekey_4x_seed, 0x10);
|
||||||
decrypt_data_into_keyslot(0xF, 0xF, devicekey_seed, 0x10);
|
decrypt_data_into_keyslot(0xF, 0xF, devicekey_seed, 0x10);
|
||||||
decrypt_data_into_keyslot(0xE, 0xC, masterkey_4x_seed, 0x10);
|
decrypt_data_into_keyslot(0xE, 0xC, masterkey_4x_seed, 0x10);
|
||||||
|
@ -40,6 +40,7 @@ static const uint8_t mkey_vectors_dev[MASTERKEY_REVISION_MAX][0x10] =
|
|||||||
{0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */
|
{0x6F, 0xD2, 0x84, 0x1D, 0x05, 0xEC, 0x40, 0x94, 0x5F, 0x18, 0xB3, 0x81, 0x09, 0x98, 0x8D, 0x4E}, /* Master key 05 encrypted with Master key 06. */
|
||||||
{0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */
|
{0x37, 0xAF, 0xAB, 0x35, 0x79, 0x09, 0xD9, 0x48, 0x29, 0xD2, 0xDB, 0xA5, 0xA5, 0xF5, 0x30, 0x19}, /* Master key 06 encrypted with Master key 07. */
|
||||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 07 encrypted with Master key 08. */
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 07 encrypted with Master key 08. */
|
||||||
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* TODO: Master key 08 encrypted with Master key 09. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Retail unit keys. */
|
/* Retail unit keys. */
|
||||||
@ -54,6 +55,7 @@ static const uint8_t mkey_vectors[MASTERKEY_REVISION_MAX][0x10] =
|
|||||||
{0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */
|
{0x1E, 0x1E, 0x22, 0xC0, 0x5A, 0x33, 0x3C, 0xB9, 0x0B, 0xA9, 0x03, 0x04, 0xBA, 0xDB, 0x07, 0x57}, /* Master key 05 encrypted with Master key 06. */
|
||||||
{0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */
|
{0xA4, 0xD4, 0x52, 0x6F, 0xD1, 0xE4, 0x36, 0xAA, 0x9F, 0xCB, 0x61, 0x27, 0x1C, 0x67, 0x65, 0x1F}, /* Master key 06 encrypted with Master key 07. */
|
||||||
{0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29}, /* Master key 07 encrypted with Master key 08. */
|
{0xEA, 0x60, 0xB3, 0xEA, 0xCE, 0x8F, 0x24, 0x46, 0x7D, 0x33, 0x9C, 0xD1, 0xBC, 0x24, 0x98, 0x29}, /* Master key 07 encrypted with Master key 08. */
|
||||||
|
{0x4D, 0xD9, 0x98, 0x42, 0x45, 0x0D, 0xB1, 0x3C, 0x52, 0x0C, 0x9A, 0x44, 0xBB, 0xAD, 0xAF, 0x80}, /* Master key 08 encrypted with Master key 09. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool check_mkey_revision(unsigned int revision, bool is_retail) {
|
static bool check_mkey_revision(unsigned int revision, bool is_retail) {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
/* This is glue code to enable master key support across versions. */
|
/* This is glue code to enable master key support across versions. */
|
||||||
|
|
||||||
/* TODO: Update to 0xA on release of new master key. */
|
/* TODO: Update to 0xB on release of new master key. */
|
||||||
#define MASTERKEY_REVISION_MAX 0x9
|
#define MASTERKEY_REVISION_MAX 0xA
|
||||||
|
|
||||||
#define MASTERKEY_REVISION_100_230 0x00
|
#define MASTERKEY_REVISION_100_230 0x00
|
||||||
#define MASTERKEY_REVISION_300 0x01
|
#define MASTERKEY_REVISION_300 0x01
|
||||||
@ -30,7 +30,8 @@
|
|||||||
#define MASTERKEY_REVISION_600_610 0x05
|
#define MASTERKEY_REVISION_600_610 0x05
|
||||||
#define MASTERKEY_REVISION_620 0x06
|
#define MASTERKEY_REVISION_620 0x06
|
||||||
#define MASTERKEY_REVISION_700_800 0x07
|
#define MASTERKEY_REVISION_700_800 0x07
|
||||||
#define MASTERKEY_REVISION_810_CURRENT 0x08
|
#define MASTERKEY_REVISION_810 0x08
|
||||||
|
#define MASTERKEY_REVISION_900_CURRENT 0x09
|
||||||
|
|
||||||
#define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410)
|
#define MASTERKEY_NUM_NEW_DEVICE_KEYS (MASTERKEY_REVISION_MAX - MASTERKEY_REVISION_400_410)
|
||||||
|
|
||||||
|
@ -208,11 +208,13 @@ static uint32_t nxboot_get_target_firmware(const void *package1loader) {
|
|||||||
}
|
}
|
||||||
case 0x0F: /* 7.0.0 - 7.0.1 */
|
case 0x0F: /* 7.0.0 - 7.0.1 */
|
||||||
return ATMOSPHERE_TARGET_FIRMWARE_700;
|
return ATMOSPHERE_TARGET_FIRMWARE_700;
|
||||||
case 0x10: { /* 8.0.0 - 8.1.0 */
|
case 0x10: { /* 8.0.0 - 9.0.0 */
|
||||||
if (memcmp(package1loader_header->build_timestamp, "20190314", 8) == 0) {
|
if (memcmp(package1loader_header->build_timestamp, "20190314", 8) == 0) {
|
||||||
return ATMOSPHERE_TARGET_FIRMWARE_800;
|
return ATMOSPHERE_TARGET_FIRMWARE_800;
|
||||||
} else if (memcmp(package1loader_header->build_timestamp, "20190531", 8) == 0) {
|
} else if (memcmp(package1loader_header->build_timestamp, "20190531", 8) == 0) {
|
||||||
return ATMOSPHERE_TARGET_FIRMWARE_810;
|
return ATMOSPHERE_TARGET_FIRMWARE_810;
|
||||||
|
} else if (memcmp(package1loader_header->build_timestamp, "20190809", 8) == 0) {
|
||||||
|
return ATMOSPHERE_TARGET_FIRMWARE_900;
|
||||||
} else {
|
} else {
|
||||||
fatal_error("[NXBOOT] Unable to identify package1!\n");
|
fatal_error("[NXBOOT] Unable to identify package1!\n");
|
||||||
}
|
}
|
||||||
@ -360,6 +362,10 @@ static void nxboot_configure_stratosphere(uint32_t target_firmware) {
|
|||||||
if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_400 && !(fuse_get_reserved_odm(7) & ~0x0000000F)) {
|
if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_400 && !(fuse_get_reserved_odm(7) & ~0x0000000F)) {
|
||||||
kip_patches_set_enable_nogc();
|
kip_patches_set_enable_nogc();
|
||||||
}
|
}
|
||||||
|
/* Check if the fuses are < 9.0.0, but firmware is >= 9.0.0 */
|
||||||
|
if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_900 && !(fuse_get_reserved_odm(7) & ~0x000003FF)) {
|
||||||
|
kip_patches_set_enable_nogc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ static bool package2_validate_metadata(package2_meta_t *metadata, uint8_t data[]
|
|||||||
|
|
||||||
/* Perform version checks. */
|
/* Perform version checks. */
|
||||||
/* We will be compatible with all package2s released before current, but not newer ones. */
|
/* We will be compatible with all package2s released before current, but not newer ones. */
|
||||||
if (metadata->version_max >= PACKAGE2_MINVER_THEORETICAL && metadata->version_min < PACKAGE2_MAXVER_810_CURRENT) {
|
if (metadata->version_max >= PACKAGE2_MINVER_THEORETICAL && metadata->version_min < PACKAGE2_MAXVER_900_CURRENT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
#define PACKAGE2_MAXVER_600_610 0x8
|
#define PACKAGE2_MAXVER_600_610 0x8
|
||||||
#define PACKAGE2_MAXVER_620 0x9
|
#define PACKAGE2_MAXVER_620 0x9
|
||||||
#define PACKAGE2_MAXVER_700_800 0xA
|
#define PACKAGE2_MAXVER_700_800 0xA
|
||||||
#define PACKAGE2_MAXVER_810_CURRENT 0xB
|
#define PACKAGE2_MAXVER_810 0xB
|
||||||
|
#define PACKAGE2_MAXVER_900_CURRENT 0xC
|
||||||
|
|
||||||
#define PACKAGE2_MINVER_100 0x3
|
#define PACKAGE2_MINVER_100 0x3
|
||||||
#define PACKAGE2_MINVER_200 0x4
|
#define PACKAGE2_MINVER_200 0x4
|
||||||
@ -48,7 +49,8 @@
|
|||||||
#define PACKAGE2_MINVER_600_610 0x9
|
#define PACKAGE2_MINVER_600_610 0x9
|
||||||
#define PACKAGE2_MINVER_620 0xA
|
#define PACKAGE2_MINVER_620 0xA
|
||||||
#define PACKAGE2_MINVER_700_800 0xB
|
#define PACKAGE2_MINVER_700_800 0xB
|
||||||
#define PACKAGE2_MINVER_810_CURRENT 0xC
|
#define PACKAGE2_MINVER_810 0xC
|
||||||
|
#define PACKAGE2_MINVER_900_CURRENT 0xD
|
||||||
|
|
||||||
#define NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS ((void *)(0xA9800000ull))
|
#define NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS ((void *)(0xA9800000ull))
|
||||||
|
|
||||||
|
@ -47,19 +47,26 @@ static const uint8_t AL16 zeroes[0x10] = {
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Note: 9.0.0 did not change the TSEC firmware. Thus, the root key is the same. */
|
||||||
|
/* To avoid distribution of more and more sept binaries, we will simply derive the 9.0.0 master key */
|
||||||
|
/* on 8.1.0 and 9.0.0. Exosphere supports this already with no issues. */
|
||||||
|
|
||||||
static const uint8_t AL16 master_kek_seeds[DERIVATION_ID_MAX][0x10] = {
|
static const uint8_t AL16 master_kek_seeds[DERIVATION_ID_MAX][0x10] = {
|
||||||
{0x9A, 0x3E, 0xA9, 0xAB, 0xFD, 0x56, 0x46, 0x1C, 0x9B, 0xF6, 0x48, 0x7F, 0x5C, 0xFA, 0x09, 0x5C},
|
{0x9A, 0x3E, 0xA9, 0xAB, 0xFD, 0x56, 0x46, 0x1C, 0x9B, 0xF6, 0x48, 0x7F, 0x5C, 0xFA, 0x09, 0x5C},
|
||||||
{0xDE, 0xDC, 0xE3, 0x39, 0x30, 0x88, 0x16, 0xF8, 0xAE, 0x97, 0xAD, 0xEC, 0x64, 0x2D, 0x41, 0x41},
|
/* 8.1.0: {0xDE, 0xDC, 0xE3, 0x39, 0x30, 0x88, 0x16, 0xF8, 0xAE, 0x97, 0xAD, 0xEC, 0x64, 0x2D, 0x41, 0x41}, */
|
||||||
|
{0x1A, 0xEC, 0x11, 0x82, 0x2B, 0x32, 0x38, 0x7A, 0x2B, 0xED, 0xBA, 0x01, 0x47, 0x7E, 0x3B, 0x67},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t AL16 master_devkey_seeds[DERIVATION_ID_MAX][0x10] = {
|
static const uint8_t AL16 master_devkey_seeds[DERIVATION_ID_MAX][0x10] = {
|
||||||
{0x8F, 0x77, 0x5A, 0x96, 0xB0, 0x94, 0xFD, 0x8D, 0x28, 0xE4, 0x19, 0xC8, 0x16, 0x1C, 0xDB, 0x3D},
|
{0x8F, 0x77, 0x5A, 0x96, 0xB0, 0x94, 0xFD, 0x8D, 0x28, 0xE4, 0x19, 0xC8, 0x16, 0x1C, 0xDB, 0x3D},
|
||||||
{0x67, 0x62, 0xD4, 0x8E, 0x55, 0xCF, 0xFF, 0x41, 0x31, 0x15, 0x3B, 0x24, 0x0C, 0x7C, 0x07, 0xAE},
|
/* 8.1.0: {0x67, 0x62, 0xD4, 0x8E, 0x55, 0xCF, 0xFF, 0x41, 0x31, 0x15, 0x3B, 0x24, 0x0C, 0x7C, 0x07, 0xAE}, */
|
||||||
|
{0x4A, 0xC3, 0x4E, 0x14, 0x8B, 0x96, 0x4A, 0xD5, 0xD4, 0x99, 0x73, 0xC4, 0x45, 0xAB, 0x8B, 0x49},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t AL16 master_devkey_vectors[DERIVATION_ID_MAX][0x10] = {
|
static const uint8_t AL16 master_devkey_vectors[DERIVATION_ID_MAX][0x10] = {
|
||||||
{0xD8, 0xD3, 0x67, 0x4F, 0xF3, 0xA2, 0xA4, 0x4E, 0xE4, 0x04, 0x37, 0xC2, 0xD9, 0xCF, 0x41, 0x6F},
|
{0xD8, 0xD3, 0x67, 0x4F, 0xF3, 0xA2, 0xA4, 0x4E, 0xE4, 0x04, 0x37, 0xC2, 0xD9, 0xCF, 0x41, 0x6F},
|
||||||
{0x72, 0xD0, 0xAD, 0xEB, 0xE1, 0xF6, 0x35, 0x90, 0xB4, 0x43, 0xCC, 0x4B, 0xC4, 0xDC, 0x88, 0x0A},
|
/* 8.1.0: {0x72, 0xD0, 0xAD, 0xEB, 0xE1, 0xF6, 0x35, 0x90, 0xB4, 0x43, 0xCC, 0x4B, 0xC4, 0xDC, 0x88, 0x0A}, */
|
||||||
|
{0x8B, 0xD6, 0x13, 0x2F, 0xC3, 0x4D, 0x53, 0x2D, 0x10, 0xA1, 0x63, 0x85, 0x49, 0x2B, 0xCF, 0x3F},
|
||||||
};
|
};
|
||||||
|
|
||||||
void derive_keys(void) {
|
void derive_keys(void) {
|
||||||
|
@ -85,7 +85,7 @@ void Utils::InitializeThreadFunc(void *args) {
|
|||||||
/* Get required services. */
|
/* Get required services. */
|
||||||
DoWithSmSession([&]() {
|
DoWithSmSession([&]() {
|
||||||
Handle tmp_hnd = 0;
|
Handle tmp_hnd = 0;
|
||||||
static const char * const required_active_services[] = {"pcv", "gpio", "pinmux", "psc:c"};
|
static const char * const required_active_services[] = {"pcv", "gpio", "pinmux", "psc:m"};
|
||||||
for (unsigned int i = 0; i < sts::util::size(required_active_services); i++) {
|
for (unsigned int i = 0; i < sts::util::size(required_active_services); i++) {
|
||||||
R_ASSERT(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])));
|
R_ASSERT(smGetServiceOriginal(&tmp_hnd, smEncodeName(required_active_services[i])));
|
||||||
svcCloseHandle(tmp_hnd);
|
svcCloseHandle(tmp_hnd);
|
||||||
|
@ -107,8 +107,6 @@ void __appExit(void) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
consoleDebugInit(debugDevice_SVC);
|
|
||||||
|
|
||||||
/* Change voltage from 3.3v to 1.8v for select devices. */
|
/* Change voltage from 3.3v to 1.8v for select devices. */
|
||||||
boot::ChangeGpioVoltageTo1_8v();
|
boot::ChangeGpioVoltageTo1_8v();
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ enum FirmwareVersion : u32 {
|
|||||||
FirmwareVersion_700 = 6,
|
FirmwareVersion_700 = 6,
|
||||||
FirmwareVersion_800 = 7,
|
FirmwareVersion_800 = 7,
|
||||||
FirmwareVersion_810 = 8,
|
FirmwareVersion_810 = 8,
|
||||||
FirmwareVersion_Current = FirmwareVersion_810,
|
FirmwareVersion_900 = 9,
|
||||||
|
FirmwareVersion_Current = FirmwareVersion_900,
|
||||||
FirmwareVersion_Max = 32,
|
FirmwareVersion_Max = 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ enum AtmosphereTargetFirmware : u32 {
|
|||||||
AtmosphereTargetFirmware_700 = 8,
|
AtmosphereTargetFirmware_700 = 8,
|
||||||
AtmosphereTargetFirmware_800 = 9,
|
AtmosphereTargetFirmware_800 = 9,
|
||||||
AtmosphereTargetFirmware_810 = 10,
|
AtmosphereTargetFirmware_810 = 10,
|
||||||
|
AtmosphereTargetFirmware_900 = 11,
|
||||||
};
|
};
|
||||||
|
|
||||||
FirmwareVersion GetRuntimeFirmwareVersion();
|
FirmwareVersion GetRuntimeFirmwareVersion();
|
||||||
|
@ -110,6 +110,7 @@ namespace sts::ncm {
|
|||||||
static const TitleId Olsc;
|
static const TitleId Olsc;
|
||||||
static const TitleId Dt;
|
static const TitleId Dt;
|
||||||
static const TitleId Nd;
|
static const TitleId Nd;
|
||||||
|
static const TitleId Ngct;
|
||||||
|
|
||||||
static const TitleId SystemEnd;
|
static const TitleId SystemEnd;
|
||||||
|
|
||||||
@ -279,6 +280,7 @@ namespace sts::ncm {
|
|||||||
inline constexpr const TitleId TitleId::Olsc = { 0x010000000000003Eul };
|
inline constexpr const TitleId TitleId::Olsc = { 0x010000000000003Eul };
|
||||||
inline constexpr const TitleId TitleId::Dt = { 0x010000000000003Ful };
|
inline constexpr const TitleId TitleId::Dt = { 0x010000000000003Ful };
|
||||||
inline constexpr const TitleId TitleId::Nd = { 0x0100000000000040ul };
|
inline constexpr const TitleId TitleId::Nd = { 0x0100000000000040ul };
|
||||||
|
inline constexpr const TitleId TitleId::Ngct = { 0x0100000000000041ul };
|
||||||
|
|
||||||
inline constexpr const TitleId TitleId::SystemEnd = { 0x01000000000007FFul };
|
inline constexpr const TitleId TitleId::SystemEnd = { 0x01000000000007FFul };
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ namespace sts::cfg {
|
|||||||
sm::ServiceName::Encode("pcv"),
|
sm::ServiceName::Encode("pcv"),
|
||||||
sm::ServiceName::Encode("gpio"),
|
sm::ServiceName::Encode("gpio"),
|
||||||
sm::ServiceName::Encode("pinmux"),
|
sm::ServiceName::Encode("pinmux"),
|
||||||
sm::ServiceName::Encode("psc:c")
|
sm::ServiceName::Encode("psc:m"),
|
||||||
};
|
};
|
||||||
constexpr size_t NumRequiredServicesForSdCardAccess = util::size(RequiredServicesForSdCardAccess);
|
constexpr size_t NumRequiredServicesForSdCardAccess = util::size(RequiredServicesForSdCardAccess);
|
||||||
|
|
||||||
@ -46,6 +46,7 @@ namespace sts::cfg {
|
|||||||
return ResultFsSdCardNotPresent;
|
return ResultFsSdCardNotPresent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
R_ASSERT(fsMountSdcard(&g_sd_card_filesystem));
|
R_ASSERT(fsMountSdcard(&g_sd_card_filesystem));
|
||||||
g_sd_card_initialized = true;
|
g_sd_card_initialized = true;
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
@ -76,6 +76,9 @@ static void _CacheValues(void)
|
|||||||
case AtmosphereTargetFirmware_810:
|
case AtmosphereTargetFirmware_810:
|
||||||
g_firmware_version = FirmwareVersion_810;
|
g_firmware_version = FirmwareVersion_810;
|
||||||
break;
|
break;
|
||||||
|
case AtmosphereTargetFirmware_900:
|
||||||
|
g_firmware_version = FirmwareVersion_900;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
std::abort();
|
std::abort();
|
||||||
break;
|
break;
|
||||||
@ -139,6 +142,11 @@ void SetFirmwareVersionForLibnx() {
|
|||||||
minor = 1;
|
minor = 1;
|
||||||
micro = 0;
|
micro = 0;
|
||||||
break;
|
break;
|
||||||
|
case FirmwareVersion_900:
|
||||||
|
major = 9;
|
||||||
|
minor = 0;
|
||||||
|
micro = 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
std::abort();
|
std::abort();
|
||||||
break;
|
break;
|
||||||
|
@ -102,6 +102,136 @@ namespace sts::ldr {
|
|||||||
bool g_has_nso[Nso_Count];
|
bool g_has_nso[Nso_Count];
|
||||||
NsoHeader g_nso_headers[Nso_Count];
|
NsoHeader g_nso_headers[Nso_Count];
|
||||||
|
|
||||||
|
/* Anti-downgrade. */
|
||||||
|
struct MinimumTitleVersion {
|
||||||
|
ncm::TitleId title_id;
|
||||||
|
u32 version;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr u32 MakeSystemVersion(u32 major, u32 minor, u32 micro) {
|
||||||
|
return (major << 26) | (minor << 20) | (micro << 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr MinimumTitleVersion g_MinimumTitleVersions810[] = {
|
||||||
|
{ncm::TitleId::Settings, 1},
|
||||||
|
{ncm::TitleId::Bus, 1},
|
||||||
|
{ncm::TitleId::Audio, 1},
|
||||||
|
{ncm::TitleId::NvServices, 1},
|
||||||
|
{ncm::TitleId::Ns, 1},
|
||||||
|
{ncm::TitleId::Ssl, 1},
|
||||||
|
{ncm::TitleId::Es, 1},
|
||||||
|
{ncm::TitleId::Creport, 1},
|
||||||
|
{ncm::TitleId::Ro, 1},
|
||||||
|
};
|
||||||
|
constexpr size_t g_MinimumTitleVersionsCount810 = util::size(g_MinimumTitleVersions810);
|
||||||
|
|
||||||
|
constexpr MinimumTitleVersion g_MinimumTitleVersions900[] = {
|
||||||
|
/* All non-Development System Modules. */
|
||||||
|
{ncm::TitleId::Usb, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Tma, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Boot2, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Settings, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Bus, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Bluetooth, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Bcat, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Dmnt, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Friends, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Nifm, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Ptm, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Shell, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::BsdSockets, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Hid, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Audio, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::LogManager, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Wlan, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Cs, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Ldn, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::NvServices, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Pcv, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Ppc, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::NvnFlinger, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Pcie, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Account, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Ns, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Nfc, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Psc, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::CapSrv, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Am, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Ssl, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Nim, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Cec, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
/* {ncm::TitleId::Tspm, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
/* {ncm::TitleId::Spl, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Lbl, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Btm, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Erpt, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Time, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Vi, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Pctl, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Npns, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Eupld, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Glue, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Eclct, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Es, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Fatal, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Grc, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Creport, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Ro, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Profiler, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Sdb, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Migration, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Jit, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::JpegDec, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::SafeMode, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::Olsc, MakeSystemVersion(9, 0, 0)},
|
||||||
|
/* {ncm::TitleId::Dt, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
/* {ncm::TitleId::Nd, MakeSystemVersion(9, 0, 0)}, */
|
||||||
|
{ncm::TitleId::Ngct, MakeSystemVersion(9, 0, 0)},
|
||||||
|
|
||||||
|
/* All Web Applets. */
|
||||||
|
{ncm::TitleId::AppletWeb, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::AppletShop, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::AppletOfflineWeb, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::AppletLoginShare, MakeSystemVersion(9, 0, 0)},
|
||||||
|
{ncm::TitleId::AppletWifiWebAuth, MakeSystemVersion(9, 0, 0)},
|
||||||
|
};
|
||||||
|
constexpr size_t g_MinimumTitleVersionsCount900 = util::size(g_MinimumTitleVersions900);
|
||||||
|
|
||||||
|
Result ValidateTitleVersion(ncm::TitleId title_id, u32 version) {
|
||||||
|
if (GetRuntimeFirmwareVersion() < FirmwareVersion_810) {
|
||||||
|
return ResultSuccess;
|
||||||
|
} else {
|
||||||
|
#ifdef LDR_VALIDATE_PROCESS_VERSION
|
||||||
|
const MinimumTitleVersion *entries = nullptr;
|
||||||
|
size_t num_entries = 0;
|
||||||
|
switch (GetRuntimeFirmwareVersion()) {
|
||||||
|
case FirmwareVersion_810:
|
||||||
|
entries = g_MinimumTitleVersions810;
|
||||||
|
num_entries = g_MinimumTitleVersionsCount810;
|
||||||
|
break;
|
||||||
|
case FirmwareVersion_900:
|
||||||
|
entries = g_MinimumTitleVersions900;
|
||||||
|
num_entries = g_MinimumTitleVersionsCount900;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
entries = nullptr;
|
||||||
|
num_entries = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < num_entries; i++) {
|
||||||
|
if (entries[i].title_id == title_id && entries[i].version > version) {
|
||||||
|
return ResultLoaderInvalidVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResultSuccess;
|
||||||
|
#else
|
||||||
|
return ResultSuccess;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Helpers. */
|
/* Helpers. */
|
||||||
Result GetProgramInfoFromMeta(ProgramInfo *out, const Meta *meta) {
|
Result GetProgramInfoFromMeta(ProgramInfo *out, const Meta *meta) {
|
||||||
/* Copy basic info. */
|
/* Copy basic info. */
|
||||||
@ -115,7 +245,7 @@ namespace sts::ldr {
|
|||||||
#define COPY_ACCESS_CONTROL(source, which) \
|
#define COPY_ACCESS_CONTROL(source, which) \
|
||||||
({ \
|
({ \
|
||||||
const size_t size = meta->source->which##_size; \
|
const size_t size = meta->source->which##_size; \
|
||||||
if (offset + size >= sizeof(out->ac_buffer)) { \
|
if (offset + size > sizeof(out->ac_buffer)) { \
|
||||||
return ResultLoaderInternalError; \
|
return ResultLoaderInternalError; \
|
||||||
} \
|
} \
|
||||||
out->source##_##which##_size = size; \
|
out->source##_##which##_size = size; \
|
||||||
@ -151,35 +281,6 @@ namespace sts::ldr {
|
|||||||
return static_cast<Acid::PoolPartition>((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift);
|
return static_cast<Acid::PoolPartition>((meta->acid->flags & Acid::AcidFlag_PoolPartitionMask) >> Acid::AcidFlag_PoolPartitionShift);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool IsDisallowedVersion810(const ncm::TitleId title_id, const u32 version) {
|
|
||||||
return version == 0 &&
|
|
||||||
(title_id == ncm::TitleId::Settings ||
|
|
||||||
title_id == ncm::TitleId::Bus ||
|
|
||||||
title_id == ncm::TitleId::Audio ||
|
|
||||||
title_id == ncm::TitleId::NvServices ||
|
|
||||||
title_id == ncm::TitleId::Ns ||
|
|
||||||
title_id == ncm::TitleId::Ssl ||
|
|
||||||
title_id == ncm::TitleId::Es ||
|
|
||||||
title_id == ncm::TitleId::Creport ||
|
|
||||||
title_id == ncm::TitleId::Ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result ValidateTitleVersion(ncm::TitleId title_id, u32 version) {
|
|
||||||
if (GetRuntimeFirmwareVersion() < FirmwareVersion_810) {
|
|
||||||
return ResultSuccess;
|
|
||||||
} else {
|
|
||||||
#ifdef LDR_VALIDATE_PROCESS_VERSION
|
|
||||||
if (IsDisallowedVersion810(title_id, version)) {
|
|
||||||
return ResultLoaderInvalidVersion;
|
|
||||||
} else {
|
|
||||||
return ResultSuccess;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return ResultSuccess;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Result LoadNsoHeaders(ncm::TitleId title_id, NsoHeader *nso_headers, bool *has_nso) {
|
Result LoadNsoHeaders(ncm::TitleId title_id, NsoHeader *nso_headers, bool *has_nso) {
|
||||||
/* Clear NSOs. */
|
/* Clear NSOs. */
|
||||||
std::memset(nso_headers, 0, sizeof(*nso_headers) * Nso_Count);
|
std::memset(nso_headers, 0, sizeof(*nso_headers) * Nso_Count);
|
||||||
|
@ -35,11 +35,11 @@ namespace sts::boot2 {
|
|||||||
ncm::TitleId::Bus, /* bus */
|
ncm::TitleId::Bus, /* bus */
|
||||||
ncm::TitleId::Settings, /* settings */
|
ncm::TitleId::Settings, /* settings */
|
||||||
ncm::TitleId::Pcv, /* pcv */
|
ncm::TitleId::Pcv, /* pcv */
|
||||||
|
ncm::TitleId::Usb, /* usb */
|
||||||
};
|
};
|
||||||
constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms);
|
constexpr size_t NumPreSdCardLaunchPrograms = util::size(PreSdCardLaunchPrograms);
|
||||||
|
|
||||||
constexpr ncm::TitleId AdditionalLaunchPrograms[] = {
|
constexpr ncm::TitleId AdditionalLaunchPrograms[] = {
|
||||||
ncm::TitleId::Usb, /* usb */
|
|
||||||
ncm::TitleId::Tma, /* tma */
|
ncm::TitleId::Tma, /* tma */
|
||||||
ncm::TitleId::Am, /* am */
|
ncm::TitleId::Am, /* am */
|
||||||
ncm::TitleId::NvServices, /* nvservices */
|
ncm::TitleId::NvServices, /* nvservices */
|
||||||
@ -80,11 +80,11 @@ namespace sts::boot2 {
|
|||||||
ncm::TitleId::Migration, /* migration */
|
ncm::TitleId::Migration, /* migration */
|
||||||
ncm::TitleId::Grc, /* grc */
|
ncm::TitleId::Grc, /* grc */
|
||||||
ncm::TitleId::Olsc, /* olsc */
|
ncm::TitleId::Olsc, /* olsc */
|
||||||
|
ncm::TitleId::Ngct, /* ngct */
|
||||||
};
|
};
|
||||||
constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms);
|
constexpr size_t NumAdditionalLaunchPrograms = util::size(AdditionalLaunchPrograms);
|
||||||
|
|
||||||
constexpr ncm::TitleId AdditionalMaintenanceLaunchPrograms[] = {
|
constexpr ncm::TitleId AdditionalMaintenanceLaunchPrograms[] = {
|
||||||
ncm::TitleId::Usb, /* usb */
|
|
||||||
ncm::TitleId::Tma, /* tma */
|
ncm::TitleId::Tma, /* tma */
|
||||||
ncm::TitleId::Am, /* am */
|
ncm::TitleId::Am, /* am */
|
||||||
ncm::TitleId::NvServices, /* nvservices */
|
ncm::TitleId::NvServices, /* nvservices */
|
||||||
@ -121,6 +121,7 @@ namespace sts::boot2 {
|
|||||||
ncm::TitleId::Migration, /* migration */
|
ncm::TitleId::Migration, /* migration */
|
||||||
ncm::TitleId::Grc, /* grc */
|
ncm::TitleId::Grc, /* grc */
|
||||||
ncm::TitleId::Olsc, /* olsc */
|
ncm::TitleId::Olsc, /* olsc */
|
||||||
|
ncm::TitleId::Ngct, /* ngct */
|
||||||
};
|
};
|
||||||
constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms);
|
constexpr size_t NumAdditionalMaintenanceLaunchPrograms = util::size(AdditionalMaintenanceLaunchPrograms);
|
||||||
|
|
||||||
@ -156,6 +157,7 @@ namespace sts::boot2 {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (out_process_id) {
|
if (out_process_id) {
|
||||||
*out_process_id = process_id;
|
*out_process_id = process_id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user