Skip to content

Commit 75bbe6a

Browse files
committed
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é <[email protected]> Reviewed-by: Warner Losh <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]>
1 parent 8501048 commit 75bbe6a

File tree

5 files changed

+45
-43
lines changed

5 files changed

+45
-43
lines changed

meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -3523,7 +3523,7 @@ if get_option('b_lto')
35233523
pagevary = declare_dependency(link_with: pagevary)
35243524
endif
35253525
common_ss.add(pagevary)
3526-
specific_ss.add(files('page-vary-target.c'))
3526+
specific_ss.add(files('page-target.c', 'page-vary-target.c'))
35273527

35283528
subdir('backends')
35293529
subdir('disas')

page-target.c

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* QEMU page values getters (target independent)
3+
*
4+
* Copyright (c) 2003 Fabrice Bellard
5+
*
6+
* SPDX-License-Identifier: LGPL-2.1-or-later
7+
*/
8+
9+
#include "qemu/osdep.h"
10+
#include "exec/target_page.h"
11+
#include "exec/cpu-defs.h"
12+
#include "cpu.h"
13+
#include "exec/cpu-all.h"
14+
15+
size_t qemu_target_page_size(void)
16+
{
17+
return TARGET_PAGE_SIZE;
18+
}
19+
20+
int qemu_target_page_mask(void)
21+
{
22+
return TARGET_PAGE_MASK;
23+
}
24+
25+
int qemu_target_page_bits(void)
26+
{
27+
return TARGET_PAGE_BITS;
28+
}
29+
30+
int qemu_target_page_bits_min(void)
31+
{
32+
return TARGET_PAGE_BITS_MIN;
33+
}
34+
35+
/* Convert target pages to MiB (2**20). */
36+
size_t qemu_target_pages_to_MiB(size_t pages)
37+
{
38+
int page_bits = TARGET_PAGE_BITS;
39+
40+
/* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
41+
g_assert(page_bits < 20);
42+
43+
return pages >> (20 - page_bits);
44+
}

system/physmem.c

-30
Original file line numberDiff line numberDiff line change
@@ -3540,36 +3540,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
35403540
return 0;
35413541
}
35423542

3543-
/*
3544-
* Allows code that needs to deal with migration bitmaps etc to still be built
3545-
* target independent.
3546-
*/
3547-
size_t qemu_target_page_size(void)
3548-
{
3549-
return TARGET_PAGE_SIZE;
3550-
}
3551-
3552-
int qemu_target_page_bits(void)
3553-
{
3554-
return TARGET_PAGE_BITS;
3555-
}
3556-
3557-
int qemu_target_page_bits_min(void)
3558-
{
3559-
return TARGET_PAGE_BITS_MIN;
3560-
}
3561-
3562-
/* Convert target pages to MiB (2**20). */
3563-
size_t qemu_target_pages_to_MiB(size_t pages)
3564-
{
3565-
int page_bits = TARGET_PAGE_BITS;
3566-
3567-
/* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
3568-
g_assert(page_bits < 20);
3569-
3570-
return pages >> (20 - page_bits);
3571-
}
3572-
35733543
bool cpu_physical_memory_is_io(hwaddr phys_addr)
35743544
{
35753545
MemoryRegion*mr;

target/meson.build

-2
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,3 @@ subdir('sh4')
1818
subdir('sparc')
1919
subdir('tricore')
2020
subdir('xtensa')
21-
22-
specific_ss.add(files('target-common.c'))

target/target-common.c

-10
This file was deleted.

0 commit comments

Comments
 (0)