mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
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>
This commit is contained in:
parent
2d0fc797fa
commit
d2c4f3841d
6 changed files with 74 additions and 74 deletions
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "qemu-common.h"
|
||||
|
||||
#define PAGE_SIZE (4096)
|
||||
#define ALLOC_PAGE_SIZE (4096)
|
||||
|
||||
void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
|
|||
QFWCFG *fw_cfg = pc_fw_cfg_init(qts);
|
||||
|
||||
ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE);
|
||||
alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE);
|
||||
alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), ALLOC_PAGE_SIZE);
|
||||
|
||||
/* clean-up */
|
||||
pc_fw_cfg_uninit(fw_cfg);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "qemu-common.h"
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
#define SPAPR_PAGE_SIZE 4096
|
||||
|
||||
/* Memory must be a multiple of 256 MB,
|
||||
* so we have at least 256MB
|
||||
|
@ -19,5 +19,5 @@
|
|||
|
||||
void spapr_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
|
||||
{
|
||||
alloc_init(s, flags, 1 << 20, SPAPR_MIN_SIZE, PAGE_SIZE);
|
||||
alloc_init(s, flags, 1 << 20, SPAPR_MIN_SIZE, SPAPR_PAGE_SIZE);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue