| 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 | void machine_memory_init(void); |
| 18 | |
| 19 | static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) |
| 20 | { |
| 21 | return fv->dispatch; |
| 22 | } |
| 23 | |
| 24 | static inline |
| 25 | AddressSpaceDispatch *address_space_to_dispatch(const AddressSpace *as) |
| 26 | { |
| 27 | return flatview_to_dispatch(address_space_to_flatview(as)); |
| 28 | } |
| 29 | |
| 30 | FlatView *address_space_get_flatview(const AddressSpace *as); |
| 31 | void flatview_unref(FlatView *view); |
| 32 | |
| 33 | extern const MemoryRegionOps unassigned_mem_ops; |
| 34 | |
| 35 | void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); |
| 36 | AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); |
| 37 | void address_space_dispatch_compact(AddressSpaceDispatch *d); |
| 38 | void address_space_dispatch_free(AddressSpaceDispatch *d); |
| 39 | |
| 40 | void mtree_print_dispatch(struct AddressSpaceDispatch *d, |
| 41 | MemoryRegion *root); |
| 42 | |
| 43 | /* returns true if end is big endian. */ |
| 44 | static inline bool devend_big_endian(enum device_endian end) |
| 45 | { |
| 46 | #ifndef TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API |
| 47 | if (end == DEVICE_NATIVE_ENDIAN) { |
| 48 | return target_big_endian(); |
| 49 | } |
| 50 | #endif |
| 51 | return end == DEVICE_BIG_ENDIAN; |
| 52 | } |
| 53 | |
| 54 | /* enum device_endian to MemOp. */ |
| 55 | static inline MemOp devend_memop(enum device_endian end) |
| 56 | { |
| 57 | return devend_big_endian(end) ? MO_BE : MO_LE; |
| 58 | } |
| 59 | |
| 60 | #endif |