From e744c76bf261e64f12501d1cdb6dcb4901e111bf Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 6 Mar 2017 13:56:33 +0100 Subject: [PATCH] mmio: make base address member private Ref #2196 --- .../src/bootstrap/spec/x86_64/platform.cc | 2 +- .../src/core/include/spec/panda/board.h | 2 +- .../src/core/include/spec/x86_64/multiboot.h | 2 +- repos/base/include/util/mmio.h | 18 ++++++------------ repos/os/src/drivers/acpi/acpi.cc | 10 +++++----- repos/os/src/drivers/ahci/ahci.h | 4 ++-- .../src/drivers/framebuffer/spec/imx53/ipu.h | 4 ++-- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc b/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc index b81ac5aa8..757114260 100644 --- a/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc +++ b/repos/base-hw/src/bootstrap/spec/x86_64/platform.cc @@ -37,7 +37,7 @@ Platform::Board::Board() for (unsigned i = 0; true; i++) { Mmap v(Multiboot_info(__initial_bx).phys_ram_mmap_base(i)); - if (!v.base) break; + if (!v.base()) break; Mmap::Addr::access_t base = v.read(); Mmap::Length::access_t size = v.read(); diff --git a/repos/base-hw/src/core/include/spec/panda/board.h b/repos/base-hw/src/core/include/spec/panda/board.h index 10d4f2b82..280cdd5af 100644 --- a/repos/base-hw/src/core/include/spec/panda/board.h +++ b/repos/base-hw/src/core/include/spec/panda/board.h @@ -114,7 +114,7 @@ class Genode::Board : public Cortex_a9::Board private: - L2_cache _l2_cache { Base::l2_cache().base }; + L2_cache _l2_cache { Base::l2_cache().base() }; }; #endif /* _CORE__INCLUDE__SPEC__PANDA__BOARD_H_ */ diff --git a/repos/base-hw/src/core/include/spec/x86_64/multiboot.h b/repos/base-hw/src/core/include/spec/x86_64/multiboot.h index 7e6f94928..6ee665fe6 100644 --- a/repos/base-hw/src/core/include/spec/x86_64/multiboot.h +++ b/repos/base-hw/src/core/include/spec/x86_64/multiboot.h @@ -62,7 +62,7 @@ class Genode::Multiboot_info : Mmio enum { MMAP_SIZE_SIZE_OF = 4, MMAP_SIZE_OF = 4 + 8 + 1 }; if (solely_within_4k_base && - (mmap + MMAP_SIZE_OF >= Genode::align_addr(base + 1, 12))) + (mmap + MMAP_SIZE_OF >= Genode::align_addr(base() + 1, 12))) return 0; Mmap r(mmap); diff --git a/repos/base/include/util/mmio.h b/repos/base/include/util/mmio.h index 42009e84e..58301b6aa 100644 --- a/repos/base/include/util/mmio.h +++ b/repos/base/include/util/mmio.h @@ -30,17 +30,9 @@ class Genode::Mmio_plain_access { friend Register_set_plain_access; - public: - - /** - * FIXME We keep this public only to stay interface compatible - * but the value should be accessible only through an - * accessor. - */ - addr_t const base; - private: + addr_t const _base; /** * Write '_ACCESS_T' typed 'value' to MMIO base + 'offset' @@ -48,7 +40,7 @@ class Genode::Mmio_plain_access template inline void _write(off_t const offset, ACCESS_T const value) { - addr_t const dst = base + offset; + addr_t const dst = _base + offset; *(ACCESS_T volatile *)dst = value; } @@ -58,7 +50,7 @@ class Genode::Mmio_plain_access template inline ACCESS_T _read(off_t const &offset) const { - addr_t const dst = base + offset; + addr_t const dst = _base + offset; ACCESS_T const value = *(ACCESS_T volatile *)dst; return value; } @@ -70,7 +62,9 @@ class Genode::Mmio_plain_access * * \param base base address of targeted MMIO region */ - Mmio_plain_access(addr_t const base) : base(base) { } + Mmio_plain_access(addr_t const base) : _base(base) { } + + addr_t base() const { return _base; } }; diff --git a/repos/os/src/drivers/acpi/acpi.cc b/repos/os/src/drivers/acpi/acpi.cc index 87a6a7d8c..ed70a5ad8 100644 --- a/repos/os/src/drivers/acpi/acpi.cc +++ b/repos/os/src/drivers/acpi/acpi.cc @@ -133,7 +133,7 @@ struct Dmar_struct_header : Generic func(dmar); - addr = dmar.base + dmar.read(); + addr = dmar.base() + dmar.read(); } while (addr < dmar_entry_end()); } @@ -178,14 +178,14 @@ struct Dmar_rmrr : Genode::Mmio template void apply(FUNC const &func = [] () { } ) { - addr_t addr = base + 24; + addr_t addr = base() + 24; do { Device_scope scope(addr); func(scope); - addr = scope.base + scope.read(); - } while (addr < base + read()); + addr = scope.base() + scope.read(); + } while (addr < base() + read()); } }; @@ -1349,7 +1349,7 @@ void Acpi::generate_report(Genode::Env &env, Genode::Allocator &alloc) if (dmar.read() != Dmar_common::Type::RMRR) return; - Dmar_rmrr rmrr(dmar.base); + Dmar_rmrr rmrr(dmar.base()); xml.node("rmrr", [&] () { attribute_hex(xml, "start", rmrr.read()); diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index e007ea0ce..cd516336b 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -202,7 +202,7 @@ struct Command_fis : Genode::Mmio } static constexpr Genode::size_t size() { return 0x14; } - void clear() { Genode::memset((void *)base, 0, size()); } + void clear() { Genode::memset((void *)base(), 0, size()); } /************************ @@ -402,7 +402,7 @@ struct Port_base : Genode::Mmio static constexpr Genode::size_t size() { return 0x80; } Port_base(unsigned number, Hba &hba) - : Mmio(hba.base + offset() + (number * size())) { } + : Mmio(hba.base() + offset() + (number * size())) { } }; diff --git a/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h b/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h index 2a53790da..e8d0c6b68 100644 --- a/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h +++ b/repos/os/src/drivers/framebuffer/spec/imx53/ipu.h @@ -215,7 +215,7 @@ class Ipu : Genode::Mmio Genode::uint16_t width, Genode::uint16_t height, Genode::uint32_t stride, Genode::addr_t phys_base) { - void *dst =(void*)(base + Cp_mem::OFFSET + channel*sizeof(Cp_mem)); + void *dst =(void*)(base() + Cp_mem::OFFSET + channel*sizeof(Cp_mem)); Cp_mem cpmem; cpmem.fw = width - 1; @@ -529,7 +529,7 @@ class Ipu : Genode::Mmio void overlay(Genode::addr_t phys_base, int x, int y, int alpha) { volatile Genode::uint32_t *ptr = (volatile Genode::uint32_t*) - (base + Cp_mem::OFFSET + CHAN_DP_PRIMARY_AUXI*sizeof(Cp_mem)); + (base() + Cp_mem::OFFSET + CHAN_DP_PRIMARY_AUXI*sizeof(Cp_mem)); ptr[8] = (((phys_base >> 3) & 0b111) << 29) | (phys_base >> 3); ptr[9] = (phys_base >> 6);