This example shows how to start a newly created thread with a defined set of CPU registers.
#include <l4/sys/thread.h>
#include <l4/sys/ipc.h>
#include <l4/sys/utcb.h>
#include <l4/util/util.h>
#include <stdlib.h>
#include <stdio.h>
static char thread_stack[8 << 10];
{
while (1)
{
printf("hey, I'm a thread\n");
printf("got register values: %ld %ld %ld %ld %ld %ld %ld\n",
d[7], d[6], d[5], d[4], d[2], d[1], d[0]);
}
}
asm(
".global thread \n\t"
"thread: \n\t"
#ifdef ARCH_x86
" pusha \n\t"
" push %esp \n\t"
" call thread_func \n\t"
#endif
#ifdef ARCH_arm
" push {r0-r7} \n\t"
" mov r0, sp \n\t"
" bl thread_func \n\t"
#endif
);
extern void thread(void);
int main(void)
{
int err;
printf("Example showing how to start a thread with an exception.\n");
printf("Make sure to start this program with ldr-flags=eager_map\n");
return 1;
return 1;
L4RE_THIS_TASK_CAP);
return 2;
return 3;
return 4;
{
printf("Umm, ipc error: %x\n", err);
return 1;
}
{
printf("PF?: %lx %lx (not prepared to handle this) %ld\n",
return 1;
}
#ifdef ARCH_x86
#endif
#ifdef ARCH_arm
#endif
printf("Error sending IPC: %x\n", err);
while (1)
return 0;
}