Exemplo n.º 1
0
void
coldfire_step_once ()
{
	unsigned int Instr;
	struct _Instruction *InstructionPtr;
#ifdef INSTRUCTION_PROFILE        
	unsigned long long LowTime=0, HighTime=0;
	char Buffer[16];
#endif        

	//while(!Run_Exit) {
	if(1){

		SKYEYE_DBG("New cycle, PC=0x%08lx, SP=0x%08lx\n",
                                memory_core.pc, memory_core.a[7]);
		/* printf("New cycle, PC=0x%08lx, SP=0x%08lx\n",
                                memory_core.pc, memory_core.a[7]);	
		*/
		/* Check for any pending exceptions */
		exception_check_and_handle();
		/* As we're coming back from an interrupt, check for exit */
		//if(Run_Exit) break;

		/* Save the PC for the beginning of this instruction
		 *  This is useful for exceptions that reset the PC */
		memory_core.pc_instruction_begin = memory_core.pc;

		/* Before we execute this instruction, catch a bad PC counter */

		/* Get the instruction from memory */
		if(!Memory_RetrWord(&Instr, memory_core.pc)) 
			//continue;
			;

		/* Look it up */
		InstructionPtr = Instruction_FindInstruction(Instr);

                if(InstructionPtr==NULL) {
                        //exception_do_exception(4);
			//continue;
                } else {
                        /* Run the instruction */


			(*InstructionPtr->FunctionPtr)();

		}
		/* Now update anything that could cause an interrupt, so we
		 * can catch it in the next cycle */

		/* Call this, which will call an update
		 * for things like the UARTs and Timers */
		//skyeye_config.mach->mach_io_do_cycle (&memory_core);
		exec_callback();
	}
}
void SerialRendererController::exec_callbacks()
{
    boost::mutex::scoped_lock lock(m_mutex);

    while (!m_pending_callbacks.empty())
    {
        exec_callback(m_pending_callbacks.front());
        m_pending_callbacks.pop_front();
    }
}
Exemplo n.º 3
0
int hwpl_i2c_setaction(int port, void * ctl){
	hwpl_action_t * action = (hwpl_action_t*)ctl;
	if( action->callback == 0 ){
		if ( !(i2c_local[port].state & I2C_DONE_FLAG) ){
			exec_callback(port, DEVICE_OP_CANCELLED);
		}
	}

	i2c_local[port].callback = action->callback;
	i2c_local[port].context = action->context;
	return 0;
}
Exemplo n.º 4
0
/**
 * The interface of write data from bus
 */
int bus_write(short size, int addr, uint32_t value){
	mem_bank_t * bank;
	generic_arch_t* arch_instance = get_arch_instance("");

	bus_snoop(SIM_access_write, size ,addr, value, Before_act);
	exec_callback(Bus_write_callback, arch_instance);
        if(bank = bank_ptr(addr))
                bank->bank_write(size, addr, value);
        else{
		SKYEYE_ERR( "Bus write error, can not find corresponding bank for addr 0x%x,pc=0x%x\n", addr, arch_instance->get_pc());
		//skyeye_exit(-1);
	}
       return 0; 
}
Exemplo n.º 5
0
/**
 *  The interface of read data from bus
 */
