hw: clearer naming scheme in kernel API

Rename kernel syscall in kernel call and the kernel-API
files in kernel/interface* .

ref #953
This commit is contained in:
Martin Stein 2013-11-14 17:29:34 +01:00 committed by Norman Feske
parent b3ccac63c3
commit e0419b2401
21 changed files with 329 additions and 573 deletions

View File

@ -1,5 +1,5 @@
/*
* \brief Syscall declarations specific for ARM systems
* \brief Interface between kernel and userland
* \author Martin Stein
* \date 2011-11-30
*/
@ -11,16 +11,16 @@
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__ARM__BASE__SYSCALL_H_
#define _INCLUDE__ARM__BASE__SYSCALL_H_
#ifndef _KERNEL__INTERFACE_SUPPORT_H_
#define _KERNEL__INTERFACE_SUPPORT_H_
/* Genode includes */
#include <base/stdint.h>
namespace Kernel
{
typedef Genode::uint32_t Syscall_arg;
typedef Genode::uint32_t Syscall_ret;
typedef Genode::uint32_t Call_arg;
typedef Genode::uint32_t Call_ret;
/**
* Registers that are provided by a kernel thread-object for user access
@ -62,5 +62,5 @@ namespace Kernel
};
}
#endif /* _INCLUDE__ARM__BASE__SYSCALL_H_ */
#endif /* _KERNEL__INTERFACE_SUPPORT_H_ */

View File

@ -1,5 +1,5 @@
/*
* \brief Platform specific basic Genode types
* \brief Basic Genode types
* \author Martin Stein
* \date 2012-01-02
*/
@ -15,7 +15,7 @@
#define _BASE__NATIVE_TYPES_H_
/* Genode includes */
#include <kernel/syscalls.h>
#include <kernel/interface.h>
#include <base/native_capability.h>
#include <base/stdint.h>
@ -88,14 +88,14 @@ namespace Genode
Ipc_msg ipc_msg;
};
void syscall_wait_for_request(void * & buf_base, size_t & buf_size)
void call_wait_for_request(void * & buf_base, size_t & buf_size)
{
msg.type = Msg::Type::INVALID;
buf_base = base();
buf_size = size();
}
void syscall_request_and_wait(void * & msg_base, size_t & msg_size,
void call_request_and_wait(void * & msg_base, size_t & msg_size,
void * & buf_base, size_t & buf_size)
{
msg.type = Msg::Type::IPC;
@ -105,7 +105,7 @@ namespace Genode
buf_size = size();
}
void syscall_reply(void * & msg_base, size_t & msg_size)
void call_reply(void * & msg_base, size_t & msg_size)
{
msg.type = Msg::Type::IPC;
msg_base = ipc_msg_base();

View File

@ -1,5 +1,5 @@
/*
* \brief Kernels syscall frontend
* \brief Interface between kernel and userland
* \author Martin stein
* \date 2011-11-30
*/
@ -11,11 +11,11 @@
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__KERNEL__SYSCALLS_H_
#define _INCLUDE__KERNEL__SYSCALLS_H_
#ifndef _KERNEL__INTERFACE_H_
#define _KERNEL__INTERFACE_H_
/* Genode includes */
#include <base/syscall_support.h>
#include <kernel/interface_support.h>
namespace Genode
{
@ -72,39 +72,39 @@ namespace Kernel
/*****************************************************************
** Syscall with 1 to 6 arguments **
** Kernel call with 1 to 6 arguments **
** **
** These functions must not be inline to ensure that objects, **
** wich are referenced by arguments, are tagged as "used" even **
** though only the pointer gets handled in here. **
*****************************************************************/
Syscall_ret syscall(Syscall_arg arg_0);
Call_ret call(Call_arg arg_0);
Syscall_ret syscall(Syscall_arg arg_0,
Syscall_arg arg_1);
Call_ret call(Call_arg arg_0,
Call_arg arg_1);
Syscall_ret syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2);
Call_ret call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2);
Syscall_ret syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3);
Call_ret call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3);
Syscall_ret syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4);
Call_ret call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3,
Call_arg arg_4);
Syscall_ret syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4,
Syscall_arg arg_5);
Call_ret call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3,
Call_arg arg_4,
Call_arg arg_5);
/**
* Virtual range of the mode transition region in every PD
@ -141,21 +141,21 @@ namespace Kernel
*/
inline unsigned new_pd(void * const dst, Platform_pd * const pd)
{
return syscall(Call_id::NEW_PD, (Syscall_arg)dst, (Syscall_arg)pd);
return call(Call_id::NEW_PD, (Call_arg)dst, (Call_arg)pd);
}
/**
* Destruct a protection domain
*
* \param pd kernel name of the targeted protection domain
* \param pd_id kernel name of the targeted protection domain
*
* \retval 0 succeeded
* \retval -1 failed
*/
inline int kill_pd(unsigned const pd)
inline int kill_pd(unsigned const pd_id)
{
return syscall(Call_id::KILL_PD, pd);
return call(Call_id::KILL_PD, pd_id);
}
@ -165,18 +165,18 @@ namespace Kernel
* \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 syscall
* 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 syscall is
* 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 syscall after a configuration change that
* 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)
{
syscall(Call_id::UPDATE_PD, (Syscall_arg)pd_id);
call(Call_id::UPDATE_PD, pd_id);
}
@ -187,14 +187,14 @@ namespace Kernel
* \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 syscall does
* gets visible directly to other address spaces, this function does
* the job.
*
* Restricted to core threads.
*/
inline void update_region(addr_t base, size_t size)
inline void update_region(addr_t const base, size_t const size)
{
syscall(Call_id::UPDATE_REGION, (Syscall_arg)base, (Syscall_arg)size);
call(Call_id::UPDATE_REGION, (Call_arg)base, (Call_arg)size);
}
@ -213,7 +213,7 @@ namespace Kernel
*/
inline int new_thread(void * const dst, Platform_thread * const pt)
{
return syscall(Call_id::NEW_THREAD, (Syscall_arg)dst, (Syscall_arg)pt);
return call(Call_id::NEW_THREAD, (Call_arg)dst, (Call_arg)pt);
}
@ -226,9 +226,9 @@ namespace Kernel
* granted beforehand by 'new_thread' to kernel for managing this thread
* is freed again.
*/
inline void delete_thread(unsigned thread_id)
inline void delete_thread(unsigned const thread_id)
{
syscall(Call_id::DELETE_THREAD, (Syscall_arg)thread_id);
call(Call_id::DELETE_THREAD, thread_id);
}
@ -245,11 +245,11 @@ namespace Kernel
*
* Restricted to core threads.
*/
inline Tlb * start_thread(Platform_thread * const phys_pt, void * ip,
void * sp, unsigned cpu_no)
inline Tlb * start_thread(Platform_thread * const phys_pt, void * const ip,
void * const sp, unsigned const cpu_no)
{
return (Tlb *)syscall(Call_id::START_THREAD, (Syscall_arg)phys_pt,
(Syscall_arg)ip, (Syscall_arg)sp, cpu_no);
return (Tlb *)call(Call_id::START_THREAD, (Call_arg)phys_pt,
(Call_arg)ip, (Call_arg)sp, cpu_no);
}
@ -259,15 +259,14 @@ namespace Kernel
* \param id ID of the targeted thread. If not set
* this will target the current thread.
*
* \retval 0 syscall was successful
* \retval <0 if the targeted thread does not exist or still participates
* in CPU scheduling after
* \retval 0 succeeded
* \retval -1 the targeted thread does not exist or is still active
*
* If the caller doesn't target itself, this is restricted to core threads.
*/
inline int pause_thread(unsigned const id = 0)
{
return syscall(Call_id::PAUSE_THREAD, id);
return call(Call_id::PAUSE_THREAD, id);
}
@ -276,17 +275,16 @@ namespace Kernel
*
* \param id ID of the targeted thread
*
* \retval 0 if syscall was successful and thread were paused beforehand
* \retval >0 if syscall was successful and thread were already active
* \retval <0 if targeted thread doesn't participate in CPU
* scheduling after
* \retval 0 succeeded and thread was paused beforehand
* \retval 1 succeeded and thread was active beforehand
* \retval -1 failed
*
* If the targeted thread blocks for any event except a 'start_thread'
* call this call cancels the blocking.
*/
inline int resume_thread(unsigned const id = 0)
{
return syscall(Call_id::RESUME_THREAD, id);
return call(Call_id::RESUME_THREAD, id);
}
@ -298,7 +296,7 @@ namespace Kernel
*/
inline void yield_thread(unsigned const id = 0)
{
syscall(Call_id::YIELD_THREAD, id);
call(Call_id::YIELD_THREAD, id);
}
@ -307,7 +305,7 @@ namespace Kernel
*/
inline int current_thread_id()
{
return syscall(Call_id::CURRENT_THREAD_ID);
return call(Call_id::CURRENT_THREAD_ID);
}
@ -323,7 +321,7 @@ namespace Kernel
*/
inline Platform_thread * get_thread(unsigned const id)
{
return (Platform_thread *)syscall(Call_id::GET_THREAD, id);
return (Platform_thread *)call(Call_id::GET_THREAD, id);
}
@ -340,8 +338,8 @@ namespace Kernel
unsigned const event_id,
unsigned const signal_context_id)
{
return syscall(Call_id::ROUTE_THREAD_EVENT, thread_id,
event_id, signal_context_id);
return call(Call_id::ROUTE_THREAD_EVENT, thread_id,
event_id, signal_context_id);
}
@ -354,7 +352,7 @@ namespace Kernel
*/
inline void request_and_wait(unsigned const id)
{
syscall(Call_id::REQUEST_AND_WAIT, id);
call(Call_id::REQUEST_AND_WAIT, id);
}
@ -367,7 +365,7 @@ namespace Kernel
*/
inline void wait_for_request()
{
syscall(Call_id::WAIT_FOR_REQUEST);
call(Call_id::WAIT_FOR_REQUEST);
}
@ -381,7 +379,7 @@ namespace Kernel
*/
inline void reply(bool const await_message)
{
syscall(Call_id::REPLY, await_message);
call(Call_id::REPLY, await_message);
}
@ -390,7 +388,7 @@ namespace Kernel
*/
inline void print_char(char const c)
{
syscall(Call_id::PRINT_CHAR, (Syscall_arg)c);
call(Call_id::PRINT_CHAR, c);
}
@ -433,8 +431,8 @@ namespace Kernel
addr_t * const read_values,
addr_t * const write_values)
{
return syscall(Call_id::ACCESS_THREAD_REGS, thread_id, reads, writes,
(Syscall_arg)read_values, (Syscall_arg)write_values);
return call(Call_id::ACCESS_THREAD_REGS, thread_id, reads, writes,
(Call_arg)read_values, (Call_arg)write_values);
}
@ -450,7 +448,7 @@ namespace Kernel
*/
inline unsigned new_signal_receiver(addr_t const p)
{
return syscall(Call_id::NEW_SIGNAL_RECEIVER, p);
return call(Call_id::NEW_SIGNAL_RECEIVER, p);
}
@ -470,7 +468,7 @@ namespace Kernel
unsigned const receiver,
unsigned const imprint)
{
return syscall(Call_id::NEW_SIGNAL_CONTEXT, p, receiver, imprint);
return call(Call_id::NEW_SIGNAL_CONTEXT, p, receiver, imprint);
}
@ -497,7 +495,7 @@ namespace Kernel
inline int await_signal(unsigned const receiver_id,
unsigned const context_id)
{
return syscall(Call_id::AWAIT_SIGNAL, receiver_id, context_id);
return call(Call_id::AWAIT_SIGNAL, receiver_id, context_id);
}
@ -511,7 +509,7 @@ namespace Kernel
*/
inline bool signal_pending(unsigned const receiver)
{
return syscall(Call_id::SIGNAL_PENDING, receiver);
return call(Call_id::SIGNAL_PENDING, receiver);
}
@ -526,7 +524,7 @@ namespace Kernel
*/
inline int submit_signal(unsigned const context, unsigned const num)
{
return syscall(Call_id::SUBMIT_SIGNAL, context, num);
return call(Call_id::SUBMIT_SIGNAL, context, num);
}
@ -537,7 +535,7 @@ namespace Kernel
*/
inline void ack_signal(unsigned const context)
{
syscall(Call_id::ACK_SIGNAL, context);
call(Call_id::ACK_SIGNAL, context);
}
@ -553,7 +551,7 @@ namespace Kernel
*/
inline int kill_signal_context(unsigned const context)
{
return syscall(Call_id::KILL_SIGNAL_CONTEXT, context);
return call(Call_id::KILL_SIGNAL_CONTEXT, context);
}
@ -569,57 +567,56 @@ namespace Kernel
*/
inline int kill_signal_receiver(unsigned const receiver)
{
return syscall(Call_id::KILL_SIGNAL_RECEIVER, receiver);
return call(Call_id::KILL_SIGNAL_RECEIVER, receiver);
}
/**
* Create a new virtual-machine that is stopped initially
* Create a virtual machine that is stopped initially
*
* \param dst physical base of an appropriate portion of memory
* that is thereupon allocated to the kernel
* \param state location of the CPU state of the VM
* \param context_id ID of the targeted signal context
* \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 ID of the new VM
* \retval 0 if no new VM was created
* \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 context_id)
unsigned const signal_context_id)
{
return syscall(Call_id::NEW_VM, (Syscall_arg)dst, (Syscall_arg)state,
(Syscall_arg)context_id);
return call(Call_id::NEW_VM, (Call_arg)dst, (Call_arg)state,
signal_context_id);
}
/**
* Execute a virtual-machine (again)
*
* \param id ID of the targeted VM
* \param vm_id kernel name of the targeted VM
*
* Restricted to core threads.
*/
inline void run_vm(unsigned const id)
inline void run_vm(unsigned const vm_id)
{
syscall(Call_id::RUN_VM, (Syscall_arg)id);
call(Call_id::RUN_VM, vm_id);
}
/**
* Stop execution of a virtual-machine
*
* \param id ID of the targeted VM
* \param vm_id kernel name of the targeted VM
*
* Restricted to core threads.
*/
inline void pause_vm(unsigned const id)
inline void pause_vm(unsigned const vm_id)
{
syscall(Call_id::PAUSE_VM, (Syscall_arg)id);
call(Call_id::PAUSE_VM, vm_id);
}
}
#endif /* _INCLUDE__KERNEL__SYSCALLS_H_ */
#endif /* _KERNEL__INTERFACE_H_ */

