diff options
author | bunnei <ericbunnie@gmail.com> | 2014-04-04 22:26:06 -0400 |
---|---|---|
committer | bunnei <ericbunnie@gmail.com> | 2014-04-04 22:26:06 -0400 |
commit | 69223d007ef70cbcbe4b0db47c00b2f4837f5d23 (patch) | |
tree | c2ec7aceaae8a70a938bd419e31d78ac632907c9 /src/core/src/core.cpp | |
parent | d601d2e69681224aee6cf8ef78c7e7fcb8974566 (diff) |
- added an interface layer for ARM cores
- cleaned up core.cpp a bit
Diffstat (limited to 'src/core/src/core.cpp')
-rw-r--r-- | src/core/src/core.cpp | 87 |
1 files changed, 11 insertions, 76 deletions
diff --git a/src/core/src/core.cpp b/src/core/src/core.cpp index edae66b9f4..5928051346 100644 --- a/src/core/src/core.cpp +++ b/src/core/src/core.cpp @@ -25,28 +25,14 @@ #include "log.h" #include "core.h" #include "mem_map.h" -#include "arm/armdefs.h" -#include "arm/armemu.h" #include "arm/disassembler/arm_disasm.h" +#include "arm/interpreter/arm_interpreter.h" namespace Core { -typedef struct arm11_core{ - conf_object_t* obj; - ARMul_State* state; - memory_space_intf* space; -}arm11_core_t; - -arm11_core* core = NULL; - -Arm* disasm = NULL; - -//ARMul_State* g_arm_state = NULL; - -/// Start the core -void Start() { - // TODO(ShizZy): ImplementMe -} +ARM_Disasm* g_disasm = NULL; ///< ARM disassembler +ARM_Interface* g_app_core = NULL; ///< ARM11 application core +ARM_Interface* g_sys_core = NULL; ///< ARM11 system (OS) core /// Run the core CPU loop void RunLoop() { @@ -55,23 +41,7 @@ void RunLoop() { /// Step the CPU one instruction void SingleStep() { - ARMul_State *state = core->state; - - state->step++; - state->cycle++; - state->EndCondition = 0; - state->stop_simulator = 0; - state->NextInstr = RESUME; /* treat as PC change */ - state->last_pc = state->Reg[15]; - state->Reg[15] = ARMul_DoInstr(state); - state->Cpsr = (state->Cpsr & 0x0fffffdf) | \ - (state->NFlag << 31) | \ - (state->ZFlag << 30) | \ - (state->CFlag << 29) | \ - (state->VFlag << 28);// | \ - //(state->TFlag << 5); - - FLUSHPIPE; + g_app_core->ExecuteInstruction(); } /// Halt the core @@ -85,55 +55,20 @@ void Stop() { } /// Initialize the core -const static cpu_config_t arm11_cpu_info = { "armv6", "arm11", 0x0007b000, 0x0007f000, NONCACHE }; int Init() { NOTICE_LOG(MASTER_LOG, "Core initialized OK"); - disasm = new Arm(); - core = (arm11_core_t*)malloc(sizeof(arm11_core_t)); - //core->obj = new_conf_object(obj_name, core); - ARMul_EmulateInit(); - ARMul_State* state = new ARMul_State; - ARMul_NewState(state); - state->abort_model = 0; - state->cpu = (cpu_config_t*)&arm11_cpu_info; - state->bigendSig = LOW; - - ARMul_SelectProcessor(state, ARM_v6_Prop | ARM_v5_Prop | ARM_v5e_Prop); - state->lateabtSig = LOW; - mmu_init(state); - /* reset the core to initial state */ - ARMul_Reset(state); - state->NextInstr = 0; - state->Emulate = 3; -#if 0 - state->mmu.ops.read_byte = arm11_read_byte; - state->mmu.ops.read_halfword = arm11_read_halfword; - state->mmu.ops.read_word = arm11_read_word; - state->mmu.ops.write_byte = arm11_write_byte; - state->mmu.ops.write_halfword = arm11_write_halfword; - state->mmu.ops.write_word = arm11_write_word; -#endif - core->state = state; - - state->pc = state->Reg[15] = 0x080c3ee0; // Hardcoded set PC to start address of a homebrew ROM - // this is where most launcher.dat code loads /bunnei + g_disasm = new ARM_Disasm(); + g_app_core = new ARM_Interpreter(); + g_sys_core = new ARM_Interpreter(); - state->Reg[13] = 0x10000000; // Set stack pointer to the top of the stack, not sure if this is - // right? /bunnei - - //state->s return 0; } -ARMul_State* GetState() -{ - return core->state; -} - void Shutdown() { - //delete g_arm_state; - //g_arm_state = NULL; + delete g_disasm; + delete g_app_core; + delete g_sys_core; } } // namespace |