mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
parent
6780cf0790
commit
9f099bd61c
@ -175,7 +175,7 @@ Platform::Platform()
|
||||
using namespace Genode;
|
||||
|
||||
/* prepare the ram allocator */
|
||||
board.early_ram_regions.for_each([this] (Memory_region const & region) {
|
||||
board.early_ram_regions.for_each([this] (unsigned, Memory_region const & region) {
|
||||
ram_alloc.add(region); });
|
||||
ram_alloc.remove(bootstrap_region);
|
||||
|
||||
@ -207,6 +207,6 @@ Platform::Platform()
|
||||
/* add all left RAM to bootinfo */
|
||||
ram_alloc.for_each_free_region([&] (Memory_region const & r) {
|
||||
bootinfo.ram_regions.add(r); });
|
||||
board.late_ram_regions.for_each([&] (Memory_region const & r) {
|
||||
board.late_ram_regions.for_each([&] (unsigned, Memory_region const & r) {
|
||||
bootinfo.ram_regions.add(r); });
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ void Platform::_init_io_mem_alloc()
|
||||
{
|
||||
/* add entire adress space minus the RAM memory regions */
|
||||
_io_mem_alloc.add_range(0, ~0x0UL);
|
||||
_boot_info().ram_regions.for_each([this] (Hw::Memory_region const &r) {
|
||||
_boot_info().ram_regions.for_each([this] (unsigned, Hw::Memory_region const &r) {
|
||||
_io_mem_alloc.remove_range(r.base, r.size); });
|
||||
};
|
||||
|
||||
@ -82,7 +82,7 @@ Hw::Memory_region_array const & Platform::_core_virt_regions()
|
||||
addr_t Platform::core_phys_addr(addr_t virt)
|
||||
{
|
||||
addr_t ret = 0;
|
||||
_boot_info().elf_mappings.for_each([&] (Hw::Mapping const & m)
|
||||
_boot_info().elf_mappings.for_each([&] (unsigned, Hw::Mapping const & m)
|
||||
{
|
||||
if (virt >= m.virt() && virt < (m.virt() + m.size()))
|
||||
ret = (virt - m.virt()) + m.phys();
|
||||
@ -165,11 +165,11 @@ Platform::Platform()
|
||||
|
||||
_core_mem_alloc.virt_alloc().add_range(Hw::Mm::core_heap().base,
|
||||
Hw::Mm::core_heap().size);
|
||||
_core_virt_regions().for_each([this] (Hw::Memory_region const & r) {
|
||||
_core_virt_regions().for_each([this] (unsigned, Hw::Memory_region const & r) {
|
||||
_core_mem_alloc.virt_alloc().remove_range(r.base, r.size); });
|
||||
_boot_info().elf_mappings.for_each([this] (Hw::Mapping const & m) {
|
||||
_boot_info().elf_mappings.for_each([this] (unsigned, Hw::Mapping const & m) {
|
||||
_core_mem_alloc.virt_alloc().remove_range(m.virt(), m.size()); });
|
||||
_boot_info().ram_regions.for_each([this] (Hw::Memory_region const & region) {
|
||||
_boot_info().ram_regions.for_each([this] (unsigned, Hw::Memory_region const & region) {
|
||||
_core_mem_alloc.phys_alloc().add_range(region.base, region.size); });
|
||||
|
||||
_init_io_port_alloc();
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* \brief Array class with static size
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2016-09-30
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _SRC__LIB__HW__ARRAY_H_
|
||||
#define _SRC__LIB__HW__ARRAY_H_
|
||||
|
||||
#include <base/log.h>
|
||||
|
||||
namespace Hw { template <typename, unsigned> class Array; }
|
||||
|
||||
|
||||
template <typename T, unsigned MAX>
|
||||
class Hw::Array
|
||||
{
|
||||
private:
|
||||
|
||||
unsigned _count = 0;
|
||||
T _objs[MAX];
|
||||
|
||||
void _init(unsigned i, T obj) { _objs[i] = obj; }
|
||||
|
||||
template <typename ... TAIL>
|
||||
void _init(unsigned i, T obj, TAIL ... tail)
|
||||
{
|
||||
_objs[i] = obj;
|
||||
_init(i+1, tail...);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Array() {}
|
||||
|
||||
template<typename ... ARGS>
|
||||
Array(ARGS ... args) : _count(sizeof...(ARGS))
|
||||
{
|
||||
static_assert(sizeof...(ARGS) <= MAX, "Array too small!");
|
||||
_init(0, args...);
|
||||
}
|
||||
|
||||
void add(T const & obj)
|
||||
{
|
||||
if (_count == MAX) Genode::error("Array too small!");
|
||||
else _objs[_count++] = obj;
|
||||
}
|
||||
|
||||
template <typename FUNC>
|
||||
void for_each(FUNC f) const {
|
||||
for (unsigned i = 0; i < _count; i++) f(_objs[i]); }
|
||||
|
||||
unsigned count() const { return _count; }
|
||||
};
|
||||
|
||||
#endif /* _SRC__LIB__HW__ARRAY_H_ */
|
@ -22,7 +22,7 @@ namespace Hw { template <typename> struct Boot_info; }
|
||||
template <typename PLAT_INFO>
|
||||
struct Hw::Boot_info
|
||||
{
|
||||
using Mapping_pool = Array<Mapping, 32>;
|
||||
using Mapping_pool = Genode::Array<Mapping, 32>;
|
||||
|
||||
addr_t const table;
|
||||
addr_t const table_allocator;
|
||||
|
@ -45,7 +45,7 @@ struct Hw::Mmio_space : Hw::Memory_region_array
|
||||
void for_each_mapping(FUNC f) const
|
||||
{
|
||||
addr_t virt_base = Mm::core_mmio().base;
|
||||
auto lambda = [&] (Memory_region const & r) {
|
||||
auto lambda = [&] (unsigned, Memory_region const & r) {
|
||||
f(Mapping { r.base, virt_base, r.size, PAGE_FLAGS_KERN_IO });
|
||||
virt_base += r.size + get_page_size();
|
||||
};
|
||||
|
@ -15,13 +15,13 @@
|
||||
#define _SRC__LIB__HW__MEMORY_REGION_H_
|
||||
|
||||
#include <base/output.h>
|
||||
#include <hw/array.h>
|
||||
#include <util/array.h>
|
||||
#include <hw/util.h>
|
||||
|
||||
namespace Hw {
|
||||
|
||||
struct Memory_region;
|
||||
using Memory_region_array = Array<Memory_region, 16>;
|
||||
using Memory_region_array = Genode::Array<Memory_region, 16>;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user