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
+ 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,
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. */
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* This file contains a complete ARMulator memory model, modelling a
"virtual memory" system. A much simpler model can be found in armfast.c,
defined to generate aborts. */
#include "armopts.h"
+#include "armos.h"
#include "armdefs.h"
#include "ansidecl.h"
#define ABORTS 1
#endif
-#define ABORTS
+/* #define ABORTS */
#ifdef ABORTS /* the memory system will abort */
/* For the old test suite Abort between 32 Kbytes and 32 Mbytes
#define PAGEBITS 16
#define OFFSETBITS 0xffff
+int SWI_vector_installed = FALSE;
+
/***************************************************************************\
* Get a Word from Virtual Memory, maybe allocating the page *
\***************************************************************************/
static ARMword
-GetWord (ARMul_State * state, ARMword address)
+GetWord (ARMul_State * state, ARMword address, int check)
{
ARMword page;
ARMword offset;
ARMword **pagetable;
ARMword *pageptr;
+ if (check && state->is_XScale)
+ XScale_check_memacc (state, &address, 0);
+
page = address >> PAGEBITS;
offset = (address & OFFSETBITS) >> 2;
pagetable = (ARMword **) state->MemDataPtr;
\***************************************************************************/
static void
-PutWord (ARMul_State * state, ARMword address, ARMword data)
+PutWord (ARMul_State * state, ARMword address, ARMword data, int check)
{
ARMword page;
ARMword offset;
ARMword **pagetable;
ARMword *pageptr;
+ if (check && state->is_XScale)
+ XScale_check_memacc (state, &address, 1);
+
page = address >> PAGEBITS;
offset = (address & OFFSETBITS) >> 2;
pagetable = (ARMword **) state->MemDataPtr;
*(pagetable + page) = pageptr;
}
+ if (address == 0x8)
+ SWI_vector_installed = TRUE;
+
*(pageptr + offset) = data;
}
if (initmemsize)
state->MemSize = initmemsize;
- pagetable = (ARMword **) malloc (sizeof (ARMword) * NUMPAGES);
+ pagetable = (ARMword **) malloc (sizeof (ARMword *) * NUMPAGES);
if (pagetable == NULL)
return FALSE;
if ((isize == 2) && (address & 0x2))
{
/* We return the next two halfwords: */
- ARMword lo = GetWord (state, address);
- ARMword hi = GetWord (state, address + 4);
+ ARMword lo = GetWord (state, address, FALSE);
+ ARMword hi = GetWord (state, address + 4, FALSE);
if (state->bigendSig == HIGH)
return (lo << 16) | (hi >> 16);
return ((hi & 0xFFFF) << 16) | (lo >> 16);
}
- return GetWord (state, address);
+ return GetWord (state, address, TRUE);
}
/***************************************************************************\
}
#endif
- return GetWord (state, address);
+ return GetWord (state, address, TRUE);
}
/***************************************************************************\
}
#endif
- PutWord (state, address, data);
+ PutWord (state, address, data, TRUE);
}
/***************************************************************************\
offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3; /* bit offset into the word */
PutWord (state, address,
- (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset));
+ (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset),
+ TRUE);
}
/***************************************************************************\
offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3; /* bit offset into the word */
PutWord (state, address,
- (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset));
+ (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
+ TRUE);
}
/***************************************************************************\
state->NumNcycles++;
- PutWord (state, address, data);
+ PutWord (state, address, data, TRUE);
return temp;
}
state->NumCcycles += number;
ARMul_CLEARABORT;
}
+
+
+/* Read a byte. Do not check for alignment or access errors. */
+
+ARMword
+ARMul_SafeReadByte (ARMul_State * state, ARMword address)
+{
+ ARMword temp, offset;
+
+ temp = GetWord (state, address, FALSE);
+ offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
+
+ return (temp >> offset & 0xffL);
+}
+
+void
+ARMul_SafeWriteByte (ARMul_State * state, ARMword address, ARMword data)
+{
+ ARMword temp, offset;
+
+ temp = GetWord (state, address, FALSE);
+ offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;
+
+ PutWord (state, address,
+ (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset),
+ FALSE);
+}