2014-10-10 16:13:52 +02:00
|
|
|
/*
|
|
|
|
* \brief Class for kernel data that is needed to manage a specific CPU
|
|
|
|
* \author Martin Stein
|
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2014-01-14
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-10-10 16:13:52 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2014-10-10 16:13:52 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* core includes */
|
|
|
|
#include <kernel/cpu.h>
|
|
|
|
#include <kernel/kernel.h>
|
|
|
|
#include <kernel/thread.h>
|
|
|
|
#include <kernel/irq.h>
|
2015-05-19 14:18:40 +02:00
|
|
|
#include <kernel/pd.h>
|
2019-05-16 14:20:39 +02:00
|
|
|
#include <board.h>
|
2017-02-21 13:46:59 +01:00
|
|
|
#include <hw/assert.h>
|
2018-11-26 11:18:57 +01:00
|
|
|
#include <hw/boot_info.h>
|
2014-10-10 16:13:52 +02:00
|
|
|
|
2016-01-20 18:27:18 +01:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/unmanaged_singleton.h>
|
2014-10-10 16:13:52 +02:00
|
|
|
|
|
|
|
using namespace Kernel;
|
|
|
|
|
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
|
|
|
Kernel::Cpu_pool &Kernel::cpu_pool() { return *unmanaged_singleton<Cpu_pool>(); }
|
2014-10-10 16:13:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************
|
|
|
|
** Cpu_job **
|
|
|
|
*************/
|
|
|
|
|
2014-12-01 15:10:33 +01:00
|
|
|
void Cpu_job::_activate_own_share() { _cpu->schedule(this); }
|
2014-10-10 16:13:52 +02:00
|
|
|
|
|
|
|
|
2014-12-01 15:10:33 +01:00
|
|
|
void Cpu_job::_deactivate_own_share()
|
2014-10-10 16:13:52 +02:00
|
|
|
{
|
|
|
|
assert(_cpu->id() == Cpu::executing_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
|
|
|
_cpu->scheduler().unready(this);
|
2014-10-10 16:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Cpu_job::_yield()
|
|
|
|
{
|
|
|
|
assert(_cpu->id() == Cpu::executing_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
|
|
|
_cpu->scheduler().yield();
|
2014-10-10 16:13:52 +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
|
|
|
void Cpu_job::_interrupt(unsigned const /* cpu_id */)
|
2014-10-10 16:13:52 +02:00
|
|
|
{
|
|
|
|
/* determine handling for specific interrupt */
|
|
|
|
unsigned irq_id;
|
2019-07-10 13:30:54 +02:00
|
|
|
if (_cpu->pic().take_request(irq_id))
|
2014-10-10 16:13:52 +02:00
|
|
|
|
2015-02-18 14:23:54 +01:00
|
|
|
/* is the interrupt a cpu-local one */
|
|
|
|
if (!_cpu->interrupt(irq_id)) {
|
2014-10-10 16:13:52 +02:00
|
|
|
|
2015-02-18 14:23:54 +01:00
|
|
|
/* it needs to be a user interrupt */
|
|
|
|
User_irq * irq = User_irq::object(irq_id);
|
|
|
|
if (irq) irq->occurred();
|
2019-04-05 13:50:34 +02:00
|
|
|
else Genode::raw("Unknown interrupt ", irq_id);
|
2014-10-10 16:13:52 +02:00
|
|
|
}
|
2015-02-18 14:23:54 +01:00
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
/* end interrupt request at controller */
|
2019-07-10 13:30:54 +02:00
|
|
|
_cpu->pic().finish_request();
|
2014-10-10 16:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
void Cpu_job::affinity(Cpu &cpu)
|
2014-10-10 16:13:52 +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
|
|
|
_cpu = &cpu;
|
|
|
|
_cpu->scheduler().insert(this);
|
2014-10-10 16:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-20 09:22:02 +01:00
|
|
|
void Cpu_job::quota(unsigned const q)
|
|
|
|
{
|
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 (_cpu) { _cpu->scheduler().quota(this, q); }
|
2015-03-20 09:22:02 +01:00
|
|
|
else { Cpu_share::quota(q); }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-16 11:25:23 +02:00
|
|
|
Cpu_job::Cpu_job(Cpu_priority const p, unsigned const q)
|
2016-05-18 12:20:04 +02:00
|
|
|
:
|
|
|
|
Cpu_share(p, q), _cpu(0) { }
|
2015-04-16 11:25:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
Cpu_job::~Cpu_job()
|
|
|
|
{
|
|
|
|
if (!_cpu) { return; }
|
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
|
|
|
_cpu->scheduler().remove(this);
|
2015-04-16 11:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
/*********
|
|
|
|
** Cpu **
|
|
|
|
*********/
|
|
|
|
|
2017-10-05 16:11:24 +02:00
|
|
|
extern "C" void idle_thread_main(void);
|
|
|
|
|
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
|
|
|
Cpu::Idle_thread::Idle_thread(Cpu &cpu)
|
2017-10-05 16:11:24 +02:00
|
|
|
: Thread("idle")
|
|
|
|
{
|
|
|
|
regs->ip = (addr_t)&idle_thread_main;
|
|
|
|
|
|
|
|
affinity(cpu);
|
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
|
|
|
Thread::_pd = &core_pd();
|
2017-10-05 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-10 16:13:52 +02:00
|
|
|
void Cpu::schedule(Job * const job)
|
|
|
|
{
|
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
|
|
|
if (_id == executing_id()) { _scheduler.ready(&job->share()); }
|
|
|
|
else if (_scheduler.ready_check(&job->share())) { trigger_ip_interrupt(); }
|
2014-10-10 16:13:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-16 11:25:23 +02:00
|
|
|
bool Cpu::interrupt(unsigned const irq_id)
|
|
|
|
{
|
|
|
|
Irq * const irq = object(irq_id);
|
|
|
|
if (!irq) return false;
|
|
|
|
irq->occurred();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-09 12:02:00 +01:00
|
|
|
Cpu_job & Cpu::schedule()
|
2015-04-16 11:25:23 +02:00
|
|
|
{
|
|
|
|
/* update scheduler */
|
2016-05-18 12:20:04 +02:00
|
|
|
Job & old_job = scheduled_job();
|
2017-10-06 12:02:36 +02:00
|
|
|
old_job.exception(*this);
|
2015-04-16 11:25:23 +02:00
|
|
|
|
2019-02-20 15:26:56 +01:00
|
|
|
if (_scheduler.need_to_schedule()) {
|
|
|
|
_timer.process_timeouts();
|
2019-02-21 17:23:10 +01:00
|
|
|
_scheduler.update(_timer.time());
|
|
|
|
time_t t = _scheduler.head_quota();
|
|
|
|
_timer.set_timeout(this, t);
|
2019-04-09 11:34:32 +02:00
|
|
|
time_t duration = _timer.schedule_timeout();
|
|
|
|
old_job.update_execution_time(duration);
|
2019-02-20 15:26:56 +01:00
|
|
|
}
|
2015-04-16 11:25:23 +02:00
|
|
|
|
2015-12-09 12:02:00 +01:00
|
|
|
/* return new job */
|
2019-02-20 15:26:56 +01:00
|
|
|
return scheduled_job();
|
2015-04-16 11:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-06 12:02:36 +02:00
|
|
|
Genode::size_t kernel_stack_size = Cpu::KERNEL_STACK_SIZE;
|
|
|
|
Genode::uint8_t kernel_stack[NR_OF_CPUS][Cpu::KERNEL_STACK_SIZE]
|
|
|
|
__attribute__((aligned(Genode::get_page_size())));
|
|
|
|
|
|
|
|
|
|
|
|
addr_t Cpu::stack_start() {
|
|
|
|
return (addr_t)&kernel_stack + KERNEL_STACK_SIZE * (_id+1); }
|
|
|
|
|
|
|
|
|
2019-10-09 14:40:30 +02:00
|
|
|
Cpu::Cpu(unsigned const id,
|
2018-11-26 11:18:57 +01:00
|
|
|
Inter_processor_work_list & global_work_list)
|
2016-05-18 12:20:04 +02:00
|
|
|
:
|
2019-10-09 14:40:30 +02:00
|
|
|
_id(id), _timer(*this),
|
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
|
|
|
_scheduler(&_idle, _quota(), _fill()), _idle(*this),
|
2019-02-20 15:26:56 +01:00
|
|
|
_ipi_irq(*this),
|
2018-11-26 11:18:57 +01:00
|
|
|
_global_work_list(global_work_list)
|
|
|
|
{ _arch_init(); }
|
2015-04-16 11:25:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**************
|
|
|
|
** Cpu_pool **
|
|
|
|
**************/
|
|
|
|
|
2019-07-10 13:30:54 +02:00
|
|
|
bool Cpu_pool::initialize()
|
2015-04-16 11:25:23 +02:00
|
|
|
{
|
2018-11-26 11:18:57 +01:00
|
|
|
unsigned id = Cpu::executing_id();
|
2019-10-09 14:40:30 +02:00
|
|
|
_cpus[id].construct(id, _global_work_list);
|
2018-11-26 11:18:57 +01:00
|
|
|
return --_initialized == 0;
|
2015-04-16 11:25:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-26 11:18:57 +01:00
|
|
|
Cpu & Cpu_pool::cpu(unsigned const id)
|
2015-04-16 11:25:23 +02:00
|
|
|
{
|
2018-11-26 11:18:57 +01:00
|
|
|
assert(id < _count && _cpus[id].constructed());
|
|
|
|
return *_cpus[id];
|
2015-04-16 11:25:23 +02:00
|
|
|
}
|
2015-05-19 14:18:40 +02:00
|
|
|
|
|
|
|
|
2019-05-16 14:20:39 +02:00
|
|
|
using Boot_info = Hw::Boot_info<Board::Boot_info>;
|
2018-11-26 11:18:57 +01:00
|
|
|
Cpu_pool::Cpu_pool()
|
2019-05-16 14:20:39 +02:00
|
|
|
: _count(reinterpret_cast<Boot_info*>(Hw::Mm::boot_info().base)->cpus) { }
|