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

📄 arm.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.
*/ 

#include "Core/Memory.h"

#include "stdafx.h"
#include "./ARM.h"
#include "./Board_AT91EV40.h"
#include "./Board_EP7312.h"
#include "./Board_PXA_Lubbock.h"
#include "./Processor_7TDMI.h"
#include "./Processor_720T.h"
#include "./Processor_XScale.h"
#include "./Instruction_Set.h"
#include "./XScale_MMU.h"
#include "./ARM7_MMU.h"

extern "C"{

	ARM_API size_t Wukong_Enum_Module(std::vector<Core::Module_Meta> &res)
	{
		res.clear();
		Core::Module_Manager::append_meta(res, "ARM7TDMI", Core::Module_Manager::MT_CPU);
		Core::Module_Manager::append_meta(res, "ARM720T", Core::Module_Manager::MT_CPU);
		Core::Module_Manager::append_meta(res, "XScale", Core::Module_Manager::MT_CPU);
		Core::Module_Manager::append_meta(res, "ARM7AT91EV40", Core::Module_Manager::MT_BOARD);
		Core::Module_Manager::append_meta(res, "ARM7EP7312", Core::Module_Manager::MT_BOARD);
		Core::Module_Manager::append_meta(res, "PXA_Lubbock", Core::Module_Manager::MT_BOARD);
		return res.size();
	}

	ARM_API Core::Module * Wukong_Create_Module(const std::string & name)
	{
		if (name == "ARM7TDMI")
		{
			ARM::CPU_7TDMI * module;
			ARM::ARM_Instruction_Set & instr_set = ARM::ARM_Instruction_Set::instance();
			Core::Dummy_MMU<Core::u32> * mmu = new Core::Dummy_MMU<Core::u32>();
			module = new ARM::CPU_7TDMI(instr_set, mmu);

			module->on_create();
			instr_set.register_instructions();

			return module;
		}

		if (name == "ARM720T")
		{
			ARM::CPU_720T * module;
			ARM::ARM_Instruction_Set & instr_set = ARM::ARM_Instruction_Set::instance();
			ARM::ARM7_MMU* mmu = new ARM::ARM7_MMU(); //for arm7
			module = new ARM::CPU_720T(instr_set, mmu);
			
			module->on_create();
			instr_set.register_instructions();

			return module;
		}

		if (name == "XScale")
		{
			ARM::CPU_XScale * module;
			ARM::ARM_Instruction_Set & instr_set = ARM::ARM_Instruction_Set::instance();
			ARM::XScale_MMU* mmu = new ARM::XScale_MMU(); 
			module = new ARM::CPU_XScale(instr_set, mmu);

			module->on_create();
			instr_set.register_instructions();

			return module;
		}

		if (name == "ARM7AT91EV40")
		{
			ARM::Board_AT91EV40 * module = new ARM::Board_AT91EV40();
			module->on_create();
			return module;
		}

		if (name == "ARM7EP7312")
		{
			ARM::Board_EP7312 * module = new ARM::Board_EP7312();
			module->on_create();
			return module;
		}

		if (name == "PXA_Lubbock")
		{
			ARM::Board_PXA_Lubbock * module = new ARM::Board_PXA_Lubbock();
			module->on_create();
			return module;
		}

		return 0;
	}

	ARM_API bool Wukong_Destroy_Module(const std::string & name, Core::Module * module)
	{	
		assert(name == module->get_name());
		if (name == module->get_name())
		{
			module->on_destroy();
			delete module;
			return true;
		}
		else 
		{
			return false;
		}
	}


	BOOL APIENTRY DllMain( HANDLE hModule, 
		DWORD  ul_reason_for_call, 
		LPVOID lpReserved
		)
	{
		return TRUE;
	}

}

⌨️ 快捷键说明

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