mirror of https://github.com/mgba-emu/mgba.git
ARM: Create component hotplugging and use it for attaching and detaching the debugger
This commit is contained in:
parent
30c28f2259
commit
f9120b842f
|
@ -73,7 +73,9 @@ void ARMInit(struct ARMCore* cpu) {
|
|||
cpu->master->init(cpu, cpu->master);
|
||||
int i;
|
||||
for (i = 0; i < cpu->numComponents; ++i) {
|
||||
cpu->components[i]->init(cpu, cpu->components[i]);
|
||||
if (cpu->components[i] && cpu->components[i]->init) {
|
||||
cpu->components[i]->init(cpu, cpu->components[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ void ARMDeinit(struct ARMCore* cpu) {
|
|||
}
|
||||
int i;
|
||||
for (i = 0; i < cpu->numComponents; ++i) {
|
||||
if (cpu->components[i]->deinit) {
|
||||
if (cpu->components[i] && cpu->components[i]->deinit) {
|
||||
cpu->components[i]->deinit(cpu->components[i]);
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +97,19 @@ void ARMSetComponents(struct ARMCore* cpu, struct ARMComponent* master, int extr
|
|||
cpu->components = extras;
|
||||
}
|
||||
|
||||
void ARMHotplugAttach(struct ARMCore* cpu, int slot) {
|
||||
if (slot >= cpu->numComponents) {
|
||||
return;
|
||||
}
|
||||
cpu->components[slot]->init(cpu, cpu->components[slot]);
|
||||
}
|
||||
|
||||
void ARMHotplugDetach(struct ARMCore* cpu, int slot) {
|
||||
if (slot >= cpu->numComponents) {
|
||||
return;
|
||||
}
|
||||
cpu->components[slot]->init(cpu, cpu->components[slot]);
|
||||
}
|
||||
|
||||
void ARMReset(struct ARMCore* cpu) {
|
||||
int i;
|
||||
|
|
|
@ -165,6 +165,8 @@ struct ARMCore {
|
|||
void ARMInit(struct ARMCore* cpu);
|
||||
void ARMDeinit(struct ARMCore* cpu);
|
||||
void ARMSetComponents(struct ARMCore* cpu, struct ARMComponent* master, int extra, struct ARMComponent** extras);
|
||||
void ARMHotplugAttach(struct ARMCore* cpu, int slot);
|
||||
void ARMHotplugDetach(struct ARMCore* cpu, int slot);
|
||||
|
||||
void ARMReset(struct ARMCore* cpu);
|
||||
void ARMSetPrivilegeMode(struct ARMCore*, enum PrivilegeMode);
|
||||
|
|
|
@ -108,13 +108,8 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
|||
struct ARMCore cpu;
|
||||
struct Patch patch;
|
||||
struct GBAThread* threadContext = context;
|
||||
struct ARMComponent* components[1] = {};
|
||||
int numComponents = 0;
|
||||
|
||||
if (threadContext->debugger) {
|
||||
components[numComponents] = &threadContext->debugger->d;
|
||||
++numComponents;
|
||||
}
|
||||
struct ARMComponent* components[GBA_COMPONENT_MAX] = {};
|
||||
int numComponents = GBA_COMPONENT_MAX;
|
||||
|
||||
#if !defined(_WIN32) && defined(USE_PTHREADS)
|
||||
sigset_t signals;
|
||||
|
|
|
@ -434,10 +434,14 @@ static int32_t GBATimersProcessEvents(struct GBA* gba, int32_t cycles) {
|
|||
|
||||
void GBAAttachDebugger(struct GBA* gba, struct ARMDebugger* debugger) {
|
||||
gba->debugger = debugger;
|
||||
gba->cpu->components[GBA_COMPONENT_DEBUGGER] = &debugger->d;
|
||||
ARMHotplugAttach(gba->cpu, GBA_COMPONENT_DEBUGGER);
|
||||
}
|
||||
|
||||
void GBADetachDebugger(struct GBA* gba) {
|
||||
gba->debugger = 0;
|
||||
ARMHotplugDetach(gba->cpu, GBA_COMPONENT_DEBUGGER);
|
||||
gba->cpu->components[GBA_COMPONENT_DEBUGGER] = 0;
|
||||
}
|
||||
|
||||
void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) {
|
||||
|
|
|
@ -75,6 +75,11 @@ enum GBAKey {
|
|||
GBA_KEY_NONE = -1
|
||||
};
|
||||
|
||||
enum GBAComponent {
|
||||
GBA_COMPONENT_DEBUGGER,
|
||||
GBA_COMPONENT_MAX
|
||||
};
|
||||
|
||||
struct GBA;
|
||||
struct GBARotationSource;
|
||||
struct Patch;
|
||||
|
|
Loading…
Reference in New Issue