ams: use R_SUCCEED, R_THROW globally

This commit is contained in:
Michael Scire 2022-03-26 00:14:36 -07:00
parent e5b1739f65
commit dd78ede99f
370 changed files with 2107 additions and 2107 deletions

View file

@ -60,7 +60,7 @@ namespace ams::sdmmc::impl {
m_memory_capacity = (c_size + 1) << ((read_bl_len + c_size_mult + 2) - 9);
m_is_valid_memory_capacity = true;
return ResultSuccess();
R_SUCCEED();
}
Result BaseDevice::CheckDeviceStatus(u32 r1_resp) const {
@ -94,7 +94,7 @@ namespace ams::sdmmc::impl {
#undef AMS_SDMMC_CHECK_DEVICE_STATUS_ERROR
return ResultSuccess();
R_SUCCEED();
}
DeviceState BaseDevice::GetDeviceState(u32 r1_resp) const {
@ -125,7 +125,7 @@ namespace ams::sdmmc::impl {
R_UNLESS(m_base_device->GetDeviceState(*out_response) == expected_state, sdmmc::ResultUnexpectedDeviceState());
}
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::IssueCommandGoIdleState() const {
@ -146,7 +146,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(dst_size >= DeviceCidSize);
m_host_controller->GetLastResponse(static_cast<u32 *>(dst), DeviceCidSize, CommandResponseType);
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::IssueCommandSelectCard() const {
@ -174,7 +174,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(dst_size >= DeviceCsdSize);
m_host_controller->GetLastResponse(static_cast<u32 *>(dst), DeviceCsdSize, CommandResponseType);
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::IssueCommandSendStatus(u32 *out_device_status, u32 status_ignore_mask) const {
@ -260,7 +260,7 @@ namespace ams::sdmmc::impl {
/* Check the device status. */
R_TRY(m_base_device->CheckDeviceStatus(st_resp & ~status_ignore_mask));
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::ReadWriteSingle(u32 *out_num_transferred_blocks, u32 sector_index, u32 num_sectors, void *buf, bool is_read) const {
@ -281,7 +281,7 @@ namespace ams::sdmmc::impl {
u32 device_status;
R_TRY(this->IssueCommandSendStatus(std::addressof(device_status), status_ignore_mask));
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::ReadWriteMultiple(u32 sector_index, u32 num_sectors, u32 sector_index_alignment, void *buf, size_t buf_size, bool is_read) {
@ -357,7 +357,7 @@ namespace ams::sdmmc::impl {
cur_buf += num_transferred_blocks * SectorSize;
}
return ResultSuccess();
R_SUCCEED();
}
#if defined(AMS_SDMMC_USE_DEVICE_VIRTUAL_ADDRESS)
@ -399,7 +399,7 @@ namespace ams::sdmmc::impl {
activate_guard.Cancel();
m_base_device->SetActive();
return ResultSuccess();
R_SUCCEED();
}
void BaseDeviceAccessor::Deactivate() {
@ -428,7 +428,7 @@ namespace ams::sdmmc::impl {
/* We successfully performed the read/write. */
rw_guard.Cancel();
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::CheckConnection(SpeedMode *out_speed_mode, BusWidth *out_bus_width) {
@ -446,7 +446,7 @@ namespace ams::sdmmc::impl {
/* Verify that we can get the status. */
R_TRY(m_host_controller->GetInternalStatus());
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetMemoryCapacity(u32 *out_sectors) const {
@ -461,7 +461,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(out_sectors != nullptr);
*out_sectors = m_base_device->GetMemoryCapacity();
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetDeviceStatus(u32 *out) const {
@ -475,7 +475,7 @@ namespace ams::sdmmc::impl {
/* Get the status. */
R_TRY(this->IssueCommandSendStatus(out, 0));
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetOcr(u32 *out) const {
@ -490,7 +490,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(out != nullptr);
*out = m_base_device->GetOcr();
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetRca(u16 *out) const {
@ -505,7 +505,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(out != nullptr);
*out = m_base_device->GetRca();
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetCid(void *out, size_t size) const {
@ -519,7 +519,7 @@ namespace ams::sdmmc::impl {
/* Get the cid. */
m_base_device->GetCid(out, size);
return ResultSuccess();
R_SUCCEED();
}
Result BaseDeviceAccessor::GetCsd(void *out, size_t size) const {
@ -533,7 +533,7 @@ namespace ams::sdmmc::impl {
/* Get the csd. */
m_base_device->GetCsd(out, size);
return ResultSuccess();
R_SUCCEED();
}
void BaseDeviceAccessor::GetAndClearErrorInfo(ErrorInfo *out_error_info, size_t *out_log_size, char *out_log_buffer, size_t log_buffer_size) {

View file

@ -306,7 +306,7 @@ namespace ams::sdmmc::impl {
R_UNLESS(!this->IsRemoved(), sdmmc::ResultDeviceRemoved());
#endif
return ResultSuccess();
R_SUCCEED();
}
Result CheckAccessible() const {
@ -319,7 +319,7 @@ namespace ams::sdmmc::impl {
/* Check removed. */
R_TRY(this->CheckRemoved());
return ResultSuccess();
R_SUCCEED();
}
void SetHighCapacity(bool en) {

View file

@ -96,25 +96,25 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_gc_asic_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::IssueCommandFinishOperation() const {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_GcAsicFinishOperation, 0, true, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::IssueCommandSleep() {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_GcAsicSleep, 0, true, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::IssueCommandUpdateKey() const {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_GcAsicUpdateKey, 0, true, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::StartupGcAsicDevice() {
@ -136,7 +136,7 @@ namespace ams::sdmmc::impl {
/* Enable power saving. */
hc->SetPowerSaving(true);
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::OnActivate() {
@ -148,7 +148,7 @@ namespace ams::sdmmc::impl {
/* We started up, so we don't need to power down. */
power_guard.Cancel();
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::OnReadWrite(u32 sector_index, u32 num_sectors, void *buf, size_t buf_size, bool is_read) {
@ -165,7 +165,7 @@ namespace ams::sdmmc::impl {
/* Require that we read/wrote as many sectors as we expected. */
AMS_ABORT_UNLESS(num_transferred_blocks == num_sectors);
return ResultSuccess();
R_SUCCEED();
}
void GcAsicDeviceAccessor::Initialize() {
@ -229,7 +229,7 @@ namespace ams::sdmmc::impl {
R_TRY(m_gc_asic_device.CheckAccessible());
*out_speed_mode = SpeedMode_GcAsicSpeed;
return ResultSuccess();
R_SUCCEED();
}
void GcAsicDeviceAccessor::PutGcAsicToSleep() {
@ -275,7 +275,7 @@ namespace ams::sdmmc::impl {
R_TRY(BaseDeviceAccessor::GetHostController()->Awaken());
}
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::WriteGcAsicOperation(const void *op_buf, size_t op_buf_size) {
@ -289,7 +289,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandWriteOperation(op_buf, op_buf_size));
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::FinishGcAsicOperation() {
@ -303,7 +303,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandFinishOperation());
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::AbortGcAsicOperation() {
@ -318,7 +318,7 @@ namespace ams::sdmmc::impl {
R_TRY(BaseDeviceAccessor::GetHostController()->IssueStopTransmissionCommand(std::addressof(resp)));
R_TRY(m_gc_asic_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::SleepGcAsic() {
@ -332,7 +332,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSleep());
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result GcAsicDeviceAccessor::UpdateGcAsicKey() {
@ -346,7 +346,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandUpdateKey());
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
}

View file

@ -339,14 +339,14 @@ namespace ams::sdmmc::impl {
/* TODO: A way for this to be non-fatal? */
AMS_ABORT_UNLESS(max7762x::SetVoltageEnabled(en));
return ResultSuccess();
R_SUCCEED();
}
Result SetSdCardVoltageValue(u32 micro_volts) {
/* TODO: A way for this to be non-fatal? */
AMS_ABORT_UNLESS(max7762x::SetVoltageValue(micro_volts));
return ResultSuccess();
R_SUCCEED();
}
namespace gpio_impl {

View file

@ -113,10 +113,10 @@ namespace ams::sdmmc::impl {
case 1: *out = SpeedMode_MmcHighSpeed; break;
case 2: *out = SpeedMode_MmcHs200; break;
case 3: *out = SpeedMode_MmcHs400; break;
default: return sdmmc::ResultUnexpectedMmcExtendedCsdValue();
default: R_THROW(sdmmc::ResultUnexpectedMmcExtendedCsdValue());
}
return ResultSuccess();
R_SUCCEED();
}
}
@ -147,7 +147,7 @@ namespace ams::sdmmc::impl {
/* Get the response. */
hc->GetLastResponse(out_ocr, sizeof(*out_ocr), CommandResponseType);
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandSetRelativeAddr() const {
@ -159,7 +159,7 @@ namespace ams::sdmmc::impl {
const u32 arg = rca << 16;
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_SetRelativeAddr, arg, false, DeviceState_Unknown));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandSwitch(CommandSwitch cs) const {
@ -169,7 +169,7 @@ namespace ams::sdmmc::impl {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_Switch, arg, true, DeviceState_Unknown));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandSendExtCsd(void *dst, size_t dst_size) const {
@ -189,7 +189,7 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_mmc_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandEraseGroupStart(u32 sector_index) const {
@ -199,7 +199,7 @@ namespace ams::sdmmc::impl {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_EraseGroupStart, arg, false, DeviceState_Unknown));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandEraseGroupEnd(u32 sector_index) const {
@ -209,14 +209,14 @@ namespace ams::sdmmc::impl {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_EraseGroupEnd, arg, false, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::IssueCommandErase() const {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_Erase, 0, false, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::CancelToshibaMmcModel() {
@ -232,7 +232,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSwitch(CommandSwitch_WriteProductionStateAwarenessNormal));
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::ChangeToReadyState(BusPower bus_power) {
@ -244,7 +244,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSendOpCond(std::addressof(ocr), bus_power));
if ((ocr & OcrCardPowerUpStatus) != 0) {
m_mmc_device.SetOcrAndHighCapacity(ocr);
return ResultSuccess();
R_SUCCEED();
}
/* Check if we've timed out. */
@ -271,7 +271,7 @@ namespace ams::sdmmc::impl {
cs = CommandSwitch_WriteBusWidth4Bit;
} else {
/* Target bus width is 1bit. */
return ResultSuccess();
R_SUCCEED();
}
/* Set the bus width. */
@ -279,7 +279,7 @@ namespace ams::sdmmc::impl {
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
hc->SetBusWidth(target_bw);
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::EnableBkopsAuto() {
@ -287,7 +287,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSwitch(CommandSwitch_SetBitsBkopsEnAutoEn));
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::ChangeToHighSpeed(bool check_before) {
@ -307,7 +307,7 @@ namespace ams::sdmmc::impl {
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
}
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::ChangeToHs200() {
@ -324,7 +324,7 @@ namespace ams::sdmmc::impl {
/* Check status. */
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::ChangeToHs400() {
@ -348,7 +348,7 @@ namespace ams::sdmmc::impl {
/* Check status. */
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::ExtendBusSpeed(u8 device_type, SpeedMode max_sm) {
@ -369,7 +369,7 @@ namespace ams::sdmmc::impl {
}
/* We can't, so stay at normal speeds. */
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::StartupMmcDevice(BusWidth max_bw, SpeedMode max_sm, void *wb, size_t wb_size) {
@ -418,7 +418,7 @@ namespace ams::sdmmc::impl {
R_TRY(m_mmc_device.SetLegacyMemoryCapacity());
m_mmc_device.SetActive();
return ResultSuccess();
R_SUCCEED();
}
/* Extend the bus width to the largest that we can. */
@ -442,7 +442,7 @@ namespace ams::sdmmc::impl {
/* Enable power saving. */
hc->SetPowerSaving(true);
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::OnActivate() {
@ -479,7 +479,7 @@ namespace ams::sdmmc::impl {
BaseDeviceAccessor::IncrementNumActivationErrorCorrections();
}
return ResultSuccess();
R_SUCCEED();
}
/* Log that our startup failed. */
@ -519,7 +519,7 @@ namespace ams::sdmmc::impl {
return result;
}
return ResultSuccess();
R_SUCCEED();
}
void MmcDeviceAccessor::Initialize() {
@ -564,7 +564,7 @@ namespace ams::sdmmc::impl {
R_TRY(GetMmcExtendedCsd(m_work_buffer, m_work_buffer_size));
R_TRY(GetCurrentSpeedModeFromExtCsd(out_speed_mode, static_cast<const u8 *>(m_work_buffer)));
return ResultSuccess();
R_SUCCEED();
}
void MmcDeviceAccessor::PutMmcToSleep() {
@ -630,7 +630,7 @@ namespace ams::sdmmc::impl {
}
m_current_partition = part;
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::EraseMmc() {
@ -693,7 +693,7 @@ namespace ams::sdmmc::impl {
}
}
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::GetMmcBootPartitionCapacity(u32 *out_num_sectors) const {
@ -702,7 +702,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->GetMmcExtendedCsd(m_work_buffer, m_work_buffer_size));
*out_num_sectors = GetBootPartitionMemoryCapacityFromExtCsd(static_cast<const u8 *>(m_work_buffer));
return ResultSuccess();
R_SUCCEED();
}
Result MmcDeviceAccessor::GetMmcExtendedCsd(void *dst, size_t dst_size) const {
@ -722,7 +722,7 @@ namespace ams::sdmmc::impl {
/* Get the ext csd. */
R_TRY(this->IssueCommandSendExtCsd(dst, dst_size));
return ResultSuccess();
R_SUCCEED();
}
}

View file

@ -149,10 +149,10 @@ namespace ams::sdmmc::impl {
*out_sm = SpeedMode_SdCardDdr50;
break;
default:
return sdmmc::ResultUnexpectedSdCardSwitchFunctionStatus();
R_THROW(sdmmc::ResultUnexpectedSdCardSwitchFunctionStatus());
}
return ResultSuccess();
R_SUCCEED();
}
}
@ -193,7 +193,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(out_rca != nullptr);
*out_rca = static_cast<u16>(resp >> 16);
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSendIfCond() const {
@ -214,7 +214,7 @@ namespace ams::sdmmc::impl {
/* Verify that our argument was returned to us. */
R_UNLESS((resp & SendIfCommandArgumentMask) == (SendIfCommandArgument & SendIfCommandArgumentMask), sdmmc::ResultSdCardValidationError());
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandCheckSupportedFunction(void *dst, size_t dst_size) const {
@ -237,7 +237,7 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_sd_card_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSwitchAccessMode(void *dst, size_t dst_size, bool set_function, SwitchFunctionAccessMode access_mode) const {
@ -260,13 +260,13 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_sd_card_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandVoltageSwitch() const {
/* Issue the command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(CommandIndex_VoltageSwitch, 0, false, DeviceState_Ready));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandAppCmd(DeviceState expected_state, u32 ignore_mask) const {
@ -299,14 +299,14 @@ namespace ams::sdmmc::impl {
R_UNLESS(m_sd_card_device.GetDeviceState(resp) == expected_state, sdmmc::ResultUnexpectedDeviceState());
}
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSetBusWidth4Bit() const {
/* Issue the application command. */
constexpr u32 Arg = 0x2;
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(SdApplicationCommandIndex_SetBusWidth, Arg, false, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSdStatus(void *dst, size_t dst_size) const {
@ -326,7 +326,7 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_sd_card_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSendOpCond(u32 *out_ocr, bool spec_under_2, bool uhs_i_supported) const {
@ -342,13 +342,13 @@ namespace ams::sdmmc::impl {
/* Get the response. */
hc->GetLastResponse(out_ocr, sizeof(u32), CommandResponseType);
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandClearCardDetect() const {
/* Issue the application command. */
R_TRY(BaseDeviceAccessor::IssueCommandAndCheckR1(SdApplicationCommandIndex_SetClearCardDetect, 0, false, DeviceState_Tran));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::IssueCommandSendScr(void *dst, size_t dst_size) const {
@ -368,7 +368,7 @@ namespace ams::sdmmc::impl {
hc->GetLastResponse(std::addressof(resp), sizeof(resp), CommandResponseType);
R_TRY(m_sd_card_device.CheckDeviceStatus(resp));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::EnterUhsIMode() {
@ -378,7 +378,7 @@ namespace ams::sdmmc::impl {
/* Switch to sdr12. */
R_TRY(BaseDeviceAccessor::GetHostController()->SwitchToSdr12());
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::ChangeToReadyState(bool spec_under_2, bool uhs_i_supported) {
@ -406,7 +406,7 @@ namespace ams::sdmmc::impl {
m_sd_card_device.SetUhsIMode(true);
}
return ResultSuccess();
R_SUCCEED();
}
/* Check if we've timed out. */
@ -426,7 +426,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSendRelativeAddr(std::addressof(rca)));
if (rca != 0) {
m_sd_card_device.SetRca(rca);
return ResultSuccess();
R_SUCCEED();
}
/* Check if we've timed out. */
@ -442,7 +442,7 @@ namespace ams::sdmmc::impl {
m_sd_card_device.SetMemoryCapacity(GetMemoryCapacityFromCsd(static_cast<const u16 *>(csd)));
}
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetScr(void *dst, size_t dst_size) const {
@ -450,7 +450,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandAppCmd(DeviceState_Tran));
R_TRY(this->IssueCommandSendScr(dst, dst_size));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::ExtendBusWidth(BusWidth max_bw, u8 sd_bw) {
@ -471,7 +471,7 @@ namespace ams::sdmmc::impl {
/* Set the host controller's bus width. */
hc->SetBusWidth(BusWidth_4Bit);
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::SwitchAccessMode(SwitchFunctionAccessMode access_mode, void *wb, size_t wb_size) {
@ -487,7 +487,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSwitchAccessMode(wb, wb_size, true, access_mode));
R_UNLESS(IsAccessModeInFunctionSelection(static_cast<const u8 *>(wb), access_mode), sdmmc::ResultSdCardFailedSwitchAccessMode());
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::ExtendBusSpeedAtUhsIMode(SpeedMode max_sm, void *wb, size_t wb_size) {
@ -506,7 +506,7 @@ namespace ams::sdmmc::impl {
target_am = SwitchFunctionAccessMode_Sdr50;
target_sm = SpeedMode_SdCardSdr50;
} else {
return sdmmc::ResultSdCardNotSupportSdr104AndSdr50();
R_THROW(sdmmc::ResultSdCardNotSupportSdr104AndSdr50());
}
/* Switch the access mode. */
@ -519,7 +519,7 @@ namespace ams::sdmmc::impl {
/* Check status. */
R_TRY(BaseDeviceAccessor::IssueCommandSendStatus());
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::ExtendBusSpeedAtNonUhsIMode(SpeedMode max_sm, bool spec_under_1_1, void *wb, size_t wb_size) {
@ -542,7 +542,7 @@ namespace ams::sdmmc::impl {
/* Set the host controller speed mode. */
R_TRY(BaseDeviceAccessor::GetHostController()->SetSpeedMode(SpeedMode_SdCardHighSpeed));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetSdStatus(void *dst, size_t dst_size) const {
@ -550,7 +550,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandAppCmd(DeviceState_Tran));
R_TRY(this->IssueCommandSdStatus(dst, dst_size));
return ResultSuccess();
R_SUCCEED();
}
void SdCardDeviceAccessor::TryDisconnectDat3PullUpResistor() const {
@ -637,7 +637,7 @@ namespace ams::sdmmc::impl {
/* Enable power saving. */
hc->SetPowerSaving(true);
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::OnActivate() {
@ -679,7 +679,7 @@ namespace ams::sdmmc::impl {
BaseDeviceAccessor::IncrementNumActivationErrorCorrections();
}
return ResultSuccess();
R_SUCCEED();
}
/* Check if we were removed. */
@ -740,7 +740,7 @@ namespace ams::sdmmc::impl {
return result;
}
return ResultSuccess();
R_SUCCEED();
}
void SdCardDeviceAccessor::Initialize() {
@ -842,14 +842,14 @@ namespace ams::sdmmc::impl {
R_TRY(this->GetScr(m_work_buffer, m_work_buffer_size));
if (IsLessThanSpecification1_1(static_cast<const u8 *>(m_work_buffer))) {
*out_speed_mode = SpeedMode_SdCardDefaultSpeed;
return ResultSuccess();
R_SUCCEED();
}
/* Get the current speed mode. */
R_TRY(this->IssueCommandCheckSupportedFunction(m_work_buffer, m_work_buffer_size));
R_TRY(GetCurrentSpeedMode(out_speed_mode, static_cast<const u8 *>(m_work_buffer), m_sd_card_device.IsUhsIMode()));
return ResultSuccess();
R_SUCCEED();
}
void SdCardDeviceAccessor::PutSdCardToSleep() {
@ -928,7 +928,7 @@ namespace ams::sdmmc::impl {
/* Get the SCR. */
R_TRY(this->GetScr(dst, dst_size));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetSdCardSwitchFunctionStatus(void *dst, size_t dst_size, SdCardSwitchFunction switch_function) const {
@ -959,7 +959,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->IssueCommandSwitchAccessMode(dst, dst_size, false, am));
}
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetSdCardCurrentConsumption(u16 *out_current_consumption, SpeedMode speed_mode) const {
@ -1004,7 +1004,7 @@ namespace ams::sdmmc::impl {
AMS_ABORT_UNLESS(out_current_consumption != nullptr);
*out_current_consumption = GetMaximumCurrentConsumption(static_cast<const u8 *>(m_work_buffer));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetSdCardSdStatus(void *dst, size_t dst_size) const {
@ -1017,7 +1017,7 @@ namespace ams::sdmmc::impl {
/* Get the status. */
R_TRY(this->GetSdStatus(dst, dst_size));
return ResultSuccess();
R_SUCCEED();
}
Result SdCardDeviceAccessor::GetSdCardProtectedAreaCapacity(u32 *out_num_sectors) const {
@ -1047,7 +1047,7 @@ namespace ams::sdmmc::impl {
*out_num_sectors = size_of_protected_area / SectorSize;
}
return ResultSuccess();
R_SUCCEED();
}

View file

@ -106,7 +106,7 @@ namespace ams::sdmmc::impl {
/* Configure timeout control to use the maximum timeout value (TMCLK * 2^27) */
reg::ReadWrite(m_registers->timeout_control, SD_REG_BITS_VALUE(TIMEOUT_CONTROL_DATA_TIMEOUT_COUNTER, 0b1110));
return ResultSuccess();
R_SUCCEED();
}
void SdHostStandardController::SetBusPower(BusPower bus_power) {
@ -176,13 +176,13 @@ namespace ams::sdmmc::impl {
os::MultiWaitHolderType *signaled_holder = os::TimedWaitAny(std::addressof(m_multi_wait), TimeSpan::FromMilliSeconds(timeout_ms));
if (signaled_holder == std::addressof(m_interrupt_event_holder)) {
/* We received the interrupt. */
return ResultSuccess();
R_SUCCEED();
} else if (signaled_holder == std::addressof(m_removed_event_holder)) {
/* The device was removed. */
return sdmmc::ResultDeviceRemoved();
R_THROW(sdmmc::ResultDeviceRemoved());
} else {
/* Timeout occurred. */
return sdmmc::ResultWaitInterruptSoftwareTimeout();
R_THROW(sdmmc::ResultWaitInterruptSoftwareTimeout());
}
}
@ -338,17 +338,17 @@ namespace ams::sdmmc::impl {
/* Otherwise, check if we've timed out. */
if (!timer.Update()) {
return sdmmc::ResultAbortTransactionSoftwareTimeout();
R_THROW(sdmmc::ResultAbortTransactionSoftwareTimeout());
}
}
}
return ResultSuccess();
R_SUCCEED();
}
Result SdHostStandardController::AbortTransaction() {
R_TRY(this->ResetCmdDatLine());
return ResultSuccess();
R_SUCCEED();
}
Result SdHostStandardController::WaitWhileCommandInhibit(bool has_dat) {
@ -370,7 +370,7 @@ namespace ams::sdmmc::impl {
/* Otherwise, check if we've timed out. */
if (!timer.Update()) {
this->AbortTransaction();
return sdmmc::ResultCommandInhibitCmdSoftwareTimeout();
R_THROW(sdmmc::ResultCommandInhibitCmdSoftwareTimeout());
}
}
}
@ -390,12 +390,12 @@ namespace ams::sdmmc::impl {
/* Otherwise, check if we've timed out. */
if (!timer.Update()) {
this->AbortTransaction();
return sdmmc::ResultCommandInhibitDatSoftwareTimeout();
R_THROW(sdmmc::ResultCommandInhibitDatSoftwareTimeout());
}
}
}
return ResultSuccess();
R_SUCCEED();
}
Result SdHostStandardController::CheckAndClearInterruptStatus(volatile u16 *out_normal_int_status, u16 wait_mask) {
@ -417,7 +417,7 @@ namespace ams::sdmmc::impl {
/* Write the masked value to the status register to ensure consistent state. */
reg::Write(m_registers->normal_int_status, masked_status);
return ResultSuccess();
R_SUCCEED();
}
/* We have an error interrupt. Write the status to the register to ensure consistent state. */
@ -440,10 +440,10 @@ namespace ams::sdmmc::impl {
R_UNLESS(reg::HasValue(auto_cmd_err_status, SD_REG_BITS_ENUM(AUTO_CMD_ERROR_AUTO_CMD_TIMEOUT, NO_ERROR)), sdmmc::ResultAutoCommandResponseTimeoutError());
/* An known auto cmd error occurred. */
return sdmmc::ResultSdHostStandardUnknownAutoCmdError();
R_THROW(sdmmc::ResultSdHostStandardUnknownAutoCmdError());
} else {
/* Unknown error occurred. */
return sdmmc::ResultSdHostStandardUnknownError();
R_THROW(sdmmc::ResultSdHostStandardUnknownError());
}
}
@ -468,7 +468,7 @@ namespace ams::sdmmc::impl {
} else {
/* If the device wasn't removed, cancel our transaction. */
this->AbortTransaction();
return sdmmc::ResultCommandCompleteSoftwareTimeout();
R_THROW(sdmmc::ResultCommandCompleteSoftwareTimeout());
}
}
#else
@ -485,12 +485,12 @@ namespace ams::sdmmc::impl {
/* If we succeeded, we're done. */
if (R_SUCCEEDED(result)) {
return ResultSuccess();
R_SUCCEED();
} else if (sdmmc::ResultNoWaitedInterrupt::Includes(result)) {
/* Otherwise, if the wait for the interrupt isn't done, update the timer and check for timeout. */
if (!timer.Update()) {
this->AbortTransaction();
return sdmmc::ResultCommandCompleteSoftwareTimeout();
R_THROW(sdmmc::ResultCommandCompleteSoftwareTimeout());
}
} else {
/* Otherwise, we have a generic failure. */
@ -525,7 +525,7 @@ namespace ams::sdmmc::impl {
if (R_SUCCEEDED(result)) {
/* If the transfer is complete, we're done. */
if (reg::HasValue(normal_int_status, SD_REG_BITS_ENUM(NORMAL_INTERRUPT_STATUS_TRANSFER_COMPLETE, COMPLETE))) {
return ResultSuccess();
R_SUCCEED();
}
/* Otherwise, if a DMA interrupt was generated, advance to the next address. */
@ -549,7 +549,7 @@ namespace ams::sdmmc::impl {
/* Otherwise, timeout if the transfer hasn't advanced. */
if (last_block_count != reg::Read(m_registers->block_count)) {
this->AbortTransaction();
return sdmmc::ResultTransferCompleteSoftwareTimeout();
R_THROW(sdmmc::ResultTransferCompleteSoftwareTimeout());
}
}
}
@ -574,7 +574,7 @@ namespace ams::sdmmc::impl {
if (R_SUCCEEDED(result)) {
/* If the transfer is complete, we're done. */
if (reg::HasValue(normal_int_status, SD_REG_BITS_ENUM(NORMAL_INTERRUPT_STATUS_TRANSFER_COMPLETE, COMPLETE))) {
return ResultSuccess();
R_SUCCEED();
}
/* Otherwise, if a DMA interrupt was generated, advance to the next address. */
@ -590,7 +590,7 @@ namespace ams::sdmmc::impl {
/* Only timeout if the transfer hasn't advanced. */
if (last_block_count != reg::Read(m_registers->block_count)) {
this->AbortTransaction();
return sdmmc::ResultTransferCompleteSoftwareTimeout();
R_THROW(sdmmc::ResultTransferCompleteSoftwareTimeout());
}
break;
}
@ -619,13 +619,13 @@ namespace ams::sdmmc::impl {
/* If the DAT0 line signal is level high, we're done. */
if (reg::HasValue(m_registers->present_state, SD_REG_BITS_ENUM(PRESENT_STATE_DAT0_LINE_SIGNAL_LEVEL, HIGH))) {
return ResultSuccess();
R_SUCCEED();
}
/* Otherwise, check if we're timed out. */
if (!timer.Update()) {
this->AbortTransaction();
return sdmmc::ResultBusySoftwareTimeout();
R_THROW(sdmmc::ResultBusySoftwareTimeout());
}
}
}
@ -715,7 +715,7 @@ namespace ams::sdmmc::impl {
R_TRY(this->WaitWhileBusy());
}
return ResultSuccess();
R_SUCCEED();
}
Result SdHostStandardController::IssueStopTransmissionCommandWithDeviceClock(u32 *out_response) {
@ -742,7 +742,7 @@ namespace ams::sdmmc::impl {
/* Wait until we're done. */
R_TRY(this->WaitWhileBusy());
return ResultSuccess();
R_SUCCEED();
}
SdHostStandardController::SdHostStandardController(dd::PhysicalAddress registers_phys_addr, size_t registers_size) {

View file

@ -112,7 +112,7 @@ namespace ams::sdmmc::impl {
R_UNLESS(!this->IsRemoved(), sdmmc::ResultDeviceRemoved());
#endif
return ResultSuccess();
R_SUCCEED();
}
public:
SdHostStandardController(dd::PhysicalAddress registers_phys_addr, size_t registers_size);

View file

@ -271,7 +271,7 @@ namespace ams::sdmmc::impl {
/* Enable internal clock. */
R_TRY(SdHostStandardController::EnableInternalClock());
return ResultSuccess();
R_SUCCEED();
}
Result SdmmcController::SetClockTrimmer(SpeedMode speed_mode, u8 tap_value) {
@ -289,7 +289,7 @@ namespace ams::sdmmc::impl {
/* Reset the cmd/dat line. */
R_TRY(SdHostStandardController::ResetCmdDatLine());
return ResultSuccess();
R_SUCCEED();
}
u8 SdmmcController::GetCurrentTapValue() {
@ -338,7 +338,7 @@ namespace ams::sdmmc::impl {
}
}
return ResultSuccess();
R_SUCCEED();
}
Result SdmmcController::SetSpeedModeWithTapValue(SpeedMode speed_mode, u8 tap_value) {
@ -434,7 +434,7 @@ namespace ams::sdmmc::impl {
/* Set the current speed mode. */
m_current_speed_mode = speed_mode;
return ResultSuccess();
R_SUCCEED();
}
Result SdmmcController::IssueTuningCommand(u32 command_index) {
@ -494,10 +494,10 @@ namespace ams::sdmmc::impl {
/* If we succeeded, clear the interrupt. */
reg::Write(m_sdmmc_registers->sd_host_standard_registers.normal_int_status, SD_REG_BITS_ENUM(NORMAL_INTERRUPT_BUFFER_READ_READY, ENABLED));
this->ClearInterrupt();
return ResultSuccess();
R_SUCCEED();
} else if (sdmmc::ResultWaitInterruptSoftwareTimeout::Includes(result)) {
SdHostStandardController::AbortTransaction();
return sdmmc::ResultIssueTuningCommandSoftwareTimeout();
R_THROW(sdmmc::ResultIssueTuningCommandSoftwareTimeout());
} else {
return result;
}
@ -511,13 +511,13 @@ namespace ams::sdmmc::impl {
if (reg::HasValue(m_sdmmc_registers->sd_host_standard_registers.normal_int_status, SD_REG_BITS_ENUM(NORMAL_INTERRUPT_BUFFER_READ_READY, ENABLED))) {
/* If we did, acknowledge it. */
reg::Write(m_sdmmc_registers->sd_host_standard_registers.normal_int_status, SD_REG_BITS_ENUM(NORMAL_INTERRUPT_BUFFER_READ_READY, ENABLED));
return ResultSuccess();
R_SUCCEED();
}
/* Otherwise, check if we timed out. */
if (!timer.Update()) {
SdHostStandardController::AbortTransaction();
return sdmmc::ResultIssueTuningCommandSoftwareTimeout();
R_THROW(sdmmc::ResultIssueTuningCommandSoftwareTimeout());
}
}
}
@ -641,7 +641,7 @@ namespace ams::sdmmc::impl {
/* Ensure that we can control the device. */
SdHostStandardController::EnsureControl();
return ResultSuccess();
R_SUCCEED();
}
void SdmmcController::Shutdown() {
@ -721,7 +721,7 @@ namespace ams::sdmmc::impl {
SdHostStandardController::EnableDeviceClock();
SdHostStandardController::EnsureControl();
return ResultSuccess();
R_SUCCEED();
}
Result SdmmcController::SwitchToSdr12() {
@ -761,7 +761,7 @@ namespace ams::sdmmc::impl {
/* Check that the dat lines are all high. */
R_UNLESS(reg::HasValue(m_sdmmc_registers->sd_host_standard_registers.present_state, SD_REG_BITS_VALUE(PRESENT_STATE_DAT0_3_LINE_SIGNAL_LEVEL, 0b1111)), sdmmc::ResultSdCardNotCompleteVoltageSwitch());
return ResultSuccess();
R_SUCCEED();
}
Result SdmmcController::SetSpeedMode(SpeedMode speed_mode) {
@ -777,7 +777,7 @@ namespace ams::sdmmc::impl {
/* Set the speed mode. */
R_TRY(this->SetSpeedModeWithTapValue(speed_mode, tap_value));
return ResultSuccess();
R_SUCCEED();
}
void SdmmcController::SetPowerSaving(bool en) {
@ -868,7 +868,7 @@ namespace ams::sdmmc::impl {
/* Check if we're using the tuned clock. */
R_UNLESS(reg::HasValue(m_sdmmc_registers->sd_host_standard_registers.host_control2, SD_REG_BITS_ENUM(HOST_CONTROL2_SAMPLING_CLOCK, USING_TUNED_CLOCK)), sdmmc::ResultTuningFailed());
return ResultSuccess();
R_SUCCEED();
}
void SdmmcController::SaveTuningStatusForHs400() {
@ -886,7 +886,7 @@ namespace ams::sdmmc::impl {
/* pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000); */
R_TRY(m_power_controller->PowerOn(BusPower_3_3V));
return ResultSuccess();
R_SUCCEED();
}
void Sdmmc1Controller::PowerOffForRegisterControl() {
@ -925,7 +925,7 @@ namespace ams::sdmmc::impl {
/* pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000); */
R_TRY(m_power_controller->LowerBusPower());
return ResultSuccess();
R_SUCCEED();
}
void Sdmmc1Controller::SetSchmittTriggerForRegisterControl(BusPower bus_power) {
@ -958,7 +958,7 @@ namespace ams::sdmmc::impl {
ON_SCOPE_EXIT { m_current_bus_power = BusPower_3_3V; };
/* TODO: return pcv::PowerOn(pcv::PowerControlTarget_SdCard, 3300000); */
return ResultSuccess();
R_SUCCEED();
}
void Sdmmc1Controller::PowerOffForPcvControl() {
@ -987,7 +987,7 @@ namespace ams::sdmmc::impl {
ON_SCOPE_EXIT { m_current_bus_power = BusPower_1_8V; };
/* TODO: return pcv::ChangeVoltage(pcv::PowerControlTarget_SdCard, 1800000); */
return ResultSuccess();
R_SUCCEED();
}
void Sdmmc1Controller::SetSchmittTriggerForPcvControl(BusPower bus_power) {
@ -1163,7 +1163,7 @@ namespace ams::sdmmc::impl {
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();
R_SUCCEED();
}
void Sdmmc1Controller::PowerController::SetSdmmcIoMode(bool is_3_3V) {
@ -1258,7 +1258,7 @@ namespace ams::sdmmc::impl {
/* Update our current bus power. */
m_current_bus_power = bus_power;
return ResultSuccess();
R_SUCCEED();
}
Result Sdmmc1Controller::PowerController::PowerOff() {
@ -1289,7 +1289,7 @@ namespace ams::sdmmc::impl {
/* Update our current bus power. */
m_current_bus_power = BusPower_Off;
return ResultSuccess();
R_SUCCEED();
}
Result Sdmmc1Controller::PowerController::LowerBusPower() {
@ -1305,7 +1305,7 @@ namespace ams::sdmmc::impl {
/* Update our current bus power. */
m_current_bus_power = BusPower_1_8V;
return ResultSuccess();
R_SUCCEED();
}
}

View file

@ -444,7 +444,7 @@ namespace ams::sdmmc::impl {
virtual Result PowerOn(BusPower bus_power) override {
/* Power for SDMMC2/4 is assumed on, so we don't need to do anything. */
AMS_UNUSED(bus_power);
return ResultSuccess();
R_SUCCEED();
}
virtual void PowerOff() override {