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 */ 20eabfc239SAndreas Färber 21eabfc239SAndreas Färber static int cpu_gdb_read_register(CPUMBState *env, uint8_t *mem_buf, int n) 22eabfc239SAndreas Färber { 23eabfc239SAndreas Färber if (n < 32) { 24986a2998SAndreas Färber return gdb_get_reg32(mem_buf, env->regs[n]); 25eabfc239SAndreas Färber } else { 26986a2998SAndreas Färber return gdb_get_reg32(mem_buf, env->sregs[n - 32]); 27eabfc239SAndreas Färber } 28eabfc239SAndreas Färber return 0; 29eabfc239SAndreas Färber } 30eabfc239SAndreas Färber 31eabfc239SAndreas Färber static int cpu_gdb_write_register(CPUMBState *env, uint8_t *mem_buf, int n) 32eabfc239SAndreas Färber { 33eabfc239SAndreas Färber MicroBlazeCPU *cpu = mb_env_get_cpu(env); 34eabfc239SAndreas Färber CPUClass *cc = CPU_GET_CLASS(cpu); 35eabfc239SAndreas Färber uint32_t tmp; 36eabfc239SAndreas Färber 37eabfc239SAndreas Färber if (n > cc->gdb_num_core_regs) { 38eabfc239SAndreas Färber return 0; 39eabfc239SAndreas Färber } 40eabfc239SAndreas Färber 41eabfc239SAndreas Färber tmp = ldl_p(mem_buf); 42eabfc239SAndreas Färber 43eabfc239SAndreas Färber if (n < 32) { 44eabfc239SAndreas Färber env->regs[n] = tmp; 45eabfc239SAndreas Färber } else { 46eabfc239SAndreas Färber env->sregs[n - 32] = tmp; 47eabfc239SAndreas Färber } 48eabfc239SAndreas Färber return 4; 49eabfc239SAndreas Färber } 50