[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/38] exec: Expose 'target_page.h' API to user emulation
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 04/38] exec: Expose 'target_page.h' API to user emulation |
Date: |
Fri, 26 Apr 2024 21:41:24 +0200 |
User-only objects might benefit from the "exec/target_page.h"
API, which allows to build some objects once for all targets.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20231211212003.21686-3-philmd@linaro.org>
---
meson.build | 2 +-
page-target.c | 44 ++++++++++++++++++++++++++++++++++++++++++
system/physmem.c | 30 ----------------------------
target/target-common.c | 10 ----------
target/meson.build | 2 --
5 files changed, 45 insertions(+), 43 deletions(-)
create mode 100644 page-target.c
delete mode 100644 target/target-common.c
diff --git a/meson.build b/meson.build
index 96fdc6dfd2..5db2dbc12e 100644
--- a/meson.build
+++ b/meson.build
@@ -3523,7 +3523,7 @@ if get_option('b_lto')
pagevary = declare_dependency(link_with: pagevary)
endif
common_ss.add(pagevary)
-specific_ss.add(files('page-vary-target.c'))
+specific_ss.add(files('page-target.c', 'page-vary-target.c'))
subdir('backends')
subdir('disas')
diff --git a/page-target.c b/page-target.c
new file mode 100644
index 0000000000..82211c8593
--- /dev/null
+++ b/page-target.c
@@ -0,0 +1,44 @@
+/*
+ * QEMU page values getters (target independent)
+ *
+ * Copyright (c) 2003 Fabrice Bellard
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "exec/target_page.h"
+#include "exec/cpu-defs.h"
+#include "cpu.h"
+#include "exec/cpu-all.h"
+
+size_t qemu_target_page_size(void)
+{
+ return TARGET_PAGE_SIZE;
+}
+
+int qemu_target_page_mask(void)
+{
+ return TARGET_PAGE_MASK;
+}
+
+int qemu_target_page_bits(void)
+{
+ return TARGET_PAGE_BITS;
+}
+
+int qemu_target_page_bits_min(void)
+{
+ return TARGET_PAGE_BITS_MIN;
+}
+
+/* Convert target pages to MiB (2**20). */
+size_t qemu_target_pages_to_MiB(size_t pages)
+{
+ int page_bits = TARGET_PAGE_BITS;
+
+ /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
+ g_assert(page_bits < 20);
+
+ return pages >> (20 - page_bits);
+}
diff --git a/system/physmem.c b/system/physmem.c
index c3d04ca921..1a81c226ba 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3540,36 +3540,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
return 0;
}
-/*
- * Allows code that needs to deal with migration bitmaps etc to still be built
- * target independent.
- */
-size_t qemu_target_page_size(void)
-{
- return TARGET_PAGE_SIZE;
-}
-
-int qemu_target_page_bits(void)
-{
- return TARGET_PAGE_BITS;
-}
-
-int qemu_target_page_bits_min(void)
-{
- return TARGET_PAGE_BITS_MIN;
-}
-
-/* Convert target pages to MiB (2**20). */
-size_t qemu_target_pages_to_MiB(size_t pages)
-{
- int page_bits = TARGET_PAGE_BITS;
-
- /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
- g_assert(page_bits < 20);
-
- return pages >> (20 - page_bits);
-}
-
bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegion*mr;
diff --git a/target/target-common.c b/target/target-common.c
deleted file mode 100644
index 903b10cfe4..0000000000
--- a/target/target-common.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#include "qemu/osdep.h"
-
-#include "cpu.h"
-#include "exec/target_page.h"
-
-int qemu_target_page_mask(void)
-{
- return TARGET_PAGE_MASK;
-}
diff --git a/target/meson.build b/target/meson.build
index 59b46b2ef4..1c2e6f2b19 100644
--- a/target/meson.build
+++ b/target/meson.build
@@ -18,5 +18,3 @@ subdir('sh4')
subdir('sparc')
subdir('tricore')
subdir('xtensa')
-
-specific_ss.add(files('target-common.c'))
--
2.41.0
- [PULL 00/38] Exec / accelerators patches, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 02/38] exec: Reduce tlb_set_dirty() declaration scope, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 01/38] exec: Rename NEED_CPU_H -> COMPILING_PER_TARGET, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 03/38] exec: Include 'cpu.h' before validating CPUArchState placement, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 04/38] exec: Expose 'target_page.h' API to user emulation,
Philippe Mathieu-Daudé <=
- [PULL 05/38] accel: Include missing 'exec/cpu_ldst.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 06/38] gdbstub: Include missing 'hw/core/cpu.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 07/38] gdbstub: Simplify #ifdef'ry in helpers.h, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 08/38] gdbstub: Avoid including 'cpu.h' in 'gdbstub/helpers.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 09/38] semihosting/uaccess: Avoid including 'cpu.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 10/38] semihosting/guestfd: Remove unused 'semihosting/uaccess.h' header, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 11/38] target: Define TCG_GUEST_DEFAULT_MO in 'cpu-param.h', Philippe Mathieu-Daudé, 2024/04/26
- [PULL 13/38] target/sparc: Replace abi_ulong by uint32_t for TARGET_ABI32, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 12/38] target/ppc/excp_helper: Avoid 'abi_ptr' in system emulation, Philippe Mathieu-Daudé, 2024/04/26
- [PULL 14/38] target/i386: Include missing 'exec/exec-all.h' header, Philippe Mathieu-Daudé, 2024/04/26