#include <asm/global_data.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
+#include <linux/sizes.h>
#include <test/suites.h>
#include <test/ut.h>
DECLARE_GLOBAL_DATA_PTR;
+
+#define BLKSZ SZ_512 /* block size */
+
/*
* Requirements for running test manually:
* mmc6.img - File size needs to be at least 12 MiB
static int mbr_test_run(struct unit_test_state *uts)
{
struct blk_desc *mmc_dev_desc;
- unsigned char mbr_wbuf[512], ebr_wbuf[512], rbuf[512];
+ unsigned char mbr_wbuf[BLKSZ], ebr_wbuf[BLKSZ], rbuf[BLKSZ];
char mbr_parts_buf[256];
ulong mbr_wa, ebr_wa, ra, ebr_blk, mbr_parts_max;
struct udevice *dev;
mbr_wa = map_to_sysmem(mbr_wbuf);
ebr_wa = map_to_sysmem(ebr_wbuf);
ra = map_to_sysmem(rbuf);
- ebr_blk = (ulong)0xb00000 / 0x200;
+ ebr_blk = (ulong)0xb00000 / BLKSZ;
/* Make sure mmc6 exists */
ut_asserteq(6, blk_get_device_by_str("mmc", "6", &mmc_dev_desc));
/* Make sure mmc6 is 12+ MiB in size */
ut_assertok(run_commandf("mmc read %lx %lx 1", ra,
- (ulong)0xbffe00 / 0x200));
+ (ulong)0xbffe00 / BLKSZ));
/* Test one MBR partition */
init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
- ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ 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));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assertok(run_commandf("mbr write mmc 6"));
ut_assert_nextlinen("MMC read: dev # 6");
ut_assert_nextline("MBR: verify success!");
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
/*
000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
- ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ 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));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assertok(run_commandf("mbr write mmc 6"));
ut_assert_nextline("MBR: write success!");
ut_assert_nextline("MBR: verify success!");
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
/*
000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
- ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ 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));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assertok(run_commandf("mbr write mmc 6"));
ut_assert_nextline("MBR: write success!");
ut_assert_nextline("MBR: verify success!");
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
/*
000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
- ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ 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));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assertok(run_commandf("mbr write mmc 6"));
ut_assert_nextline("MBR: write success!");
ut_assert_nextline("MBR: verify success!");
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assert_console_end();
/*
000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
ut_assertok(run_commandf("write mmc 6:0 %lx 0 1", mbr_wa));
memset(rbuf, 0, sizeof(rbuf));
ut_assertok(run_commandf("read mmc 6:0 %lx 0 1", ra));
- ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ 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));
ut_assertok(run_commandf("read mmc 6:0 %lx %lx 1", ra, ebr_blk));
- ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, BLKSZ));
ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assertf(0 == run_commandf("mbr write mmc 6"), "Invalid partitions string: %s\n", mbr_parts_buf);
ut_assert_nextline("MBR: write success!");