Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dbc79dd5c | ||
|
|
90b54c03b3 | ||
|
|
7821241356 | ||
|
|
8fea8d9b2e | ||
|
|
dcdf46f576 | ||
|
|
df5537b748 | ||
|
|
0f2855ada8 | ||
|
|
c790d03693 | ||
|
|
25be7c5b1b | ||
|
|
7e05e12b83 | ||
|
|
99d7f72c51 | ||
|
|
691a453d77 | ||
|
|
88246f475c | ||
|
|
269d4496b2 | ||
|
|
bb4c7a390b | ||
|
|
b846628362 | ||
|
|
26fb201518 | ||
|
|
01ce7cef14 | ||
|
|
3f3aaa01fa | ||
|
|
bf8de39e69 | ||
|
|
6bb4253df5 | ||
|
|
cfd7121574 | ||
|
|
972681c57e | ||
|
|
0a11cbc2d6 | ||
|
|
32f487abfb | ||
|
|
7d61cab01c | ||
|
|
14ed4e4057 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -49,6 +49,8 @@ X.X.X</br>
|
||||
- [ Ex: Kosmos' distribution of Atmosphère ]
|
||||
- Do you have additional kips or sysmodules you're loading:
|
||||
- Homebrew software installed: [ * ]
|
||||
- EmuMMC or SysNAND:
|
||||
- [ If using an EmuMMC, include whether it's partition-based or file-based. ]
|
||||
|
||||
### Additional context?
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,18 @@
|
||||
# Changelog
|
||||
## 0.19.4
|
||||
+ Support was added for 12.0.3.
|
||||
+ A number of minor issues were fixed, including:
|
||||
+ An issue was fixed that could cause heap memory corruption when allocation was highly contended.
|
||||
+ An issue was fixed that could cause sleep to fail under certain conditions.
|
||||
+ An issue was fixed that could cause a scheduler slow path to be taken more often than necessary.
|
||||
+ General system stability improvements to enhance the user's experience.
|
||||
## 0.19.3
|
||||
+ Support was added for 12.0.2.
|
||||
+ A number of minor issues were fixed, including:
|
||||
+ An issue was fixed in dns.mitm that caused a crash when games attempted to resolve the IP address of nullptr.
|
||||
+ An issue was fixed in erpt that would cause an abort when booting without having ever booted stock previously.
|
||||
+ An issue was fixed in (file-based) emummc that caused an error on system format/downloading certain games.
|
||||
+ General system stability improvements to enhance the user's experience.
|
||||
## 0.19.2
|
||||
+ Atmosphère's components were further updated to reflect latest official behaviors as of 12.0.0.
|
||||
+ Notably, `erpt` was updated to implement the new forced shutdown detection feature.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[subrepo]
|
||||
remote = https://github.com/m4xw/emuMMC
|
||||
branch = develop
|
||||
commit = b355ee6a8f376faa615785419c7d73a8814d9d65
|
||||
parent = b24784f5c13a142bd0cb5d7edb82691c71f4bd00
|
||||
commit = 219c723c3001fbc33d47840ceceb83cf39a1d218
|
||||
parent = 7821241356c2f6b159945babf657ffd921957918
|
||||
method = rebase
|
||||
cmdver = 0.4.1
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
#include "offsets/1100_exfat.h"
|
||||
#include "offsets/1200.h"
|
||||
#include "offsets/1200_exfat.h"
|
||||
#include "offsets/1203.h"
|
||||
#include "offsets/1203_exfat.h"
|
||||
#include "../utils/fatal.h"
|
||||
|
||||
#define GET_OFFSET_STRUCT_NAME(vers) g_offsets##vers
|
||||
@@ -117,6 +119,8 @@ DEFINE_OFFSET_STRUCT(_1100);
|
||||
DEFINE_OFFSET_STRUCT(_1100_EXFAT);
|
||||
DEFINE_OFFSET_STRUCT(_1200);
|
||||
DEFINE_OFFSET_STRUCT(_1200_EXFAT);
|
||||
DEFINE_OFFSET_STRUCT(_1203);
|
||||
DEFINE_OFFSET_STRUCT(_1203_EXFAT);
|
||||
|
||||
const fs_offsets_t *get_fs_offsets(enum FS_VER version) {
|
||||
switch (version) {
|
||||
@@ -194,6 +198,10 @@ const fs_offsets_t *get_fs_offsets(enum FS_VER version) {
|
||||
return &(GET_OFFSET_STRUCT_NAME(_1200));
|
||||
case FS_VER_12_0_0_EXFAT:
|
||||
return &(GET_OFFSET_STRUCT_NAME(_1200_EXFAT));
|
||||
case FS_VER_12_0_3:
|
||||
return &(GET_OFFSET_STRUCT_NAME(_1203));
|
||||
case FS_VER_12_0_3_EXFAT:
|
||||
return &(GET_OFFSET_STRUCT_NAME(_1203_EXFAT));
|
||||
default:
|
||||
fatal_abort(Fatal_UnknownVersion);
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ enum FS_VER
|
||||
FS_VER_12_0_0,
|
||||
FS_VER_12_0_0_EXFAT,
|
||||
|
||||
FS_VER_12_0_3,
|
||||
FS_VER_12_0_3_EXFAT,
|
||||
|
||||
FS_VER_MAX,
|
||||
};
|
||||
|
||||
|
||||
60
emummc/source/FS/offsets/1203.h
Normal file
60
emummc/source/FS/offsets/1203.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
|
||||
* Copyright (c) 2019 Atmosphere-NX
|
||||
* Copyright (c) 2021 CTCaer
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
#ifndef __FS_1203_H__
|
||||
#define __FS_1203_H__
|
||||
|
||||
// Accessor vtable getters
|
||||
#define FS_OFFSET_1203_SDMMC_ACCESSOR_GC 0x1550E0
|
||||
#define FS_OFFSET_1203_SDMMC_ACCESSOR_SD 0x156EF0
|
||||
#define FS_OFFSET_1203_SDMMC_ACCESSOR_NAND 0x155610
|
||||
|
||||
// Hooks
|
||||
#define FS_OFFSET_1203_SDMMC_WRAPPER_READ 0x150A80
|
||||
#define FS_OFFSET_1203_SDMMC_WRAPPER_WRITE 0x150B40
|
||||
#define FS_OFFSET_1203_RTLD 0x688
|
||||
#define FS_OFFSET_1203_RTLD_DESTINATION ((uintptr_t)(INT64_C(-0x3C)))
|
||||
|
||||
#define FS_OFFSET_1203_CLKRST_SET_MIN_V_CLK_RATE 0x14FDD0
|
||||
|
||||
// Misc funcs
|
||||
#define FS_OFFSET_1203_LOCK_MUTEX 0x29350
|
||||
#define FS_OFFSET_1203_UNLOCK_MUTEX 0x293A0
|
||||
|
||||
#define FS_OFFSET_1203_SDMMC_WRAPPER_CONTROLLER_OPEN 0x150960
|
||||
#define FS_OFFSET_1203_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1509F0
|
||||
|
||||
// Misc Data
|
||||
#define FS_OFFSET_1203_SD_MUTEX 0xE3D3E8
|
||||
#define FS_OFFSET_1203_NAND_MUTEX 0xE38768
|
||||
#define FS_OFFSET_1203_ACTIVE_PARTITION 0xE387A8
|
||||
#define FS_OFFSET_1203_SDMMC_DAS_HANDLE 0xE20DB0
|
||||
|
||||
// NOPs
|
||||
#define FS_OFFSET_1203_SD_DAS_INIT 0x27244
|
||||
|
||||
// Nintendo Paths
|
||||
#define FS_OFFSET_1203_NINTENDO_PATHS \
|
||||
{ \
|
||||
{.opcode_reg = 3, .adrp_offset = 0x0006E920, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 3, .adrp_offset = 0x0007AFD0, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 4, .adrp_offset = 0x00081364, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 4, .adrp_offset = 0x00092960, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
|
||||
}
|
||||
|
||||
#endif // __FS_1203_H__
|
||||
60
emummc/source/FS/offsets/1203_exfat.h
Normal file
60
emummc/source/FS/offsets/1203_exfat.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2019 m4xw <m4x@m4xw.net>
|
||||
* Copyright (c) 2019 Atmosphere-NX
|
||||
* Copyright (c) 2021 CTCaer
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
#ifndef __FS_1203_EXFAT_H__
|
||||
#define __FS_1203_EXFAT_H__
|
||||
|
||||
// Accessor vtable getters
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_ACCESSOR_GC 0x1550E0
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_ACCESSOR_SD 0x156EF0
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_ACCESSOR_NAND 0x155610
|
||||
|
||||
// Hooks
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_WRAPPER_READ 0x150A80
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_WRAPPER_WRITE 0x150B40
|
||||
#define FS_OFFSET_1203_EXFAT_RTLD 0x688
|
||||
#define FS_OFFSET_1203_EXFAT_RTLD_DESTINATION ((uintptr_t)(INT64_C(-0x3C)))
|
||||
|
||||
#define FS_OFFSET_1203_EXFAT_CLKRST_SET_MIN_V_CLK_RATE 0x14FDD0
|
||||
|
||||
// Misc funcs
|
||||
#define FS_OFFSET_1203_EXFAT_LOCK_MUTEX 0x29350
|
||||
#define FS_OFFSET_1203_EXFAT_UNLOCK_MUTEX 0x293A0
|
||||
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_WRAPPER_CONTROLLER_OPEN 0x150960
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_WRAPPER_CONTROLLER_CLOSE 0x1509F0
|
||||
|
||||
// Misc Data
|
||||
#define FS_OFFSET_1203_EXFAT_SD_MUTEX 0xE4B3E8
|
||||
#define FS_OFFSET_1203_EXFAT_NAND_MUTEX 0xE46768
|
||||
#define FS_OFFSET_1203_EXFAT_ACTIVE_PARTITION 0xE467A8
|
||||
#define FS_OFFSET_1203_EXFAT_SDMMC_DAS_HANDLE 0xE2EDB0
|
||||
|
||||
// NOPs
|
||||
#define FS_OFFSET_1203_EXFAT_SD_DAS_INIT 0x27244
|
||||
|
||||
// Nintendo Paths
|
||||
#define FS_OFFSET_1203_EXFAT_NINTENDO_PATHS \
|
||||
{ \
|
||||
{.opcode_reg = 3, .adrp_offset = 0x0006E920, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 3, .adrp_offset = 0x0007AFD0, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 4, .adrp_offset = 0x00081364, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 4, .adrp_offset = 0x00092960, .add_rel_offset = 0x00000004}, \
|
||||
{.opcode_reg = 0, .adrp_offset = 0, .add_rel_offset = 0}, \
|
||||
}
|
||||
|
||||
#endif // __FS_1203_EXFAT_H__
|
||||
@@ -292,6 +292,36 @@ static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned
|
||||
{
|
||||
fp = &f_emu.fp_gpp[sector / f_emu.part_size];
|
||||
sector = sector % f_emu.part_size;
|
||||
|
||||
// Special handling for reads/writes which cross file-boundaries.
|
||||
if (__builtin_expect(sector + num_sectors > f_emu.part_size, 0))
|
||||
{
|
||||
unsigned int remaining = num_sectors;
|
||||
while (remaining > 0) {
|
||||
const unsigned int cur_sectors = MIN(remaining, f_emu.part_size - sector);
|
||||
|
||||
if (f_lseek(fp, (u64)sector << 9) != FR_OK)
|
||||
return 0; // Out of bounds.
|
||||
|
||||
if (is_write)
|
||||
{
|
||||
if (f_write_fast(fp, buf, (u64)cur_sectors << 9) != FR_OK)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (f_read_fast(fp, buf, (u64)cur_sectors << 9) != FR_OK)
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf = (char *)buf + ((u64)cur_sectors << 9);
|
||||
remaining -= cur_sectors;
|
||||
sector = 0;
|
||||
++fp;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -306,14 +336,14 @@ static uint64_t emummc_read_write_inner(void *buf, unsigned int sector, unsigned
|
||||
break;
|
||||
}
|
||||
|
||||
if (f_lseek(fp, sector << 9) != FR_OK)
|
||||
if (f_lseek(fp, (u64)sector << 9) != FR_OK)
|
||||
return 0; // Out of bounds.
|
||||
|
||||
uint64_t res = 0;
|
||||
if (!is_write)
|
||||
res = !f_read_fast(fp, buf, num_sectors << 9);
|
||||
res = !f_read_fast(fp, buf, (u64)num_sectors << 9);
|
||||
else
|
||||
res = !f_write_fast(fp, buf, num_sectors << 9);
|
||||
res = !f_write_fast(fp, buf, (u64)num_sectors << 9);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace ams::warmboot {
|
||||
void Main(const Metadata *metadata) {
|
||||
/* Ensure that we're running under vaguely sane conditions. */
|
||||
AMS_ABORT_UNLESS(metadata->magic == Metadata::Magic);
|
||||
AMS_ABORT_UNLESS(metadata->target_firmware <= ams::TargetFirmware_Max);
|
||||
|
||||
/* Restrict the bpmp's access to dram. */
|
||||
if (metadata->target_firmware >= TargetFirmware_4_0_0) {
|
||||
|
||||
@@ -94,6 +94,9 @@ typedef enum {
|
||||
FS_VER_12_0_0,
|
||||
FS_VER_12_0_0_EXFAT,
|
||||
|
||||
FS_VER_12_0_3,
|
||||
FS_VER_12_0_3_EXFAT,
|
||||
|
||||
FS_VER_MAX,
|
||||
} emummc_fs_ver_t;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -429,6 +429,9 @@ static const uint8_t g_fs_hashes[FS_VER_MAX][0x8] = {
|
||||
|
||||
"\xDC\x2A\x08\x49\x96\xBB\x3C\x01", /* FS_VER_12_0_0 */
|
||||
"\xD5\xA5\xBF\x36\x64\x0C\x49\xEA", /* FS_VER_12_0_0_EXFAT */
|
||||
|
||||
"\xC8\x67\x62\xBE\x19\xA5\x1F\xA0", /* FS_VER_12_0_3 */
|
||||
"\xE1\xE8\xD3\xD6\xA2\xFE\x0B\x10", /* FS_VER_12_0_3_EXFAT */
|
||||
};
|
||||
|
||||
kip1_header_t *apply_kip_ips_patches(kip1_header_t *kip, size_t kip_size, emummc_fs_ver_t *out_fs_ver) {
|
||||
|
||||
@@ -285,7 +285,10 @@ static bool is_nca_present(const char *nca_name) {
|
||||
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) {
|
||||
if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_12_0_2) {
|
||||
CHECK_NCA("a1863a5c0e1cedd442f5e60b0422dc15", 12_0_3);
|
||||
CHECK_NCA("63d928b5a3016fe8cc0e76d2f06f4e98", 12_0_2);
|
||||
} else if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_12_0_0) {
|
||||
CHECK_NCA("e65114b456f9d0b566a80e53bade2d89", 12_0_1);
|
||||
CHECK_NCA("bd4185843550fbba125b20787005d1d2", 12_0_0);
|
||||
} else if (target_firmware >= ATMOSPHERE_TARGET_FIRMWARE_11_0_0) {
|
||||
@@ -393,6 +396,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");
|
||||
}
|
||||
@@ -604,6 +609,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
[subrepo]
|
||||
remote = https://github.com/Atmosphere-NX/Atmosphere-libs
|
||||
branch = master
|
||||
commit = acee57e888aa87ba8976db889dfcf20701cb38a8
|
||||
parent = dbcb1e15648ef7b050b9b59b40d413038b4888ec
|
||||
commit = b5b55f60d8567ea4608163abc299e5e238381d44
|
||||
parent = 7e05e12b833e19333ffac02e4fec72250c8b17fa
|
||||
method = merge
|
||||
cmdver = 0.4.1
|
||||
|
||||
@@ -34,7 +34,8 @@ export CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \
|
||||
-Wl,--wrap,_Unwind_Resume \
|
||||
-Wl,--wrap,_ZSt19__throw_logic_errorPKc \
|
||||
-Wl,--wrap,_ZSt20__throw_length_errorPKc \
|
||||
-Wl,--wrap,_ZNSt11logic_errorC2EPKc
|
||||
-Wl,--wrap,_ZNSt11logic_errorC2EPKc \
|
||||
-Wl,--wrap,exit
|
||||
|
||||
export LDFLAGS = -specs=$(ATMOSPHERE_LIBRARIES_DIR)/libstratosphere/stratosphere.specs -specs=$(DEVKITPRO)/libnx/switch.specs $(SETTINGS) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
|
||||
@@ -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'>;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -308,8 +308,11 @@ namespace ams::kern {
|
||||
}
|
||||
|
||||
/* Send an exception event to represent our breaking the process. */
|
||||
static_assert(util::size(thread_ids) >= 4);
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_Exception, ams::svc::DebugException_DebuggerBreak, thread_ids[0], thread_ids[1], thread_ids[2], thread_ids[3]);
|
||||
/* TODO: How should this be handled in the case of more than 4 physical cores? */
|
||||
static_assert(util::size(thread_ids) <= 4);
|
||||
[&]<size_t... Ix>(std::index_sequence<Ix...>) ALWAYS_INLINE_LAMBDA {
|
||||
this->PushDebugEvent(ams::svc::DebugEvent_Exception, ams::svc::DebugException_DebuggerBreak, thread_ids[Ix]...);
|
||||
}(std::make_index_sequence<util::size(thread_ids)>());
|
||||
|
||||
/* Signal. */
|
||||
this->NotifyAvailable();
|
||||
|
||||
@@ -231,6 +231,10 @@ namespace ams::kern {
|
||||
next_thread = m_idle_thread;
|
||||
}
|
||||
|
||||
if (next_thread->GetCurrentCore() != m_core_id) {
|
||||
next_thread->SetCurrentCore(m_core_id);
|
||||
}
|
||||
|
||||
/* If we're not actually switching thread, there's nothing to do. */
|
||||
if (next_thread == cur_thread) {
|
||||
return;
|
||||
@@ -263,10 +267,6 @@ namespace ams::kern {
|
||||
|
||||
MESOSPHERE_KTRACE_THREAD_SWITCH(next_thread);
|
||||
|
||||
if (next_thread->GetCurrentCore() != m_core_id) {
|
||||
next_thread->SetCurrentCore(m_core_id);
|
||||
}
|
||||
|
||||
/* Switch the current process, if we're switching processes. */
|
||||
if (KProcess *next_process = next_thread->GetOwnerProcess(); next_process != cur_process) {
|
||||
KProcess::Switch(cur_process, next_process);
|
||||
|
||||
@@ -124,6 +124,7 @@ $(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
ams_environment_weak.o: CXXFLAGS += -fno-lto
|
||||
pm_info_api_weak.o: CXXFLAGS += -fno-lto
|
||||
hos_stratosphere_api.o: CXXFLAGS += -fno-lto
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%_bin.h %.bin.o : %.bin
|
||||
|
||||
@@ -20,23 +20,23 @@ namespace ams::fs::impl {
|
||||
|
||||
class Newable {
|
||||
public:
|
||||
static void *operator new(size_t size) {
|
||||
static ALWAYS_INLINE void *operator new(size_t size) noexcept {
|
||||
return ::ams::fs::impl::Allocate(size);
|
||||
}
|
||||
|
||||
static void *operator new(size_t size, Newable *placement) {
|
||||
static ALWAYS_INLINE void *operator new(size_t size, Newable *placement) noexcept {
|
||||
return placement;
|
||||
}
|
||||
|
||||
static void *operator new[](size_t size) {
|
||||
static ALWAYS_INLINE void *operator new[](size_t size) noexcept {
|
||||
return ::ams::fs::impl::Allocate(size);
|
||||
}
|
||||
|
||||
static void operator delete(void *ptr, size_t size) {
|
||||
static ALWAYS_INLINE void operator delete(void *ptr, size_t size) noexcept {
|
||||
return ::ams::fs::impl::Deallocate(ptr, size);
|
||||
}
|
||||
|
||||
static void operator delete[](void *ptr, size_t size) {
|
||||
static ALWAYS_INLINE void operator delete[](void *ptr, size_t size) noexcept {
|
||||
return ::ams::fs::impl::Deallocate(ptr, size);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,11 +106,9 @@ namespace ams::fssystem {
|
||||
|
||||
using Newable::operator new;
|
||||
using Newable::operator delete;
|
||||
static void *operator new(size_t, void *p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
static void operator delete(void *, size_t, void*) { /* ... */ }
|
||||
static ALWAYS_INLINE void *operator new(size_t, void *p) noexcept { return p; }
|
||||
static ALWAYS_INLINE void operator delete(void *, size_t, void*) noexcept { /* ... */ }
|
||||
};
|
||||
|
||||
using AttrListTraits = util::IntrusiveListBaseTraits<AttrInfo>;
|
||||
|
||||
@@ -62,6 +62,8 @@ 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_12_0_3 = ::ams::TargetFirmware_12_0_3,
|
||||
|
||||
Version_Current = ::ams::TargetFirmware_Current,
|
||||
|
||||
|
||||
@@ -54,7 +54,10 @@ namespace ams::sf::cmif {
|
||||
Result (*handler)(CmifOutHeader **out_header_ptr, ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data);
|
||||
|
||||
constexpr inline bool Matches(u32 cmd_id, hos::Version hosver) const {
|
||||
return this->cmd_id == cmd_id && this->hosver_low <= hosver && hosver <= this->hosver_high;
|
||||
const bool min_valid = this->hosver_low == hos::Version_Min;
|
||||
const bool max_valid = this->hosver_high == hos::Version_Max;
|
||||
|
||||
return this->cmd_id == cmd_id && (min_valid || this->hosver_low <= hosver) && (max_valid || hosver <= this->hosver_high);
|
||||
}
|
||||
|
||||
constexpr inline decltype(handler) GetHandler() const {
|
||||
|
||||
@@ -79,8 +79,9 @@ namespace ams::tipc::impl {
|
||||
|
||||
#define AMS_TIPC_IMPL_PROCESS_METHOD_REQUEST_BY_ID(CLASSNAME, CMD_ID, RETURN, NAME, ARGS, ARGNAMES, VERSION_MIN, VERSION_MAX) \
|
||||
if constexpr (constexpr u16 TipcCommandId = CMD_ID + 0x10; CommandId == TipcCommandId) { \
|
||||
constexpr bool AlwaysValid = VERSION_MIN == hos::Version_Min && VERSION_MAX == hos::Version_Max; \
|
||||
if (AlwaysValid || (VERSION_MIN <= fw_ver && fw_ver <= VERSION_MAX)) { \
|
||||
constexpr bool MinValid = VERSION_MIN == hos::Version_Min; \
|
||||
constexpr bool MaxValid = VERSION_MAX == hos::Version_Max; \
|
||||
if ((MinValid || VERSION_MIN <= fw_ver) && (MaxValid || fw_ver <= VERSION_MAX)) { \
|
||||
return ::ams::tipc::impl::InvokeServiceCommandImpl<TipcCommandId, &ImplType::NAME, ImplType>(impl, message_buffer); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -153,29 +153,14 @@ namespace ams {
|
||||
::ams::ExceptionHandler(&ams_ctx);
|
||||
}
|
||||
|
||||
inline NORETURN void AbortImpl() {
|
||||
/* Just perform a data abort. */
|
||||
register u64 addr __asm__("x27") = FatalErrorContext::StdAbortMagicAddress;
|
||||
register u64 val __asm__("x28") = FatalErrorContext::StdAbortMagicValue;
|
||||
while (true) {
|
||||
__asm__ __volatile__ (
|
||||
"str %[val], [%[addr]]"
|
||||
:
|
||||
: [val]"r"(val), [addr]"r"(addr)
|
||||
);
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
NORETURN void AbortImpl();
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* Redefine abort to trigger these handlers. */
|
||||
void abort();
|
||||
|
||||
/* Redefine C++ exception handlers. Requires wrap linker flag. */
|
||||
#define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); }
|
||||
#define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { ::ams::AbortImpl(); __builtin_unreachable(); }
|
||||
WRAP_ABORT_FUNC(__cxa_throw)
|
||||
WRAP_ABORT_FUNC(__cxa_rethrow)
|
||||
WRAP_ABORT_FUNC(__cxa_allocate_exception)
|
||||
@@ -195,9 +180,3 @@ extern "C" {
|
||||
#undef WRAP_ABORT_FUNC
|
||||
|
||||
}
|
||||
|
||||
/* Custom abort handler, so that std::abort will trigger these. */
|
||||
void abort() {
|
||||
ams::AbortImpl();
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
extern "C" void NORETURN __real_exit(int rc);
|
||||
|
||||
namespace ams {
|
||||
|
||||
WEAK_SYMBOL void *Malloc(size_t size) {
|
||||
@@ -37,13 +39,43 @@ namespace ams {
|
||||
return std::free(ptr);
|
||||
}
|
||||
|
||||
WEAK_SYMBOL void NORETURN Exit(int rc) {
|
||||
__real_exit(rc);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
NOINLINE NORETURN void AbortImpl() {
|
||||
/* Just perform a data abort. */
|
||||
register u64 addr __asm__("x27") = FatalErrorContext::StdAbortMagicAddress;
|
||||
register u64 val __asm__("x28") = FatalErrorContext::StdAbortMagicValue;
|
||||
while (true) {
|
||||
__asm__ __volatile__ (
|
||||
"str %[val], [%[addr]]"
|
||||
:
|
||||
: [val]"r"(val), [addr]"r"(addr)
|
||||
);
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* Redefine abort to trigger these handlers. */
|
||||
void abort();
|
||||
|
||||
/* Redefine C++ exception handlers. Requires wrap linker flag. */
|
||||
#define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { abort(); __builtin_unreachable(); }
|
||||
#define WRAP_ABORT_FUNC(func) void NORETURN __wrap_##func(void) { ::ams::AbortImpl(); __builtin_unreachable(); }
|
||||
WRAP_ABORT_FUNC(__cxa_pure_virtual)
|
||||
#undef WRAP_ABORT_FUNC
|
||||
|
||||
void NORETURN __wrap_exit(int rc) { ::ams::Exit(rc); __builtin_unreachable(); }
|
||||
|
||||
}
|
||||
|
||||
/* Custom abort handler, so that std::abort will trigger these. */
|
||||
void abort() {
|
||||
ams::AbortImpl();
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ namespace ams::erpt::srv {
|
||||
|
||||
class Allocator {
|
||||
public:
|
||||
void *operator new(size_t sz) { return lmem::AllocateFromExpHeap(g_heap_handle, sz); }
|
||||
void *operator new(size_t sz, size_t algn) { return lmem::AllocateFromExpHeap(g_heap_handle, sz, static_cast<s32>(algn)); }
|
||||
void *operator new[](size_t sz) { return lmem::AllocateFromExpHeap(g_heap_handle, sz); }
|
||||
void *operator new[](size_t sz, size_t algn) { return lmem::AllocateFromExpHeap(g_heap_handle, sz, static_cast<s32>(algn)); }
|
||||
void *operator new(size_t sz) noexcept { return lmem::AllocateFromExpHeap(g_heap_handle, sz); }
|
||||
void *operator new(size_t sz, size_t algn) noexcept { return lmem::AllocateFromExpHeap(g_heap_handle, sz, static_cast<s32>(algn)); }
|
||||
void *operator new[](size_t sz) noexcept { return lmem::AllocateFromExpHeap(g_heap_handle, sz); }
|
||||
void *operator new[](size_t sz, size_t algn) noexcept { return lmem::AllocateFromExpHeap(g_heap_handle, sz, static_cast<s32>(algn)); }
|
||||
|
||||
void operator delete(void *p) { lmem::FreeToExpHeap(g_heap_handle, p); }
|
||||
void operator delete[](void *p) { lmem::FreeToExpHeap(g_heap_handle, p); }
|
||||
void operator delete(void *p) noexcept { lmem::FreeToExpHeap(g_heap_handle, p); }
|
||||
void operator delete[](void *p) noexcept { lmem::FreeToExpHeap(g_heap_handle, p); }
|
||||
};
|
||||
|
||||
inline void *Allocate(size_t sz) {
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace ams::erpt::srv {
|
||||
} else {
|
||||
R_UNLESS(mode == StreamMode_Read, erpt::ResultInvalidArgument());
|
||||
|
||||
fs::OpenFile(std::addressof(this->file_handle), path, fs::OpenMode_Read);
|
||||
R_TRY(fs::OpenFile(std::addressof(this->file_handle), path, fs::OpenMode_Read));
|
||||
}
|
||||
auto file_guard = SCOPE_GUARD { fs::CloseFile(this->file_handle); };
|
||||
|
||||
|
||||
@@ -156,6 +156,14 @@ namespace ams::fs::impl {
|
||||
}
|
||||
}
|
||||
|
||||
template<> const char *IdString::ToString<fs::DirectoryEntryType>(fs::DirectoryEntryType type) {
|
||||
switch (type) {
|
||||
case fs::DirectoryEntryType_Directory: return "Directory";
|
||||
case fs::DirectoryEntryType_File: return "File";
|
||||
default: return ToValueString(static_cast<int>(type));
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class AccessLogPrinterCallbackManager {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "hos_version_api_private.hpp"
|
||||
#include "../os/impl/os_rng_manager.hpp"
|
||||
|
||||
namespace ams::os {
|
||||
|
||||
@@ -22,6 +23,15 @@ namespace ams::os {
|
||||
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* Provide libnx address space allocation shim. */
|
||||
uintptr_t __libnx_virtmem_rng(void) {
|
||||
return static_cast<uintptr_t>(::ams::os::impl::GetRngManager().GenerateRandomU64());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace ams::hos {
|
||||
|
||||
void InitializeForStratosphere() {
|
||||
|
||||
@@ -976,26 +976,35 @@ namespace ams::mem::impl::heap {
|
||||
return span;
|
||||
}
|
||||
} else {
|
||||
/* Save the extents of the free span we found. */
|
||||
auto * const prev_ptr = span->start.p;
|
||||
const size_t prev_pages = span->num_pages;
|
||||
|
||||
/* Allocate a new span struct. */
|
||||
Span *new_span = this->AllocateSpanStruct();
|
||||
if (new_span == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
auto new_span_guard = SCOPE_GUARD { this->FreeSpanToSpanPage(new_span); };
|
||||
|
||||
const size_t prev_pages = span->num_pages;
|
||||
span = GetSpanFromPointer(std::addressof(this->span_table), span->start.p);
|
||||
const size_t found_pages = span->num_pages;
|
||||
/* Allocating the new span potentially invalidates the span we were looking at, so find the span for it in the table. */
|
||||
span = GetSpanFromPointer(std::addressof(this->span_table), prev_ptr);
|
||||
const size_t cur_pages = span->num_pages;
|
||||
|
||||
|
||||
if (found_pages != prev_pages) {
|
||||
/* If the span was partially allocated, we need to find a new one that's big enough. */
|
||||
if (cur_pages != prev_pages) {
|
||||
span = this->SearchFreeSpan(num_pages);
|
||||
if (span == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_pages == prev_pages || num_pages != span->num_pages) {
|
||||
/* We're going to use the new span. */
|
||||
/* If the span is big enough to split (span->num_pages > num_pages), we want to split it. */
|
||||
/* span->num_pages > num_pages is true if the span wasn't partially allocated (cur_pages == prev_pages) */
|
||||
/* OR if the new free span we found has num_pages > num_pages. Note that we know span->num_pages >= num_pages */
|
||||
/* so this > condition can be expressed as span->num_pages != num_pages. */
|
||||
if (cur_pages == prev_pages || num_pages != span->num_pages) {
|
||||
/* We're going to use the new span for our split. */
|
||||
new_span_guard.Cancel();
|
||||
|
||||
return this->SplitSpan(span, num_pages, new_span);
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace ams::os::impl {
|
||||
class RngManager {
|
||||
private:
|
||||
util::TinyMT mt;
|
||||
os::Mutex lock;
|
||||
os::SdkMutex lock;
|
||||
bool initialized;
|
||||
private:
|
||||
void Initialize();
|
||||
public:
|
||||
constexpr RngManager() : mt(), lock(false), initialized() { /* ... */ }
|
||||
constexpr RngManager() : mt(), lock(), initialized() { /* ... */ }
|
||||
public:
|
||||
u64 GenerateRandomU64();
|
||||
};
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace ams::os {
|
||||
|
||||
namespace {
|
||||
|
||||
util::TinyMT g_random;
|
||||
os::Mutex g_random_mutex(false);
|
||||
bool g_initialized_random;
|
||||
constinit util::TinyMT g_random;
|
||||
constinit os::SdkMutex g_random_mutex;
|
||||
constinit bool g_initialized_random;
|
||||
|
||||
template<typename T>
|
||||
inline T GenerateRandomTImpl(T max) {
|
||||
|
||||
@@ -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 4
|
||||
|
||||
#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 3
|
||||
|
||||
@@ -60,8 +60,10 @@
|
||||
#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_12_0_3 ATMOSPHERE_TARGET_FIRMWARE(12, 0, 3)
|
||||
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_12_0_1
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_12_0_3
|
||||
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE(0, 0, 0)
|
||||
#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_CURRENT
|
||||
@@ -114,6 +116,8 @@ 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_12_0_3 = ATMOSPHERE_TARGET_FIRMWARE_12_0_3,
|
||||
|
||||
TargetFirmware_Current = ATMOSPHERE_TARGET_FIRMWARE_CURRENT,
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -136,8 +136,7 @@ _ZN3ams4kern10KScheduler12ScheduleImplEv:
|
||||
|
||||
/* Check if the highest priority thread is the same as the current thread. */
|
||||
ldr x7, [x1, #(KSCHEDULER_HIGHEST_PRIORITY_THREAD)]
|
||||
ldr x2, [x18]
|
||||
cmp x7, x2
|
||||
cmp x7, x18
|
||||
b.ne 1f
|
||||
|
||||
/* If they're the same, then we can just return as there's nothing to do. */
|
||||
|
||||
@@ -89,6 +89,8 @@ namespace ams::mitm::socket::resolver {
|
||||
|
||||
LogDebug("[%016lx]: GetHostByNameRequest(%s)\n", this->client_info.program_id.value, hostname);
|
||||
|
||||
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
ams::socket::InAddrT redirect_addr = {};
|
||||
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
@@ -107,6 +109,8 @@ 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::mitm::ResultShouldForwardToSession());
|
||||
|
||||
ams::socket::InAddrT redirect_addr = {};
|
||||
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
@@ -142,6 +146,8 @@ namespace ams::mitm::socket::resolver {
|
||||
|
||||
LogDebug("[%016lx]: GetHostByNameRequestWithOptions(%s)\n", this->client_info.program_id.value, hostname);
|
||||
|
||||
R_UNLESS(hostname != nullptr, sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
ams::socket::InAddrT redirect_addr = {};
|
||||
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
@@ -160,6 +166,8 @@ 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::mitm::ResultShouldForwardToSession());
|
||||
|
||||
ams::socket::InAddrT redirect_addr = {};
|
||||
R_UNLESS(GetRedirectedHostByName(std::addressof(redirect_addr), hostname), sm::mitm::ResultShouldForwardToSession());
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -367,7 +367,7 @@ namespace ams::sm::impl {
|
||||
{
|
||||
/* TODO: Convert mitm internal messaging to use tipc? */
|
||||
::Service srv { .session = service_info->mitm_query_h };
|
||||
R_TRY(::serviceDispatchInOut(std::addressof(srv), 65000, client_info, should_mitm));
|
||||
R_ABORT_UNLESS(::serviceDispatchInOut(std::addressof(srv), 65000, client_info, should_mitm));
|
||||
}
|
||||
|
||||
/* If we shouldn't mitm, give normal session. */
|
||||
@@ -383,8 +383,9 @@ namespace ams::sm::impl {
|
||||
auto fwd_guard = SCOPE_GUARD { R_ABORT_UNLESS(svc::CloseHandle(fwd_hnd)); };
|
||||
|
||||
/* Get the mitm handle. */
|
||||
/* This should be guaranteed to succeed, since we got a forward handle. */
|
||||
svc::Handle hnd;
|
||||
R_TRY(svc::ConnectToPort(std::addressof(hnd), service_info->mitm_port_h));
|
||||
R_ABORT_UNLESS(svc::ConnectToPort(std::addressof(hnd), service_info->mitm_port_h));
|
||||
|
||||
/* We got both handles, so we no longer need to clean up the forward handle. */
|
||||
fwd_guard.Cancel();
|
||||
@@ -410,9 +411,8 @@ namespace ams::sm::impl {
|
||||
MitmProcessInfo client_info;
|
||||
GetMitmProcessInfo(std::addressof(client_info), process_id);
|
||||
if (!IsMitmDisallowed(client_info.program_id)) {
|
||||
/* We're mitm'd. Assert, because mitm service host dead is an error state. */
|
||||
R_ABORT_UNLESS(GetMitmServiceHandleImpl(out, service_info, client_info));
|
||||
return ResultSuccess();
|
||||
/* Get a mitm service handle. */
|
||||
return GetMitmServiceHandleImpl(out, service_info, client_info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
extern "C" {
|
||||
extern u32 __start__;
|
||||
|
||||
extern int __system_argc;
|
||||
extern char** __system_argv;
|
||||
|
||||
u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
#define INNER_HEAP_SIZE 0x0
|
||||
@@ -26,6 +29,7 @@ extern "C" {
|
||||
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||
|
||||
void __libnx_initheap(void);
|
||||
void argvSetup(void);
|
||||
void __appInit(void);
|
||||
void __appExit(void);
|
||||
|
||||
@@ -39,10 +43,20 @@ extern "C" {
|
||||
void __libnx_free(void *mem);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
constinit char *g_empty_argv = nullptr;
|
||||
|
||||
}
|
||||
|
||||
namespace ams {
|
||||
|
||||
ncm::ProgramId CurrentProgramId = ncm::SystemProgramId::Sm;
|
||||
|
||||
void NORETURN Exit(int rc) {
|
||||
AMS_ABORT("Exit called by immortal process");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace ams;
|
||||
@@ -64,6 +78,12 @@ void __libnx_initheap(void) {
|
||||
fake_heap_end = (char*)addr + size;
|
||||
}
|
||||
|
||||
void argvSetup(void) {
|
||||
/* We don't need argc/argv, so set them to empty defaults. */
|
||||
__system_argc = 0;
|
||||
__system_argv = std::addressof(g_empty_argv);
|
||||
}
|
||||
|
||||
void __appInit(void) {
|
||||
hos::InitializeForStratosphere();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user