Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/SDMMCAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const char* SDMMCAnalyzer::GetAnalyzerName() const

void SDMMCAnalyzer::WorkerThread()
{
bool appCommandPending = false;

mResults.reset(new SDMMCAnalyzerResults(this, mSettings.get()));
SetAnalyzerResults(mResults.get());

Expand All @@ -40,7 +42,7 @@ void SDMMCAnalyzer::WorkerThread()
CheckIfThreadShouldExit();
AdvanceToNextClock();

cmdindex = TryReadCommand();
cmdindex = TryReadCommand(appCommandPending);
if (cmdindex < 0) {
/* continue if parsing the command failed */
continue;
Expand All @@ -51,7 +53,21 @@ void SDMMCAnalyzer::WorkerThread()
if (response.mType != MMC_RSP_NONE)
WaitForAndReadMMCResponse(response);
} else {
/* FIXME: implement SD response handling */
if (appCommandPending)
{
struct MMCResponse response = SDMMCHelpers::SDAppCommandResponse(cmdindex);
if (response.mType != MMC_RSP_NONE)
WaitForAndReadMMCResponse(response);
appCommandPending = false;
}
else
{
struct MMCResponse response = SDMMCHelpers::MMCCommandResponse(cmdindex);
if (response.mType != MMC_RSP_NONE) {
int result = WaitForAndReadMMCResponse(response);
appCommandPending = ((result > 0) && (cmdindex == 55));
}
}
}
}
}
Expand Down Expand Up @@ -87,7 +103,7 @@ void SDMMCAnalyzer::AdvanceToNextClock()
mCommand->AdvanceToAbsPosition(mClock->GetSampleNumber());
}

int SDMMCAnalyzer::TryReadCommand()
int SDMMCAnalyzer::TryReadCommand(bool appCmd)
{
int index;

Expand All @@ -113,7 +129,7 @@ int SDMMCAnalyzer::TryReadCommand()
frame.mStartingSampleInclusive = mClock->GetSampleNumber();
frame.mData1 = 0;
frame.mData2 = 0;
frame.mType = SDMMCAnalyzerResults::FRAMETYPE_COMMAND;
frame.mType = appCmd ? SDMMCAnalyzerResults::FRAMETYPE_ACOMMAND : SDMMCAnalyzerResults::FRAMETYPE_COMMAND;

for (int i = 0; i < 6; i++) {
frame.mData1 = (frame.mData1 << 1) | mCommand->GetBitState();
Expand Down
2 changes: 1 addition & 1 deletion src/SDMMCAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ANALYZER_EXPORT SDMMCAnalyzer : public Analyzer

protected:
void AdvanceToNextClock();
int TryReadCommand();
int TryReadCommand(bool appCmd = false);
int WaitForAndReadMMCResponse(struct MMCResponse response);

protected:
Expand Down
14 changes: 14 additions & 0 deletions src/SDMMCAnalyzerResults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ void SDMMCAnalyzerResults::GenerateBubbleText(U64 frame_index, Channel& channel,
break;
}

case FRAMETYPE_ACOMMAND:
{
char str_cmd[4];
char str_arg[33];

AnalyzerHelpers::GetNumberString(frame.mData1, Decimal, 6, str_cmd, sizeof(str_cmd));
AnalyzerHelpers::GetNumberString(frame.mData2, display_base, 32, str_arg, sizeof(str_arg));

AddResultString("ACMD");
AddResultString("ACMD", str_cmd);
AddResultString("ACMD", str_cmd, ", arg=", str_arg);
break;
}

case FRAMETYPE_RESPONSE:
{
char str_32[33];
Expand Down
1 change: 1 addition & 0 deletions src/SDMMCAnalyzerResults.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class SDMMCAnalyzerResults : public AnalyzerResults
enum FrameType {
FRAMETYPE_HEADER,
FRAMETYPE_COMMAND,
FRAMETYPE_ACOMMAND,
FRAMETYPE_RESPONSE,
FRAMETYPE_CRC,
};
Expand Down
75 changes: 75 additions & 0 deletions src/SDMMCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,73 @@ static struct MMCResponse responses[64] = {
/* 63 */ {MMC_RSP_NONE, 0, 0, false}, /* reserved */
};

static struct MMCResponse sdapp_responses[64] = {
/* 0 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 1 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 2 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 3 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 4 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 5 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 6 */{ MMC_RSP_R1, 32, 64, false },
/* 7 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 8 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 9 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 10 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 11 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 12 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 13 */{ MMC_RSP_R1, 32, 64, false },
/* 14 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 15 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 16 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 17 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 18 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 19 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 20 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 21 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 22 */{ MMC_RSP_R1, 32, 64, false },
/* 23 */{ MMC_RSP_R1, 32, 64, false },
/* 24 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 25 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 26 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 27 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 28 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 29 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 30 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 31 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 32 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 33 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 34 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 35 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 36 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 37 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 38 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 39 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 40 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 41 */{ MMC_RSP_R3, 32, 64, false },
/* 42 */{ MMC_RSP_R1, 32, 64, false },
/* 43 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 44 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 45 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 46 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 47 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 48 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 49 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 50 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 51 */{ MMC_RSP_R1, 32, 64, false },
/* 52 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 53 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 54 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 55 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 56 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 57 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 58 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 59 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 60 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 61 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 62 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
/* 63 */{ MMC_RSP_NONE, 0, 0, false }, /* reserved */
};

static struct MMCResponse invalid_response = {
MMC_RSP_NONE, 0, 0, false
};
Expand All @@ -91,6 +158,14 @@ struct MMCResponse SDMMCHelpers::MMCCommandResponse(unsigned int index)
return responses[index];
}

struct MMCResponse SDMMCHelpers::SDAppCommandResponse(unsigned int index)
{
if (index > 63)
return invalid_response;

return sdapp_responses[index];
}

/*
* fast crc7 sd/mmc implementation taken from:
* http://catid.mechafetus.com/news/news.php?view=253
Expand Down
1 change: 1 addition & 0 deletions src/SDMMCHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SDMMCHelpers
public:
static U8 crc7(const U8 *data, unsigned int size);
static struct MMCResponse MMCCommandResponse(unsigned int index);
static struct MMCResponse SDAppCommandResponse(unsigned int index);

private:
static U8 __crc7(U8 crc, U8 data);
Expand Down
5 changes: 5 additions & 0 deletions vs2013/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Debug
Release
*.ncb
*.suo
*.vcproj.*.user
28 changes: 28 additions & 0 deletions vs2013/SDMMCAnalyzer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDMMCAnalyzer", "SDMMCAnalyzer.vcxproj", "{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|Win32.ActiveCfg = Debug|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|Win32.Build.0 = Debug|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|x64.ActiveCfg = Release|x64
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Debug|x64.Build.0 = Release|x64
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|Win32.ActiveCfg = Release|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|Win32.Build.0 = Release|Win32
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|x64.ActiveCfg = Release|x64
{D7556E7E-A6BF-4BCE-BDC8-E66D2874C301}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading