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

📄 ppc_main.cpp

📁 浙江大学的悟空嵌入式系统模拟器
💻 CPP
字号:
// PPC_Main.cpp : Defines the entry point for the console application.
//

#include <string>#include <iostream>#include <cstdio>#include "Core/DLL.h"
#include "Core/System.h"
#include "Core/Instruction.h"
#include "Core/Processor.h"
#include "Core/Board.h"
#include "Core/Loader.h"
#include "Core/Helper.h"
#include "Core/ConfigFile.h"

#include "Utils/Debug.h"
#include "Boot_loader.h"
#include "CPU.h"


static std::string arch_name = "PPC";

static std::string conf_file = "PPC.conf";


int main(int argc, char* argv[])
{

	/*if (PPC::Logger::instance()->init_logfile("log.txt") < 0) {
		std::cout<<"open log error";
		exit(0);
	}*/
	
	Core::Log::clear_all();

	Core::Wukong_Get_System().load_config(arch_name, conf_file);

	Core::Config_File * cf = Core::Wukong_Get_System().get_config();

	std::string cpu_name, board_name,  loader_name;
	cf->read("/cpu/name", cpu_name);
	cf->read("/board/name", board_name);
	cf->read("/loader/name", loader_name);
	Core::Module * cpu = Core::Module_Manager::create_module(cpu_name);
	Core::Module * board = Core::Module_Manager::create_module(board_name);
	Core::Module *loader = Core::Module_Manager::create_module(loader_name);

	Core::Wukong_Get_System().install_cpu((Core::Part *)cpu);
	Core::Wukong_Get_System().install_board((Core::Part *)board);
	Core::Wukong_Get_System().install_loader((Core::Binary_Loader *)loader);


	//if (!Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "PPC", "ucos.elf")) {
	//	std::cout<<"Load zfile error!\n";
	//	return -1;
	//}

	if (!Core::Wukong_Get_System().load_binary((Core::Binary_Loader &)(*loader), "PPC", "zvmlinux")) {
		std::cout<<"Load zfile error!\n";
		return -1;
	}
	((Core::Board<Core::u32> *)(Core::Wukong_Get_System().get_board()))->prepare_rom();


	//std::string bios = Core::Host_Machine::gen_fullpath(
	//						Core::Host_Machine::get_image_path("PPC"),
	//						"ppc_rom.bin"
	//						);

	//std::string kernel = Core::Host_Machine::gen_fullpath(
	//					Core::Host_Machine::get_image_path("PPC"),
	//					"zImage.ebony"
	//					);

	//if (PPC::Boot_Loader::load_bios(bios) < 0)
	//	PPC_ERROR_FAIL(("bios fail\n"));

	//if (PPC::Boot_Loader::load_kernel(kernel) < 0)
	//	PPC_ERROR_FAIL(("kernel fail\n"));

	//set stack pointer;
	//( (PPC::PPC_CPU  *)Core::Wukong_Get_System().get_cpu() )->set_pc(0x800000);

	( (Core::CPU_32Bit  *)Core::Wukong_Get_System().get_cpu() )->run();
	
	return 0;
}

⌨️ 快捷键说明

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