Beispiel #1
0
/*
 * prevent all other threads from running
 */
void 
jthread_suspendall(void)
{
 l4_umword_t   old_eflags;
 l4_umword_t   dummy;
 l4_msgdope_t  result;
 l4_threadid_t src;
 l4_threadid_t preempter  = L4_INVALID_ID;
 l4_threadid_t pager      = L4_INVALID_ID;
 jthread_t     current    = live;
 l4thread_t    myself     = l4thread_myself();

 leaflet.gc = l4_myself();

// LOG("suspendall");
 /*
  * ex-regs all threads and save their state
  */
 while (current)
  {
    /**
     * NoHeapRealtimeThreads will not be stopped
     */
    if (current->daemon==0 &&
        #ifdef REALTIME_EXTENSION
        current->threadtype != THREADTYPE_NOHEAPREAL &&
        #endif
        !l4thread_equal(current->l4thread,myself))
    { 
      l4_thread_ex_regs(l4thread_l4_id(current->l4thread),
                        (unsigned long)_l4threads_suspendall,
                        (l4_umword_t)-1,
                        &preempter,
                        &pager,
                        &old_eflags,&current->eip,&current->esp);
    }
    current = current -> next;
  }

 /*
  * Waiting for the notification IPC of the last stopped thread
  */
 {
   l4_ipc_wait(&src, L4_IPC_SHORT_MSG, &dummy, &dummy,
                           L4_IPC_NEVER,&result);
 }while(!l4_tasknum_equal(leaflet.gc, src) ||
         L4_IPC_ERROR(result) == L4_IPC_RECANCELED ||
         L4_IPC_ERROR(result) == L4_IPC_REABORTED);

// LOG("suspendall-complete");
}
Beispiel #2
0
/*
 * restore threads
 */
void
jthread_unsuspendall(void)
{
 volatile unsigned long int * ret_addr;
 l4_umword_t   old_eflags,dummy;
 l4_threadid_t preempter = L4_INVALID_ID;
 l4_threadid_t pager     = L4_INVALID_ID;
 l4thread_t    myself    = l4thread_myself();
 jthread_t     current   = live;

 while (current)
 {
   /**
    * NoHeapRealtimeThreads are never stopped and therefore they are not resumed
    */
   if (current->daemon==0 &&
       #ifdef REALTIME_EXTENSION
       current->threadtype != THREADTYPE_NOHEAPREAL &&
       #endif
       !l4thread_equal(current->l4thread,myself))
     {
       current->esp -= 0x04; 
       /* stack address for the return address*/
       ret_addr      = (unsigned long int *)current->esp;
       /* replace place holder with the eip*/
       *ret_addr     = current->eip;
       l4_thread_ex_regs(l4thread_l4_id(current->l4thread),
                         (unsigned long)_l4threads_resumepoint,
                         current->esp-0x24,
                         &preempter, &pager,
                         &old_eflags, &dummy, &dummy);
  }
  current = current -> next;
 }

 sleepcount = 0;

}
Beispiel #3
0
/******************************************************************************
 * main                                                                       *
 *                                                                            *
 * Main function                                                              *
 ******************************************************************************/
int main(int argc, char *argv[])
{
  int error = 0, i=1;
  l4_threadid_t dummy_l4id = L4_NIL_ID, loader_id;
//  l4events_event_t event;
//  l4events_nr_t eventnr;

  CORBA_Environment _env = dice_default_environment;

  /* init */
  do_args(argc, argv);
  my_l4id = l4thread_l4_id( l4thread_myself() );

  LOG("Hello, I'm running as "l4util_idfmt, l4util_idstr(my_l4id));

  /* ask for 'con' (timeout = 5000 ms) */
  if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 50000) == 0) 
    {
      LOG("PANIC: %s not registered at names", CON_NAMES_STR);
      enter_kdebug("panic");
    }

  if (names_waitfor_name("LOADER", &loader_id, 50000) == 0)
    {
      LOG("PANIC: LOADER not registered at names");
      enter_kdebug("panic");
    }
  
  if (con_if_openqry_call(&con_l4id, MY_SBUF_SIZE, 0, 0,
		     L4THREAD_DEFAULT_PRIO,
		     &vc_l4id, 
	  	     CON_VFB, &_env))
    enter_kdebug("Ouch, open vc failed");
  
  if (con_vc_smode_call(&vc_l4id, CON_OUT, &dummy_l4id, &_env))
    enter_kdebug("Ouch, setup vc failed");

  if (con_vc_graph_gmode_call(&vc_l4id, &gmode, &xres, &yres,
			 &bits_per_pixel, &bytes_per_pixel,
			 &bytes_per_line, &accel_flags, 
			 &fn_x, &fn_y, &_env))
    enter_kdebug("Ouch, graph_gmode failed");

  if (bytes_per_pixel != 2)
    {
      printf("Graphics mode not 2 bytes/pixel, exiting\n");
      con_vc_close_call(&vc_l4id, &_env);
      exit(0);
    }

  if (create_logo())
    enter_kdebug("Ouch, logo creation failed");

  while (!error && (i>0)) 
    {
      if ((error = clear_screen()))
	enter_kdebug("Ouch, clear_screen failed");
      if ((error = logo()))
	enter_kdebug("Ouch, logo failed");
      l4_sleep(500);
      i--;
    }

  if (con_vc_close_call(&vc_l4id, &_env))
    enter_kdebug("Ouch, close vc failed?!");
  
  LOG("Finally closed vc");

  LOG("Going to bed ...");

  names_register("CON_DEMO1");
