xref: /qemu/page-target.c (revision fc524567087c2537b5103cdfc1d41e4f442892b6)
1*75bbe6a4SPhilippe Mathieu-Daudé /*
2*75bbe6a4SPhilippe Mathieu-Daudé  * QEMU page values getters (target independent)
3*75bbe6a4SPhilippe Mathieu-Daudé  *
4*75bbe6a4SPhilippe Mathieu-Daudé  *  Copyright (c) 2003 Fabrice Bellard
5*75bbe6a4SPhilippe Mathieu-Daudé  *
6*75bbe6a4SPhilippe Mathieu-Daudé  * SPDX-License-Identifier: LGPL-2.1-or-later
7*75bbe6a4SPhilippe Mathieu-Daudé  */
8*75bbe6a4SPhilippe Mathieu-Daudé 
9*75bbe6a4SPhilippe Mathieu-Daudé #include "qemu/osdep.h"
10*75bbe6a4SPhilippe Mathieu-Daudé #include "exec/target_page.h"
11*75bbe6a4SPhilippe Mathieu-Daudé 
12*75bbe6a4SPhilippe Mathieu-Daudé /* Convert target pages to MiB (2**20). */
qemu_target_pages_to_MiB(size_t pages)13*75bbe6a4SPhilippe Mathieu-Daudé size_t qemu_target_pages_to_MiB(size_t pages)
14*75bbe6a4SPhilippe Mathieu-Daudé {
15*75bbe6a4SPhilippe Mathieu-Daudé     int page_bits = TARGET_PAGE_BITS;
16*75bbe6a4SPhilippe Mathieu-Daudé 
17*75bbe6a4SPhilippe Mathieu-Daudé     /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
18*75bbe6a4SPhilippe Mathieu-Daudé     g_assert(page_bits < 20);
19*75bbe6a4SPhilippe Mathieu-Daudé 
20*75bbe6a4SPhilippe Mathieu-Daudé     return pages >> (20 - page_bits);
21*75bbe6a4SPhilippe Mathieu-Daudé }
22