This example shows how system call tracing can be done.
This example shows how system call tracing can be done.
#if defined(ARCH_x86) || defined(ARCH_amd64)
#endif
#include <l4/sys/ipc.h>
#include <l4/sys/thread.h>
#include <l4/sys/utcb.h>
#include <l4/util/util.h>
#include <stdlib.h>
#include <stdio.h>
#if defined(ARCH_x86) || defined(ARCH_amd64)
static int
{
#if defined(ARCH_x86)
#else
#endif
}
static inline void
{
printf("PC=%08lx SP=%08lx Err=%08lx Trap=%lx, %s syscall, SC-Nr: %lx\n",
exc->
trapno, is_alien_after_call(exc) ?
" after" :
"before",
exc->err >> 3);
}
#elif defined(ARCH_arm)
static int
{
return exc->
err & 0x40; }
static inline void
{
printf("PC=%08lx SP=%08lx ULR=%08lx CPSR=%08lx Err=%lx/%lx, %s syscall\n",
is_alien_after_call(exc) ? " after" : "before");
}
#elif defined(ARCH_arm64)
static int
{
return exc->
err & (1ul << 16); }
static inline void
{
printf("PC=%08lx SP=%08lx PSTATE=%08lx Err=%lx/%lx, %s syscall\n",
is_alien_after_call(exc) ? " after" : "before");
}
#elif defined(ARCH_mips)
static int
{ return 0; }
static inline void
{
printf("PC=%08lx SP=%08lx Cause=%lx, %s syscall\n",
is_alien_after_call(exc) ? " after" : "before");
}
#elif defined(ARCH_riscv)
static int
{ return exc->cause == L4_riscv_ec_l4_alien_after_syscall; }
static inline void
{
printf("PC=%08lx SP=%08lx Cause=%lx, %s syscall\n",
is_alien_after_call(exc) ? " after" : "before");
}
#else
static int
static inline void
{
printf("PC=%08lx SP=%08lx, %s syscall\n",
is_alien_after_call(exc) ? " after" : "before");
}
#endif
#ifdef MEASURE
#include <l4/util/rdtsc.h>
static inline void
calibrate_timer(void)
{
}
static inline void
{
}
static inline void
alien_sleep(void)
{
}
static inline void
{
if (0)
_print_exc_state(exc);
}
#else
static inline void
calibrate_timer(void)
{
}
static inline void
{
(void)start;
}
{
return 0;
}
static inline void
alien_sleep(void)
{
}
static inline void
{
_print_exc_state(exc);
}
#endif
static char alien_thread_stack[8 << 10];
static void alien_thread(void)
{
while (1)
{
alien_sleep();
}
}
int main(void)
{
printf("Alien feature testing\n");
return 1;
l4_touch_rw(alien_thread_stack,
sizeof(alien_thread_stack));
return 2;
return 3;
return 4;
(
l4_umword_t)alien_thread_stack +
sizeof(alien_thread_stack),
0);
return 5;
return 6;
calibrate_timer();
{
printf("l4_ipc_receive failed");
return 7;
}
for (;;)
{
{
print_exc_state(&exc);
L4_UTCB_EXCEPTION_REGS_SIZE, 0, 0);
}
else
printf("Umm, non-handled request (like PF): %lx %lx\n", mr0, mr1);
{
printf("l4_ipc_call failed\n");
return 8;
}
print_timediff(s);
}
return 0;
}
Capability allocator C interface.
Debugger related definitions.
Common factory related definitions.
l4_cap_idx_t l4re_util_cap_alloc(void) L4_NOTHROW
Get free capability index at capability allocator.
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_addr_t
Address type.
l4_uint64_t l4_cpu_time_t
CPU clock type.
unsigned long l4_cap_idx_t
Capability selector type.
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
@ L4_CAP_SHIFT
Capability index shift.
l4_msgtag_t l4_debugger_set_object_name(l4_cap_idx_t cap, const char *name) L4_NOTHROW
Set the name of a kernel object.
l4_msgtag_t l4_factory_create_thread(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new thread.
l4_msgtag_t l4_ipc_receive(l4_cap_idx_t object, l4_utcb_t *utcb, l4_timeout_t timeout) L4_NOTHROW
Wait for a message from a specific source.
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
@ L4_PROTO_ALLOW_SYSCALL
Allow an alien the system call.
l4_msgtag_t l4_scheduler_run_thread(l4_cap_idx_t scheduler, l4_cap_idx_t thread, l4_sched_param_t const *sp) L4_NOTHROW)
Run a thread on a Scheduler.
l4_sched_param_t l4_sched_param(unsigned prio, l4_umword_t quantum=0) L4_NOTHROW
Construct scheduler parameter.
l4_msgtag_t l4_thread_ex_regs(l4_cap_idx_t thread, l4_addr_t ip, l4_addr_t sp, l4_umword_t flags) L4_NOTHROW
Exchange basic thread registers.
void l4_thread_control_bind(l4_utcb_t *thread_utcb, l4_cap_idx_t task) L4_NOTHROW
Bind the thread to a task.
l4_msgtag_t l4_thread_control_commit(l4_cap_idx_t thread) L4_NOTHROW
Commit the thread control parameters.
void l4_thread_control_alien(int on) L4_NOTHROW
Enable alien mode.
void l4_thread_control_exc_handler(l4_cap_idx_t exc_handler) L4_NOTHROW
Set the exception handler.
void l4_thread_control_start(void) L4_NOTHROW
Start a thread control API sequence.
void l4_thread_control_pager(l4_cap_idx_t pager) L4_NOTHROW
Set the pager.
#define L4_IPC_NEVER
never timeout
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
l4_exc_regs_t * l4_utcb_exc(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB (for an exception IPC).
l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Access function to get the program counter of the exception state.
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
l4_uint64_t l4_tsc_to_ns(l4_cpu_time_t tsc)
Convert timestamp to ns value.
l4_uint32_t l4_calibrate_tsc(l4_kernel_info_t const *kip)
Determine scalers for timestamp calculations.
l4_cpu_time_t l4_rdtsc(void)
Read current value of CPU-internal timestamp counter.
Kumem allocator utility C interface.
int l4re_util_kumem_alloc(l4_addr_t *mem, unsigned pages_order, l4_cap_idx_t task, l4_cap_idx_t rm) L4_NOTHROW
Allocate state area.
UTCB structure for exceptions.
l4_umword_t trapno
trap number
l4_umword_t sp
stack pointer
l4_umword_t err
error code
Message tag data structure.
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.