int bus_read(short size, int addr, uint32_t * value){
	mem_bank_t * bank;
	generic_arch_t* arch_instance = get_arch_instance("");

	if((bank = bank_ptr(addr)) && (bank->bank_read))
		bank->bank_read(size, addr, value);
	else{
		SKYEYE_ERR( "Bus read error, can not find corresponding bank for addr 0x%x,pc=0x%x\n", addr, arch_instance->get_pc());
		return -1;
		//skyeye_exit(-1);
	}
	bus_snoop(SIM_access_read, size ,addr, *value, After_act);
	exec_callback(Bus_read_callback, arch_instance);
	return 0;	
}
Exemplo n.º 6
0
static void _hwpl_i2c_isr(int port) {
	uint8_t stat_value;
	LPC_I2C_TypeDef * i2c_regs;
	// this handler deals with master read and master write only
	i2c_regs = i2c_get_regs(port);

	if ( i2c_regs == NULL ){
		be_done(port);
	}
	stat_value = i2c_regs->STAT;
	switch ( stat_value ){
	case 0x08: //Start Condition has been sent
	case 0x10: //Repeated Start condition
		i2c_local[port].err = 0;
		if ( i2c_local[port].state == I2C_STATE_NONE){
			i2c_regs->DAT = i2c_local[port].addr | 0x01; //Set the Read bit -- repeated start after write ptr
		} else {
			i2c_regs->DAT = i2c_local[port].addr;
		}

		i2c_regs->CONSET = AA;
		i2c_regs->CONCLR = STA;
		break;
	case 0x18: //SLA+W transmitted -- Ack Received
		i2c_regs->DAT = i2c_local[port].ptr.ptr8[1]; //Send the offset pointer (MSB of 16 or 8 bit)
		i2c_regs->CONSET = AA;
		break;
	case 0x28: //Data byte transmitted -- Ack Received
		if (( i2c_local[port].state == I2C_STATE_RD_16_OP )||
				( i2c_local[port].state == I2C_STATE_WR_16_OP )){
			i2c_regs->DAT = i2c_local[port].ptr.ptr8[0]; //Send the offset pointer (LSB)
			i2c_regs->CONSET = AA;
			if ( i2c_local[port].state == I2C_STATE_RD_16_OP ){
				i2c_local[port].state = I2C_STATE_RD_OP;
			}
			break;
		}

		if ( i2c_local[port].state == I2C_STATE_RD_OP ){
			i2c_regs->CONSET = AA|STA; //Restart (then send read command)
			i2c_local[port].state = I2C_STATE_NONE;
			break;
		}

		//Transmit data
		if ( i2c_local[port].size ){
			i2c_regs->DAT = *(i2c_local[port].data);
			i2c_local[port].data++;
			i2c_regs->CONSET = AA;
			i2c_local[port].size--;
		} else {
			i2c_regs->CONSET = STO|AA;
			i2c_local[port].state = I2C_STATE_NONE | I2C_DONE_FLAG;
		}
		break;
	case 0x20:
	case 0x30:
	case 0x48:
		//Receiver nack'd
		i2c_regs->CONSET = STO;
		i2c_local[port].size = 0;
		i2c_local[port].err = I2C_ERROR_ACK;
		i2c_local[port].state = I2C_DONE_FLAG;
		break;
	case 0x38:
		i2c_local[port].size = 0;
		i2c_regs->CONSET = STO;
		i2c_local[port].err = I2C_ERROR_ARBITRATION_LOST;
		i2c_local[port].state = I2C_DONE_FLAG;
		break;
	case 0x40: //SLA+R transmitted -- Ack received
		if ( i2c_local[port].size > 1 ){
			i2c_regs->CONSET = AA; //only ACK if more than one byte is coming
		} else {
			i2c_regs->CONCLR = AA;
		}
		break;
	case 0x50: //Data Byte received -- Ack returned
		//Receive Data
		if ( i2c_local[port].size ) i2c_local[port].size--;
		*(i2c_local[port].data) = (char)i2c_regs->DAT;
		i2c_local[port].data++;
		if ( i2c_local[port].size > 1 ){
			i2c_regs->CONSET = AA;
		} else {
			i2c_regs->CONCLR = AA;
		}
		break;
	case 0x58: //Data byte received -- Not Ack returned
		if ( i2c_local[port].size ) i2c_local[port].size--;
		*(i2c_local[port].data) = (char)i2c_regs->DAT;
		i2c_local[port].data++;

		i2c_regs->CONSET = STO;
		i2c_local[port].state = I2C_STATE_NONE | I2C_DONE_FLAG;
		break;
	case 0x00:
		i2c_local[port].err = I2C_ERROR_START;
		i2c_local[port].state = I2C_DONE_FLAG;
		i2c_regs->CONSET = STO;
		break;
	}

	i2c_regs->CONCLR = SI; //clear the interrupt flag

	if ( i2c_local[port].state & I2C_DONE_FLAG ){
		exec_callback(port, 0);
	}
}
Exemplo n.º 7
0
void SIM_start(void){
	sky_pref_t *pref;
	/* get the current preference for simulator */
	pref = get_skyeye_pref();
	skyeye_config_t* config = get_current_config();
	if(pref->conf_filename)
		skyeye_read_config(pref->conf_filename);

	if(config->arch == NULL){
		skyeye_log(Error_log, __FUNCTION__, "Should provide valid arch option in your config file.\n");
		return;
	}
	generic_arch_t *arch_instance = get_arch_instance(config->arch->arch_name);

	if(config->mach == NULL){
		skyeye_log(Error_log, __FUNCTION__, "Should provide valid mach option in your config file.\n");
		return;
	}

	arch_instance->init();
	
	/* reset all the memory */
	mem_reset();

	config->mach->mach_init(arch_instance, config->mach);
	/* reset current arch_instanc */
	arch_instance->reset();
	/* reset all the values of mach */
	io_reset(arch_instance);
	
	if(pref->exec_file){
		exception_t ret;
		/* 
		 * If no relocation is indicated, we will load elf file by 
		 * virtual address
		 */
		if((((~pref->exec_load_mask) & pref->exec_load_base) == 0x0) &&
			(arch_instance->mmu_write != NULL))
			ret = load_elf(pref->exec_file, Virt_addr);
		else
			ret = load_elf(pref->exec_file, Phys_addr);
	}

	/* set pc from config */
	generic_address_t pc = (config->start_address & pref->exec_load_mask)|pref->exec_load_base; 
	skyeye_log(Info_log, __FUNCTION__, "Set PC to the address 0x%x\n", pc);
	arch_instance->set_pc(pc);

	/* Call bootmach callback */
	exec_callback(Bootmach_callback, arch_instance);	

	pthread_t id;
	create_thread(skyeye_loop, arch_instance, &id);
	
	/* 
	 * At this time, if we set conf file, then we parse it
	 * Or do it later.
	 */

	/*
	if(pref->conf_filename)
		skyeye_read_config(pref->conf_filename);
	*/
#if 0	
	else{
		/* try to run in batch mode */
		if(skyeye_read_config(pref->conf_filename) == No_exp){