]> git.proxmox.com Git - mirror_qemu.git/blame - include/qom/cpu.h
target-i386: x86_cpu_get_phys_page_debug(): support 1GB page translation
[mirror_qemu.git] / include / qom / cpu.h
CommitLineData
dd83b06a
AF
1/*
2 * QEMU CPU model
3 *
4 * Copyright (c) 2012 SUSE LINUX Products GmbH
5 *
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.
10 *
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.
15 *
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>
19 */
20#ifndef QEMU_CPU_H
21#define QEMU_CPU_H
22
fcd7d003 23#include <signal.h>
6f03bef0 24#include <setjmp.h>
961f8395 25#include "hw/qdev-core.h"
c658b94f 26#include "exec/hwaddr.h"
bdc44640 27#include "qemu/queue.h"
1de7afc9 28#include "qemu/thread.h"
4917cf44 29#include "qemu/tls.h"
a23bbfda 30#include "qemu/typedefs.h"
dd83b06a 31
b5ba1cc6
QN
32typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
33 void *opaque);
c72bf468 34
577f42c0
AF
35/**
36 * vaddr:
37 * Type wide enough to contain any #target_ulong virtual address.
38 */
39typedef uint64_t vaddr;
40#define VADDR_PRId PRId64
41#define VADDR_PRIu PRIu64
42#define VADDR_PRIo PRIo64
43#define VADDR_PRIx PRIx64
44#define VADDR_PRIX PRIX64
45#define VADDR_MAX UINT64_MAX
46
dd83b06a
AF
47/**
48 * SECTION:cpu
49 * @section_id: QEMU-cpu
50 * @title: CPU Class
51 * @short_description: Base class for all CPUs
52 */
53
54#define TYPE_CPU "cpu"
55
56#define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU)
57#define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)
58#define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU)
59
60typedef struct CPUState CPUState;
61
c658b94f
AF
62typedef void (*CPUUnassignedAccess)(CPUState *cpu, hwaddr addr,
63 bool is_write, bool is_exec, int opaque,
64 unsigned size);
65
bdf7ae5b
AF
66struct TranslationBlock;
67
dd83b06a
AF
68/**
69 * CPUClass:
2b8c2754
AF
70 * @class_by_name: Callback to map -cpu command line model name to an
71 * instantiatable CPU type.
94a444b2 72 * @parse_features: Callback to parse command line arguments.
f5df5baf 73 * @reset: Callback to reset the #CPUState to its initial state.
91b1df8c 74 * @reset_dump_flags: #CPUDumpFlags to use for reset logging.
8c2e1b00 75 * @has_work: Callback for checking if there is work to do.
97a8ea5a 76 * @do_interrupt: Callback for interrupt handling.
c658b94f 77 * @do_unassigned_access: Callback for unassigned access handling.
f3659eee 78 * @memory_rw_debug: Callback for GDB memory access.
878096ee
AF
79 * @dump_state: Callback for dumping state.
80 * @dump_statistics: Callback for dumping statistics.
997395d3 81 * @get_arch_id: Callback for getting architecture-dependent CPU ID.
444d5590 82 * @get_paging_enabled: Callback for inquiring whether paging is enabled.
a23bbfda 83 * @get_memory_mapping: Callback for obtaining the memory mappings.
f45748f1 84 * @set_pc: Callback for setting the Program Counter register.
bdf7ae5b
AF
85 * @synchronize_from_tb: Callback for synchronizing state from a TCG
86 * #TranslationBlock.
7510454e 87 * @handle_mmu_fault: Callback for handling an MMU fault.
00b941e5 88 * @get_phys_page_debug: Callback for obtaining a physical address.
5b50e790
AF
89 * @gdb_read_register: Callback for letting GDB read a register.
90 * @gdb_write_register: Callback for letting GDB write a register.
b170fce3 91 * @vmsd: State description for migration.
a0e372f0 92 * @gdb_num_core_regs: Number of core registers accessible to GDB.
5b24c641 93 * @gdb_core_xml_file: File name for core registers GDB XML description.
dd83b06a
AF
94 *
95 * Represents a CPU family or model.
96 */
97typedef struct CPUClass {
98 /*< private >*/
961f8395 99 DeviceClass parent_class;
dd83b06a
AF
100 /*< public >*/
101
2b8c2754 102 ObjectClass *(*class_by_name)(const char *cpu_model);
94a444b2 103 void (*parse_features)(CPUState *cpu, char *str, Error **errp);
2b8c2754 104
dd83b06a 105 void (*reset)(CPUState *cpu);
91b1df8c 106 int reset_dump_flags;
8c2e1b00 107 bool (*has_work)(CPUState *cpu);
97a8ea5a 108 void (*do_interrupt)(CPUState *cpu);
c658b94f 109 CPUUnassignedAccess do_unassigned_access;
f3659eee
AF
110 int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
111 uint8_t *buf, int len, bool is_write);
878096ee
AF
112 void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
113 int flags);
114 void (*dump_statistics)(CPUState *cpu, FILE *f,
115 fprintf_function cpu_fprintf, int flags);
997395d3 116 int64_t (*get_arch_id)(CPUState *cpu);
444d5590 117 bool (*get_paging_enabled)(const CPUState *cpu);
a23bbfda
AF
118 void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list,
119 Error **errp);
f45748f1 120 void (*set_pc)(CPUState *cpu, vaddr value);
bdf7ae5b 121 void (*synchronize_from_tb)(CPUState *cpu, struct TranslationBlock *tb);
7510454e
AF
122 int (*handle_mmu_fault)(CPUState *cpu, vaddr address, int rw,
123 int mmu_index);
00b941e5 124 hwaddr (*get_phys_page_debug)(CPUState *cpu, vaddr addr);
5b50e790
AF
125 int (*gdb_read_register)(CPUState *cpu, uint8_t *buf, int reg);
126 int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
b170fce3 127
c72bf468
JF
128 int (*write_elf64_note)(WriteCoreDumpFunction f, CPUState *cpu,
129 int cpuid, void *opaque);
130 int (*write_elf64_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
131 void *opaque);
132 int (*write_elf32_note)(WriteCoreDumpFunction f, CPUState *cpu,
133 int cpuid, void *opaque);
134 int (*write_elf32_qemunote)(WriteCoreDumpFunction f, CPUState *cpu,
135 void *opaque);
a0e372f0
AF
136
137 const struct VMStateDescription *vmsd;
138 int gdb_num_core_regs;
5b24c641 139 const char *gdb_core_xml_file;
dd83b06a
AF
140} CPUClass;
141
28ecfd7a
AF
142#ifdef HOST_WORDS_BIGENDIAN
143typedef struct icount_decr_u16 {
144 uint16_t high;
145 uint16_t low;
146} icount_decr_u16;
147#else
148typedef struct icount_decr_u16 {
149 uint16_t low;
150 uint16_t high;
151} icount_decr_u16;
152#endif
153
f0c3c505
AF
154typedef struct CPUBreakpoint {
155 vaddr pc;
156 int flags; /* BP_* */
157 QTAILQ_ENTRY(CPUBreakpoint) entry;
158} CPUBreakpoint;
159
ff4700b0
AF
160typedef struct CPUWatchpoint {
161 vaddr vaddr;
162 vaddr len_mask;
163 int flags; /* BP_* */
164 QTAILQ_ENTRY(CPUWatchpoint) entry;
165} CPUWatchpoint;
166
a60f24b5 167struct KVMState;
f7575c96 168struct kvm_run;
a60f24b5 169
8cd70437
AF
170#define TB_JMP_CACHE_BITS 12
171#define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
172
dd83b06a
AF
173/**
174 * CPUState:
55e5c285 175 * @cpu_index: CPU index (informative).
ce3960eb
AF
176 * @nr_cores: Number of cores within this CPU package.
177 * @nr_threads: Number of threads within this CPU.
1b1ed8dc 178 * @numa_node: NUMA node this CPU is belonging to.
0d34282f 179 * @host_tid: Host thread ID.
0315c31c 180 * @running: #true if CPU is currently running (usermode).
61a46217 181 * @created: Indicates whether the CPU thread has been successfully created.
259186a7
AF
182 * @interrupt_request: Indicates a pending interrupt request.
183 * @halted: Nonzero if the CPU is in suspended state.
4fdeee7c 184 * @stop: Indicates a pending stop request.
f324e766 185 * @stopped: Indicates the CPU has been artificially stopped.
378df4b2
PM
186 * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this
187 * CPU and return to its top level loop.
ed2803da 188 * @singlestep_enabled: Flags for single-stepping.
efee7340 189 * @icount_extra: Instructions until next timer event.
28ecfd7a
AF
190 * @icount_decr: Number of cycles left, with interrupt flag in high bit.
191 * This allows a single read-compare-cbranch-write sequence to test
192 * for both decrementer underflow and exceptions.
99df7dce 193 * @can_do_io: Nonzero if memory-mapped IO is safe.
c05efcb1 194 * @env_ptr: Pointer to subclass-specific CPUArchState field.
d77953b9 195 * @current_tb: Currently executing TB.
eac8b355 196 * @gdb_regs: Additional GDB registers.
a0e372f0 197 * @gdb_num_regs: Number of total registers accessible to GDB.
35143f01 198 * @gdb_num_g_regs: Number of registers in GDB 'g' packets.
182735ef 199 * @next_cpu: Next CPU sharing TB cache.
0429a971 200 * @opaque: User data.
93afeade
AF
201 * @mem_io_pc: Host Program Counter at which the memory was accessed.
202 * @mem_io_vaddr: Target virtual address at which the memory was accessed.
8737c51c 203 * @kvm_fd: vCPU file descriptor for KVM.
dd83b06a
AF
204 *
205 * State of one CPU core or thread.
206 */
207struct CPUState {
208 /*< private >*/
961f8395 209 DeviceState parent_obj;
dd83b06a
AF
210 /*< public >*/
211
ce3960eb
AF
212 int nr_cores;
213 int nr_threads;
1b1ed8dc 214 int numa_node;
ce3960eb 215
814e612e 216 struct QemuThread *thread;
bcba2a72
AF
217#ifdef _WIN32
218 HANDLE hThread;
219#endif
9f09e18a 220 int thread_id;
0d34282f 221 uint32_t host_tid;
0315c31c 222 bool running;
f5c121b8 223 struct QemuCond *halt_cond;
c64ca814 224 struct qemu_work_item *queued_work_first, *queued_work_last;
216fc9a4 225 bool thread_kicked;
61a46217 226 bool created;
4fdeee7c 227 bool stop;
f324e766 228 bool stopped;
fcd7d003 229 volatile sig_atomic_t exit_request;
259186a7 230 uint32_t interrupt_request;
ed2803da 231 int singlestep_enabled;
efee7340 232 int64_t icount_extra;
6f03bef0 233 sigjmp_buf jmp_env;
bcba2a72 234
09daed84
EI
235 AddressSpace *as;
236 MemoryListener *tcg_as_listener;
237
c05efcb1 238 void *env_ptr; /* CPUArchState */
d77953b9 239 struct TranslationBlock *current_tb;
8cd70437 240 struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE];
eac8b355 241 struct GDBRegisterState *gdb_regs;
a0e372f0 242 int gdb_num_regs;
35143f01 243 int gdb_num_g_regs;
bdc44640 244 QTAILQ_ENTRY(CPUState) node;
d77953b9 245
f0c3c505
AF
246 /* ice debug support */
247 QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints;
248
ff4700b0
AF
249 QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints;
250 CPUWatchpoint *watchpoint_hit;
251
0429a971
AF
252 void *opaque;
253
93afeade
AF
254 /* In order to avoid passing too many arguments to the MMIO helpers,
255 * we store some rarely used information in the CPU context.
256 */
257 uintptr_t mem_io_pc;
258 vaddr mem_io_vaddr;
259
8737c51c 260 int kvm_fd;
20d695a9 261 bool kvm_vcpu_dirty;
a60f24b5 262 struct KVMState *kvm_state;
f7575c96 263 struct kvm_run *kvm_run;
8737c51c 264
f5df5baf 265 /* TODO Move common fields from CPUArchState here. */
55e5c285 266 int cpu_index; /* used by alpha TCG */
259186a7 267 uint32_t halted; /* used by alpha, cris, ppc TCG */
28ecfd7a
AF
268 union {
269 uint32_t u32;
270 icount_decr_u16 u16;
271 } icount_decr;
99df7dce 272 uint32_t can_do_io;
27103424 273 int32_t exception_index; /* used by m68k TCG */
7e4fb26d
RH
274
275 /* Note that this is accessed at the start of every TB via a negative
276 offset from AREG0. Leave this field at the end so as to make the
277 (absolute value) offset as small as possible. This reduces code
278 size, especially for hosts without large memory offsets. */
279 volatile sig_atomic_t tcg_exit_req;
dd83b06a
AF
280};
281
bdc44640
AF
282QTAILQ_HEAD(CPUTailQ, CPUState);
283extern struct CPUTailQ cpus;
284#define CPU_NEXT(cpu) QTAILQ_NEXT(cpu, node)
285#define CPU_FOREACH(cpu) QTAILQ_FOREACH(cpu, &cpus, node)
286#define CPU_FOREACH_SAFE(cpu, next_cpu) \
287 QTAILQ_FOREACH_SAFE(cpu, &cpus, node, next_cpu)
288#define first_cpu QTAILQ_FIRST(&cpus)
182735ef 289
4917cf44
AF
290DECLARE_TLS(CPUState *, current_cpu);
291#define current_cpu tls_var(current_cpu)
292
444d5590
AF
293/**
294 * cpu_paging_enabled:
295 * @cpu: The CPU whose state is to be inspected.
296 *
297 * Returns: %true if paging is enabled, %false otherwise.
298 */
299bool cpu_paging_enabled(const CPUState *cpu);
300
a23bbfda
AF
301/**
302 * cpu_get_memory_mapping:
303 * @cpu: The CPU whose memory mappings are to be obtained.
304 * @list: Where to write the memory mappings to.
305 * @errp: Pointer for reporting an #Error.
306 */
307void cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
308 Error **errp);
309
c72bf468
JF
310/**
311 * cpu_write_elf64_note:
312 * @f: pointer to a function that writes memory to a file
313 * @cpu: The CPU whose memory is to be dumped
314 * @cpuid: ID number of the CPU
315 * @opaque: pointer to the CPUState struct
316 */
317int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
318 int cpuid, void *opaque);
319
320/**
321 * cpu_write_elf64_qemunote:
322 * @f: pointer to a function that writes memory to a file
323 * @cpu: The CPU whose memory is to be dumped
324 * @cpuid: ID number of the CPU
325 * @opaque: pointer to the CPUState struct
326 */
327int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
328 void *opaque);
329
330/**
331 * cpu_write_elf32_note:
332 * @f: pointer to a function that writes memory to a file
333 * @cpu: The CPU whose memory is to be dumped
334 * @cpuid: ID number of the CPU
335 * @opaque: pointer to the CPUState struct
336 */
337int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
338 int cpuid, void *opaque);
339
340/**
341 * cpu_write_elf32_qemunote:
342 * @f: pointer to a function that writes memory to a file
343 * @cpu: The CPU whose memory is to be dumped
344 * @cpuid: ID number of the CPU
345 * @opaque: pointer to the CPUState struct
346 */
347int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
348 void *opaque);
dd83b06a 349
878096ee
AF
350/**
351 * CPUDumpFlags:
352 * @CPU_DUMP_CODE:
353 * @CPU_DUMP_FPU: dump FPU register state, not just integer
354 * @CPU_DUMP_CCOP: dump info about TCG QEMU's condition code optimization state
355 */
356enum CPUDumpFlags {
357 CPU_DUMP_CODE = 0x00010000,
358 CPU_DUMP_FPU = 0x00020000,
359 CPU_DUMP_CCOP = 0x00040000,
360};
361
362/**
363 * cpu_dump_state:
364 * @cpu: The CPU whose state is to be dumped.
365 * @f: File to dump to.
366 * @cpu_fprintf: Function to dump with.
367 * @flags: Flags what to dump.
368 *
369 * Dumps CPU state.
370 */
371void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
372 int flags);
373
374/**
375 * cpu_dump_statistics:
376 * @cpu: The CPU whose state is to be dumped.
377 * @f: File to dump to.
378 * @cpu_fprintf: Function to dump with.
379 * @flags: Flags what to dump.
380 *
381 * Dumps CPU statistics.
382 */
383void cpu_dump_statistics(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
384 int flags);
385
00b941e5
AF
386#ifndef CONFIG_USER_ONLY
387/**
388 * cpu_get_phys_page_debug:
389 * @cpu: The CPU to obtain the physical page address for.
390 * @addr: The virtual address.
391 *
392 * Obtains the physical page corresponding to a virtual one.
393 * Use it only for debugging because no protection checks are done.
394 *
395 * Returns: Corresponding physical page address or -1 if no page found.
396 */
397static inline hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr)
398{
399 CPUClass *cc = CPU_GET_CLASS(cpu);
400
401 return cc->get_phys_page_debug(cpu, addr);
402}
403#endif
404
dd83b06a
AF
405/**
406 * cpu_reset:
407 * @cpu: The CPU whose state is to be reset.
408 */
409void cpu_reset(CPUState *cpu);
410
2b8c2754
AF
411/**
412 * cpu_class_by_name:
413 * @typename: The CPU base type.
414 * @cpu_model: The model string without any parameters.
415 *
416 * Looks up a CPU #ObjectClass matching name @cpu_model.
417 *
418 * Returns: A #CPUClass or %NULL if not matching class is found.
419 */
420ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
421
9262685b
AF
422/**
423 * cpu_generic_init:
424 * @typename: The CPU base type.
425 * @cpu_model: The model string including optional parameters.
426 *
427 * Instantiates a CPU, processes optional parameters and realizes the CPU.
428 *
429 * Returns: A #CPUState or %NULL if an error occurred.
430 */
431CPUState *cpu_generic_init(const char *typename, const char *cpu_model);
432
3993c6bd 433/**
8c2e1b00 434 * cpu_has_work:
3993c6bd
AF
435 * @cpu: The vCPU to check.
436 *
437 * Checks whether the CPU has work to do.
438 *
439 * Returns: %true if the CPU has work, %false otherwise.
440 */
8c2e1b00
AF
441static inline bool cpu_has_work(CPUState *cpu)
442{
443 CPUClass *cc = CPU_GET_CLASS(cpu);
444
445 g_assert(cc->has_work);
446 return cc->has_work(cpu);
447}
3993c6bd 448
60e82579
AF
449/**
450 * qemu_cpu_is_self:
451 * @cpu: The vCPU to check against.
452 *
453 * Checks whether the caller is executing on the vCPU thread.
454 *
455 * Returns: %true if called from @cpu's thread, %false otherwise.
456 */
457bool qemu_cpu_is_self(CPUState *cpu);
458
c08d7424
AF
459/**
460 * qemu_cpu_kick:
461 * @cpu: The vCPU to kick.
462 *
463 * Kicks @cpu's thread.
464 */
465void qemu_cpu_kick(CPUState *cpu);
466
2fa45344
AF
467/**
468 * cpu_is_stopped:
469 * @cpu: The CPU to check.
470 *
471 * Checks whether the CPU is stopped.
472 *
473 * Returns: %true if run state is not running or if artificially stopped;
474 * %false otherwise.
475 */
476bool cpu_is_stopped(CPUState *cpu);
477
f100f0b3
AF
478/**
479 * run_on_cpu:
480 * @cpu: The vCPU to run on.
481 * @func: The function to be executed.
482 * @data: Data to pass to the function.
483 *
484 * Schedules the function @func for execution on the vCPU @cpu.
485 */
486void run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
487
3c02270d
CV
488/**
489 * async_run_on_cpu:
490 * @cpu: The vCPU to run on.
491 * @func: The function to be executed.
492 * @data: Data to pass to the function.
493 *
494 * Schedules the function @func for execution on the vCPU @cpu asynchronously.
495 */
496void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data);
497
38d8f5c8
AF
498/**
499 * qemu_get_cpu:
500 * @index: The CPUState@cpu_index value of the CPU to obtain.
501 *
502 * Gets a CPU matching @index.
503 *
504 * Returns: The CPU or %NULL if there is no matching CPU.
505 */
506CPUState *qemu_get_cpu(int index);
507
69e5ff06
IM
508/**
509 * cpu_exists:
510 * @id: Guest-exposed CPU ID to lookup.
511 *
512 * Search for CPU with specified ID.
513 *
514 * Returns: %true - CPU is found, %false - CPU isn't found.
515 */
516bool cpu_exists(int64_t id);
517
c3affe56
AF
518#ifndef CONFIG_USER_ONLY
519
520typedef void (*CPUInterruptHandler)(CPUState *, int);
521
522extern CPUInterruptHandler cpu_interrupt_handler;
523
524/**
525 * cpu_interrupt:
526 * @cpu: The CPU to set an interrupt on.
527 * @mask: The interupts to set.
528 *
529 * Invokes the interrupt handler.
530 */
531static inline void cpu_interrupt(CPUState *cpu, int mask)
532{
533 cpu_interrupt_handler(cpu, mask);
534}
535
536#else /* USER_ONLY */
537
538void cpu_interrupt(CPUState *cpu, int mask);
539
540#endif /* USER_ONLY */
541
c658b94f
AF
542#ifndef CONFIG_USER_ONLY
543
544static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
545 bool is_write, bool is_exec,
546 int opaque, unsigned size)
547{
548 CPUClass *cc = CPU_GET_CLASS(cpu);
549
550 if (cc->do_unassigned_access) {
551 cc->do_unassigned_access(cpu, addr, is_write, is_exec, opaque, size);
552 }
553}
554
555#endif
556
d8ed887b
AF
557/**
558 * cpu_reset_interrupt:
559 * @cpu: The CPU to clear the interrupt on.
560 * @mask: The interrupt mask to clear.
561 *
562 * Resets interrupts on the vCPU @cpu.
563 */
564void cpu_reset_interrupt(CPUState *cpu, int mask);
565
60a3e17a
AF
566/**
567 * cpu_exit:
568 * @cpu: The CPU to exit.
569 *
570 * Requests the CPU @cpu to exit execution.
571 */
572void cpu_exit(CPUState *cpu);
573
2993683b
IM
574/**
575 * cpu_resume:
576 * @cpu: The CPU to resume.
577 *
578 * Resumes CPU, i.e. puts CPU into runnable state.
579 */
580void cpu_resume(CPUState *cpu);
dd83b06a 581
c643bed9
AF
582/**
583 * qemu_init_vcpu:
584 * @cpu: The vCPU to initialize.
585 *
586 * Initializes a vCPU.
587 */
588void qemu_init_vcpu(CPUState *cpu);
589
3825b28f
AF
590#define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */
591#define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */
592#define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */
593
594/**
595 * cpu_single_step:
596 * @cpu: CPU to the flags for.
597 * @enabled: Flags to enable.
598 *
599 * Enables or disables single-stepping for @cpu.
600 */
601void cpu_single_step(CPUState *cpu, int enabled);
602
b3310ab3
AF
603/* Breakpoint/watchpoint flags */
604#define BP_MEM_READ 0x01
605#define BP_MEM_WRITE 0x02
606#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE)
607#define BP_STOP_BEFORE_ACCESS 0x04
608#define BP_WATCHPOINT_HIT 0x08
609#define BP_GDB 0x10
610#define BP_CPU 0x20
611
612int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
613 CPUBreakpoint **breakpoint);
614int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags);
615void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint);
616void cpu_breakpoint_remove_all(CPUState *cpu, int mask);
617
75a34036
AF
618int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
619 int flags, CPUWatchpoint **watchpoint);
620int cpu_watchpoint_remove(CPUState *cpu, vaddr addr,
621 vaddr len, int flags);
622void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint);
623void cpu_watchpoint_remove_all(CPUState *cpu, int mask);
624
a47dddd7
AF
625void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
626 GCC_FMT_ATTR(2, 3);
627
1a1562f5
AF
628#ifdef CONFIG_SOFTMMU
629extern const struct VMStateDescription vmstate_cpu_common;
630#else
631#define vmstate_cpu_common vmstate_dummy
632#endif
633
634#define VMSTATE_CPU() { \
635 .name = "parent_obj", \
636 .size = sizeof(CPUState), \
637 .vmsd = &vmstate_cpu_common, \
638 .flags = VMS_STRUCT, \
639 .offset = 0, \
640}
641
dd83b06a 642#endif