1 /* 2 * Declarations for functions which are internal to the memory subsystem. 3 * 4 * Copyright 2011 Red Hat, Inc. and/or its affiliates 5 * 6 * Authors: 7 * Avi Kivity <avi@redhat.com> 8 * 9 * This work is licensed under the terms of the GNU GPL, version 2 or 10 * later. See the COPYING file in the top-level directory. 11 * 12 */ 13 14 #ifndef MEMORY_INTERNAL_H 15 #define MEMORY_INTERNAL_H 16 17 #ifndef CONFIG_USER_ONLY 18 static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) 19 { 20 return fv->dispatch; 21 } 22 23 static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as) 24 { 25 return flatview_to_dispatch(address_space_to_flatview(as)); 26 } 27 28 FlatView *address_space_get_flatview(AddressSpace *as); 29 void flatview_unref(FlatView *view); 30 31 extern const MemoryRegionOps unassigned_mem_ops; 32 33 void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); 34 AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); 35 void address_space_dispatch_compact(AddressSpaceDispatch *d); 36 void address_space_dispatch_free(AddressSpaceDispatch *d); 37 38 void mtree_print_dispatch(struct AddressSpaceDispatch *d, 39 MemoryRegion *root); 40 41 /* returns true if end is big endian. */ 42 static inline bool devend_big_endian(enum device_endian end) 43 { 44 QEMU_BUILD_BUG_ON(DEVICE_HOST_ENDIAN != DEVICE_LITTLE_ENDIAN && 45 DEVICE_HOST_ENDIAN != DEVICE_BIG_ENDIAN); 46 47 if (end == DEVICE_NATIVE_ENDIAN) { 48 return target_words_bigendian(); 49 } 50 return end == DEVICE_BIG_ENDIAN; 51 } 52 53 /* enum device_endian to MemOp. */ 54 static inline MemOp devend_memop(enum device_endian end) 55 { 56 return devend_big_endian(end) ? MO_BE : MO_LE; 57 } 58 59 #endif 60 #endif 61