mirror of
https://github.com/holub/mame
synced 2025-04-26 10:13:37 +03:00
ns32000: prepare for mmu
* centralized memory accessors * added translation interface * implemented some missing instructions * add cascaded interrupt support
This commit is contained in:
parent
242f986c1e
commit
87ca33171f
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,7 @@ class ns32000_device : public cpu_device
|
||||
{
|
||||
public:
|
||||
template <typename T> void set_fpu(T &&tag) { m_fpu.set_tag(std::forward<T>(tag)); }
|
||||
template <typename T> void set_mmu(T &&tag) { m_mmu.set_tag(std::forward<T>(tag)); }
|
||||
|
||||
// construction/destruction
|
||||
ns32000_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock);
|
||||
@ -44,12 +45,12 @@ protected:
|
||||
|
||||
enum addr_mode_type : unsigned
|
||||
{
|
||||
IMM,
|
||||
REG,
|
||||
MEM,
|
||||
IND,
|
||||
EXT,
|
||||
TOS,
|
||||
IMM, // immediate
|
||||
REG, // register
|
||||
MEM, // memory space
|
||||
REL, // memory relative
|
||||
EXT, // external
|
||||
TOS, // top of stack
|
||||
};
|
||||
enum access_class : unsigned
|
||||
{
|
||||
@ -71,8 +72,7 @@ protected:
|
||||
// time needed to read or write a memory operand
|
||||
unsigned top(size_code const size, u32 const address = 0) const
|
||||
{
|
||||
// TODO: mmu cycles
|
||||
static constexpr unsigned tmmu = 0;
|
||||
unsigned const tmmu = m_mmu ? 1 : 0;
|
||||
|
||||
switch (size)
|
||||
{
|
||||
@ -118,7 +118,12 @@ protected:
|
||||
unsigned tea;
|
||||
};
|
||||
|
||||
// instruction decoding helpers
|
||||
// memory accessors
|
||||
template <typename T> T mem_read(unsigned st, u32 address, bool user = false);
|
||||
template <typename T> void mem_write(unsigned st, u32 address, T data, bool user = false);
|
||||
|
||||
// instruction fetch/decode helpers
|
||||
template <typename T> T fetch(unsigned &bytes);
|
||||
s32 displacement(unsigned &bytes);
|
||||
void decode(addr_mode *mode, unsigned &bytes);
|
||||
|
||||
@ -132,7 +137,7 @@ protected:
|
||||
bool condition(unsigned const cc);
|
||||
void flags(u32 const src1, u32 const src2, u32 const dest, unsigned const size, bool const subtraction);
|
||||
void interrupt(unsigned const vector, u32 const return_address, bool const trap = true);
|
||||
u16 slave(addr_mode op1, addr_mode op2);
|
||||
u16 slave(ns32000_slave_interface *slave, addr_mode op1, addr_mode op2);
|
||||
|
||||
private:
|
||||
// configuration
|
||||
@ -140,12 +145,16 @@ private:
|
||||
address_space_config m_interrupt_config;
|
||||
|
||||
optional_device<ns32000_slave_interface> m_fpu;
|
||||
optional_device<ns32000_mmu_interface> m_mmu;
|
||||
|
||||
// emulation state
|
||||
int m_icount;
|
||||
|
||||
typename memory_access<24, Width, 0, ENDIANNESS_LITTLE>::specific m_bus[16];
|
||||
|
||||
u32 m_ssp; // saved stack pointer
|
||||
u16 m_sps; // saved program status
|
||||
|
||||
u32 m_pc; // program counter
|
||||
u32 m_sb; // static base
|
||||
u32 m_fp; // frame pointer
|
||||
|
@ -33,6 +33,12 @@ public:
|
||||
virtual u16 read_op() = 0;
|
||||
|
||||
protected:
|
||||
ns32000_slave_interface(machine_config const &mconfig, device_t &device, char const *type)
|
||||
: device_interface(device, type)
|
||||
, m_out_scb(*this)
|
||||
{
|
||||
}
|
||||
|
||||
// device_interface overrides
|
||||
virtual void interface_post_start() override
|
||||
{
|
||||
@ -42,4 +48,16 @@ protected:
|
||||
devcb_write_line m_out_scb;
|
||||
};
|
||||
|
||||
class ns32000_mmu_interface : public ns32000_slave_interface
|
||||
{
|
||||
public:
|
||||
ns32000_mmu_interface(machine_config const &mconfig, device_t &device)
|
||||
: ns32000_slave_interface(mconfig, device, "ns32000_mmu")
|
||||
{
|
||||
}
|
||||
|
||||
enum translate_result : unsigned { COMPLETE, CANCEL, ABORT };
|
||||
virtual translate_result translate(address_space &space, unsigned st, u32 &address, bool user, bool write, bool debug = false) = 0;
|
||||
};
|
||||
|
||||
#endif // MAME_CPU_NS32000_SLAVE_H
|
||||
|
Loading…
Reference in New Issue
Block a user