2015-02-06 17:29:30 +01:00
|
|
|
/*
|
2015-08-24 15:35:54 +02:00
|
|
|
* \brief Kernel back-end for execution contexts in userland
|
2015-02-06 17:29:30 +01:00
|
|
|
* \author Martin Stein
|
2015-03-13 09:20:28 +01:00
|
|
|
* \author Reto Buerki
|
2015-02-06 17:29:30 +01:00
|
|
|
* \author Stefan Kalkowski
|
|
|
|
* \date 2013-11-11
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2013-2017 Genode Labs GmbH
|
2015-02-06 17:29:30 +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.
|
2015-02-06 17:29:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* core includes */
|
2017-10-06 12:02:36 +02:00
|
|
|
#include <kernel/cpu.h>
|
2015-02-06 17:29:30 +01:00
|
|
|
#include <kernel/thread.h>
|
|
|
|
#include <kernel/pd.h>
|
|
|
|
|
2018-11-26 11:18:57 +01:00
|
|
|
void Kernel::Thread::Pd_update::execute()
|
|
|
|
{
|
|
|
|
/* invalidate cpu-local TLB */
|
|
|
|
Cpu::invalidate_tlb();
|
2016-09-22 11:53:09 +02:00
|
|
|
|
2018-11-26 11:18:57 +01:00
|
|
|
/* if this is the last cpu, wake up the caller thread */
|
|
|
|
if (--cnt == 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
|
|
|
cpu_pool().work_list().remove(&_le);
|
2018-11-26 11:18:57 +01:00
|
|
|
caller._restart();
|
|
|
|
}
|
|
|
|
};
|
2016-09-22 11:53:09 +02:00
|
|
|
|
|
|
|
|
2018-11-26 11:18:57 +01:00
|
|
|
void Kernel::Thread::_call_update_data_region() { }
|
2016-09-22 11:53:09 +02:00
|
|
|
|
|
|
|
|
2018-11-26 11:18:57 +01:00
|
|
|
void Kernel::Thread::_call_update_instr_region() { }
|
2017-06-30 12:00:27 +02:00
|
|
|
|
|
|
|
|
2017-10-06 12:02:36 +02:00
|
|
|
void Kernel::Thread::proceed(Cpu & cpu)
|
2017-06-30 12:00:27 +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.switch_to(*regs, pd().mmu_regs);
|
2017-06-30 12:00:27 +02:00
|
|
|
|
|
|
|
asm volatile("mov %0, %%rsp \n"
|
|
|
|
"popq %%r8 \n"
|
|
|
|
"popq %%r9 \n"
|
|
|
|
"popq %%r10 \n"
|
|
|
|
"popq %%r11 \n"
|
|
|
|
"popq %%r12 \n"
|
|
|
|
"popq %%r13 \n"
|
|
|
|
"popq %%r14 \n"
|
|
|
|
"popq %%r15 \n"
|
|
|
|
"popq %%rax \n"
|
|
|
|
"popq %%rbx \n"
|
|
|
|
"popq %%rcx \n"
|
|
|
|
"popq %%rdx \n"
|
|
|
|
"popq %%rdi \n"
|
|
|
|
"popq %%rsi \n"
|
|
|
|
"popq %%rbp \n"
|
|
|
|
"add $16, %%rsp \n"
|
|
|
|
"iretq \n" :: "r" (®s->r8));
|
|
|
|
}
|
2017-10-06 12:02:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
void Kernel::Thread::user_arg_0(Kernel::Call_arg const arg) { regs->rdi = arg; }
|
|
|
|
void Kernel::Thread::user_arg_1(Kernel::Call_arg const arg) { regs->rsi = arg; }
|
|
|
|
void Kernel::Thread::user_arg_2(Kernel::Call_arg const arg) { regs->rdx = arg; }
|
|
|
|
void Kernel::Thread::user_arg_3(Kernel::Call_arg const arg) { regs->rcx = arg; }
|
|
|
|
void Kernel::Thread::user_arg_4(Kernel::Call_arg const arg) { regs->r8 = arg; }
|
|
|
|
|
|
|
|
Kernel::Call_arg Kernel::Thread::user_arg_0() const { return regs->rdi; }
|
|
|
|
Kernel::Call_arg Kernel::Thread::user_arg_1() const { return regs->rsi; }
|
|
|
|
Kernel::Call_arg Kernel::Thread::user_arg_2() const { return regs->rdx; }
|
|
|
|
Kernel::Call_arg Kernel::Thread::user_arg_3() const { return regs->rcx; }
|
|
|
|
Kernel::Call_arg Kernel::Thread::user_arg_4() const { return regs->r8; }
|