Skip to content

Commit c3bef3b

Browse files
committed
target/microblaze: Add gdbstub xml
Mirroring the upstream gdb xml files, the two stack boundary registers are separated out. Reviewed-by: Edgar E. Iglesias <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent d7d5601 commit c3bef3b

9 files changed

+125
-12
lines changed

configs/targets/microblaze-linux-user.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ TARGET_SYSTBL_ABI=common
33
TARGET_SYSTBL=syscall.tbl
44
TARGET_BIG_ENDIAN=y
55
TARGET_HAS_BFLT=y
6+
TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml

configs/targets/microblaze-softmmu.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ TARGET_ARCH=microblaze
22
TARGET_BIG_ENDIAN=y
33
TARGET_SUPPORTS_MTTCG=y
44
TARGET_NEED_FDT=y
5+
TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml

configs/targets/microblazeel-linux-user.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ TARGET_ARCH=microblaze
22
TARGET_SYSTBL_ABI=common
33
TARGET_SYSTBL=syscall.tbl
44
TARGET_HAS_BFLT=y
5+
TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
TARGET_ARCH=microblaze
22
TARGET_SUPPORTS_MTTCG=y
33
TARGET_NEED_FDT=y
4+
TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml

gdb-xml/microblaze-core.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0"?>
2+
<!-- Copyright (C) 2008 Free Software Foundation, Inc.
3+
4+
Copying and distribution of this file, with or without modification,
5+
are permitted in any medium without royalty provided the copyright
6+
notice and this notice are preserved. -->
7+
8+
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
9+
<feature name="org.gnu.gdb.microblaze.core">
10+
<reg name="r0" bitsize="32" regnum="0"/>
11+
<reg name="r1" bitsize="32" type="data_ptr"/>
12+
<reg name="r2" bitsize="32"/>
13+
<reg name="r3" bitsize="32"/>
14+
<reg name="r4" bitsize="32"/>
15+
<reg name="r5" bitsize="32"/>
16+
<reg name="r6" bitsize="32"/>
17+
<reg name="r7" bitsize="32"/>
18+
<reg name="r8" bitsize="32"/>
19+
<reg name="r9" bitsize="32"/>
20+
<reg name="r10" bitsize="32"/>
21+
<reg name="r11" bitsize="32"/>
22+
<reg name="r12" bitsize="32"/>
23+
<reg name="r13" bitsize="32"/>
24+
<reg name="r14" bitsize="32"/>
25+
<reg name="r15" bitsize="32"/>
26+
<reg name="r16" bitsize="32"/>
27+
<reg name="r17" bitsize="32"/>
28+
<reg name="r18" bitsize="32"/>
29+
<reg name="r19" bitsize="32"/>
30+
<reg name="r20" bitsize="32"/>
31+
<reg name="r21" bitsize="32"/>
32+
<reg name="r22" bitsize="32"/>
33+
<reg name="r23" bitsize="32"/>
34+
<reg name="r24" bitsize="32"/>
35+
<reg name="r25" bitsize="32"/>
36+
<reg name="r26" bitsize="32"/>
37+
<reg name="r27" bitsize="32"/>
38+
<reg name="r28" bitsize="32"/>
39+
<reg name="r29" bitsize="32"/>
40+
<reg name="r30" bitsize="32"/>
41+
<reg name="r31" bitsize="32"/>
42+
<reg name="rpc" bitsize="32" type="code_ptr"/>
43+
<reg name="rmsr" bitsize="32"/>
44+
<reg name="rear" bitsize="32"/>
45+
<reg name="resr" bitsize="32"/>
46+
<reg name="rfsr" bitsize="32"/>
47+
<reg name="rbtr" bitsize="32"/>
48+
<reg name="rpvr0" bitsize="32"/>
49+
<reg name="rpvr1" bitsize="32"/>
50+
<reg name="rpvr2" bitsize="32"/>
51+
<reg name="rpvr3" bitsize="32"/>
52+
<reg name="rpvr4" bitsize="32"/>
53+
<reg name="rpvr5" bitsize="32"/>
54+
<reg name="rpvr6" bitsize="32"/>
55+
<reg name="rpvr7" bitsize="32"/>
56+
<reg name="rpvr8" bitsize="32"/>
57+
<reg name="rpvr9" bitsize="32"/>
58+
<reg name="rpvr10" bitsize="32"/>
59+
<reg name="rpvr11" bitsize="32"/>
60+
<reg name="redr" bitsize="32"/>
61+
<reg name="rpid" bitsize="32"/>
62+
<reg name="rzpr" bitsize="32"/>
63+
<reg name="rtlbx" bitsize="32"/>
64+
<reg name="rtlbsx" bitsize="32"/>
65+
<reg name="rtlblo" bitsize="32"/>
66+
<reg name="rtlbhi" bitsize="32"/>
67+
</feature>

