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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [sim/] [arm/] [armvirt.c] - Diff between revs 227 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 227 Rev 816
/*  armvirt.c -- ARMulator virtual memory interace:  ARM6 Instruction Emulator.
/*  armvirt.c -- ARMulator virtual memory interace:  ARM6 Instruction Emulator.
    Copyright (C) 1994 Advanced RISC Machines Ltd.
    Copyright (C) 1994 Advanced RISC Machines Ltd.
 
 
    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 2 of the License, or
    the Free Software Foundation; either version 2 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, write to the Free Software
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
 
 
/* This file contains a complete ARMulator memory model, modelling a
/* This file contains a complete ARMulator memory model, modelling a
"virtual memory" system. A much simpler model can be found in armfast.c,
"virtual memory" system. A much simpler model can be found in armfast.c,
and that model goes faster too, but has a fixed amount of memory. This
and that model goes faster too, but has a fixed amount of memory. This
model's memory has 64K pages, allocated on demand from a 64K entry page
model's memory has 64K pages, allocated on demand from a 64K entry page
table. The routines PutWord and GetWord implement this. Pages are never
table. The routines PutWord and GetWord implement this. Pages are never
freed as they might be needed again. A single area of memory may be
freed as they might be needed again. A single area of memory may be
defined to generate aborts. */
defined to generate aborts. */
 
 
#include "armopts.h"
#include "armopts.h"
#include "armos.h"
#include "armos.h"
#include "armdefs.h"
#include "armdefs.h"
#include "ansidecl.h"
#include "ansidecl.h"
 
 
#ifdef VALIDATE                 /* for running the validate suite */
#ifdef VALIDATE                 /* for running the validate suite */
#define TUBE 48 * 1024 * 1024   /* write a char on the screen */
#define TUBE 48 * 1024 * 1024   /* write a char on the screen */
#define ABORTS 1
#define ABORTS 1
#endif
#endif
 
 
/* #define ABORTS */
/* #define ABORTS */
 
 
#ifdef ABORTS                   /* the memory system will abort */
#ifdef ABORTS                   /* the memory system will abort */
/* For the old test suite Abort between 32 Kbytes and 32 Mbytes
/* For the old test suite Abort between 32 Kbytes and 32 Mbytes
   For the new test suite Abort between 8 Mbytes and 26 Mbytes */
   For the new test suite Abort between 8 Mbytes and 26 Mbytes */
