[ros-kernel] Feature freeze

Filip Navara xnavara at volny.cz
Thu Apr 8 00:24:26 CEST 2004


Hi,

it's funny, but I have also made a patches for the Win32 QEMU. They're 
attached in case someone is interested.

qemu-console.diff - Get console working under QEMU for Win32.
qemu-keys.diff - Get the keyboard input working almost correctly under 
Win32.
qemu-path.diff - Use the path of executable to determine the directory 
of BIOS files.

- Filip

Hartmut Birr wrote:

>Hi,    
>
>I've made a short qemu windows test. It is possible to compile qemu 0.5.3
>for windows. The source needs some fixes. Currently the keyboard doesn't
>work properly. I had a look at the source. Qemu uses the native sdl key
>codes, which are different for windows and linux. It should be changed like
>the bochs way for sdl. An other problem is the emulation code. I do compile
>ros always with the options '-Os -march=athlon-xp' (and many fixes within
>the ros source). This crashes ros within qemu. Without the optimisation ros
>runs within qemu. If I compile the tools section, the compiling fails within
>qemu. I've made a quick fix for qemu which fixes the keyboard (the main work
>comes from http://www.h7.dion.ne.jp/%7Eqemu-win/) and adds the e9 debug
>output. If anyone is interested, I can send the diffs or a binary.    
>
>- Hartmut
>  
>

-------------- next part --------------
--- qemu/configure	Fri Apr  2 21:55:48 2004
+++ qemu/configure	Wed Apr  7 18:29:40 2004
@@ -364,10 +364,10 @@
 if test "$sdl" = "yes" ; then
   echo "CONFIG_SDL=yes" >> $config_mak
   echo "#define CONFIG_SDL 1" >> $config_h
-  echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
+  echo "SDL_LIBS=`$sdl_config --libs | sed s/-mwindows/-mconsole/`" >> $config_mak
   aa="no"
   `$sdl_config --static-libs | grep \\\-laa > /dev/null` && aa="yes"
-  echo -n "SDL_STATIC_LIBS=`$sdl_config --static-libs`" >> $config_mak
+  echo -n "SDL_STATIC_LIBS=`$sdl_config --static-libs | sed s/-mwindows/-mconsole/`" >> $config_mak
   if [ "${aa}" = "yes" ] ; then
       echo -n " `aalib-config --libs`" >> $config_mak ;
   fi
--- qemu/vl.c	Mon Apr  5 21:49:14 2004
+++ qemu/vl.c	Wed Apr  7 18:29:40 2004
@@ -48,6 +48,7 @@
 #ifdef _WIN32
 #include <sys/timeb.h>
 #include <windows.h>
+#include <conio.h>
 #define getopt_long_only getopt_long
 #define memalign(align, size) malloc(size)
 #endif
@@ -1502,10 +1503,10 @@
 {
 #ifndef _WIN32
     struct pollfd ufds[MAX_IO_HANDLERS + 1], *pf;
+#endif
     IOHandlerRecord *ioh, *ioh_next;
     uint8_t buf[4096];
     int n, max_size;
-#endif
     int ret, timeout;
     CPUState *env = global_env;
 
@@ -1529,8 +1530,8 @@
             timeout = 10;
         }
 
-#ifndef _WIN32
         /* poll any events */
+#ifndef _WIN32
         /* XXX: separate device handlers from system ones */
         pf = ufds;
         for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) {
@@ -1579,6 +1580,32 @@
                 }
             }
         }
+#else
+        for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) {
+            ioh_next = ioh->next;
+
+            if (ioh->fd == -1)
+                continue;
+
+            max_size = ioh->fd_can_read(ioh->opaque);
+            if (max_size > 0) {
+                if (max_size > sizeof(buf))
+                    max_size = sizeof(buf);
+
+                if (max_size != 0) {
+                    if (!isatty(ioh->fd) || kbhit())
+                        n = read(ioh->fd, buf, max_size);
+                    else
+                        n = 0;
+
+                    if (n >= 0) {
+                        ioh->fd_read(ioh->opaque, buf, n);
+                    } else if (errno != -EAGAIN) {
+                        ioh->fd_read(ioh->opaque, NULL, -errno);
+                    }
+                }
+            }
+        }
 #endif
 
         if (vm_running) {
-------------- next part --------------
--- qemu/sdl.c	Wed Mar 31 23:37:16 2004
+++ qemu/sdl.c	Wed Apr  7 18:35:00 2004
@@ -121,10 +121,83 @@
    0x53,         /* 157 KP_Del */
 };
 
