OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [sim/] [common/] [sim-n-core.h] - Diff between revs 24 and 157

Only display areas with differences | Details | Blame | View Log

Rev 24 Rev 157
/* The common simulator framework for GDB, the GNU Debugger.
/* The common simulator framework for GDB, the GNU Debugger.
 
 
   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
   Copyright 2002, 2007, 2008 Free Software Foundation, Inc.
 
 
   Contributed by Andrew Cagney and Red Hat.
   Contributed by Andrew Cagney and Red Hat.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   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
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 
 
#ifndef N
#ifndef N
#error "N must be #defined"
#error "N must be #defined"
#endif
#endif
#ifndef M
#ifndef M
#define M N
#define M N
#endif
#endif
 
 
/* N: The number of bytes of data to transfer.
/* N: The number of bytes of data to transfer.
   M: The number of bytes in the type used to transfer the data */
   M: The number of bytes in the type used to transfer the data */
 
 
#if (N > M)
#if (N > M)
#error "N (nr bytes of data) must be <= M (nr of bytes in data type)"
#error "N (nr bytes of data) must be <= M (nr of bytes in data type)"
#endif
#endif
 
 
 
 
#include "symcat.h"
#include "symcat.h"
 
 
/* NOTE: see end of file for #undef of these macros */
/* NOTE: see end of file for #undef of these macros */
 
 
#define unsigned_M XCONCAT2(unsigned_,M)
#define unsigned_M XCONCAT2(unsigned_,M)
 
 
#define T2H_M XCONCAT2(T2H_,M)
#define T2H_M XCONCAT2(T2H_,M)
#define H2T_M XCONCAT2(H2T_,M)
#define H2T_M XCONCAT2(H2T_,M)
#define SWAP_M XCONCAT2(SWAP_,M)
#define SWAP_M XCONCAT2(SWAP_,M)
 
 
#define sim_core_read_aligned_N XCONCAT2(sim_core_read_aligned_,N)
#define sim_core_read_aligned_N XCONCAT2(sim_core_read_aligned_,N)
#define sim_core_read_unaligned_N XCONCAT2(sim_core_read_unaligned_,N)
#define sim_core_read_unaligned_N XCONCAT2(sim_core_read_unaligned_,N)
#define sim_core_read_misaligned_N XCONCAT2(sim_core_read_misaligned_,N)
#define sim_core_read_misaligned_N XCONCAT2(sim_core_read_misaligned_,N)
#define sim_core_write_aligned_N XCONCAT2(sim_core_write_aligned_,N)
#define sim_core_write_aligned_N XCONCAT2(sim_core_write_aligned_,N)
#define sim_core_write_unaligned_N XCONCAT2(sim_core_write_unaligned_,N)
#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_write_misaligned_N XCONCAT2(sim_core_write_misaligned_,N)
#define sim_core_trace_M XCONCAT2(sim_core_trace_,M)
#define sim_core_trace_M XCONCAT2(sim_core_trace_,M)
#define sim_core_dummy_M XCONCAT2(sim_core_dummy_,M)
#define sim_core_dummy_M XCONCAT2(sim_core_dummy_,M)
 
 
 
 
#if (M == N && N > 1)
#if (M == N && N > 1)
/* dummy variable used as a return value when nothing else is
/* dummy variable used as a return value when nothing else is
   available and the compiler is complaining */
   available and the compiler is complaining */
