Fix MT7560 [O. Galibert]

This commit is contained in:
Olivier Galibert 2020-04-08 23:05:41 +02:00
parent ca4f63c49b
commit 6455bedb9c
4 changed files with 18 additions and 6 deletions

View File

@ -542,6 +542,8 @@ template<int Width, int AddrShift, int Endian> class handler_entry_read : public
public:
using uX = typename emu::detail::handler_entry_size<Width>::uX;
static constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? make_bitmask<u32>(Width + AddrShift) : 0;
struct mapping {
handler_entry_read<Width, AddrShift, Endian> *original;
handler_entry_read<Width, AddrShift, Endian> *patched;
@ -603,6 +605,8 @@ template<int Width, int AddrShift, int Endian> class handler_entry_write : publi
public:
using uX = typename emu::detail::handler_entry_size<Width>::uX;
static constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? make_bitmask<u32>(Width + AddrShift) : 0;
struct mapping {
handler_entry_write<Width, AddrShift, Endian> *original;
handler_entry_write<Width, AddrShift, Endian> *patched;
@ -617,6 +621,8 @@ public:
virtual void lookup(offs_t address, offs_t &start, offs_t &end, handler_entry_write<Width, AddrShift, Endian> *&handler) const;
inline void populate(offs_t start, offs_t end, offs_t mirror, handler_entry_write<Width, AddrShift, Endian> *handler) {
start &= ~NATIVE_MASK;
end |= ~NATIVE_MASK;
if(mirror)
populate_mirror(start, end, start, end, mirror, handler);
else
@ -627,6 +633,9 @@ public:
virtual void populate_mirror(offs_t start, offs_t end, offs_t ostart, offs_t oend, offs_t mirror, handler_entry_write<Width, AddrShift, Endian> *handler);
inline void populate_mismatched(offs_t start, offs_t end, offs_t mirror, const memory_units_descriptor<Width, AddrShift, Endian> &descriptor) {
start &= ~NATIVE_MASK;
end |= ~NATIVE_MASK;
std::vector<mapping> mappings;
if(mirror)
populate_mismatched_mirror(start, end, start, end, mirror, descriptor, mappings);
@ -693,7 +702,7 @@ template<int Width, int AddrShift, int Endian, int TargetWidth, bool Aligned, ty
constexpr u32 NATIVE_BYTES = 1 << Width;
constexpr u32 NATIVE_BITS = 8 * NATIVE_BYTES;
constexpr u32 NATIVE_STEP = AddrShift >= 0 ? NATIVE_BYTES << iabs(AddrShift) : NATIVE_BYTES >> iabs(AddrShift);
constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? (1 << (Width + AddrShift)) - 1 : 0;
constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? make_bitmask<u32>(Width + AddrShift) : 0;
// equal to native size and aligned; simple pass-through to the native reader
if (NATIVE_BYTES == TARGET_BYTES && (Aligned || (address & NATIVE_MASK) == 0))

View File

@ -14,7 +14,7 @@ public:
~handler_entry_read_address() = default;
inline void set_address_info(offs_t base, offs_t mask) {
m_address_base = base;
m_address_base = base & ~handler_entry_read<Width, AddrShift, Endian>::NATIVE_MASK;
m_address_mask = mask;
}
@ -27,11 +27,13 @@ template<int Width, int AddrShift, int Endian> class handler_entry_write_address
public:
using uX = typename emu::detail::handler_entry_size<Width>::uX;
static constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? (1 << (Width + AddrShift)) - 1 : 0;
handler_entry_write_address(address_space *space, u32 flags) : handler_entry_write<Width, AddrShift, Endian>(space, flags) {}
~handler_entry_write_address() = default;
inline void set_address_info(offs_t base, offs_t mask) {
m_address_base = base;
m_address_base = base & ~handler_entry_write<Width, AddrShift, Endian>::NATIVE_MASK;
m_address_mask = mask;
}

View File

@ -41,8 +41,10 @@ template<int HighBits, int Width, int AddrShift, int Endian> void handler_entry_
offs_t entry = (cur >> LowBits) & BITMASK;
if(m_dispatch[entry]->is_dispatch())
m_dispatch[entry]->dump_map(map);
else
else {
fprintf(stderr, "add range %08x %08x\n", m_ranges[entry].start, m_ranges[entry].end);
map.emplace_back(memory_entry{ m_ranges[entry].start, m_ranges[entry].end, m_dispatch[entry] });
}
cur = map.back().end + 1;
} while(cur && !((cur ^ base) & UPMASK));
}

View File

@ -37,14 +37,13 @@ template<> u8 mask_to_ukey<u64>(u64 mask)
template<int Width, int AddrShift, int Endian> memory_units_descriptor<Width, AddrShift, Endian>::memory_units_descriptor(u8 access_width, u8 access_endian, handler_entry *handler, offs_t addrstart, offs_t addrend, offs_t mask, typename emu::detail::handler_entry_size<Width>::uX unitmask, int cswidth) : m_handler(handler), m_access_width(access_width), m_access_endian(access_endian)
{
constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? make_bitmask<u32>(Width + AddrShift) : 0;
u32 bits_per_access = 8 << access_width;
constexpr u32 NATIVE_MASK = Width + AddrShift >= 0 ? make_bitmask<u32>(Width + AddrShift) : 0;
// Compute the real base addresses
m_addrstart = addrstart & ~NATIVE_MASK;
m_addrend = addrend & ~NATIVE_MASK;
// Compute the masks and the keys
std::array<uX, 4> umasks;
umasks.fill(unitmask);