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é #include "exec/cpu-defs.h" 12*75bbe6a4SPhilippe Mathieu-Daudé #include "cpu.h" 13*75bbe6a4SPhilippe Mathieu-Daudé #include "exec/cpu-all.h" 14*75bbe6a4SPhilippe Mathieu-Daudé qemu_target_page_size(void)15*75bbe6a4SPhilippe Mathieu-Daudésize_t qemu_target_page_size(void) 16*75bbe6a4SPhilippe Mathieu-Daudé { 17*75bbe6a4SPhilippe Mathieu-Daudé return TARGET_PAGE_SIZE; 18*75bbe6a4SPhilippe Mathieu-Daudé } 19*75bbe6a4SPhilippe Mathieu-Daudé qemu_target_page_mask(void)20*75bbe6a4SPhilippe Mathieu-Daudéint qemu_target_page_mask(void) 21*75bbe6a4SPhilippe Mathieu-Daudé { 22*75bbe6a4SPhilippe Mathieu-Daudé return TARGET_PAGE_MASK; 23*75bbe6a4SPhilippe Mathieu-Daudé } 24*75bbe6a4SPhilippe Mathieu-Daudé qemu_target_page_bits(void)25*75bbe6a4SPhilippe Mathieu-Daudéint qemu_target_page_bits(void) 26*75bbe6a4SPhilippe Mathieu-Daudé { 27*75bbe6a4SPhilippe Mathieu-Daudé return TARGET_PAGE_BITS; 28*75bbe6a4SPhilippe Mathieu-Daudé } 29*75bbe6a4SPhilippe Mathieu-Daudé qemu_target_page_bits_min(void)30*75bbe6a4SPhilippe Mathieu-Daudéint qemu_target_page_bits_min(void) 31*75bbe6a4SPhilippe Mathieu-Daudé { 32*75bbe6a4SPhilippe Mathieu-Daudé return TARGET_PAGE_BITS_MIN; 33*75bbe6a4SPhilippe Mathieu-Daudé } 34*75bbe6a4SPhilippe Mathieu-Daudé 35*75bbe6a4SPhilippe Mathieu-Daudé /* Convert target pages to MiB (2**20). */ qemu_target_pages_to_MiB(size_t pages)36*75bbe6a4SPhilippe Mathieu-Daudésize_t qemu_target_pages_to_MiB(size_t pages) 37*75bbe6a4SPhilippe Mathieu-Daudé { 38*75bbe6a4SPhilippe Mathieu-Daudé int page_bits = TARGET_PAGE_BITS; 39*75bbe6a4SPhilippe Mathieu-Daudé 40*75bbe6a4SPhilippe Mathieu-Daudé /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ 41*75bbe6a4SPhilippe Mathieu-Daudé g_assert(page_bits < 20); 42*75bbe6a4SPhilippe Mathieu-Daudé 43*75bbe6a4SPhilippe Mathieu-Daudé return pages >> (20 - page_bits); 44*75bbe6a4SPhilippe Mathieu-Daudé } 45