erpt: GetMmcErrorInfo, GetSdCard*Info

This commit is contained in:
Michael Scire
2023-10-25 12:41:18 -07:00
parent fa384fd920
commit 60974a5f4e
10 changed files with 472 additions and 10 deletions

View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/fat/fat_file_system.hpp>

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::fat {
constexpr inline size_t FatErrorNameMaxLength = 0x10;
struct FatError {
int error;
int extra_error;
int device_id;
char name[FatErrorNameMaxLength];
u8 reserved[4];
};
static_assert(sizeof(FatError) == 0x20);
static_assert(util::is_pod<FatError>::value);
struct FatReportInfo1 {
u16 file_peak_open_count;
u16 directory_peak_open_count;
};
static_assert(sizeof(FatReportInfo1) == 4);
static_assert(util::is_pod<FatReportInfo1>::value);
struct FatReportInfo2 {
u16 unique_file_entry_peak_open_count;
u16 unique_directory_entry_peak_open_count;
};
static_assert(sizeof(FatReportInfo2) == 4);
static_assert(util::is_pod<FatReportInfo2>::value);
struct FatSafeInfo {
u32 result;
u32 error_number;
u32 safe_error_number;
};
static_assert(sizeof(FatSafeInfo) == 12);
static_assert(util::is_pod<FatSafeInfo>::value);
}

View File

@@ -51,6 +51,7 @@
#include <stratosphere/fs/fs_code.hpp>
#include <stratosphere/fs/fs_content.hpp>
#include <stratosphere/fs/fs_content_storage.hpp>
#include <stratosphere/fs/fs_error_info.hpp>
#include <stratosphere/fs/fs_game_card.hpp>
#include <stratosphere/fs/fs_host.hpp>
#include <stratosphere/fs/fs_image_directory.hpp>

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fat/fat_file_system.hpp>
namespace ams::fs {
struct StorageErrorInfo {
u32 num_activation_failures;
u32 num_activation_error_corrections;
u32 num_read_write_failures;
u32 num_read_write_error_corrections;
};
static_assert(sizeof(StorageErrorInfo) == 0x10);
static_assert(util::is_pod<StorageErrorInfo>::value);
struct FileSystemProxyErrorInfo {
u32 rom_fs_remont_for_data_corruption_count;
u32 rom_fs_unrecoverable_data_corruption_by_remount_count;
fat::FatError fat_fs_error;
u32 rom_fs_recovered_by_invalidate_cache_count;
u32 save_data_index_count;
fat::FatReportInfo1 bis_system_report1;
fat::FatReportInfo1 bis_user_report1;
fat::FatReportInfo1 sd_card_report1;
fat::FatReportInfo2 bis_system_report2;
fat::FatReportInfo2 bis_user_report2;
fat::FatReportInfo2 sd_card_report2;
u32 rom_fs_deep_retry_start_count;
u32 rom_fs_unrecoverable_by_game_card_access_failed_count;
fat::FatSafeInfo bis_system_fat_safe_info;
fat::FatSafeInfo bis_user_fat_safe_info;
u8 reserved[0x18];
};
static_assert(sizeof(FileSystemProxyErrorInfo) == 0x80);
static_assert(util::is_pod<FileSystemProxyErrorInfo>::value);
Result GetAndClearMmcErrorInfo(StorageErrorInfo *out_sei, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size);
Result GetAndClearSdCardErrorInfo(StorageErrorInfo *out_sei, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size);
Result GetAndClearFileSystemProxyErrorInfo(FileSystemProxyErrorInfo *out);
}

View File

@@ -21,12 +21,38 @@ namespace ams::fs {
/* ACCURATE_TO_VERSION: Unknown */
class IEventNotifier;
constexpr inline size_t SdCardCidSize = 0x10;
enum SdCardSpeedMode {
SdCardSpeedMode_Identification = 0,
SdCardSpeedMode_DefaultSpeed = 1,
SdCardSpeedMode_HighSpeed = 2,
SdCardSpeedMode_Sdr12 = 3,
SdCardSpeedMode_Sdr25 = 4,
SdCardSpeedMode_Sdr50 = 5,
SdCardSpeedMode_Sdr104 = 6,
SdCardSpeedMode_Ddr50 = 7,
SdCardSpeedMode_Unknown = 8,
};
struct EncryptionSeed {
char value[0x10];
};
static_assert(util::is_pod<EncryptionSeed>::value);
static_assert(sizeof(EncryptionSeed) == 0x10);
Result GetSdCardCid(void *dst, size_t size);
inline void ClearSdCardCidSerialNumber(u8 *cid) {
/* Clear the serial number from the cid. */
std::memset(cid + 2, 0, 4);
}
Result GetSdCardUserAreaSize(s64 *out);
Result GetSdCardProtectedAreaSize(s64 *out);
Result GetSdCardSpeedMode(SdCardSpeedMode *out);
Result MountSdCard(const char *name);
Result MountSdCardErrorReportDirectoryForAtmosphere(const char *name);

View File

@@ -16,16 +16,23 @@
#pragma once
#include <vapours.hpp>
#include <stratosphere/sf.hpp>
#include <stratosphere/fs/fs_error_info.hpp>
/* TODO */
/* ACCURATE_TO_VERSION: 13.4.0.0 */
#define AMS_FSSRV_I_DEVICE_OPERATOR_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, IsSdCardInserted, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 100, Result, GetMmcCid, (ams::sf::OutBuffer out, s64 size), (out, size)) \
AMS_SF_METHOD_INFO(C, H, 101, Result, GetMmcSpeedMode, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 112, Result, GetMmcPatrolCount, (ams::sf::Out<u32> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 114, Result, GetMmcExtendedCsd, (ams::sf::OutBuffer out, s64 size), (out, size)) \
AMS_SF_METHOD_INFO(C, H, 200, Result, IsGameCardInserted, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 202, Result, GetGameCardHandle, (ams::sf::Out<u32> out), (out))
AMS_SF_METHOD_INFO(C, H, 0, Result, IsSdCardInserted, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetSdCardSpeedMode, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GetSdCardCid, (ams::sf::OutBuffer out, s64 size), (out, size)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetSdCardUserAreaSize, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GetSdCardProtectedAreaSize, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetAndClearSdCardErrorInfo, (ams::sf::Out<fs::StorageErrorInfo> out_sei, ams::sf::Out<s64> out_size, ams::sf::OutBuffer out_buf, s64 size), (out_sei, out_size, out_buf, size)) \
AMS_SF_METHOD_INFO(C, H, 100, Result, GetMmcCid, (ams::sf::OutBuffer out, s64 size), (out, size)) \
AMS_SF_METHOD_INFO(C, H, 101, Result, GetMmcSpeedMode, (ams::sf::Out<s64> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 112, Result, GetMmcPatrolCount, (ams::sf::Out<u32> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 113, Result, GetAndClearMmcErrorInfo, (ams::sf::Out<fs::StorageErrorInfo> out_sei, ams::sf::Out<s64> out_size, ams::sf::OutBuffer out_buf, s64 size), (out_sei, out_size, out_buf, size)) \
AMS_SF_METHOD_INFO(C, H, 114, Result, GetMmcExtendedCsd, (ams::sf::OutBuffer out, s64 size), (out, size)) \
AMS_SF_METHOD_INFO(C, H, 200, Result, IsGameCardInserted, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 202, Result, GetGameCardHandle, (ams::sf::Out<u32> out), (out))
AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IDeviceOperator, AMS_FSSRV_I_DEVICE_OPERATOR_INTERFACE_INFO, 0x1484E21C)