2013-07-07 18:45:47 +08:00
|
|
|
/*
|
|
|
|
* MicroBlaze gdb server stub
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2005 Fabrice Bellard
|
|
|
|
* Copyright (c) 2013 SUSE LINUX Products GmbH
|
|
|
|
*
|
|
|
|
* 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 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/>.
|
|
|
|
*/
|
2016-01-27 02:05:31 +08:00
|
|
|
#include "qemu/osdep.h"
|
2016-03-15 23:58:45 +08:00
|
|
|
#include "cpu.h"
|
2013-06-29 10:18:45 +08:00
|
|
|
#include "exec/gdbstub.h"
|
2013-07-07 18:45:47 +08:00
|
|
|
|
2020-08-19 02:26:59 +08:00
|
|
|
/*
|
|
|
|
* GDB expects SREGs in the following order:
|
|
|
|
* PC, MSR, EAR, ESR, FSR, BTR, EDR, PID, ZPR, TLBX, TLBSX, TLBLO, TLBHI.
|
|
|
|
*
|
|
|
|
* PID, ZPR, TLBx, TLBsx, TLBLO, and TLBHI aren't modeled, so we don't
|
|
|
|
* map them to anything and return a value of 0 instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
GDB_PC = 32 + 0,
|
|
|
|
GDB_MSR = 32 + 1,
|
|
|
|
GDB_EAR = 32 + 2,
|
|
|
|
GDB_ESR = 32 + 3,
|
|
|
|
GDB_FSR = 32 + 4,
|
|
|
|
GDB_BTR = 32 + 5,
|
|
|
|
GDB_PVR0 = 32 + 6,
|
|
|
|
GDB_PVR11 = 32 + 17,
|
|
|
|
GDB_EDR = 32 + 18,
|
|
|
|
GDB_SLR = 32 + 25,
|
|
|
|
GDB_SHR = 32 + 26,
|
|
|
|
};
|
|
|
|
|
2020-03-17 01:21:41 +08:00
|
|
|
int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
|
2013-07-07 18:45:47 +08:00
|
|
|
{
|
2013-06-29 10:18:45 +08:00
|
|
|
MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
|
2020-08-19 02:26:59 +08:00
|
|
|
CPUClass *cc = CPU_GET_CLASS(cs);
|
2013-06-29 10:18:45 +08:00
|
|
|
CPUMBState *env = &cpu->env;
|
2020-08-19 02:26:59 +08:00
|
|
|
uint32_t val;
|
2013-06-29 10:18:45 +08:00
|
|
|
|
2020-08-19 02:26:59 +08:00
|
|
|
if (n > cc->gdb_num_core_regs) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case 1 ... 31:
|
|
|
|
val = env->regs[n];
|
|
|
|
break;
|
|
|
|
case GDB_PC:
|
2020-08-20 12:33:32 +08:00
|
|
|
val = env->pc;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_MSR:
|
2020-08-19 02:58:23 +08:00
|
|
|
val = mb_cpu_read_msr(env);
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_EAR:
|
2020-08-20 12:46:10 +08:00
|
|
|
val = env->ear;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_ESR:
|
2020-08-20 12:50:35 +08:00
|
|
|
val = env->esr;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_FSR:
|
2020-08-20 12:54:38 +08:00
|
|
|
val = env->fsr;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_BTR:
|
2020-08-20 12:58:40 +08:00
|
|
|
val = env->btr;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_PVR0 ... GDB_PVR11:
|
2020-05-14 02:08:46 +08:00
|
|
|
/* PVR12 is intentionally skipped */
|
2020-08-19 02:26:59 +08:00
|
|
|
val = env->pvr.regs[n - GDB_PVR0];
|
|
|
|
break;
|
|
|
|
case GDB_EDR:
|
2020-08-20 13:05:29 +08:00
|
|
|
val = env->edr;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_SLR:
|
|
|
|
val = env->slr;
|
|
|
|
break;
|
|
|
|
case GDB_SHR:
|
|
|
|
val = env->shr;
|
|
|
|
break;
|
|
|
|
default:
|
2020-05-14 02:08:47 +08:00
|
|
|
/* Other SRegs aren't modeled, so report a value of 0 */
|
2020-08-19 02:26:59 +08:00
|
|
|
val = 0;
|
|
|
|
break;
|
2013-07-07 18:45:47 +08:00
|
|
|
}
|
2020-08-19 02:26:59 +08:00
|
|
|
return gdb_get_reg32(mem_buf, val);
|
2013-07-07 18:45:47 +08:00
|
|
|
}
|
|
|
|
|
2013-06-29 10:18:45 +08:00
|
|
|
int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
2013-07-07 18:45:47 +08:00
|
|
|
{
|
2013-06-29 10:18:45 +08:00
|
|
|
MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
|
|
|
|
CPUClass *cc = CPU_GET_CLASS(cs);
|
|
|
|
CPUMBState *env = &cpu->env;
|
2013-07-07 18:45:47 +08:00
|
|
|
uint32_t tmp;
|
|
|
|
|
|
|
|
if (n > cc->gdb_num_core_regs) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = ldl_p(mem_buf);
|
|
|
|
|
2020-08-19 02:26:59 +08:00
|
|
|
switch (n) {
|
|
|
|
case 1 ... 31:
|
2013-07-07 18:45:47 +08:00
|
|
|
env->regs[n] = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_PC:
|
2020-08-20 12:33:32 +08:00
|
|
|
env->pc = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_MSR:
|
2020-08-19 02:58:23 +08:00
|
|
|
mb_cpu_write_msr(env, tmp);
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_EAR:
|
2020-08-20 12:46:10 +08:00
|
|
|
env->ear = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_ESR:
|
2020-08-20 12:50:35 +08:00
|
|
|
env->esr = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_FSR:
|
2020-08-20 12:54:38 +08:00
|
|
|
env->fsr = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_BTR:
|
2020-08-20 12:58:40 +08:00
|
|
|
env->btr = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_PVR0 ... GDB_PVR11:
|
2020-05-14 02:08:46 +08:00
|
|
|
/* PVR12 is intentionally skipped */
|
2020-08-19 02:26:59 +08:00
|
|
|
env->pvr.regs[n - GDB_PVR0] = tmp;
|
|
|
|
break;
|
|
|
|
case GDB_EDR:
|
2020-08-20 13:05:29 +08:00
|
|
|
env->edr = tmp;
|
2020-08-19 02:26:59 +08:00
|
|
|
break;
|
|
|
|
case GDB_SLR:
|
|
|
|
env->slr = tmp;
|
|
|
|
break;
|
|
|
|
case GDB_SHR:
|
|
|
|
env->shr = tmp;
|
|
|
|
break;
|
2013-07-07 18:45:47 +08:00
|
|
|
}
|
|
|
|
return 4;
|
|
|
|
}
|