Esempio n. 1
0
static void
zone0150_thread1_routine(void)
{
    L4_MsgTag_t result;

    L4_ThreadId_t thread0_tid;

    okl4_init_thread();

    while (zone0150_children_can_run == 0) {
        /* spin */
    }

    thread0_tid.raw = thread0_cap.raw;

    result = L4_Receive(thread0_tid);
    fail_unless(L4_IpcSucceeded(result) != 0, "thread1 L4_Receive() failed.");
    result = L4_Send(thread0_tid);
    fail_unless(L4_IpcSucceeded(result) != 0, "thread1 L4_Send() failed.");

    result = L4_Call(thread0_tid);
    fail_unless(L4_IpcSucceeded(result) != 0, "thread1 L4_Call() failed.");

    zone0150_child_thread_run++;

    L4_WaitForever();
}
Esempio n. 2
0
File: mutex.c Progetto: BruceYi/okl4
static void
lock_mutex_thread(void)
{
    L4_MsgTag_t tag;
    L4_Word_t label;
    L4_Word_t res;

    tag = L4_Receive(main_thread);
    while (1) {
        label = L4_Label(tag);
        if (label == 0xa) {
            res = L4_Lock(m);
            fail_unless(res == 1, "L4_Lock() failed");
            L4_Unlock(m);
        }
        if (label == 0xb) {
            res = L4_TryLock(m);
            fail_unless(res == 0, "L4_TryLock() did not fail");
            fail_unless(L4_ErrorCode() == L4_ErrMutexBusy, "Wrong error code");
        }

        tag = L4_Call(main_thread);
    }

    L4_WaitForever();
}
Esempio n. 3
0
/* Child startup point. */
static void
child_startup(void)
{
    struct startup_args args;
    okl4_word_t bytes;
    int error;

    /* Setup libokl4. */
    okl4_init_thread();

    /* Wait for parent to tell us our args. */
    error = okl4_message_wait(&args, sizeof(args), &bytes, NULL);
    assert(!error);
    assert(bytes == sizeof(args));
    error = okl4_message_send(args.parent, NULL, 0);
    assert(!error);

    /* Run the child function. */
    args.startup(args.id, args.peers, args.arg);

    /* Tell our parent we have finished. */
    error = okl4_message_send(args.parent, NULL, 0);
    assert(!error);

    /* Block waiting for them to kill us. */
#if defined(OKL4_KERNEL_MICRO)
    L4_WaitForever();
#else
    okl4_kthread_exit();
#endif
}
Esempio n. 4
0
static void
ping_thread_simulated (void)
{
    volatile L4_Word_t x;
    /* Wait for pong thread to come up */
    L4_Msg_t msg;
    L4_MsgTag_t tag;
    for (int i=0; i < num_iterations; i++) {
        L4_Fpage_t ppage = L4_Fpage((L4_Word_t)&fault_area[i*1024], 4096);

        L4_Set_Rights(&ppage, L4_FullyAccessible);
        /* accept fpages */
        L4_Accept(L4_UntypedWordsAcceptor);

        /* send it to our pager */
        L4_MsgClear(&msg);
        L4_MsgAppendWord(&msg, (L4_Word_t) ppage.raw);
        L4_MsgAppendWord(&msg, (L4_Word_t) 0);
        L4_Set_Label(&msg.tag, L4_PAGEFAULT);
        L4_MsgLoad(&msg);

        /* make the call */
        tag = L4_Call(pager_tid);
        x = fault_area[i*1024];
    }

    /* Tell master that we're finished */
    L4_Set_MsgTag (L4_Niltag);
    L4_Send (master_tid);

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 5
0
static void
locking_m2_thread(void)
{
    L4_Lock(mutex2);

    L4_WaitForever();
    while(1) ;
}
Esempio n. 6
0
static void
other_sending_thread(void)
{
    L4_LoadMR(0, 0);
    L4_Send(prio5_thread);

    L4_WaitForever();
    while(1) ;
}
Esempio n. 7
0
File: mutex.c Progetto: BruceYi/okl4
END_TEST

static void mutex0406_child_thread(void)
{
    L4_Word_t res;

    res = L4_Lock(m);
    fail("Unexpectantly acquired lock\n");
    L4_WaitForever();
}
Esempio n. 8
0
static void
zone0700_write_thread(void)
{
    okl4_init_thread();

    *(volatile okl4_word_t *)zone0700_base[myself] = 0xdeadbeefU;
    read_write_done = 1;

    L4_WaitForever();
}
Esempio n. 9
0
File: mutex.c Progetto: BruceYi/okl4
static void mutex0600_child_thread(void)
{
    L4_Word_t res;

    mutex0600_progress = 1;
    res = L4_Lock(m);
    mutex0600_progress = 2;
    fail_unless(res == 0, "L4_Lock() did not fail");
    L4_WaitForever();
}
Esempio n. 10
0
static void
zone0400_thread1_routine(void)
{
    okl4_init_thread();

    *(volatile okl4_word_t *)zone0400_shared_zone_addr.base = 1;

    zone0400_child_thread_b_done = 1;
    L4_WaitForever();
}
Esempio n. 11
0
File: mutex.c Progetto: BruceYi/okl4
static void mutex0705_high_thread(void)
{
    /* Acquire the mutex. */
    L4_Lock(m);
    L4_Unlock(m);

    /* Inform master thread we have the lock. */
    L4_Send(main_thread);

    L4_WaitForever();
}
Esempio n. 12
0
/*
 * Called when Linux startup fails / exit server
 * XXX: Send status to iguana/loader?
 */
void
_Exit(int status)
{
#ifndef NDEBUG
	printk("Linux exit status: %d\n", status);
	L4_KDB_Enter("Linux exit");
#endif
	assert(!"Can't exit -- shouldn't reach here");
	L4_WaitForever();
	while(1);
}
Esempio n. 13
0
static void
pong_thread_faulter (void)
{
    volatile L4_Word_t x;
    x = fault_area[0];

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 14
0
File: mutex.c Progetto: BruceYi/okl4
END_TEST

static void
mutex0405_child_thread(void)
{
    L4_Word_t res;

    res = L4_Lock(m);
    fail_unless(res == 1, "L4_Lock() failed");
    L4_Send(main_thread);
    L4_WaitForever();
}
Esempio n. 15
0
static void
pong_thread_ovh (void)
{
    L4_Word_t untyped = 0;

    for (int i = 0; i < num_iterations; i++) {
        pingpong_ipc_ovh(ping_tid, untyped);
    }

    L4_Send(ping_tid);
    for (;;)
            L4_WaitForever();
    /* NOTREACHED */
}
Esempio n. 16
0
static void
zone0800_thread_routine(void)
{
    okl4_init_thread();

    zone0800_child_thread_run = 1;

    /* Write to magic address to trigger a pagefault. */
    *((volatile okl4_word_t *)zone0800_thread_faulting_address) = 1;

    /* Let parent know we survived the ordeal. */
    zone0800_child_thread_run = 2;
    L4_WaitForever();
}
Esempio n. 17
0
File: check.c Progetto: BruceYi/okl4
void _fail_unless (int result, const char *file,
                   int line, const char * msg, ...)
{
  va_list ap;
  char buf[BUFSIZ];

  /* Ensure a sane message was passed in. */
  if (msg == NULL) {
    eprintf ("_fail_unless() called with NULL msg",__FILE__,__LINE__);
    msg = "(null)";
  }

  /* If we passed the test, we need do nothing more. */
  if (result) {
      return;
  }

  /* Unlike normal libcheck, we don't want to mark all the time, as it can
   * waste a lot of memory, so we only mark on failure */
  send_loc_info (get_send_key(), file, line);

  va_start(ap,msg);
  vsnprintf(buf, BUFSIZ, msg, ap);
  va_end(ap);

  /* Display a failure message now, just in case we don't make it
   * until the end of the tests. */
  printf("*** Failure: ");
  puts(buf);

  /* Send failure information to the test controller. */
  send_failure_info(get_send_key(), buf);

#if defined(OKL4_KERNEL_MICRO)
  /* Send failure message to our pager. */
  if (cur_fork_status() == CK_WITHPAGER) {
    L4_MsgTag_t tag = L4_Niltag;

    /* Send a failure message to the test runner. A label of '1' indicates
     * failure. */
    tag = L4_MsgTagAddLabel(tag, 1);
    L4_Set_MsgTag(tag);

    /* Inform the library, and wait for them to kill us. */
    L4_Call(libcheck);
    L4_WaitForever();
  }
#endif
}
Esempio n. 18
0
File: mutex.c Progetto: BruceYi/okl4
static void mutex0403_worker_thread(void)
{
    int i;
    for (i = 0; i < 100; i++) {
        L4_Lock(m);
        mutex0403_lock_holder = L4_Myself();
        L4_Yield();
        fail_unless(mutex0403_lock_holder.raw == L4_Myself().raw,
                "Protected counter changed while we held the lock.");
        L4_Unlock(m);
        L4_Yield();
    }
    L4_Send(main_thread);
    L4_WaitForever();
}
Esempio n. 19
0
static void
ping_thread_async_ovh (void)
{
    for (int i=0; i < num_iterations; i++)
    { ; }
    
    /* Tell master that we're finished */
    L4_Set_MsgTag (L4_Niltag);
    L4_Send (master_tid);

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 20
0
static void
zone0700_read_thread(void)
{
    okl4_word_t tmp;
    int i;

    okl4_init_thread();

    for(i=0; i<K_ZONE; i++) {
        tmp = *(volatile okl4_word_t *)zone0700_base[i];
        fail_unless(tmp == 0xdeadbeefU, "Unexpected value read!\n");
    }
    read_write_done = 1;

    L4_WaitForever();
}
Esempio n. 21
0
static void
zone0600_thread(void)
{
    int tmp;

    okl4_init_thread();

    tmp = *(volatile int *)base;
    read_write_done = 1;

    *(volatile int *)base = 1;
    read_write_done = 2;

    *(volatile int *)base = tmp;

    L4_WaitForever();
}
Esempio n. 22
0
static void
ping_thread_ovh (void)
{
    /* Wait for pong thread to come up */
    L4_Receive (pong_tid);
    for (int i=0; i < num_iterations; i++) {
        pingpong_ipc_ovh (pong_tid, num_mrs);
    }
    /* Tell master that we're finished */
    L4_Set_MsgTag (L4_Niltag);
    L4_Send (master_tid);

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 23
0
static void
ping_thread_pager (void)
{
    volatile L4_Word_t x;
    /* Wait for pong thread to come up */
    for (int i=0; i < num_iterations; i++) {
        x = *  (L4_Word_t*) ( ((uintptr_t) &fault_area[i*1024]) + (30 * 1024 * 1024));
    }

    /* Tell master that we're finished */
    L4_Set_MsgTag (L4_Niltag);
    L4_Send (master_tid);

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 24
0
File: mutex.c Progetto: BruceYi/okl4
END_TEST

static void mutex0705_low_thread(void)
{
    /* Acquire the mutex. */
    L4_Lock(m);

    /* Inform master thread we have the lock. */
    L4_Send(main_thread);

    /* Release the lock for somebody else to have. */
    L4_Unlock(m);

    /* Ensure that we don't run ever again. */
    fail("Low priority thread should not run.");

    L4_WaitForever();
}
Esempio n. 25
0
static void
ping_thread_rpc_server(void)
{
    int i;
    L4_ThreadId_t cap;

    /* Wait for pong thread to come up */
    L4_Wait(&cap);

    for (i = 0; i < num_iterations; i++) {
        pingpong_ipc_rpc_server(cap, num_mrs, &cap);
    }
    /* Tell master that we're finished */
    L4_Set_MsgTag(L4_Niltag);
    L4_Send(master_tid);

    L4_WaitForever();
    /* NOTREACHED */
}
Esempio n. 26
0
static void
worker_a(void *ignore)
{
    ARCH_THREAD_INIT
    memsection_ref_t m;
    uintptr_t base;
    int i;

    L4_KDB_SetThreadName(thread_l4tid(thread_myself()), "worker_a");
    L4_Yield();

    for (i = 0; i < 10000; i++) {
        m = pd_create_memsection(pd_myself(), 1UL << 31, &base);
        assert(m == 0);
    }

    worker_a_done = 1;
    L4_WaitForever();
}
Esempio n. 27
0
File: mutex.c Progetto: BruceYi/okl4
END_TEST

/* L4_Mutex Priority Tests ------------------------------------------*/

#define NUM_CHILDREN 3

static void mutex0700_child_thread(void)
{
    /* Acquire the mutex. */
    L4_Lock(m);

    /* Inform master thread we have the lock. */
    L4_Send(main_thread);

    /* Release the lock for somebody else to have. */
    L4_Unlock(m);

    L4_WaitForever();
}
Esempio n. 28
0
static void
ping_thread_buffer (void)
{
    volatile L4_Word_t x;

    /* Wait for pong thread to come up */
    L4_Receive (pong_tid);

    for (int i=0; i < num_iterations; i++) {
        pingpong_ipc (pong_tid, num_mrs);
        x = fault_area[0];
    }

    /* Tell master that we're finished */
    L4_Set_MsgTag (L4_Niltag);
    L4_Send (master_tid);

    for (;;)
        L4_WaitForever();

    /* NOTREACHED */
}
Esempio n. 29
0
static void
sending_thread(void)
{
    L4_Word_t result;
    L4_MsgTag_t tag;

    if (L4_UserDefinedHandle()) {
        result = L4_Lock(mutex2);
        fail_unless(result == 1, "L4_Lock() failed");
    }
    L4_LoadMR(0, 0);
    L4_Send(main_thread);

    tag = L4_Receive(setup_thread);
    if (L4_Label(tag) == 0x3) {
        L4_Unlock(mutex2);
        L4_LoadMR(0, 0);
        L4_Send(main_thread);
    }
    L4_WaitForever();
    while(1) ;
}
Esempio n. 30
0
static void
worker_b(void *ignore)
{
    ARCH_THREAD_INIT
    memsection_ref_t m;
    uintptr_t base;
    int i;
    char *p;

    L4_KDB_SetThreadName(thread_l4tid(thread_myself()), "worker_b");
    L4_Yield();

    for (i = 0; i < 1000; i++) {
        m = pd_create_memsection(pd_myself(), MEM_SIZE, &base);
        assert(m != 0);
        p = (char *)base;
        memset(p, '%', 0x10);
        memsection_delete(m);
    }

    worker_b_done = 1;
    L4_WaitForever();
}