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