blob: 8fcd5443b526b9cbe9d8872d0ec5ad9083aaf687 [file] [log] [blame]
Philippe Mathieu-Daudé75bbe6a2023-12-07 10:41:27 +01001/*
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"
Philippe Mathieu-Daudé75bbe6a2023-12-07 10:41:27 +010011
Philippe Mathieu-Daudé75bbe6a2023-12-07 10:41:27 +010012/* Convert target pages to MiB (2**20). */
13size_t qemu_target_pages_to_MiB(size_t pages)
14{
15 int page_bits = TARGET_PAGE_BITS;
16
17 /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
18 g_assert(page_bits < 20);
19
20 return pages >> (20 - page_bits);
21}