2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Platform specific part of a Genode protection domain
|
|
|
|
* \author Martin Stein
|
hw: restrict processor broadcast to TLB flushing
Removes the generic processor broadcast function call. By now, that call
was used for cross processor TLB maintance operations only. When core/kernel
gets its memory mapped on demand, and unmapped again, the previous cross
processor flush routine doesn't work anymore, because of a hen-egg problem.
The previous cross processor broadcast is realized using a thread constructed
by core running on top of each processor core. When constructing threads in
core, a dataspace for its thread context is constructed. Each constructed
RAM dataspace gets attached, zeroed out, and detached again. The detach
routine requires a TLB flush operation executed on each processor core.
Instead of executing a thread on each processor core, now a thread waiting
for a global TLB flush is removed from the scheduler queue, and gets attached
to a TLB flush queue of each processor. The processor local queue gets checked
whenever the kernel is entered. The last processor, which executed the TLB
flush, re-attaches the blocked thread to its scheduler queue again.
To ease uo the above described mechanism, a platform thread is now directly
associated with a platform pd object, instead of just associate it with the
kernel pd's id.
Ref #723
2014-04-28 20:36:00 +02:00
|
|
|
* \author Stefan Kalkowski
|
2012-05-30 20:13:09 +02:00
|
|
|
* \date 2012-02-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2009-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
2017-04-12 10:06:29 +02:00
|
|
|
#ifndef _CORE__PLATFORM_PD_H_
|
|
|
|
#define _CORE__PLATFORM_PD_H_
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* Core includes */
|
2014-04-28 21:31:57 +02:00
|
|
|
#include <translation_table.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <platform.h>
|
2013-03-08 11:54:12 +01:00
|
|
|
#include <address_space.h>
|
2017-02-21 13:46:59 +01:00
|
|
|
#include <hw/page_table_allocator.h>
|
2015-05-19 14:18:40 +02:00
|
|
|
#include <object.h>
|
2015-06-16 10:59:26 +02:00
|
|
|
#include <kernel/configuration.h>
|
2015-05-19 14:18:40 +02:00
|
|
|
#include <kernel/object.h>
|
|
|
|
#include <kernel/pd.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
namespace Hw
|
|
|
|
{
|
2015-06-16 10:59:26 +02:00
|
|
|
using namespace Kernel;
|
|
|
|
using namespace Genode;
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
/**
|
|
|
|
* Memory virtualization interface of a protection domain
|
|
|
|
*/
|
|
|
|
class Address_space;
|
|
|
|
}
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
namespace Genode
|
|
|
|
{
|
2015-04-28 14:07:51 +02:00
|
|
|
class Platform_thread; /* forward declaration */
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
class Cap_space;
|
2015-05-19 14:18:40 +02:00
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
/**
|
|
|
|
* Platform specific part of a Genode protection domain
|
|
|
|
*/
|
2015-04-28 14:07:51 +02:00
|
|
|
class Platform_pd;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Platform specific part of Core's protection domain
|
|
|
|
*/
|
|
|
|
class Core_platform_pd;
|
2017-02-21 13:46:59 +01:00
|
|
|
|
|
|
|
using Hw::Page_flags;
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
class Hw::Address_space : public Genode::Address_space
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Noncopyable
|
|
|
|
*/
|
|
|
|
Address_space(Address_space const &);
|
|
|
|
Address_space &operator = (Address_space const &);
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
friend class Genode::Platform;
|
2015-09-17 14:16:59 +02:00
|
|
|
friend class Genode::Mapped_mem_allocator;
|
2015-04-28 14:07:51 +02:00
|
|
|
|
2017-02-21 13:46:59 +01:00
|
|
|
using Table = Hw::Page_table;
|
|
|
|
using Array = Table::Allocator::Array<DEFAULT_TRANSLATION_TABLE_MAX>;
|
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
|
|
|
|
2019-10-16 15:07:11 +02:00
|
|
|
Genode::Lock _lock { }; /* table lock */
|
|
|
|
Table & _tt; /* table virt addr */
|
|
|
|
Genode::addr_t _tt_phys; /* table phys addr */
|
|
|
|
Array * _tt_array = nullptr;
|
|
|
|
Table::Allocator & _tt_alloc; /* table allocator */
|
2015-04-28 14:07:51 +02:00
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
static inline Genode::Core_mem_allocator &_cma();
|
|
|
|
|
|
|
|
static inline void *_table_alloc();
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2019-10-16 15:07:11 +02:00
|
|
|
Kernel_object<Kernel::Pd> _kobj;
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
/**
|
|
|
|
* Core-specific constructor
|
|
|
|
*
|
2019-10-16 15:07:11 +02:00
|
|
|
* \param tt reference to translation table
|
|
|
|
* \param tt_alloc reference to translation table allocator
|
|
|
|
* \param pd reference to platform pd object
|
2015-04-28 14:07:51 +02:00
|
|
|
*/
|
2019-10-16 15:07:11 +02:00
|
|
|
Address_space(Hw::Page_table & tt,
|
|
|
|
Hw::Page_table::Allocator & tt_alloc,
|
|
|
|
Platform_pd & pd);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2019-10-16 15:07:11 +02:00
|
|
|
* \param pd reference to platform pd object
|
2015-04-28 14:07:51 +02:00
|
|
|
*/
|
2019-10-16 15:07:11 +02:00
|
|
|
Address_space(Platform_pd & pd);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
2015-05-21 15:00:03 +02:00
|
|
|
~Address_space();
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
/**
|
|
|
|
* Insert memory mapping into translation table of the address space
|
|
|
|
*
|
|
|
|
* \param virt virtual start address
|
|
|
|
* \param phys physical start address
|
|
|
|
* \param size size of memory region
|
|
|
|
* \param flags translation table flags (e.g. caching attributes)
|
|
|
|
*/
|
|
|
|
bool insert_translation(Genode::addr_t virt, Genode::addr_t phys,
|
|
|
|
Genode::size_t size, Genode::Page_flags flags);
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************
|
|
|
|
** Address-space interface **
|
|
|
|
*****************************/
|
|
|
|
|
2017-08-14 11:32:07 +02:00
|
|
|
void flush(addr_t, size_t, Core_local_addr) override;
|
|
|
|
void flush(addr_t addr, size_t size) {
|
|
|
|
flush(addr, size, Core_local_addr{0}); }
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***************
|
|
|
|
** Accessors **
|
|
|
|
***************/
|
|
|
|
|
2019-10-16 15:07:11 +02:00
|
|
|
Kernel::Pd & kernel_pd() { return *_kobj; }
|
|
|
|
Hw::Page_table & translation_table() { return _tt; }
|
|
|
|
Genode::addr_t translation_table_phys() { return _tt_phys; }
|
2015-04-28 14:07:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
class Genode::Cap_space
|
2015-05-19 14:18:40 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
enum { SLAB_SIZE = 2 * get_page_size() };
|
|
|
|
|
|
|
|
using Cap_slab = Tslab<Kernel::Object_identity_reference,
|
|
|
|
SLAB_SIZE>;
|
|
|
|
|
|
|
|
uint8_t _initial_sb[SLAB_SIZE];
|
|
|
|
Cap_slab _slab;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
Cap_space();
|
2015-05-19 14:18:40 +02:00
|
|
|
|
|
|
|
Cap_slab & capability_slab() { return _slab; }
|
|
|
|
|
|
|
|
void upgrade_slab(Allocator &alloc);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
class Genode::Platform_pd : public Hw::Address_space,
|
2019-10-16 15:07:11 +02:00
|
|
|
private Cap_space
|
2015-04-28 14:07:51 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Noncopyable
|
|
|
|
*/
|
|
|
|
Platform_pd(Platform_pd const &);
|
|
|
|
Platform_pd &operator = (Platform_pd const &);
|
|
|
|
|
|
|
|
Native_capability _parent { };
|
2015-05-19 14:18:40 +02:00
|
|
|
bool _thread_associated = false;
|
|
|
|
char const * const _label;
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for core pd
|
|
|
|
*
|
2015-06-16 10:59:26 +02:00
|
|
|
* \param tt translation table address
|
|
|
|
* \param tt_alloc translation table allocator
|
2015-04-28 14:07:51 +02:00
|
|
|
*/
|
2017-02-21 13:46:59 +01:00
|
|
|
Platform_pd(Hw::Page_table & tt,
|
|
|
|
Hw::Page_table::Allocator & tt_alloc);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor for non-core pd
|
|
|
|
*
|
|
|
|
* \param label name of protection domain
|
|
|
|
*/
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
Platform_pd(Allocator &md_alloc, char const *label);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
2015-08-25 08:59:33 +02:00
|
|
|
/**
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
~Platform_pd();
|
|
|
|
|
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
|
|
|
using Cap_space::capability_slab;
|
|
|
|
using Cap_space::upgrade_slab;
|
|
|
|
|
2015-04-28 14:07:51 +02:00
|
|
|
/**
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
* Bind thread to protection domain
|
2015-04-28 14:07:51 +02:00
|
|
|
*/
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
bool bind_thread(Platform_thread &);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
/**
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
* Unbind thread from protection domain
|
2015-04-28 14:07:51 +02:00
|
|
|
*/
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
void unbind_thread(Platform_thread &);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assign parent interface to protection domain
|
|
|
|
*/
|
2016-04-14 16:29:07 +02:00
|
|
|
void assign_parent(Native_capability parent);
|
2015-04-28 14:07:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***************
|
|
|
|
** Accessors **
|
|
|
|
***************/
|
|
|
|
|
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
|
|
|
char const * label() { return _label; }
|
|
|
|
Native_capability parent() { return _parent; }
|
2015-04-28 14:07:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-11-07 18:00:24 +01:00
|
|
|
struct Genode::Core_platform_pd : Genode::Platform_pd
|
2015-04-28 14:07:51 +02:00
|
|
|
{
|
2016-11-07 18:00:24 +01:00
|
|
|
Core_platform_pd();
|
2015-04-28 14:07:51 +02:00
|
|
|
};
|
|
|
|
|
2017-04-12 10:06:29 +02:00
|
|
|
#endif /* _CORE__PLATFORM_PD_H_ */
|