2013-07-07 12:54:12 +02:00
|
|
|
/*
|
|
|
|
* s390x 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/>.
|
|
|
|
*/
|
2013-06-29 04:18:45 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "exec/gdbstub.h"
|
|
|
|
#include "qemu/bitops.h"
|
2013-07-07 12:54:12 +02:00
|
|
|
|
2013-06-29 04:18:45 +02:00
|
|
|
int s390_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
|
2013-07-07 12:54:12 +02:00
|
|
|
{
|
2013-06-29 04:18:45 +02:00
|
|
|
S390CPU *cpu = S390_CPU(cs);
|
|
|
|
CPUS390XState *env = &cpu->env;
|
2013-07-07 12:54:12 +02:00
|
|
|
uint64_t val;
|
|
|
|
int cc_op;
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case S390_PSWM_REGNUM:
|
|
|
|
cc_op = calc_cc(env, env->cc_op, env->cc_src, env->cc_dst, env->cc_vr);
|
|
|
|
val = deposit64(env->psw.mask, 44, 2, cc_op);
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_regl(mem_buf, val);
|
2013-07-07 12:54:12 +02:00
|
|
|
case S390_PSWA_REGNUM:
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_regl(mem_buf, env->psw.addr);
|
2013-07-07 12:54:12 +02:00
|
|
|
case S390_R0_REGNUM ... S390_R15_REGNUM:
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_regl(mem_buf, env->regs[n-S390_R0_REGNUM]);
|
2013-07-07 12:54:12 +02:00
|
|
|
case S390_A0_REGNUM ... S390_A15_REGNUM:
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_reg32(mem_buf, env->aregs[n-S390_A0_REGNUM]);
|
2013-07-07 12:54:12 +02:00
|
|
|
case S390_FPC_REGNUM:
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_reg32(mem_buf, env->fpc);
|
2013-07-07 12:54:12 +02:00
|
|
|
case S390_F0_REGNUM ... S390_F15_REGNUM:
|
2013-07-07 13:05:05 +02:00
|
|
|
return gdb_get_reg64(mem_buf, env->fregs[n-S390_F0_REGNUM].ll);
|
2013-07-07 12:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-29 04:18:45 +02:00
|
|
|
int s390_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
|
2013-07-07 12:54:12 +02:00
|
|
|
{
|
2013-06-29 04:18:45 +02:00
|
|
|
S390CPU *cpu = S390_CPU(cs);
|
|
|
|
CPUS390XState *env = &cpu->env;
|
2013-07-07 12:54:12 +02:00
|
|
|
target_ulong tmpl;
|
|
|
|
uint32_t tmp32;
|
|
|
|
int r = 8;
|
|
|
|
tmpl = ldtul_p(mem_buf);
|
|
|
|
tmp32 = ldl_p(mem_buf);
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case S390_PSWM_REGNUM:
|
|
|
|
env->psw.mask = tmpl;
|
|
|
|
env->cc_op = extract64(tmpl, 44, 2);
|
|
|
|
break;
|
|
|
|
case S390_PSWA_REGNUM:
|
|
|
|
env->psw.addr = tmpl;
|
|
|
|
break;
|
|
|
|
case S390_R0_REGNUM ... S390_R15_REGNUM:
|
|
|
|
env->regs[n-S390_R0_REGNUM] = tmpl;
|
|
|
|
break;
|
|
|
|
case S390_A0_REGNUM ... S390_A15_REGNUM:
|
|
|
|
env->aregs[n-S390_A0_REGNUM] = tmp32;
|
|
|
|
r = 4;
|
|
|
|
break;
|
|
|
|
case S390_FPC_REGNUM:
|
|
|
|
env->fpc = tmp32;
|
|
|
|
r = 4;
|
|
|
|
break;
|
|
|
|
case S390_F0_REGNUM ... S390_F15_REGNUM:
|
|
|
|
env->fregs[n-S390_F0_REGNUM].ll = tmpl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|