View File

@ -11,11 +11,11 @@
* under the terms of the GNU General Public License version 2.
*/
#ifndef _INCLUDE__KERNEL__LOG_H_
#define _INCLUDE__KERNEL__LOG_H_
#ifndef _KERNEL__LOG_H_
#define _KERNEL__LOG_H_
/* Genode includes */
#include <kernel/syscalls.h>
#include <kernel/interface.h>
namespace Genode
{
@ -105,5 +105,5 @@ namespace Genode
}
}
#endif /* _INCLUDE__KERNEL__LOG_H_ */
#endif /* _KERNEL__LOG_H_ */

View File

@ -0,0 +1,2 @@
SRC_CC = kernel/interface.cc
vpath % $(REP_DIR)/src/arm

View File

@ -1,5 +0,0 @@
SRC_CC = syscall.cc
vpath syscall.cc $(REP_DIR)/src/base/arm

View File

@ -4,7 +4,7 @@
# \date 2013-02-14
#
LIBS += cxx syscall
LIBS += cxx kernel_interface
SRC_CC += main_bootstrap.cc
SRC_CC += ipc.cc ipc/ipc_marshal_cap.cc

View File

@ -0,0 +1,180 @@
/*
* \brief Interface between kernel and userland
* \author Martin stein
* \date 2011-11-30
*/
/*
* Copyright (C) 2011-2013 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.
*/
/* Genode includes */
#include <kernel/interface.h>
using namespace Kernel;
/**********************************************************************
** Inline assembly templates for kernel calls with 1 to 6 arguments **
**********************************************************************/
#define CALL_6_ASM_OPS \
"mov r5, #0 \n" \
"add r5, %[arg_5] \n" \
CALL_5_ASM_OPS
#define CALL_5_ASM_OPS \
"mov r4, #0 \n" \
"add r4, %[arg_4] \n" \
CALL_4_ASM_OPS
#define CALL_4_ASM_OPS \
"mov r3, #0 \n" \
"add r3, %[arg_3] \n" \
CALL_3_ASM_OPS
#define CALL_3_ASM_OPS \
"mov r2, #0 \n" \
"add r2, %[arg_2] \n" \
CALL_2_ASM_OPS
#define CALL_2_ASM_OPS \
"mov r1, #0 \n" \
"add r1, %[arg_1] \n" \
CALL_1_ASM_OPS
#define CALL_1_ASM_OPS \
"mov r0, #0 \n" \
"add r0, %[arg_0] \n" \
"swi 0 \n" \
"mov %[result], #0 \n" \
"add %[result], r0 "
/****************************************************************************
** Inline assembly "writeable" tpl-args for kernel calls with 1 to 6 args **
****************************************************************************/
#define CALL_6_ASM_WRITE [arg_5] "+r" (arg_5), CALL_5_ASM_WRITE
#define CALL_5_ASM_WRITE [arg_4] "+r" (arg_4), CALL_4_ASM_WRITE
#define CALL_4_ASM_WRITE [arg_3] "+r" (arg_3), CALL_3_ASM_WRITE
#define CALL_3_ASM_WRITE [arg_2] "+r" (arg_2), CALL_2_ASM_WRITE
#define CALL_2_ASM_WRITE [arg_1] "+r" (arg_1), CALL_1_ASM_WRITE
#define CALL_1_ASM_WRITE \
[arg_0] "+r" (arg_0), \
[result] "+r" (result)
/**************************************************************************
** Inline assembly clobber lists for kernel calls with 1 to 6 arguments **
**************************************************************************/
#define CALL_6_ASM_CLOBBER "r5", CALL_5_ASM_CLOBBER
#define CALL_5_ASM_CLOBBER "r4", CALL_4_ASM_CLOBBER
#define CALL_4_ASM_CLOBBER "r3", CALL_3_ASM_CLOBBER
#define CALL_3_ASM_CLOBBER "r2", CALL_2_ASM_CLOBBER
#define CALL_2_ASM_CLOBBER "r1", CALL_1_ASM_CLOBBER
#define CALL_1_ASM_CLOBBER "r0"
/************************************
** Calls with 1 to 6 arguments **
************************************/
Call_ret Kernel::call(Call_arg arg_0)
{
Call_ret result = 0;
asm volatile(CALL_1_ASM_OPS
: CALL_1_ASM_WRITE
:: CALL_1_ASM_CLOBBER);
return result;
}
Call_ret Kernel::call(Call_arg arg_0,
Call_arg arg_1)
{
Call_ret result = 0;
asm volatile(CALL_2_ASM_OPS
: CALL_2_ASM_WRITE
:: CALL_2_ASM_CLOBBER);
return result;
}
Call_ret Kernel::call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2)
{
Call_ret result = 0;
asm volatile(CALL_3_ASM_OPS
: CALL_3_ASM_WRITE
:: CALL_3_ASM_CLOBBER);
return result;
}
Call_ret Kernel::call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3)
{
Call_ret result = 0;
asm volatile(CALL_4_ASM_OPS
: CALL_4_ASM_WRITE
:: CALL_4_ASM_CLOBBER);
return result;
}
Call_ret Kernel::call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3,
Call_arg arg_4)
{
Call_ret result = 0;
asm volatile(CALL_5_ASM_OPS
: CALL_5_ASM_WRITE
:: CALL_5_ASM_CLOBBER);
return result;
}
Call_ret Kernel::call(Call_arg arg_0,
Call_arg arg_1,
Call_arg arg_2,
Call_arg arg_3,
Call_arg arg_4,
Call_arg arg_5)
{
Call_ret result = 0;
asm volatile(CALL_6_ASM_OPS
: CALL_6_ASM_WRITE
:: CALL_6_ASM_CLOBBER);
return result;
}
/*************************
** 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]);
}

View File

@ -1,183 +0,0 @@
/*
* \brief Syscall-framework implementation for ARM
* \author Martin stein
* \date 2011-11-30
*
* The code in this file is compliant to the general ARM instruction- and
* register-set but the semantics are tested only on ARMv6 and ARMv7 by now.
*/
/*
* Copyright (C) 2011-2013 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.
*/
/* Genode includes */
#include <kernel/syscalls.h>
using namespace Kernel;
/******************************************************************
** Inline assembly templates for syscalls with 1 to 6 arguments **
******************************************************************/
#define SYSCALL_6_ASM_OPS \
"mov r5, #0 \n" \
"add r5, %[arg_5] \n" \
SYSCALL_5_ASM_OPS
#define SYSCALL_5_ASM_OPS \
"mov r4, #0 \n" \
"add r4, %[arg_4] \n" \
SYSCALL_4_ASM_OPS
#define SYSCALL_4_ASM_OPS \
"mov r3, #0 \n" \
"add r3, %[arg_3] \n" \
SYSCALL_3_ASM_OPS
#define SYSCALL_3_ASM_OPS \
"mov r2, #0 \n" \
"add r2, %[arg_2] \n" \
SYSCALL_2_ASM_OPS
#define SYSCALL_2_ASM_OPS \
"mov r1, #0 \n" \
"add r1, %[arg_1] \n" \
SYSCALL_1_ASM_OPS
#define SYSCALL_1_ASM_OPS \
"mov r0, #0 \n" \
"add r0, %[arg_0] \n" \
"swi 0 \n" \
"mov %[result], #0 \n" \
"add %[result], r0 "
/*****************************************************************************
** Inline assembly "writeable" template-args for syscalls with 1 to 6 args **
*****************************************************************************/
#define SYSCALL_6_ASM_WRITE [arg_5] "+r" (arg_5), SYSCALL_5_ASM_WRITE
#define SYSCALL_5_ASM_WRITE [arg_4] "+r" (arg_4), SYSCALL_4_ASM_WRITE
#define SYSCALL_4_ASM_WRITE [arg_3] "+r" (arg_3), SYSCALL_3_ASM_WRITE
#define SYSCALL_3_ASM_WRITE [arg_2] "+r" (arg_2), SYSCALL_2_ASM_WRITE
#define SYSCALL_2_ASM_WRITE [arg_1] "+r" (arg_1), SYSCALL_1_ASM_WRITE
#define SYSCALL_1_ASM_WRITE \
[arg_0] "+r" (arg_0), \
[result] "+r" (result)
/**********************************************************************
** Inline assembly clobber lists for syscalls with 1 to 6 arguments **
**********************************************************************/
#define SYSCALL_6_ASM_CLOBBER "r5", SYSCALL_5_ASM_CLOBBER
#define SYSCALL_5_ASM_CLOBBER "r4", SYSCALL_4_ASM_CLOBBER
#define SYSCALL_4_ASM_CLOBBER "r3", SYSCALL_3_ASM_CLOBBER
#define SYSCALL_3_ASM_CLOBBER "r2", SYSCALL_2_ASM_CLOBBER
#define SYSCALL_2_ASM_CLOBBER "r1", SYSCALL_1_ASM_CLOBBER
#define SYSCALL_1_ASM_CLOBBER "r0"
/************************************
** Syscalls with 1 to 6 arguments **
************************************/
Syscall_ret Kernel::syscall(Syscall_arg arg_0)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_1_ASM_OPS
: SYSCALL_1_ASM_WRITE
:: SYSCALL_1_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_2_ASM_OPS
: SYSCALL_2_ASM_WRITE
:: SYSCALL_2_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_3_ASM_OPS
: SYSCALL_3_ASM_WRITE
:: SYSCALL_3_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_4_ASM_OPS
: SYSCALL_4_ASM_WRITE
:: SYSCALL_4_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_5_ASM_OPS
: SYSCALL_5_ASM_WRITE
:: SYSCALL_5_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4,
Syscall_arg arg_5)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_6_ASM_OPS
: SYSCALL_6_ASM_WRITE
:: SYSCALL_6_ASM_CLOBBER);
return result;
}
/*************************
** 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]);
}

View File

@ -1,160 +0,0 @@
/*
* \brief Syscall-framework implementation for ARM V7A systems
* \author Martin stein
* \date 2011-11-30
*/
/*
* Copyright (C) 2011-2013 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.
*/
/* Genode includes */
#include <base/syscall.h>
using namespace Kernel;
/******************************************************************
** Inline assembly templates for syscalls with 1 to 6 arguments **
******************************************************************/
#define SYSCALL_6_ASM_OPS \
"mov r5, #0 \n" \
"add r5, %[arg_5] \n" \
SYSCALL_5_ASM_OPS
#define SYSCALL_5_ASM_OPS \
"mov r4, #0 \n" \
"add r4, %[arg_4] \n" \
SYSCALL_4_ASM_OPS
#define SYSCALL_4_ASM_OPS \
"mov r3, #0 \n" \
"add r3, %[arg_3] \n" \
SYSCALL_3_ASM_OPS
#define SYSCALL_3_ASM_OPS \
"mov r2, #0 \n" \
"add r2, %[arg_2] \n" \
SYSCALL_2_ASM_OPS
#define SYSCALL_2_ASM_OPS \
"mov r1, #0 \n" \
"add r1, %[arg_1] \n" \
SYSCALL_1_ASM_OPS
#define SYSCALL_1_ASM_OPS \
"mov r0, #0 \n" \
"add r0, %[arg_0] \n" \
"svc 0x0 \n" \
"mov %[result], #0 \n" \
"add %[result], r0 "
/*****************************************************************************
** Inline assembly "writeable" template-args for syscalls with 1 to 6 args **
*****************************************************************************/
#define SYSCALL_6_ASM_WRITE [arg_5] "+r" (arg_5), SYSCALL_5_ASM_WRITE
#define SYSCALL_5_ASM_WRITE [arg_4] "+r" (arg_4), SYSCALL_4_ASM_WRITE
#define SYSCALL_4_ASM_WRITE [arg_3] "+r" (arg_3), SYSCALL_3_ASM_WRITE
#define SYSCALL_3_ASM_WRITE [arg_2] "+r" (arg_2), SYSCALL_2_ASM_WRITE
#define SYSCALL_2_ASM_WRITE [arg_1] "+r" (arg_1), SYSCALL_1_ASM_WRITE
#define SYSCALL_1_ASM_WRITE \
[arg_0] "+r" (arg_0), \
[result] "+r" (result)
/**********************************************************************
** Inline assembly clobber lists for syscalls with 1 to 6 arguments **
**********************************************************************/
#define SYSCALL_6_ASM_CLOBBER "r5", SYSCALL_5_ASM_CLOBBER
#define SYSCALL_5_ASM_CLOBBER "r4", SYSCALL_4_ASM_CLOBBER
#define SYSCALL_4_ASM_CLOBBER "r3", SYSCALL_3_ASM_CLOBBER
#define SYSCALL_3_ASM_CLOBBER "r2", SYSCALL_2_ASM_CLOBBER
#define SYSCALL_2_ASM_CLOBBER "r1", SYSCALL_1_ASM_CLOBBER
#define SYSCALL_1_ASM_CLOBBER "r0"
/************************************
** Syscalls with 1 to 6 arguments **
************************************/
Syscall_ret Kernel::syscall(Syscall_arg arg_0)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_1_ASM_OPS
: SYSCALL_1_ASM_WRITE
:: SYSCALL_1_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_2_ASM_OPS
: SYSCALL_2_ASM_WRITE
:: SYSCALL_2_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_3_ASM_OPS
: SYSCALL_3_ASM_WRITE
:: SYSCALL_3_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_4_ASM_OPS
: SYSCALL_4_ASM_WRITE
:: SYSCALL_4_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_5_ASM_OPS
: SYSCALL_5_ASM_WRITE
:: SYSCALL_5_ASM_CLOBBER);
return result;
}
Syscall_ret Kernel::syscall(Syscall_arg arg_0,
Syscall_arg arg_1,
Syscall_arg arg_2,
Syscall_arg arg_3,
Syscall_arg arg_4,
Syscall_arg arg_5)
{
Syscall_ret result = 0;
asm volatile(SYSCALL_6_ASM_OPS
: SYSCALL_6_ASM_WRITE
:: SYSCALL_6_ASM_CLOBBER);
return result;
}

