aboutsummaryrefslogtreecommitdiff
path: root/tests/qtest/m25p80-test.c
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2021-01-18 14:38:05 +0800
committerThomas Huth <thuth@redhat.com>2021-01-20 10:46:54 +0100
commitd2c4f3841d1cba17c99f76812ffcb75a6c402202 (patch)
tree338680b9d8a259330839568b545d8bca0b04d0ec /tests/qtest/m25p80-test.c
parent2d0fc797faaa73fbc1d30f5f9e90407bf3dd93f0 (diff)
tests: Rename PAGE_SIZE definitions
As per POSIX specification of limits.h [1], OS libc may define PAGE_SIZE in limits.h. Self defined PAGE_SIZE is frequently used in tests, to prevent collosion of definition, we give PAGE_SIZE definitons reasonable prefixs. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/limits.h.html Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20210118063808.12471-7-jiaxun.yang@flygoat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/qtest/m25p80-test.c')
-rw-r--r--tests/qtest/m25p80-test.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/tests/qtest/m25p80-test.c b/tests/qtest/m25p80-test.c
index 50c6b79fb3..f860cef5f0 100644
--- a/tests/qtest/m25p80-test.c
+++ b/tests/qtest/m25p80-test.c
@@ -62,7 +62,7 @@ enum {
#define FLASH_JEDEC 0x20ba19 /* n25q256a */
#define FLASH_SIZE (32 * 1024 * 1024)
-#define PAGE_SIZE 256
+#define FLASH_PAGE_SIZE 256
/*
* Use an explicit bswap for the values read/wrote to the flash region
@@ -165,7 +165,7 @@ static void read_page(uint32_t addr, uint32_t *page)
writel(ASPEED_FLASH_BASE, make_be32(addr));
/* Continuous read are supported */
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
page[i] = make_be32(readl(ASPEED_FLASH_BASE));
}
spi_ctrl_stop_user();
@@ -178,15 +178,15 @@ static void read_page_mem(uint32_t addr, uint32_t *page)
/* move out USER mode to use direct reads from the AHB bus */
spi_ctrl_setmode(CTRL_READMODE, READ);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
page[i] = make_be32(readl(ASPEED_FLASH_BASE + addr + i * 4));
}
}
static void test_erase_sector(void)
{
- uint32_t some_page_addr = 0x600 * PAGE_SIZE;
- uint32_t page[PAGE_SIZE / 4];
+ uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
int i;
spi_conf(CONF_ENABLE_W0);
@@ -200,14 +200,14 @@ static void test_erase_sector(void)
/* Previous page should be full of zeroes as backend is not
* initialized */
- read_page(some_page_addr - PAGE_SIZE, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ read_page(some_page_addr - FLASH_PAGE_SIZE, page);
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0x0);
}
/* But this one was erased */
read_page(some_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
}
@@ -216,8 +216,8 @@ static void test_erase_sector(void)
static void test_erase_all(void)
{
- uint32_t some_page_addr = 0x15000 * PAGE_SIZE;
- uint32_t page[PAGE_SIZE / 4];
+ uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
int i;
spi_conf(CONF_ENABLE_W0);
@@ -225,7 +225,7 @@ static void test_erase_all(void)
/* Check some random page. Should be full of zeroes as backend is
* not initialized */
read_page(some_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0x0);
}
@@ -236,7 +236,7 @@ static void test_erase_all(void)
/* Recheck that some random page */
read_page(some_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
}
@@ -245,9 +245,9 @@ static void test_erase_all(void)
static void test_write_page(void)
{
- uint32_t my_page_addr = 0x14000 * PAGE_SIZE; /* beyond 16MB */
- uint32_t some_page_addr = 0x15000 * PAGE_SIZE;
- uint32_t page[PAGE_SIZE / 4];
+ uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
+ uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
int i;
spi_conf(CONF_ENABLE_W0);
@@ -259,20 +259,20 @@ static void test_write_page(void)
writel(ASPEED_FLASH_BASE, make_be32(my_page_addr));
/* Fill the page with its own addresses */
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
writel(ASPEED_FLASH_BASE, make_be32(my_page_addr + i * 4));
}
spi_ctrl_stop_user();
/* Check what was written */
read_page(my_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
}
/* Check some other page. It should be full of 0xff */
read_page(some_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
}
@@ -281,9 +281,9 @@ static void test_write_page(void)
static void test_read_page_mem(void)
{
- uint32_t my_page_addr = 0x14000 * PAGE_SIZE; /* beyond 16MB */
- uint32_t some_page_addr = 0x15000 * PAGE_SIZE;
- uint32_t page[PAGE_SIZE / 4];
+ uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */
+ uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
int i;
/* Enable 4BYTE mode for controller. This is should be strapped by
@@ -300,13 +300,13 @@ static void test_read_page_mem(void)
/* Check what was written */
read_page_mem(my_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
}
/* Check some other page. It should be full of 0xff */
read_page_mem(some_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, 0xffffffff);
}
@@ -315,8 +315,8 @@ static void test_read_page_mem(void)
static void test_write_page_mem(void)
{
- uint32_t my_page_addr = 0x15000 * PAGE_SIZE;
- uint32_t page[PAGE_SIZE / 4];
+ uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
int i;
/* Enable 4BYTE mode for controller. This is should be strapped by
@@ -334,14 +334,14 @@ static void test_write_page_mem(void)
/* move out USER mode to use direct writes to the AHB bus */
spi_ctrl_setmode(CTRL_WRITEMODE, PP);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
writel(ASPEED_FLASH_BASE + my_page_addr + i * 4,
make_be32(my_page_addr + i * 4));
}
/* Check what was written */
read_page_mem(my_page_addr, page);
- for (i = 0; i < PAGE_SIZE / 4; i++) {
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
}