static unsigned_M sim_core_dummy_M;
static unsigned_M sim_core_dummy_M;
#endif
#endif
 
 
 
 
/* TAGS: sim_core_trace_1 sim_core_trace_2 */
/* TAGS: sim_core_trace_1 sim_core_trace_2 */
/* TAGS: sim_core_trace_4 sim_core_trace_8 */
/* TAGS: sim_core_trace_4 sim_core_trace_8 */
/* TAGS: sim_core_trace_16 */
/* TAGS: sim_core_trace_16 */
 
 
#if (M == N)
#if (M == N)
STATIC_SIM_CORE(void)
STATIC_SIM_CORE(void)
sim_core_trace_M (sim_cpu *cpu,
sim_core_trace_M (sim_cpu *cpu,
                  sim_cia cia,
                  sim_cia cia,
                  int line_nr,
                  int line_nr,
                  transfer_type type,
                  transfer_type type,
                  unsigned map,
                  unsigned map,
                  address_word addr,
                  address_word addr,
                  unsigned_M val,
                  unsigned_M val,
                  int nr_bytes)
                  int nr_bytes)
{
{
  const char *transfer = (type == read_transfer ? "read" : "write");
  const char *transfer = (type == read_transfer ? "read" : "write");
  const char *direction = (type == read_transfer ? "->" : "<-");
  const char *direction = (type == read_transfer ? "->" : "<-");
 
 
  if (TRACE_DEBUG_P (cpu))
  if (TRACE_DEBUG_P (cpu))
    trace_printf (CPU_STATE (cpu), cpu, "sim-n-core.h:%d: ", line_nr);
    trace_printf (CPU_STATE (cpu), cpu, "sim-n-core.h:%d: ", line_nr);
 
 
#if (M == 16)
#if (M == 16)
  trace_printf (CPU_STATE (cpu), cpu,
  trace_printf (CPU_STATE (cpu), cpu,
                "%s-%d %s:0x%08lx %s 0x%08lx%08lx%08lx%08lx\n",
                "%s-%d %s:0x%08lx %s 0x%08lx%08lx%08lx%08lx\n",
                transfer, nr_bytes,
                transfer, nr_bytes,
                map_to_str (map),
                map_to_str (map),
                (unsigned long) addr,
                (unsigned long) addr,
                direction,
                direction,
                (unsigned long) V4_16 (val, 0),
                (unsigned long) V4_16 (val, 0),
                (unsigned long) V4_16 (val, 1),
                (unsigned long) V4_16 (val, 1),
                (unsigned long) V4_16 (val, 2),
                (unsigned long) V4_16 (val, 2),
                (unsigned long) V4_16 (val, 3));
                (unsigned long) V4_16 (val, 3));
#endif
#endif
#if (M == 8)
#if (M == 8)
  trace_printf (CPU_STATE (cpu), cpu,
  trace_printf (CPU_STATE (cpu), cpu,
                "%s-%d %s:0x%08lx %s 0x%08lx%08lx\n",
                "%s-%d %s:0x%08lx %s 0x%08lx%08lx\n",
                transfer, nr_bytes,
                transfer, nr_bytes,
                map_to_str (map),
                map_to_str (map),
                (unsigned long) addr,
                (unsigned long) addr,
                direction,
                direction,
                (unsigned long) V4_8 (val, 0),
                (unsigned long) V4_8 (val, 0),
                (unsigned long) V4_8 (val, 1));
                (unsigned long) V4_8 (val, 1));
#endif
#endif
#if (M == 4)
#if (M == 4)
  trace_printf (CPU_STATE (cpu), cpu,
  trace_printf (CPU_STATE (cpu), cpu,
                "%s-%d %s:0x%08lx %s 0x%08lx\n",
                "%s-%d %s:0x%08lx %s 0x%08lx\n",
                transfer,
                transfer,
                nr_bytes,
                nr_bytes,
                map_to_str (map),
                map_to_str (map),
                (unsigned long) addr,
                (unsigned long) addr,
                direction,
                direction,
                (unsigned long) val);
                (unsigned long) val);
#endif
#endif
#if (M == 2)
#if (M == 2)
  trace_printf (CPU_STATE (cpu), cpu,
  trace_printf (CPU_STATE (cpu), cpu,
                "%s-%d %s:0x%08lx %s 0x%04lx\n",
                "%s-%d %s:0x%08lx %s 0x%04lx\n",
                transfer,
                transfer,
                nr_bytes,
                nr_bytes,
                map_to_str (map),
                map_to_str (map),
                (unsigned long) addr,
                (unsigned long) addr,
                direction,
                direction,
                (unsigned long) val);
                (unsigned long) val);
#endif
#endif
#if (M == 1)
#if (M == 1)
  trace_printf (CPU_STATE (cpu), cpu,
  trace_printf (CPU_STATE (cpu), cpu,
                "%s-%d %s:0x%08lx %s 0x%02lx\n",
                "%s-%d %s:0x%08lx %s 0x%02lx\n",
                transfer,
                transfer,
                nr_bytes,
                nr_bytes,
                map_to_str (map),
                map_to_str (map),
                (unsigned long) addr,
                (unsigned long) addr,
                direction,
                direction,
                (unsigned long) val);
                (unsigned long) val);
#endif
#endif
}
}
#endif
#endif
 
 
 
 
/* TAGS: sim_core_read_aligned_1 sim_core_read_aligned_2 */
/* TAGS: sim_core_read_aligned_1 sim_core_read_aligned_2 */
/* TAGS: sim_core_read_aligned_4 sim_core_read_aligned_8 */
/* TAGS: sim_core_read_aligned_4 sim_core_read_aligned_8 */
/* TAGS: sim_core_read_aligned_16 */
/* TAGS: sim_core_read_aligned_16 */
 
 
#if (M == N)
#if (M == N)
INLINE_SIM_CORE(unsigned_M)
INLINE_SIM_CORE(unsigned_M)
sim_core_read_aligned_N(sim_cpu *cpu,
sim_core_read_aligned_N(sim_cpu *cpu,
                        sim_cia cia,
                        sim_cia cia,
                        unsigned map,
                        unsigned map,
                        address_word xaddr)
                        address_word xaddr)
{
{
  sim_cpu_core *cpu_core = CPU_CORE (cpu);
  sim_cpu_core *cpu_core = CPU_CORE (cpu);
  sim_core_common *core = &cpu_core->common;
  sim_core_common *core = &cpu_core->common;
  unsigned_M val;
  unsigned_M val;
  sim_core_mapping *mapping;
  sim_core_mapping *mapping;
  address_word addr;
  address_word addr;
#if WITH_XOR_ENDIAN != 0
#if WITH_XOR_ENDIAN != 0
  if (WITH_XOR_ENDIAN)
  if (WITH_XOR_ENDIAN)
    addr = xaddr ^ cpu_core->xor[(N - 1) % WITH_XOR_ENDIAN];
    addr = xaddr ^ cpu_core->xor[(N - 1) % WITH_XOR_ENDIAN];
  else
  else
#endif
#endif
    addr = xaddr;
    addr = xaddr;
  mapping = sim_core_find_mapping (core, map, addr, N, read_transfer, 1 /*abort*/, cpu, cia);
  mapping = sim_core_find_mapping (core, map, addr, N, read_transfer, 1 /*abort*/, cpu, cia);
  do
  do
    {
    {
#if (WITH_DEVICES)
#if (WITH_DEVICES)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
        {
        {
          unsigned_M data;
          unsigned_M data;
          if (device_io_read_buffer (mapping->device, &data, mapping->space, addr, N, CPU_STATE (cpu), cpu, cia) != N)
          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",
            device_error (mapping->device, "internal error - %s - io_read_buffer should not fail",
                          XSTRING (sim_core_read_aligned_N));
                          XSTRING (sim_core_read_aligned_N));
          val = T2H_M (data);
          val = T2H_M (data);
          break;
          break;
        }
        }
#endif
#endif
#if (WITH_HW)
#if (WITH_HW)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
        {
        {
          unsigned_M data;
          unsigned_M data;
          sim_cpu_hw_io_read_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N);
          sim_cpu_hw_io_read_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N);
          val = T2H_M (data);
          val = T2H_M (data);
          break;
          break;
        }
        }
#endif
#endif
      val = T2H_M (*(unsigned_M*) sim_core_translate (mapping, addr));
      val = T2H_M (*(unsigned_M*) sim_core_translate (mapping, addr));
    }
    }
  while (0);
  while (0);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  if (TRACE_P (cpu, TRACE_CORE_IDX))
  if (TRACE_P (cpu, TRACE_CORE_IDX))
    sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
    sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
  return val;
  return val;
}
}
#endif
#endif
 
 
/* TAGS: sim_core_read_unaligned_1 sim_core_read_unaligned_2 */
/* 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_4 sim_core_read_unaligned_8 */
/* TAGS: sim_core_read_unaligned_16 */
/* TAGS: sim_core_read_unaligned_16 */
 
 
#if (M == N && N > 1)
#if (M == N && N > 1)
INLINE_SIM_CORE(unsigned_M)
INLINE_SIM_CORE(unsigned_M)
sim_core_read_unaligned_N(sim_cpu *cpu,
sim_core_read_unaligned_N(sim_cpu *cpu,
                          sim_cia cia,
                          sim_cia cia,
                          unsigned map,
                          unsigned map,
                          address_word addr)
                          address_word addr)
{
{
  int alignment = N - 1;
  int alignment = N - 1;
  /* if hardwired to forced alignment just do it */
  /* if hardwired to forced alignment just do it */
  if (WITH_ALIGNMENT == FORCED_ALIGNMENT)
  if (WITH_ALIGNMENT == FORCED_ALIGNMENT)
    return sim_core_read_aligned_N (cpu, cia, map, addr & ~alignment);
    return sim_core_read_aligned_N (cpu, cia, map, addr & ~alignment);
  else if ((addr & alignment) == 0)
  else if ((addr & alignment) == 0)
    return sim_core_read_aligned_N (cpu, cia, map, addr);
    return sim_core_read_aligned_N (cpu, cia, map, addr);
  else
  else
    switch (CURRENT_ALIGNMENT)
    switch (CURRENT_ALIGNMENT)
      {
      {
      case STRICT_ALIGNMENT:
      case STRICT_ALIGNMENT:
        SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
        SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                         read_transfer, sim_core_unaligned_signal);
                         read_transfer, sim_core_unaligned_signal);
      case NONSTRICT_ALIGNMENT:
      case NONSTRICT_ALIGNMENT:
        {
        {
          unsigned_M val;
          unsigned_M val;
          if (sim_core_xor_read_buffer (CPU_STATE (cpu), cpu, map, &val, addr, N) != N)
          if (sim_core_xor_read_buffer (CPU_STATE (cpu), cpu, map, &val, addr, N) != N)
            SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
            SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                             read_transfer, sim_core_unaligned_signal);
                             read_transfer, sim_core_unaligned_signal);
          val = T2H_M(val);
          val = T2H_M(val);
          PROFILE_COUNT_CORE (cpu, addr, N, map);
          PROFILE_COUNT_CORE (cpu, addr, N, map);
          if (TRACE_P (cpu, TRACE_CORE_IDX))
          if (TRACE_P (cpu, TRACE_CORE_IDX))
            sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
            sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
          return val;
          return val;
        }
        }
      case FORCED_ALIGNMENT:
      case FORCED_ALIGNMENT:
        return sim_core_read_aligned_N (cpu, cia, map, addr & ~alignment);
        return sim_core_read_aligned_N (cpu, cia, map, addr & ~alignment);
      case MIXED_ALIGNMENT:
      case MIXED_ALIGNMENT:
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
                          "internal error - %s - mixed alignment",
                          "internal error - %s - mixed alignment",
                          XSTRING (sim_core_read_unaligned_N));
                          XSTRING (sim_core_read_unaligned_N));
      default:
      default:
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
                          "internal error - %s - bad switch",
                          "internal error - %s - bad switch",
                          XSTRING (sim_core_read_unaligned_N));
                          XSTRING (sim_core_read_unaligned_N));
        /* to keep some compilers happy, we return a dummy */
        /* to keep some compilers happy, we return a dummy */
        return sim_core_dummy_M;
        return sim_core_dummy_M;
      }
      }
}
}
#endif
#endif
 
 
/* TAGS: sim_core_read_misaligned_3 sim_core_read_misaligned_5 */
/* TAGS: sim_core_read_misaligned_3 sim_core_read_misaligned_5 */
/* TAGS: sim_core_read_misaligned_6 sim_core_read_misaligned_7 */
/* TAGS: sim_core_read_misaligned_6 sim_core_read_misaligned_7 */
 
 
#if (M != N)
#if (M != N)
INLINE_SIM_CORE(unsigned_M)
INLINE_SIM_CORE(unsigned_M)
sim_core_read_misaligned_N(sim_cpu *cpu,
sim_core_read_misaligned_N(sim_cpu *cpu,
                          sim_cia cia,
                          sim_cia cia,
                          unsigned map,
                          unsigned map,
                          address_word addr)
                          address_word addr)
{
{
  unsigned_M val = 0;
  unsigned_M val = 0;
  if (sim_core_xor_read_buffer (CPU_STATE (cpu), cpu, map, &val, addr, N) != N)
  if (sim_core_xor_read_buffer (CPU_STATE (cpu), cpu, map, &val, addr, N) != N)
    SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
    SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                     read_transfer, sim_core_unaligned_signal);
                     read_transfer, sim_core_unaligned_signal);
  if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
  if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
    val = SWAP_M (val);
    val = SWAP_M (val);
  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
    val >>= (M - N) * 8;
    val >>= (M - N) * 8;
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  if (TRACE_P (cpu, TRACE_CORE_IDX))
  if (TRACE_P (cpu, TRACE_CORE_IDX))
    sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
    sim_core_trace_M (cpu, cia, __LINE__, read_transfer, map, addr, val, N);
  return val;
  return val;
}
}
#endif
#endif
 
 
/* TAGS: sim_core_write_aligned_1 sim_core_write_aligned_2 */
/* TAGS: sim_core_write_aligned_1 sim_core_write_aligned_2 */
/* TAGS: sim_core_write_aligned_4 sim_core_write_aligned_8 */
/* TAGS: sim_core_write_aligned_4 sim_core_write_aligned_8 */
/* TAGS: sim_core_write_aligned_16 */
/* TAGS: sim_core_write_aligned_16 */
 
 
#if (M == N)
#if (M == N)
INLINE_SIM_CORE(void)
INLINE_SIM_CORE(void)
sim_core_write_aligned_N(sim_cpu *cpu,
sim_core_write_aligned_N(sim_cpu *cpu,
                         sim_cia cia,
                         sim_cia cia,
                         unsigned map,
                         unsigned map,
                         address_word xaddr,
                         address_word xaddr,
                         unsigned_M val)
                         unsigned_M val)
{
{
  sim_cpu_core *cpu_core = CPU_CORE (cpu);
  sim_cpu_core *cpu_core = CPU_CORE (cpu);
  sim_core_common *core = &cpu_core->common;
  sim_core_common *core = &cpu_core->common;
  sim_core_mapping *mapping;
  sim_core_mapping *mapping;
  address_word addr;
  address_word addr;
#if WITH_XOR_ENDIAN != 0
#if WITH_XOR_ENDIAN != 0
  if (WITH_XOR_ENDIAN)
  if (WITH_XOR_ENDIAN)
    addr = xaddr ^ cpu_core->xor[(N - 1) % WITH_XOR_ENDIAN];
    addr = xaddr ^ cpu_core->xor[(N - 1) % WITH_XOR_ENDIAN];
  else
  else
#endif
#endif
    addr = xaddr;
    addr = xaddr;
  mapping = sim_core_find_mapping (core, map, addr, N, write_transfer, 1 /*abort*/, cpu, cia);
  mapping = sim_core_find_mapping (core, map, addr, N, write_transfer, 1 /*abort*/, cpu, cia);
  do
  do
    {
    {
#if (WITH_DEVICES)
#if (WITH_DEVICES)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
        {
        {
          unsigned_M data = H2T_M (val);
          unsigned_M data = H2T_M (val);
          if (device_io_write_buffer (mapping->device, &data, mapping->space, addr, N, CPU_STATE (cpu), cpu, cia) != N)
          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",
            device_error (mapping->device, "internal error - %s - io_write_buffer should not fail",
                          XSTRING (sim_core_write_aligned_N));
                          XSTRING (sim_core_write_aligned_N));
          break;
          break;
        }
        }
#endif
#endif
#if (WITH_HW)
#if (WITH_HW)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
      if (WITH_CALLBACK_MEMORY && mapping->device != NULL)
        {
        {
          unsigned_M data = H2T_M (val);
          unsigned_M data = H2T_M (val);
          sim_cpu_hw_io_write_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N);
          sim_cpu_hw_io_write_buffer (cpu, cia, mapping->device, &data, mapping->space, addr, N);
          break;
          break;
        }
        }
#endif
#endif
      *(unsigned_M*) sim_core_translate (mapping, addr) = H2T_M (val);
      *(unsigned_M*) sim_core_translate (mapping, addr) = H2T_M (val);
    }
    }
  while (0);
  while (0);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  if (TRACE_P (cpu, TRACE_CORE_IDX))
  if (TRACE_P (cpu, TRACE_CORE_IDX))
    sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
    sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
}
}
#endif
#endif
 
 
/* TAGS: sim_core_write_unaligned_1 sim_core_write_unaligned_2 */
/* TAGS: sim_core_write_unaligned_1 sim_core_write_unaligned_2 */
/* TAGS: sim_core_write_unaligned_4 sim_core_write_unaligned_8 */
/* TAGS: sim_core_write_unaligned_4 sim_core_write_unaligned_8 */
/* TAGS: sim_core_write_unaligned_16 */
/* TAGS: sim_core_write_unaligned_16 */
 
 
#if (M == N && N > 1)
#if (M == N && N > 1)
INLINE_SIM_CORE(void)
INLINE_SIM_CORE(void)
sim_core_write_unaligned_N(sim_cpu *cpu,
sim_core_write_unaligned_N(sim_cpu *cpu,
                           sim_cia cia,
                           sim_cia cia,
                           unsigned map,
                           unsigned map,
                           address_word addr,
                           address_word addr,
                           unsigned_M val)
                           unsigned_M val)
{
{
  int alignment = N - 1;
  int alignment = N - 1;
  /* if hardwired to forced alignment just do it */
  /* if hardwired to forced alignment just do it */
  if (WITH_ALIGNMENT == FORCED_ALIGNMENT)
  if (WITH_ALIGNMENT == FORCED_ALIGNMENT)
    sim_core_write_aligned_N (cpu, cia, map, addr & ~alignment, val);
    sim_core_write_aligned_N (cpu, cia, map, addr & ~alignment, val);
  else if ((addr & alignment) == 0)
  else if ((addr & alignment) == 0)
    sim_core_write_aligned_N (cpu, cia, map, addr, val);
    sim_core_write_aligned_N (cpu, cia, map, addr, val);
  else
  else
    switch (CURRENT_ALIGNMENT)
    switch (CURRENT_ALIGNMENT)
      {
      {
      case STRICT_ALIGNMENT:
      case STRICT_ALIGNMENT:
        SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
        SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                         write_transfer, sim_core_unaligned_signal);
                         write_transfer, sim_core_unaligned_signal);
        break;
        break;
      case NONSTRICT_ALIGNMENT:
      case NONSTRICT_ALIGNMENT:
        {
        {
          unsigned_M data = H2T_M (val);
          unsigned_M data = H2T_M (val);
          if (sim_core_xor_write_buffer (CPU_STATE (cpu), cpu, map, &data, addr, N) != N)
          if (sim_core_xor_write_buffer (CPU_STATE (cpu), cpu, map, &data, addr, N) != N)
            SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
            SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                             write_transfer, sim_core_unaligned_signal);
                             write_transfer, sim_core_unaligned_signal);
          PROFILE_COUNT_CORE (cpu, addr, N, map);
          PROFILE_COUNT_CORE (cpu, addr, N, map);
          if (TRACE_P (cpu, TRACE_CORE_IDX))
          if (TRACE_P (cpu, TRACE_CORE_IDX))
            sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
            sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
          break;
          break;
        }
        }
      case FORCED_ALIGNMENT:
      case FORCED_ALIGNMENT:
        sim_core_write_aligned_N (cpu, cia, map, addr & ~alignment, val);
        sim_core_write_aligned_N (cpu, cia, map, addr & ~alignment, val);
        break;
        break;
      case MIXED_ALIGNMENT:
      case MIXED_ALIGNMENT:
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
                          "internal error - %s - mixed alignment",
                          "internal error - %s - mixed alignment",
                          XSTRING (sim_core_write_unaligned_N));
                          XSTRING (sim_core_write_unaligned_N));
        break;
        break;
      default:
      default:
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
        sim_engine_abort (CPU_STATE (cpu), cpu, cia,
                          "internal error - %s - bad switch",
                          "internal error - %s - bad switch",
                          XSTRING (sim_core_write_unaligned_N));
                          XSTRING (sim_core_write_unaligned_N));
        break;
        break;
      }
      }
}
}
#endif
#endif
 
 
/* TAGS: sim_core_write_misaligned_3 sim_core_write_misaligned_5 */
/* TAGS: sim_core_write_misaligned_3 sim_core_write_misaligned_5 */
/* TAGS: sim_core_write_misaligned_6 sim_core_write_misaligned_7 */
/* TAGS: sim_core_write_misaligned_6 sim_core_write_misaligned_7 */
 
 
#if (M != N)
#if (M != N)
INLINE_SIM_CORE(void)
INLINE_SIM_CORE(void)
sim_core_write_misaligned_N(sim_cpu *cpu,
sim_core_write_misaligned_N(sim_cpu *cpu,
                           sim_cia cia,
                           sim_cia cia,
                           unsigned map,
                           unsigned map,
                           address_word addr,
                           address_word addr,
                           unsigned_M val)
                           unsigned_M val)
{
{
  unsigned_M data = val;
  unsigned_M data = val;
  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
  if (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
    data <<= (M - N) * 8;
    data <<= (M - N) * 8;
  if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
  if (CURRENT_HOST_BYTE_ORDER != CURRENT_TARGET_BYTE_ORDER)
    data = SWAP_M (data);
    data = SWAP_M (data);
  if (sim_core_xor_write_buffer (CPU_STATE (cpu), cpu, map, &data, addr, N) != N)
  if (sim_core_xor_write_buffer (CPU_STATE (cpu), cpu, map, &data, addr, N) != N)
    SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
    SIM_CORE_SIGNAL (CPU_STATE (cpu), cpu, cia, map, N, addr,
                     write_transfer, sim_core_unaligned_signal);
                     write_transfer, sim_core_unaligned_signal);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  PROFILE_COUNT_CORE (cpu, addr, N, map);
  if (TRACE_P (cpu, TRACE_CORE_IDX))
  if (TRACE_P (cpu, TRACE_CORE_IDX))
    sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
    sim_core_trace_M (cpu, cia, __LINE__, write_transfer, map, addr, val, N);
}
}
#endif
#endif
 
 
 
 
/* NOTE: see start of file for #define of these macros */
/* NOTE: see start of file for #define of these macros */
#undef unsigned_M
#undef unsigned_M
#undef T2H_M
#undef T2H_M
#undef H2T_M
#undef H2T_M
#undef SWAP_M
#undef SWAP_M
#undef sim_core_read_aligned_N
#undef sim_core_read_aligned_N
#undef sim_core_read_unaligned_N
#undef sim_core_read_unaligned_N
#undef sim_core_read_misaligned_N
#undef sim_core_read_misaligned_N
#undef sim_core_write_aligned_N
#undef sim_core_write_aligned_N
#undef sim_core_write_unaligned_N
#undef sim_core_write_unaligned_N
#undef sim_core_write_misaligned_N
#undef sim_core_write_misaligned_N
#undef sim_core_trace_M
#undef sim_core_trace_M
#undef sim_core_dummy_M
#undef sim_core_dummy_M
#undef M
#undef M
#undef N
#undef N
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.