xref: /openbmc/qemu/page-target.c (revision 2f95279a)
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 }
45