Exemplo n.º 1
0
Arquivo: ofd.c Projeto: jiamacs/rhype
static ofdn_t
ofd_vdevice_vty(void *m, ofdn_t p, struct partition_status *ps)
{
	ofdn_t n;
	static const char pathfmt[] = "/vdevice/vty@%lx";
	static const char name[] = "vty";
	static const char compatible[] = "hvterm1";
	static const char device_type[] = "serial";
	char path[sizeof (pathfmt) + 8 - 2];
	uval server;
	uval client;

	vterm_create(ps, &server, &client);

	snprintf(path, sizeof (path), pathfmt, client);
	n = ofd_node_add(m, p, path, sizeof (path));

	if (n > 0) {
		uval32 val32;

		val32 = client;
		ofd_prop_add(m, n, "name", name, sizeof (name));
		ofd_prop_add(m, n, "reg", &val32, sizeof (val32));
		ofd_prop_add(m, n, "compatible",
				compatible, sizeof (compatible));
		ofd_prop_add(m, n, "device_type",
				device_type, sizeof (device_type));
	}
	if (server == 0 && ps->lpid == iohost_lpid) {
		ofd_vdevice_vty_server(m, p, 64);
	}

	return n;
}
Exemplo n.º 2
0
WINDOW* vwmterm_init(gpointer anything)
{
   extern WINDOW  	*SCREEN_WINDOW;
	extern ps_runq_t	*vwm_runq;
   vterm_t           *vterm;
	WINDOW	      	*window;
	gint		      	width,height;
   int               master_fd;
   int               fflags;

   getmaxyx(SCREEN_WINDOW,height,width);
   if(height>30 && width>84)
   {
      height=25;
      width=80;
   }
   else
   {
      /* calculate scaled window size */
	   window_get_size_scaled(NULL,&width,&height,0.85,0.65);
	   if(width>80) width=80;
	   if(height>25) height=25;
   }

   vterm=vterm_create(width,height,0);
   vterm_set_colors(vterm,COLOR_WHITE,COLOR_BLACK);
   master_fd=vterm_get_pty_fd(vterm);

   // configure SIGIO acceleration
#ifdef SIGPOLL
   vwmterm_sigset(SIGPOLL,vwmterm_SIGIO);
#else
   vwmterm_sigset(SIGIO,vwmterm_SIGIO);
#endif
	fcntl(master_fd,F_SETOWN,getpid());
   fflags=fcntl(master_fd,F_GETFL);
   fcntl(master_fd,F_SETFL,fflags | FASYNC);

   viper_thread_enter();

   // create window
	window=viper_window_create(" VTerm ",0.5,0.5,width,height,TRUE);
   viper_window_set_state(window,STATE_UNSET | STATE_NORESIZE);
	viper_window_set_limits(window,15,2,WSIZE_UNCHANGED,WSIZE_UNCHANGED);

   // libviper set the default bkgd OR to WHITE on BLACK.  undo it.
   wbkgdset(window,0);
	wattron(window,VIPER_COLORS(COLOR_WHITE,COLOR_BLACK));

   // init terminal
   vterm_wnd_set(vterm,window);
   vterm_erase(vterm);

   // attache event handlers
	viper_event_set(window,"window-resized",vwmterm_ON_RESIZE,(gpointer)vterm);
	viper_event_set(window,"window-close",vwmterm_ON_CLOSE,(gpointer)vterm);
	viper_event_set(window,"window-destroy",vwmterm_ON_DESTROY,
		(gpointer)vterm);
	viper_window_set_key_func(window,vwmterm_ON_KEYSTROKE);
	viper_window_set_userptr(window,(gpointer)vterm);

   // push pseudo-thread onto run queue
	psthread_add(vwm_runq,vwmterm_psthread,(gpointer)window);

	viper_thread_leave();

	return window;
}