static int mbr_test_run(struct unit_test_state *uts)
{
struct blk_desc *mmc_dev_desc;
- unsigned char mbr_wbuf[BLKSZ], ebr_wbuf[BLKSZ], rbuf[BLKSZ];
+ unsigned char *mbr_wbuf, *ebr_wbuf, *rbuf;
char mbr_parts_buf[256];
- ulong mbr_wa, ebr_wa, ra, ebr_blk, mbr_parts_max;
+ ulong addr = 0x1000; /* start address for buffers */
+ ulong mbr_wa = addr, ebr_wa = addr + BLKSZ, ra = addr + BLKSZ * 2;
+ ulong ebr_blk, mbr_parts_max;
struct udevice *dev;
ofnode root, node;
ut_assertf(sizeof(mbr_parts_buf) >= mbr_parts_max, "Buffer avail: %ld; buffer req: %ld\n",
sizeof(mbr_parts_buf), mbr_parts_max);
- mbr_wa = map_to_sysmem(mbr_wbuf);
- ebr_wa = map_to_sysmem(ebr_wbuf);
- ra = map_to_sysmem(rbuf);
+ mbr_wbuf = map_sysmem(mbr_wa, BLKSZ);
+ ebr_wbuf = map_sysmem(ebr_wa, BLKSZ);
+ rbuf = map_sysmem(ra, BLKSZ);
ebr_blk = (ulong)0xb00000 / BLKSZ;
/* Make sure mmc6 exists */
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 1));
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ));
ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assert_nextline("MBR: write success!");
ut_assertok(run_commandf("mbr verify mmc 6"));
ut_assert_nextline("MBR: verify success!");
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
for (unsigned i = 0; i < mbr_cmp_size; i++) {
ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p1[i],
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 2));
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ));
ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assert_nextline("MBR: write success!");
ut_assertok(run_commandf("mbr verify mmc 6"));
ut_assert_nextline("MBR: verify success!");
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
for (unsigned i = 0; i < mbr_cmp_size; i++) {
ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p2[i],
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 3));
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ));
ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assert_nextline("MBR: write success!");
ut_assertok(run_commandf("mbr verify mmc 6"));
ut_assert_nextline("MBR: verify success!");
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 00 |...f%..P........|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
for (unsigned i = 0; i < mbr_cmp_size; i++) {
ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p3[i],
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 4));
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ));
ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assert_nextline("MBR: write success!");
ut_assertok(run_commandf("mbr verify mmc 6"));
ut_assert_nextline("MBR: verify success!");
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
for (unsigned i = 0; i < mbr_cmp_size; i++) {
ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p4[i],
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 5));
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
ut_assertok(memcmp(mbr_wbuf, rbuf, BLKSZ));
ut_assertok(run_commandf("write mmc 6:0 %lx %lx 1", ebr_wa, ebr_blk));
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
for (unsigned i = 0; i < mbr_cmp_size; i++) {
ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p5[i],
00b001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
*/
- memset(rbuf, 0, sizeof(rbuf));
+ memset(rbuf, '\0', BLKSZ);
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
for (unsigned i = 0; i < ebr_cmp_size; i++) {
ut_assertf(rbuf[ebr_cmp_start + i] == ebr_parts_ref_p5[i],