Disambiguate Mmio::local_addr

This is a follow-up fix for "Streamline platform-device API on ARM".
There is an ambiguity of the 'local_addr' method between the inherited
'Attached_dataspace' and the local declaration, which results in the
double application of the sub-page Range::start.

Issue #4075
This commit is contained in:
Norman Feske 2021-04-22 14:03:59 +02:00
parent 173264ed1e
commit ace7c9172b

View File

@ -86,6 +86,11 @@ class Platform::Device::Mmio : Range, Attached_dataspace, public Genode::Mmio
return io_mem.dataspace();
}
addr_t _local_addr()
{
return (addr_t)Attached_dataspace::local_addr<char>() + Range::start;
}
public:
struct Index { unsigned value; };
@ -93,7 +98,7 @@ class Platform::Device::Mmio : Range, Attached_dataspace, public Genode::Mmio
Mmio(Device &device, Index index)
:
Attached_dataspace(device._rm(), _ds_cap(device, index.value)),
Genode::Mmio((addr_t)(local_addr<char>() + Range::start))
Genode::Mmio(_local_addr())
{ }
explicit Mmio(Device &device) : Mmio(device, Index { 0 }) { }
@ -101,11 +106,7 @@ class Platform::Device::Mmio : Range, Attached_dataspace, public Genode::Mmio
size_t size() const { return Range::size; }
template <typename T>
T *local_addr()
{
void *ptr = Attached_dataspace::local_addr<char>() + Range::start;
return reinterpret_cast<T *>(ptr);
}
T *local_addr() { return reinterpret_cast<T *>(_local_addr()); }
};