diff options
author | Jason Molenda <jmolenda@apple.com> | 2000-02-05 07:30:26 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2000-02-05 07:30:26 +0000 |
commit | dfcd3bfb6f8a213007c20e60060b4e9ec9205205 (patch) | |
tree | c43f1f196f08266345d283414914033ecc50bd5e /sim/arm/armvirt.c | |
parent | 32edc927faea39b1f7be4654f6ffa03f3e6b16ce (diff) | |
download | gdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.zip gdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.tar.gz gdb-dfcd3bfb6f8a213007c20e60060b4e9ec9205205.tar.bz2 |
import gdb-2000-02-04 snapshot
Diffstat (limited to 'sim/arm/armvirt.c')
-rw-r--r-- | sim/arm/armvirt.c | 221 |
1 files changed, 105 insertions, 116 deletions
diff --git a/sim/arm/armvirt.c b/sim/arm/armvirt.c index 57ebedf..ffcebd2 100644 --- a/sim/arm/armvirt.c +++ b/sim/arm/armvirt.c @@ -26,14 +26,14 @@ defined to generate aborts. */ #include "armopts.h" #include "armdefs.h" -#ifdef VALIDATE /* for running the validate suite */ -#define TUBE 48 * 1024 * 1024 /* write a char on the screen */ +#ifdef VALIDATE /* for running the validate suite */ +#define TUBE 48 * 1024 * 1024 /* write a char on the screen */ #define ABORTS 1 #endif #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 new test suite Abort between 8 Mbytes and 26 Mbytes */ /* #define LOWABORT 32 * 1024 @@ -55,29 +55,29 @@ defined to generate aborts. */ static ARMword GetWord (ARMul_State * state, ARMword address) { - ARMword page; - ARMword offset; - ARMword ** pagetable; - ARMword * pageptr; + ARMword page; + ARMword offset; + ARMword **pagetable; + ARMword *pageptr; - page = address >> PAGEBITS; - offset = (address & OFFSETBITS) >> 2; + page = address >> PAGEBITS; + offset = (address & OFFSETBITS) >> 2; pagetable = (ARMword **) state->MemDataPtr; - pageptr = *(pagetable + page); - + pageptr = *(pagetable + page); + if (pageptr == NULL) { pageptr = (ARMword *) malloc (PAGESIZE); - + if (pageptr == NULL) { perror ("ARMulator can't allocate VM page"); exit (12); } - + *(pagetable + page) = pageptr; } - + return *(pageptr + offset); } @@ -88,28 +88,28 @@ GetWord (ARMul_State * state, ARMword address) static void PutWord (ARMul_State * state, ARMword address, ARMword data) { - ARMword page; - ARMword offset; - ARMword ** pagetable; - ARMword * pageptr; - - page = address >> PAGEBITS; - offset = (address & OFFSETBITS) >> 2; - pagetable = (ARMword **)state->MemDataPtr; - pageptr = *(pagetable + page); - + ARMword page; + ARMword offset; + ARMword **pagetable; + ARMword *pageptr; + + page = address >> PAGEBITS; + offset = (address & OFFSETBITS) >> 2; + pagetable = (ARMword **) state->MemDataPtr; + pageptr = *(pagetable + page); + if (pageptr == NULL) { pageptr = (ARMword *) malloc (PAGESIZE); if (pageptr == NULL) { perror ("ARMulator can't allocate VM page"); - exit(13); + exit (13); } - + *(pagetable + page) = pageptr; } - + *(pageptr + offset) = data; } @@ -120,25 +120,25 @@ PutWord (ARMul_State * state, ARMword address, ARMword data) unsigned ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize) { - ARMword ** pagetable; - unsigned page; + ARMword **pagetable; + unsigned page; if (initmemsize) state->MemSize = initmemsize; - + pagetable = (ARMword **) malloc (sizeof (ARMword) * NUMPAGES); - + if (pagetable == NULL) return FALSE; - - for (page = 0 ; page < NUMPAGES ; page++) + + for (page = 0; page < NUMPAGES; page++) *(pagetable + page) = NULL; - - state->MemDataPtr = (unsigned char *)pagetable; + + state->MemDataPtr = (unsigned char *) pagetable; ARMul_ConsolePrint (state, ", 4 Gb memory"); - - return TRUE; + + return TRUE; } /***************************************************************************\ @@ -148,18 +148,18 @@ ARMul_MemoryInit (ARMul_State * state, unsigned long initmemsize) void ARMul_MemoryExit (ARMul_State * state) { - ARMword page; - ARMword ** pagetable; - ARMword * pageptr; + ARMword page; + ARMword **pagetable; + ARMword *pageptr; - pagetable = (ARMword **)state->MemDataPtr; - for (page = 0 ; page < NUMPAGES ; page++) + pagetable = (ARMword **) state->MemDataPtr; + for (page = 0; page < NUMPAGES; page++) { pageptr = *(pagetable + page); if (pageptr != NULL) - free ((char *)pageptr); + free ((char *) pageptr); } - free ((char *)pagetable); + free ((char *) pagetable); return; } @@ -171,28 +171,28 @@ ARMword ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize) { #ifdef ABORTS - if (address >= LOWABORT && address < HIGHABORT) + if (address >= LOWABORT && address < HIGHABORT) { ARMul_PREFETCHABORT (address); return ARMul_ABORTWORD; } - else - { - ARMul_CLEARABORT; - } + else + { + ARMul_CLEARABORT; + } #endif - if ((isize == 2) && (address & 0x2)) - { - /* We return the next two halfwords: */ - ARMword lo = GetWord (state, address); - ARMword hi = GetWord (state, address + 4); + if ((isize == 2) && (address & 0x2)) + { + /* We return the next two halfwords: */ + ARMword lo = GetWord (state, address); + ARMword hi = GetWord (state, address + 4); - if (state->bigendSig == HIGH) - return (lo << 16) | (hi >> 16); - else - return ((hi & 0xFFFF) << 16) | (lo >> 16); - } + if (state->bigendSig == HIGH) + return (lo << 16) | (hi >> 16); + else + return ((hi & 0xFFFF) << 16) | (lo >> 16); + } return GetWord (state, address); } @@ -201,13 +201,12 @@ ARMul_ReLoadInstr (ARMul_State * state, ARMword address, ARMword isize) * 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 - if (( state->NumScycles & HOURGLASS_RATE ) == 0) + if ((state->NumScycles & HOURGLASS_RATE) == 0) { HOURGLASS; } @@ -220,10 +219,9 @@ ARMul_LoadInstrS (ARMul_State * state, ARMword address, ARMword isize) * 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); } @@ -232,8 +230,7 @@ ARMul_LoadInstrN (ARMul_State * state, ARMword address, ARMword isize) * 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 if (address >= LOWABORT && address < HIGHABORT) @@ -254,10 +251,9 @@ ARMul_ReadWord (ARMul_State * state, ARMword address) * 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); } @@ -266,11 +262,10 @@ ARMul_LoadWordS (ARMul_State * state, ARMword address) * 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); } @@ -278,15 +273,14 @@ ARMul_LoadWordN (ARMul_State * state, ARMword address) * Load Halfword, (Non Sequential Cycle) * \***************************************************************************/ -ARMword -ARMul_LoadHalfWord (ARMul_State * state, ARMword address) +ARMword ARMul_LoadHalfWord (ARMul_State * state, ARMword address) { ARMword temp, offset; - state->NumNcycles ++; + state->NumNcycles++; - temp = ARMul_ReadWord (state, address); - offset = (((ARMword)state->bigendSig * 2) ^ (address & 2)) << 3; /* bit offset into the word */ + temp = ARMul_ReadWord (state, address); + offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3; /* bit offset into the word */ return (temp >> offset) & 0xffff; } @@ -295,25 +289,23 @@ ARMul_LoadHalfWord (ARMul_State * state, ARMword address) * 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; - temp = ARMul_ReadWord (state, address); - offset = (((ARMword)state->bigendSig * 3) ^ (address & 3)) << 3; /* bit offset into the word */ + temp = ARMul_ReadWord (state, address); + 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) * \***************************************************************************/ -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); } @@ -347,7 +339,7 @@ ARMul_WriteWord (ARMul_State * state, ARMword address, ARMword data) void ARMul_StoreWordS (ARMul_State * state, ARMword address, ARMword data) { - state->NumScycles ++; + state->NumScycles++; ARMul_WriteWord (state, address, data); } @@ -359,7 +351,7 @@ ARMul_StoreWordS (ARMul_State * state, ARMword address, ARMword data) void ARMul_StoreWordN (ARMul_State * state, ARMword address, ARMword data) { - state->NumNcycles ++; + state->NumNcycles++; ARMul_WriteWord (state, address, data); } @@ -373,23 +365,24 @@ ARMul_StoreHalfWord (ARMul_State * state, ARMword address, ARMword data) { ARMword temp, offset; - state->NumNcycles ++; - + state->NumNcycles++; + #ifdef VALIDATE if (address == TUBE) { if (data == 4) state->Emulate = FALSE; else - (void) putc ((char)data, stderr); /* Write Char */ + (void) putc ((char) data, stderr); /* Write Char */ return; } #endif - temp = ARMul_ReadWord (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 = ARMul_ReadWord (state, address); + offset = (((ARMword) state->bigendSig * 2) ^ (address & 2)) << 3; /* bit offset into the word */ + + PutWord (state, address, + (temp & ~(0xffffL << offset)) | ((data & 0xffffL) << offset)); } /***************************************************************************\ @@ -401,10 +394,11 @@ ARMul_WriteByte (ARMul_State * state, ARMword address, ARMword data) { ARMword temp, offset; - temp = ARMul_ReadWord (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 = ARMul_ReadWord (state, address); + offset = (((ARMword) state->bigendSig * 3) ^ (address & 3)) << 3; /* bit offset into the word */ + + PutWord (state, address, + (temp & ~(0xffL << offset)) | ((data & 0xffL) << offset)); } /***************************************************************************\ @@ -414,7 +408,7 @@ ARMul_WriteByte (ARMul_State * state, ARMword address, ARMword data) void ARMul_StoreByte (ARMul_State * state, ARMword address, ARMword data) { - state->NumNcycles ++; + state->NumNcycles++; #ifdef VALIDATE if (address == TUBE) @@ -422,7 +416,7 @@ ARMul_StoreByte (ARMul_State * state, ARMword address, ARMword data) if (data == 4) state->Emulate = FALSE; else - (void) putc ((char)data,stderr); /* Write Char */ + (void) putc ((char) data, stderr); /* Write Char */ return; } #endif @@ -434,19 +428,18 @@ ARMul_StoreByte (ARMul_State * state, ARMword address, ARMword data) * 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; - state->NumNcycles ++; + state->NumNcycles++; temp = ARMul_ReadWord (state, address); - - state->NumNcycles ++; - + + state->NumNcycles++; + PutWord (state, address, data); - + return temp; } @@ -454,14 +447,13 @@ ARMul_SwapWord (ARMul_State * state, ARMword address, ARMword data) * 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; temp = ARMul_LoadByte (state, address); ARMul_StoreByte (state, address, data); - + return temp; } @@ -486,6 +478,3 @@ ARMul_Ccycles (ARMul_State * state, unsigned number, ARMword address) state->NumCcycles += number; ARMul_CLEARABORT; } - - - |