exec: Expose 'target_page.h' API to user emulation

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>
This commit is contained in:
Philippe Mathieu-Daudé 2023-12-07 10:41:27 +01:00
parent 8501048b50
commit 75bbe6a4d2
5 changed files with 45 additions and 43 deletions

View File

@ -3523,7 +3523,7 @@ if get_option('b_lto')
pagevary = declare_dependency(link_with: pagevary) pagevary = declare_dependency(link_with: pagevary)
endif endif
common_ss.add(pagevary) 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('backends')
subdir('disas') subdir('disas')

44
page-target.c Normal file
View File

@ -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);
}

View File

@ -3540,36 +3540,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
return 0; 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) bool cpu_physical_memory_is_io(hwaddr phys_addr)
{ {
MemoryRegion*mr; MemoryRegion*mr;

View File

@ -18,5 +18,3 @@ subdir('sh4')
subdir('sparc') subdir('sparc')
subdir('tricore') subdir('tricore')
subdir('xtensa') subdir('xtensa')
specific_ss.add(files('target-common.c'))

View File

@ -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;
}