From 9a41e19004b9abe54a996d784d62bb043df0df6f Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 25 Oct 2020 21:57:37 -0700 Subject: [PATCH] sdmmc: fix speed mode extension, add CheckMmcConnection for debug --- exosphere/sdmmc_test/source/sdmmc_test_main.cpp | 12 +++++++++++- .../libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp | 1 + .../source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp | 2 +- libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp | 4 ++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/exosphere/sdmmc_test/source/sdmmc_test_main.cpp b/exosphere/sdmmc_test/source/sdmmc_test_main.cpp index e03e672d5..f9d7fe092 100644 --- a/exosphere/sdmmc_test/source/sdmmc_test_main.cpp +++ b/exosphere/sdmmc_test/source/sdmmc_test_main.cpp @@ -73,8 +73,18 @@ namespace ams::sdmmc_test { DEBUG[0] = 5; CheckResult(result); + /* Get the connection status. */ + sdmmc::SpeedMode speed_mode; + sdmmc::BusWidth bus_width; + result = sdmmc::CheckMmcConnection(std::addressof(speed_mode), std::addressof(bus_width), Port); + + /* Save status for debug. */ + DEBUG[0] = 6; + DEBUG[1] = result.GetValue(); + DEBUG[2] = static_cast(speed_mode); + DEBUG[3] = static_cast(bus_width); + /* Perform a reboot. */ - DEBUG[1] = 0; PmcMainReboot(); } diff --git a/libraries/libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp b/libraries/libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp index d6bab0111..39d9e7390 100644 --- a/libraries/libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp +++ b/libraries/libvapours/include/vapours/sdmmc/sdmmc_mmc.hpp @@ -38,5 +38,6 @@ namespace ams::sdmmc { Result GetMmcBootPartitionCapacity(u32 *out_num_sectors, Port port); Result GetMmcExtendedCsd(void *out_buffer, size_t buffer_size, Port port); + Result CheckMmcConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port); } \ No newline at end of file diff --git a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp index 5fd211d70..7350bde28 100644 --- a/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp +++ b/libraries/libvapours/source/sdmmc/impl/sdmmc_mmc_device_accessor.cpp @@ -65,7 +65,7 @@ namespace ams::sdmmc::impl { return (ext_csd[163] & (1u << 1)) != 0; } - constexpr bool GetDeviceType(const u8 *ext_csd) { + constexpr u8 GetDeviceType(const u8 *ext_csd) { /* Get the DEVICE_TYPE register. */ AMS_ABORT_UNLESS(ext_csd != nullptr); return ext_csd[196]; diff --git a/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp b/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp index e19183fec..7f671bcd2 100644 --- a/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp +++ b/libraries/libvapours/source/sdmmc/sdmmc_mmc.cpp @@ -66,4 +66,8 @@ namespace ams::sdmmc { return GetMmcDeviceAccessor(port)->GetMmcExtendedCsd(out_buffer, buffer_size); } + Result CheckMmcConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width, Port port) { + return GetMmcDeviceAccessor(port)->CheckConnection(out_speed_mode, out_bus_width); + } + }