Consider byte offset in Attached_io_mem_dataspace

Ref #1764
This commit is contained in:
Norman Feske 2015-09-08 20:43:39 +02:00 committed by Christian Helmuth
parent ab79b0d5e0
commit 7920b57d34
4 changed files with 7 additions and 6 deletions

View File

@ -203,8 +203,7 @@ void *_ioremap(resource_size_t phys_addr, unsigned long size, int wc)
try {
Genode::Attached_io_mem_dataspace *ds = new(Genode::env()->heap())
Genode::Attached_io_mem_dataspace(phys_addr, size, !!wc);
/* map base + page offset */
return ds->local_addr<char>() + (phys_addr & (PAGE_SIZE - 1));
return ds->local_addr<void>();
} catch (...) {
panic("Failed to request I/O memory: [%zx,%lx)", phys_addr, phys_addr + size);
return 0;

View File

@ -55,7 +55,10 @@ class Genode::Attached_io_mem_dataspace
_mmio(base, size, write_combined),
_ds(_mmio.dataspace()),
_local_addr(env()->rm_session()->attach(_ds))
{ }
{
/* apply sub-page offset to virtual address */
_local_addr = (void *)((addr_t)_local_addr | (base & (addr_t)0xfff));
}
/**
* Destructor

View File

@ -50,7 +50,7 @@ class Genode::Attached_mmio : public Attached_io_mem_dataspace,
Attached_mmio(addr_t base, size_t size,
bool write_combined = false)
: Attached_io_mem_dataspace(base, size, write_combined),
Mmio((addr_t)local_addr<void>() | (base & 0xfff)) { }
Mmio((addr_t)local_addr<void>()) { }
};
#endif /* _INCLUDE__OS__ATTACHED_MMIO_H_ */

View File

@ -29,7 +29,6 @@
* The dataspace base address will correspond to 0x2000b000.
*/
enum { TIMER_MMIO_BASE = 0x2000b400,
TIMER_MMIO_OFFSET = 0x400,
TIMER_MMIO_SIZE = 0x100,
TIMER_CLOCK = 1984*1000 };
@ -42,7 +41,7 @@ struct Platform_timer_base
Platform_timer_base() :
Attached_io_mem_dataspace(TIMER_MMIO_BASE, TIMER_MMIO_SIZE),
Sp804_base((Genode::addr_t)local_addr<void>() + TIMER_MMIO_OFFSET)
Sp804_base((Genode::addr_t)local_addr<void>())
{ }
};