/* #define LOWABORT 32 * 1024
/* #define LOWABORT 32 * 1024
#define HIGHABORT 32 * 1024 * 1024 */
#define HIGHABORT 32 * 1024 * 1024 */
#define LOWABORT 8 * 1024 * 1024
#define LOWABORT 8 * 1024 * 1024
#define HIGHABORT 26 * 1024 * 1024
#define HIGHABORT 26 * 1024 * 1024
 
 
#endif
#endif
 
 
#define NUMPAGES 64 * 1024
#define NUMPAGES 64 * 1024
#define PAGESIZE 64 * 1024
#define PAGESIZE 64 * 1024
#define PAGEBITS 16
#define PAGEBITS 16
#define OFFSETBITS 0xffff
#define OFFSETBITS 0xffff
 
 
int SWI_vector_installed = FALSE;
int SWI_vector_installed = FALSE;
 
 
/***************************************************************************\
/***************************************************************************\
*        Get a Word from Virtual Memory, maybe allocating the page          *
*        Get a Word from Virtual Memory, maybe allocating the page          *
\***************************************************************************/
\***************************************************************************/
 
 
static ARMword
static ARMword
GetWord (ARMul_State * state, ARMword address, int check)
GetWord (ARMul_State * state, ARMword address, int check)
{
{
  ARMword page;
  ARMword page;
  ARMword offset;
  ARMword offset;
  ARMword **pagetable;
  ARMword **pagetable;
  ARMword *pageptr;
  ARMword *pageptr;
 
 
  if (check && state->is_XScale)
  if (check && state->is_XScale)
    XScale_check_memacc (state, &address, 0);
    XScale_check_memacc (state, &address, 0);
 
 
  page = address >> PAGEBITS;
  page = address >> PAGEBITS;
  offset = (address & OFFSETBITS) >> 2;
  offset = (address & OFFSETBITS) >> 2;
  pagetable = (ARMword **) state->MemDataPtr;
  pagetable = (ARMword **) state->MemDataPtr;
  pageptr = *(pagetable + page);
  pageptr = *(pagetable + page);
 
 
  if (pageptr == NULL)
  if (pageptr == NULL)
    {
    {
      pageptr = (ARMword *) malloc (PAGESIZE);
      pageptr = (ARMword *) malloc (PAGESIZE);
 
 
      if (pageptr == NULL)
      if (pageptr == NULL)
        {
        {
          perror ("ARMulator can't allocate VM page");
          perror ("ARMulator can't allocate VM page");
          exit (12);
          exit (12);
        }
        }
 
 
      *(pagetable + page) = pageptr;
      *(pagetable + page) = pageptr;
    }
    }
 
 
  return *(pageptr + offset);
  return *(pageptr + offset);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*        Put a Word into Virtual Memory, maybe allocating the page          *
*        Put a Word into Virtual Memory, maybe allocating the page          *
\***************************************************************************/
\***************************************************************************/
 
 
static void
static void
PutWord (ARMul_State * state, ARMword address, ARMword data, int check)
PutWord (ARMul_State * state, ARMword address, ARMword data, int check)
{
{
  ARMword page;
  ARMword page;
  ARMword offset;
  ARMword offset;
  ARMword **pagetable;
  ARMword **pagetable;
  ARMword *pageptr;
  ARMword *pageptr;
 
 
  if (check && state->is_XScale)
  if (check && state->is_XScale)
    XScale_check_memacc (state, &address, 1);
    XScale_check_memacc (state, &address, 1);
 
 
  page = address >> PAGEBITS;
  page = address >> PAGEBITS;
  offset = (address & OFFSETBITS) >> 2;
  offset = (address & OFFSETBITS) >> 2;
  pagetable = (ARMword **) state->MemDataPtr;
  pagetable = (ARMword **) state->MemDataPtr;
  pageptr = *(pagetable + page);
  pageptr = *(pagetable + page);
 
 
  if (pageptr == NULL)
  if (pageptr == NULL)
    {
    {
      pageptr = (ARMword *) malloc (PAGESIZE);
      pageptr = (ARMword *) malloc (PAGESIZE);
      if (pageptr == NULL)
      if (pageptr == NULL)
        {
        {
          perror ("ARMulator can't allocate VM page");
          perror ("ARMulator can't allocate VM page");
          exit (13);
          exit (13);
        }
        }
 
 
      *(pagetable + page) = pageptr;
      *(pagetable + page) = pageptr;
    }
    }
 
 
  if (address == 0x8)
  if (address == 0x8)
    SWI_vector_installed = TRUE;
    SWI_vector_installed = TRUE;
 
 
  *(pageptr + offset) = data;
  *(pageptr + offset) = data;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                      Initialise the memory interface                      *
*                      Initialise the memory interface                      *
\***************************************************************************/
\***************************************************************************/
 
 
unsigned
unsigned
ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize)
ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize)
{
{
  ARMword **pagetable;
  ARMword **pagetable;
  unsigned page;
  unsigned page;
 
 
  if (initmemsize)
  if (initmemsize)
    state->MemSize = initmemsize;
    state->MemSize = initmemsize;
 
 
  pagetable = (ARMword **) malloc (sizeof (ARMword *) * NUMPAGES);
  pagetable = (ARMword **) malloc (sizeof (ARMword *) * NUMPAGES);
 
 
  if (pagetable == NULL)
  if (pagetable == NULL)
    return FALSE;
    return FALSE;
 
 
  for (page = 0; page < NUMPAGES; page++)
  for (page = 0; page < NUMPAGES; page++)
    *(pagetable + page) = NULL;
    *(pagetable + page) = NULL;
 
 
  state->MemDataPtr = (unsigned char *) pagetable;
  state->MemDataPtr = (unsigned char *) pagetable;
 
 
  ARMul_ConsolePrint (state, ", 4 Gb memory");
  ARMul_ConsolePrint (state, ", 4 Gb memory");
 
 
  return TRUE;
  return TRUE;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                         Remove the memory interface                       *
*                         Remove the memory interface                       *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_MemoryExit (ARMul_State * state)
ARMul_MemoryExit (ARMul_State * state)
{
{
  ARMword page;
  ARMword page;
  ARMword **pagetable;
  ARMword **pagetable;
  ARMword *pageptr;
  ARMword *pageptr;
 
 
  pagetable = (ARMword **) state->MemDataPtr;
  pagetable = (ARMword **) state->MemDataPtr;
  for (page = 0; page < NUMPAGES; page++)
  for (page = 0; page < NUMPAGES; page++)
    {
    {
      pageptr = *(pagetable + page);
      pageptr = *(pagetable + page);
      if (pageptr != NULL)
      if (pageptr != NULL)
        free ((char *) pageptr);
        free ((char *) pageptr);
    }
    }
  free ((char *) pagetable);
  free ((char *) pagetable);
  return;
  return;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                   ReLoad Instruction                                     *
*                   ReLoad Instruction                                     *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword
ARMword
ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize)
ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize)
{
{
#ifdef ABORTS
#ifdef ABORTS
  if (address >= LOWABORT && address < HIGHABORT)
  if (address >= LOWABORT && address < HIGHABORT)
    {
    {
      ARMul_PREFETCHABORT (address);
      ARMul_PREFETCHABORT (address);
      return ARMul_ABORTWORD;
      return ARMul_ABORTWORD;
    }
    }
  else
  else
    {
    {
      ARMul_CLEARABORT;
      ARMul_CLEARABORT;
    }
    }
#endif
#endif
 
 
  if ((isize == 2) && (address & 0x2))
  if ((isize == 2) && (address & 0x2))
    {
    {
      /* We return the next two halfwords: */
      /* We return the next two halfwords: */
      ARMword lo = GetWord (state, address, FALSE);
      ARMword lo = GetWord (state, address, FALSE);
      ARMword hi = GetWord (state, address + 4, FALSE);
      ARMword hi = GetWord (state, address + 4, FALSE);
 
 
      if (state->bigendSig == HIGH)
      if (state->bigendSig == HIGH)
        return (lo << 16) | (hi >> 16);
        return (lo << 16) | (hi >> 16);
      else
      else
        return ((hi & 0xFFFF) << 16) | (lo >> 16);
        return ((hi & 0xFFFF) << 16) | (lo >> 16);
    }
    }
 
 
  return GetWord (state, address, TRUE);
  return GetWord (state, address, TRUE);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                   Load Instruction, Sequential Cycle                      *
*                   Load Instruction, Sequential Cycle                      *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadInstrS (ARMul_State * state, ARMword address, ARMword isize)
ARMword ARMul_LoadInstrS (ARMul_State * state, ARMword address, ARMword isize)
{
{
  state->NumScycles++;
  state->NumScycles++;
 
 
#ifdef HOURGLASS
#ifdef HOURGLASS
  if ((state->NumScycles & HOURGLASS_RATE) == 0)
  if ((state->NumScycles & HOURGLASS_RATE) == 0)
    {
    {
      HOURGLASS;
      HOURGLASS;
    }
    }
#endif
#endif
 
 
  return ARMul_ReLoadInstr (state, address, isize);
  return ARMul_ReLoadInstr (state, address, isize);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                 Load Instruction, Non Sequential Cycle                    *
*                 Load Instruction, Non Sequential Cycle                    *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadInstrN (ARMul_State * state, ARMword address, ARMword isize)
ARMword ARMul_LoadInstrN (ARMul_State * state, ARMword address, ARMword isize)
{
{
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  return ARMul_ReLoadInstr (state, address, isize);
  return ARMul_ReLoadInstr (state, address, isize);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                      Read Word (but don't tell anyone!)                   *
*                      Read Word (but don't tell anyone!)                   *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_ReadWord (ARMul_State * state, ARMword address)
ARMword ARMul_ReadWord (ARMul_State * state, ARMword address)
{
{
#ifdef ABORTS
#ifdef ABORTS
  if (address >= LOWABORT && address < HIGHABORT)
  if (address >= LOWABORT && address < HIGHABORT)
    {
    {
      ARMul_DATAABORT (address);
      ARMul_DATAABORT (address);
      return ARMul_ABORTWORD;
      return ARMul_ABORTWORD;
    }
    }
  else
  else
    {
    {
      ARMul_CLEARABORT;
      ARMul_CLEARABORT;
    }
    }
#endif
#endif
 
 
  return GetWord (state, address, TRUE);
  return GetWord (state, address, TRUE);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                        Load Word, Sequential Cycle                        *
*                        Load Word, Sequential Cycle                        *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadWordS (ARMul_State * state, ARMword address)
ARMword ARMul_LoadWordS (ARMul_State * state, ARMword address)
{
{
  state->NumScycles++;
  state->NumScycles++;
 
 
  return ARMul_ReadWord (state, address);
  return ARMul_ReadWord (state, address);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                      Load Word, Non Sequential Cycle                      *
*                      Load Word, Non Sequential Cycle                      *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadWordN (ARMul_State * state, ARMword address)
ARMword ARMul_LoadWordN (ARMul_State * state, ARMword address)
{
{
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  return ARMul_ReadWord (state, address);
  return ARMul_ReadWord (state, address);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                     Load Halfword, (Non Sequential Cycle)                 *
*                     Load Halfword, (Non Sequential Cycle)                 *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadHalfWord (ARMul_State * state, ARMword address)
ARMword ARMul_LoadHalfWord (ARMul_State * state, ARMword address)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  temp = ARMul_ReadWord (state, address);
  temp = ARMul_ReadWord (state, address);
  offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3;     /* bit offset into the word */
  offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3;     /* bit offset into the word */
 
 
  return (temp >> offset) & 0xffff;
  return (temp >> offset) & 0xffff;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                      Read Byte (but don't tell anyone!)                   *
*                      Read Byte (but don't tell anyone!)                   *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_ReadByte (ARMul_State * state, ARMword address)
ARMword ARMul_ReadByte (ARMul_State * state, ARMword address)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  temp = ARMul_ReadWord (state, address);
  temp = ARMul_ReadWord (state, address);
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;     /* bit offset into the word */
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;     /* bit offset into the word */
 
 
  return (temp >> offset & 0xffL);
  return (temp >> offset & 0xffL);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                     Load Byte, (Non Sequential Cycle)                     *
*                     Load Byte, (Non Sequential Cycle)                     *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_LoadByte (ARMul_State * state, ARMword address)
ARMword ARMul_LoadByte (ARMul_State * state, ARMword address)
{
{
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  return ARMul_ReadByte (state, address);
  return ARMul_ReadByte (state, address);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                     Write Word (but don't tell anyone!)                   *
*                     Write Word (but don't tell anyone!)                   *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_WriteWord (ARMul_State * state, ARMword address, ARMword data)
ARMul_WriteWord (ARMul_State * state, ARMword address, ARMword data)
{
{
#ifdef ABORTS
#ifdef ABORTS
  if (address >= LOWABORT && address < HIGHABORT)
  if (address >= LOWABORT && address < HIGHABORT)
    {
    {
      ARMul_DATAABORT (address);
      ARMul_DATAABORT (address);
      return;
      return;
    }
    }
  else
  else
    {
    {
      ARMul_CLEARABORT;
      ARMul_CLEARABORT;
    }
    }
#endif
#endif
 
 
  PutWord (state, address, data, TRUE);
  PutWord (state, address, data, TRUE);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                       Store Word, Sequential Cycle                        *
*                       Store Word, Sequential Cycle                        *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_StoreWordS (ARMul_State * state, ARMword address, ARMword data)
ARMul_StoreWordS (ARMul_State * state, ARMword address, ARMword data)
{
{
  state->NumScycles++;
  state->NumScycles++;
 
 
  ARMul_WriteWord (state, address, data);
  ARMul_WriteWord (state, address, data);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                       Store Word, Non Sequential Cycle                        *
*                       Store Word, Non Sequential Cycle                        *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_StoreWordN (ARMul_State * state, ARMword address, ARMword data)
ARMul_StoreWordN (ARMul_State * state, ARMword address, ARMword data)
{
{
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  ARMul_WriteWord (state, address, data);
  ARMul_WriteWord (state, address, data);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                    Store HalfWord, (Non Sequential Cycle)                 *
*                    Store HalfWord, (Non Sequential Cycle)                 *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_StoreHalfWord (ARMul_State * state, ARMword address, ARMword data)
ARMul_StoreHalfWord (ARMul_State * state, ARMword address, ARMword data)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  state->NumNcycles++;
  state->NumNcycles++;
 
 
#ifdef VALIDATE
#ifdef VALIDATE
  if (address == TUBE)
  if (address == TUBE)
    {
    {
      if (data == 4)
      if (data == 4)
        state->Emulate = FALSE;
        state->Emulate = FALSE;
      else
      else
        (void) putc ((char) data, stderr);      /* Write Char */
        (void) putc ((char) data, stderr);      /* Write Char */
      return;
      return;
    }
    }
#endif
#endif
 
 
  temp = ARMul_ReadWord (state, address);
  temp = ARMul_ReadWord (state, address);
  offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3;     /* bit offset into the word */
  offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3;     /* bit offset into the word */
 
 
  PutWord (state, address,
  PutWord (state, address,
           (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset),
           (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset),
           TRUE);
           TRUE);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                     Write Byte (but don't tell anyone!)                   *
*                     Write Byte (but don't tell anyone!)                   *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_WriteByte (ARMul_State * state, ARMword address, ARMword data)
ARMul_WriteByte (ARMul_State * state, ARMword address, ARMword data)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  temp = ARMul_ReadWord (state, address);
  temp = ARMul_ReadWord (state, address);
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;     /* bit offset into the word */
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;     /* bit offset into the word */
 
 
  PutWord (state, address,
  PutWord (state, address,
           (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
           (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
           TRUE);
           TRUE);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                    Store Byte, (Non Sequential Cycle)                     *
*                    Store Byte, (Non Sequential Cycle)                     *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_StoreByte (ARMul_State * state, ARMword address, ARMword data)
ARMul_StoreByte (ARMul_State * state, ARMword address, ARMword data)
{
{
  state->NumNcycles++;
  state->NumNcycles++;
 
 
#ifdef VALIDATE
#ifdef VALIDATE
  if (address == TUBE)
  if (address == TUBE)
    {
    {
      if (data == 4)
      if (data == 4)
        state->Emulate = FALSE;
        state->Emulate = FALSE;
      else
      else
        (void) putc ((char) data, stderr);      /* Write Char */
        (void) putc ((char) data, stderr);      /* Write Char */
      return;
      return;
    }
    }
#endif
#endif
 
 
  ARMul_WriteByte (state, address, data);
  ARMul_WriteByte (state, address, data);
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                   Swap Word, (Two Non Sequential Cycles)                  *
*                   Swap Word, (Two Non Sequential Cycles)                  *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_SwapWord (ARMul_State * state, ARMword address, ARMword data)
ARMword ARMul_SwapWord (ARMul_State * state, ARMword address, ARMword data)
{
{
  ARMword temp;
  ARMword temp;
 
 
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  temp = ARMul_ReadWord (state, address);
  temp = ARMul_ReadWord (state, address);
 
 
  state->NumNcycles++;
  state->NumNcycles++;
 
 
  PutWord (state, address, data, TRUE);
  PutWord (state, address, data, TRUE);
 
 
  return temp;
  return temp;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                   Swap Byte, (Two Non Sequential Cycles)                  *
*                   Swap Byte, (Two Non Sequential Cycles)                  *
\***************************************************************************/
\***************************************************************************/
 
 
ARMword ARMul_SwapByte (ARMul_State * state, ARMword address, ARMword data)
ARMword ARMul_SwapByte (ARMul_State * state, ARMword address, ARMword data)
{
{
  ARMword temp;
  ARMword temp;
 
 
  temp = ARMul_LoadByte (state, address);
  temp = ARMul_LoadByte (state, address);
  ARMul_StoreByte (state, address, data);
  ARMul_StoreByte (state, address, data);
 
 
  return temp;
  return temp;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                             Count I Cycles                                *
*                             Count I Cycles                                *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_Icycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_UNUSED)
ARMul_Icycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_UNUSED)
{
{
  state->NumIcycles += number;
  state->NumIcycles += number;
  ARMul_CLEARABORT;
  ARMul_CLEARABORT;
}
}
 
 
/***************************************************************************\
/***************************************************************************\
*                             Count C Cycles                                *
*                             Count C Cycles                                *
\***************************************************************************/
\***************************************************************************/
 
 
void
void
ARMul_Ccycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_UNUSED)
ARMul_Ccycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_UNUSED)
{
{
  state->NumCcycles += number;
  state->NumCcycles += number;
  ARMul_CLEARABORT;
  ARMul_CLEARABORT;
}
}
 
 
 
 
/* Read a byte.  Do not check for alignment or access errors.  */
/* Read a byte.  Do not check for alignment or access errors.  */
 
 
ARMword
ARMword
ARMul_SafeReadByte (ARMul_State * state, ARMword address)
ARMul_SafeReadByte (ARMul_State * state, ARMword address)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  temp = GetWord (state, address, FALSE);
  temp = GetWord (state, address, FALSE);
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
 
 
  return (temp >> offset & 0xffL);
  return (temp >> offset & 0xffL);
}
}
 
 
void
void
ARMul_SafeWriteByte (ARMul_State * state, ARMword address, ARMword data)
ARMul_SafeWriteByte (ARMul_State * state, ARMword address, ARMword data)
{
{
  ARMword temp, offset;
  ARMword temp, offset;
 
 
  temp = GetWord (state, address, FALSE);
  temp = GetWord (state, address, FALSE);
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
  offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
 
 
  PutWord (state, address,
  PutWord (state, address,
           (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
           (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
           FALSE);
           FALSE);
}
}
 
 

powered by: WebSVN 2.1.0

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