+static const uint32_t sdl_keycode_to_pc_keycode[] = {
+   0x52,         /* SDLK_KP0 */
+   0x4f,         /* SDLK_KP1 */
+   0x50,         /* SDLK_KP2 */
+   0x51,         /* SDLK_KP3 */
+   0x4b,         /* SDLK_KP4 */
+   0x4c,         /* SDLK_KP5 */
+   0x4d,         /* SDLK_KP6 */
+   0x47,         /* SDLK_KP7 */
+   0x48,         /* SDLK_KP8 */
+   0x49,         /* SDLK_KP9 */
+
+   0x53,         /* SDLK_KP_PERIOD */
+
+   0x35e0,       /* SDLK_KP_DIVIDE */
+   0x0,          /* FIXME: SDLK_KP_MULTIPLY */
+   0x0,          /* FIXME: SDLK_KP_MINUS */
+   0x0,          /* FIXME: SDLK_KP_PLUS */
+   0x0,          /* FIXME: SDLK_KP_ENTER */
+   0x0,          /* FIXME: SDLK_KP_EQUALS */
+
+   0x48e0,      /* SDLK_UP */
+   0x50e0,      /* SDLK_DOWN */
+   0x4de0,      /* SDLK_RIGHT */
+   0x4be0,      /* SDLK_LEFT */
+   0x52e0,      /* SDLK_INSERT */
+   0x47e0,      /* SDLK_HOME */
+   0x4fe0,      /* SDLK_END */
+   0x49e0,      /* SDLK_PAGEUP */
+   0x51e0,      /* SDLK_PAGEDOWN */
+   0,		/* FIXME: SDLK_F1 */
+   0,		/* FIXME: SDLK_F2 */
+   0,		/* FIXME: SDLK_F3 */
+   0,		/* FIXME: SDLK_F4 */
+   0,		/* FIXME: SDLK_F5 */
+   0,		/* FIXME: SDLK_F6 */
+   0,		/* FIXME: SDLK_F7 */
+   0,		/* FIXME: SDLK_F8 */
+   0,		/* FIXME: SDLK_F9 */
+   0,		/* FIXME: SDLK_F10 */
+   0,		/* FIXME: SDLK_F11 */
+   0,		/* FIXME: SDLK_F12 */
+   0,		/* SDLK_F13 */
+   0,		/* SDLK_F14 */
+   0,		/* SDLK_F15 */
+   0,		/* FIXME: SDLK_NUMLOCK */
+   0,		/* FIXME: SDLK_CAPSLOCK */
+   0,		/* FIXME: SDLK_SCROLLOCK */
+   0,		/* FIXME: SDLK_RSHIFT */
+   0,		/* FIXME: SDLK_LSHIFT */
+   0,		/* FIXME: SDLK_RCTRL */
+   0,		/* FIXME: SDLK_LCTRL */
+   0,		/* FIXME: SDLK_RALT */
+   0,		/* FIXME: SDLK_LALT */
+   0,		/* FIXME: SDLK_RMETA */
+   0,		/* FIXME: SDLK_LMETA */
+   0,		/* FIXME: SDLK_LSUPER */
+   0,		/* FIXME: SDLK_RSUPER */
+   0,		/* FIXME: SDLK_MODE */
+   0,		/* FIXME: SDLK_COMPOSE */
+   0,		/* FIXME: SDLK_HELP */
+   0,		/* FIXME: SDLK_PRINT */
+   0,		/* FIXME: SDLK_SYSREQ */
+   0,		/* FIXME: SDLK_BREAK */
+   0,		/* FIXME: SDLK_MENU */
+   0,		/* FIXME: SDLK_POWER */
+   0,		/* FIXME: SDLK_EURO */
+   0		/* FIXME: SDLK_UNDO */
+};
+
+#define sdl_keycode_table_size (sizeof(sdl_keycode_to_pc_keycode) / sizeof(uint32_t))
+
 static void sdl_process_key(SDL_KeyboardEvent *ev)
 {
     int keycode, v;
     
+#ifndef WIN32
     /* XXX: not portable, but avoids complicated mappings */
     keycode = ev->keysym.scancode;
     if (keycode < 9) {
@@ -137,6 +210,17 @@
     } else {
         keycode = 0;
     }
+#else
+    keycode = 0;
+
+    if (ev->keysym.sym >= 256 && ev->keysym.sym < 256 + sdl_keycode_table_size)
+    {
+        keycode = sdl_keycode_to_pc_keycode[ev->keysym.sym - 256];
+    }
+
+    if (keycode == 0)
+        keycode = ev->keysym.scancode;
+#endif
     
     /* now send the key code */
     while (keycode != 0) {
-------------- next part --------------
--- qemu/vl.c	Mon Apr  5 21:49:14 2004
+++ qemu/vl.c	Wed Apr  7 18:29:40 2004
@@ -84,7 +85,7 @@
 /* XXX: use a two level table to limit memory usage */
 #define MAX_IOPORTS 65536
 
-const char *bios_dir = CONFIG_QEMU_SHAREDIR;
+const char *bios_dir;
 char phys_ram_file[1024];
 CPUState *global_env;
 CPUState *cpu_single_env;
@@ -1700,6 +1727,7 @@
     const char *initrd_filename;
     const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD];
     const char *kernel_filename, *kernel_cmdline;
+    char *temp_bios_dir;
     DisplayState *ds = &display_state;
     int cyls, heads, secs;
     uint8_t macaddr[6];
@@ -1739,6 +1767,21 @@
     for(i = 0; i < MAX_NICS; i++) 
         nd_table[i].fd = -1;
     
+    /* extract the bios directory from excutable path */
+    if (*argv[0] != 0) {
+        bios_dir = argv[0];
+        temp_bios_dir = argv[0] + strlen(bios_dir) - 1;
+        while (temp_bios_dir != bios_dir) {
+            if (*temp_bios_dir == '\\' || *temp_bios_dir == '/') {
+                *temp_bios_dir = 0;
+                break;
+            }
+            temp_bios_dir--;
+        }
+    } else {
+        bios_dir = CONFIG_QEMU_SHAREDIR;
+    }
+        
     for(;;) {
         c = getopt_long_only(argc, argv, "hm:d:n:sp:L:", long_options, &long_index);
         if (c == -1)


More information about the Ros-kernel mailing list