Skip to content

Commit

Permalink
ams: update for 12.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
SciresM committed May 12, 2021
1 parent b846628 commit bb4c7a3
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions fusee/fusee-secondary/src/fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ uint32_t fuse_get_regulator(void) {


static const uint32_t fuse_version_increment_firmwares[] = {
ATMOSPHERE_TARGET_FIRMWARE_12_0_2,
ATMOSPHERE_TARGET_FIRMWARE_11_0_0,
ATMOSPHERE_TARGET_FIRMWARE_10_0_0,
ATMOSPHERE_TARGET_FIRMWARE_9_1_0,
Expand Down
8 changes: 8 additions & 0 deletions fusee/fusee-secondary/src/nxboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ static uint32_t nxboot_get_specific_target_firmware(uint32_t target_firmware){
#define CHECK_NCA(NCA_ID, VERSION) do { if (is_nca_present(NCA_ID)) { return ATMOSPHERE_TARGET_FIRMWARE_##VERSION; } } while(0)

if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_12_0_0) {
CHECK_NCA("63d928b5a3016fe8cc0e76d2f06f4e98", 12_0_2);
CHECK_NCA("e65114b456f9d0b566a80e53bade2d89", 12_0_1);
CHECK_NCA("bd4185843550fbba125b20787005d1d2", 12_0_0);
} else if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_11_0_0) {
Expand Down Expand Up @@ -393,6 +394,8 @@ static uint32_t nxboot_get_target_firmware(const void *package1loader) {
return ATMOSPHERE_TARGET_FIRMWARE_11_0_0;
} else if (memcmp(package1loader_header->build_timestamp, "20210129", 8) == 0) {
return ATMOSPHERE_TARGET_FIRMWARE_12_0_0;
} else if (memcmp(package1loader_header->build_timestamp, "20210422", 8) == 0) {
return ATMOSPHERE_TARGET_FIRMWARE_12_0_2;
} else {
fatal_error("[NXBOOT] Unable to identify package1!\n");
}
Expand Down Expand Up @@ -604,6 +607,11 @@ static void nxboot_configure_stratosphere(uint32_t target_firmware) {
/* NOTE: 12.0.0 added a new lotus firmware, but did not burn a fuse. */
/* This is literally undetectable using normal fuses.... */
/* C'est la vie. */

/* Check if the fuses are < 12.0.0, but firmware is >= 12.0.0 */
if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_12_0_2 && !(fuse_get_reserved_odm(7) & ~0x00003FFF)) {
kip_patches_set_enable_nogc();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion fusee/fusee-secondary/src/package2.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static bool package2_validate_metadata(package2_meta_t *metadata, uint8_t data[]

/* Perform version checks. */
/* 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_1100_CURRENT) {
if (metadata->version_max >= PACKAGE2_MINVER_THEORETICAL && metadata->version_min < PACKAGE2_MAXVER_1202_CURRENT) {
return true;
}

Expand Down
6 changes: 4 additions & 2 deletions fusee/fusee-secondary/src/package2.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
#define PACKAGE2_MAXVER_900 0xC
#define PACKAGE2_MAXVER_910_920 0xD
#define PACKAGE2_MAXVER_1000 0xE
#define PACKAGE2_MAXVER_1100_CURRENT 0xF
#define PACKAGE2_MAXVER_1100 0xF
#define PACKAGE2_MAXVER_1202_CURRENT 0x10

#define PACKAGE2_MINVER_100 0x3
#define PACKAGE2_MINVER_200 0x4
Expand All @@ -56,7 +57,8 @@
#define PACKAGE2_MINVER_900 0xD
#define PACKAGE2_MINVER_910_920 0xE
#define PACKAGE2_MINVER_1000 0xF
#define PACKAGE2_MINVER_1100_CURRENT 0x10
#define PACKAGE2_MINVER_1100 0x10
#define PACKAGE2_MINVER_1202_CURRENT 0x11

#define NX_BOOTLOADER_PACKAGE2_LOAD_ADDRESS ((void *)(0xA9800000ull))

Expand Down
4 changes: 2 additions & 2 deletions libraries/libexosphere/include/exosphere/pkg2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace ams::pkg2 {

constexpr inline int PayloadCount = 3;

constexpr inline int MinimumValidDataVersion = 0; /* We allow older package2 to load; this value is currently 0x10 in Nintendo's code. */
constexpr inline int CurrentBootloaderVersion = 0xE;
constexpr inline int MinimumValidDataVersion = 0; /* We allow older package2 to load; this value is currently 0x11 in Nintendo's code. */
constexpr inline int CurrentBootloaderVersion = 0xF;

struct Package2Meta {
using Magic = util::FourCC<'P','K','2','1'>;
Expand Down
1 change: 1 addition & 0 deletions libraries/libexosphere/source/fuse/fuse_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ namespace ams::fuse {
}

constexpr const TargetFirmware FuseVersionIncrementFirmwares[] = {
TargetFirmware_12_0_2,
TargetFirmware_11_0_0,
TargetFirmware_10_0_0,
TargetFirmware_9_1_0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace ams::hos {
Version_11_0_1 = ::ams::TargetFirmware_11_0_1,
Version_12_0_0 = ::ams::TargetFirmware_12_0_0,
Version_12_0_1 = ::ams::TargetFirmware_12_0_1,
Version_12_0_2 = ::ams::TargetFirmware_12_0_2,

Version_Current = ::ams::TargetFirmware_Current,

Expand Down
4 changes: 2 additions & 2 deletions libraries/libvapours/include/vapours/ams/ams_api_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

#define ATMOSPHERE_RELEASE_VERSION_MAJOR 0
#define ATMOSPHERE_RELEASE_VERSION_MINOR 19
#define ATMOSPHERE_RELEASE_VERSION_MICRO 2
#define ATMOSPHERE_RELEASE_VERSION_MICRO 3

#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO

#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 12
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 0
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 1
#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 2
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@
#define ATMOSPHERE_TARGET_FIRMWARE_11_0_1 ATMOSPHERE_TARGET_FIRMWARE(11, 0, 1)
#define ATMOSPHERE_TARGET_FIRMWARE_12_0_0 ATMOSPHERE_TARGET_FIRMWARE(12, 0, 0)
#define ATMOSPHERE_TARGET_FIRMWARE_12_0_1 ATMOSPHERE_TARGET_FIRMWARE(12, 0, 1)
#define ATMOSPHERE_TARGET_FIRMWARE_12_0_2 ATMOSPHERE_TARGET_FIRMWARE(12, 0, 2)

#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_12_0_1
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_12_0_2

#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE(0, 0, 0)
#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_CURRENT
Expand Down Expand Up @@ -114,6 +115,7 @@ namespace ams {
TargetFirmware_11_0_1 = ATMOSPHERE_TARGET_FIRMWARE_11_0_1,
TargetFirmware_12_0_0 = ATMOSPHERE_TARGET_FIRMWARE_12_0_0,
TargetFirmware_12_0_1 = ATMOSPHERE_TARGET_FIRMWARE_12_0_1,
TargetFirmware_12_0_2 = ATMOSPHERE_TARGET_FIRMWARE_12_0_2,

TargetFirmware_Current = ATMOSPHERE_TARGET_FIRMWARE_CURRENT,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define PINMUX_AUX_DVFS_PWM (0x3184)
#define PINMUX_AUX_NFC_EN (0x31D0)
#define PINMUX_AUX_NFC_INT (0x31D4)
#define PINMUX_AUX_CAM_FLASH_EN (0x31E8)
#define PINMUX_AUX_LCD_BL_PWM (0x31FC)
#define PINMUX_AUX_LCD_BL_EN (0x3200)
#define PINMUX_AUX_LCD_RST (0x3204)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace ams::mitm::socket::resolver {

LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname);

R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession());
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());

ams::socket::InAddrT redirect_addr = {};
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
Expand All @@ -109,7 +109,7 @@ namespace ams::mitm::socket::resolver {

LogDebug("[%016lx]: GetAddrInfoRequest(%s, %s)\n", this->client_info.program_id.value, reinterpret_cast<const char *>(node.GetPointer()), reinterpret_cast<const char *>(srv.GetPointer()));

R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession());
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());

ams::socket::InAddrT redirect_addr = {};
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
Expand Down Expand Up @@ -146,7 +146,7 @@ namespace ams::mitm::socket::resolver {

LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname);

R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession());
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());

ams::socket::InAddrT redirect_addr = {};
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
Expand All @@ -166,7 +166,7 @@ namespace ams::mitm::socket::resolver {

LogDebug("[%016lx]: GetAddrInfoRequestWithOptions(%s, %s)\n", this->client_info.program_id.value, hostname, reinterpret_cast<const char *>(srv.GetPointer()));

R_UNLESS(hostname != nullptr, sm::ResultShouldForwardToSession());
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());

ams::socket::InAddrT redirect_addr = {};
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
Expand Down
6 changes: 6 additions & 0 deletions stratosphere/boot/source/boot_charger_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ namespace ams::boot {
}

Result Initialize(bool set_input_current_limit) {
/* Configure PINMUX_AUX_CAM_FLASH_EN as tristate + passthrough. */
{
const uintptr_t apb_regs = dd::QueryIoMapping(0x70000000ul, os::MemoryPageSize);
reg::ClearBits(apb_regs + PINMUX_AUX_CAM_FLASH_EN, reg::EncodeMask(PINMUX_REG_BITS_MASK(AUX_TRISTATE)));
}

/* Set input current limit to 500 ma. */
if (set_input_current_limit) {
R_TRY(powctl::SetChargerInputCurrentLimit(this->charger_session, 500));
Expand Down

0 comments on commit bb4c7a3

Please sign in to comment.