#include "diskio.h" /* Declarations of disk functions */\r
\r
\r
-static\r
-DWORD pn ( /* Pseudo random number generator */\r
- DWORD pns /* 0:Initialize, !0:Read */\r
+\r
+static DWORD pn ( /* Pseudo random number generator */\r
+ DWORD pns /* 0:Initialize, !0:Read */\r
)\r
{\r
static DWORD lfsr;\r
\r
printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff);\r
\r
- if (sz_buff < _MAX_SS + 4) {\r
- printf("Insufficient work area to run program.\n");\r
+ if (sz_buff < FF_MAX_SS + 8) {\r
+ printf("Insufficient work area to run the program.\n");\r
return 1;\r
}\r
\r
}\r
\r
/* Single sector write test */\r
- printf("**** Single sector write test 1 ****\n");\r
+ printf("**** Single sector write test ****\n");\r
lba = 0;\r
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n] = (BYTE)pn(0);\r
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba);\r
}\r
for (n = 0, pn(pns); n < sz_sect && pbuff[n] == (BYTE)pn(0); n++) ;\r
if (n == sz_sect) {\r
- printf(" Data matched.\n");\r
+ printf(" Read data matched.\n");\r
} else {\r
- printf("Failed: Read data differs from the data written.\n");\r
+ printf(" Read data differs from the data written.\n");\r
return 10;\r
}\r
pns++;\r
\r
printf("**** Multiple sector write test ****\n");\r
- lba = 1; ns = sz_buff / sz_sect;\r
+ lba = 5; ns = sz_buff / sz_sect;\r
if (ns > 4) ns = 4;\r
- for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0);\r
- printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);\r
- dr = disk_write(pdrv, pbuff, lba, ns);\r
- if (dr == RES_OK) {\r
- printf(" - ok.\n");\r
- } else {\r
- printf(" - failed.\n");\r
- return 11;\r
- }\r
- printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);\r
- dr = disk_ioctl(pdrv, CTRL_SYNC, 0);\r
- if (dr == RES_OK) {\r
- printf(" - ok.\n");\r
- } else {\r
- printf(" - failed.\n");\r
- return 12;\r
- }\r
- memset(pbuff, 0, sz_sect * ns);\r
- printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);\r
- dr = disk_read(pdrv, pbuff, lba, ns);\r
- if (dr == RES_OK) {\r
- printf(" - ok.\n");\r
- } else {\r
- printf(" - failed.\n");\r
- return 13;\r
- }\r
- for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ;\r
- if (n == (UINT)(sz_sect * ns)) {\r
- printf(" Data matched.\n");\r
+ if (ns > 1) {\r
+ for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0);\r
+ printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);\r
+ dr = disk_write(pdrv, pbuff, lba, ns);\r
+ if (dr == RES_OK) {\r
+ printf(" - ok.\n");\r
+ } else {\r
+ printf(" - failed.\n");\r
+ return 11;\r
+ }\r
+ printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv);\r
+ dr = disk_ioctl(pdrv, CTRL_SYNC, 0);\r
+ if (dr == RES_OK) {\r
+ printf(" - ok.\n");\r
+ } else {\r
+ printf(" - failed.\n");\r
+ return 12;\r
+ }\r
+ memset(pbuff, 0, sz_sect * ns);\r
+ printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns);\r
+ dr = disk_read(pdrv, pbuff, lba, ns);\r
+ if (dr == RES_OK) {\r
+ printf(" - ok.\n");\r
+ } else {\r
+ printf(" - failed.\n");\r
+ return 13;\r
+ }\r
+ for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ;\r
+ if (n == (UINT)(sz_sect * ns)) {\r
+ printf(" Read data matched.\n");\r
+ } else {\r
+ printf(" Read data differs from the data written.\n");\r
+ return 14;\r
+ }\r
} else {\r
- printf("Failed: Read data differs from the data written.\n");\r
- return 14;\r
+ printf(" Test skipped.\n");\r
}\r
pns++;\r
\r
- printf("**** Single sector write test (misaligned address) ****\n");\r
+ printf("**** Single sector write test (unaligned buffer address) ****\n");\r
lba = 5;\r
for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n+3] = (BYTE)pn(0);\r
printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+3), lba);\r
}\r
for (n = 0, pn(pns); n < sz_sect && pbuff[n+5] == (BYTE)pn(0); n++) ;\r
if (n == sz_sect) {\r
- printf(" Data matched.\n");\r
+ printf(" Read data matched.\n");\r
} else {\r
- printf("Failed: Read data differs from the data written.\n");\r
+ printf(" Read data differs from the data written.\n");\r
return 18;\r
}\r
pns++;\r
}\r
for (n = 0, pn(pns); pbuff[n] == (BYTE)pn(0) && n < (UINT)(sz_sect * 2); n++) ;\r
if (n == (UINT)(sz_sect * 2)) {\r
- printf(" Data matched.\n");\r
+ printf(" Read data matched.\n");\r
} else {\r
- printf("Failed: Read data differs from the data written.\n");\r
+ printf(" Read data differs from the data written.\n");\r
return 24;\r
}\r
} else {\r