1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include "qemu/osdep.h"
21#include "cpu.h"
22#include "exec/gdbstub.h"
23#include "hw/lm32/lm32_pic.h"
24
25int lm32_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
26{
27 LM32CPU *cpu = LM32_CPU(cs);
28 CPULM32State *env = &cpu->env;
29
30 if (n < 32) {
31 return gdb_get_reg32(mem_buf, env->regs[n]);
32 } else {
33 switch (n) {
34 case 32:
35 return gdb_get_reg32(mem_buf, env->pc);
36
37 case 33:
38 return gdb_get_reg32(mem_buf, 0);
39 case 34:
40 return gdb_get_reg32(mem_buf, env->eba);
41 case 35:
42 return gdb_get_reg32(mem_buf, env->deba);
43 case 36:
44 return gdb_get_reg32(mem_buf, env->ie);
45 case 37:
46 return gdb_get_reg32(mem_buf, lm32_pic_get_im(env->pic_state));
47 case 38:
48 return gdb_get_reg32(mem_buf, lm32_pic_get_ip(env->pic_state));
49 }
50 }
51 return 0;
52}
53
54int lm32_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
55{
56 LM32CPU *cpu = LM32_CPU(cs);
57 CPUClass *cc = CPU_GET_CLASS(cs);
58 CPULM32State *env = &cpu->env;
59 uint32_t tmp;
60
61 if (n > cc->gdb_num_core_regs) {
62 return 0;
63 }
64
65 tmp = ldl_p(mem_buf);
66
67 if (n < 32) {
68 env->regs[n] = tmp;
69 } else {
70 switch (n) {
71 case 32:
72 env->pc = tmp;
73 break;
74 case 34:
75 env->eba = tmp;
76 break;
77 case 35:
78 env->deba = tmp;
79 break;
80 case 36:
81 env->ie = tmp;
82 break;
83 case 37:
84 lm32_pic_set_im(env->pic_state, tmp);
85 break;
86 case 38:
87 lm32_pic_set_ip(env->pic_state, tmp);
88 break;
89 }
90 }
91 return 4;
92}
93