gdb-xml/microblaze-stack-protect.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!-- Copyright (C) 2008 Free Software Foundation, Inc.
3+
4+
Copying and distribution of this file, with or without modification,
5+
are permitted in any medium without royalty provided the copyright
6+
notice and this notice are preserved. -->
7+
8+
<!DOCTYPE feature SYSTEM "gdb-target.dtd">
9+
<feature name="org.gnu.gdb.microblaze.stack-protect">
10+
<reg name="rslr" bitsize="32"/>
11+
<reg name="rshr" bitsize="32"/>
12+
</feature>

target/microblaze/cpu.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "qemu/module.h"
2929
#include "hw/qdev-properties.h"
3030
#include "exec/exec-all.h"
31+
#include "exec/gdbstub.h"
3132
#include "fpu/softfloat-helpers.h"
3233

3334
static const struct {
@@ -294,6 +295,9 @@ static void mb_cpu_initfn(Object *obj)
294295
CPUMBState *env = &cpu->env;
295296

296297
cpu_set_cpustate_pointers(cpu);
298+
gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect,
299+
mb_cpu_gdb_write_stack_protect, 2,
300+
"microblaze-stack-protect.xml", 0);
297301

298302
set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
299303

@@ -422,7 +426,8 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)
422426
cc->sysemu_ops = &mb_sysemu_ops;
423427
#endif
424428
device_class_set_props(dc, mb_properties);
425-
cc->gdb_num_core_regs = 32 + 27;
429+
cc->gdb_num_core_regs = 32 + 25;
430+
cc->gdb_core_xml_file = "microblaze-core.xml";
426431

427432
cc->disas_set_info = mb_disas_set_info;
428433
cc->tcg_ops = &mb_tcg_ops;

target/microblaze/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
367367
MemTxAttrs *attrs);
368368
int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
369369
int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
370+
int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int reg);
371+
int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int reg);
370372

371373
static inline uint32_t mb_cpu_read_msr(const CPUMBState *env)
372374
{

target/microblaze/gdbstub.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ enum {
3939
GDB_PVR0 = 32 + 6,
4040
GDB_PVR11 = 32 + 17,
4141
GDB_EDR = 32 + 18,
42-
GDB_SLR = 32 + 25,
43-
GDB_SHR = 32 + 26,
42+
};
43+
44+
enum {
45+
GDB_SP_SHL,
46+
GDB_SP_SHR,
4447
};
4548

4649
int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
@@ -83,16 +86,27 @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
8386
case GDB_EDR:
8487
val = env->edr;
8588
break;
86-
case GDB_SLR:
89+
default:
90+
/* Other SRegs aren't modeled, so report a value of 0 */
91+
val = 0;
92+
break;
93+
}
94+
return gdb_get_reg32(mem_buf, val);
95+
}
96+
97+
int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, int n)
98+
{
99+
uint32_t val;
100+
101+
switch (n) {
102+
case GDB_SP_SHL:
87103
val = env->slr;
88104
break;
89-
case GDB_SHR:
105+
case GDB_SP_SHR:
90106
val = env->shr;
91107
break;
92108
default:
93-
/* Other SRegs aren't modeled, so report a value of 0 */
94-
val = 0;
95-
break;
109+
return 0;
96110
}
97111
return gdb_get_reg32(mem_buf, val);
98112
}
@@ -135,12 +149,21 @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
135149
case GDB_EDR:
136150
env->edr = tmp;
137151
break;
138-
case GDB_SLR:
139-
env->slr = tmp;
152+
}
153+
return 4;
154+
}
155+
156+
int mb_cpu_gdb_write_stack_protect(CPUMBState *env, uint8_t *mem_buf, int n)
157+
{
158+
switch (n) {
159+
case GDB_SP_SHL:
160+
env->slr = ldl_p(mem_buf);
140161
break;
141-
case GDB_SHR:
142-
env->shr = tmp;
162+
case GDB_SP_SHR:
163+
env->shr = ldl_p(mem_buf);
143164
break;
165+
default:
166+
return 0;
144167
}
145168
return 4;
146169
}

0 commit comments

Comments
 (0)