Remove i386_elf_emit_arch_note
[deliverable/binutils-gdb.git] / sim / arm / armvirt.c
index 38f0083d2d8df7eb73088460394f5cb03d882632..31ff8d8c59eb2795c22d3e91a821d05a434033d7 100644 (file)
@@ -3,7 +3,7 @@
  
     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
  
     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,
     (at your option) any later version.
  
     This program is distributed in the hope that it will be useful,
@@ -12,8 +12,7 @@
     GNU General Public License for more details.
  
     You should have received a copy of the GNU General Public License
     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,
 
 /* This file contains a complete ARMulator memory model, modelling a
 "virtual memory" system. A much simpler model can be found in armfast.c,
@@ -24,6 +23,7 @@ freed as they might be needed again. A single area of memory may be
 defined to generate aborts. */
 
 #include "armopts.h"
 defined to generate aborts. */
 
 #include "armopts.h"
+#include "armos.h"
 #include "armdefs.h"
 #include "ansidecl.h"
 
 #include "armdefs.h"
 #include "ansidecl.h"
 
@@ -32,7 +32,7 @@ defined to generate aborts. */
 #define ABORTS 1
 #endif
 
 #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
 
 #ifdef ABORTS                  /* the memory system will abort */
 /* For the old test suite Abort between 32 Kbytes and 32 Mbytes
@@ -49,18 +49,23 @@ defined to generate aborts. */
 #define PAGEBITS 16
 #define OFFSETBITS 0xffff
 
 #define PAGEBITS 16
 #define OFFSETBITS 0xffff
 
+int SWI_vector_installed = FALSE;
+
 /***************************************************************************\
 *        Get a Word from Virtual Memory, maybe allocating the page          *
 \***************************************************************************/
 
 static ARMword
 /***************************************************************************\
 *        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;
 
 {
   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;
   page = address >> PAGEBITS;
   offset = (address & OFFSETBITS) >> 2;
   pagetable = (ARMword **) state->MemDataPtr;
@@ -87,13 +92,16 @@ GetWord (ARMul_State * state, ARMword address)
 \***************************************************************************/
 
 static void
 \***************************************************************************/
 
 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;
 
 {
   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;
   page = address >> PAGEBITS;
   offset = (address & OFFSETBITS) >> 2;
   pagetable = (ARMword **) state->MemDataPtr;
@@ -111,6 +119,9 @@ PutWord (ARMul_State * state, ARMword address, ARMword data)
       *(pagetable + page) = pageptr;
     }
 
       *(pagetable + page) = pageptr;
     }
 
+  if (address == 0x8)
+    SWI_vector_installed = TRUE;
+
   *(pageptr + offset) = data;
 }
 
   *(pageptr + offset) = data;
 }
 
@@ -127,7 +138,7 @@ ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize)
   if (initmemsize)
     state->MemSize = initmemsize;
 
   if (initmemsize)
     state->MemSize = initmemsize;
 
-  pagetable = (ARMword **) malloc (sizeof (ARMword) * NUMPAGES);
+  pagetable = (ARMword **) malloc (sizeof (ARMword *) * NUMPAGES);
 
   if (pagetable == NULL)
     return FALSE;
 
   if (pagetable == NULL)
     return FALSE;
@@ -186,8 +197,8 @@ ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize)
   if ((isize == 2) && (address & 0x2))
     {
       /* We return the next two halfwords: */
   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);
 
       if (state->bigendSig == HIGH)
        return (lo << 16) | (hi >> 16);
@@ -195,7 +206,7 @@ ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize)
        return ((hi & 0xFFFF) << 16) | (lo >> 16);
     }
 
        return ((hi & 0xFFFF) << 16) | (lo >> 16);
     }
 
-  return GetWord (state, address);
+  return GetWord (state, address, TRUE);
 }
 
 /***************************************************************************\
 }
 
 /***************************************************************************\
@@ -245,7 +256,7 @@ ARMword ARMul_ReadWord (ARMul_State * state, ARMword address)
     }
 #endif
 
     }
 #endif
 
-  return GetWord (state, address);
+  return GetWord (state, address, TRUE);
 }
 
 /***************************************************************************\
 }
 
 /***************************************************************************\
@@ -330,7 +341,7 @@ ARMul_WriteWord (ARMul_State * state, ARMword address, ARMword data)
     }
 #endif
 
     }
 #endif
 
-  PutWord (state, address, data);
+  PutWord (state, address, data, TRUE);
 }
 
 /***************************************************************************\
 }
 
 /***************************************************************************\
@@ -383,7 +394,8 @@ ARMul_StoreHalfWord (ARMul_State * state, ARMword address, ARMword data)
   offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3;    /* bit offset into the word */
 
   PutWord (state, address,
   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);
 }
 
 /***************************************************************************\
 }
 
 /***************************************************************************\
@@ -399,7 +411,8 @@ ARMul_WriteByte (ARMul_State * state, ARMword address, ARMword data)
   offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3;    /* bit offset into the word */
 
   PutWord (state, address,
   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);
 }
 
 /***************************************************************************\
 }
 
 /***************************************************************************\
@@ -439,7 +452,7 @@ ARMword ARMul_SwapWord (ARMul_State * state, ARMword address, ARMword data)
 
   state->NumNcycles++;
 
 
   state->NumNcycles++;
 
-  PutWord (state, address, data);
+  PutWord (state, address, data, TRUE);
 
   return temp;
 }
 
   return temp;
 }
@@ -479,3 +492,30 @@ ARMul_Ccycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_U
   state->NumCcycles += number;
   ARMul_CLEARABORT;
 }
   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);
+}
This page took 0.025741 seconds and 4 git commands to generate.