示例#1
0
static int kp_irq_func(void)
{
  l4_cap_idx_t irq_cap = l4re_util_cap_alloc();
  l4_cap_idx_t thread_cap = pthread_getl4cap(_pthread);
  l4_msgtag_t tag;

  l4_debugger_set_object_name(thread_cap, "kp-omap3.irq");
  
  if (l4io_request_irq(7, irq_cap) < 0)
    return -2;
  // was L4_IRQ_F_LEVEL_LOW
  tag = l4_irq_attach(irq_cap, 0, thread_cap);
  if (l4_ipc_error(tag, l4_utcb()))
    return -3;

  while (1)
    {
      tag = l4_irq_receive(irq_cap, L4_IPC_NEVER);
      if (l4_ipc_error(tag, l4_utcb()))
	{
	  printf("[KEYP] Error: Receive irq failed\n");
	  continue;
	}

      kp_write(REG_KEYP_IMR1, 0xf);
     
      if (kp_handler)
	scan_key();

      l4_uint8_t value = 0;
      kp_read(REG_KEYP_ISR1, &value);
      kp_write(REG_KEYP_IMR1, 0x0);
    }
}
示例#2
0
static void *thread_producer(void *d)
{
  (void)d;
  l4shmc_chunk_t p_one;
  l4shmc_signal_t s_one, s_done;
  l4shmc_area_t shmarea;

  l4_debugger_set_object_name(pthread_getl4cap(pthread_self()), "prod");

  // attach this thread to the shm object
  CHK(l4shmc_attach("testshm", &shmarea));

  // add a chunk
  CHK(l4shmc_add_chunk(&shmarea, "one", 1024, &p_one));

  // add a signal
  CHK(l4shmc_add_signal(&shmarea, "prod", &s_one));

  // connect chunk and signal
  CHK(l4shmc_connect_chunk_signal(&p_one, &s_one));

  CHK(l4shmc_attach_signal_to(&shmarea, "done",
                              pthread_getl4cap(pthread_self()), 10000, &s_done));

  printf("PRODUCER: ready\n");

  while (1)
    {
      while (l4shmc_chunk_try_to_take(&p_one))
        printf("Uh, should not happen!\n"); //l4_thread_yield();

      set_some_data();

      memcpy(l4shmc_chunk_ptr(&p_one), some_data, sizeof(some_data));

      CHK(l4shmc_chunk_ready_sig(&p_one, sizeof(some_data)));

      printf("PRODUCER: Sent data %s\n", some_data);

      CHK(l4shmc_wait_signal(&s_done));

      l4_sleep(5000);
    }

  l4_sleep_forever();
  return NULL;
}
示例#3
0
static void *updater_thread(void *data)
{
  l4_umword_t l;
  (void)data;

  l4_thread_control_start();
  l4_thread_control_ux_host_syscall(1);
  l4_thread_control_commit(pthread_getl4cap(pthread_self()));

  while (1)
    {
      if (l4_ipc_error(l4_ipc_wait(l4_utcb(), &l, L4_IPC_NEVER), l4_utcb()))
        printf("updater_thread: l4_ipc_wait failed\n");
      l4_sleep(30);
      lx_kill(ux_con_pid, LX_SIGUSR1);
      waiting = 0;
    }
  return NULL;
}
示例#4
0
int
ux_probe(con_accel_t *accel)
{
  struct l4_vhw_descriptor *vhw;
  struct l4_vhw_entry *vhwe;

  if (!l4util_kip_kernel_is_ux(l4re_kip()))
    return -L4_ENODEV;

  if (l4io_lookup_device("L4UXfb", NULL, 0, 0))
    {
      printf("WARNING: Running under Fiasco-UX and no 'L4UXfb' device found, can only use polling mode!\n");
      return -L4_ENODEV;
    }

  printf("Found Fiasco-UX Framebuffer\n");

  if (!(vhw = l4_vhw_get(l4re_kip())))
    return -L4_ENODEV;

  if (!(vhwe = l4_vhw_get_entry_type(vhw, L4_TYPE_VHW_FRAMEBUFFER)))
    return -L4_ENODEV;

  ux_con_pid = vhwe->provider_pid;
  accel->drty = uxScreenUpdate;
  accel->caps = ACCEL_POST_DIRTY;

  printf("Found VHW descriptor, provider is %d\n", ux_con_pid);

  l4_thread_control_start();
  l4_thread_control_ux_host_syscall(1);
  l4_thread_control_commit(l4re_env()->main_thread);

  /* The update thread needs to run with the same priority than as the vc
   * threads (otherwise the screen won't be updated) */
  {
    pthread_t update_tid;
    pthread_attr_t a;
    struct sched_param sp;

    pthread_attr_init(&a);
    sp.sched_priority = 0x70;
    pthread_attr_setschedpolicy(&a, SCHED_L4);
    pthread_attr_setschedparam(&a, &sp);
    pthread_attr_setinheritsched(&a, PTHREAD_EXPLICIT_SCHED);

    if (pthread_create(&update_tid, &a, updater_thread, NULL))
       return -L4_ENOMEM;
    updater_id = pthread_getl4cap(update_tid);

#if 0
    update_tid = l4thread_create_long(L4THREAD_INVALID_ID,
                                      updater_thread, ".scr-upd",
                                      L4THREAD_INVALID_SP, L4THREAD_DEFAULT_SIZE,
                                      0xff, NULL,
                                      L4THREAD_CREATE_ASYNC);
    if (update_tid < 0)
      {
        printf("Could not create updater thread.\n");
        return -L4_ENOTHREAD;
      }

    updater_id = l4thread_l4_id(update_tid);
#endif
  }

#if 0
  if (hw_vid_mem_addr != vhwe->mem_start
      || hw_vid_mem_size != vhwe->mem_size)
    printf("!!! Memory area mismatch "l4_addr_fmt"(%lx) vs. "l4_addr_fmt
           "(%lx) ... continuing\n",
           hw_vid_mem_addr, hw_vid_mem_size, vhwe->mem_start, vhwe->mem_size);
#endif

  //map_io_mem(hw_vid_mem_addr, hw_vid_mem_size, 0, "UX video",
   //          (l4_addr_t *)&hw_map_vid_mem_addr);

  // already mapped by vesa-ds + rm-attach
  hw_map_vid_mem_addr = hw_vid_mem_addr;

  return 0;
}
示例#5
0
文件: main.c 项目: KyulingLee/L4Re
int main(int argc, char **argv)
{
	if (l4ankh_init())
	  return 1;

	l4_cap_idx_t c = pthread_getl4cap(pthread_self());
	cfg.send_thread = c;

	static struct option long_opts[] = {
		{"bufsize", 1, 0, BUF_SIZE },
		{"shm", 1, 0, SHM_NAME },
		GETOPT_LIST_END
	};

	while (1) {
		int optind = 0;
		int opt = getopt_long(argc, argv, "b:s:", long_opts, &optind);
		printf("getopt: %d\n", opt);

		if (opt == -1)
			break;

		switch(opt) {
			case BUF_SIZE:
				printf("buf size: %d\n", atoi(optarg));
				cfg.bufsize = atoi(optarg);
				break;
			case SHM_NAME:
				printf("shm name: %s\n", optarg);
				snprintf(cfg.shm_name, CFG_SHM_NAME_SIZE, "%s", optarg);
				break;
			default:
				break;
		}
	}

	// Start the TCP/IP thread & init stuff
	tcpip_init(NULL, NULL);
	struct netif *n = netif_add(&my_netif,
	                            &ipaddr, &netmask, &gw,
	                            &cfg, // configuration state
	                            ankhif_init, ethernet_input);

	printf("netif_add: %p (%p)\n", n, &my_netif);
	assert(n == &my_netif);

	printf("dhcp_start()\n");
	dhcp_start(&my_netif);
	printf("dhcp started\n");

	while (!netif_is_up(&my_netif))
		l4_sleep(1000);
	printf("Network interface is up.\n");

	printf("IP: "); lwip_util_print_ip(&my_netif.ip_addr); printf("\n");
	printf("GW: "); lwip_util_print_ip(&my_netif.gw); printf("\n");

	dns_test();
	server();

	return 0;
}