Reply -- make it to the next part at least

This commit is contained in:
Pokechu22 2020-08-21 19:20:02 -07:00
parent 38e56c1e36
commit 45205c3a56
2 changed files with 40 additions and 2 deletions

View File

@ -44,10 +44,18 @@ u32 CEXISD::ImmRead(u32 size)
}
else
{
return IEXIDevice::ImmRead(size);
u32 res = IEXIDevice::ImmRead(size);
INFO_LOG_FMT(EXPANSIONINTERFACE, "Responding with {:08x}", res);
return res;
}
}
void CEXISD::ImmReadWrite(u32& data, u32 size)
{
ImmWrite(data, size);
data = ImmRead(size);
}
void CEXISD::SetCS(int cs)
{
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD SetCS: {}", cs);
@ -64,6 +72,7 @@ void CEXISD::DoState(PointerWrap& p)
p.Do(get_id);
p.Do(m_uPosition);
p.DoArray(cmd);
p.Do(result);
}
void CEXISD::TransferByte(u8& byte)
@ -95,7 +104,11 @@ void CEXISD::TransferByte(u8& byte)
// TODO: Check CRC
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI SD command received: {:02x}", fmt::join(cmd.begin(), cmd.end(), " "));
result = R1::InIdleState;
}
}
byte = static_cast<u8>(result);
}
} // namespace ExpansionInterface

View File

@ -22,6 +22,7 @@ public:
void ImmWrite(u32 data, u32 size) override;
u32 ImmRead(u32 size) override;
void ImmReadWrite(u32& data, u32 size) override;
void SetCS(int cs) override;
bool IsPresent() const override;
@ -30,10 +31,34 @@ public:
private:
void TransferByte(u8& byte) override;
enum class R1
{
InIdleState = 1 << 0,
EraseRequest = 1 << 1,
IllegalCommand = 1 << 2,
CommunicationCRCError = 1 << 3,
EraseSequenceError = 1 << 4,
AddressError = 1 << 5,
ParameterError = 1 << 6,
// Top bit 0
};
enum class R2
{
CardIsLocked = 1 << 0,
WriteProtectEraseSkip = 1 << 1, // or lock/unlock command failed
Error = 1 << 2,
CardControllerError = 1 << 3,
CardEccFailed = 1 << 4,
WriteProtectViolation = 1 << 5,
EraseParam = 1 << 6,
// OUT_OF_RANGE_OR_CSD_OVERWRITE, not documented in text?
};
// STATE_TO_SAVE
bool inited = false;
bool get_id = false;
u32 m_uPosition = 0;
std::array<u8, 6> cmd;
std::array<u8, 6> cmd = {};
R1 result = static_cast<R1>(0);
};
} // namespace ExpansionInterface