[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] tests: fw_cfg: Rename pc_fw_cfg_* to fw_cfg_*
From: |
Xiang Zheng |
Subject: |
[PATCH 1/5] tests: fw_cfg: Rename pc_fw_cfg_* to fw_cfg_* |
Date: |
Tue, 3 Dec 2019 20:27:49 +0800 |
Rename pc_fw_cfg_* to fw_cfg_* to make them common for other
architectures so that we can run fw_cfg tests on aarch64.
Signed-off-by: Xiang Zheng <address@hidden>
---
tests/fw_cfg-test.c | 48 ++++++++++++++++++++--------------------
tests/hd-geo-test.c | 6 ++---
tests/libqos/fw_cfg.h | 20 +++++++++++++----
tests/libqos/malloc-pc.c | 4 ++--
4 files changed, 45 insertions(+), 33 deletions(-)
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 5dc807ba23..5a5342fa9d 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -30,13 +30,13 @@ static void test_fw_cfg_signature(void)
char buf[5];
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4);
buf[4] = 0;
g_assert_cmpstr(buf, ==, "QEMU");
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -47,12 +47,12 @@ static void test_fw_cfg_id(void)
uint32_t id;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID);
g_assert((id == 1) ||
(id == 3));
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -68,12 +68,12 @@ static void test_fw_cfg_uuid(void)
};
s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16);
g_assert(memcmp(buf, uuid, sizeof(buf)) == 0);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -84,11 +84,11 @@ static void test_fw_cfg_ram_size(void)
QTestState *s;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), ==, ram_size);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -98,11 +98,11 @@ static void test_fw_cfg_nographic(void)
QTestState *s;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), ==, 0);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -112,11 +112,11 @@ static void test_fw_cfg_nb_cpus(void)
QTestState *s;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), ==, nb_cpus);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -126,10 +126,10 @@ static void test_fw_cfg_max_cpus(void)
QTestState *s;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), ==, max_cpus);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -141,7 +141,7 @@ static void test_fw_cfg_numa(void)
uint64_t *node_mask;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), ==, nb_nodes);
@@ -158,7 +158,7 @@ static void test_fw_cfg_numa(void)
g_free(node_mask);
g_free(cpu_mask);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -168,10 +168,10 @@ static void test_fw_cfg_boot_menu(void)
QTestState *s;
s = qtest_init("");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), ==, boot_menu);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -183,14 +183,14 @@ static void test_fw_cfg_reboot_timeout(void)
size_t filesize;
s = qtest_init("-boot reboot-timeout=15");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait",
&reboot_timeout, sizeof(reboot_timeout));
g_assert_cmpint(filesize, ==, sizeof(reboot_timeout));
reboot_timeout = le32_to_cpu(reboot_timeout);
g_assert_cmpint(reboot_timeout, ==, 15);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -203,14 +203,14 @@ static void test_fw_cfg_no_reboot_timeout(void)
/* Special value -1 means "don't reboot" */
s = qtest_init("-boot reboot-timeout=-1");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait",
&reboot_timeout, sizeof(reboot_timeout));
g_assert_cmpint(filesize, ==, sizeof(reboot_timeout));
reboot_timeout = le32_to_cpu(reboot_timeout);
g_assert_cmpint(reboot_timeout, ==, UINT32_MAX);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
@@ -222,14 +222,14 @@ static void test_fw_cfg_splash_time(void)
size_t filesize;
s = qtest_init("-boot splash-time=12");
- fw_cfg = pc_fw_cfg_init(s);
+ fw_cfg = fw_cfg_init(s);
filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-menu-wait",
&splash_time, sizeof(splash_time));
g_assert_cmpint(filesize, ==, sizeof(splash_time));
splash_time = le16_to_cpu(splash_time);
g_assert_cmpint(splash_time, ==, 12);
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
qtest_quit(s);
}
diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
index 7e86c5416c..a9b8a07403 100644
--- a/tests/hd-geo-test.c
+++ b/tests/hd-geo-test.c
@@ -693,7 +693,7 @@ static void test_override(TestArgs *args, CHSResult
expected[])
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
- fw_cfg = pc_fw_cfg_init(qts);
+ fw_cfg = fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
@@ -829,7 +829,7 @@ static void test_override_scsi_hot_unplug(void)
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
- fw_cfg = pc_fw_cfg_init(qts);
+ fw_cfg = fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
@@ -889,7 +889,7 @@ static void test_override_virtio_hot_unplug(void)
joined_args = g_strjoinv(" ", args->argv);
qts = qtest_init(joined_args);
- fw_cfg = pc_fw_cfg_init(qts);
+ fw_cfg = fw_cfg_init(qts);
read_bootdevices(fw_cfg, expected);
diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h
index 13325cc4ff..708aa922ed 100644
--- a/tests/libqos/fw_cfg.h
+++ b/tests/libqos/fw_cfg.h
@@ -39,14 +39,26 @@ void mm_fw_cfg_uninit(QFWCFG *fw_cfg);
QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base);
void io_fw_cfg_uninit(QFWCFG *fw_cfg);
-static inline QFWCFG *pc_fw_cfg_init(QTestState *qts)
+static inline QFWCFG *fw_cfg_init(QTestState *qts)
{
- return io_fw_cfg_init(qts, 0x510);
+ const char *arch = qtest_get_arch();
+
+ if (!strcmp(arch, "aarch64")) {
+ return mm_fw_cfg_init(qts, 0x09020000);
+ } else {
+ return io_fw_cfg_init(qts, 0x510);
+ }
}
-static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg)
+static inline void fw_cfg_uninit(QFWCFG *fw_cfg)
{
- io_fw_cfg_uninit(fw_cfg);
+ const char *arch = qtest_get_arch();
+
+ if (!strcmp(arch, "aarch64")) {
+ mm_fw_cfg_uninit(fw_cfg);
+ } else {
+ io_fw_cfg_uninit(fw_cfg);
+ }
}
#endif
diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index 6f92ce4135..5c58bf6e88 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -23,11 +23,11 @@
void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags)
{
uint64_t ram_size;
- QFWCFG *fw_cfg = pc_fw_cfg_init(qts);
+ QFWCFG *fw_cfg = 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);
/* clean-up */
- pc_fw_cfg_uninit(fw_cfg);
+ fw_cfg_uninit(fw_cfg);
}
--
2.19.1
- [PATCH 0/5] tests: Enable fw_cfg tests on AArch64, Xiang Zheng, 2019/12/03
- [PATCH 4/5] hw/arm/virt: Add FW_CFG_RAM_SIZE and FW_CFG_MAX_CPUS into fw_cfg, Xiang Zheng, 2019/12/03
- [PATCH 3/5] tests: fw_cfg: Use virt as default machine in fw_cfg-test.c, Xiang Zheng, 2019/12/03
- [PATCH 5/5] tests: Enable fw_cfg test on aarch64, Xiang Zheng, 2019/12/03
- [PATCH 2/5] tests: fw_cfg: Support read/write of fw_cfg registers on aarch64, Xiang Zheng, 2019/12/03
- [PATCH 1/5] tests: fw_cfg: Rename pc_fw_cfg_* to fw_cfg_*,
Xiang Zheng <=
- Re: [PATCH 0/5] tests: Enable fw_cfg tests on AArch64, Thomas Huth, 2019/12/03