Пример #1
0
void sim_resume(int step){
	do {
		/* if we are in remote debugmode we will check ctrl+c and breakpoint */
		if(remote_debugmode){
			int i;
			WORD addr;
			/* to detect if Ctrl+c is pressed.. */
			if(remote_interrupt())
				return;
			addr = arch_instance->get_pc();
			for (i = 0;i < skyeye_ice.num_bps;i++){
				if(skyeye_ice.bps[i] == addr)
      					return;
			} /* for */
                        if (skyeye_ice.tps_status==TRACE_STARTED)
                        {
	                        for (i=0;i<skyeye_ice.num_tps;i++)
                                {
        	                        if (((skyeye_ice.tps[i].tp_address==addr)&& 
					            (skyeye_ice.tps[i].status==TRACEPOINT_ENABLED))||(skyeye_ice.tps[i].status==TRACEPOINT_STEPPING))
                	                {
                                            handle_tracepoint(i);
                                        }
                               	}
                        }
		} /* if(remote_debugmode) */
		if (skyeye_config.log.logon >= 1) {
			WORD pc = arch_instance->get_pc();
			if (pc >= skyeye_config.log.start &&
				    pc <= skyeye_config.log.end) {
#if !defined(__MINGW32__)
				char * func_name = get_sym(pc);
				if(func_name)
					fprintf (skyeye_logfd,"\n in %s\n", func_name);
#endif
				/*
					if (skyeye_config.log.logon >= 2)
						fprintf (skyeye_logfd,
                                                         "pc=0x%x", pc);

						SKYEYE_OUTREGS (skyeye_logfd);
					if (skyeye_config.log.logon >= 3)
						SKYEYE_OUTMOREREGS
							(skyeye_logfd);
				*/
			}
		}/* if (skyeye_config.log.logon >= 1) */

		arch_instance->step_once ();
	}while(!step);
}
Пример #2
0
ARMword
ARMul_DoProg (ARMul_State * state)
{
    ARMword pc = 0;

    /*
     * 2007-01-24 removed the term-io functions by Anthony Lee,
     * moved to "device/uart/skyeye_uart_stdio.c".
     */

//teawater add DBCT_TEST_SPEED 2005.10.04---------------------------------------
#ifdef DBCT_TEST_SPEED
    {
        if (!dbct_test_speed_state) {
            //init timer
            struct itimerval	value;
            struct sigaction	act;

            dbct_test_speed_state = state;
            state->instr_count = 0;
            act.sa_handler = dbct_test_speed_sig;
            act.sa_flags = SA_RESTART;
            //cygwin don't support ITIMER_VIRTUAL or ITIMER_PROF
#ifndef __CYGWIN__
            if (sigaction(SIGVTALRM, &act, NULL) == -1) {
#else
            if (sigaction(SIGALRM, &act, NULL) == -1) {
#endif	//__CYGWIN__
                fprintf(stderr, "init timer error.\n");
                exit(-1);
                //skyeye_exit(-1);
            }
            if (skyeye_config.dbct_test_speed_sec) {
                value.it_value.tv_sec = skyeye_config.dbct_test_speed_sec;
            } else {
                value.it_value.tv_sec = DBCT_TEST_SPEED_SEC;
            }
            printf("dbct_test_speed_sec = %ld\n", value.it_value.tv_sec);
            value.it_value.tv_usec = 0;
            value.it_interval.tv_sec = 0;
            value.it_interval.tv_usec = 0;
#ifndef __CYGWIN__
            if (setitimer(ITIMER_VIRTUAL, &value, NULL) == -1) {
#else
            if (setitimer(ITIMER_REAL, &value, NULL) == -1) {
#endif	//__CYGWIN__
                fprintf(stderr, "init timer error.\n");
                //skyeye_exit(-1);
            }
        }
    }
#endif	//DBCT_TEST_SPEED
//AJ2D--------------------------------------------------------------------------
    state->Emulate = RUN;
    while (state->Emulate != STOP) {
        state->Emulate = RUN;

        /*ywc 2005-03-31 */
        if (state->prog32Sig && ARMul_MODE32BIT) {
#ifdef DBCT
            if (skyeye_config.no_dbct) {
                pc = ARMul_Emulate32 (state);
            } else {
                pc = ARMul_Emulate32_dbct (state);
            }
#else
            pc = ARMul_Emulate32 (state);
#endif
        }

        else {
            //pc = ARMul_Emulate26 (state);
        }
        //chy 2006-02-22, should test debugmode first
        //chy 2006-04-14, put below codes in ARMul_Emulate
#if 0
        if(debugmode)
            if(remote_interrupt())
                state->Emulate = STOP;
#endif
    }

    /*
     * 2007-01-24 removed the term-io functions by Anthony Lee,
     * moved to "device/uart/skyeye_uart_stdio.c".
     */

    return (pc);
}

/***************************************************************************\
* Emulate the execution of one instruction.  Start the correct emulator     *
* (Emulate26 for a 26 bit ARM and Emulate32 for a 32 bit ARM), return the   *
* address of the instruction that is executed.                              *
\***************************************************************************/

ARMword
ARMul_DoInstr (ARMul_State * state)
{
    ARMword pc = 0;

    state->Emulate = ONCE;

    /*ywc 2005-03-31 */
    if (state->prog32Sig && ARMul_MODE32BIT) {
#ifdef DBCT
        if (skyeye_config.no_dbct) {
            pc = ARMul_Emulate32 (state);
        } else {
//teawater add compile switch for DBCT GDB RSP function 2005.10.21--------------
#ifndef DBCT_GDBRSP
            printf("DBCT GDBRSP function switch is off.\n");
            printf("To use this function, open \"#define DBCT_GDBRSP\" in arch/arm/common/armdefs.h & recompile skyeye.\n");
            skyeye_exit(-1);
#endif	//DBCT_GDBRSP
//AJ2D--------------------------------------------------------------------------
            pc = ARMul_Emulate32_dbct (state);
        }
#else
        pc = ARMul_Emulate32 (state);
#endif
    }

    //else
        //pc = ARMul_Emulate26 (state);

        return (pc);
}

/***************************************************************************\
* This routine causes an Abort to occur, including selecting the correct    *
* mode, register bank, and the saving of registers.  Call with the          *
* appropriate vector's memory address (0,4,8 ....)                          *
\***************************************************************************/

void
ARMul_Abort (ARMul_State * state, ARMword vector)
{
    ARMword temp;
    int isize = INSN_SIZE;
    int esize = (TFLAG ? 0 : 4);
    int e2size = (TFLAG ? -4 : 0);

    state->Aborted = FALSE;

    if (state->prog32Sig)
        if (ARMul_MODE26BIT)
            temp = R15PC;
        else
            temp = state->Reg[15];
    else
        temp = R15PC | ECC | ER15INT | EMODE;

    switch (vector) {
    case ARMul_ResetV:	/* RESET */
        SETABORT (INTBITS, state->prog32Sig ? SVC32MODE : SVC26MODE,
                  0);
        break;
    case ARMul_UndefinedInstrV:	/* Undefined Instruction */
        SETABORT (IBIT, state->prog32Sig ? UNDEF32MODE : SVC26MODE,
                  isize);
        break;
    case ARMul_SWIV:	/* Software Interrupt */
        SETABORT (IBIT, state->prog32Sig ? SVC32MODE : SVC26MODE,
                  isize);
        break;
    case ARMul_PrefetchAbortV:	/* Prefetch Abort */
        state->AbortAddr = 1;
        SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE,
                  esize);
        break;
    case ARMul_DataAbortV:	/* Data Abort */
        SETABORT (IBIT, state->prog32Sig ? ABORT32MODE : SVC26MODE,
                  e2size);
        break;
    case ARMul_AddrExceptnV:	/* Address Exception */
        SETABORT (IBIT, SVC26MODE, isize);
        break;
    case ARMul_IRQV:	/* IRQ */
        //chy 2003-09-02 the if sentence seems no use
#if 0
        if (!state->is_XScale || !state->CPRead[13] (state, 0, &temp)
                || (temp & ARMul_CP13_R0_IRQ))
#endif
            SETABORT (IBIT,
                      state->prog32Sig ? IRQ32MODE : IRQ26MODE,
                      esize);
        break;
    case ARMul_FIQV:	/* FIQ */
        //chy 2003-09-02 the if sentence seems no use
#if 0
        if (!state->is_XScale || !state->CPRead[13] (state, 0, &temp)
                || (temp & ARMul_CP13_R0_FIQ))
#endif
            SETABORT (INTBITS,
                      state->prog32Sig ? FIQ32MODE : FIQ26MODE,
                      esize);
        break;
    }

    if (ARMul_MODE32BIT) {
        /*if (state->mmu.control & CONTROL_VECTOR)
          vector += 0xffff0000;	//for v4 high exception  address*/
        if (state->vector_remap_flag)
            vector += state->vector_remap_addr; /* support some remap function in LPC processor */
        ARMul_SetR15 (state, vector);
    } else
        ARMul_SetR15 (state, R15CCINTMODE | vector);
}
Пример #3
0
void
sim_resume (int step)
{
	/* workaround here: we have different run mode on arm */
	if(!strcmp(skyeye_config.arch->arch_name, "arm")){
		state->EndCondition = 0;
		stop_simulator = 0;

		if (step) {
			state->Reg[15] = ARMul_DoInstr (state);

			if (state->EndCondition == 0) {
				//chy 20050729 ????
				printf ("error in sim_resume for state->EndCondition");
				skyeye_exit (-1);
			}
		}
		else {
			state->NextInstr = RESUME;	/* treat as PC change */
			state->Reg[15] = ARMul_DoProg (state);
		}
		FLUSHPIPE;
	}
	/* other target simulator step run */
	else {
		do {
			/* if we are in remote debugmode we will check ctrl+c and breakpoint */
			if(remote_debugmode){
				int i;
				WORD addr;

				/* to detect if Ctrl+c is pressed.. */
				if(remote_interrupt())
					return;
				addr = arch_instance->get_pc();
				for (i = 0;i < skyeye_ice.num_bps;i++){
					if(skyeye_ice.bps[i] == addr)
            					return;
				} /* for */
                                if (skyeye_ice.tps_status==TRACE_STARTED)
                                {
                                    for (i=0;i<skyeye_ice.num_tps;i++)
                                    {
                                        if (((skyeye_ice.tps[i].tp_address==addr)&&             (skyeye_ice.tps[i].status==TRACEPOINT_ENABLED))||(skyeye_ice.tps[i].status==TRACEPOINT_STEPPING))
                                        {
                                            handle_tracepoint(i);
                                        }
                               	    }
                                }
			} /* if(remote_debugmode) */
			if (skyeye_config.log.logon >= 1) {
				WORD pc = arch_instance->get_pc();
				if (pc >= skyeye_config.log.start &&
					    pc <= skyeye_config.log.end) {
#if !defined(__MINGW32__)
					char * func_name = get_sym(pc);
					if(func_name)
						fprintf (skyeye_logfd,"\n in %s\n", func_name);
#endif
				/*
					if (skyeye_config.log.logon >= 2)
						fprintf (skyeye_logfd,
                                                         "pc=0x%x", pc);

						SKYEYE_OUTREGS (skyeye_logfd);
					if (skyeye_config.log.logon >= 3)
						SKYEYE_OUTMOREREGS
							(skyeye_logfd);
				*/
				}
			}/* if (skyeye_config.log.logon >= 1) */

			arch_instance->step_once ();
		}while(!step);
	}
}