/*
  my_id = l4_myself();
  event.len=sizeof(l4_umword_t);
  *(l4_umword_t*)event.str=my_id.id.task;
  
  l4events_send(1, &event, &eventnr, L4EVENTS_SEND_ACK);
  l4events_get_ack(eventnr, L4_IPC_NEVER);
*/  
  return 0;
}
Beispiel #4
0
/******************************************************************************
 * main                                                                       *
 *                                                                            *
 * Main function                                                              *
 ******************************************************************************/
int main(int argc, char *argv[])
{
  int error = 0;
  l4_threadid_t dummy_l4id = L4_NIL_ID;

  CORBA_Environment _env = dice_default_environment;

  /* init */
  do_args(argc, argv);
  my_l4id = l4thread_l4_id( l4thread_myself() );

  LOG("Hello, I'm running as "l4util_idfmt, l4util_idstr(my_l4id));

  /* ask for 'con' (timeout = 5000 ms) */
  if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 50000) == 0) 
    {
      LOG("PANIC: %s not registered at names", CON_NAMES_STR);
      enter_kdebug("panic");
    }

  if (con_if_openqry_call(&con_l4id, MY_SBUF_SIZE, 0, 0,
		     L4THREAD_DEFAULT_PRIO,
		     &vc_l4id, 
	  	     CON_VFB, &_env))
    enter_kdebug("Ouch, open vc failed");
  
  if (con_vc_smode_call(&vc_l4id, CON_OUT, &dummy_l4id, &_env))
    enter_kdebug("Ouch, setup vc failed");

  if (con_vc_graph_gmode_call(&vc_l4id, &gmode, &xres, &yres,
			 &bits_per_pixel, &bytes_per_pixel,
			 &bytes_per_line, &accel_flags, 
			 &fn_x, &fn_y, &_env))
    enter_kdebug("Ouch, graph_gmode failed");

  if (bytes_per_pixel != 2)
    {
      printf("Graphics mode not 2 bytes/pixel, exiting\n");
      con_vc_close_call(&vc_l4id, &_env);
      exit(0);
    }

  if (create_logo())
    enter_kdebug("Ouch, logo creation failed");

  while (!error) 
    {
      if ((error = clear_screen()))
	enter_kdebug("Ouch, clear_screen failed");
      if ((error = logo()))
	enter_kdebug("Ouch, logo failed");
      l4_sleep(2000);
    }

  if (con_vc_close_call(&vc_l4id, &_env))
    enter_kdebug("Ouch, close vc failed?!");
  
  LOG("Finally closed vc");

  LOG("Going to bed ...");
  l4_sleep(-1);

  return 0;
}
Beispiel #5
0
			       L4THREAD_CREATE_SYNC));  

        #endif

        leaflet.threadCollector   = threadCollector;
        leaflet.onthreadexit      = _onthreadexit; /* function to call, if a thread dies*/
        leaflet.daemonCount       = 0; /* count of all daemon threads */
        leaflet.threadCount       = 1; /* count of all threads */
        #ifdef REALTIME_EXTENSION
        leaflet.noheapthreadCount = 0; /* count of all NoHeapRealtime threads */
        #endif

        athread = KGC_malloc(threadCollector, sizeof (*athread), KGC_ALLOC_THREADCTX);
        KGC_addRef(threadCollector, athread);

        athread->l4thread     = l4thread_myself();
        athread->prev         = NULL;
        athread->next         = NULL;
        athread->daemon       = 0; // no daemon thread
	athread->interrupting = 0;
        #ifdef REALTIME_EXTENSION
        athread->status       = 0;
        #endif

	assert(live == NULL);

        live = athread;

        /* allocate data key */
        leaflet.datakey = l4thread_data_allocate_key();
        if (leaflet.datakey < 0) assert(!"l4thread_data_allocate_key failed");