From: Sam M. <pa...@gm...> - 2005-04-29 12:58:10
|
Perhaps a similar style interface to qemu? For example, ctrl-alt-2 switches to a qemu minicommand line, and ctrl-alt-1 switches back to the os being emulated. I can't see how adding some of the FLTK stuff to the NT console would work without doing it this way (or with an external connector). Debugging code could also be put into this area as well, perhaps. Some thoughts, Sam On 4/29/05, Nuno Lucas <ml-...@xp...> wrote: > After some time without doing much in colinux, here are some more things > to the colinux development branch: >=20 > * Add IOCTL to list monitors active > * Bump CO_LINUX_PERIPHERY_API_VERSION because of that > * Return to the default behavior of the FLTK console of attaching > to the first available monitor, if none given. > * Implement the "Select Monitor" menu command. >=20 > To do was making the same with the NT console. I'll let that as an > exercise to the reader :D >=20 > Regards, > ~Nuno Lucas >=20 > P.S.- I'll be the weekend off, so sorry if I only answer next Monday. >=20 >=20 > # > # patch "src/colinux/common/common_base.h" > # from [70794f6511895d41ee64ff6b2b9020a0609de461] > # to [b373bfb43098a960e3e120af2f352758c1ed6371] > # > # patch "src/colinux/common/ioctl.h" > # from [3d3abe925dd2c1345aa4c5cb0adb468f4fccaee2] > # to [e439c8800a05d4fdf8560381b916db2725102231] > # > # patch "src/colinux/kernel/manager.c" > # from [c80bcb32d7f13bed4100c9805fc2e7f845f72db5] > # to [576fc091bda2327f69b40502865d06ca9342b936] > # > # patch "src/colinux/user/console/console.cpp" > # from [354bda19e1d855fd0cfbec67794850832343e773] > # to [fe44379ae533cdd28117af0ac835b2024621c975] > # > # patch "src/colinux/user/console/select_monitor.cpp" > # from [4224b15fd48c354a708e54d699da71a264e4bead] > # to [8333d5aa880e7faf600d733f310b26068c41d503] > # > # patch "src/colinux/user/console/select_monitor.h" > # from [11b122a9a26bee031e09e44990067f9c20bd65fd] > # to [95c65cd9c1a000f94419663bf874997e36b8055e] > # > # patch "src/colinux/user/manager.c" > # from [2a149871ec71e2c5d39a9401c4aadf9f01f6d976] > # to [0a315079f50acd80ef3a021af738d8215ab37845] > # > # patch "src/colinux/user/manager.h" > # from [d418a8870f9da4e2fb9385c70a5407c44ab4dd97] > # to [8dff9b75e49e18328f3df4bfe98e399a9fbf8029] > # > --- src/colinux/common/common_base.h > +++ src/colinux/common/common_base.h > @@ -18,7 +18,7 @@ > #define PACKED_STRUCT __attribute__((packed)) >=20 > #define CO_MAX_MONITORS 16 > -#define CO_LINUX_PERIPHERY_API_VERSION 18 > +#define CO_LINUX_PERIPHERY_API_VERSION 19 >=20 > #define CO_ERRORS_X_MACRO \ > X(ERROR) \ > --- src/colinux/common/ioctl.h > +++ src/colinux/common/ioctl.h > @@ -27,6 +27,7 @@ > CO_MANAGER_IOCTL_DEBUG_LEVELS, > CO_MANAGER_IOCTL_INFO, > CO_MANAGER_IOCTL_ATTACH, > + CO_MANAGER_IOCTL_MONITOR_LIST, > } co_manager_ioctl_t; >=20 > /* > @@ -109,6 +110,13 @@ > bool_t modify; > } co_manager_ioctl_debug_levels_t; >=20 > +/* interface for CO_MANAGER_IOCTL_MONITOR_LIST: */ > +typedef struct { > + co_rc_t rc; > + unsigned long count; > + co_id_t ids[CO_MAX_MONITORS]; > +} co_manager_ioctl_monitor_list_t; > + > /* > * Monitor ioctl()s > */ > --- src/colinux/kernel/manager.c > +++ src/colinux/kernel/manager.c > @@ -372,6 +372,30 @@ > *return_size =3D sizeof(*params); > break; > } > + case CO_MANAGER_IOCTL_MONITOR_LIST: { > + co_manager_ioctl_monitor_list_t *params =3D (typeof(param= s))(io_buffer); > + co_monitor_t *monitor =3D NULL; > + co_rc_t rc =3D CO_RC(OK); > + int i =3D 0; > + > + co_os_mutex_acquire(manager->lock); > + co_list_each_entry(monitor, &manager->monitors, node) { > + if ( i >=3D CO_MAX_MONITORS ) > + { > + /* We don't enforce a limit on create, so= just > + * break from the loop and return the fir= st ones > + */ > + break; > + } > + params->ids[i++] =3D monitor->id; > + } > + co_os_mutex_release(manager->lock); > + params->count =3D i; > + > + params->rc =3D rc; > + *return_size =3D sizeof(*params); > + break; > + } > case CO_MANAGER_IOCTL_ATTACH: { > co_manager_ioctl_attach_t *params =3D (typeof(params))(io= _buffer); > co_monitor_t *monitor =3D NULL; > --- src/colinux/user/console/console.cpp > +++ src/colinux/user/console/console.cpp > @@ -114,7 +114,7 @@ > co_rc_t rc; >=20 > /* Default settings */ > - start_parameters.attach_id =3D 0; > + start_parameters.attach_id =3D CO_INVALID_ID; > attached_id =3D CO_INVALID_ID; > state =3D CO_CONSOLE_STATE_DETACHED; > window =3D 0; > @@ -158,6 +158,31 @@ > return CO_RC(OK); > } >=20 > +/** > + * Returns PID of first monitor. > + * > + * If none found, returns CO_INVALID_ID. > + * > + * TODO: Find first monitor not already attached. > + */ > +co_id_t find_first_monitor( ) > +{ > + co_manager_handle_t handle; > + co_manager_ioctl_monitor_list_t list; > + co_rc_t rc; > + > + handle =3D co_os_manager_open( ); > + if ( handle =3D=3D NULL ) > + return CO_INVALID_ID; > + > + rc =3D co_manager_monitor_list( handle, &list ); > + co_os_manager_close( handle ); > + if ( !CO_OK(rc) || list.count =3D=3D 0 ) > + return CO_INVALID_ID; > + > + return list.ids[0]; > +} > + > co_rc_t console_window_t::start() > { > window =3D new console_main_window_t(this); > @@ -233,13 +258,16 @@ > if (start_parameters.attach_id !=3D CO_INVALID_ID) > attached_id =3D start_parameters.attach_id; >=20 > + if ( attached_id =3D=3D CO_INVALID_ID ) > + attached_id =3D find_first_monitor( ); > + > if (attached_id !=3D CO_INVALID_ID) > - return attach(); > - > + attach(); /* Ignore errors, as we can attach latter */ > + > return CO_RC(OK); > } >=20 > -static console_window_t *g_console; > +console_window_t *g_console; >=20 > co_rc_t console_window_t::message_receive(co_reactor_user_t user, unsign= ed char *buffer, unsigned long size) > { > --- src/colinux/user/console/select_monitor.cpp > +++ src/colinux/user/console/select_monitor.cpp > @@ -9,6 +9,7 @@ > */ >=20 > #include <stdio.h> > +#include <string.h> >=20 > #include "select_monitor.h" > #include "console.h" > @@ -56,27 +57,36 @@ > resizable(browser); >=20 > end(); > - show(); >=20 > load_monitors_list(); > + show(); > } >=20 > void select_monitor_widget_t::load_monitors_list() > { > - int i =3D 0; > + co_manager_handle_t handle; > + co_manager_ioctl_monitor_list_t list; > + co_rc_t rc; >=20 > - if (id_map) > - delete []id_map; > + memset( id_map, 0, sizeof(id_map) ); > + id_map_count =3D 0; > + browser->clear(); >=20 > - id_map =3D new co_id_t[CO_MAX_MONITORS]; > - id_map_size =3D 0; > + handle =3D co_os_manager_open( ); > + if ( handle =3D=3D NULL ) > + return; >=20 > - browser->clear(); > + rc =3D co_manager_monitor_list( handle, &list ); > + co_os_manager_close( handle ); > + if ( !CO_OK(rc) ) > + return; >=20 > - char buf[0x100]; > - > - snprintf(buf, sizeof(buf), "Monitor%d\t", i); > - > - id_map[id_map_size] =3D 0; > - id_map_size++; > + for ( unsigned i =3D 0; i < list.count; ++i ) > + { > + char buf[32]; > + id_map[i] =3D list.ids[i]; > + snprintf( buf, sizeof(buf), "Monitor%d (pid=3D%d)\t", i, = id_map[i] ); > + browser->add( buf ); > + } > + id_map_count =3D list.count; > } > --- src/colinux/user/console/select_monitor.h > +++ src/colinux/user/console/select_monitor.h > @@ -24,22 +24,22 @@ >=20 > class select_monitor_widget_t : public Fl_Double_Window { > public: > - select_monitor_widget_t(int w, int h, const char *label =3D 0) : > - Fl_Double_Window(w, h, label), id_map(0), id_map_size(0) {}; > - select_monitor_widget_t(int x, int y, int w, int h, const char *l= abel =3D 0) : > - Fl_Double_Window(x, y, w, h, label), id_map(0), id_map_size(0) {}= ; > + select_monitor_widget_t(int w, int h, const char *label =3D 0) > + : Fl_Double_Window(w, h, label), id_map_count(0) {}; > + select_monitor_widget_t(int x, int y, int w, int h, const char *l= abel =3D 0) > + : Fl_Double_Window(x, y, w, h, label), id_map_count(0) {}= ; >=20 > void on_button(Fl_Widget *widget); > void populate(class console_window_t *console_window); > void load_monitors_list(); >=20 > protected: > - Fl_Button *select_button; > - Fl_Button *cancel_button; > - Fl_Hold_Browser *browser; > - co_id_t *id_map; > - int id_map_size; > - console_window_t *console; > + Fl_Button * select_button; > + Fl_Button * cancel_button; > + Fl_Hold_Browser * browser; > + co_id_t id_map[CO_MAX_MONITORS]; > + int id_map_count; > + console_window_t * console; > }; >=20 > #endif > --- src/colinux/user/manager.c > +++ src/colinux/user/manager.c > @@ -118,3 +118,20 @@ >=20 > return rc; > } > + > +/** > + * Ask manager for the list of monitors running. > + * > + * The driver will fill the array with the PIDs of the registered > + * monitors. > + */ > +co_rc_t co_manager_monitor_list( co_manager_handle_t handle, co_manager_= ioctl_monitor_list_t *list ) > +{ > + co_rc_t rc; > + unsigned long returned =3D 0; > + > + rc =3D co_os_manager_ioctl( handle, CO_MANAGER_IOCTL_MONITOR_LIST= , > + list, sizeof(*list), list, sizeof(*list),= &returned ); > + > + return rc; > +} > --- src/colinux/user/manager.h > +++ src/colinux/user/manager.h > @@ -42,4 +42,6 @@ >=20 > extern co_rc_t co_manager_attach(co_manager_handle_t handle, co_manager_= ioctl_attach_t *params); >=20 > +co_rc_t co_manager_monitor_list( co_manager_handle_t handle, co_manager_= ioctl_monitor_list_t *list ); > + > #endif >=20 >=20 > |