View File

@ -14,7 +14,9 @@
/* Genode includes */
#include <base/ipc.h>
#include <base/thread.h>
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
#include <kernel/log.h>
using namespace Genode;

View File

@ -15,7 +15,9 @@
#include <base/thread.h>
#include <base/signal.h>
#include <signal_session/connection.h>
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
using namespace Genode;

View File

@ -13,7 +13,9 @@
/* Genode includes */
#include <base/thread.h>
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
void Genode::Thread_base::_thread_bootstrap()

View File

@ -18,8 +18,10 @@
#include <base/sync_allocator.h>
#include <base/allocator_avl.h>
#include <irq_session/irq_session.h>
/* base-hw includes */
#include <kernel/log.h>
#include <kernel/syscalls.h>
#include <kernel/interface.h>
/* core includes */
#include <platform_generic.h>

View File

@ -17,13 +17,15 @@
/* Genode includes */
#include <ram_session/ram_session.h>
#include <base/native_types.h>
#include <kernel/syscalls.h>
#include <kernel/log.h>
#include <base/thread.h>
#include <kernel/thread.h>
/* base-hw includes */
#include <kernel/interface.h>
#include <kernel/log.h>
/* core includes */
#include <address_space.h>
#include <kernel/thread.h>
namespace Genode {

View File

@ -16,7 +16,9 @@
/* Genode includes */
#include <root/component.h>
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
/* core includes */
#include <signal_session_component.h>

View File

@ -11,8 +11,8 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
/* core includes */
#include <kernel/irq.h>

View File

@ -244,7 +244,7 @@ void Thread::handle_exception()
{
switch (cpu_exception) {
case SUPERVISOR_CALL:
_syscall();
_call();
return;
case PREFETCH_ABORT:
_mmu_exception();
@ -297,9 +297,6 @@ char const * Kernel::Thread::pd_label() const
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_new_pd()
{
/* check permissions */
@ -317,9 +314,6 @@ void Thread::_call_new_pd()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_kill_pd()
{
/* check permissions */
@ -347,29 +341,24 @@ void Thread::_call_kill_pd()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_new_thread()
{
/* check permissions */
assert(_core());
/* dispatch arguments */
Syscall_arg const arg1 = user_arg_1();
Syscall_arg const arg2 = user_arg_2();
Call_arg const arg1 = user_arg_1();
Call_arg const arg2 = user_arg_2();
/* create thread */
Thread * const t = new ((void *)arg1)
Thread((Platform_thread *)arg2);
/* return thread ID */
user_arg_0((Syscall_ret)t->id());
user_arg_0((Call_ret)t->id());
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_delete_thread()
{
/* check permissions */
@ -384,9 +373,7 @@ void Thread::_call_delete_thread()
thread->~Thread();
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_start_thread()
{
/* check permissions */
@ -408,13 +395,10 @@ void Thread::_call_start_thread()
Native_utcb * const utcb_v = pt->virt_utcb();
bool const main = pt->main_thread();
t->init(ip, sp, cpu_id, pd_id, utcb_p, utcb_v, main, 1);
user_arg_0((Syscall_ret)t->_pd->tlb());
user_arg_0((Call_ret)t->_pd->tlb());
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_pause_thread()
{
unsigned const tid = user_arg_1();
@ -436,9 +420,6 @@ void Thread::_call_pause_thread()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_resume_thread()
{
/* lookup thread */
@ -479,9 +460,6 @@ void Thread_event::submit()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_yield_thread()
{
Thread * const t = Thread::pool()->object(user_arg_1());
@ -490,16 +468,9 @@ void Thread::_call_yield_thread()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_current_thread_id()
{ user_arg_0((Syscall_ret)id()); }
void Thread::_call_current_thread_id() { user_arg_0((Call_ret)id()); }
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_get_thread()
{
/* check permissions */
@ -518,25 +489,19 @@ void Thread::_call_get_thread()
user_arg_0(0);
}
} else { t = this; }
user_arg_0((Syscall_ret)t->platform_thread());
user_arg_0((Call_ret)t->platform_thread());
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_wait_for_request()
{
void * buf_base;
size_t buf_size;
_phys_utcb->syscall_wait_for_request(buf_base, buf_size);
_phys_utcb->call_wait_for_request(buf_base, buf_size);
Ipc_node::await_request(buf_base, buf_size);
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_request_and_wait()
{
Thread * const dst = Thread::pool()->object(user_arg_1());
@ -549,30 +514,24 @@ void Thread::_call_request_and_wait()
size_t msg_size;
void * buf_base;
size_t buf_size;
_phys_utcb->syscall_request_and_wait(msg_base, msg_size,
_phys_utcb->call_request_and_wait(msg_base, msg_size,
buf_base, buf_size);
Ipc_node::send_request_await_reply(dst, msg_base, msg_size,
buf_base, buf_size);
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_reply()
{
void * msg_base;
size_t msg_size;
_phys_utcb->syscall_reply(msg_base, msg_size);
_phys_utcb->call_reply(msg_base, msg_size);
Ipc_node::send_reply(msg_base, msg_size);
bool const await_request = user_arg_1();
if (await_request) { _call_wait_for_request(); }
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_route_thread_event()
{
/* check permissions */
@ -634,9 +593,6 @@ unsigned Thread_event::signal_context_id() const
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_access_thread_regs()
{
/* check permissions */
@ -679,9 +635,6 @@ void Thread::_call_access_thread_regs()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_update_pd()
{
assert(_core());
@ -689,9 +642,6 @@ void Thread::_call_update_pd()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_update_region()
{
assert(_core());
@ -702,18 +652,12 @@ void Thread::_call_update_region()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_print_char()
{
Genode::printf("%c", (char)user_arg_1());
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_new_signal_receiver()
{
/* check permissions */
@ -729,9 +673,6 @@ void Thread::_call_new_signal_receiver()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_new_signal_context()
{
/* check permissions */
@ -761,9 +702,6 @@ void Thread::_call_new_signal_context()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_await_signal()
{
/* check wether to acknowledge a context */
@ -791,9 +729,6 @@ void Thread::_call_await_signal()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_signal_pending()
{
/* lookup signal receiver */
@ -809,9 +744,6 @@ void Thread::_call_signal_pending()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_submit_signal()
{
/* lookup signal context */
@ -832,9 +764,6 @@ void Thread::_call_submit_signal()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_ack_signal()
{
/* lookup signal context */
@ -849,9 +778,6 @@ void Thread::_call_ack_signal()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_kill_signal_context()
{
/* check permissions */
@ -878,9 +804,6 @@ void Thread::_call_kill_signal_context()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_kill_signal_receiver()
{
/* check permissions */
@ -907,9 +830,6 @@ void Thread::_call_kill_signal_receiver()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_new_vm()
{
/* check permissions */
@ -927,13 +847,10 @@ void Thread::_call_new_vm()
Vm * const vm = new (allocator) Vm(state, context);
/* return vm id */
user_arg_0((Syscall_ret)vm->id());
user_arg_0((Call_ret)vm->id());
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_run_vm()
{
/* check permissions */
@ -948,9 +865,6 @@ void Thread::_call_run_vm()
}
/**
* Do specific syscall for this thread, for details see 'syscall.h'
*/
void Thread::_call_pause_vm()
{
/* check permissions */
@ -989,10 +903,7 @@ int Thread::_write_reg(addr_t const id, addr_t const value)
}
/**
* Handle a syscall request
*/
void Thread::_syscall()
void Thread::_call()
{
switch (user_arg_0()) {
case Call_id::NEW_THREAD: _call_new_thread(); return;

View File

@ -147,9 +147,9 @@ class Kernel::Thread
void _mmu_exception();
/**
* Handle syscall request of this thread
* Handle kernel-call request of this thread
*/
void _syscall();
void _call();
/**
* Read a thread register
@ -184,9 +184,9 @@ class Kernel::Thread
addr_t Thread::* _reg(addr_t const id) const;
/***************************************************
** Syscall backends, for details see 'syscall.h' **
***************************************************/
/****************************************************************
** Kernel-call backends, for details see 'kernel/interface.h' **
****************************************************************/
void _call_new_pd();
void _call_kill_pd();

View File

@ -13,7 +13,9 @@
/* Genode includes */
#include <base/printf.h>
#include <kernel/syscalls.h>
/* base-hw includes */
#include <kernel/interface.h>
/* core includes */
#include <ram_session_component.h>

View File

@ -15,7 +15,7 @@
#include <base/printf.h>
/* base-hw includes */
#include <kernel/syscalls.h>
#include <kernel/interface.h>
#include <placement_new.h>
/* core includes */