blob: c28ed67efe1837bb549a869df36796ee428878cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
* QEMU AVR gdbstub
*
* Copyright (c) 2016-2020 Michael Rolnik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>
*/
#include "qemu/osdep.h"
#include "exec/gdbstub.h"
int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
{
AVRCPU *cpu = AVR_CPU(cs);
CPUAVRState *env = &cpu->env;
/* R */
if (n < 32) {
return gdb_get_reg8(mem_buf, env->r[n]);
}
/* SREG */
if (n == 32) {
uint8_t sreg = cpu_get_sreg(env);
return gdb_get_reg8(mem_buf, sreg);
}
/* SP */
if (n == 33) {
return gdb_get_reg16(mem_buf, env->sp & 0x0000ffff);
}
/* PC */
if (n == 34) {
return gdb_get_reg32(mem_buf, env->pc_w * 2);
}
return 0;
}
int avr_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
{
AVRCPU *cpu = AVR_CPU(cs);
CPUAVRState *env = &cpu->env;
/* R */
if (n < 32) {
env->r[n] = *mem_buf;
return 1;
}
/* SREG */
if (n == 32) {
cpu_set_sreg(env, *mem_buf);
return 1;
}
/* SP */
if (n == 33) {
env->sp = lduw_p(mem_buf);
return 2;
}
/* PC */
if (n == 34) {
env->pc_w = ldl_p(mem_buf) / 2;
return 4;
}
return 0;
}
|