2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Core-specific environment
|
|
|
|
* \author Norman Feske
|
|
|
|
* \author Christian Helmuth
|
|
|
|
* \date 2006-07-28
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2011-12-22 16:19:25 +01: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.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__CORE_ENV_H_
|
|
|
|
#define _CORE__INCLUDE__CORE_ENV_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/env.h>
|
2019-01-30 17:53:16 +01:00
|
|
|
#include <deprecated/env.h>
|
2017-05-11 00:07:54 +02:00
|
|
|
|
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/globals.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* core includes */
|
2012-05-28 16:57:09 +02:00
|
|
|
#include <platform.h>
|
2016-04-15 15:19:22 +02:00
|
|
|
#include <core_region_map.h>
|
2017-05-11 20:03:28 +02:00
|
|
|
#include <pd_session_component.h>
|
|
|
|
#include <synced_ram_allocator.h>
|
2017-05-11 00:07:54 +02:00
|
|
|
#include <assertion.h>
|
2015-12-23 15:22:33 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
namespace Genode {
|
2017-05-11 20:03:28 +02:00
|
|
|
|
2017-05-11 00:07:54 +02:00
|
|
|
class Core_env;
|
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
|
|
|
extern Core_env &core_env();
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
2017-05-11 00:07:54 +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
|
|
|
class Genode::Core_env : public Env_deprecated, Noncopyable
|
2017-05-11 00:07:54 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2017-09-06 13:38:55 +02:00
|
|
|
enum { ENTRYPOINT_STACK_SIZE = 20 * 1024 };
|
2017-05-11 00:07:54 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the stack area before creating the first thread,
|
|
|
|
* which happens to be the '_entrypoint'.
|
|
|
|
*/
|
|
|
|
bool _init_stack_area() { init_stack_area(); return true; }
|
|
|
|
bool _stack_area_initialized = _init_stack_area();
|
|
|
|
|
2017-05-11 20:03:28 +02:00
|
|
|
Rpc_entrypoint _entrypoint;
|
|
|
|
Core_region_map _region_map;
|
|
|
|
Pd_session_component _pd_session;
|
|
|
|
Synced_ram_allocator _synced_ram_allocator { _pd_session };
|
2017-05-11 00:07:54 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Core_env()
|
|
|
|
:
|
|
|
|
_entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint"),
|
|
|
|
_region_map(_entrypoint),
|
2017-05-11 20:03:28 +02:00
|
|
|
_pd_session(_entrypoint,
|
2017-11-20 15:30:18 +01:00
|
|
|
_entrypoint,
|
2017-05-11 20:03:28 +02:00
|
|
|
Session::Resources {
|
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
|
|
|
Ram_quota { platform().ram_alloc().avail() },
|
|
|
|
Cap_quota { platform().max_caps() } },
|
2017-05-11 20:03:28 +02:00
|
|
|
Session::Label("core"),
|
|
|
|
Session::Diag{false},
|
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().ram_alloc(),
|
2017-05-11 20:03:28 +02:00
|
|
|
Ram_dataspace_factory::any_phys_range(),
|
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
|
|
|
Ram_dataspace_factory::Virt_range { platform().vm_start(),
|
|
|
|
platform().vm_size() },
|
2017-05-11 20:03:28 +02:00
|
|
|
_region_map,
|
|
|
|
*((Pager_entrypoint *)nullptr),
|
2017-11-09 14:20:07 +01:00
|
|
|
"" /* args to native PD */,
|
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_specific().core_mem_alloc())
|
2017-05-11 00:07:54 +02:00
|
|
|
{
|
2017-05-11 20:03:28 +02:00
|
|
|
_pd_session.init_cap_and_ram_accounts();
|
2017-05-11 00:07:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
~Core_env() { parent()->exit(0); }
|
|
|
|
|
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
|
|
|
Rpc_entrypoint &entrypoint() { return _entrypoint; }
|
|
|
|
Ram_allocator &ram_allocator() { return _synced_ram_allocator; }
|
|
|
|
Region_map &local_rm() { return _region_map; }
|
2017-05-11 00:07:54 +02:00
|
|
|
|
2017-11-20 15:33:25 +01:00
|
|
|
Rpc_entrypoint &signal_ep();
|
2017-05-11 00:07:54 +02:00
|
|
|
|
|
|
|
/******************************
|
|
|
|
** Env_deprecated interface **
|
|
|
|
******************************/
|
|
|
|
|
|
|
|
Parent *parent() override { return nullptr; }
|
|
|
|
Region_map *rm_session() override { return &_region_map; }
|
2017-05-11 20:03:28 +02:00
|
|
|
Pd_session *pd_session() override { return &_pd_session; }
|
2017-05-11 00:07:54 +02:00
|
|
|
Allocator *heap() override { ASSERT_NEVER_CALLED; }
|
|
|
|
Cpu_session *cpu_session() override { ASSERT_NEVER_CALLED; }
|
|
|
|
Cpu_session_capability cpu_session_cap() override { ASSERT_NEVER_CALLED; }
|
2017-05-11 20:03:28 +02:00
|
|
|
Pd_session_capability pd_session_cap() override { return _pd_session.cap(); }
|
2017-05-11 00:07:54 +02:00
|
|
|
|
|
|
|
void reinit(Capability<Parent>::Raw) override { }
|
|
|
|
void reinit_main_thread(Capability<Region_map> &) override { }
|
|
|
|
};
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */
|