1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "qemu/osdep.h"
22#include "exec/gdbstub.h"
23
24int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
25{
26 AVRCPU *cpu = AVR_CPU(cs);
27 CPUAVRState *env = &cpu->env;
28
29
30 if (n < 32) {
31 return gdb_get_reg8(mem_buf, env->r[n]);
32 }
33
34
35 if (n == 32) {
36 uint8_t sreg = cpu_get_sreg(env);
37
38 return gdb_get_reg8(mem_buf, sreg);
39 }
40
41
42 if (n == 33) {
43 return gdb_get_reg16(mem_buf, env->sp & 0x0000ffff);
44 }
45
46
47 if (n == 34) {
48 return gdb_get_reg32(mem_buf, env->pc_w * 2);
49 }
50
51 return 0;
52}
53
54int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
55{
56 AVRCPU *cpu = AVR_CPU(cs);
57 CPUAVRState *env = &cpu->env;
58
59
60 if (n < 32) {
61 env->r[n] = *mem_buf;
62 return 1;
63 }
64
65
66 if (n == 32) {
67 cpu_set_sreg(env, *mem_buf);
68 return 1;
69 }
70
71
72 if (n == 33) {
73 env->sp = lduw_p(mem_buf);
74 return 2;
75 }
76
77
78 if (n == 34) {
79 env->pc_w = ldl_p(mem_buf) / 2;
80 return 4;
81 }
82
83 return 0;
84}
85
86vaddr avr_cpu_gdb_adjust_breakpoint(CPUState *cpu, vaddr addr)
87{
88
89
90
91
92
93
94
95
96 return addr % OFFSET_DATA;
97}
98