コード例 #1
0
ファイル: main.c プロジェクト: ErisBlastar/osfree
void event_thread(void)
{
  l4events_ch_t event_ch = L4EVENTS_EXIT_CHANNEL;
  l4events_nr_t event_nr = L4EVENTS_NO_NR;
  l4events_event_t event;
  l4_threadid_t tid;
  int rc;

  if (!l4events_init())
  {
    LOG_Error("l4events_init() failed");
    __exit(1, 1);
  }

  if ((rc = l4events_register(L4EVENTS_EXIT_CHANNEL, 15)) != 0)
  {
    LOG_Error("l4events_register failed");
    __exit(1, 1);
  }

  while(1)
  {
    /* wait for event */
    if ((rc = l4events_give_ack_and_receive(&event_ch, &event, &event_nr,
					    L4_IPC_NEVER,
					    L4EVENTS_RECV_ACK))<0)
    {
      l4env_perror("l4events_give_ack_and_receive()", -rc);
      continue;
    }
    tid = *(l4_threadid_t *)event.str;
    LOG("Got exit event for "l4util_idfmt, l4util_idstr(tid));

    /* exit myself */
    if (l4_task_equal(tid, os2srv))
      __exit(1, rc);
  }
}
コード例 #2
0
ファイル: main.c プロジェクト: RajasekharBhumi/L4Re
static void get_fb(void)
{
  l4_addr_t fpage_addr;
  l4_size_t fpage_size;
  l4dm_dataspace_t ds;
  CORBA_Environment env = dice_default_environment;
  int i, pages, error;
  struct stat st;

  /* check if we're running under L4Linux */
  if (stat("/proc/l4", &st) == -1) {
    fprintf(stderr, "Error: /proc/l4 doesn't exist, not running on L4Linux?!\n");
    exit(1);
  }

  /* ask for 'con' (timeout = 5000 ms) */
  if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 5000) == 0) {
    fprintf(stderr, "PANIC: %s not registered at names", CON_NAMES_STR);
    exit(1);
  }
  INFO("Found my console through names, it's at "l4util_idfmt".\n",
       l4util_idstr(con_l4id));

  PRINT("Screenshot'ing, please smile... ;-)\n");
  /* get screenshot */
  if (con_if_screenshot_call(&con_l4id, get_vc, &ds, 
			&xres, &yres, &bpp, &env)) {
    fprintf(stderr, "Could not get screenshot\n");
    exit(1);
  }
  INFO("Got screenshot: res: %dx%d, bpp: %d\n", xres, yres, bpp);

  if (l4dm_mem_size(&ds, &fb_size)) {
    fprintf(stderr, "Couldn't get size of data space\n");
    exit(1);
  }
  INFO("Size of data space: %d\n", fb_size);

  if ((fb_mem = malloc(fb_size)) == NULL) {
    fprintf(stderr, "Couldn't malloc %d Bytes of memory!\n", fb_size);
    exit(1);
  }
  raw_pic_size = xres*yres*3;
  if ((raw_pic_mem = malloc(raw_pic_size)) == NULL) {
    fprintf(stderr, "Couldn't malloc %d bytes of memory!\n", raw_pic_size);
    exit(1);
  }
  
  pages = fb_size / L4_PAGESIZE; // size is always a multiple of L4_PAGESIZE?
  for (i = 0; i < pages; i++) {
    /* unmap memory */
    l4_fpage_unmap(l4_fpage((l4_umword_t)map_page, L4_LOG2_PAGESIZE,
	  	   L4_FPAGE_RW, L4_MAP_ITEM_MAP),
                   L4_FP_FLUSH_PAGE|L4_FP_ALL_SPACES);

    /* page in L4 page */
    if ((error = l4dm_map_pages(&ds, i*L4_PAGESIZE, L4_PAGESIZE,
			        (l4_addr_t)map_page, L4_LOG2_PAGESIZE,
				0, L4DM_RO, &fpage_addr,&fpage_size)) < 0) {
      fprintf(stderr, "Error %d requesting ds %d at ds_manager "
	      l4util_idfmt"\n",
	  error, ds.id, l4util_idstr(ds.manager));
      l4dm_close(&ds);
      exit(error);
    }

    memcpy(fb_mem + i*L4_PAGESIZE, map_page, L4_PAGESIZE);
  }

  if (l4dm_close(&ds)) {
    fprintf(stderr, "Error on closing dataspace, expect memory leakage...\n");
  }
}
コード例 #3
0
ファイル: main.c プロジェクト: michas2/l4re-snapshot
static void eval_event(ferret_list_entry_common_t * e)
{
    //static unsigned short last = -1;
    //static int count_atomic  = 0;
    //static int count_context = 0;

    ferret_list_entry_kernel_t * k = (ferret_list_entry_kernel_t *)e;

    static ferret_utime_t t_start_atomic = 0;
    static ferret_utime_t t_stop_atomic  = 0;
    static ferret_utime_t t_last_context = 0;
    static int l4lx_task_id         = -1;
    static int l4lx_tamer_thread_id = -1;
    static int dump_count = -1;

    switch (e->major)
    {
    case FERRET_L4LX_MAJOR:
        /* debug stuff ...
        if (last != FERRET_L4LX_MAJOR)
        {
            append_count(count_context);
            count_context = 0;
        }
        count_atomic++;
        last = FERRET_L4LX_MAJOR;
        ... debug stuff */
        switch (e->minor)
        {
        case FERRET_L4LX_ATOMIC_BEGIN:
            t_start_atomic = e->timestamp;
            t_stop_atomic  = 0;
            if (l4lx_task_id == -1)  // L4Linux kernel's task id
            {
                l4lx_task_id = ((l4_threadid_t)(e->data32[0])).id.task;
                l4lx_tamer_thread_id =
                    ((l4_threadid_t)(e->data32[0])).id.lthread;
                printf("Tamer TID: %x.%x\n",
                       l4lx_task_id, l4lx_tamer_thread_id);
            }
            break;
        case FERRET_L4LX_ATOMIC_END1:
        case FERRET_L4LX_ATOMIC_END2:
            t_stop_atomic = e->timestamp;
            //printf("%llu:%llu, %llu\n",
            //       t_start_atomic, t_stop_atomic, t_last_context);
            break;
        default:
            //printf("Got other event %hd:%hd:%hd, ignored.\n",
            //       e->major, e->minor, e->instance);
            break;
        }
        break;
    case FERRET_TBUF_MAJOR:
        /* debug stuff ...
        if (last != FERRET_TBUF_MAJOR)
        {
            append_count(count_atomic);
            //printf("Atomic: %d\n", count_atomic);
            count_atomic = 0;
        }
        count_context++;
        last = FERRET_TBUF_MAJOR;
        ... debug stuff */
        switch (e->minor)
        {
        case l4_ktrace_tbuf_context_switch:
            t_last_context = e->timestamp;
            if (t_last_context > t_start_atomic &&
                t_stop_atomic == 0 && t_start_atomic != 0)
            {
                if (l4lx_task_id ==
                    l4_ktrace_get_l4_taskid((void * )k->data32[1]) &&
                    l4lx_tamer_thread_id !=
                    l4_ktrace_get_l4_lthreadid((void * )k->data32[1]))

                {
                    if (quiet < 2 )
                    {
                        printf(
                            l4util_idfmt" -> "l4util_idfmt": " ,
                            l4util_idstr(l4_ktrace_get_l4_threadid(k->context)),
                            l4util_idstr(l4_ktrace_get_l4_threadid(
                                             (void * )k->data32[1]))
                            );
                        printf("Atomicity violation: %llu < %llu\n",
                               t_start_atomic, t_last_context);
                    }
                    dump_count = 100;  // start count down for dump
                }
            }
            break;
        default:
            //printf("Got other event %hd:%hd:%hd, ignored.\n",
            //       e->major, e->minor, e->instance);
            break;
        }
        break;
    default:
        //printf("Got other event %hd:%hd:%hd, ignored.\n",
        //       e->major, e->minor, e->instance);
        break;
    }
    append_history(e);

    if (dump_count > 0)
    {
        dump_count--;
    }
    if (dump_count == 0)
    {
        if (quiet < 1)
        {
            uu_dumpz_ringbuffer("atomicity.dump", &history,
                                HISTORY_SIZE * sizeof(history_entry_t),
                                history_position * sizeof(history_entry_t),
                                HISTORY_SIZE * sizeof(history_entry_t));
        }
        dump_count = -1;
    }
}
コード例 #4
0
ファイル: main.c プロジェクト: RajasekharBhumi/L4Re
/******************************************************************************
 * 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;
}
コード例 #5
0
ファイル: demo1.c プロジェクト: RajasekharBhumi/L4Re
/******************************************************************************
 * 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;
}