]>
Commit | Line | Data |
---|---|---|
d0ff8d05 AF |
1 | /* |
2 | * LM32 gdb server stub | |
3 | * | |
4 | * Copyright (c) 2003-2005 Fabrice Bellard | |
5 | * Copyright (c) 2013 SUSE LINUX Products GmbH | |
6 | * | |
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. | |
11 | * | |
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. | |
16 | * | |
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/>. | |
19 | */ | |
5b50e790 AF |
20 | #include "config.h" |
21 | #include "qemu-common.h" | |
22 | #include "exec/gdbstub.h" | |
d0ff8d05 AF |
23 | #include "hw/lm32/lm32_pic.h" |
24 | ||
5b50e790 | 25 | int lm32_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) |
d0ff8d05 | 26 | { |
5b50e790 AF |
27 | LM32CPU *cpu = LM32_CPU(cs); |
28 | CPULM32State *env = &cpu->env; | |
29 | ||
d0ff8d05 | 30 | if (n < 32) { |
986a2998 | 31 | return gdb_get_reg32(mem_buf, env->regs[n]); |
d0ff8d05 AF |
32 | } else { |
33 | switch (n) { | |
34 | case 32: | |
986a2998 | 35 | return gdb_get_reg32(mem_buf, env->pc); |
d0ff8d05 AF |
36 | /* FIXME: put in right exception ID */ |
37 | case 33: | |
986a2998 | 38 | return gdb_get_reg32(mem_buf, 0); |
d0ff8d05 | 39 | case 34: |
986a2998 | 40 | return gdb_get_reg32(mem_buf, env->eba); |
d0ff8d05 | 41 | case 35: |
986a2998 | 42 | return gdb_get_reg32(mem_buf, env->deba); |
d0ff8d05 | 43 | case 36: |
986a2998 | 44 | return gdb_get_reg32(mem_buf, env->ie); |
d0ff8d05 | 45 | case 37: |
986a2998 | 46 | return gdb_get_reg32(mem_buf, lm32_pic_get_im(env->pic_state)); |
d0ff8d05 | 47 | case 38: |
986a2998 | 48 | return gdb_get_reg32(mem_buf, lm32_pic_get_ip(env->pic_state)); |
d0ff8d05 AF |
49 | } |
50 | } | |
51 | return 0; | |
52 | } | |
53 | ||
5b50e790 | 54 | int lm32_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) |
d0ff8d05 | 55 | { |
5b50e790 AF |
56 | LM32CPU *cpu = LM32_CPU(cs); |
57 | CPUClass *cc = CPU_GET_CLASS(cs); | |
58 | CPULM32State *env = &cpu->env; | |
d0ff8d05 AF |
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 | } |