mirror of https://github.com/mgba-emu/mgba.git
ARM: Expose ARMSelectBank API
This commit is contained in:
parent
e68d3ed00f
commit
07667955f6
|
@ -142,4 +142,26 @@ static inline bool ARMTestCondition(struct ARMCore* cpu, unsigned condition) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline enum RegisterBank ARMSelectBank(enum PrivilegeMode mode) {
|
||||
switch (mode) {
|
||||
case MODE_USER:
|
||||
case MODE_SYSTEM:
|
||||
// No banked registers
|
||||
return BANK_NONE;
|
||||
case MODE_FIQ:
|
||||
return BANK_FIQ;
|
||||
case MODE_IRQ:
|
||||
return BANK_IRQ;
|
||||
case MODE_SUPERVISOR:
|
||||
return BANK_SUPERVISOR;
|
||||
case MODE_ABORT:
|
||||
return BANK_ABORT;
|
||||
case MODE_UNDEFINED:
|
||||
return BANK_UNDEFINED;
|
||||
default:
|
||||
// This should be unreached
|
||||
return BANK_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,16 +9,14 @@
|
|||
#include <mgba/internal/arm/isa-inlines.h>
|
||||
#include <mgba/internal/arm/isa-thumb.h>
|
||||
|
||||
static inline enum RegisterBank _ARMSelectBank(enum PrivilegeMode);
|
||||
|
||||
void ARMSetPrivilegeMode(struct ARMCore* cpu, enum PrivilegeMode mode) {
|
||||
if (mode == cpu->privilegeMode) {
|
||||
// Not switching modes after all
|
||||
return;
|
||||
}
|
||||
|
||||
enum RegisterBank newBank = _ARMSelectBank(mode);
|
||||
enum RegisterBank oldBank = _ARMSelectBank(cpu->privilegeMode);
|
||||
enum RegisterBank newBank = ARMSelectBank(mode);
|
||||
enum RegisterBank oldBank = ARMSelectBank(cpu->privilegeMode);
|
||||
if (newBank != oldBank) {
|
||||
// Switch banked registers
|
||||
if (mode == MODE_FIQ || cpu->privilegeMode == MODE_FIQ) {
|
||||
|
@ -46,28 +44,6 @@ void ARMSetPrivilegeMode(struct ARMCore* cpu, enum PrivilegeMode mode) {
|
|||
cpu->privilegeMode = mode;
|
||||
}
|
||||
|
||||
static inline enum RegisterBank _ARMSelectBank(enum PrivilegeMode mode) {
|
||||
switch (mode) {
|
||||
case MODE_USER:
|
||||
case MODE_SYSTEM:
|
||||
// No banked registers
|
||||
return BANK_NONE;
|
||||
case MODE_FIQ:
|
||||
return BANK_FIQ;
|
||||
case MODE_IRQ:
|
||||
return BANK_IRQ;
|
||||
case MODE_SUPERVISOR:
|
||||
return BANK_SUPERVISOR;
|
||||
case MODE_ABORT:
|
||||
return BANK_ABORT;
|
||||
case MODE_UNDEFINED:
|
||||
return BANK_UNDEFINED;
|
||||
default:
|
||||
// This should be unreached
|
||||
return BANK_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
void ARMInit(struct ARMCore* cpu) {
|
||||
cpu->master->init(cpu, cpu->master);
|
||||
size_t i;
|
||||
|
|
Loading…
Reference in New Issue