1eabfc239SAndreas Färber /* 2eabfc239SAndreas Färber * MicroBlaze gdb server stub 3eabfc239SAndreas Färber * 4eabfc239SAndreas Färber * Copyright (c) 2003-2005 Fabrice Bellard 5eabfc239SAndreas Färber * Copyright (c) 2013 SUSE LINUX Products GmbH 6eabfc239SAndreas Färber * 7eabfc239SAndreas Färber * This library is free software; you can redistribute it and/or 8eabfc239SAndreas Färber * modify it under the terms of the GNU Lesser General Public 9eabfc239SAndreas Färber * License as published by the Free Software Foundation; either 10eabfc239SAndreas Färber * version 2 of the License, or (at your option) any later version. 11eabfc239SAndreas Färber * 12eabfc239SAndreas Färber * This library is distributed in the hope that it will be useful, 13eabfc239SAndreas Färber * but WITHOUT ANY WARRANTY; without even the implied warranty of 14eabfc239SAndreas Färber * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15eabfc239SAndreas Färber * Lesser General Public License for more details. 16eabfc239SAndreas Färber * 17eabfc239SAndreas Färber * You should have received a copy of the GNU Lesser General Public 18eabfc239SAndreas Färber * License along with this library; if not, see <http://www.gnu.org/licenses/>. 19eabfc239SAndreas Färber */ 208fd9deceSPeter Maydell #include "qemu/osdep.h" 2133c11879SPaolo Bonzini #include "cpu.h" 225b50e790SAndreas Färber #include "exec/gdbstub.h" 23eabfc239SAndreas Färber 24*a010bdbeSAlex Bennée int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) 25eabfc239SAndreas Färber { 265b50e790SAndreas Färber MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); 275b50e790SAndreas Färber CPUMBState *env = &cpu->env; 285b50e790SAndreas Färber 29eabfc239SAndreas Färber if (n < 32) { 30986a2998SAndreas Färber return gdb_get_reg32(mem_buf, env->regs[n]); 31eabfc239SAndreas Färber } else { 32986a2998SAndreas Färber return gdb_get_reg32(mem_buf, env->sregs[n - 32]); 33eabfc239SAndreas Färber } 34eabfc239SAndreas Färber return 0; 35eabfc239SAndreas Färber } 36eabfc239SAndreas Färber 375b50e790SAndreas Färber int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) 38eabfc239SAndreas Färber { 395b50e790SAndreas Färber MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); 405b50e790SAndreas Färber CPUClass *cc = CPU_GET_CLASS(cs); 415b50e790SAndreas Färber CPUMBState *env = &cpu->env; 42eabfc239SAndreas Färber uint32_t tmp; 43eabfc239SAndreas Färber 44eabfc239SAndreas Färber if (n > cc->gdb_num_core_regs) { 45eabfc239SAndreas Färber return 0; 46eabfc239SAndreas Färber } 47eabfc239SAndreas Färber 48eabfc239SAndreas Färber tmp = ldl_p(mem_buf); 49eabfc239SAndreas Färber 50eabfc239SAndreas Färber if (n < 32) { 51eabfc239SAndreas Färber env->regs[n] = tmp; 52eabfc239SAndreas Färber } else { 53eabfc239SAndreas Färber env->sregs[n - 32] = tmp; 54eabfc239SAndreas Färber } 55eabfc239SAndreas Färber return 4; 56eabfc239SAndreas Färber } 57