diff --git a/repos/base-fiasco/src/core/include/platform.h b/repos/base-fiasco/src/core/include/platform.h index 5f7796b5a2..a584fe7d8f 100644 --- a/repos/base-fiasco/src/core/include/platform.h +++ b/repos/base-fiasco/src/core/include/platform.h @@ -15,9 +15,9 @@ #ifndef _CORE__INCLUDE__PLATFORM_H_ #define _CORE__INCLUDE__PLATFORM_H_ -#include #include +#include "synced_range_allocator.h" #include "platform_generic.h" #include "platform_thread.h" #include "platform_pd.h" @@ -33,7 +33,7 @@ namespace Genode { /* * Shortcut for the type of allocator instances for physical resources */ - typedef Synchronized_range_allocator Phys_allocator; + typedef Synced_range_allocator Phys_allocator; char _core_label[1]; /* to satisfy _core_pd */ Platform_pd *_core_pd; /* core protection domain object */ diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc index 2636f12675..66652379ac 100644 --- a/repos/base-fiasco/src/core/platform.cc +++ b/repos/base-fiasco/src/core/platform.cc @@ -49,9 +49,9 @@ static const bool verbose_region_alloc = false; ** Core address space management ** ***********************************/ -static Synchronized_range_allocator &_core_address_ranges() +static Synced_range_allocator &_core_address_ranges() { - static Synchronized_range_allocator _core_address_ranges(0); + static Synced_range_allocator _core_address_ranges(nullptr); return _core_address_ranges; } @@ -457,7 +457,7 @@ void Platform::_setup_rom() Platform::Platform() : - _ram_alloc(0), _io_mem_alloc(core_mem_alloc()), + _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), _region_alloc(core_mem_alloc()) { @@ -475,13 +475,13 @@ Platform::Platform() : _setup_rom(); if (verbose) { - printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); - printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); + printf(":irq: "); _irq_alloc()->dump_addr_tree(); printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree(); + printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); } Fiasco::l4_threadid_t myself = Fiasco::l4_myself(); diff --git a/repos/base-foc/src/core/include/cap_id_alloc.h b/repos/base-foc/src/core/include/cap_id_alloc.h index d5e4e26721..b780b7cf40 100644 --- a/repos/base-foc/src/core/include/cap_id_alloc.h +++ b/repos/base-foc/src/core/include/cap_id_alloc.h @@ -18,7 +18,7 @@ #include #include #include -#include +#include namespace Genode { @@ -33,8 +33,8 @@ namespace Genode { CAP_ID_OFFSET = 1 << 2 }; - Synchronized_range_allocator _id_alloc; - Lock _lock; + Synced_range_allocator _id_alloc; + Lock _lock; public: diff --git a/repos/base-foc/src/core/include/platform.h b/repos/base-foc/src/core/include/platform.h index 8629234382..e00993f9f1 100644 --- a/repos/base-foc/src/core/include/platform.h +++ b/repos/base-foc/src/core/include/platform.h @@ -17,7 +17,7 @@ #define _CORE__INCLUDE__PLATFORM_H_ /* Genode includes */ -#include +#include #include /* Core includes */ @@ -51,7 +51,7 @@ namespace Genode { /* * Shortcut for the type of allocator instances for physical resources */ - typedef Synchronized_range_allocator Phys_allocator; + typedef Synced_range_allocator Phys_allocator; Platform_pd *_core_pd; /* core protection domain object */ Phys_allocator _ram_alloc; /* RAM allocator */ diff --git a/repos/base-foc/src/core/include/platform_pd.h b/repos/base-foc/src/core/include/platform_pd.h index b9a05da899..460b8411ca 100644 --- a/repos/base-foc/src/core/include/platform_pd.h +++ b/repos/base-foc/src/core/include/platform_pd.h @@ -21,7 +21,7 @@ /* Genode includes */ #include #include -#include +#include #include #include diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc index 4a562e2834..a37f4d7bd7 100644 --- a/repos/base-foc/src/core/platform.cc +++ b/repos/base-foc/src/core/platform.cc @@ -53,9 +53,9 @@ static const bool verbose_region_alloc = false; ** Core address space management ** ***********************************/ -static Synchronized_range_allocator &_core_address_ranges() +static Synced_range_allocator &_core_address_ranges() { - static Synchronized_range_allocator _core_address_ranges(0); + static Synced_range_allocator _core_address_ranges(nullptr); return _core_address_ranges; } @@ -465,7 +465,7 @@ void Platform::_setup_rom() Platform::Platform() : - _ram_alloc(0), _io_mem_alloc(core_mem_alloc()), + _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), _region_alloc(core_mem_alloc()), _cap_id_alloc(core_mem_alloc()), _sigma0(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_PAGER_CAP)) @@ -484,13 +484,13 @@ Platform::Platform() : _setup_rom(); if (verbose) { - printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); - printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); + printf(":irq: "); _irq_alloc()->dump_addr_tree(); printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree(); + printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); } Core_cap_index* pdi = diff --git a/repos/base-hw/src/core/include/platform.h b/repos/base-hw/src/core/include/platform.h index aeefd03688..55a206d6d1 100644 --- a/repos/base-hw/src/core/include/platform.h +++ b/repos/base-hw/src/core/include/platform.h @@ -16,7 +16,7 @@ #define _CORE__INCLUDE__PLATFORM_H_ /* Genode includes */ -#include +#include #include #include @@ -46,8 +46,6 @@ namespace Genode { { private: - typedef Core_mem_allocator::Phys_allocator Phys_allocator; - Core_mem_allocator _core_mem_alloc; /* core-accessible memory */ Phys_allocator _io_mem_alloc; /* MMIO allocator */ Phys_allocator _io_port_alloc; /* I/O port allocator */ diff --git a/repos/base-hw/src/core/include/platform_pd.h b/repos/base-hw/src/core/include/platform_pd.h index 43ea6d067b..1b0f175b8e 100644 --- a/repos/base-hw/src/core/include/platform_pd.h +++ b/repos/base-hw/src/core/include/platform_pd.h @@ -59,7 +59,7 @@ class Hw::Address_space : public Genode::Address_space private: friend class Genode::Platform; - friend class Genode::Core_mem_allocator::Mapped_mem_allocator; + friend class Genode::Mapped_mem_allocator; using Table_allocator = Translation_table_allocator_tpl; diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc index 90c8776139..9701534b49 100644 --- a/repos/base-hw/src/core/platform.cc +++ b/repos/base-hw/src/core/platform.cc @@ -159,23 +159,23 @@ Platform::Platform() if (VERBOSE) { printf("Core virtual memory allocator\n"); printf("---------------------\n"); - _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree(); + (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); printf("\n"); printf("RAM memory allocator\n"); printf("---------------------\n"); - _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree(); + (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); printf("\n"); printf("IO memory allocator\n"); printf("-------------------\n"); - _io_mem_alloc.raw()->dump_addr_tree(); + _io_mem_alloc()->dump_addr_tree(); printf("\n"); printf("IO port allocator\n"); printf("-------------------\n"); - _io_port_alloc.raw()->dump_addr_tree(); + _io_port_alloc()->dump_addr_tree(); printf("\n"); printf("IRQ allocator\n"); printf("-------------------\n"); - _irq_alloc.raw()->dump_addr_tree(); + _irq_alloc()->dump_addr_tree(); printf("\n"); printf("ROM filesystem\n"); printf("--------------\n"); @@ -217,12 +217,10 @@ bool Genode::unmap_local(addr_t virt_addr, size_t num_pages) } -bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, - addr_t phys_addr, - unsigned size) { +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, + unsigned size) { return ::map_local(phys_addr, virt_addr, size / get_page_size()); } -bool Core_mem_allocator::Mapped_mem_allocator::_unmap_local(addr_t virt_addr, - unsigned size) { +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, unsigned size) { return ::unmap_local(virt_addr, size / get_page_size()); } diff --git a/repos/base-linux/src/core/include/platform.h b/repos/base-linux/src/core/include/platform.h index 211f53658c..4dac77cd08 100644 --- a/repos/base-linux/src/core/include/platform.h +++ b/repos/base-linux/src/core/include/platform.h @@ -15,13 +15,13 @@ #ifndef _CORE__INCLUDE__LINUX__PLATFORM_H_ #define _CORE__INCLUDE__LINUX__PLATFORM_H_ -#include #include #include #include #include #include +#include namespace Genode { @@ -34,7 +34,7 @@ namespace Genode { /** * Allocator for core-internal meta data */ - Synchronized_range_allocator _core_mem_alloc; + Synced_range_allocator _core_mem_alloc; /** * Allocator for pseudo physical memory diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc index d73667e22a..66fa84c881 100644 --- a/repos/base-linux/src/core/platform.cc +++ b/repos/base-linux/src/core/platform.cc @@ -84,7 +84,7 @@ static void sigchld_handler(int signnum) Platform::Platform() -: _core_mem_alloc(0) +: _core_mem_alloc(nullptr) { /* catch control-c */ lx_sigaction(LX_SIGINT, sigint_handler); diff --git a/repos/base-nova/src/core/include/platform.h b/repos/base-nova/src/core/include/platform.h index a0bd2d7a90..5c121f7e3c 100644 --- a/repos/base-nova/src/core/include/platform.h +++ b/repos/base-nova/src/core/include/platform.h @@ -27,8 +27,6 @@ namespace Genode { { private: - typedef Core_mem_allocator::Phys_allocator Phys_allocator; - Core_mem_allocator _core_mem_alloc; /* core-accessible memory */ Phys_allocator _io_mem_alloc; /* MMIO allocator */ Phys_allocator _io_port_alloc; /* I/O port allocator */ diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc index c56a9add64..5a7662bdb1 100644 --- a/repos/base-nova/src/core/platform.cc +++ b/repos/base-nova/src/core/platform.cc @@ -620,9 +620,9 @@ Platform::Platform() : _gsi_base_sel = (hip->mem_desc_offset - hip->cpu_desc_offset) / hip->cpu_desc_size; if (verbose_boot_info) { - printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree(); - printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree(); - printf(":io_mem_alloc: "); _io_mem_alloc.raw()->dump_addr_tree(); + printf(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + printf(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + printf(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); } /* add capability selector ranges to map */ @@ -696,9 +696,8 @@ Platform::Platform() : ** Support for core memory management ** ****************************************/ -bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, - addr_t phys_addr, - unsigned size) +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, + unsigned size) { map_local((Utcb *)Thread_base::myself()->utcb(), phys_addr, virt_addr, size / get_page_size(), @@ -707,8 +706,7 @@ bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, } -bool Core_mem_allocator::Mapped_mem_allocator::_unmap_local(addr_t virt_addr, - unsigned size) +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, unsigned size) { unmap_local((Utcb *)Thread_base::myself()->utcb(), virt_addr, size / get_page_size()); diff --git a/repos/base-okl4/src/core/include/platform.h b/repos/base-okl4/src/core/include/platform.h index 9a6a5c2555..df33f06218 100644 --- a/repos/base-okl4/src/core/include/platform.h +++ b/repos/base-okl4/src/core/include/platform.h @@ -35,7 +35,6 @@ namespace Genode { { private: - using Phys_allocator = Core_mem_allocator::Phys_allocator; using Rom_slab = Tslab; using Thread_slab = Tslab; diff --git a/repos/base-okl4/src/core/platform.cc b/repos/base-okl4/src/core/platform.cc index a5f55c9bfe..3198f8c2c1 100644 --- a/repos/base-okl4/src/core/platform.cc +++ b/repos/base-okl4/src/core/platform.cc @@ -53,14 +53,12 @@ static int num_boot_module_objects; ** Support for core memory management ** ****************************************/ -bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, - addr_t phys_addr, - unsigned size) { +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, + unsigned size) { return map_local(phys_addr, virt_addr, size / get_page_size()); } -bool Core_mem_allocator::Mapped_mem_allocator::_unmap_local(addr_t virt_addr, - unsigned size) { +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, unsigned size) { return unmap_local(virt_addr, size / get_page_size()); } @@ -284,11 +282,11 @@ Platform::Platform() : * hold the meta data for the ROM modules as initialized by '_setup_rom'. */ if (verbose_boot_info) { - printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree(); - printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); - printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + printf(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); + printf(":irq: "); _irq_alloc()->dump_addr_tree(); printf(":rom_fs: "); _rom_fs.print_fs(); } diff --git a/repos/base-pistachio/src/core/include/platform.h b/repos/base-pistachio/src/core/include/platform.h index 10923a2be7..71e8ad2c49 100644 --- a/repos/base-pistachio/src/core/include/platform.h +++ b/repos/base-pistachio/src/core/include/platform.h @@ -15,9 +15,9 @@ #ifndef _CORE__INCLUDE__PLATFORM_H_ #define _CORE__INCLUDE__PLATFORM_H_ -#include #include +#include "synced_range_allocator.h" #include "platform_generic.h" #include "platform_thread.h" #include "platform_pd.h" @@ -33,7 +33,7 @@ namespace Genode { /* * Shortcut for the type of allocator instances for physical resources */ - typedef Synchronized_range_allocator Phys_allocator; + typedef Synced_range_allocator Phys_allocator; Phys_allocator _ram_alloc; /* RAM allocator */ Phys_allocator _io_mem_alloc; /* MMIO allocator */ diff --git a/repos/base-pistachio/src/core/platform.cc b/repos/base-pistachio/src/core/platform.cc index 9adb671a2f..43e06e1dae 100644 --- a/repos/base-pistachio/src/core/platform.cc +++ b/repos/base-pistachio/src/core/platform.cc @@ -50,9 +50,9 @@ static const bool verbose_region_alloc = false; ** Core address space management ** ***********************************/ -static Synchronized_range_allocator &_core_address_ranges() +static Synced_range_allocator &_core_address_ranges() { - static Synchronized_range_allocator _core_address_ranges(0); + static Synced_range_allocator _core_address_ranges(nullptr); return _core_address_ranges; } @@ -625,7 +625,7 @@ Platform_pd *Platform::core_pd() Platform::Platform() : - _ram_alloc(0), _io_mem_alloc(core_mem_alloc()), + _ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()), _region_alloc(core_mem_alloc()) { @@ -649,13 +649,13 @@ Platform::Platform() : * hold the meta data for the ROM modules as initialized by '_setup_rom'. */ if (verbose) { - printf(":ram_alloc: "); _ram_alloc.raw()->dump_addr_tree(); - printf(":region_alloc: "); _region_alloc.raw()->dump_addr_tree(); - printf(":io_mem: "); _io_mem_alloc.raw()->dump_addr_tree(); - printf(":io_port: "); _io_port_alloc.raw()->dump_addr_tree(); - printf(":irq: "); _irq_alloc.raw()->dump_addr_tree(); + printf(":ram_alloc: "); _ram_alloc()->dump_addr_tree(); + printf(":region_alloc: "); _region_alloc()->dump_addr_tree(); + printf(":io_mem: "); _io_mem_alloc()->dump_addr_tree(); + printf(":io_port: "); _io_port_alloc()->dump_addr_tree(); + printf(":irq: "); _irq_alloc()->dump_addr_tree(); printf(":rom_fs: "); _rom_fs.print_fs(); - printf(":core ranges: "); _core_address_ranges().raw()->dump_addr_tree(); + printf(":core ranges: "); _core_address_ranges()()->dump_addr_tree(); } /* diff --git a/repos/base-sel4/src/core/context_area.cc b/repos/base-sel4/src/core/context_area.cc index 7818412e9f..e69e92489c 100644 --- a/repos/base-sel4/src/core/context_area.cc +++ b/repos/base-sel4/src/core/context_area.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include /* local includes */ @@ -42,8 +43,8 @@ class Context_area_rm_session : public Rm_session { private: - using Ds_slab = Synchronized_allocator >; + using Ds_slab = Synced_allocator >; Ds_slab _ds_slab { platform()->core_mem_alloc() }; diff --git a/repos/base-sel4/src/core/include/platform.h b/repos/base-sel4/src/core/include/platform.h index 707c8a796a..863f6e74ca 100644 --- a/repos/base-sel4/src/core/include/platform.h +++ b/repos/base-sel4/src/core/include/platform.h @@ -30,9 +30,6 @@ class Genode::Platform : public Platform_generic { private: - typedef Core_mem_allocator::Phys_allocator Phys_allocator; - - Core_mem_allocator _core_mem_alloc; /* core-accessible memory */ Phys_allocator _io_mem_alloc; /* MMIO allocator */ Phys_allocator _io_port_alloc; /* I/O port allocator */ diff --git a/repos/base-sel4/src/core/platform.cc b/repos/base-sel4/src/core/platform.cc index c7c91a642f..caef7257f8 100644 --- a/repos/base-sel4/src/core/platform.cc +++ b/repos/base-sel4/src/core/platform.cc @@ -56,9 +56,8 @@ extern int _boot_modules_binaries_end; ** Support for core memory management ** ****************************************/ -bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, - addr_t phys_addr, - unsigned size) +bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr, + unsigned size) { size_t const num_pages = size / get_page_size(); @@ -68,8 +67,7 @@ bool Core_mem_allocator::Mapped_mem_allocator::_map_local(addr_t virt_addr, } -bool Core_mem_allocator::Mapped_mem_allocator::_unmap_local(addr_t virt_addr, - unsigned size) +bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, unsigned size) { return unmap_local(virt_addr, size / get_page_size()); } @@ -364,10 +362,10 @@ Platform::Platform() printf("VM area at [%08lx,%08lx)\n", _vm_base, _vm_base + _vm_size); if (verbose_boot_info) { - printf(":phys_alloc: "); _core_mem_alloc.phys_alloc()->raw()->dump_addr_tree(); - printf(":unused_phys_alloc:"); _unused_phys_alloc.raw()->dump_addr_tree(); - printf(":virt_alloc: "); _core_mem_alloc.virt_alloc()->raw()->dump_addr_tree(); - printf(":io_mem_alloc: "); _io_mem_alloc.raw()->dump_addr_tree(); + printf(":phys_alloc: "); (*_core_mem_alloc.phys_alloc())()->dump_addr_tree(); + printf(":unused_phys_alloc:"); _unused_phys_alloc()->dump_addr_tree(); + printf(":virt_alloc: "); (*_core_mem_alloc.virt_alloc())()->dump_addr_tree(); + printf(":io_mem_alloc: "); _io_mem_alloc()->dump_addr_tree(); } _init_rom_modules(); diff --git a/repos/base/include/base/sync_allocator.h b/repos/base/include/base/sync_allocator.h deleted file mode 100644 index 45573b9db3..0000000000 --- a/repos/base/include/base/sync_allocator.h +++ /dev/null @@ -1,261 +0,0 @@ -/* - * \brief Lock-guarded allocator interface - * \author Norman Feske - * \date 2008-08-05 - */ - -/* - * Copyright (C) 2008-2013 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU General Public License version 2. - */ - -#ifndef _INCLUDE__BASE__SYNC_ALLOCATOR_H_ -#define _INCLUDE__BASE__SYNC_ALLOCATOR_H_ - -#include -#include - -namespace Genode { - - template class Synchronized_allocator; - template class Synchronized_range_allocator; -} - - -/** - * Lock-guarded allocator - * - * This class wraps the complete 'Allocator' interface while - * preventing concurrent calls to the wrapped allocator implementation. - * - * \param ALLOCATOR_IMPL class implementing the 'Allocator' - * interface - */ -template -class Genode::Synchronized_allocator : public Allocator -{ - private: - - Lock _default_lock; - Lock *_lock; - ALLOCATOR_IMPL _alloc; - - public: - - /** - * Constructor - * - * This constructor uses an embedded lock for synchronizing the - * access to the allocator. - */ - Synchronized_allocator() - : _lock(&_default_lock) { } - - /** - * Constructor - * - * This constructor uses an embedded lock for synchronizing the - * access to the allocator. - */ - explicit Synchronized_allocator(Allocator *metadata_alloc) - : _lock(&_default_lock), _alloc(metadata_alloc) { } - - /** - * Return reference to wrapped (non-thread-safe) allocator - * - * This is needed, for example, if the wrapped allocator implements - * methods in addition to the Range_allocator interface. - */ - ALLOCATOR_IMPL *raw() { return &_alloc; } - - /************************* - ** Allocator interface ** - *************************/ - - bool alloc(size_t size, void **out_addr) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.alloc(size, out_addr); - } - - void free(void *addr, size_t size) override - { - Lock::Guard lock_guard(*_lock); - _alloc.free(addr, size); - } - - size_t consumed() const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.consumed(); - } - - size_t overhead(size_t size) const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.overhead(size); - } - - bool need_size_for_free() const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.need_size_for_free(); - } -}; - - -/** - * Lock-guarded range allocator - * - * This class wraps the complete 'Range_allocator' interface while - * preventing concurrent calls to the wrapped allocator implementation. - * - * \param ALLOCATOR_IMPL class implementing the 'Range_allocator' - * interface - */ -template -class Genode::Synchronized_range_allocator : public Range_allocator -{ - private: - - Lock _default_lock; - Lock *_lock; - ALLOCATOR_IMPL _alloc; - - public: - - /** - * Constructor - * - * This constructor uses an embedded lock for synchronizing the - * access to the allocator. - */ - Synchronized_range_allocator() - : _lock(&_default_lock) { } - - /** - * Constructor - * - * This constructor uses an embedded lock for synchronizing the - * access to the allocator. - */ - explicit Synchronized_range_allocator(Allocator *metadata_alloc) - : _lock(&_default_lock), _alloc(metadata_alloc) { } - - /** - * Constructor - * - * \param lock use specified lock rather then an embedded lock for - * synchronization - * - * This constructor is useful if multiple allocators must be - * synchronized with each other. In such as case, the shared - * lock can be passed to each 'Synchronized_range_allocator' - * instance. - */ - Synchronized_range_allocator(Lock *lock, Allocator *metadata_alloc) - : _lock(lock), _alloc(metadata_alloc) { } - - /** - * Return reference to wrapped (non-thread-safe) allocator - * - * This is needed, for example, if the wrapped allocator implements - * methods in addition to the Range_allocator interface. - * - * NOTE: Synchronize accesses to the raw allocator by facilitating - * the lock() method. - */ - ALLOCATOR_IMPL *raw() { return &_alloc; } - - /** - * Return reference to synchronization lock - */ - Lock *lock() { return _lock; } - - - /************************* - ** Allocator interface ** - *************************/ - - bool alloc(size_t size, void **out_addr) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.alloc(size, out_addr); - } - - void free(void *addr, size_t size) override - { - Lock::Guard lock_guard(*_lock); - _alloc.free(addr, size); - } - - size_t consumed() const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.consumed(); - } - - size_t overhead(size_t size) const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.overhead(size); - } - - bool need_size_for_free() const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.need_size_for_free(); - } - - - /******************************* - ** Range-allocator interface ** - *******************************/ - - int add_range(addr_t base, size_t size) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.add_range(base, size); - } - - int remove_range(addr_t base, size_t size) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.remove_range(base, size); - } - - Alloc_return alloc_aligned(size_t size, void **out_addr, int align = 0, - addr_t from = 0, addr_t to = ~0UL) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.alloc_aligned(size, out_addr, align, from, to); - } - - Alloc_return alloc_addr(size_t size, addr_t addr) override - { - Lock::Guard lock_guard(*_lock); - return _alloc.alloc_addr(size, addr); - } - - void free(void *addr) override - { - Lock::Guard lock_guard(*_lock); - _alloc.free(addr); - } - - size_t avail() const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.avail(); - } - - bool valid_addr(addr_t addr) const override - { - Lock::Guard lock_guard(*_lock); - return _alloc.valid_addr(addr); - } -}; - -#endif /* _INCLUDE__BASE__SYNC_ALLOCATOR_H_ */ diff --git a/repos/base/include/base/synced_allocator.h b/repos/base/include/base/synced_allocator.h new file mode 100644 index 0000000000..f8c97cbee0 --- /dev/null +++ b/repos/base/include/base/synced_allocator.h @@ -0,0 +1,75 @@ +/* + * \brief Lock-guarded allocator interface + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2008-08-05 + */ + +/* + * Copyright (C) 2008-2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__BASE__SYNCED_ALLOCATOR_H_ +#define _INCLUDE__BASE__SYNCED_ALLOCATOR_H_ + +#include +#include + +namespace Genode { + template class Synced_allocator; +} + + +/** + * Lock-guarded allocator + * + * This class wraps the complete 'Allocator' interface while + * preventing concurrent calls to the wrapped allocator implementation. + * + * \param ALLOC class implementing the 'Allocator' interface + */ +template +class Genode::Synced_allocator : public Allocator +{ + private: + + Lock _lock; + ALLOC _alloc; + Synced_interface _synced_object; + + public: + + using Guard = typename Synced_interface::Guard; + + template + Synced_allocator(ARGS &&... args) + : _alloc(args...), _synced_object(_lock, &_alloc) { } + + Guard operator () () { return _synced_object(); } + Guard operator () () const { return _synced_object(); } + + + /************************* + ** Allocator interface ** + *************************/ + + bool alloc(size_t size, void **out_addr) override { + return _synced_object()->alloc(size, out_addr); } + + void free(void *addr, size_t size) override { + _synced_object()->free(addr, size); } + + size_t consumed() const override { + return _synced_object()->consumed(); } + + size_t overhead(size_t size) const override { + return _synced_object()->overhead(size); } + + bool need_size_for_free() const override { + return _synced_object()->need_size_for_free(); } +}; + +#endif /* _INCLUDE__BASE__SYNCED_ALLOCATOR_H_ */ diff --git a/repos/os/include/os/synced_interface.h b/repos/base/include/base/synced_interface.h similarity index 86% rename from repos/os/include/os/synced_interface.h rename to repos/base/include/base/synced_interface.h index cb48e99693..9554a408bd 100644 --- a/repos/os/include/os/synced_interface.h +++ b/repos/base/include/base/synced_interface.h @@ -4,8 +4,8 @@ * \date 2013-05-16 */ -#ifndef _INCLUDE__OS__SYNCED_INTERFACE_H_ -#define _INCLUDE__OS__SYNCED_INTERFACE_H_ +#ifndef _INCLUDE__BASE__SYNCED_INTERFACE_H_ +#define _INCLUDE__BASE__SYNCED_INTERFACE_H_ /* Genode includes */ #include @@ -67,6 +67,11 @@ class Genode::Synced_interface { return Guard(_lock, _interface); } + + Guard operator () () const + { + return Guard(_lock, _interface); + } }; -#endif /* _INCLUDE__OS__SYNCED_INTERFACE_H_ */ +#endif /* _INCLUDE__BASE__SYNCED_INTERFACE_H_ */ diff --git a/repos/base/src/core/context_area.cc b/repos/base/src/core/context_area.cc index e9b6dcffd2..3c9a30e2bf 100644 --- a/repos/base/src/core/context_area.cc +++ b/repos/base/src/core/context_area.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include /* local includes */ @@ -42,8 +43,8 @@ class Context_area_rm_session : public Rm_session { private: - using Ds_slab = Synchronized_allocator >; + using Ds_slab = Synced_allocator >; Ds_slab _ds_slab { platform()->core_mem_alloc() }; diff --git a/repos/base/src/core/core_mem_alloc.cc b/repos/base/src/core/core_mem_alloc.cc index 70b2d6476c..8d47bf9aad 100644 --- a/repos/base/src/core/core_mem_alloc.cc +++ b/repos/base/src/core/core_mem_alloc.cc @@ -24,7 +24,7 @@ using namespace Genode; static const bool verbose_core_mem_alloc = false; -void * Core_mem_allocator::Mapped_avl_allocator::map_addr(void * addr) +void * Mapped_avl_allocator::map_addr(void * addr) { Block *b = static_cast(_find_by_address((addr_t)addr)); @@ -36,7 +36,7 @@ void * Core_mem_allocator::Mapped_avl_allocator::map_addr(void * addr) Range_allocator::Alloc_return -Core_mem_allocator::Mapped_mem_allocator::alloc_aligned(size_t size, void **out_addr, int align, addr_t from, addr_t to) +Mapped_mem_allocator::alloc_aligned(size_t size, void **out_addr, int align, addr_t from, addr_t to) { size_t page_rounded_size = (size + get_page_size() - 1) & get_page_mask(); void *phys_addr = 0; @@ -77,7 +77,7 @@ Core_mem_allocator::Mapped_mem_allocator::alloc_aligned(size_t size, void **out_ } -void Core_mem_allocator::Mapped_mem_allocator::free(void *addr, size_t size) +void Mapped_mem_allocator::free(void *addr, size_t size) { using Block = Mapped_avl_allocator::Block; Block *b = static_cast(_virt_alloc->_find_by_address((addr_t)addr)); @@ -89,7 +89,7 @@ void Core_mem_allocator::Mapped_mem_allocator::free(void *addr, size_t size) } -void Core_mem_allocator::Mapped_mem_allocator::free(void *addr) +void Mapped_mem_allocator::free(void *addr) { PWRN("Not implemented!"); } diff --git a/repos/base/src/core/include/core_mem_alloc.h b/repos/base/src/core/include/core_mem_alloc.h index e13a138e4a..ceedc335aa 100644 --- a/repos/base/src/core/include/core_mem_alloc.h +++ b/repos/base/src/core/include/core_mem_alloc.h @@ -16,13 +16,22 @@ #define _CORE__INCLUDE__CORE_MEM_ALLOC_H_ #include -#include #include +#include #include namespace Genode { class Core_mem_translator; class Core_mem_allocator; + + struct Metadata; + class Mapped_mem_allocator; + class Mapped_avl_allocator; + + using Page_allocator = Allocator_avl_tpl; + using Phys_allocator = Synced_range_allocator; + using Synced_mapped_allocator = + Synced_range_allocator; }; @@ -50,6 +59,131 @@ class Genode::Core_mem_translator : public Genode::Range_allocator }; +/** + * Metadata for allocator blocks that stores a related address + */ +struct Genode::Metadata { void * map_addr; }; + + +/** + * Page-size granular allocator that links ranges to related ones. + */ +class Genode::Mapped_avl_allocator +: public Genode::Allocator_avl_tpl +{ + friend class Mapped_mem_allocator; + + public: + + /** + * Constructor + * + * \param md_alloc metadata allocator + */ + explicit Mapped_avl_allocator(Allocator *md_alloc) + : Allocator_avl_tpl(md_alloc) {} + + /** + * Returns related address for allocated range + * + * \param addr address within allocated range + */ + void * map_addr(void * addr); +}; + + +/** + * Unsynchronized allocator for core-mapped memory + * + * This is an allocator of core-mapped memory. It is meant to be used as + * meta-data allocator for the other allocators and as back end for core's + * synchronized memory allocator. + */ +class Genode::Mapped_mem_allocator : public Genode::Core_mem_translator +{ + private: + + Mapped_avl_allocator *_phys_alloc; + Mapped_avl_allocator *_virt_alloc; + + public: + + /** + * Constructor + * + * \param phys_alloc allocator of physical memory + * \param virt_alloc allocator of core-local virtual memory ranges + */ + + Mapped_mem_allocator(Synced_mapped_allocator &phys_alloc, + Synced_mapped_allocator &virt_alloc) + : _phys_alloc(&phys_alloc._alloc), _virt_alloc(&virt_alloc._alloc) { } + + /** + * Establish mapping between physical and virtual address range + * + * Note: has to be implemented by platform specific code + * + * \param virt_addr start address of virtual range + * \param phys_addr start address of physical range + * \param size size of range + */ + bool _map_local(addr_t virt_addr, addr_t phys_addr, unsigned size); + + /** + * Destroy mapping between physical and virtual address range + * + * Note: has to be implemented by platform specific code + * + * \param virt_addr start address of virtual range + * \param size size of range + */ + bool _unmap_local(addr_t virt_addr, unsigned size); + + + /*********************************** + ** Core_mem_translator interface ** + ***********************************/ + + void * phys_addr(void * addr) { + return _virt_alloc->map_addr(addr); } + + void * virt_addr(void * addr) { + return _phys_alloc->map_addr(addr); } + + + /******************************* + ** Range allocator interface ** + *******************************/ + + int add_range(addr_t base, size_t size) override { return -1; } + int remove_range(addr_t base, size_t size) override { return -1; } + Alloc_return alloc_aligned(size_t size, void **out_addr, + int align = 0, addr_t from = 0, + addr_t to = ~0UL) override; + Alloc_return alloc_addr(size_t size, addr_t addr) override { + return Alloc_return::RANGE_CONFLICT; } + void free(void *addr) override; + size_t avail() const override { return _phys_alloc->avail(); } + bool valid_addr(addr_t addr) const override { + return _virt_alloc->valid_addr(addr); } + + + /************************* + ** Allocator interface ** + *************************/ + + bool alloc(size_t size, void **out_addr) override { + return alloc_aligned(size, out_addr).is_ok(); } + void free(void *addr, size_t) override; + size_t consumed() const override { return _phys_alloc->consumed(); } + size_t overhead(size_t size) const override { + return _phys_alloc->overhead(size); } + bool need_size_for_free() const override { + return _phys_alloc->need_size_for_free(); } +}; + + /** * Allocators for physical memory, core's virtual address space, * and core-local memory. The interface of this class is thread safe. @@ -60,135 +194,6 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator { public: - using Page_allocator = Allocator_avl_tpl; - using Phys_allocator = Synchronized_range_allocator; - - /** - * Metadata for allocator blocks that stores a related address - */ - struct Metadata { void * map_addr; }; - - class Mapped_mem_allocator; - - /** - * Page-size granular allocator that links ranges to related ones. - */ - class Mapped_avl_allocator - : public Allocator_avl_tpl - { - friend class Mapped_mem_allocator; - - public: - - /** - * Constructor - * - * \param md_alloc metadata allocator - */ - explicit Mapped_avl_allocator(Allocator *md_alloc) - : Allocator_avl_tpl(md_alloc) {} - - /** - * Returns related address for allocated range - * - * \param addr address within allocated range - */ - void * map_addr(void * addr); - }; - - using Synchronized_mapped_allocator = - Synchronized_range_allocator; - - /** - * Unsynchronized allocator for core-mapped memory - * - * This is an allocator of core-mapped memory. It is meant to be used as - * meta-data allocator for the other allocators and as back end for core's - * synchronized memory allocator. - */ - class Mapped_mem_allocator : public Genode::Core_mem_translator - { - private: - - Mapped_avl_allocator *_phys_alloc; - Mapped_avl_allocator *_virt_alloc; - - public: - - /** - * Constructor - * - * \param phys_alloc allocator of physical memory - * \param virt_alloc allocator of core-local virtual memory ranges - */ - - Mapped_mem_allocator(Mapped_avl_allocator *phys_alloc, - Mapped_avl_allocator *virt_alloc) - : _phys_alloc(phys_alloc), _virt_alloc(virt_alloc) { } - - /** - * Establish mapping between physical and virtual address range - * - * Note: has to be implemented by platform specific code - * - * \param virt_addr start address of virtual range - * \param phys_addr start address of physical range - * \param size size of range - */ - bool _map_local(addr_t virt_addr, addr_t phys_addr, unsigned size); - - /** - * Destroy mapping between physical and virtual address range - * - * Note: has to be implemented by platform specific code - * - * \param virt_addr start address of virtual range - * \param size size of range - */ - bool _unmap_local(addr_t virt_addr, unsigned size); - - - /*********************************** - ** Core_mem_translator interface ** - ***********************************/ - - void * phys_addr(void * addr) { - return _virt_alloc->map_addr(addr); } - - void * virt_addr(void * addr) { - return _phys_alloc->map_addr(addr); } - - - /******************************* - ** Range allocator interface ** - *******************************/ - - int add_range(addr_t base, size_t size) override { return -1; } - int remove_range(addr_t base, size_t size) override { return -1; } - Alloc_return alloc_aligned(size_t size, void **out_addr, - int align = 0, addr_t from = 0, - addr_t to = ~0UL) override; - Alloc_return alloc_addr(size_t size, addr_t addr) override { - return Alloc_return::RANGE_CONFLICT; } - void free(void *addr) override; - size_t avail() const override { return _phys_alloc->avail(); } - bool valid_addr(addr_t addr) const override { - return _virt_alloc->valid_addr(addr); } - - - /************************* - ** Allocator interface ** - *************************/ - - bool alloc(size_t size, void **out_addr) override { - return alloc_aligned(size, out_addr).is_ok(); } - void free(void *addr, size_t) override; - size_t consumed() const override { return _phys_alloc->consumed(); } - size_t overhead(size_t size) const override { - return _phys_alloc->overhead(size); } - bool need_size_for_free() const override { - return _phys_alloc->need_size_for_free(); } - }; protected: @@ -204,7 +209,7 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator * This allocator must only be used to allocate memory * ranges at page granularity. */ - Synchronized_mapped_allocator _phys_alloc; + Synced_mapped_allocator _phys_alloc; /** * Synchronized allocator of core's virtual memory ranges @@ -212,7 +217,7 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator * This allocator must only be used to allocate memory * ranges at page granularity. */ - Synchronized_mapped_allocator _virt_alloc; + Synced_mapped_allocator _virt_alloc; /** * Unsynchronized core-mapped memory allocator @@ -233,24 +238,19 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator * Constructor */ Core_mem_allocator() - : _phys_alloc(&_lock, &_mem_alloc), - _virt_alloc(&_lock, &_mem_alloc), - _mem_alloc(_phys_alloc.raw(), _virt_alloc.raw()) { } + : _phys_alloc(_lock, &_mem_alloc), + _virt_alloc(_lock, &_mem_alloc), + _mem_alloc(_phys_alloc, _virt_alloc) { } /** * Access physical-memory allocator */ - Synchronized_mapped_allocator *phys_alloc() { return &_phys_alloc; } + Synced_mapped_allocator *phys_alloc() { return &_phys_alloc; } /** * Access core's virtual-memory allocator */ - Synchronized_mapped_allocator *virt_alloc() { return &_virt_alloc; } - - /** - * Access core's local memory allocator unsynchronized - */ - Mapped_mem_allocator *raw() { return &_mem_alloc; } + Synced_mapped_allocator *virt_alloc() { return &_virt_alloc; } /*********************************** @@ -259,14 +259,12 @@ class Genode::Core_mem_allocator : public Genode::Core_mem_translator void * phys_addr(void * addr) { - Lock::Guard lock_guard(_lock); - return _virt_alloc.raw()->map_addr(addr); + return _virt_alloc()->map_addr(addr); } void * virt_addr(void * addr) { - Lock::Guard lock_guard(_lock); - return _phys_alloc.raw()->map_addr(addr); + return _phys_alloc()->map_addr(addr); } diff --git a/repos/base/src/core/include/ram_session_component.h b/repos/base/src/core/include/ram_session_component.h index 0c6c031a6f..ef250159ce 100644 --- a/repos/base/src/core/include/ram_session_component.h +++ b/repos/base/src/core/include/ram_session_component.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include /* core includes */ #include @@ -40,8 +40,7 @@ namespace Genode { static constexpr size_t SBS = get_page_size(); - using Ds_slab = Synchronized_allocator >; + using Ds_slab = Synced_allocator >; Rpc_entrypoint *_ds_ep; Rpc_entrypoint *_ram_session_ep; diff --git a/repos/base/src/core/include/rm_session_component.h b/repos/base/src/core/include/rm_session_component.h index 7fea59796a..3c919127f4 100644 --- a/repos/base/src/core/include/rm_session_component.h +++ b/repos/base/src/core/include/rm_session_component.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -263,7 +263,7 @@ namespace Genode { }; - typedef Synchronized_allocator > Client_slab_alloc; + typedef Synced_allocator > Client_slab_alloc; Client_slab_alloc _client_slab; /* backing store for client structures, synchronized */ Tslab _ref_slab; /* backing store for diff --git a/repos/base/src/core/include/synced_range_allocator.h b/repos/base/src/core/include/synced_range_allocator.h new file mode 100644 index 0000000000..9a628cbd65 --- /dev/null +++ b/repos/base/src/core/include/synced_range_allocator.h @@ -0,0 +1,111 @@ +/* + * \brief Lock-guarded allocator interface + * \author Norman Feske + * \author Stefan Kalkowski + * \date 2008-08-05 + */ + +/* + * Copyright (C) 2008-2013 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _SRC__CORE__INCLUDE__SYNCED_RANGE_ALLOCATOR_H_ +#define _SRC__CORE__INCLUDE__SYNCED_RANGE_ALLOCATOR_H_ + +#include +#include + +namespace Genode { + class Mapped_mem_allocator; + template class Synced_range_allocator; +} + + +/** + * Lock-guarded range allocator + * + * This class wraps the complete 'Range_allocator' interface while + * preventing concurrent calls to the wrapped allocator implementation. + * + * \param ALLOC class implementing the 'Range_allocator' interface + */ +template +class Genode::Synced_range_allocator : public Range_allocator +{ + private: + + friend class Mapped_mem_allocator; + + Lock _default_lock; + Lock &_lock; + ALLOC _alloc; + Synced_interface _synced_object; + + public: + + using Guard = typename Synced_interface::Guard; + + template + Synced_range_allocator(Lock &lock, ARGS &&... args) + : _lock(lock), _alloc(args...), _synced_object(_lock, &_alloc) { } + + template + Synced_range_allocator(ARGS &&... args) + : _lock(_default_lock), _alloc(args...), + _synced_object(_lock, &_alloc) { } + + Guard operator () () { return _synced_object(); } + Guard operator () () const { return _synced_object(); } + + + /************************* + ** Allocator interface ** + *************************/ + + bool alloc(size_t size, void **out_addr) override { + return _synced_object()->alloc(size, out_addr); } + + void free(void *addr, size_t size) override { + _synced_object()->free(addr, size); } + + size_t consumed() const override { + return _synced_object()->consumed(); } + + size_t overhead(size_t size) const override { + return _synced_object()->overhead(size); } + + bool need_size_for_free() const override { + return _synced_object()->need_size_for_free(); } + + + /******************************* + ** Range-allocator interface ** + *******************************/ + + int add_range(addr_t base, size_t size) override { + return _synced_object()->add_range(base, size); } + + int remove_range(addr_t base, size_t size) override { + return _synced_object()->remove_range(base, size); } + + Alloc_return alloc_aligned(size_t size, void **out_addr, int align = 0, + addr_t from = 0, addr_t to = ~0UL) override { + return _synced_object()->alloc_aligned(size, out_addr, align, from, to); } + + Alloc_return alloc_addr(size_t size, addr_t addr) override { + return _synced_object()->alloc_addr(size, addr); } + + void free(void *addr) override { + _synced_object()->free(addr); } + + size_t avail() const override { + return _synced_object()->avail(); } + + bool valid_addr(addr_t addr) const override { + return _synced_object()->valid_addr(addr); } +}; + +#endif /* _SRC__CORE__INCLUDE__SYNCED_RANGE_ALLOCATOR_H_ */ diff --git a/repos/base/src/core/ram_session_component.cc b/repos/base/src/core/ram_session_component.cc index db6b9ce9d8..1ae4effee2 100644 --- a/repos/base/src/core/ram_session_component.cc +++ b/repos/base/src/core/ram_session_component.cc @@ -291,7 +291,7 @@ Ram_session_component::Ram_session_component(Rpc_entrypoint *ds_ep, Ram_session_component::~Ram_session_component() { /* destroy all dataspaces */ - for (Dataspace_component *ds; (ds = _ds_slab.raw()->first_object()); _free_ds(ds)); + for (Dataspace_component *ds; (ds = _ds_slab()->first_object()); _free_ds(ds)); if (_payload != 0) PWRN("Remaining payload of %zu in ram session to destroy", _payload); diff --git a/repos/base/src/core/rm_session_component.cc b/repos/base/src/core/rm_session_component.cc index 2040af06ef..853a253ad8 100644 --- a/repos/base/src/core/rm_session_component.cc +++ b/repos/base/src/core/rm_session_component.cc @@ -754,7 +754,7 @@ Rm_session_component::~Rm_session_component() faulter->dissolve_from_faulting_rm_session(this); /* remove all clients, invalidate rm_client pointers in cpu_thread objects */ - while (Rm_client *cl = _client_slab.raw()->first_object()) { + while (Rm_client *cl = _client_slab()->first_object()) { cl->dissolve_from_faulting_rm_session(this); Thread_capability thread_cap = cl->thread_cap(); diff --git a/repos/os/src/test/synced_interface/main.cc b/repos/os/src/test/synced_interface/main.cc index bef7987323..8238781da6 100644 --- a/repos/os/src/test/synced_interface/main.cc +++ b/repos/os/src/test/synced_interface/main.cc @@ -12,7 +12,7 @@ */ /* Genode includes */ -#include +#include #include diff --git a/repos/ports/src/app/seoul/disk.h b/repos/ports/src/app/seoul/disk.h index 158f08b070..e66468e0d5 100644 --- a/repos/ports/src/app/seoul/disk.h +++ b/repos/ports/src/app/seoul/disk.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include /* local includes */ #include "synced_motherboard.h" @@ -100,17 +100,17 @@ class Vancouver_disk : public Genode::Thread<8192>, public StaticReceiver MessageDisk_Slab; - typedef Genode::Synchronized_allocator MessageDisk_Slab_Sync; + typedef Genode::Synced_allocator MessageDisk_Slab_Sync; typedef Genode::Tslab DmaDesc_Slab; - typedef Genode::Synchronized_allocator DmaDesc_Slab_Sync; + typedef Genode::Synced_allocator DmaDesc_Slab_Sync; MessageDisk_Slab_Sync _tslab_msg; DmaDesc_Slab_Sync _tslab_dma; /* Structure to find back the MessageDisk object out of a Block Ack */ typedef Genode::Tslab Avl_entry_slab; - typedef Genode::Synchronized_allocator Avl_entry_slab_sync; + typedef Genode::Synced_allocator Avl_entry_slab_sync; Avl_entry_slab_sync _tslab_avl; diff --git a/repos/ports/src/app/seoul/main.cc b/repos/ports/src/app/seoul/main.cc index 19116a82c3..f90a5c10b4 100644 --- a/repos/ports/src/app/seoul/main.cc +++ b/repos/ports/src/app/seoul/main.cc @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include diff --git a/repos/ports/src/app/seoul/synced_motherboard.h b/repos/ports/src/app/seoul/synced_motherboard.h index c870ec397e..63ee62d02e 100644 --- a/repos/ports/src/app/seoul/synced_motherboard.h +++ b/repos/ports/src/app/seoul/synced_motherboard.h @@ -15,7 +15,7 @@ #define _SYNCED_MOTHERBOARD_H_ #include -#include +#include typedef Genode::Synced_interface Synced_motherboard;