genode/repos/base-pistachio/src/core/include/platform.h

170 lines
4.1 KiB
C
Raw Normal View History

2011-12-22 16:19:25 +01:00
/*
* \brief Pistachio platform
* \author Christian Helmuth
* \author Norman Feske
* \date 2007-09-10
*/
/*
* Copyright (C) 2007-2017 Genode Labs GmbH
2011-12-22 16:19:25 +01:00
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
2011-12-22 16:19:25 +01:00
*/
#ifndef _CORE__INCLUDE__PLATFORM_H_
#define _CORE__INCLUDE__PLATFORM_H_
/* Genode includes */
2011-12-22 16:19:25 +01:00
#include <base/allocator_avl.h>
/* base-internal includes */
#include <base/internal/capability_space.h>
/* core-local includes */
#include "synced_range_allocator.h"
2011-12-22 16:19:25 +01:00
#include "platform_generic.h"
#include "platform_thread.h"
#include "platform_pd.h"
namespace Genode {
class Platform : public Platform_generic
{
private:
/*
* Shortcut for the type of allocator instances for physical resources
*/
typedef Synced_range_allocator<Allocator_avl> Phys_allocator;
2011-12-22 16:19:25 +01:00
Follow practices suggested by "Effective C++" The patch adjust the code of the base, base-<kernel>, and os repository. To adapt existing components to fix violations of the best practices suggested by "Effective C++" as reported by the -Weffc++ compiler argument. The changes follow the patterns outlined below: * A class with virtual functions can no longer publicly inherit base classed without a vtable. The inherited object may either be moved to a member variable, or inherited privately. The latter would be used for classes that inherit 'List::Element' or 'Avl_node'. In order to enable the 'List' and 'Avl_tree' to access the meta data, the 'List' must become a friend. * Instead of adding a virtual destructor to abstract base classes, we inherit the new 'Interface' class, which contains a virtual destructor. This way, single-line abstract base classes can stay as compact as they are now. The 'Interface' utility resides in base/include/util/interface.h. * With the new warnings enabled, all member variables must be explicitly initialized. Basic types may be initialized with '='. All other types are initialized with braces '{ ... }' or as class initializers. If basic types and non-basic types appear in a row, it is nice to only use the brace syntax (also for basic types) and align the braces. * If a class contains pointers as members, it must now also provide a copy constructor and assignment operator. In the most cases, one would make them private, effectively disallowing the objects to be copied. Unfortunately, this warning cannot be fixed be inheriting our existing 'Noncopyable' class (the compiler fails to detect that the inheriting class cannot be copied and still gives the error). For now, we have to manually add declarations for both the copy constructor and assignment operator as private class members. Those declarations should be prepended with a comment like this: /* * Noncopyable */ Thread(Thread const &); Thread &operator = (Thread const &); In the future, we should revisit these places and try to replace the pointers with references. In the presence of at least one reference member, the compiler would no longer implicitly generate a copy constructor. So we could remove the manual declaration. Issue #465
2017-12-21 15:42:15 +01:00
Phys_allocator _ram_alloc; /* RAM allocator */
Phys_allocator _io_mem_alloc; /* MMIO allocator */
Phys_allocator _io_port_alloc; /* I/O port allocator */
Phys_allocator _irq_alloc; /* IRQ allocator */
Phys_allocator _region_alloc; /* virtual memory allocator for core */
Rom_fs _rom_fs { }; /* ROM file system */
Rom_module _kip_rom; /* ROM module for Fiasco KIP */
addr_t _vm_start = 0; /* begin of virtual memory */
size_t _vm_size = 0; /* size of virtual memory */
2011-12-22 16:19:25 +01:00
/*
* We do not export any boot module loaded before FIRST_ROM.
*/
enum { FIRST_ROM = 3 };
/**
* Setup base resources
*
* - Map and provide KIP as ROM module
* - Initializes region allocator
*/
void _setup_basics();
/**
* Setup preemption flags
*/
void _setup_preemption();
/**
* Setup RAM, IO_MEM, and region allocators
*/
void _setup_mem_alloc();
/**
* Setup I/O port space allocator
*/
void _setup_io_port_alloc();
/**
* Setup IRQ allocator
*/
void _setup_irq_alloc();
/**
* Parse multi-boot information and update ROM database
*/
void _init_rom_modules();
addr_t _rom_module_phys(addr_t virt) { return virt; }
2011-12-22 16:19:25 +01:00
public:
/**
* Pager object representing the pager of core namely sigma0
*/
struct Sigma0 : public Pager_object
{
/**
* Constructor
*/
Sigma0();
int pager(Ipc_pager &) override { /* never called */ return -1; }
2011-12-22 16:19:25 +01:00
};
/**
* Return singleton instance of Sigma0 pager object
*/
static Sigma0 &sigma0();
2011-12-22 16:19:25 +01:00
/**
* Core pager thread that handles core-internal page-faults
*/
struct Core_pager : public Platform_thread, public Pager_object
{
/**
* Constructor
*/
Core_pager(Platform_pd &core_pd);
2011-12-22 16:19:25 +01:00
int pager(Ipc_pager &) override { /* never called */ return -1; }
2011-12-22 16:19:25 +01:00
};
/**
* Return singleton instance of core pager object
*/
Core_pager &core_pager();
2011-12-22 16:19:25 +01:00
/**
* Constructor
*/
Platform();
/**
* Return singleton instance of core PD object
*/
Platform_pd &core_pd();
2011-12-22 16:19:25 +01:00
/********************************
** Generic platform interface **
********************************/
Range_allocator &core_mem_alloc() override { return _ram_alloc; }
Range_allocator &ram_alloc() override { return _ram_alloc; }
Range_allocator &io_mem_alloc() override { return _io_mem_alloc; }
Range_allocator &io_port_alloc() override { return _io_port_alloc; }
Range_allocator &irq_alloc() override { return _irq_alloc; }
Range_allocator &region_alloc() override { return _region_alloc; }
addr_t vm_start() const override { return _vm_start; }
size_t vm_size() const override { return _vm_size; }
Rom_fs &rom_fs() override { return _rom_fs; }
size_t max_caps() const override { return Capability_space::max_caps(); }
2011-12-22 16:19:25 +01:00
void wait_for_exit() override;
Affinity::Space affinity_space() const override
{
/*
* Ignore topology of CPU nodes, just return a one-dimensional
* affinity space.
*/
return Affinity::Space(L4_NumProcessors(Pistachio::get_kip()), 1);
}
2011-12-22 16:19:25 +01:00
};
}
#endif /* _CORE__INCLUDE__PLATFORM_H_ */