X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Farm%2Farmvirt.c;h=31ff8d8c59eb2795c22d3e91a821d05a434033d7;hb=00923338dec84505addaf9cdeca2e9c844757824;hp=b9a018b997a2e61da7a48228eb816a38971d2473;hpb=88694af3f9e50c9196913fc0246cad42a0ae4d80;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/arm/armvirt.c b/sim/arm/armvirt.c index b9a018b997..31ff8d8c59 100644 --- a/sim/arm/armvirt.c +++ b/sim/arm/armvirt.c @@ -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 - 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, @@ -12,8 +12,7 @@ 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 . */ /* 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" +#include "armos.h" #include "armdefs.h" #include "ansidecl.h" @@ -56,13 +56,16 @@ int SWI_vector_installed = FALSE; \***************************************************************************/ 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; @@ -89,13 +92,16 @@ GetWord (ARMul_State * state, ARMword address) \***************************************************************************/ 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; @@ -132,7 +138,7 @@ ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize) if (initmemsize) state->MemSize = initmemsize; - pagetable = (ARMword **) malloc (sizeof (ARMword) * NUMPAGES); + pagetable = (ARMword **) malloc (sizeof (ARMword *) * NUMPAGES); if (pagetable == NULL) return FALSE; @@ -191,8 +197,8 @@ ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize) 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); @@ -200,7 +206,7 @@ ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize) return ((hi & 0xFFFF) << 16) | (lo >> 16); } - return GetWord (state, address); + return GetWord (state, address, TRUE); } /***************************************************************************\ @@ -250,7 +256,7 @@ ARMword ARMul_ReadWord (ARMul_State * state, ARMword address) } #endif - return GetWord (state, address); + return GetWord (state, address, TRUE); } /***************************************************************************\ @@ -335,7 +341,7 @@ ARMul_WriteWord (ARMul_State * state, ARMword address, ARMword data) } #endif - PutWord (state, address, data); + PutWord (state, address, data, TRUE); } /***************************************************************************\ @@ -388,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, - (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset)); + (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset), + TRUE); } /***************************************************************************\ @@ -404,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, - (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset)); + (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset), + TRUE); } /***************************************************************************\ @@ -444,7 +452,7 @@ ARMword ARMul_SwapWord (ARMul_State * state, ARMword address, ARMword data) state->NumNcycles++; - PutWord (state, address, data); + PutWord (state, address, data, TRUE); return temp; } @@ -484,3 +492,30 @@ ARMul_Ccycles (ARMul_State * state, unsigned number, ARMword address ATTRIBUTE_U 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); +}