⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processor_720t.cpp

📁 浙江大学的悟空嵌入式系统模拟器
💻 CPP
字号:
/*
*  Copyright (c) 2005 Zhejiang University, P.R.China
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ 

//=============================================================================
/**
*  \file    Arch/ARM/Processor_720T.cpp
*
*  $Id: Processor_720T.cpp,v 1.1 2005/06/08 07:40:50 qilj Exp $
*
*  \author  Lingjie Qi <lingjie_qi@163.com> 
*/
//=============================================================================

#include "./Processor_720T.h"
#include "Core/Memory.h"
#include "./Board_EP7312.h"
#include "Compare.h"
#include "ARM7_MMU.h"

namespace ARM{

	CPU_720T::CPU_720T(Core::Instruction_Set & instr_set, Core::MMU<Core::u32> * mmu)
		:  ARM::ARM_CPU(instr_set, mmu)
	{
		//set pc 
	}

	void CPU_720T::on_create()
	{
		config_.name = "ARM720T";
		config_.family = "ARMv4";
		load_register();
		ARM_CPU::on_create();
		install_coprocessor();
	}

	void CPU_720T::on_reset()
	{
		current_bpt_.addr = -1;
		current_mode_ = CPU_720T::Svc;
		set_cpsr(0xd3);
		write_register(R1, 91);  //for ep7312
		//for debug
		con_ = false;
	}

	void CPU_720T::on_reset_exception()
	{
		current_mode_ = CPU_720T::Svc;
		Core::Register_Int val;
		read_register(CPU_720T::CPSR, val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0011);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1101, 0011);
		set_cpsr(val);
#ifdef	HIGH_VECTORS
		set_pc(Core::u32(0xffff0000));
#else
		set_pc(Core::u32(0x00000000));
#endif
	}

	void CPU_720T::on_undefined_instruction()
	{
		current_mode_ = CPU_720T::Und;
		write_register(CPU_720T::R14_und, (Core::Register_Int)get_pc());
		Core::Register_Int val;
		read_register(CPU_720T::CPSR, val);
		write_register(CPU_720T::SPSR_und, val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 1011);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1001, 1011);
		set_cpsr(val);

#ifdef	HIGH_VECTORS
		set_pc(Core::u32(0xffff0004));
#else
		set_pc(Core::u32(0x00000004));
#endif

		push_expception(CPU_720T::Undef_exp);
	}

	void CPU_720T::on_prefetch_exception()
	{
		current_mode_ = CPU_720T::Abt;
		write_register(CPU_720T::R14, (Core::Register_Int)(get_pc())+4);
		Core::Register_Int val;
		val = get_cpsr().convert_to_int();
		get_spsr().convert_from_int(val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0111);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1001, 0111);
		set_cpsr(val);

		if( ((CP15 *)get_coprocessor(15))->is_high_vectors())
			set_pc(Core::u32(0xffff000c));
        else
			set_pc(Core::u32(0x0000000c));

		push_expception(CPU_720T::PreAbt_exp);
	}

	void CPU_720T::on_dataabt_exception()
	{
		current_mode_ = CPU_720T::Abt;
		write_register(CPU_720T::R14, (Core::Register_Int)(get_pc())+4);
		Core::Register_Int val;
		val = get_cpsr().convert_to_int();
		get_spsr().convert_from_int(val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0111);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1001, 0111);
		set_cpsr(val);

		if( ((CP15 *)get_coprocessor(15))->is_high_vectors())
				set_pc(Core::u32(0xffff0010));
       else
				set_pc(Core::u32(0x00000010));

		push_expception(CPU_720T::DataAbt_exp);
	}

	void CPU_720T::on_irq_exception()
	{
		current_mode_ = CPU_720T::IRQ;
		write_register(CPU_720T::R14, (Core::Register_Int)(get_pc()+4));
		Core::Register_Int val;
		val = get_cpsr().convert_to_int();
		get_spsr().convert_from_int(val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0010);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1001, 0010);
		set_cpsr(val);

		if( ((CP15 *)get_coprocessor(15))->is_high_vectors())
			set_pc(Core::u32(0xffff0018));
		else
			set_pc(Core::u32(0x00000018)); 

		push_expception(CPU_720T::IRQ_exp);
	}

	void CPU_720T::on_fiq_exception()
	{
		current_mode_ = CPU_720T::FIQ;
		write_register(CPU_720T::R14_fiq, (Core::Register_Int)(get_pc()+4));
		Core::Register_Int val;
		read_register(CPU_720T::CPSR, val);
		write_register(CPU_720T::SPSR_fiq, val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0001);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1101, 0001);
		set_cpsr(val);

#ifdef HIGH_VECTORS
		set_pc(Core::u32(0xffff001c));
#else
		set_pc(Core::u32(0x0000001c));
#endif

		push_expception(CPU_720T::FIQ_exp);
	}

	void CPU_720T::on_swi_exception()
	{
		current_mode_ = CPU_720T::Svc;
		write_register(CPU_720T::R14, (Core::Register_Int)(get_pc()));

		Core::Register_Int val;
		val = get_cpsr().convert_to_int();
		get_spsr().convert_from_int(val);

		val = val & BINARY32(1111, 1111, 1111, 1111, 1111, 1111, 1101, 0011);
		val = val | BINARY32(0000, 0000, 0000, 0000, 0000, 0000, 1001, 0011);
		set_cpsr(val);

		if( ((CP15 *)get_coprocessor(15))->is_high_vectors())
			set_pc(Core::u32(0xffff0008));
		else
			set_pc(Core::u32(0x00000008)); 

		push_expception(CPU_720T::SWI_exp);
	}

	void CPU_720T::install_coprocessor(void)
	{
		ARM7_CP15 * cp = new ARM7_CP15(0x41807200);

		cp->on_create();
		coprocessors_.resize(16);
		coprocessors_[15] = cp;	
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -