#endif
-unsigned32 trace_values[3];
-int trace_num_values;
-unsigned32 trace_pc;
-const char *trace_name;
-int trace_module;
+unsigned32 trace_values[3];
+int trace_num_values;
+unsigned32 trace_pc;
+const char * trace_name;
+int trace_module;
void
-trace_input (name, type, size)
- char *name;
- enum op_types type;
- int size;
+trace_input (char *name, enum op_types type, int size)
{
-
if (!TRACE_ALU_P (STATE_CPU (simulator, 0)))
return;
/* append any result to the end of the buffer */
if (has_result)
- sprintf (chp, " :: 0x%.8lx", (unsigned long)result);
+ sprintf (chp, " :: 0x%.8lx", (unsigned long) result);
- trace_generic (simulator, STATE_CPU (simulator, 0), trace_module, buf);
+ trace_generic (simulator, STATE_CPU (simulator, 0), trace_module, "%s", buf);
}
void
-trace_output (result)
- enum op_types result;
+trace_output (enum op_types result)
{
if (!TRACE_ALU_P (STATE_CPU (simulator, 0)))
return;
}
\f
-/* Read a null terminated string from memory, return in a buffer */
+/* Read a null terminated string from memory, return in a buffer. */
+
static char *
-fetch_str (sd, addr)
- SIM_DESC sd;
- address_word addr;
+fetch_str (SIM_DESC sd, address_word addr)
{
char *buf;
int nr = 0;
+
while (sim_core_read_1 (STATE_CPU (sd, 0),
PC, read_map, addr + nr) != 0)
nr++;
+
buf = NZALLOC (char, nr + 1);
- sim_read (simulator, addr, buf, nr);
+ sim_read (simulator, addr, (unsigned char *) buf, nr);
+
return buf;
}
/* Read a null terminated argument vector from memory, return in a
- buffer */
+ buffer. */
+
static char **
-fetch_argv (sd, addr)
- SIM_DESC sd;
- address_word addr;
+fetch_argv (SIM_DESC sd, address_word addr)
{
int max_nr = 64;
int nr = 0;
char **buf = xmalloc (max_nr * sizeof (char*));
+
while (1)
{
unsigned32 a = sim_core_read_4 (STATE_CPU (sd, 0),
\f
/* sst.b */
int
-OP_380 ()
+OP_380 (void)
{
trace_input ("sst.b", OP_STORE16, 1);
/* sst.h */
int
-OP_480 ()
+OP_480 (void)
{
trace_input ("sst.h", OP_STORE16, 2);
/* sst.w */
int
-OP_501 ()
+OP_501 (void)
{
trace_input ("sst.w", OP_STORE16, 4);
/* ld.b */
int
-OP_700 ()
+OP_700 (void)
{
int adr;
/* ld.h */
int
-OP_720 ()
+OP_720 (void)
{
int adr;
/* ld.w */
int
-OP_10720 ()
+OP_10720 (void)
{
int adr;
/* st.b */
int
-OP_740 ()
+OP_740 (void)
{
trace_input ("st.b", OP_STORE32, 1);
/* st.h */
int
-OP_760 ()
+OP_760 (void)
{
int adr;
/* st.w */
int
-OP_10760 ()
+OP_10760 (void)
{
int adr;
/* add reg, reg */
int
-OP_1C0 ()
+OP_1C0 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
/* add sign_extend(imm5), reg */
int
-OP_240 ()
+OP_240 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
int temp;
/* addi sign_extend(imm16), reg, reg */
int
-OP_600 ()
+OP_600 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
/* sub reg1, reg2 */
int
-OP_1A0 ()
+OP_1A0 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
/* subr reg1, reg2 */
int
-OP_180 ()
+OP_180 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
/* sxh reg1 */
int
-OP_E0 ()
+OP_E0 (void)
{
trace_input ("mulh", OP_REG_REG, 0);
/* mulh sign_extend(imm5), reg2 */
int
-OP_2E0 ()
+OP_2E0 (void)
{
trace_input ("mulh", OP_IMM_REG, 0);
/* mulhi imm16, reg1, reg2 */
int
-OP_6E0 ()
+OP_6E0 (void)
{
trace_input ("mulhi", OP_IMM16_REG_REG, 0);
/* cmp reg, reg */
int
-OP_1E0 ()
+OP_1E0 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
/* cmp sign_extend(imm5), reg */
int
-OP_260 ()
+OP_260 (void)
{
unsigned int op0, op1, result, z, s, cy, ov;
int temp;
/* setf cccc,reg2 */
int
-OP_7E0 ()
+OP_7E0 (void)
{
trace_input ("setf", OP_EX1, 0);
/* satadd reg,reg */
int
-OP_C0 ()
+OP_C0 (void)
{
unsigned int op0, op1, result, z, s, cy, ov, sat;
/* satadd sign_extend(imm5), reg */
int
-OP_220 ()
+OP_220 (void)
{
unsigned int op0, op1, result, z, s, cy, ov, sat;
/* satsub reg1, reg2 */
int
-OP_A0 ()
+OP_A0 (void)
{
unsigned int op0, op1, result, z, s, cy, ov, sat;
/* satsubi sign_extend(imm16), reg */
int
-OP_660 ()
+OP_660 (void)
{
unsigned int op0, op1, result, z, s, cy, ov, sat;
int temp;
/* satsubr reg,reg */
int
-OP_80 ()
+OP_80 (void)
{
unsigned int op0, op1, result, z, s, cy, ov, sat;
/* tst reg,reg */
int
-OP_160 ()
+OP_160 (void)
{
unsigned int op0, op1, result, z, s;
/* mov sign_extend(imm5), reg */
int
-OP_200 ()
+OP_200 (void)
{
int value = SEXT5 (OP[0]);
/* movhi imm16, reg, reg */
int
-OP_640 ()
+OP_640 (void)
{
trace_input ("movhi", OP_UIMM16_REG_REG, 16);
/* sar zero_extend(imm5),reg1 */
int
-OP_2A0 ()
+OP_2A0 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* sar reg1, reg2 */
int
-OP_A007E0 ()
+OP_A007E0 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* shl zero_extend(imm5),reg1 */
int
-OP_2C0 ()
+OP_2C0 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* shl reg1, reg2 */
int
-OP_C007E0 ()
+OP_C007E0 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* shr zero_extend(imm5),reg1 */
int
-OP_280 ()
+OP_280 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* shr reg1, reg2 */
int
-OP_8007E0 ()
+OP_8007E0 (void)
{
unsigned int op0, op1, result, z, s, cy;
/* or reg, reg */
int
-OP_100 ()
+OP_100 (void)
{
unsigned int op0, op1, result, z, s;
/* ori zero_extend(imm16), reg, reg */
int
-OP_680 ()
+OP_680 (void)
{
unsigned int op0, op1, result, z, s;
/* and reg, reg */
int
-OP_140 ()
+OP_140 (void)
{
unsigned int op0, op1, result, z, s;
/* andi zero_extend(imm16), reg, reg */
int
-OP_6C0 ()
+OP_6C0 (void)
{
unsigned int result, z;
/* xor reg, reg */
int
-OP_120 ()
+OP_120 (void)
{
unsigned int op0, op1, result, z, s;
/* xori zero_extend(imm16), reg, reg */
int
-OP_6A0 ()
+OP_6A0 (void)
{
unsigned int op0, op1, result, z, s;
/* not reg1, reg2 */
int
-OP_20 ()
+OP_20 (void)
{
unsigned int op0, result, z, s;
/* set1 */
int
-OP_7C0 ()
+OP_7C0 (void)
{
unsigned int op0, op1, op2;
int temp;
/* not1 */
int
-OP_47C0 ()
+OP_47C0 (void)
{
unsigned int op0, op1, op2;
int temp;
/* clr1 */
int
-OP_87C0 ()
+OP_87C0 (void)
{
unsigned int op0, op1, op2;
int temp;
/* tst1 */
int
-OP_C7C0 ()
+OP_C7C0 (void)
{
unsigned int op0, op1, op2;
int temp;
/* di */
int
-OP_16007E0 ()
+OP_16007E0 (void)
{
trace_input ("di", OP_NONE, 0);
PSW |= PSW_ID;
/* ei */
int
-OP_16087E0 ()
+OP_16087E0 (void)
{
trace_input ("ei", OP_NONE, 0);
PSW &= ~PSW_ID;
/* halt */
int
-OP_12007E0 ()
+OP_12007E0 (void)
{
trace_input ("halt", OP_NONE, 0);
/* FIXME this should put processor into a mode where NMI still handled */
/* trap */
int
-OP_10007E0 ()
+OP_10007E0 (void)
{
trace_input ("trap", OP_TRAP, 0);
trace_output (OP_TRAP);
buf = PARM1;
RETVAL = pipe (host_fd);
SW (buf, host_fd[0]);
- buf += sizeof(uint16);
+ buf += sizeof (uint16);
SW (buf, host_fd[1]);
RETERR = errno;
}
{
char *buf = zalloc (PARM3);
RETVAL = sim_io_read (simulator, PARM1, buf, PARM3);
- sim_write (simulator, PARM2, buf, PARM3);
+ sim_write (simulator, PARM2, (unsigned char *) buf, PARM3);
free (buf);
if ((int) RETVAL < 0)
RETERR = sim_io_get_errno (simulator);
case TARGET_SYS_write:
{
char *buf = zalloc (PARM3);
- sim_read (simulator, PARM2, buf, PARM3);
+ sim_read (simulator, PARM2, (unsigned char *) buf, PARM3);
if (PARM1 == 1)
RETVAL = sim_io_write_stdout (simulator, buf, PARM3);
else
sim_fpu_status_denorm = 16384, ----U (sim spec.)
*/
-void update_fpsr (SIM_DESC sd, sim_fpu_status status, unsigned int mask, unsigned int double_op_p)
+void
+update_fpsr (SIM_DESC sd, sim_fpu_status status, unsigned int mask, unsigned int double_op_p)
{
unsigned int fpsr = FPSR & mask;
FPSR &= ~FPSR_XC;
FPSR |= flags;
- SignalExceptionFPE(sd, double_op_p);
+ SignalExceptionFPE (sd, double_op_p);
}
}
-/*
- exception
-*/
+/* Exception. */
-void SignalException(SIM_DESC sd)
+void
+SignalException (SIM_DESC sd)
{
if (MPM & MPM_AUE)
{
}
}
-void SignalExceptionFPE(SIM_DESC sd, unsigned int double_op_p)
+void
+SignalExceptionFPE (SIM_DESC sd, unsigned int double_op_p)
{
if (((PSW & (PSW_NP|PSW_ID)) == 0)
|| !(FPSR & (double_op_p ? FPSR_DEM : FPSR_SEM)))
PSW |= (PSW_EP | PSW_ID);
PC = 0x70;
- SignalException(sd);
+ SignalException (sd);
}
}
-
-void check_invalid_snan(SIM_DESC sd, sim_fpu_status status, unsigned int double_op_p)
+void
+check_invalid_snan (SIM_DESC sd, sim_fpu_status status, unsigned int double_op_p)
{
if ((FPSR & FPSR_XEI)
&& (status & sim_fpu_status_invalid_snan))
FPSR &= ~FPSR_XC;
FPSR |= FPSR_XCV;
FPSR |= FPSR_XPV;
- SignalExceptionFPE(sd, double_op_p);
+ SignalExceptionFPE (sd, double_op_p);
}
}
-int v850_float_compare(SIM_DESC sd, int cmp, sim_fpu wop1, sim_fpu wop2, int double_op_p)
+int
+v850_float_compare (SIM_DESC sd, int cmp, sim_fpu wop1, sim_fpu wop2, int double_op_p)
{
int result = -1;
- if (sim_fpu_is_nan(&wop1) || sim_fpu_is_nan(&wop2))
+ if (sim_fpu_is_nan (&wop1) || sim_fpu_is_nan (&wop2))
{
if (cmp & 0x8)
{
if (FPSR & FPSR_XEV)
{
FPSR |= FPSR_XCV | FPSR_XPV;
- SignalExceptionFPE(sd, double_op_p);
+ SignalExceptionFPE (sd, double_op_p);
}
}
result = 1;
break;
default:
- abort();
+ abort ();
}
}
- else if (sim_fpu_is_infinity(&wop1) && sim_fpu_is_infinity(&wop2)
- && sim_fpu_sign(&wop1) == sim_fpu_sign(&wop2))
+ else if (sim_fpu_is_infinity (&wop1) && sim_fpu_is_infinity (&wop2)
+ && sim_fpu_sign (&wop1) == sim_fpu_sign (&wop2))
{
switch (cmp)
{
result = 1;
break;
default:
- abort();
+ abort ();
}
}
else
{
int gt = 0,lt = 0,eq = 0, status;
- status = sim_fpu_cmp( &wop1, &wop2 );
-
- switch (status) {
- case SIM_FPU_IS_SNAN:
- case SIM_FPU_IS_QNAN:
- abort();
- break;
-
- case SIM_FPU_IS_NINF:
- lt = 1;
- break;
- case SIM_FPU_IS_PINF:
- gt = 1;
- break;
- case SIM_FPU_IS_NNUMBER:
- lt = 1;
- break;
- case SIM_FPU_IS_PNUMBER:
- gt = 1;
- break;
- case SIM_FPU_IS_NDENORM:
- lt = 1;
- break;
- case SIM_FPU_IS_PDENORM:
- gt = 1;
- break;
- case SIM_FPU_IS_NZERO:
- case SIM_FPU_IS_PZERO:
- eq = 1;
- break;
- }
+ status = sim_fpu_cmp (&wop1, &wop2);
+
+ switch (status)
+ {
+ case SIM_FPU_IS_SNAN:
+ case SIM_FPU_IS_QNAN:
+ abort ();
+ break;
+
+ case SIM_FPU_IS_NINF:
+ lt = 1;
+ break;
+ case SIM_FPU_IS_PINF:
+ gt = 1;
+ break;
+ case SIM_FPU_IS_NNUMBER:
+ lt = 1;
+ break;
+ case SIM_FPU_IS_PNUMBER:
+ gt = 1;
+ break;
+ case SIM_FPU_IS_NDENORM:
+ lt = 1;
+ break;
+ case SIM_FPU_IS_PDENORM:
+ gt = 1;
+ break;
+ case SIM_FPU_IS_NZERO:
+ case SIM_FPU_IS_PZERO:
+ eq = 1;
+ break;
+ }
switch (cmp)
{
}
}
- ASSERT(result != -1);
+ ASSERT (result != -1);
return result;
}
-void v850_div(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p, unsigned int *op3p)
+void
+v850_div (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p, unsigned int *op3p)
{
signed long int quotient;
signed long int remainder;
/* Compute the result. */
divide_by = op0;
divide_this = op1;
-
+
if (divide_by == 0 || (divide_by == -1 && divide_this == (1 << 31)))
{
overflow = TRUE;
*op3p = remainder;
}
-void v850_divu(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p, unsigned int *op3p)
+void
+v850_divu (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p, unsigned int *op3p)
{
unsigned long int quotient;
unsigned long int remainder;
*op3p = remainder;
}
-
-void v850_sar(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
+void
+v850_sar (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
{
unsigned int result, z, s, cy;
*op2p = result;
}
-void v850_shl(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
+void
+v850_shl (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
{
unsigned int result, z, s, cy;
* dest = result;
}
-void v850_shr(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
+void
+v850_shr (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
{
unsigned int result, z, s, cy;
*op2p = result;
}
-void v850_satadd(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
+void
+v850_satadd (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
{
unsigned int result, z, s, cy, ov, sat;
*op2p = result;
}
-void v850_satsub(SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
+void
+v850_satsub (SIM_DESC sd, unsigned int op0, unsigned int op1, unsigned int *op2p)
{
unsigned int result, z, s, cy, ov, sat;
}
unsigned32
-load_data_mem(sd, addr, len)
- SIM_DESC sd;
- SIM_ADDR addr;
- int len;
+load_data_mem (SIM_DESC sd,
+ SIM_ADDR addr,
+ int len)
{
uint32 data;
}
void
-store_data_mem(sd, addr, len, data)
- SIM_DESC sd;
- SIM_ADDR addr;
- int len;
- unsigned32 data;
+store_data_mem (SIM_DESC sd,
+ SIM_ADDR addr,
+ int len,
+ unsigned32 data)
{
switch (len)
{
case 1:
- store_mem(addr, 1, data);
+ store_mem (addr, 1, data);
break;
case 2:
- store_mem(addr, 2, data);
+ store_mem (addr, 2, data);
break;
case 4:
- store_mem(addr, 4, data);
+ store_mem (addr, 4, data);
break;
default:
abort ();
}
}
-int mpu_load_mem_test(SIM_DESC sd, unsigned int addr, int size, int base_reg)
+int
+mpu_load_mem_test (SIM_DESC sd, unsigned int addr, int size, int base_reg)
{
int result = 1;
if (PSW & PSW_DMP)
{
- if (IPE0 && addr >= IPA2ADDR(IPA0L) && addr <= IPA2ADDR(IPA0L) && IPR0)
+ if (IPE0 && addr >= IPA2ADDR (IPA0L) && addr <= IPA2ADDR (IPA0L) && IPR0)
{
/* text area */
}
- else if (IPE1 && addr >= IPA2ADDR(IPA1L) && addr <= IPA2ADDR(IPA1L) && IPR1)
+ else if (IPE1 && addr >= IPA2ADDR (IPA1L) && addr <= IPA2ADDR (IPA1L) && IPR1)
{
/* text area */
}
- else if (IPE2 && addr >= IPA2ADDR(IPA2L) && addr <= IPA2ADDR(IPA2L) && IPR2)
+ else if (IPE2 && addr >= IPA2ADDR (IPA2L) && addr <= IPA2ADDR (IPA2L) && IPR2)
{
/* text area */
}
- else if (IPE3 && addr >= IPA2ADDR(IPA3L) && addr <= IPA2ADDR(IPA3L) && IPR3)
+ else if (IPE3 && addr >= IPA2ADDR (IPA3L) && addr <= IPA2ADDR (IPA3L) && IPR3)
{
/* text area */
}
- else if (addr >= PPA2ADDR(PPA & ~PPM) && addr <= DPA2ADDR(PPA | PPM))
+ else if (addr >= PPA2ADDR (PPA & ~PPM) && addr <= DPA2ADDR (PPA | PPM))
{
/* preifarallel area */
}
- else if (addr >= PPA2ADDR(SPAL) && addr <= DPA2ADDR(SPAU))
+ else if (addr >= PPA2ADDR (SPAL) && addr <= DPA2ADDR (SPAU))
{
/* stack area */
}
- else if (DPE0 && addr >= DPA2ADDR(DPA0L) && addr <= DPA2ADDR(DPA0L) && DPR0
+ else if (DPE0 && addr >= DPA2ADDR (DPA0L) && addr <= DPA2ADDR (DPA0L) && DPR0
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE1 && addr >= DPA2ADDR(DPA1L) && addr <= DPA2ADDR(DPA1L) && DPR1
+ else if (DPE1 && addr >= DPA2ADDR (DPA1L) && addr <= DPA2ADDR (DPA1L) && DPR1
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE2 && addr >= DPA2ADDR(DPA2L) && addr <= DPA2ADDR(DPA2L) && DPR2
+ else if (DPE2 && addr >= DPA2ADDR (DPA2L) && addr <= DPA2ADDR (DPA2L) && DPR2
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE3 && addr >= DPA2ADDR(DPA3L) && addr <= DPA2ADDR(DPA3L) && DPR3
+ else if (DPE3 && addr >= DPA2ADDR (DPA3L) && addr <= DPA2ADDR (DPA3L) && DPR3
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
PC = 0x30;
- SignalException(sd);
+ SignalException (sd);
result = 0;
}
}
return result;
}
-int mpu_store_mem_test(SIM_DESC sd, unsigned int addr, int size, int base_reg)
+int
+mpu_store_mem_test (SIM_DESC sd, unsigned int addr, int size, int base_reg)
{
int result = 1;
if (PSW & PSW_DMP)
{
- if (addr >= PPA2ADDR(PPA & ~PPM) && addr <= DPA2ADDR(PPA | PPM))
+ if (addr >= PPA2ADDR (PPA & ~PPM) && addr <= DPA2ADDR (PPA | PPM))
{
/* preifarallel area */
}
- else if (addr >= PPA2ADDR(SPAL) && addr <= DPA2ADDR(SPAU))
+ else if (addr >= PPA2ADDR (SPAL) && addr <= DPA2ADDR (SPAU))
{
/* stack area */
}
- else if (DPE0 && addr >= DPA2ADDR(DPA0L) && addr <= DPA2ADDR(DPA0L) && DPW0
+ else if (DPE0 && addr >= DPA2ADDR (DPA0L) && addr <= DPA2ADDR (DPA0L) && DPW0
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE1 && addr >= DPA2ADDR(DPA1L) && addr <= DPA2ADDR(DPA1L) && DPW1
+ else if (DPE1 && addr >= DPA2ADDR (DPA1L) && addr <= DPA2ADDR (DPA1L) && DPW1
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE2 && addr >= DPA2ADDR(DPA2L) && addr <= DPA2ADDR(DPA2L) && DPW2
+ else if (DPE2 && addr >= DPA2ADDR (DPA2L) && addr <= DPA2ADDR (DPA2L) && DPW2
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
- else if (DPE3 && addr >= DPA2ADDR(DPA3L) && addr <= DPA2ADDR(DPA3L) && DPW3
+ else if (DPE3 && addr >= DPA2ADDR (DPA3L) && addr <= DPA2ADDR (DPA3L) && DPW3
&& ((SPAL & SPAL_SPS) ? base_reg == SP_REGNO : 1))
{
/* data area */
}
else
{
- if (addr >= PPA2ADDR(PPA & ~PPM) && addr <= DPA2ADDR(PPA | PPM))
+ if (addr >= PPA2ADDR (PPA & ~PPM) && addr <= DPA2ADDR (PPA | PPM))
{
FEIC = 0x432;
VPTID = TID;