2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Platform interface implementation
|
|
|
|
* \author Norman Feske
|
|
|
|
* \author Sebastian Sumpf
|
2012-08-01 16:16:51 +02:00
|
|
|
* \author Alexander Boettcher
|
2011-12-22 16:19:25 +01:00
|
|
|
* \date 2009-10-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2009-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
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/sleep.h>
|
|
|
|
#include <base/thread.h>
|
2017-10-30 15:26:35 +01:00
|
|
|
#include <util/mmio.h>
|
2017-06-12 22:12:17 +02:00
|
|
|
#include <util/string.h>
|
|
|
|
#include <util/xml_generator.h>
|
2015-10-07 15:16:03 +02:00
|
|
|
#include <trace/source_registry.h>
|
2018-01-24 14:02:35 +01:00
|
|
|
#include <util/construct_at.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* core includes */
|
2016-09-15 16:08:33 +02:00
|
|
|
#include <boot_modules.h>
|
2017-12-11 13:05:23 +01:00
|
|
|
#include <core_log.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
#include <platform.h>
|
|
|
|
#include <nova_util.h>
|
|
|
|
#include <util.h>
|
2015-10-07 15:16:03 +02:00
|
|
|
#include <ipc_pager.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-03-03 17:57:29 +01:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/stack_area.h>
|
2016-03-08 16:59:43 +01:00
|
|
|
#include <base/internal/native_utcb.h>
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/internal/globals.h>
|
2016-03-03 17:57:29 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* NOVA includes */
|
|
|
|
#include <nova/syscalls.h>
|
2016-03-18 22:53:25 +01:00
|
|
|
#include <nova/util.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
using namespace Nova;
|
|
|
|
|
|
|
|
|
|
|
|
enum { verbose_boot_info = true };
|
|
|
|
|
2012-09-28 12:24:14 +02:00
|
|
|
Native_utcb *main_thread_utcb();
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2013-01-11 23:10:21 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/**
|
2013-07-10 14:35:54 +02:00
|
|
|
* Initial value of esp register, saved by the crt0 startup code.
|
2011-12-22 16:19:25 +01:00
|
|
|
* This value contains the address of the hypervisor information page.
|
|
|
|
*/
|
2013-02-21 17:39:45 +01:00
|
|
|
extern addr_t __initial_sp;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pointer to the UTCB of the main thread
|
|
|
|
*/
|
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 Utcb *__main_thread_utcb;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Virtual address range consumed by core's program image
|
|
|
|
*/
|
|
|
|
extern unsigned _prog_img_beg, _prog_img_end;
|
|
|
|
|
2012-11-22 14:11:15 +01:00
|
|
|
|
2013-02-21 17:39:45 +01:00
|
|
|
/**
|
2014-03-26 11:06:00 +01:00
|
|
|
* Map preserved physical pages core-exclusive
|
|
|
|
*
|
|
|
|
* This function uses the virtual-memory region allocator to find a region
|
|
|
|
* fitting the desired mapping. Other allocators are left alone.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
2017-12-11 13:05:23 +01:00
|
|
|
addr_t Platform::_map_pages(addr_t const phys_addr, addr_t const pages,
|
|
|
|
bool guard_page)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2017-12-11 13:05:23 +01:00
|
|
|
addr_t const size = pages << get_page_size_log2();
|
2013-02-21 17:39:45 +01:00
|
|
|
|
|
|
|
/* try to reserve contiguous virtual area */
|
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 *core_local_ptr = nullptr;
|
|
|
|
if (region_alloc().alloc_aligned(size + (guard_page ? get_page_size() : 0),
|
|
|
|
&core_local_ptr, get_page_size_log2()).error())
|
2013-02-21 17:39:45 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
addr_t const core_local_addr = reinterpret_cast<addr_t>(core_local_ptr);
|
|
|
|
|
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
|
|
|
int res = map_local(_core_pd_sel, *__main_thread_utcb, phys_addr,
|
2018-06-29 14:04:32 +02:00
|
|
|
core_local_addr, pages,
|
2017-10-13 14:18:29 +02:00
|
|
|
Nova::Rights(true, true, false), true);
|
2013-02-21 17:39:45 +01:00
|
|
|
|
2012-11-22 11:26:51 +01:00
|
|
|
return res ? 0 : core_local_addr;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
2012-11-22 14:11:15 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/*****************************
|
|
|
|
** Core page-fault handler **
|
|
|
|
*****************************/
|
|
|
|
|
2013-02-21 17:39:45 +01:00
|
|
|
|
2012-09-04 12:45:27 +02:00
|
|
|
enum { CORE_PAGER_UTCB_ADDR = 0xbff02000 };
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IDC handler for the page-fault portal
|
|
|
|
*/
|
|
|
|
static void page_fault_handler()
|
|
|
|
{
|
|
|
|
Utcb *utcb = (Utcb *)CORE_PAGER_UTCB_ADDR;
|
|
|
|
|
|
|
|
addr_t pf_addr = utcb->qual[1];
|
2012-12-04 11:57:50 +01:00
|
|
|
addr_t pf_ip = utcb->ip;
|
|
|
|
addr_t pf_sp = utcb->sp;
|
|
|
|
addr_t pf_type = utcb->qual[0];
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-09-05 11:24:51 +02:00
|
|
|
error("\nPAGE-FAULT IN CORE addr=", Hex(pf_addr), " ip=", Hex(pf_ip),
|
|
|
|
" (", (pf_type & Ipc_pager::ERR_W) ? "write" : "read", ")");
|
2011-12-22 16:19:25 +01:00
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("\nstack pointer ", Hex(pf_sp), ", qualifiers ", Hex(pf_type), " ",
|
|
|
|
pf_type & Ipc_pager::ERR_I ? "I" : "i",
|
|
|
|
pf_type & Ipc_pager::ERR_R ? "R" : "r",
|
|
|
|
pf_type & Ipc_pager::ERR_U ? "U" : "u",
|
|
|
|
pf_type & Ipc_pager::ERR_W ? "W" : "w",
|
|
|
|
pf_type & Ipc_pager::ERR_P ? "P" : "p");
|
2015-10-12 13:17:34 +02:00
|
|
|
|
2016-03-03 17:57:29 +01:00
|
|
|
if ((stack_area_virtual_base() <= pf_sp) &&
|
|
|
|
(pf_sp < stack_area_virtual_base() +
|
|
|
|
stack_area_virtual_size()))
|
2015-10-12 13:17:34 +02:00
|
|
|
{
|
2016-03-03 17:57:29 +01:00
|
|
|
addr_t utcb_addr_f = pf_sp / stack_virtual_size();
|
|
|
|
utcb_addr_f *= stack_virtual_size();
|
|
|
|
utcb_addr_f += stack_virtual_size();
|
2015-10-12 13:17:34 +02:00
|
|
|
utcb_addr_f -= 4096;
|
|
|
|
|
|
|
|
Nova::Utcb * utcb_fault = reinterpret_cast<Nova::Utcb *>(utcb_addr_f);
|
|
|
|
unsigned last_items = utcb_fault->msg_items();
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("faulter utcb ", utcb_fault, ", last message item count ", last_items);
|
2015-10-12 13:17:34 +02:00
|
|
|
|
|
|
|
for (unsigned i = 0; i < last_items; i++) {
|
|
|
|
Nova::Utcb::Item * item = utcb_fault->get_item(i);
|
|
|
|
if (!item)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Nova::Crd crd(item->crd);
|
|
|
|
if (crd.is_null())
|
|
|
|
continue;
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log(i, " - "
|
|
|
|
"type=", Hex(crd.type()), " "
|
|
|
|
"rights=", Hex(crd.rights()), " "
|
|
|
|
"region=", Hex(crd.addr()), "+", Hex(1UL << (12 + crd.order())), " "
|
|
|
|
"hotspot=", Hex(crd.hotspot(item->hotspot)),
|
|
|
|
"(", Hex(item->hotspot), ")"
|
|
|
|
" - ", item->is_del() ? "delegated" : "translated");
|
2015-10-12 13:17:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* dump stack trace */
|
|
|
|
struct Core_img
|
|
|
|
{
|
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
|
|
|
addr_t _beg = 0;
|
|
|
|
addr_t _end = 0;
|
|
|
|
addr_t *_ip = nullptr;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
Core_img(addr_t sp)
|
|
|
|
{
|
|
|
|
extern addr_t _dtors_end;
|
|
|
|
_beg = (addr_t)&_prog_img_beg;
|
|
|
|
_end = (addr_t)&_dtors_end;
|
|
|
|
|
|
|
|
_ip = (addr_t *)sp;
|
|
|
|
for (;!ip_valid(); _ip++) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
addr_t *ip() { return _ip; }
|
|
|
|
void next_ip() { _ip = ((addr_t *)*(_ip - 1)) + 1;}
|
2012-12-04 11:57:50 +01:00
|
|
|
bool ip_valid() { return (*_ip >= _beg) && (*_ip < _end); }
|
2011-12-22 16:19:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int count = 1;
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log(" #", count++, " ", Hex(pf_sp, Hex::PREFIX, Hex::PAD), " ",
|
|
|
|
Hex(pf_ip, Hex::PREFIX, Hex::PAD));
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-08-24 10:25:24 +02:00
|
|
|
Core_img dump(pf_sp);
|
2011-12-22 16:19:25 +01:00
|
|
|
while (dump.ip_valid()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log(" #", count++, " ", Hex((addr_t)dump.ip(), Hex::PREFIX, Hex::PAD),
|
|
|
|
" ", Hex(*dump.ip(), Hex::PREFIX, Hex::PAD));
|
2011-12-22 16:19:25 +01:00
|
|
|
dump.next_ip();
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep_forever();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-05 14:46:16 +02:00
|
|
|
static addr_t core_pager_stack_top()
|
|
|
|
{
|
|
|
|
enum { STACK_SIZE = 4*1024 };
|
|
|
|
static char stack[STACK_SIZE];
|
|
|
|
return (addr_t)&stack[STACK_SIZE - sizeof(addr_t)];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Startup handler for core threads
|
|
|
|
*/
|
|
|
|
static void startup_handler()
|
|
|
|
{
|
|
|
|
Utcb *utcb = (Utcb *)CORE_PAGER_UTCB_ADDR;
|
|
|
|
|
|
|
|
/* initial IP is on stack */
|
|
|
|
utcb->ip = *reinterpret_cast<addr_t *>(utcb->sp);
|
|
|
|
utcb->mtd = Mtd::EIP | Mtd::ESP;
|
|
|
|
utcb->set_msg_word(0);
|
|
|
|
|
|
|
|
reply((void*)core_pager_stack_top());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-17 11:59:08 +01:00
|
|
|
static addr_t init_core_page_fault_handler(addr_t const core_pd_sel)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2018-06-29 14:04:32 +02:00
|
|
|
/* create fault handler EC for core main thread */
|
2012-08-01 16:16:51 +02:00
|
|
|
enum {
|
2011-12-22 16:19:25 +01:00
|
|
|
GLOBAL = false,
|
|
|
|
EXC_BASE = 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
|
|
|
addr_t ec_sel = cap_map().insert(1);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-10 11:46:30 +01:00
|
|
|
uint8_t ret = create_ec(ec_sel, core_pd_sel, boot_cpu(),
|
2012-10-05 14:46:16 +02:00
|
|
|
CORE_PAGER_UTCB_ADDR, core_pager_stack_top(),
|
|
|
|
EXC_BASE, GLOBAL);
|
2011-12-22 16:19:25 +01:00
|
|
|
if (ret)
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log(__func__, ": create_ec returned ", ret);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* set up page-fault portal */
|
2016-11-10 11:46:30 +01:00
|
|
|
create_pt(PT_SEL_PAGE_FAULT, core_pd_sel, ec_sel,
|
2011-12-22 16:19:25 +01:00
|
|
|
Mtd(Mtd::QUAL | Mtd::ESP | Mtd::EIP),
|
2012-07-30 10:56:07 +02:00
|
|
|
(addr_t)page_fault_handler);
|
2013-02-22 15:26:43 +01:00
|
|
|
revoke(Obj_crd(PT_SEL_PAGE_FAULT, 0, Obj_crd::RIGHT_PT_CTRL));
|
2012-10-05 14:46:16 +02:00
|
|
|
|
|
|
|
/* startup portal for global core threads */
|
2016-11-10 11:46:30 +01:00
|
|
|
create_pt(PT_SEL_STARTUP, core_pd_sel, ec_sel,
|
2012-10-05 14:46:16 +02:00
|
|
|
Mtd(Mtd::EIP | Mtd::ESP),
|
|
|
|
(addr_t)startup_handler);
|
2013-02-22 15:26:43 +01:00
|
|
|
revoke(Obj_crd(PT_SEL_STARTUP, 0, Obj_crd::RIGHT_PT_CTRL));
|
2018-01-17 11:59:08 +01:00
|
|
|
|
|
|
|
return ec_sel;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-02 13:12:10 +02:00
|
|
|
static bool cpuid_invariant_tsc()
|
|
|
|
{
|
|
|
|
unsigned long cpuid = 0x80000007, edx = 0;
|
2016-09-15 16:08:33 +02:00
|
|
|
#ifdef __x86_64__
|
|
|
|
asm volatile ("cpuid" : "+a" (cpuid), "=d" (edx) : : "rbx", "rcx");
|
|
|
|
#else
|
|
|
|
asm volatile ("push %%ebx \n"
|
|
|
|
"cpuid \n"
|
|
|
|
"pop %%ebx" : "+a" (cpuid), "=d" (edx) : : "ecx");
|
|
|
|
#endif
|
2015-07-02 13:12:10 +02:00
|
|
|
return edx & 0x100;
|
|
|
|
}
|
|
|
|
|
2017-10-30 15:26:35 +01:00
|
|
|
/* boot framebuffer resolution */
|
|
|
|
struct Resolution : Register<64>
|
|
|
|
{
|
|
|
|
struct Bpp : Bitfield<0, 8> { };
|
2018-06-23 17:19:12 +02:00
|
|
|
struct Type : Bitfield<8, 8> { enum { VGA_TEXT = 2 }; };
|
2017-10-30 15:26:35 +01:00
|
|
|
struct Height : Bitfield<16, 24> { };
|
|
|
|
struct Width : Bitfield<40, 24> { };
|
|
|
|
};
|
2015-07-02 13:12:10 +02:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/**************
|
|
|
|
** Platform **
|
|
|
|
**************/
|
|
|
|
|
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::Platform()
|
|
|
|
:
|
|
|
|
_io_mem_alloc(&core_mem_alloc()), _io_port_alloc(&core_mem_alloc()),
|
|
|
|
_irq_alloc(&core_mem_alloc()),
|
2013-08-07 22:16:58 +02:00
|
|
|
_vm_base(0x1000), _vm_size(0), _cpus(Affinity::Space(1,1))
|
2011-12-22 16:19:25 +01: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
|
|
|
Hip const &hip = *(Hip *)__initial_sp;
|
2013-02-22 14:42:32 +01:00
|
|
|
/* check for right API version */
|
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
|
|
|
if (hip.api_version != 8)
|
2013-02-22 14:42:32 +01:00
|
|
|
nova_die();
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2013-08-07 22:16:58 +02:00
|
|
|
/*
|
|
|
|
* Determine number of available CPUs
|
|
|
|
*
|
|
|
|
* XXX As of now, we assume a one-dimensional affinity space, ignoring
|
|
|
|
* the y component of the affinity location. When adding support
|
|
|
|
* for two-dimensional affinity spaces, look out and adjust the use of
|
|
|
|
* 'Platform_thread::_location' in 'platform_thread.cc'. Also look
|
2016-05-04 12:27:17 +02:00
|
|
|
* at the 'Thread::start' function in core/thread_start.cc.
|
2013-08-07 22:16:58 +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
|
|
|
_cpus = Affinity::Space(hip.cpus(), 1);
|
2012-10-05 11:35:14 +02:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* register UTCB of main thread */
|
|
|
|
__main_thread_utcb = (Utcb *)(__initial_sp - get_page_size());
|
|
|
|
|
|
|
|
/* set core pd selector */
|
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
|
|
|
_core_pd_sel = hip.sel_exc;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-08-01 16:16:51 +02:00
|
|
|
/* create lock used by capability allocator */
|
2016-11-10 11:46:30 +01:00
|
|
|
Nova::create_sm(Nova::SM_SEL_EC, core_pd_sel(), 0);
|
2012-08-01 16:16:51 +02:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* locally map the whole I/O port range */
|
|
|
|
enum { ORDER_64K = 16 };
|
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
|
|
|
map_local_one_to_one(*__main_thread_utcb, Io_crd(0, ORDER_64K), _core_pd_sel);
|
2012-11-27 09:31:00 +01:00
|
|
|
/* map BDA region, console reads IO ports at BDA_VIRT_ADDR + 0x400 */
|
|
|
|
enum { BDA_PHY = 0x0U, BDA_VIRT = 0x1U, BDA_VIRT_ADDR = 0x1000U };
|
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
|
|
|
map_local_phys_to_virt(*__main_thread_utcb,
|
2012-11-27 09:31:00 +01:00
|
|
|
Mem_crd(BDA_PHY, 0, Rights(true, false, false)),
|
2018-06-29 14:04:32 +02:00
|
|
|
Mem_crd(BDA_VIRT, 0, Rights(true, false, false)),
|
|
|
|
_core_pd_sel);
|
2014-03-10 15:24:53 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we can access the I/O ports for comport 0, printf works...
|
|
|
|
*/
|
|
|
|
|
2014-03-10 15:24:53 +01:00
|
|
|
/*
|
|
|
|
* remap main utcb to default utcb address
|
|
|
|
* we do this that early, because Core_mem_allocator uses
|
|
|
|
* the main_thread_utcb very early to establish mappings
|
|
|
|
*/
|
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
|
|
|
if (map_local(_core_pd_sel, *__main_thread_utcb, (addr_t)__main_thread_utcb,
|
2014-03-10 15:24:53 +01:00
|
|
|
(addr_t)main_thread_utcb(), 1, Rights(true, true, false))) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("could not remap utcb of main thread");
|
2014-03-10 15:24:53 +01:00
|
|
|
nova_die();
|
|
|
|
}
|
|
|
|
|
2012-10-01 12:01:04 +02:00
|
|
|
/* sanity checks */
|
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
|
|
|
if (hip.sel_exc + 3 > NUM_INITIAL_PT_RESERVED) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("configuration error (NUM_INITIAL_PT_RESERVED)");
|
2012-10-01 12:01:04 +02:00
|
|
|
nova_die();
|
|
|
|
}
|
|
|
|
|
2016-11-04 13:01:09 +01:00
|
|
|
/* init genode cpu ids based on kernel cpu ids (used for syscalls) */
|
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
|
|
|
if (sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0]) < hip.cpu_max()) {
|
|
|
|
error("number of max CPUs is larger than expected - ", hip.cpu_max(),
|
2016-11-04 13:01:09 +01:00
|
|
|
" vs ", sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0]));
|
|
|
|
nova_die();
|
|
|
|
}
|
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
|
|
|
if (!hip.remap_cpu_ids(map_cpu_ids, boot_cpu())) {
|
2016-11-04 13:01:09 +01:00
|
|
|
error("re-ording cpu_id failed");
|
|
|
|
nova_die();
|
|
|
|
}
|
|
|
|
|
2014-12-17 13:57:59 +01:00
|
|
|
/* map idle SCs */
|
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
|
|
|
unsigned const log2cpu = log2(hip.cpu_max());
|
|
|
|
if ((1U << log2cpu) != hip.cpu_max()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("number of max CPUs is not of power of 2");
|
2014-12-17 13:57:59 +01:00
|
|
|
nova_die();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
addr_t sc_idle_base = cap_map().insert(log2cpu + 1);
|
2014-12-17 13:57:59 +01:00
|
|
|
if (sc_idle_base & ((1UL << log2cpu) - 1)) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("unaligned sc_idle_base value ", Hex(sc_idle_base));
|
2014-12-17 13:57:59 +01:00
|
|
|
nova_die();
|
|
|
|
}
|
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
|
|
|
if (map_local(_core_pd_sel, *__main_thread_utcb, Obj_crd(0, log2cpu),
|
2016-11-04 13:01:09 +01:00
|
|
|
Obj_crd(sc_idle_base, log2cpu), true))
|
2014-12-17 13:57:59 +01:00
|
|
|
nova_die();
|
|
|
|
|
|
|
|
/* test reading out idle SCs */
|
|
|
|
bool sc_init = true;
|
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
|
|
|
for (unsigned i = 0; i < hip.cpu_max(); i++) {
|
2015-06-30 13:19:01 +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
|
|
|
if (!hip.is_cpu_enabled(i))
|
2015-06-30 13:19:01 +02:00
|
|
|
continue;
|
|
|
|
|
2014-12-17 13:57:59 +01:00
|
|
|
uint64_t n_time;
|
|
|
|
uint8_t res = Nova::sc_ctrl(sc_idle_base + i, n_time);
|
|
|
|
if (res != Nova::NOVA_OK) {
|
|
|
|
sc_init = false;
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error(i, " ", res, " ", n_time, " - failed");
|
2014-12-17 13:57:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!sc_init)
|
|
|
|
nova_die();
|
|
|
|
|
2012-09-04 12:45:27 +02:00
|
|
|
/* configure virtual address spaces */
|
|
|
|
#ifdef __x86_64__
|
2015-11-26 09:15:27 +01:00
|
|
|
_vm_size = 0x7fffc0000000UL - _vm_base;
|
2012-09-04 12:45:27 +02:00
|
|
|
#else
|
|
|
|
_vm_size = 0xc0000000UL - _vm_base;
|
|
|
|
#endif
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* set up page fault handler for core - for debugging */
|
2018-06-29 14:04:32 +02:00
|
|
|
addr_t const ec_core_exc_sel = init_core_page_fault_handler(core_pd_sel());
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
if (verbose_boot_info) {
|
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
|
|
|
if (hip.has_feature_vmx())
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("Hypervisor features VMX");
|
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
|
|
|
if (hip.has_feature_svm())
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("Hypervisor features SVM");
|
|
|
|
log("Hypervisor reports ", _cpus.width(), "x", _cpus.height(), " "
|
2016-11-04 13:01:09 +01:00
|
|
|
"CPU", _cpus.total() > 1 ? "s" : " ");
|
2015-07-02 13:12:10 +02:00
|
|
|
if (!cpuid_invariant_tsc())
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
warning("CPU has no invariant TSC.");
|
2016-11-04 13:01:09 +01:00
|
|
|
|
|
|
|
log("CPU ID (genode->kernel:package:core:thread) remapping");
|
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
|
|
|
unsigned const cpus = hip.cpus();
|
|
|
|
for (unsigned i = 0; i < cpus; i++) {
|
|
|
|
|
|
|
|
Hip::Cpu_desc const * const cpu_desc_ptr = hip.cpu_desc_of_cpu(map_cpu_ids[i]);
|
|
|
|
|
|
|
|
if (cpu_desc_ptr) {
|
|
|
|
log(" remap (", i, "->", map_cpu_ids[i], ":",
|
|
|
|
cpu_desc_ptr->package, ":",
|
|
|
|
cpu_desc_ptr->core, ":",
|
|
|
|
cpu_desc_ptr->thread, ") ",
|
|
|
|
boot_cpu() == map_cpu_ids[i] ? "boot cpu" : "");
|
|
|
|
} else {
|
|
|
|
error("missing descriptor for CPU ", i);
|
|
|
|
}
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize core allocators */
|
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
|
|
|
size_t const num_mem_desc = (hip.hip_length - hip.mem_desc_offset)
|
|
|
|
/ hip.mem_desc_size;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
if (verbose_boot_info)
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("Hypervisor info page contains ", num_mem_desc, " memory descriptors:");
|
2011-12-22 16:19:25 +01: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
|
|
|
addr_t mem_desc_base = ((addr_t)&hip + hip.mem_desc_offset);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* define core's virtual address space */
|
2012-09-04 12:45:27 +02:00
|
|
|
addr_t virt_beg = _vm_base;
|
|
|
|
addr_t virt_end = _vm_size;
|
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
|
|
|
_core_mem_alloc.virt_alloc().add_range(virt_beg, virt_end - virt_beg);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* exclude core image from core's virtual address allocator */
|
2016-09-15 16:08:33 +02:00
|
|
|
addr_t const core_virt_beg = trunc_page((addr_t)&_prog_img_beg);
|
|
|
|
addr_t const core_virt_end = round_page((addr_t)&_prog_img_end);
|
|
|
|
addr_t const binaries_beg = trunc_page((addr_t)&_boot_modules_binaries_begin);
|
|
|
|
addr_t const binaries_end = round_page((addr_t)&_boot_modules_binaries_end);
|
|
|
|
|
|
|
|
size_t const core_size = binaries_beg - core_virt_beg;
|
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
|
|
|
region_alloc().remove_range(core_virt_beg, core_size);
|
2012-11-27 09:31:00 +01:00
|
|
|
|
2016-09-15 16:08:33 +02:00
|
|
|
if (verbose_boot_info || binaries_end != core_virt_end) {
|
|
|
|
log("core image ",
|
|
|
|
Hex_range<addr_t>(core_virt_beg, core_virt_end - core_virt_beg));
|
|
|
|
log("binaries region ",
|
|
|
|
Hex_range<addr_t>(binaries_beg, binaries_end - binaries_beg),
|
|
|
|
" free for reuse");
|
|
|
|
}
|
|
|
|
if (binaries_end != core_virt_end)
|
|
|
|
nova_die();
|
|
|
|
|
|
|
|
/* ROM modules are un-used by core - de-detach region */
|
|
|
|
addr_t const binaries_size = binaries_end - binaries_beg;
|
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
|
|
|
unmap_local(*__main_thread_utcb, binaries_beg, binaries_size >> 12);
|
2016-09-15 16:08:33 +02:00
|
|
|
|
2012-11-27 09:31:00 +01:00
|
|
|
/* preserve Bios Data Area (BDA) in core's virtual address space */
|
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
|
|
|
region_alloc().remove_range(BDA_VIRT_ADDR, 0x1000);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-01-23 14:42:55 +01:00
|
|
|
/* preserve stack area in core's virtual address space */
|
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
|
|
|
region_alloc().remove_range(stack_area_virtual_base(),
|
|
|
|
stack_area_virtual_size());
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-09-04 12:45:27 +02:00
|
|
|
/* exclude utcb of core pager thread + empty guard pages before and after */
|
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
|
|
|
region_alloc().remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
|
|
|
|
get_page_size() * 3);
|
2012-09-04 12:45:27 +02:00
|
|
|
|
|
|
|
/* exclude utcb of main thread and hip + empty guard pages before and after */
|
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
|
|
|
region_alloc().remove_range((addr_t)__main_thread_utcb - get_page_size(),
|
|
|
|
get_page_size() * 4);
|
2012-09-04 12:45:27 +02:00
|
|
|
|
|
|
|
/* sanity checks */
|
|
|
|
addr_t check [] = {
|
|
|
|
reinterpret_cast<addr_t>(__main_thread_utcb), CORE_PAGER_UTCB_ADDR,
|
2018-06-29 14:04:32 +02:00
|
|
|
BDA_VIRT_ADDR
|
2012-09-04 12:45:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < sizeof(check) / sizeof(check[0]); i++) {
|
2016-03-03 17:57:29 +01:00
|
|
|
if (stack_area_virtual_base() <= check[i] &&
|
|
|
|
check[i] < stack_area_virtual_base() + stack_area_virtual_size())
|
2012-09-04 12:45:27 +02:00
|
|
|
{
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("overlapping area - ",
|
|
|
|
Hex_range<addr_t>(stack_area_virtual_base(),
|
|
|
|
stack_area_virtual_size()), " vs ",
|
|
|
|
Hex(check[i]));
|
2012-09-04 12:45:27 +02:00
|
|
|
nova_die();
|
2013-01-11 23:10:21 +01:00
|
|
|
}
|
2012-09-04 12:45:27 +02:00
|
|
|
}
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* initialize core's physical-memory and I/O memory allocator */
|
2012-09-04 12:45:27 +02:00
|
|
|
_io_mem_alloc.add_range(0, ~0xfffUL);
|
2011-12-22 16:19:25 +01:00
|
|
|
Hip::Mem_desc *mem_desc = (Hip::Mem_desc *)mem_desc_base;
|
2015-05-11 14:43:56 +02:00
|
|
|
|
2017-10-30 15:26:35 +01:00
|
|
|
Hip::Mem_desc *boot_fb = nullptr;
|
2017-08-29 18:24:43 +02:00
|
|
|
|
2018-06-06 13:01:54 +02:00
|
|
|
bool efi_boot = false;
|
2018-09-13 16:53:57 +02:00
|
|
|
addr_t kernel_memory = 0;
|
2018-06-06 13:01:54 +02:00
|
|
|
|
2015-05-11 14:43:56 +02:00
|
|
|
/*
|
|
|
|
* All "available" ram must be added to our physical allocator before all
|
|
|
|
* non "available" regions that overlaps with ram get removed.
|
|
|
|
*/
|
2011-12-22 16:19:25 +01:00
|
|
|
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
2018-06-06 13:01:54 +02:00
|
|
|
/* 32/64bit EFI image handle pointer - see multiboot spec 2 */
|
2017-10-30 15:26:35 +01:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER)
|
|
|
|
boot_fb = mem_desc;
|
2018-09-13 16:53:57 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::MICROHYPERVISOR)
|
|
|
|
kernel_memory += mem_desc->size;
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
if (mem_desc->type != Hip::Mem_desc::AVAILABLE_MEMORY) continue;
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
if (verbose_boot_info) {
|
|
|
|
addr_t const base = mem_desc->addr;
|
|
|
|
size_t const size = mem_desc->size;
|
|
|
|
log("detected physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD),
|
|
|
|
" - size: ", Hex(size, Hex::PREFIX, Hex::PAD));
|
|
|
|
}
|
2012-07-09 11:00:03 +02:00
|
|
|
|
2015-11-27 17:07:42 +01:00
|
|
|
if (!mem_desc->size) continue;
|
|
|
|
|
2012-07-09 11:00:03 +02:00
|
|
|
/* skip regions above 4G on 32 bit, no op on 64 bit */
|
|
|
|
if (mem_desc->addr > ~0UL) continue;
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
addr_t base = round_page(mem_desc->addr);
|
2012-07-09 11:00:03 +02:00
|
|
|
size_t size;
|
|
|
|
/* truncate size if base+size larger then natural 32/64 bit boundary */
|
|
|
|
if (mem_desc->addr >= ~0UL - mem_desc->size + 1)
|
|
|
|
size = trunc_page(~0UL - mem_desc->addr + 1);
|
|
|
|
else
|
|
|
|
size = trunc_page(mem_desc->addr + mem_desc->size) - base;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
if (verbose_boot_info)
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
log("use physical memory: ", Hex(base, Hex::PREFIX, Hex::PAD),
|
|
|
|
" - size: ", Hex(size, Hex::PREFIX, Hex::PAD));
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
_io_mem_alloc.remove_range(base, size);
|
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_alloc().add_range(base, size);
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
2016-05-28 20:54:24 +02:00
|
|
|
uint64_t hyp_log = 0;
|
|
|
|
uint64_t hyp_log_size = 0;
|
|
|
|
|
2015-05-11 14:43:56 +02:00
|
|
|
/*
|
|
|
|
* Exclude all non-available memory from physical allocator AFTER all
|
|
|
|
* available RAM was added - otherwise the non-available memory gets not
|
|
|
|
* properly removed from the physical allocator
|
|
|
|
*/
|
2011-12-22 16:19:25 +01:00
|
|
|
mem_desc = (Hip::Mem_desc *)mem_desc_base;
|
|
|
|
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue;
|
|
|
|
|
2016-05-28 20:54:24 +02:00
|
|
|
if (verbose_boot_info)
|
|
|
|
log("detected res memory: ", Hex(mem_desc->addr), " - size: ",
|
|
|
|
Hex(mem_desc->size), " type=", (int)mem_desc->type);
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::HYPERVISOR_LOG) {
|
|
|
|
hyp_log = mem_desc->addr;
|
|
|
|
hyp_log_size = mem_desc->size;
|
|
|
|
}
|
|
|
|
|
2012-07-09 11:00:03 +02:00
|
|
|
/* skip regions above 4G on 32 bit, no op on 64 bit */
|
|
|
|
if (mem_desc->addr > ~0UL) continue;
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
addr_t base = trunc_page(mem_desc->addr);
|
2015-11-27 17:07:42 +01:00
|
|
|
size_t size = mem_desc->size;
|
|
|
|
|
2017-08-29 18:24:43 +02:00
|
|
|
/* remove framebuffer from available memory */
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER) {
|
2017-10-30 15:26:35 +01:00
|
|
|
uint32_t const height = Resolution::Height::get(mem_desc->size);
|
|
|
|
uint32_t const pitch = mem_desc->aux;
|
2017-08-29 18:24:43 +02:00
|
|
|
/* calculate size of framebuffer */
|
2017-10-30 15:26:35 +01:00
|
|
|
size = pitch * height;
|
2017-08-29 18:24:43 +02:00
|
|
|
}
|
|
|
|
|
2012-07-09 11:00:03 +02:00
|
|
|
/* truncate size if base+size larger then natural 32/64 bit boundary */
|
2015-11-27 17:07:42 +01:00
|
|
|
if (mem_desc->addr + size < mem_desc->addr)
|
|
|
|
size = 0UL - base;
|
2012-07-09 11:00:03 +02:00
|
|
|
else
|
2015-11-27 17:07:42 +01:00
|
|
|
size = round_page(mem_desc->addr + size) - base;
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
continue;
|
2012-07-09 11:00:03 +02:00
|
|
|
|
2015-05-11 14:43:56 +02:00
|
|
|
/* make acpi regions as io_mem available to platform driver */
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::ACPI_RECLAIM_MEMORY ||
|
|
|
|
mem_desc->type == Hip::Mem_desc::ACPI_NVS_MEMORY)
|
|
|
|
_io_mem_alloc.add_range(base, size);
|
|
|
|
|
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_alloc().remove_range(base, size);
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* needed as I/O memory by the VESA driver */
|
|
|
|
_io_mem_alloc.add_range(0, 0x1000);
|
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_alloc().remove_range(0, 0x1000);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
/* exclude pages holding multi-boot command lines from core allocators */
|
|
|
|
mem_desc = (Hip::Mem_desc *)mem_desc_base;
|
2013-02-21 17:39:45 +01:00
|
|
|
addr_t prev_cmd_line_page = ~0, curr_cmd_line_page = 0;
|
2011-12-22 16:19:25 +01:00
|
|
|
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
|
|
|
if (mem_desc->type != Hip::Mem_desc::MULTIBOOT_MODULE) continue;
|
2012-07-09 11:00:03 +02:00
|
|
|
if (!mem_desc->aux) continue;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
curr_cmd_line_page = mem_desc->aux >> get_page_size_log2();
|
|
|
|
if (curr_cmd_line_page == prev_cmd_line_page) continue;
|
|
|
|
|
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_alloc().remove_range(curr_cmd_line_page << get_page_size_log2(),
|
|
|
|
get_page_size() * 2);
|
2011-12-22 16:19:25 +01:00
|
|
|
prev_cmd_line_page = curr_cmd_line_page;
|
|
|
|
}
|
|
|
|
|
2015-02-10 21:11:59 +01:00
|
|
|
/* sanity checks that regions don't overlap - could be bootloader issue */
|
|
|
|
mem_desc = (Hip::Mem_desc *)mem_desc_base;
|
|
|
|
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
|
|
|
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue;
|
2017-06-12 22:12:17 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::ACPI_RSDT) continue;
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::ACPI_XSDT) continue;
|
2017-06-12 22:59:08 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::FRAMEBUFFER) continue;
|
2019-07-09 18:27:13 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::EFI_SYSTEM_TABLE) continue;
|
2015-02-10 21:11:59 +01:00
|
|
|
|
|
|
|
Hip::Mem_desc * mem_d = (Hip::Mem_desc *)mem_desc_base;
|
|
|
|
for (unsigned j = 0; j < num_mem_desc; j++, mem_d++) {
|
|
|
|
if (mem_d->type == Hip::Mem_desc::AVAILABLE_MEMORY) continue;
|
2017-06-12 22:12:17 +02:00
|
|
|
if (mem_d->type == Hip::Mem_desc::ACPI_RSDT) continue;
|
|
|
|
if (mem_d->type == Hip::Mem_desc::ACPI_XSDT) continue;
|
2017-06-12 22:59:08 +02:00
|
|
|
if (mem_d->type == Hip::Mem_desc::FRAMEBUFFER) continue;
|
2019-07-09 18:27:13 +02:00
|
|
|
if (mem_d->type == Hip::Mem_desc::EFI_SYSTEM_TABLE) continue;
|
2015-02-10 21:11:59 +01:00
|
|
|
if (mem_d == mem_desc) continue;
|
|
|
|
|
|
|
|
/* if regions are disjunct all is fine */
|
|
|
|
if ((mem_d->addr + mem_d->size <= mem_desc->addr) ||
|
|
|
|
(mem_d->addr >= mem_desc->addr + mem_desc->size))
|
|
|
|
continue;
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("region overlap ",
|
|
|
|
Hex_range<addr_t>(mem_desc->addr, mem_desc->size), " "
|
|
|
|
"(", (int)mem_desc->type, ") with ",
|
|
|
|
Hex_range<addr_t>(mem_d->addr, mem_d->size), " "
|
|
|
|
"(", (int)mem_d->type, ")");
|
2015-02-10 21:11:59 +01:00
|
|
|
nova_die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* From now on, it is save to use the core allocators...
|
|
|
|
*/
|
|
|
|
|
2019-07-09 18:27:13 +02:00
|
|
|
uint64_t efi_sys_tab_phy = 0UL;
|
2017-06-12 22:12:17 +02:00
|
|
|
uint64_t rsdt = 0UL;
|
|
|
|
uint64_t xsdt = 0UL;
|
|
|
|
|
2016-09-15 16:08:33 +02:00
|
|
|
mem_desc = (Hip::Mem_desc *)mem_desc_base;
|
2011-12-22 16:19:25 +01:00
|
|
|
for (unsigned i = 0; i < num_mem_desc; i++, mem_desc++) {
|
2019-07-09 18:27:13 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::EFI_SYSTEM_TABLE) efi_sys_tab_phy = mem_desc->addr;
|
2017-06-12 22:12:17 +02:00
|
|
|
if (mem_desc->type == Hip::Mem_desc::ACPI_RSDT) rsdt = mem_desc->addr;
|
|
|
|
if (mem_desc->type == Hip::Mem_desc::ACPI_XSDT) xsdt = mem_desc->addr;
|
2011-12-22 16:19:25 +01:00
|
|
|
if (mem_desc->type != Hip::Mem_desc::MULTIBOOT_MODULE) continue;
|
2017-06-12 22:12:17 +02:00
|
|
|
if (!mem_desc->addr || !mem_desc->size) continue;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-09-15 16:08:33 +02:00
|
|
|
/* assume core's ELF image has one-page header */
|
2017-08-17 16:20:56 +02:00
|
|
|
_core_phys_start = trunc_page(mem_desc->addr + get_page_size());
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
2017-08-17 16:20:56 +02:00
|
|
|
_init_rom_modules();
|
|
|
|
|
2017-06-12 22:12:17 +02:00
|
|
|
{
|
|
|
|
/* export x86 platform specific infos */
|
|
|
|
|
|
|
|
unsigned const pages = 1;
|
2018-10-25 16:31:16 +02:00
|
|
|
void * phys_ptr = nullptr;
|
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
|
|
|
if (ram_alloc().alloc_aligned(get_page_size(), &phys_ptr,
|
|
|
|
get_page_size_log2()).ok()) {
|
2018-10-25 16:31:16 +02:00
|
|
|
|
|
|
|
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
|
|
|
|
addr_t const core_local_addr = _map_pages(phys_addr, pages);
|
|
|
|
|
|
|
|
if (!core_local_addr) {
|
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_alloc().free(phys_ptr);
|
2018-10-25 16:31:16 +02:00
|
|
|
} else {
|
|
|
|
|
|
|
|
Genode::Xml_generator xml(reinterpret_cast<char *>(core_local_addr),
|
|
|
|
pages << get_page_size_log2(),
|
|
|
|
"platform_info", [&] ()
|
|
|
|
{
|
2019-04-17 12:51:39 +02:00
|
|
|
xml.node("kernel", [&] () { xml.attribute("name", "nova"); });
|
2019-07-09 18:27:13 +02:00
|
|
|
if (efi_sys_tab_phy) {
|
|
|
|
xml.node("efi-system-table", [&] () {
|
|
|
|
xml.attribute("address", String<32>(Hex(efi_sys_tab_phy)));
|
|
|
|
});
|
|
|
|
}
|
2018-10-25 16:31:16 +02:00
|
|
|
xml.node("acpi", [&] () {
|
|
|
|
|
|
|
|
xml.attribute("revision", 2); /* XXX */
|
|
|
|
|
|
|
|
if (rsdt)
|
|
|
|
xml.attribute("rsdt", String<32>(Hex(rsdt)));
|
|
|
|
|
|
|
|
if (xsdt)
|
|
|
|
xml.attribute("xsdt", String<32>(Hex(xsdt)));
|
|
|
|
});
|
|
|
|
xml.node("boot", [&] () {
|
|
|
|
if (!boot_fb)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!efi_boot && (Resolution::Type::get(boot_fb->size) != Resolution::Type::VGA_TEXT))
|
|
|
|
return;
|
|
|
|
|
|
|
|
xml.node("framebuffer", [&] () {
|
|
|
|
xml.attribute("phys", String<32>(Hex(boot_fb->addr)));
|
|
|
|
xml.attribute("width", Resolution::Width::get(boot_fb->size));
|
|
|
|
xml.attribute("height", Resolution::Height::get(boot_fb->size));
|
|
|
|
xml.attribute("bpp", Resolution::Bpp::get(boot_fb->size));
|
|
|
|
xml.attribute("type", Resolution::Type::get(boot_fb->size));
|
|
|
|
xml.attribute("pitch", boot_fb->aux);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
xml.node("hardware", [&] () {
|
|
|
|
xml.node("features", [&] () {
|
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
|
|
|
xml.attribute("svm", hip.has_feature_svm());
|
|
|
|
xml.attribute("vmx", hip.has_feature_vmx());
|
2018-10-25 16:31:16 +02:00
|
|
|
});
|
|
|
|
xml.node("tsc", [&] () {
|
|
|
|
xml.attribute("invariant", cpuid_invariant_tsc());
|
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
|
|
|
xml.attribute("freq_khz" , hip.tsc_freq);
|
2018-10-25 16:31:16 +02:00
|
|
|
});
|
|
|
|
xml.node("cpus", [&] () {
|
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
|
|
|
unsigned const cpus = hip.cpus();
|
2018-10-25 16:31:16 +02:00
|
|
|
for (unsigned i = 0; i < cpus; i++) {
|
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
|
|
|
|
|
|
|
Hip::Cpu_desc const * const cpu_desc_ptr =
|
|
|
|
hip.cpu_desc_of_cpu(Platform::kernel_cpu_id(i));
|
|
|
|
|
|
|
|
if (!cpu_desc_ptr)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Hip::Cpu_desc const &cpu_desc = *cpu_desc_ptr;
|
|
|
|
|
2018-10-25 16:31:16 +02:00
|
|
|
xml.node("cpu", [&] () {
|
|
|
|
xml.attribute("id", i);
|
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
|
|
|
xml.attribute("package", cpu_desc.package);
|
|
|
|
xml.attribute("core", cpu_desc.core);
|
|
|
|
xml.attribute("thread", cpu_desc.thread);
|
|
|
|
xml.attribute("family", String<5>(Hex(cpu_desc.family)));
|
|
|
|
xml.attribute("model", String<5>(Hex(cpu_desc.model)));
|
|
|
|
xml.attribute("stepping", String<5>(Hex(cpu_desc.stepping)));
|
|
|
|
xml.attribute("platform", String<5>(Hex(cpu_desc.platform)));
|
|
|
|
xml.attribute("patch", String<12>(Hex(cpu_desc.patch)));
|
2018-10-25 16:31:16 +02:00
|
|
|
});
|
|
|
|
}
|
2018-08-06 12:32:16 +02:00
|
|
|
});
|
2018-10-25 16:31:16 +02:00
|
|
|
});
|
2018-08-06 12:32:16 +02:00
|
|
|
});
|
2017-06-12 22:12:17 +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
|
|
|
unmap_local(*__main_thread_utcb, core_local_addr, pages);
|
|
|
|
region_alloc().free(reinterpret_cast<void *>(core_local_addr),
|
|
|
|
pages * get_page_size());
|
2017-06-12 22:12:17 +02:00
|
|
|
|
2018-10-25 16:31:16 +02:00
|
|
|
_rom_fs.insert(new (core_mem_alloc())
|
|
|
|
Rom_module(phys_addr, pages * get_page_size(),
|
|
|
|
"platform_info"));
|
|
|
|
}
|
|
|
|
}
|
2017-06-12 22:12:17 +02:00
|
|
|
}
|
|
|
|
|
2017-12-11 13:05:23 +01:00
|
|
|
/* core log as ROM module */
|
|
|
|
{
|
|
|
|
void * phys_ptr = nullptr;
|
2018-09-13 16:53:57 +02:00
|
|
|
unsigned const pages = 4;
|
2017-12-11 13:05:23 +01:00
|
|
|
size_t const log_size = pages << get_page_size_log2();
|
|
|
|
|
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
|
|
|
if (ram_alloc().alloc_aligned(log_size, &phys_ptr,
|
|
|
|
get_page_size_log2()).ok()) {
|
2018-10-25 16:31:16 +02:00
|
|
|
|
|
|
|
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
|
2017-12-11 13:05:23 +01:00
|
|
|
|
2018-10-25 16:31:16 +02:00
|
|
|
addr_t const virt = _map_pages(phys_addr, pages, true);
|
|
|
|
if (virt) {
|
|
|
|
memset(reinterpret_cast<void *>(virt), 0, log_size);
|
2017-12-11 13:05:23 +01:00
|
|
|
|
2018-10-25 16:31:16 +02:00
|
|
|
_rom_fs.insert(new (core_mem_alloc()) Rom_module(phys_addr, log_size,
|
|
|
|
"core_log"));
|
2017-12-11 13:05:23 +01:00
|
|
|
|
2018-10-25 16:31:16 +02:00
|
|
|
init_core_log( Core_log_range { virt, log_size } );
|
|
|
|
} else
|
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_alloc().free(phys_ptr);
|
2018-10-25 16:31:16 +02:00
|
|
|
}
|
2017-12-11 13:05:23 +01:00
|
|
|
}
|
|
|
|
|
2016-05-28 20:54:24 +02:00
|
|
|
/* export hypervisor log memory */
|
|
|
|
if (hyp_log && hyp_log_size)
|
|
|
|
_rom_fs.insert(new (core_mem_alloc()) Rom_module(hyp_log, hyp_log_size,
|
|
|
|
"kernel_log"));
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* I/O port allocator (only meaningful for x86) */
|
|
|
|
_io_port_alloc.add_range(0, 0x10000);
|
|
|
|
|
|
|
|
/* IRQ allocator */
|
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
|
|
|
_irq_alloc.add_range(0, hip.sel_gsi);
|
|
|
|
_gsi_base_sel = (hip.mem_desc_offset - hip.cpu_desc_offset) / hip.cpu_desc_size;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2017-12-13 19:52:06 +01:00
|
|
|
log(_rom_fs);
|
2013-09-11 10:42:33 +02:00
|
|
|
|
2018-09-13 16:53:57 +02:00
|
|
|
log(Number_of_bytes(kernel_memory), " kernel memory"); log("");
|
|
|
|
|
2013-09-11 10:42:33 +02:00
|
|
|
/* add capability selector ranges to map */
|
2017-05-07 22:44:15 +02:00
|
|
|
unsigned const first_index = 0x2000;
|
|
|
|
unsigned index = first_index;
|
2015-07-14 16:19:14 +02:00
|
|
|
for (unsigned i = 0; i < 32; i++)
|
2013-09-11 10:42:33 +02:00
|
|
|
{
|
2018-10-25 16:31:16 +02:00
|
|
|
void * phys_ptr = nullptr;
|
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
|
|
|
if (ram_alloc().alloc_aligned(get_page_size(), &phys_ptr,
|
|
|
|
get_page_size_log2()).error())
|
2018-10-25 16:31:16 +02:00
|
|
|
break;
|
2013-09-11 10:42:33 +02:00
|
|
|
|
|
|
|
addr_t phys_addr = reinterpret_cast<addr_t>(phys_ptr);
|
2017-12-11 13:05:23 +01:00
|
|
|
addr_t core_local_addr = _map_pages(phys_addr, 1);
|
2018-10-25 16:31:16 +02:00
|
|
|
|
|
|
|
if (!core_local_addr) {
|
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_alloc().free(phys_ptr);
|
2018-10-25 16:31:16 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
Cap_range &range = *reinterpret_cast<Cap_range *>(core_local_addr);
|
|
|
|
construct_at<Cap_range>(&range, index);
|
2013-09-11 10:42:33 +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
|
|
|
cap_map().insert(range);
|
2013-09-11 10:42:33 +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
|
|
|
index = range.base() + range.elements();
|
2013-09-11 10:42:33 +02:00
|
|
|
}
|
2017-05-07 22:44:15 +02:00
|
|
|
_max_caps = index - first_index;
|
2015-06-16 20:39:09 +02:00
|
|
|
|
|
|
|
/* add idle ECs to trace sources */
|
2016-11-04 13:01:09 +01:00
|
|
|
for (unsigned genode_cpu_id = 0; genode_cpu_id < _cpus.width(); genode_cpu_id++) {
|
2015-06-30 13:19:01 +02:00
|
|
|
|
2016-11-04 13:01:09 +01:00
|
|
|
unsigned kernel_cpu_id = Platform::kernel_cpu_id(genode_cpu_id);
|
|
|
|
|
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
|
|
|
if (!hip.is_cpu_enabled(kernel_cpu_id))
|
2015-06-30 13:19:01 +02:00
|
|
|
continue;
|
2015-06-16 20:39:09 +02:00
|
|
|
|
2017-09-07 23:08:07 +02:00
|
|
|
struct Trace_source : public Trace::Source::Info_accessor,
|
|
|
|
private Trace::Control,
|
|
|
|
private Trace::Source
|
2015-06-16 20:39:09 +02:00
|
|
|
{
|
|
|
|
Affinity::Location const affinity;
|
|
|
|
unsigned const sc_sel;
|
2017-09-07 23:08:07 +02:00
|
|
|
Genode::String<8> const name;
|
2015-06-16 20:39:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trace::Source::Info_accessor interface
|
|
|
|
*/
|
|
|
|
Info trace_source_info() const override
|
|
|
|
{
|
2018-01-17 11:59:08 +01:00
|
|
|
uint64_t sc_time = 0;
|
2015-06-16 20:39:09 +02:00
|
|
|
|
2017-09-07 23:08:07 +02:00
|
|
|
enum SYSCALL_OP { IDLE_SC = 0, CROSS_SC = 1 };
|
|
|
|
uint8_t syscall_op = (name == "cross") ? CROSS_SC : IDLE_SC;
|
|
|
|
|
|
|
|
uint8_t res = Nova::sc_ctrl(sc_sel, sc_time, syscall_op);
|
2018-01-17 11:59:08 +01:00
|
|
|
if (res != Nova::NOVA_OK)
|
2017-09-07 23:08:07 +02:00
|
|
|
warning("sc_ctrl on idle SC cap, op=", syscall_op,
|
|
|
|
", res=", res);
|
2015-06-16 20:39:09 +02:00
|
|
|
|
2017-09-07 23:08:07 +02:00
|
|
|
return { Session_label("kernel"), Trace::Thread_name(name),
|
2017-09-11 13:03:28 +02:00
|
|
|
Trace::Execution_time(sc_time, sc_time), affinity };
|
2015-06-16 20:39:09 +02:00
|
|
|
}
|
|
|
|
|
2017-09-07 23:08:07 +02:00
|
|
|
Trace_source(Trace::Source_registry ®istry,
|
|
|
|
Affinity::Location const affinity,
|
|
|
|
unsigned const sc_sel,
|
|
|
|
char const * type_name)
|
2015-06-16 20:39:09 +02: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
|
|
|
Trace::Control(),
|
2017-09-07 23:08:07 +02:00
|
|
|
Trace::Source(*this, *this), affinity(affinity),
|
|
|
|
sc_sel(sc_sel), name(type_name)
|
2018-01-17 11:59:08 +01:00
|
|
|
{
|
|
|
|
registry.insert(this);
|
|
|
|
}
|
2015-06-16 20:39:09 +02:00
|
|
|
};
|
|
|
|
|
2017-09-07 23:08:07 +02:00
|
|
|
new (core_mem_alloc()) Trace_source(Trace::sources(),
|
|
|
|
Affinity::Location(genode_cpu_id, 0,
|
|
|
|
_cpus.width(), 1),
|
|
|
|
sc_idle_base + kernel_cpu_id,
|
|
|
|
"idle");
|
|
|
|
|
|
|
|
new (core_mem_alloc()) Trace_source(Trace::sources(),
|
|
|
|
Affinity::Location(genode_cpu_id, 0,
|
|
|
|
_cpus.width(), 1),
|
|
|
|
sc_idle_base + kernel_cpu_id,
|
|
|
|
"cross");
|
2015-06-16 20:39:09 +02:00
|
|
|
}
|
2018-01-17 11:59:08 +01:00
|
|
|
|
2018-06-29 14:04:32 +02:00
|
|
|
/* add exception handler EC for core and EC root thread to trace sources */
|
2018-01-17 11:59:08 +01:00
|
|
|
struct Core_trace_source : public Trace::Source::Info_accessor,
|
|
|
|
private Trace::Control,
|
|
|
|
private Trace::Source
|
|
|
|
{
|
|
|
|
Affinity::Location const location;
|
|
|
|
addr_t const ec_sc_sel;
|
|
|
|
Genode::String<8> const name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trace::Source::Info_accessor interface
|
|
|
|
*/
|
|
|
|
Info trace_source_info() const override
|
|
|
|
{
|
|
|
|
uint64_t sc_time = 0;
|
|
|
|
|
|
|
|
if (name == "root") {
|
|
|
|
uint8_t res = Nova::sc_ctrl(ec_sc_sel + 1, sc_time);
|
|
|
|
if (res != Nova::NOVA_OK)
|
|
|
|
warning("sc_ctrl for ", name, " thread failed res=", res);
|
|
|
|
}
|
|
|
|
|
|
|
|
return { Session_label("core"), name,
|
2017-09-11 13:03:28 +02:00
|
|
|
Trace::Execution_time(sc_time, sc_time), location };
|
2018-01-17 11:59:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Core_trace_source(Trace::Source_registry ®istry,
|
|
|
|
Affinity::Location loc, addr_t sel,
|
|
|
|
char const *name)
|
|
|
|
:
|
|
|
|
Trace::Control(),
|
|
|
|
Trace::Source(*this, *this), location(loc), ec_sc_sel(sel),
|
|
|
|
name(name)
|
|
|
|
{
|
|
|
|
registry.insert(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
new (core_mem_alloc())
|
|
|
|
Core_trace_source(Trace::sources(),
|
|
|
|
Affinity::Location(0, 0, _cpus.width(), 1),
|
2018-06-29 14:04:32 +02:00
|
|
|
ec_core_exc_sel, "core_fault");
|
2018-01-17 11:59:08 +01:00
|
|
|
|
|
|
|
new (core_mem_alloc())
|
|
|
|
Core_trace_source(Trace::sources(),
|
|
|
|
Affinity::Location(0, 0, _cpus.width(), 1),
|
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
|
|
|
hip.sel_exc + 1, "root");
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-08-17 16:20:56 +02:00
|
|
|
addr_t Platform::_rom_module_phys(addr_t virt)
|
|
|
|
{
|
|
|
|
return virt - (addr_t)&_prog_img_beg + _core_phys_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-11-04 13:01:09 +01:00
|
|
|
unsigned Platform::kernel_cpu_id(unsigned genode_cpu_id)
|
|
|
|
{
|
|
|
|
if (genode_cpu_id >= sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0])) {
|
|
|
|
error("invalid genode cpu id ", genode_cpu_id);
|
|
|
|
return ~0U;
|
|
|
|
}
|
|
|
|
return map_cpu_ids[genode_cpu_id];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/****************************************
|
|
|
|
** Support for core memory management **
|
|
|
|
****************************************/
|
|
|
|
|
2015-09-17 14:16:59 +02:00
|
|
|
bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
|
|
|
|
unsigned size)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2018-06-29 14:04:32 +02:00
|
|
|
/* platform_specific()->core_pd_sel() deadlocks if called from platform constructor */
|
2019-05-06 14:09:26 +02:00
|
|
|
Hip const &hip = *(Hip const *)__initial_sp;
|
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
|
|
|
Genode::addr_t const core_pd_sel = hip.sel_exc;
|
2018-06-29 14:04:32 +02:00
|
|
|
|
|
|
|
map_local(core_pd_sel,
|
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
|
|
|
*(Utcb *)Thread::myself()->utcb(), phys_addr,
|
2014-03-10 15:24:53 +01:00
|
|
|
virt_addr, size / get_page_size(),
|
2017-10-13 14:18:29 +02:00
|
|
|
Rights(true, true, false), true);
|
2011-12-22 16:19:25 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t, unsigned size)
|
2014-03-10 15:24:53 +01: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
|
|
|
unmap_local(*(Utcb *)Thread::myself()->utcb(),
|
2014-03-10 15:24:53 +01:00
|
|
|
virt_addr, size / get_page_size());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/********************************
|
|
|
|
** Generic platform interface **
|
|
|
|
********************************/
|
|
|
|
|
2020-01-22 16:58:21 +01:00
|
|
|
void Platform::wait_for_exit() { sleep_forever(); }
|
2011-12-22 16:19:25 +01:00
|
|
|
|