mirror of https://github.com/mgba-emu/mgba.git
Core: Merge ARMComponent and LR35902Component
This commit is contained in:
parent
82c4d93dc4
commit
fbfbbbf279
|
@ -90,7 +90,7 @@ void ARMDeinit(struct ARMCore* cpu) {
|
|||
}
|
||||
}
|
||||
|
||||
void ARMSetComponents(struct ARMCore* cpu, struct ARMComponent* master, int extra, struct ARMComponent** extras) {
|
||||
void ARMSetComponents(struct ARMCore* cpu, struct mCPUComponent* master, int extra, struct mCPUComponent** extras) {
|
||||
cpu->master = master;
|
||||
cpu->numComponents = extra;
|
||||
cpu->components = extras;
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/cpu.h"
|
||||
|
||||
enum {
|
||||
ARM_SP = 13,
|
||||
ARM_LR = 14,
|
||||
|
@ -129,12 +131,6 @@ struct ARMInterruptHandler {
|
|||
void (*hitStub)(struct ARMCore* cpu, uint32_t opcode);
|
||||
};
|
||||
|
||||
struct ARMComponent {
|
||||
uint32_t id;
|
||||
void (*init)(struct ARMCore* cpu, struct ARMComponent* component);
|
||||
void (*deinit)(struct ARMComponent* component);
|
||||
};
|
||||
|
||||
struct ARMCore {
|
||||
int32_t gprs[16];
|
||||
union PSR cpsr;
|
||||
|
@ -157,15 +153,15 @@ struct ARMCore {
|
|||
struct ARMMemory memory;
|
||||
struct ARMInterruptHandler irqh;
|
||||
|
||||
struct ARMComponent* master;
|
||||
struct mCPUComponent* master;
|
||||
|
||||
size_t numComponents;
|
||||
struct ARMComponent** components;
|
||||
struct mCPUComponent** components;
|
||||
};
|
||||
|
||||
void ARMInit(struct ARMCore* cpu);
|
||||
void ARMDeinit(struct ARMCore* cpu);
|
||||
void ARMSetComponents(struct ARMCore* cpu, struct ARMComponent* master, int extra, struct ARMComponent** extras);
|
||||
void ARMSetComponents(struct ARMCore* cpu, struct mCPUComponent* master, int extra, struct mCPUComponent** extras);
|
||||
void ARMHotplugAttach(struct ARMCore* cpu, size_t slot);
|
||||
void ARMHotplugDetach(struct ARMCore* cpu, size_t slot);
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#ifndef M_CPU_H
|
||||
#define M_CPU_H
|
||||
|
||||
#include "util/common.h"
|
||||
|
||||
struct mCPUComponent {
|
||||
uint32_t id;
|
||||
void (*init)(void* cpu, struct mCPUComponent* component);
|
||||
void (*deinit)(struct mCPUComponent* component);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -43,8 +43,8 @@ static void _checkBreakpoints(struct ARMDebugger* debugger) {
|
|||
ARMDebuggerEnter(debugger, DEBUGGER_ENTER_BREAKPOINT, &info);
|
||||
}
|
||||
|
||||
static void ARMDebuggerInit(struct ARMCore*, struct ARMComponent*);
|
||||
static void ARMDebuggerDeinit(struct ARMComponent*);
|
||||
static void ARMDebuggerInit(void* cpu, struct mCPUComponent*);
|
||||
static void ARMDebuggerDeinit(struct mCPUComponent*);
|
||||
|
||||
void ARMDebuggerCreate(struct ARMDebugger* debugger) {
|
||||
debugger->d.id = ARM_DEBUGGER_ID;
|
||||
|
@ -52,11 +52,11 @@ void ARMDebuggerCreate(struct ARMDebugger* debugger) {
|
|||
debugger->d.deinit = ARMDebuggerDeinit;
|
||||
}
|
||||
|
||||
void ARMDebuggerInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
||||
void ARMDebuggerInit(void* cpu, struct mCPUComponent* component) {
|
||||
struct ARMDebugger* debugger = (struct ARMDebugger*) component;
|
||||
debugger->cpu = cpu;
|
||||
debugger->state = DEBUGGER_RUNNING;
|
||||
debugger->originalMemory = cpu->memory;
|
||||
debugger->originalMemory = debugger->cpu->memory;
|
||||
debugger->currentBreakpoint = 0;
|
||||
DebugBreakpointListInit(&debugger->breakpoints, 0);
|
||||
DebugBreakpointListInit(&debugger->swBreakpoints, 0);
|
||||
|
@ -66,7 +66,7 @@ void ARMDebuggerInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
|||
}
|
||||
}
|
||||
|
||||
void ARMDebuggerDeinit(struct ARMComponent* component) {
|
||||
void ARMDebuggerDeinit(struct mCPUComponent* component) {
|
||||
struct ARMDebugger* debugger = (struct ARMDebugger*) component;
|
||||
debugger->deinit(debugger);
|
||||
DebugBreakpointListDeinit(&debugger->breakpoints);
|
||||
|
|
|
@ -75,7 +75,7 @@ enum DebuggerLogLevel {
|
|||
};
|
||||
|
||||
struct ARMDebugger {
|
||||
struct ARMComponent d;
|
||||
struct mCPUComponent d;
|
||||
enum DebuggerState state;
|
||||
struct ARMCore* cpu;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ const uint32_t GB_COMPONENT_MAGIC = 0x400000;
|
|||
|
||||
mLOG_DEFINE_CATEGORY(GB, "GB");
|
||||
|
||||
static void GBInit(struct LR35902Core* cpu, struct LR35902Component* component);
|
||||
static void GBInit(void* cpu, struct mCPUComponent* component);
|
||||
static void GBInterruptHandlerInit(struct LR35902InterruptHandler* irqh);
|
||||
static void GBProcessEvents(struct LR35902Core* cpu);
|
||||
static void GBSetInterrupts(struct LR35902Core* cpu, bool enable);
|
||||
|
@ -34,11 +34,11 @@ void GBCreate(struct GB* gb) {
|
|||
gb->d.deinit = 0;
|
||||
}
|
||||
|
||||
static void GBInit(struct LR35902Core* cpu, struct LR35902Component* component) {
|
||||
static void GBInit(void* cpu, struct mCPUComponent* component) {
|
||||
struct GB* gb = (struct GB*) component;
|
||||
gb->cpu = cpu;
|
||||
|
||||
GBInterruptHandlerInit(&cpu->irqh);
|
||||
GBInterruptHandlerInit(&gb->cpu->irqh);
|
||||
GBMemoryInit(gb);
|
||||
|
||||
gb->video.p = gb;
|
||||
|
|
|
@ -42,7 +42,7 @@ enum GBIRQVector {
|
|||
|
||||
struct mCoreSync;
|
||||
struct GB {
|
||||
struct LR35902Component d;
|
||||
struct mCPUComponent d;
|
||||
|
||||
struct LR35902Core* cpu;
|
||||
struct GBMemory memory;
|
||||
|
|
|
@ -99,8 +99,8 @@ static void _unpatchROM(struct GBACheatDevice* device, struct GBACheatSet* cheat
|
|||
}
|
||||
}
|
||||
|
||||
static void GBACheatDeviceInit(struct ARMCore*, struct ARMComponent*);
|
||||
static void GBACheatDeviceDeinit(struct ARMComponent*);
|
||||
static void GBACheatDeviceInit(void*, struct mCPUComponent*);
|
||||
static void GBACheatDeviceDeinit(struct mCPUComponent*);
|
||||
|
||||
void GBACheatDeviceCreate(struct GBACheatDevice* device) {
|
||||
device->d.id = GBA_CHEAT_DEVICE_ID;
|
||||
|
@ -557,9 +557,9 @@ void GBACheatSetCopyProperties(struct GBACheatSet* newSet, struct GBACheatSet* s
|
|||
}
|
||||
}
|
||||
|
||||
void GBACheatDeviceInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
||||
void GBACheatDeviceInit(void* cpu, struct mCPUComponent* component) {
|
||||
struct GBACheatDevice* device = (struct GBACheatDevice*) component;
|
||||
device->p = (struct GBA*) cpu->master;
|
||||
device->p = (struct GBA*) ((struct ARMCore*) cpu)->master;
|
||||
size_t i;
|
||||
for (i = 0; i < GBACheatSetsSize(&device->cheats); ++i) {
|
||||
struct GBACheatSet* cheats = *GBACheatSetsGetPointer(&device->cheats, i);
|
||||
|
@ -568,7 +568,7 @@ void GBACheatDeviceInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
|||
}
|
||||
}
|
||||
|
||||
void GBACheatDeviceDeinit(struct ARMComponent* component) {
|
||||
void GBACheatDeviceDeinit(struct mCPUComponent* component) {
|
||||
struct GBACheatDevice* device = (struct GBACheatDevice*) component;
|
||||
size_t i;
|
||||
for (i = GBACheatSetsSize(&device->cheats); i--;) {
|
||||
|
|
|
@ -182,7 +182,7 @@ struct GBACheatSet {
|
|||
DECLARE_VECTOR(GBACheatSets, struct GBACheatSet*);
|
||||
|
||||
struct GBACheatDevice {
|
||||
struct ARMComponent d;
|
||||
struct mCPUComponent d;
|
||||
struct GBA* p;
|
||||
|
||||
struct GBACheatSets cheats;
|
||||
|
|
|
@ -19,7 +19,7 @@ struct GBACore {
|
|||
struct mCore d;
|
||||
struct GBAVideoSoftwareRenderer renderer;
|
||||
int keys;
|
||||
struct ARMComponent* components[GBA_COMPONENT_MAX];
|
||||
struct mCPUComponent* components[GBA_COMPONENT_MAX];
|
||||
};
|
||||
|
||||
static bool _GBACoreInit(struct mCore* core) {
|
||||
|
|
|
@ -32,7 +32,7 @@ static const uint8_t GBA_ROM_MAGIC[] = { 0xEA };
|
|||
|
||||
static const size_t GBA_MB_MAGIC_OFFSET = 0xC0;
|
||||
|
||||
static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component);
|
||||
static void GBAInit(void* cpu, struct mCPUComponent* component);
|
||||
static void GBAInterruptHandlerInit(struct ARMInterruptHandler* irqh);
|
||||
static void GBAProcessEvents(struct ARMCore* cpu);
|
||||
static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles);
|
||||
|
@ -55,13 +55,13 @@ void GBACreate(struct GBA* gba) {
|
|||
gba->d.deinit = 0;
|
||||
}
|
||||
|
||||
static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) {
|
||||
static void GBAInit(void* cpu, struct mCPUComponent* component) {
|
||||
struct GBA* gba = (struct GBA*) component;
|
||||
gba->cpu = cpu;
|
||||
gba->debugger = 0;
|
||||
gba->sync = 0;
|
||||
|
||||
GBAInterruptHandlerInit(&cpu->irqh);
|
||||
GBAInterruptHandlerInit(&gba->cpu->irqh);
|
||||
GBAMemoryInit(gba);
|
||||
GBASavedataInit(&gba->memory.savedata, 0);
|
||||
|
||||
|
@ -936,7 +936,7 @@ void GBAFrameEnded(struct GBA* gba) {
|
|||
}
|
||||
}
|
||||
|
||||
void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t address, enum ExecutionMode mode, uint32_t* opcode) {
|
||||
void GBASetBreakpoint(struct GBA* gba, struct mCPUComponent* component, uint32_t address, enum ExecutionMode mode, uint32_t* opcode) {
|
||||
size_t immediate;
|
||||
for (immediate = 0; immediate < gba->cpu->numComponents; ++immediate) {
|
||||
if (gba->cpu->components[immediate] == component) {
|
||||
|
|
|
@ -78,7 +78,7 @@ struct GBATimer {
|
|||
};
|
||||
|
||||
struct GBA {
|
||||
struct ARMComponent d;
|
||||
struct mCPUComponent d;
|
||||
|
||||
struct ARMCore* cpu;
|
||||
struct GBAMemory memory;
|
||||
|
@ -169,7 +169,7 @@ void GBAStop(struct GBA* gba);
|
|||
void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger);
|
||||
void GBADetachDebugger(struct GBA* gba);
|
||||
|
||||
void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t address, enum ExecutionMode mode,
|
||||
void GBASetBreakpoint(struct GBA* gba, struct mCPUComponent* component, uint32_t address, enum ExecutionMode mode,
|
||||
uint32_t* opcode);
|
||||
void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
|||
struct Patch patch;
|
||||
struct GBACheatDevice cheatDevice;
|
||||
struct GBAThread* threadContext = context;
|
||||
struct ARMComponent* components[GBA_COMPONENT_MAX] = { 0 };
|
||||
struct mCPUComponent* components[GBA_COMPONENT_MAX] = { 0 };
|
||||
struct GBARRContext* movie = 0;
|
||||
int numComponents = GBA_COMPONENT_MAX;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ void LR35902Deinit(struct LR35902Core* cpu) {
|
|||
}
|
||||
}
|
||||
|
||||
void LR35902SetComponents(struct LR35902Core* cpu, struct LR35902Component* master, int extra, struct LR35902Component** extras) {
|
||||
void LR35902SetComponents(struct LR35902Core* cpu, struct mCPUComponent* master, int extra, struct mCPUComponent** extras) {
|
||||
cpu->master = master;
|
||||
cpu->numComponents = extra;
|
||||
cpu->components = extras;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "util/common.h"
|
||||
|
||||
#include "core/cpu.h"
|
||||
#include "lr35902/isa-lr35902.h"
|
||||
|
||||
struct LR35902Core;
|
||||
|
@ -67,13 +68,6 @@ struct LR35902InterruptHandler {
|
|||
void (*hitStub)(struct LR35902Core* cpu);
|
||||
};
|
||||
|
||||
// TODO: Merge with ARMComponent?
|
||||
struct LR35902Component {
|
||||
uint32_t id;
|
||||
void (*init)(struct LR35902Core* cpu, struct LR35902Component* component);
|
||||
void (*deinit)(struct LR35902Component* component);
|
||||
};
|
||||
|
||||
struct LR35902Core {
|
||||
#pragma pack(push, 1)
|
||||
union {
|
||||
|
@ -125,10 +119,10 @@ struct LR35902Core {
|
|||
struct LR35902Memory memory;
|
||||
struct LR35902InterruptHandler irqh;
|
||||
|
||||
struct LR35902Component* master;
|
||||
struct mCPUComponent* master;
|
||||
|
||||
size_t numComponents;
|
||||
struct LR35902Component** components;
|
||||
struct mCPUComponent** components;
|
||||
};
|
||||
|
||||
static inline uint16_t LR35902ReadHL(struct LR35902Core* cpu) {
|
||||
|
@ -163,7 +157,7 @@ static inline void LR35902WriteDE(struct LR35902Core* cpu, uint16_t de) {
|
|||
|
||||
void LR35902Init(struct LR35902Core* cpu);
|
||||
void LR35902Deinit(struct LR35902Core* cpu);
|
||||
void LR35902SetComponents(struct LR35902Core* cpu, struct LR35902Component* master, int extra, struct LR35902Component** extras);
|
||||
void LR35902SetComponents(struct LR35902Core* cpu, struct mCPUComponent* master, int extra, struct mCPUComponent** extras);
|
||||
void LR35902HotplugAttach(struct LR35902Core* cpu, size_t slot);
|
||||
void LR35902HotplugDetach(struct LR35902Core* cpu, size_t slot);
|
||||
|
||||
|
|
Loading…
Reference in New Issue