X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Fcommon%2Fsim-n-core.h;h=e423fb585f78e079a7851bfc69f3480fcdf4751f;hb=9b254dd1ce46c19dde1dde5b8d1e22e862dfacce;hp=b355e3bb401cb1e13d3e74a1f3a3f07c0a4ab603;hpb=9e8a900adf4d6e4845dc763407af7a142bed9424;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/common/sim-n-core.h b/sim/common/sim-n-core.h index b355e3bb40..e423fb585f 100644 --- a/sim/common/sim-n-core.h +++ b/sim/common/sim-n-core.h @@ -1,22 +1,23 @@ -/* This file is part of the program psim. +/* The common simulator framework for GDB, the GNU Debugger. - Copyright (C) 1994-1997, Andrew Cagney + Copyright 2002, 2007, 2008 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + Contributed by Andrew Cagney and Red Hat. - This program 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - */ + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #ifndef N @@ -26,7 +27,15 @@ #define M N #endif -#include "sim-xcat.h" +/* N: The number of bytes of data to transfer. + M: The number of bytes in the type used to transfer the data */ + +#if (N > M) +#error "N (nr bytes of data) must be <= M (nr of bytes in data type)" +#endif + + +#include "symcat.h" /* NOTE: see end of file for #undef of these macros */ @@ -43,6 +52,14 @@ #define sim_core_write_unaligned_N XCONCAT2(sim_core_write_unaligned_,N) #define sim_core_write_misaligned_N XCONCAT2(sim_core_write_misaligned_,N) #define sim_core_trace_M XCONCAT2(sim_core_trace_,M) +#define sim_core_dummy_M XCONCAT2(sim_core_dummy_,M) + + +#if (M == N && N > 1) +/* dummy variable used as a return value when nothing else is + available and the compiler is complaining */ +static unsigned_M sim_core_dummy_M; +#endif /* TAGS: sim_core_trace_1 sim_core_trace_2 */ @@ -55,13 +72,13 @@ sim_core_trace_M (sim_cpu *cpu, sim_cia cia, int line_nr, transfer_type type, - sim_core_maps map, + unsigned map, address_word addr, unsigned_M val, int nr_bytes) { - char *transfer = (type == read_transfer ? "read" : "write"); - char *direction = (type == read_transfer ? "->" : "<-"); + const char *transfer = (type == read_transfer ? "read" : "write"); + const char *direction = (type == read_transfer ? "->" : "<-"); if (TRACE_DEBUG_P (cpu)) trace_printf (CPU_STATE (cpu), cpu, "sim-n-core.h:%d: ", line_nr); @@ -70,7 +87,7 @@ sim_core_trace_M (sim_cpu *cpu, trace_printf (CPU_STATE (cpu), cpu, "%s-%d %s:0x%08lx %s 0x%08lx%08lx%08lx%08lx\n", transfer, nr_bytes, - sim_core_map_to_str (map), + map_to_str (map), (unsigned long) addr, direction, (unsigned long) V4_16 (val, 0), @@ -82,7 +99,7 @@ sim_core_trace_M (sim_cpu *cpu, trace_printf (CPU_STATE (cpu), cpu, "%s-%d %s:0x%08lx %s 0x%08lx%08lx\n", transfer, nr_bytes, - sim_core_map_to_str (map), + map_to_str (map), (unsigned long) addr, direction, (unsigned long) V4_8 (val, 0), @@ -93,7 +110,7 @@ sim_core_trace_M (sim_cpu *cpu, "%s-%d %s:0x%08lx %s 0x%08lx\n", transfer, nr_bytes, - sim_core_map_to_str (map), + map_to_str (map), (unsigned long) addr, direction, (unsigned long) val); @@ -103,7 +120,7 @@ sim_core_trace_M (sim_cpu *cpu, "%s-%d %s:0x%08lx %s 0x%04lx\n", transfer, nr_bytes, - sim_core_map_to_str (map), + map_to_str (map), (unsigned long) addr, direction, (unsigned long) val); @@ -113,7 +130,7 @@ sim_core_trace_M (sim_cpu *cpu, "%s-%d %s:0x%08lx %s 0x%02lx\n", transfer, nr_bytes, - sim_core_map_to_str (map), + map_to_str (map), (unsigned long) addr, direction, (unsigned long) val); @@ -130,7 +147,7 @@ sim_core_trace_M (sim_cpu *cpu, INLINE_SIM_CORE(unsigned_M) sim_core_read_aligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word xaddr) { sim_cpu_core *cpu_core = CPU_CORE (cpu); @@ -145,24 +162,38 @@ sim_core_read_aligned_N(sim_cpu *cpu, #endif addr = xaddr; mapping = sim_core_find_mapping (core, map, addr, N, read_transfer, 1 /*abort*/, cpu, cia); + do + { #if (WITH_DEVICES) - if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { - unsigned_M data; - if (device_io_read_buffer (mapping->device, &data, mapping->space, addr, N) != N) - device_error (mapping->device, "internal error - %s - io_read_buffer should not fail", - XSTRING (sim_core_read_aligned_N)); - val = T2H_M (data); - } - else + if (WITH_CALLBACK_MEMORY && mapping->device != NULL) + { + unsigned_M data; + if (device_io_read_buffer (mapping->device, &data, mapping->space, addr, N, CPU_STATE (cpu), cpu, cia) != N) + device_error (mapping->device, "internal error - %s - io_read_buffer should not fail", + XSTRING (sim_core_read_aligned_N)); + val = T2H_M (data); + break; + } #endif - val = T2H_M (*(unsigned_M*) sim_core_translate (mapping, addr)); +#if (WITH_HW) + if (WITH_CALLBACK_MEMORY && mapping->device != NULL) + { + unsigned_M data; + sim_cpu_hw_io_read_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N); + val = T2H_M (data); + break; + } +#endif + val = T2H_M (*(unsigned_M*) sim_core_translate (mapping, addr)); + } + while (0); PROFILE_COUNT_CORE (cpu, addr, N, map); if (TRACE_P (cpu, TRACE_CORE_IDX)) sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N); return val; } #endif - + /* TAGS: sim_core_read_unaligned_1 sim_core_read_unaligned_2 */ /* TAGS: sim_core_read_unaligned_4 sim_core_read_unaligned_8 */ /* TAGS: sim_core_read_unaligned_16 */ @@ -171,7 +202,7 @@ sim_core_read_aligned_N(sim_cpu *cpu, INLINE_SIM_CORE(unsigned_M) sim_core_read_unaligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word addr) { int alignment = N - 1; @@ -209,10 +240,7 @@ sim_core_read_unaligned_N(sim_cpu *cpu, "internal error - %s - bad switch", XSTRING (sim_core_read_unaligned_N)); /* to keep some compilers happy, we return a dummy */ - { - unsigned_M val[1] = { 0 }; - return val[0]; - } + return sim_core_dummy_M; } } #endif @@ -224,7 +252,7 @@ sim_core_read_unaligned_N(sim_cpu *cpu, INLINE_SIM_CORE(unsigned_M) sim_core_read_misaligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word addr) { unsigned_M val = 0; @@ -250,7 +278,7 @@ sim_core_read_misaligned_N(sim_cpu *cpu, INLINE_SIM_CORE(void) sim_core_write_aligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word xaddr, unsigned_M val) { @@ -265,16 +293,29 @@ sim_core_write_aligned_N(sim_cpu *cpu, #endif addr = xaddr; mapping = sim_core_find_mapping (core, map, addr, N, write_transfer, 1 /*abort*/, cpu, cia); + do + { #if (WITH_DEVICES) - if (WITH_CALLBACK_MEMORY && mapping->device != NULL) { - unsigned_M data = H2T_M (val); - if (device_io_write_buffer (mapping->device, &data, mapping->space, addr, N, cpu, cia) != N) - device_error (mapping->device, "internal error - %s - io_write_buffer should not fail", - XSTRING (sim_core_write_aligned_N)); - } - else + if (WITH_CALLBACK_MEMORY && mapping->device != NULL) + { + unsigned_M data = H2T_M (val); + if (device_io_write_buffer (mapping->device, &data, mapping->space, addr, N, CPU_STATE (cpu), cpu, cia) != N) + device_error (mapping->device, "internal error - %s - io_write_buffer should not fail", + XSTRING (sim_core_write_aligned_N)); + break; + } +#endif +#if (WITH_HW) + if (WITH_CALLBACK_MEMORY && mapping->device != NULL) + { + unsigned_M data = H2T_M (val); + sim_cpu_hw_io_write_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N); + break; + } #endif - *(unsigned_M*) sim_core_translate (mapping, addr) = H2T_M (val); + *(unsigned_M*) sim_core_translate (mapping, addr) = H2T_M (val); + } + while (0); PROFILE_COUNT_CORE (cpu, addr, N, map); if (TRACE_P (cpu, TRACE_CORE_IDX)) sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N); @@ -289,7 +330,7 @@ sim_core_write_aligned_N(sim_cpu *cpu, INLINE_SIM_CORE(void) sim_core_write_unaligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word addr, unsigned_M val) { @@ -341,7 +382,7 @@ sim_core_write_unaligned_N(sim_cpu *cpu, INLINE_SIM_CORE(void) sim_core_write_misaligned_N(sim_cpu *cpu, sim_cia cia, - sim_core_maps map, + unsigned map, address_word addr, unsigned_M val) { @@ -372,5 +413,6 @@ sim_core_write_misaligned_N(sim_cpu *cpu, #undef sim_core_write_unaligned_N #undef sim_core_write_misaligned_N #undef sim_core_trace_M +#undef sim_core_dummy_M #undef M #undef N