copro_instruction.cpp

来自「浙江大学的悟空嵌入式系统模拟器」· C++ 代码 · 共 76 行

CPP
76
字号
/*
 *  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    ARM/MMU.h
 *
 *  $Id: Copro_Instruction.cpp,v 1.4 2005/06/08 07:40:44 qilj Exp $
 *
 *  \author  Juncheng Jia <jiajuncheng@gmail.com>
 */
//=============================================================================
#include "./Copro_Instruction.h"
#include "Coprocessor.h"

namespace ARM{

	DEFINE_SINGLETON(Copro_Instruction)

	void Copro_Instruction::execute(Core::Instruction_Unit binary)
	{

		Core::Binary_32Bit bits = Binary_32Bit(binary);
		
		// for XScale
		Core::u32 bits20_27 = bits.convert_to_int(20, 27);

		Core::u32 bits24_27 = bits.convert_to_int(24, 27);
		Core::u32 bits25_27 = bits.convert_to_int(25, 27);
		Core::u32 bit20 = bits.convert_to_int(20, 20);	
		Core::u32 bit4 = bits.convert_to_int(4, 4);
		Core::u32 cp_num = bits.convert_to_int(8, 11);


		ARM_Coprocessor * cp = get_cpu()->get_coprocessor((size_t)cp_num);
		if( cp == NULL )
		{
			//WUKONG_STDOUT << "Coprocessor #" << (int)cp_num << " not supported yet!"<<std::endl;
			return;
		}

		if ( bits25_27 == BINARY4(0110) && bit20 == 0 ) // STC 
			cp->STC(binary);
		else if ( bits25_27 == BINARY4(0110) && bit20 == 1) // LDC	
			cp->LDC(binary);
		else if ( bits24_27 == BINARY4(1110) && bit4 == 0) // CDP
			cp->CDP(binary);
		else if (bits24_27 == BINARY4(1110) && bit4 == 1 && bit20 == 0) // MCR
			cp->MCR(binary);
		else if (bits24_27 == BINARY4(1110) && bit4 == 1 && bit20 == 1) // MRC
			cp->MRC(binary);
		else if (bits20_27 == BINARY8(1100, 0100)  ) // MAR
			cp->MAR(binary);
		else if (bits20_27 == BINARY8(1100, 0101) ) // MRA
			cp->MRA(binary);
		


	}

}

⌨️ 快捷键说明

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