flycast/core/hw/arm7/arm_mem.cpp

102 lines
1.8 KiB
C++
Raw Normal View History

2013-12-19 17:10:14 +00:00
#include "arm_mem.h"
#include "hw/aica/aica_mem.h"
2013-12-19 17:10:14 +00:00
namespace aica
{
namespace arm
{
2013-12-19 17:10:14 +00:00
#define REG_L (0x2D00)
#define REG_M (0x2D04)
//Set to true when aica interrupt is pending
2023-01-30 12:21:43 +00:00
bool aica_interr;
u32 aica_reg_L;
2013-12-19 17:10:14 +00:00
//Set to true when the out of the intc is 1
2023-01-30 12:21:43 +00:00
bool e68k_out;
2013-12-19 17:10:14 +00:00
u32 e68k_reg_L;
2023-01-30 12:21:43 +00:00
u32 e68k_reg_M; //constant ?
2013-12-19 17:10:14 +00:00
void update_e68k()
{
if (!e68k_out && aica_interr)
{
//Set the pending signal
//Is L register held here too ?
2023-01-30 12:21:43 +00:00
e68k_out = true;
e68k_reg_L = aica_reg_L;
2013-12-19 17:10:14 +00:00
update_armintc();
}
}
void interruptChange(u32 bits,u32 L)
2013-12-19 17:10:14 +00:00
{
2023-01-30 12:21:43 +00:00
aica_interr = bits != 0;
2013-12-19 17:10:14 +00:00
if (aica_interr)
2023-01-30 12:21:43 +00:00
aica_reg_L = L;
2013-12-19 17:10:14 +00:00
update_e68k();
}
void e68k_AcceptInterrupt()
{
2023-01-30 12:21:43 +00:00
e68k_out = false;
2013-12-19 17:10:14 +00:00
update_e68k();
update_armintc();
}
//Reg reads from arm side ..
template <typename T>
2023-01-30 12:21:43 +00:00
T readReg(u32 addr)
2013-12-19 17:10:14 +00:00
{
addr &= 0x7FFF;
if (addr == REG_L)
return (T)e68k_reg_L;
else if (addr == REG_M)
return (T)e68k_reg_M; //shouldn't really happen
else if (sizeof(T) == 4)
2023-01-30 12:21:43 +00:00
return readRegInternal<u16>(addr);
2013-12-19 17:10:14 +00:00
else
2023-01-30 12:21:43 +00:00
return readRegInternal<T>(addr);
}
template <typename T>
2023-01-30 12:21:43 +00:00
void writeReg(u32 addr, T data)
2013-12-19 17:10:14 +00:00
{
addr &= 0x7FFF;
if (addr == REG_L)
{
return; // Shouldn't really happen (read only)
}
else if (addr == REG_M)
2013-12-19 17:10:14 +00:00
{
//accept interrupts
if (data & 1)
2013-12-19 17:10:14 +00:00
e68k_AcceptInterrupt();
}
else
{
if (sizeof(T) == 4)
2023-01-30 12:21:43 +00:00
writeRegInternal(addr, (u16)data);
else
2023-01-30 12:21:43 +00:00
writeRegInternal(addr, data);
}
2013-12-19 17:10:14 +00:00
}
//00000000~007FFFFF @DRAM_AREA*
//00800000~008027FF @CHANNEL_DATA
//00802800~00802FFF @COMMON_DATA
//00803000~00807FFF @DSP_DATA
2023-01-30 12:21:43 +00:00
template u8 readReg<u8>(u32 adr);
template u16 readReg<u16>(u32 adr);
template u32 readReg<u32>(u32 adr);
2013-12-19 17:10:14 +00:00
2023-01-30 12:21:43 +00:00
template void writeReg<>(u32 adr, u8 data);
template void writeReg<>(u32 adr, u16 data);
template void writeReg<>(u32 adr, u32 data);
} // namespace arm
} // namespace aica