mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
f0ac145471
commit
e2268c09a0
@ -14,7 +14,7 @@
|
||||
#ifndef _KERNEL__INTERFACE_H_
|
||||
#define _KERNEL__INTERFACE_H_
|
||||
|
||||
/* Genode includes */
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface_support.h>
|
||||
|
||||
namespace Genode
|
||||
@ -26,48 +26,27 @@ namespace Genode
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
typedef Genode::Tlb Tlb;
|
||||
typedef Genode::addr_t addr_t;
|
||||
typedef Genode::size_t size_t;
|
||||
typedef Genode::Platform_pd Platform_pd;
|
||||
typedef Genode::Native_utcb Native_utcb;
|
||||
typedef Genode::Tlb Tlb;
|
||||
typedef Genode::addr_t addr_t;
|
||||
typedef Genode::size_t size_t;
|
||||
typedef Genode::Platform_pd Platform_pd;
|
||||
typedef Genode::Native_utcb Native_utcb;
|
||||
|
||||
/**
|
||||
* Kernel names of all kernel calls
|
||||
* Kernel names of the kernel calls
|
||||
*/
|
||||
struct Call_id
|
||||
{
|
||||
enum {
|
||||
NEW_THREAD = 0,
|
||||
BIN_THREAD = 1,
|
||||
START_THREAD = 2,
|
||||
PAUSE_THREAD = 3,
|
||||
RESUME_THREAD = 4,
|
||||
YIELD_THREAD = 5,
|
||||
ACCESS_THREAD_REGS = 6,
|
||||
ROUTE_THREAD_EVENT = 7,
|
||||
UPDATE_PD = 8,
|
||||
UPDATE_REGION = 9,
|
||||
NEW_PD = 10,
|
||||
BIN_PD = 11,
|
||||
SEND_REQUEST_MSG = 12,
|
||||
SEND_REPLY_MSG = 13,
|
||||
AWAIT_REQUEST_MSG = 14,
|
||||
NEW_SIGNAL_RECEIVER = 15,
|
||||
NEW_SIGNAL_CONTEXT = 16,
|
||||
KILL_SIGNAL_CONTEXT = 17,
|
||||
BIN_SIGNAL_CONTEXT = 18,
|
||||
BIN_SIGNAL_RECEIVER = 19,
|
||||
SUBMIT_SIGNAL = 20,
|
||||
AWAIT_SIGNAL = 21,
|
||||
SIGNAL_PENDING = 22,
|
||||
ACK_SIGNAL = 23,
|
||||
NEW_VM = 24,
|
||||
RUN_VM = 25,
|
||||
PAUSE_VM = 26,
|
||||
PRINT_CHAR = 27,
|
||||
};
|
||||
};
|
||||
constexpr Call_arg call_id_pause_thread() { return 0; }
|
||||
constexpr Call_arg call_id_resume_thread() { return 1; }
|
||||
constexpr Call_arg call_id_yield_thread() { return 2; }
|
||||
constexpr Call_arg call_id_send_request_msg() { return 3; }
|
||||
constexpr Call_arg call_id_send_reply_msg() { return 4; }
|
||||
constexpr Call_arg call_id_await_request_msg() { return 5; }
|
||||
constexpr Call_arg call_id_kill_signal_context() { return 6; }
|
||||
constexpr Call_arg call_id_submit_signal() { return 7; }
|
||||
constexpr Call_arg call_id_await_signal() { return 8; }
|
||||
constexpr Call_arg call_id_signal_pending() { return 9; }
|
||||
constexpr Call_arg call_id_ack_signal() { return 10; }
|
||||
constexpr Call_arg call_id_print_char() { return 11; }
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
@ -105,148 +84,6 @@ namespace Kernel
|
||||
Call_arg arg_4,
|
||||
Call_arg arg_5);
|
||||
|
||||
/**
|
||||
* Virtual range of the mode transition region in every PD
|
||||
*/
|
||||
addr_t mode_transition_virt_base();
|
||||
size_t mode_transition_size();
|
||||
|
||||
/**
|
||||
* Get sizes of the kernel objects
|
||||
*/
|
||||
size_t thread_size();
|
||||
size_t pd_size();
|
||||
size_t signal_context_size();
|
||||
size_t signal_receiver_size();
|
||||
size_t vm_size();
|
||||
|
||||
/**
|
||||
* Get alignment constraints of the kernel objects
|
||||
*/
|
||||
unsigned kernel_pd_alignm_log2();
|
||||
|
||||
|
||||
/**
|
||||
* Create a protection domain
|
||||
*
|
||||
* \param p appropriate memory donation for the kernel object
|
||||
* \param pd core local Platform_pd object
|
||||
*
|
||||
* \retval >0 kernel name of the new protection domain
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Restricted to core threads. Regaining of the supplied memory is not
|
||||
* supported by now.
|
||||
*/
|
||||
inline unsigned new_pd(void * const dst, Platform_pd * const pd)
|
||||
{
|
||||
return call(Call_id::NEW_PD, (Call_arg)dst, (Call_arg)pd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a protection domain
|
||||
*
|
||||
* \param pd_id kernel name of the targeted protection domain
|
||||
*
|
||||
* \retval 0 succeeded
|
||||
* \retval -1 failed
|
||||
*/
|
||||
inline int bin_pd(unsigned const pd_id)
|
||||
{
|
||||
return call(Call_id::BIN_PD, pd_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Propagate changes in PD configuration
|
||||
*
|
||||
* \param pd_id ID of the PD that has been configured
|
||||
*
|
||||
* It might be, that the kernel and/or the hardware caches parts of PD
|
||||
* configurations such as virtual address translations. This function
|
||||
* ensures that the current configuration of the targeted PD gets fully
|
||||
* applied from the moment it returns to the userland. This function is
|
||||
* inappropriate in case that a PD wants to change its own configuration.
|
||||
* There's no need for this function after a configuration change that
|
||||
* can't affect the kernel- and/or hardware-caches.
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline void update_pd(unsigned const pd_id)
|
||||
{
|
||||
call(Call_id::UPDATE_PD, pd_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Propagate memory-updates within a given virtual region
|
||||
*
|
||||
* \param base virtual base of the region
|
||||
* \param size size of the region
|
||||
*
|
||||
* If one updates a memory region and must ensure that the update
|
||||
* gets visible directly to other address spaces, this function does
|
||||
* the job.
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline void update_region(addr_t const base, size_t const size)
|
||||
{
|
||||
call(Call_id::UPDATE_REGION, (Call_arg)base, (Call_arg)size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create kernel object that acts as thread that isn't executed initially
|
||||
*
|
||||
* \param p memory donation for the new kernel thread object
|
||||
* \param priority scheduling priority of the new thread
|
||||
* \param label debugging label of the new thread
|
||||
*
|
||||
* \retval >0 kernel name of the new thread
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline int new_thread(void * const p, unsigned const priority,
|
||||
char const * const label)
|
||||
{
|
||||
return call((Call_arg)Call_id::NEW_THREAD, (Call_arg)p, (Call_arg)priority,
|
||||
(Call_arg)label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct kernel thread-object
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline void bin_thread(unsigned const thread_id)
|
||||
{
|
||||
call(Call_id::BIN_THREAD, thread_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start executing a thread
|
||||
*
|
||||
* \param thread_id kernel name of targeted thread
|
||||
* \param cpu_id kernel name of targeted processor
|
||||
* \param pd_id kernel name of targeted protection domain
|
||||
* \param utcb core local pointer to userland thread-context
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline Tlb * start_thread(unsigned const thread_id, unsigned const cpu_id,
|
||||
unsigned const pd_id, Native_utcb * const utcb)
|
||||
{
|
||||
return (Tlb *)call(Call_id::START_THREAD, thread_id, cpu_id, pd_id,
|
||||
(Call_arg)utcb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prevent thread from participating in CPU scheduling
|
||||
@ -261,7 +98,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int pause_thread(unsigned const thread_id)
|
||||
{
|
||||
return call(Call_id::PAUSE_THREAD, thread_id);
|
||||
return call(call_id_pause_thread(), thread_id);
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +116,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int resume_thread(unsigned const thread_id)
|
||||
{
|
||||
return call(Call_id::RESUME_THREAD, thread_id);
|
||||
return call(call_id_resume_thread(), thread_id);
|
||||
}
|
||||
|
||||
|
||||
@ -293,25 +130,7 @@ namespace Kernel
|
||||
*/
|
||||
inline void yield_thread(unsigned const thread_id)
|
||||
{
|
||||
call(Call_id::YIELD_THREAD, thread_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set or unset the handler of an event a kernel thread-object triggers
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
* \param event_id kernel name of the targeted thread event
|
||||
* \param signal_context_id kernel name of the handlers signal context
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline int route_thread_event(unsigned const thread_id,
|
||||
unsigned const event_id,
|
||||
unsigned const signal_context_id)
|
||||
{
|
||||
return call(Call_id::ROUTE_THREAD_EVENT, thread_id,
|
||||
event_id, signal_context_id);
|
||||
call(call_id_yield_thread(), thread_id);
|
||||
}
|
||||
|
||||
|
||||
@ -328,7 +147,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int send_request_msg(unsigned const thread_id)
|
||||
{
|
||||
return call(Call_id::SEND_REQUEST_MSG, thread_id);
|
||||
return call(call_id_send_request_msg(), thread_id);
|
||||
}
|
||||
|
||||
|
||||
@ -343,7 +162,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int await_request_msg()
|
||||
{
|
||||
return call(Call_id::AWAIT_REQUEST_MSG);
|
||||
return call(call_id_await_request_msg());
|
||||
}
|
||||
|
||||
|
||||
@ -360,7 +179,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int send_reply_msg(bool const await_request_msg)
|
||||
{
|
||||
return call(Call_id::SEND_REPLY_MSG, await_request_msg);
|
||||
return call(call_id_send_reply_msg(), await_request_msg);
|
||||
}
|
||||
|
||||
|
||||
@ -372,87 +191,7 @@ namespace Kernel
|
||||
*/
|
||||
inline void print_char(char const c)
|
||||
{
|
||||
call(Call_id::PRINT_CHAR, c);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access plain member variables of a kernel thread-object
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
* \param reads amount of read operations
|
||||
* \param writes amount of write operations
|
||||
* \param read_values base of value buffer for read operations
|
||||
* \param write_values base of value buffer for write operations
|
||||
*
|
||||
* \retval 0 all operations done
|
||||
* \retval >0 amount of undone operations
|
||||
* \retval -1 failed to start processing operations
|
||||
*
|
||||
* Restricted to core threads. Operations are processed in order of the
|
||||
* appearance of the register names in the callers UTCB. If reads = 0,
|
||||
* read_values is of no relevance. If writes = 0, write_values is of no
|
||||
* relevance.
|
||||
*
|
||||
* Expected structure at the callers UTCB base:
|
||||
*
|
||||
* 0 * sizeof(addr_t): read register name #1
|
||||
* ... ...
|
||||
* (reads - 1) * sizeof(addr_t): read register name #reads
|
||||
* (reads - 0) * sizeof(addr_t): write register name #1
|
||||
* ... ...
|
||||
* (reads + writes - 1) * sizeof(addr_t): write register name #writes
|
||||
*
|
||||
* Expected structure at write_values:
|
||||
*
|
||||
* 0 * sizeof(addr_t): write value #1
|
||||
* ... ...
|
||||
* (writes - 1) * sizeof(addr_t): write value #writes
|
||||
*/
|
||||
inline int access_thread_regs(unsigned const thread_id,
|
||||
unsigned const reads,
|
||||
unsigned const writes,
|
||||
addr_t * const read_values,
|
||||
addr_t * const write_values)
|
||||
{
|
||||
return call(Call_id::ACCESS_THREAD_REGS, thread_id, reads, writes,
|
||||
(Call_arg)read_values, (Call_arg)write_values);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a kernel object that acts as a signal receiver
|
||||
*
|
||||
* \param p memory donation for the kernel signal-receiver object
|
||||
*
|
||||
* \retval >0 kernel name of the new signal receiver
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline unsigned new_signal_receiver(addr_t const p)
|
||||
{
|
||||
return call(Call_id::NEW_SIGNAL_RECEIVER, p);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create kernel object that acts as a signal context and assign it
|
||||
*
|
||||
* \param p memory donation for the kernel signal-context object
|
||||
* \param receiver kernel name of targeted signal receiver
|
||||
* \param imprint user label of the signal context
|
||||
*
|
||||
* \retval >0 kernel name of the new signal context
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline unsigned new_signal_context(addr_t const p,
|
||||
unsigned const receiver,
|
||||
unsigned const imprint)
|
||||
{
|
||||
return call(Call_id::NEW_SIGNAL_CONTEXT, p, receiver, imprint);
|
||||
call(call_id_print_char(), c);
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +218,7 @@ namespace Kernel
|
||||
inline int await_signal(unsigned const receiver_id,
|
||||
unsigned const context_id)
|
||||
{
|
||||
return call(Call_id::AWAIT_SIGNAL, receiver_id, context_id);
|
||||
return call(call_id_await_signal(), receiver_id, context_id);
|
||||
}
|
||||
|
||||
|
||||
@ -493,7 +232,7 @@ namespace Kernel
|
||||
*/
|
||||
inline bool signal_pending(unsigned const receiver)
|
||||
{
|
||||
return call(Call_id::SIGNAL_PENDING, receiver);
|
||||
return call(call_id_signal_pending(), receiver);
|
||||
}
|
||||
|
||||
|
||||
@ -508,7 +247,7 @@ namespace Kernel
|
||||
*/
|
||||
inline int submit_signal(unsigned const context, unsigned const num)
|
||||
{
|
||||
return call(Call_id::SUBMIT_SIGNAL, context, num);
|
||||
return call(call_id_submit_signal(), context, num);
|
||||
}
|
||||
|
||||
|
||||
@ -519,7 +258,7 @@ namespace Kernel
|
||||
*/
|
||||
inline void ack_signal(unsigned const context)
|
||||
{
|
||||
call(Call_id::ACK_SIGNAL, context);
|
||||
call(call_id_ack_signal(), context);
|
||||
}
|
||||
|
||||
|
||||
@ -533,88 +272,8 @@ namespace Kernel
|
||||
*/
|
||||
inline int kill_signal_context(unsigned const context)
|
||||
{
|
||||
return call(Call_id::KILL_SIGNAL_CONTEXT, context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a signal context
|
||||
*
|
||||
* \param context kernel name of the targeted signal context
|
||||
*
|
||||
* \retval 0 suceeded
|
||||
* \retval -1 failed
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline int bin_signal_context(unsigned const context)
|
||||
{
|
||||
return call(Call_id::BIN_SIGNAL_CONTEXT, context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a signal receiver
|
||||
*
|
||||
* \param receiver kernel name of the targeted signal receiver
|
||||
*
|
||||
* \retval 0 suceeded
|
||||
* \retval -1 failed
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline int bin_signal_receiver(unsigned const receiver)
|
||||
{
|
||||
return call(Call_id::BIN_SIGNAL_RECEIVER, receiver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a virtual machine that is stopped initially
|
||||
*
|
||||
* \param dst memory donation for the kernel VM-object
|
||||
* \param state location of the CPU state of the VM
|
||||
* \param signal_context_id kernel name of the signal context for VM events
|
||||
*
|
||||
* \retval >0 kernel name of the new VM
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Restricted to core threads. Regaining of the supplied memory is not
|
||||
* supported by now.
|
||||
*/
|
||||
inline int new_vm(void * const dst, void * const state,
|
||||
unsigned const signal_context_id)
|
||||
{
|
||||
return call(Call_id::NEW_VM, (Call_arg)dst, (Call_arg)state,
|
||||
signal_context_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a virtual-machine (again)
|
||||
*
|
||||
* \param vm_id kernel name of the targeted VM
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline void run_vm(unsigned const vm_id)
|
||||
{
|
||||
call(Call_id::RUN_VM, vm_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stop execution of a virtual-machine
|
||||
*
|
||||
* \param vm_id kernel name of the targeted VM
|
||||
*
|
||||
* Restricted to core threads.
|
||||
*/
|
||||
inline void pause_vm(unsigned const vm_id)
|
||||
{
|
||||
call(Call_id::PAUSE_VM, vm_id);
|
||||
return call(call_id_kill_signal_context(), context);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _KERNEL__INTERFACE_H_ */
|
||||
|
||||
|
@ -116,25 +116,4 @@ Call_ret Kernel::call(Call_arg arg_0,
|
||||
CALL_6_FILL_ARG_REGS
|
||||
asm volatile(CALL_6_SWI);
|
||||
return arg_0_reg;
|
||||
}
|
||||
|
||||
|
||||
/*************************
|
||||
** CPU-state utilities **
|
||||
*************************/
|
||||
|
||||
typedef Thread_reg_id Reg_id;
|
||||
|
||||
static addr_t const _cpu_state_regs[] = {
|
||||
Reg_id::R0, Reg_id::R1, Reg_id::R2, Reg_id::R3, Reg_id::R4,
|
||||
Reg_id::R5, Reg_id::R6, Reg_id::R7, Reg_id::R8, Reg_id::R9,
|
||||
Reg_id::R10, Reg_id::R11, Reg_id::R12, Reg_id::SP, Reg_id::LR,
|
||||
Reg_id::IP, Reg_id::CPSR, Reg_id::CPU_EXCEPTION };
|
||||
|
||||
addr_t const * cpu_state_regs() { return _cpu_state_regs; }
|
||||
|
||||
|
||||
size_t cpu_state_regs_length()
|
||||
{
|
||||
return sizeof(_cpu_state_regs)/sizeof(_cpu_state_regs[0]);
|
||||
}
|
||||
}
|
@ -93,3 +93,24 @@ void Thread::_mmu_exception()
|
||||
*************************/
|
||||
|
||||
void Kernel::Cpu_context::_init(size_t const stack_size) { r12 = stack_size; }
|
||||
|
||||
|
||||
/*************************
|
||||
** CPU-state utilities **
|
||||
*************************/
|
||||
|
||||
typedef Thread_reg_id Reg_id;
|
||||
|
||||
static addr_t const _cpu_state_regs[] = {
|
||||
Reg_id::R0, Reg_id::R1, Reg_id::R2, Reg_id::R3, Reg_id::R4,
|
||||
Reg_id::R5, Reg_id::R6, Reg_id::R7, Reg_id::R8, Reg_id::R9,
|
||||
Reg_id::R10, Reg_id::R11, Reg_id::R12, Reg_id::SP, Reg_id::LR,
|
||||
Reg_id::IP, Reg_id::CPSR, Reg_id::CPU_EXCEPTION };
|
||||
|
||||
addr_t const * cpu_state_regs() { return _cpu_state_regs; }
|
||||
|
||||
|
||||
size_t cpu_state_regs_length()
|
||||
{
|
||||
return sizeof(_cpu_state_regs)/sizeof(_cpu_state_regs[0]);
|
||||
}
|
@ -21,7 +21,7 @@
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/log.h>
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform_generic.h>
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <base/thread.h>
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
#include <kernel/log.h>
|
||||
|
||||
/* core includes */
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <root/component.h>
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
|
||||
/* core includes */
|
||||
#include <signal_session_component.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
|
||||
/* core includes */
|
||||
#include <kernel/irq.h>
|
||||
|
313
base-hw/src/core/kernel/core_interface.h
Normal file
313
base-hw/src/core/kernel/core_interface.h
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
* \brief Parts of the kernel interface that are restricted to core
|
||||
* \author Martin stein
|
||||
* \date 2014-03-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _KERNEL__CORE_INTERFACE_H_
|
||||
#define _KERNEL__CORE_INTERFACE_H_
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
addr_t mode_transition_virt_base();
|
||||
size_t mode_transition_size();
|
||||
size_t thread_size();
|
||||
size_t pd_size();
|
||||
size_t signal_context_size();
|
||||
size_t signal_receiver_size();
|
||||
size_t vm_size();
|
||||
unsigned kernel_pd_alignm_log2();
|
||||
|
||||
/**
|
||||
* Kernel names of the kernel calls
|
||||
*/
|
||||
constexpr Call_arg call_id_new_thread() { return 12; }
|
||||
constexpr Call_arg call_id_bin_thread() { return 13; }
|
||||
constexpr Call_arg call_id_start_thread() { return 14; }
|
||||
constexpr Call_arg call_id_access_thread_regs() { return 15; }
|
||||
constexpr Call_arg call_id_route_thread_event() { return 16; }
|
||||
constexpr Call_arg call_id_update_pd() { return 17; }
|
||||
constexpr Call_arg call_id_update_region() { return 18; }
|
||||
constexpr Call_arg call_id_new_pd() { return 19; }
|
||||
constexpr Call_arg call_id_bin_pd() { return 20; }
|
||||
constexpr Call_arg call_id_new_signal_receiver() { return 21; }
|
||||
constexpr Call_arg call_id_new_signal_context() { return 22; }
|
||||
constexpr Call_arg call_id_bin_signal_context() { return 23; }
|
||||
constexpr Call_arg call_id_bin_signal_receiver() { return 24; }
|
||||
constexpr Call_arg call_id_new_vm() { return 25; }
|
||||
constexpr Call_arg call_id_run_vm() { return 26; }
|
||||
constexpr Call_arg call_id_pause_vm() { return 27; }
|
||||
|
||||
/**
|
||||
* Create a domain
|
||||
*
|
||||
* \param dst appropriate memory donation for the kernel object
|
||||
* \param pd core local Platform_pd object
|
||||
*
|
||||
* \retval >0 kernel name of the new domain
|
||||
* \retval 0 failed
|
||||
*/
|
||||
inline unsigned new_pd(void * const dst, Platform_pd * const pd)
|
||||
{
|
||||
return call(call_id_new_pd(), (Call_arg)dst, (Call_arg)pd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a domain
|
||||
*
|
||||
* \param pd_id kernel name of the targeted domain
|
||||
*
|
||||
* \retval 0 succeeded
|
||||
* \retval -1 failed
|
||||
*/
|
||||
inline int bin_pd(unsigned const pd_id)
|
||||
{
|
||||
return call(call_id_bin_pd(), pd_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update locally effective domain configuration to in-memory state
|
||||
*
|
||||
* \param pd_id kernel name of the targeted domain
|
||||
*
|
||||
* Kernel and/or hardware may cache parts of a domain configuration. This
|
||||
* function ensures that the in-memory state of the targeted domain gets
|
||||
* processor locally effective.
|
||||
*/
|
||||
inline void update_pd(unsigned const pd_id)
|
||||
{
|
||||
call(call_id_update_pd(), pd_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write-through the cached contents of a region in the current domain
|
||||
*
|
||||
* \param base base of the region within the current domain
|
||||
* \param size size of the region
|
||||
*/
|
||||
inline void update_region(addr_t const base, size_t const size)
|
||||
{
|
||||
call(call_id_update_region(), (Call_arg)base, (Call_arg)size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a thread
|
||||
*
|
||||
* \param p memory donation for the new kernel thread object
|
||||
* \param priority scheduling priority of the new thread
|
||||
* \param label debugging label of the new thread
|
||||
*
|
||||
* \retval >0 kernel name of the new thread
|
||||
* \retval 0 failed
|
||||
*/
|
||||
inline int new_thread(void * const p, unsigned const priority,
|
||||
char const * const label)
|
||||
{
|
||||
return call(call_id_new_thread(), (Call_arg)p, (Call_arg)priority,
|
||||
(Call_arg)label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a thread
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
*/
|
||||
inline void bin_thread(unsigned const thread_id)
|
||||
{
|
||||
call(call_id_bin_thread(), thread_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start execution of a thread
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
* \param cpu_id kernel name of the targeted processor
|
||||
* \param pd_id kernel name of the targeted domain
|
||||
* \param utcb core local pointer to userland thread-context
|
||||
*/
|
||||
inline Tlb * start_thread(unsigned const thread_id, unsigned const cpu_id,
|
||||
unsigned const pd_id, Native_utcb * const utcb)
|
||||
{
|
||||
return (Tlb *)call(call_id_start_thread(), thread_id, cpu_id, pd_id,
|
||||
(Call_arg)utcb);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set or unset the handler of an event that can be triggered by a thread
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
* \param event_id kernel name of the targeted thread event
|
||||
* \param signal_context_id kernel name of the handlers signal context
|
||||
*/
|
||||
inline int route_thread_event(unsigned const thread_id,
|
||||
unsigned const event_id,
|
||||
unsigned const signal_context_id)
|
||||
{
|
||||
return call(call_id_route_thread_event(), thread_id,
|
||||
event_id, signal_context_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access plain member variables of a kernel thread-object
|
||||
*
|
||||
* \param thread_id kernel name of the targeted thread
|
||||
* \param reads amount of read operations
|
||||
* \param writes amount of write operations
|
||||
* \param read_values base of value buffer for read operations
|
||||
* \param write_values base of value buffer for write operations
|
||||
*
|
||||
* \retval 0 all operations done
|
||||
* \retval >0 amount of undone operations
|
||||
* \retval -1 failed to start processing operations
|
||||
*
|
||||
* Operations are processed in order of the appearance of the register
|
||||
* names in the callers UTCB. If reads = 0, read_values is of no relevance.
|
||||
* If writes = 0, write_values is of no relevance.
|
||||
*
|
||||
* Expected structure at the callers UTCB base:
|
||||
*
|
||||
* 0 * sizeof(addr_t): read register name #1
|
||||
* ... ...
|
||||
* (reads - 1) * sizeof(addr_t): read register name #reads
|
||||
* (reads - 0) * sizeof(addr_t): write register name #1
|
||||
* ... ...
|
||||
* (reads + writes - 1) * sizeof(addr_t): write register name #writes
|
||||
*
|
||||
* Expected structure at write_values:
|
||||
*
|
||||
* 0 * sizeof(addr_t): write value #1
|
||||
* ... ...
|
||||
* (writes - 1) * sizeof(addr_t): write value #writes
|
||||
*/
|
||||
inline int access_thread_regs(unsigned const thread_id,
|
||||
unsigned const reads,
|
||||
unsigned const writes,
|
||||
addr_t * const read_values,
|
||||
addr_t * const write_values)
|
||||
{
|
||||
return call(call_id_access_thread_regs(), thread_id, reads, writes,
|
||||
(Call_arg)read_values, (Call_arg)write_values);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a signal receiver
|
||||
*
|
||||
* \param p memory donation for the kernel signal-receiver object
|
||||
*
|
||||
* \retval >0 kernel name of the new signal receiver
|
||||
* \retval 0 failed
|
||||
*/
|
||||
inline unsigned new_signal_receiver(addr_t const p)
|
||||
{
|
||||
return call(call_id_new_signal_receiver(), p);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a signal context and assign it to a signal receiver
|
||||
*
|
||||
* \param p memory donation for the kernel signal-context object
|
||||
* \param receiver kernel name of targeted signal receiver
|
||||
* \param imprint user label of the signal context
|
||||
*
|
||||
* \retval >0 kernel name of the new signal context
|
||||
* \retval 0 failed
|
||||
*/
|
||||
inline unsigned new_signal_context(addr_t const p,
|
||||
unsigned const receiver,
|
||||
unsigned const imprint)
|
||||
{
|
||||
return call(call_id_new_signal_context(), p, receiver, imprint);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a signal context
|
||||
*
|
||||
* \param context kernel name of the targeted signal context
|
||||
*
|
||||
* \retval 0 suceeded
|
||||
* \retval -1 failed
|
||||
*/
|
||||
inline int bin_signal_context(unsigned const context)
|
||||
{
|
||||
return call(call_id_bin_signal_context(), context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destruct a signal receiver
|
||||
*
|
||||
* \param receiver kernel name of the targeted signal receiver
|
||||
*
|
||||
* \retval 0 suceeded
|
||||
* \retval -1 failed
|
||||
*/
|
||||
inline int bin_signal_receiver(unsigned const receiver)
|
||||
{
|
||||
return call(call_id_bin_signal_receiver(), receiver);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a virtual machine that is stopped initially
|
||||
*
|
||||
* \param dst memory donation for the VM object
|
||||
* \param state location of the processor state of the VM
|
||||
* \param signal_context_id kernel name of the signal context for VM events
|
||||
*
|
||||
* \retval >0 kernel name of the new VM
|
||||
* \retval 0 failed
|
||||
*
|
||||
* Regaining of the supplied memory is not supported by now.
|
||||
*/
|
||||
inline int new_vm(void * const dst, void * const state,
|
||||
unsigned const signal_context_id)
|
||||
{
|
||||
return call(call_id_new_vm(), (Call_arg)dst, (Call_arg)state,
|
||||
signal_context_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute a virtual-machine (again)
|
||||
*
|
||||
* \param vm_id kernel name of the targeted VM
|
||||
*/
|
||||
inline void run_vm(unsigned const vm_id)
|
||||
{
|
||||
call(call_id_run_vm(), vm_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stop execution of a virtual-machine
|
||||
*
|
||||
* \param vm_id kernel name of the targeted VM
|
||||
*/
|
||||
inline void pause_vm(unsigned const vm_id)
|
||||
{
|
||||
call(call_id_pause_vm(), vm_id);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _KERNEL__CORE_INTERFACE_H_ */
|
@ -940,34 +940,34 @@ int Thread::_write_reg(addr_t const id, addr_t const value)
|
||||
void Thread::_call(unsigned const processor_id)
|
||||
{
|
||||
switch (user_arg_0()) {
|
||||
case Call_id::NEW_THREAD: _call_new_thread(); return;
|
||||
case Call_id::BIN_THREAD: _call_bin_thread(); return;
|
||||
case Call_id::START_THREAD: _call_start_thread(); return;
|
||||
case Call_id::PAUSE_THREAD: _call_pause_thread(); return;
|
||||
case Call_id::RESUME_THREAD: _call_resume_thread(); return;
|
||||
case Call_id::YIELD_THREAD: _call_yield_thread(); return;
|
||||
case Call_id::SEND_REQUEST_MSG: _call_send_request_msg(); return;
|
||||
case Call_id::SEND_REPLY_MSG: _call_send_reply_msg(); return;
|
||||
case Call_id::AWAIT_REQUEST_MSG: _call_await_request_msg(); return;
|
||||
case Call_id::UPDATE_PD: _call_update_pd(); return;
|
||||
case Call_id::UPDATE_REGION: _call_update_region(); return;
|
||||
case Call_id::NEW_PD: _call_new_pd(); return;
|
||||
case Call_id::PRINT_CHAR: _call_print_char(); return;
|
||||
case Call_id::NEW_SIGNAL_RECEIVER: _call_new_signal_receiver(); return;
|
||||
case Call_id::NEW_SIGNAL_CONTEXT: _call_new_signal_context(); return;
|
||||
case Call_id::KILL_SIGNAL_CONTEXT: _call_kill_signal_context(); return;
|
||||
case Call_id::BIN_SIGNAL_CONTEXT: _call_bin_signal_context(); return;
|
||||
case Call_id::BIN_SIGNAL_RECEIVER: _call_bin_signal_receiver(); return;
|
||||
case Call_id::AWAIT_SIGNAL: _call_await_signal(); return;
|
||||
case Call_id::SUBMIT_SIGNAL: _call_submit_signal(); return;
|
||||
case Call_id::SIGNAL_PENDING: _call_signal_pending(); return;
|
||||
case Call_id::ACK_SIGNAL: _call_ack_signal(); return;
|
||||
case Call_id::NEW_VM: _call_new_vm(); return;
|
||||
case Call_id::RUN_VM: _call_run_vm(); return;
|
||||
case Call_id::PAUSE_VM: _call_pause_vm(); return;
|
||||
case Call_id::BIN_PD: _call_bin_pd(); return;
|
||||
case Call_id::ACCESS_THREAD_REGS: _call_access_thread_regs(); return;
|
||||
case Call_id::ROUTE_THREAD_EVENT: _call_route_thread_event(); return;
|
||||
case call_id_new_thread(): _call_new_thread(); return;
|
||||
case call_id_bin_thread(): _call_bin_thread(); return;
|
||||
case call_id_start_thread(): _call_start_thread(); return;
|
||||
case call_id_pause_thread(): _call_pause_thread(); return;
|
||||
case call_id_resume_thread(): _call_resume_thread(); return;
|
||||
case call_id_yield_thread(): _call_yield_thread(); return;
|
||||
case call_id_send_request_msg(): _call_send_request_msg(); return;
|
||||
case call_id_send_reply_msg(): _call_send_reply_msg(); return;
|
||||
case call_id_await_request_msg(): _call_await_request_msg(); return;
|
||||
case call_id_update_pd(): _call_update_pd(); return;
|
||||
case call_id_update_region(): _call_update_region(); return;
|
||||
case call_id_new_pd(): _call_new_pd(); return;
|
||||
case call_id_print_char(): _call_print_char(); return;
|
||||
case call_id_new_signal_receiver(): _call_new_signal_receiver(); return;
|
||||
case call_id_new_signal_context(): _call_new_signal_context(); return;
|
||||
case call_id_kill_signal_context(): _call_kill_signal_context(); return;
|
||||
case call_id_bin_signal_context(): _call_bin_signal_context(); return;
|
||||
case call_id_bin_signal_receiver(): _call_bin_signal_receiver(); return;
|
||||
case call_id_await_signal(): _call_await_signal(); return;
|
||||
case call_id_submit_signal(): _call_submit_signal(); return;
|
||||
case call_id_signal_pending(): _call_signal_pending(); return;
|
||||
case call_id_ack_signal(): _call_ack_signal(); return;
|
||||
case call_id_new_vm(): _call_new_vm(); return;
|
||||
case call_id_run_vm(): _call_run_vm(); return;
|
||||
case call_id_pause_vm(): _call_pause_vm(); return;
|
||||
case call_id_bin_pd(): _call_bin_pd(); return;
|
||||
case call_id_access_thread_regs(): _call_access_thread_regs(); return;
|
||||
case call_id_route_thread_event(): _call_route_thread_event(); return;
|
||||
default:
|
||||
PWRN("unknown kernel call");
|
||||
_stop();
|
||||
|
@ -227,9 +227,9 @@ class Kernel::Thread
|
||||
void _print_common_activity();
|
||||
|
||||
|
||||
/****************************************************************
|
||||
** Kernel-call backends, for details see 'kernel/interface.h' **
|
||||
****************************************************************/
|
||||
/*********************************************************
|
||||
** Kernel-call back-ends, see kernel-interface headers **
|
||||
*********************************************************/
|
||||
|
||||
void _call_new_pd();
|
||||
void _call_bin_pd();
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <base/printf.h>
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
|
||||
/* core includes */
|
||||
#include <ram_session_component.h>
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <base/printf.h>
|
||||
|
||||
/* base-hw includes */
|
||||
#include <kernel/interface.h>
|
||||
#include <kernel/core_interface.h>
|
||||
#include <placement_new.h>
|
||||
|
||||
/* core includes */
|
||||
|
Loading…
x
Reference in New Issue
Block a user