📄 pccard_test.cpp
字号:
#include "system.h"
#include "pccard.h"
static PCCARD oPccard;
void PrintCIS(void)
{
u32 cisEnd=0;
u8 str[16];
u8 c;
oPccard.OpenMedia();
Disp("[Card Information Structure]\n");
//search the end of CIS
while (1)
{
oPccard.GetAttribData((cisEnd)*2, c);
if (c==0xff) //0xff= termination tuple
break;
cisEnd++;
oPccard.GetAttribData((cisEnd)*2, c);
cisEnd += c+1;
}
Disp("cisEnd=0~%x\n",cisEnd);
for (u32 i=0; i<=cisEnd*2; i+=2)
{
oPccard.GetAttribData(i, c);
str[(i%0x20)/2]=c;
Disp("%2x,",c);
if ((i%0x20)>=0x1e)
{
Disp("//");
for (u32 j=0; j<0x10; j++)
if (str[j]>=' ' && str[j]<=127)
Disp("%c",str[j]);
else
Disp(".");
Disp("\n");
}
}
Disp("\n");
}
void TestWriteRead_PcCard(void)
{
u32 uWriteBuf = CODEC_MEM_ST;
u32 uReadBuf = CODEC_MEM_ST + 0x400000;
u32 deviceLba;
u32 uBlockCount;
oPccard.OpenMedia();
Disp("\nInput device sector address\n");
deviceLba = (u32)GetInt();
Disp("Input sector count\n");
uBlockCount = (u32)GetInt();
for (u32 i=0; i<uBlockCount*512; i++){
Outp8(uWriteBuf+i, (i+3)%256);
Outp8(uReadBuf+i, 0);
}
oPccard.WriteBlocks(deviceLba, uBlockCount, uWriteBuf);
oPccard.ReadBlocks(deviceLba, uBlockCount, uReadBuf);
if (Compare32(uWriteBuf, uReadBuf, uBlockCount*128) == false)
{
Disp("Error detected\n");
Dump32(uReadBuf, uBlockCount*128);
}
else
{
Disp("Write/Read in PC Card mode is OK\n");
}
}
void TestRead_PcCard(void)
{
u32 uReadBuf = CODEC_MEM_ST + 0x400000;
u32 deviceLba;
u32 uBlockCount;
oPccard.OpenMedia();
Disp("\nInput device sector address\n");
deviceLba = (u32)GetInt();
Disp("Input sector count\n");
uBlockCount = (u32)GetInt();
for (u32 i=0; i<uBlockCount*512; i=i+4)
{
Outp32(uReadBuf+i, 0);
}
oPccard.ReadBlocks(deviceLba, uBlockCount, uReadBuf);
Dump32(uReadBuf, uBlockCount*128);
}
void Test_PCCARD(void)
{
int i, sel;
const FUNC_MENU menu[]=
{
NULL, "Exit",
PrintCIS, "Display CIS",
TestWriteRead_PcCard, "PC Card Common memory Write/Read test",
TestRead_PcCard, "PC Card Common memory Read test",
0,0
};
while(1)
{
Disp("\n");
for (i=0; (int)(menu[i].desc)!=0; i++)
Disp("%2d: %s\n", i, menu[i].desc);
Disp("\nSelect the function to test : ");
sel = GetInt();
Disp("\n");
if (sel == 0)
break;
else if (sel>0 && sel<(sizeof(menu)/8-1))
(menu[sel].func)();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -