This example shows how to send IPC using the UTCB to store payload.
#include <l4/sys/ipc.h>
#include <l4/sys/thread.h>
#include <l4/sys/utcb.h>
#include <stdio.h>
static unsigned char stack2[8 << 10];
static void thread1(void)
{
int i, j;
printf(
"Thread1 up (%p)\n",
l4_utcb());
for (i = 0; i < 10; i++)
{
mr->
mr[j] =
'A' + (i + j) % (
'~' -
'A' + 1);
printf("IPC-send error\n");
}
}
L4UTIL_THREAD_STATIC_FUNC(thread2)
{
unsigned i;
printf(
"Thread2 up (%p)\n",
l4_utcb());
while (1)
{
printf("IPC receive error\n");
printf(
"%c", (
char)mr.
mr[i]);
printf("\n");
}
__builtin_trap();
}
int main(void)
{
return 1;
return 1;
L4RE_THIS_TASK_CAP);
return 2;
return 3;
return 4;
thread1();
return 0;
}
Capability allocator C interface.
Common factory related definitions.
l4_cap_idx_t l4re_util_cap_alloc(void) L4_NOTHROW
Get free capability index at capability allocator.
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_cap_idx_t
L4 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_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_send(l4_cap_idx_t dest, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Send a message to an object (do not wait for a reply).
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Return error code of a system call return message tag or the tag label.
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.
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
l4_sched_param_t l4_sched_param(unsigned prio, l4_cpu_time_t quantum=0) L4_NOTHROW
Construct scheduler parameter.
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_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_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.
@ L4_UTCB_GENERIC_DATA_SIZE
Total number of message register (MRs) available.
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.
Low-level Thread Functions.
Message tag data structure.
l4_cap_idx_t main_thread
Object-capability of the first user thread.
Encapsulation of the message-register block in the UTCB.
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.