block: Update bs->open_flags earlier in bdrv_open_common()
[qemu/ar7.git] / target-lm32 / gdbstub.c
blobcf929dd3926df1d6948b74afd128a29697fb2251
1 /*
2 * LM32 gdb server stub
4 * Copyright (c) 2003-2005 Fabrice Bellard
5 * Copyright (c) 2013 SUSE LINUX Products GmbH
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
22 #include "cpu.h"
23 #include "exec/gdbstub.h"
24 #include "hw/lm32/lm32_pic.h"
26 int lm32_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
28 LM32CPU *cpu = LM32_CPU(cs);
29 CPULM32State *env = &cpu->env;
31 if (n < 32) {
32 return gdb_get_reg32(mem_buf, env->regs[n]);
33 } else {
34 switch (n) {
35 case 32:
36 return gdb_get_reg32(mem_buf, env->pc);
37 /* FIXME: put in right exception ID */
38 case 33:
39 return gdb_get_reg32(mem_buf, 0);
40 case 34:
41 return gdb_get_reg32(mem_buf, env->eba);
42 case 35:
43 return gdb_get_reg32(mem_buf, env->deba);
44 case 36:
45 return gdb_get_reg32(mem_buf, env->ie);
46 case 37:
47 return gdb_get_reg32(mem_buf, lm32_pic_get_im(env->pic_state));
48 case 38:
49 return gdb_get_reg32(mem_buf, lm32_pic_get_ip(env->pic_state));
52 return 0;
55 int lm32_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
57 LM32CPU *cpu = LM32_CPU(cs);
58 CPUClass *cc = CPU_GET_CLASS(cs);
59 CPULM32State *env = &cpu->env;
60 uint32_t tmp;
62 if (n > cc->gdb_num_core_regs) {
63 return 0;
66 tmp = ldl_p(mem_buf);
68 if (n < 32) {
69 env->regs[n] = tmp;
70 } else {
71 switch (n) {
72 case 32:
73 env->pc = tmp;
74 break;
75 case 34:
76 env->eba = tmp;
77 break;
78 case 35:
79 env->deba = tmp;
80 break;
81 case 36:
82 env->ie = tmp;
83 break;
84 case 37:
85 lm32_pic_set_im(env->pic_state, tmp);
86 break;
87 case 38:
88 lm32_pic_set_ip(env->pic_state, tmp);
89 break;
92 return 4;