2 * QEMU CPU model (system emulation specific)
4 * Copyright (c) 2012-2014 SUSE LINUX Products GmbH
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see
18 * <http://www.gnu.org/licenses/gpl-2.0.html>
21 #include "qemu/osdep.h"
22 #include "qapi/error.h"
23 #include "exec/tswap.h"
24 #include "hw/core/sysemu-cpu-ops.h"
26 bool cpu_paging_enabled(const CPUState
*cpu
)
28 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
30 if (cc
->sysemu_ops
->get_paging_enabled
) {
31 return cc
->sysemu_ops
->get_paging_enabled(cpu
);
37 bool cpu_get_memory_mapping(CPUState
*cpu
, MemoryMappingList
*list
,
40 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
42 if (cc
->sysemu_ops
->get_memory_mapping
) {
43 return cc
->sysemu_ops
->get_memory_mapping(cpu
, list
, errp
);
46 error_setg(errp
, "Obtaining memory mappings is unsupported on this CPU.");
50 hwaddr
cpu_get_phys_page_attrs_debug(CPUState
*cpu
, vaddr addr
,
53 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
55 if (cc
->sysemu_ops
->get_phys_page_attrs_debug
) {
56 return cc
->sysemu_ops
->get_phys_page_attrs_debug(cpu
, addr
, attrs
);
58 /* Fallback for CPUs which don't implement the _attrs_ hook */
59 *attrs
= MEMTXATTRS_UNSPECIFIED
;
60 return cc
->sysemu_ops
->get_phys_page_debug(cpu
, addr
);
63 hwaddr
cpu_get_phys_page_debug(CPUState
*cpu
, vaddr addr
)
65 MemTxAttrs attrs
= {};
67 return cpu_get_phys_page_attrs_debug(cpu
, addr
, &attrs
);
70 int cpu_asidx_from_attrs(CPUState
*cpu
, MemTxAttrs attrs
)
74 if (cpu
->cc
->sysemu_ops
->asidx_from_attrs
) {
75 ret
= cpu
->cc
->sysemu_ops
->asidx_from_attrs(cpu
, attrs
);
76 assert(ret
< cpu
->num_ases
&& ret
>= 0);
81 int cpu_write_elf32_qemunote(WriteCoreDumpFunction f
, CPUState
*cpu
,
84 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
86 if (!cc
->sysemu_ops
->write_elf32_qemunote
) {
89 return (*cc
->sysemu_ops
->write_elf32_qemunote
)(f
, cpu
, opaque
);
92 int cpu_write_elf32_note(WriteCoreDumpFunction f
, CPUState
*cpu
,
93 int cpuid
, void *opaque
)
95 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
97 if (!cc
->sysemu_ops
->write_elf32_note
) {
100 return (*cc
->sysemu_ops
->write_elf32_note
)(f
, cpu
, cpuid
, opaque
);
103 int cpu_write_elf64_qemunote(WriteCoreDumpFunction f
, CPUState
*cpu
,
106 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
108 if (!cc
->sysemu_ops
->write_elf64_qemunote
) {
111 return (*cc
->sysemu_ops
->write_elf64_qemunote
)(f
, cpu
, opaque
);
114 int cpu_write_elf64_note(WriteCoreDumpFunction f
, CPUState
*cpu
,
115 int cpuid
, void *opaque
)
117 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
119 if (!cc
->sysemu_ops
->write_elf64_note
) {
122 return (*cc
->sysemu_ops
->write_elf64_note
)(f
, cpu
, cpuid
, opaque
);
125 bool cpu_virtio_is_big_endian(CPUState
*cpu
)
127 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
129 if (cc
->sysemu_ops
->virtio_is_big_endian
) {
130 return cc
->sysemu_ops
->virtio_is_big_endian(cpu
);
132 return target_words_bigendian();
135 GuestPanicInformation
*cpu_get_crash_info(CPUState
*cpu
)
137 CPUClass
*cc
= CPU_GET_CLASS(cpu
);
138 GuestPanicInformation
*res
= NULL
;
140 if (cc
->sysemu_ops
->get_crash_info
) {
141 res
= cc
->sysemu_ops
->get_crash_info(cpu
);