aboutsummaryrefslogtreecommitdiff
path: root/sim/rx/mem.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2010-07-29 18:41:28 +0000
committerDJ Delorie <dj@redhat.com>2010-07-29 18:41:28 +0000
commitf9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13 (patch)
treea760f9b77fd6470565431634077188b206488346 /sim/rx/mem.c
parentd0d995612d39d0be3e1629f07e524f219e90b92e (diff)
downloadgdb-f9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13.zip
gdb-f9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13.tar.gz
gdb-f9c7014e9c1c8ac8b39b1819a6510d0a2ba90e13.tar.bz2
[include/opcode]
* rx.h (RX_Operand_Type): Add TwoReg. (RX_Opcode_ID): Remove ediv and ediv2. [opcodes] * rx-decode.opc (SRR): New. (rx_decode_opcode): Use it for movbi and movbir. Decode NOP2 (mov r0,r0) and NOP3 (max r0,r0) special cases. * rx-decode.c: Regenerate. [sim/rx] * rx.c (decode_cache_base): New. (id_names): Remove ediv and edivu. (optype_names): Add TwoReg. (maybe_get_mem_page): New. (rx_get_byte): Call it. (get_op): Add TwoReg support. (put_op): Likewise. (PD, PS, PS2, GD, GS, GS2, DSZ, SSZ, S2SZ, US1, US2, OM): "opcode" is a pointer now. (DO_RETURN): New. We use longjmp to return an exception result. (decode_opcode): Make opcode a pointer to the decode cache. Save decoded opcode information and re-use. Call DO_RETURN instead of return throughout. Remove ediv and edivu. * mem.c (ptdc): New. Adds decode cache. (rx_mem_ptr): Support it. (rx_mem_decode_cache): New. * mem.h (enum mem_ptr_action): add MPA_DECODE_CACHE. (rx_mem_decode_cache): Declare. * gdb-if.c (sim_resume): Add decode_opcode's setjmp logic here... * main.c (main): ...and here. Use a fast loop if neither trace nor disassemble is given. * cpu.h (RX_MAKE_STEPPED, RX_MAKE_HIT_BREAK, RX_MAKE_EXITED, RX_MAKE_STOPPED, RX_EXITED, RX_STOPPED): Adjust so that 0 is not a valid code for anything.
Diffstat (limited to 'sim/rx/mem.c')
-rw-r--r--sim/rx/mem.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sim/rx/mem.c b/sim/rx/mem.c
index 3b7a7a2..7405518 100644
--- a/sim/rx/mem.c
+++ b/sim/rx/mem.c
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
#include <string.h>
+#include "opcode/rx.h"
#include "mem.h"
#include "cpu.h"
#include "syscalls.h"
@@ -46,6 +47,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
static unsigned char **pt[L1_LEN];
static unsigned char **ptr[L1_LEN];
+static RX_Opcode_Decoded ***ptdc[L1_LEN];
/* [ get=0/put=1 ][ byte size ] */
static unsigned int mem_counters[2][5];
@@ -85,16 +87,16 @@ rx_mem_ptr (unsigned long address, enum mem_ptr_action action)
{
pt[pt1] = (unsigned char **) calloc (L2_LEN, sizeof (char **));
ptr[pt1] = (unsigned char **) calloc (L2_LEN, sizeof (char **));
+ ptdc[pt1] = (RX_Opcode_Decoded ***) calloc (L2_LEN, sizeof (RX_Opcode_Decoded ***));
}
if (pt[pt1][pt2] == 0)
{
if (action == MPA_READING)
execution_error (SIM_ERR_READ_UNWRITTEN_PAGES, address);
- pt[pt1][pt2] = (unsigned char *) malloc (OFF_LEN);
- memset (pt[pt1][pt2], 0, OFF_LEN);
- ptr[pt1][pt2] = (unsigned char *) malloc (OFF_LEN);
- memset (ptr[pt1][pt2], MC_UNINIT, OFF_LEN);
+ pt[pt1][pt2] = (unsigned char *) calloc (OFF_LEN, 1);
+ ptr[pt1][pt2] = (unsigned char *) calloc (OFF_LEN, 1);
+ ptdc[pt1][pt2] = (RX_Opcode_Decoded **) calloc (OFF_LEN, sizeof(RX_Opcode_Decoded *));
}
else if (action == MPA_READING
&& ptr[pt1][pt2][pto] == MC_UNINIT)
@@ -105,14 +107,28 @@ rx_mem_ptr (unsigned long address, enum mem_ptr_action action)
if (ptr[pt1][pt2][pto] == MC_PUSHED_PC)
execution_error (SIM_ERR_CORRUPT_STACK, address);
ptr[pt1][pt2][pto] = MC_DATA;
+ if (ptdc[pt1][pt2][pto])
+ {
+ free (ptdc[pt1][pt2][pto]);
+ ptdc[pt1][pt2][pto] = NULL;
+ }
}
if (action == MPA_CONTENT_TYPE)
- return ptr[pt1][pt2] + pto;
+ return (unsigned char *) (ptr[pt1][pt2] + pto);
+
+ if (action == MPA_DECODE_CACHE)
+ return (unsigned char *) (ptdc[pt1][pt2] + pto);
return pt[pt1][pt2] + pto;
}
+RX_Opcode_Decoded **
+rx_mem_decode_cache (unsigned long address)
+{
+ return (RX_Opcode_Decoded **) rx_mem_ptr (address, MPA_DECODE_CACHE);
+}
+
static inline int
is_reserved_address (unsigned int address)
{
@@ -335,7 +351,9 @@ mem_put_qi (int address, unsigned char value)
COUNT (1, 1);
}
+#ifdef CYCLE_ACCURATE
static int tpu_base;
+#endif
void
mem_put_hi (int address, unsigned short value)