diff options
Diffstat (limited to 'src/emu/dimemory.h')
-rw-r--r-- | src/emu/dimemory.h | 60 |
1 files changed, 17 insertions, 43 deletions
diff --git a/src/emu/dimemory.h b/src/emu/dimemory.h index 3d43c6a6a4d..14cd4d48ae2 100644 --- a/src/emu/dimemory.h +++ b/src/emu/dimemory.h @@ -19,44 +19,23 @@ #include <type_traits> - -//************************************************************************** -// CONSTANTS -//************************************************************************** - -// Translation intentions -constexpr int TRANSLATE_TYPE_MASK = 0x03; // read write or fetch -constexpr int TRANSLATE_USER_MASK = 0x04; // user mode or fully privileged -constexpr int TRANSLATE_DEBUG_MASK = 0x08; // debug mode (no side effects) - -constexpr int TRANSLATE_READ = 0; // translate for read -constexpr int TRANSLATE_WRITE = 1; // translate for write -constexpr int TRANSLATE_FETCH = 2; // translate for instruction fetch -constexpr int TRANSLATE_READ_USER = (TRANSLATE_READ | TRANSLATE_USER_MASK); -constexpr int TRANSLATE_WRITE_USER = (TRANSLATE_WRITE | TRANSLATE_USER_MASK); -constexpr int TRANSLATE_FETCH_USER = (TRANSLATE_FETCH | TRANSLATE_USER_MASK); -constexpr int TRANSLATE_READ_DEBUG = (TRANSLATE_READ | TRANSLATE_DEBUG_MASK); -constexpr int TRANSLATE_WRITE_DEBUG = (TRANSLATE_WRITE | TRANSLATE_DEBUG_MASK); -constexpr int TRANSLATE_FETCH_DEBUG = (TRANSLATE_FETCH | TRANSLATE_DEBUG_MASK); - - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> device_memory_interface - class device_memory_interface : public device_interface { friend class device_scheduler; - template <typename T, typename U> struct is_related_class { static constexpr bool value = std::is_convertible<std::add_pointer_t<T>, std::add_pointer_t<U> >::value; }; - template <typename T, typename U> struct is_related_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && is_related_class<T, U>::value; }; - template <typename T, typename U> struct is_related_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && is_related_class<T, U>::value; }; - template <typename T, typename U> struct is_unrelated_device { static constexpr bool value = emu::detail::is_device_implementation<T>::value && !is_related_class<T, U>::value; }; - template <typename T, typename U> struct is_unrelated_interface { static constexpr bool value = emu::detail::is_device_interface<T>::value && !is_related_class<T, U>::value; }; + template <typename T, typename U> using is_related_class = std::bool_constant<std::is_convertible_v<std::add_pointer_t<T>, std::add_pointer_t<U> > >; + template <typename T, typename U> using is_related_device = std::bool_constant<emu::detail::is_device_implementation<T>::value && is_related_class<T, U>::value >; + template <typename T, typename U> using is_related_interface = std::bool_constant<emu::detail::is_device_interface<T>::value && is_related_class<T, U>::value >; + template <typename T, typename U> using is_unrelated_device = std::bool_constant<emu::detail::is_device_implementation<T>::value && !is_related_class<T, U>::value >; + template <typename T, typename U> using is_unrelated_interface = std::bool_constant<emu::detail::is_device_interface<T>::value && !is_related_class<T, U>::value >; public: + // Translation intentions for the translate() call + enum { + TR_READ, + TR_WRITE, + TR_FETCH + }; + // construction/destruction device_memory_interface(const machine_config &mconfig, device_t &device); virtual ~device_memory_interface(); @@ -76,9 +55,7 @@ public: template <typename T, typename U, typename Ret, typename... Params> std::enable_if_t<is_unrelated_interface<T, U>::value> set_addrmap(int spacenum, T &obj, Ret (U::*func)(Params...)) { set_addrmap(spacenum, address_map_constructor(func, obj.device().tag(), &dynamic_cast<U &>(obj))); } template <typename T, typename Ret, typename... Params> - std::enable_if_t<is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params...)); - template <typename T, typename Ret, typename... Params> - std::enable_if_t<!is_related_class<device_t, T>::value> set_addrmap(int spacenum, Ret (T::*func)(Params...)); + void set_addrmap(int spacenum, Ret (T::*func)(Params...)); void set_addrmap(int spacenum, address_map_constructor map); // basic information getters @@ -87,7 +64,7 @@ public: address_space &space(int index = 0) const { assert(index >= 0 && index < int(m_addrspace.size()) && m_addrspace[index]); return *m_addrspace[index]; } // address translation - bool translate(int spacenum, int intention, offs_t &address) { return memory_translate(spacenum, intention, address); } + bool translate(int spacenum, int intention, offs_t &address, address_space *&target_space) { return memory_translate(spacenum, intention, address, target_space); } // deliberately ambiguous functions; if you have the memory interface // just use it @@ -103,8 +80,6 @@ public: } void prepare_maps() { for (auto const &space : m_addrspace) { if (space) { space->prepare_map(); } } } void populate_from_maps() { for (auto const &space : m_addrspace) { if (space) { space->populate_from_map(); } } } - void allocate_memory() { for (auto const &space : m_addrspace) { if (space) { space->allocate_memory(); } } } - void locate_memory() { for (auto const &space : m_addrspace) { if (space) { space->locate_memory(); } } } void set_log_unmap(bool log) { for (auto const &space : m_addrspace) { if (space) { space->set_log_unmap(log); } } } protected: @@ -114,7 +89,7 @@ protected: virtual space_config_vector memory_space_config() const = 0; // optional operation overrides - virtual bool memory_translate(int spacenum, int intention, offs_t &address); + virtual bool memory_translate(int spacenum, int intention, offs_t &address, address_space *&target_space); // interface-level overrides virtual void interface_config_complete() override; @@ -130,8 +105,7 @@ private: }; // iterator -typedef device_interface_iterator<device_memory_interface> memory_interface_iterator; - +typedef device_interface_enumerator<device_memory_interface> memory_interface_enumerator; -#endif /* MAME_EMU_DIMEMORY_H */ +#endif // MAME_EMU_DIMEMORY_H |