Merge commit 'origin/master' into maemo-test
authorRiku Voipio <riku.voipio@nokia.com>
Thu, 5 Mar 2009 09:14:29 +0000 (11:14 +0200)
committerRiku Voipio <riku.voipio@nokia.com>
Thu, 5 Mar 2009 09:14:29 +0000 (11:14 +0200)
1  2 
Makefile.target
cocoa.m
configure
hw/boards.h
linux-user/main.c

diff --combined Makefile.target
@@@ -235,10 -235,8 +235,10 @@@ endi
  VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
  CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
  
 +#sbox hack
  ifdef CONFIG_STATIC
 -LDFLAGS+=-static
 +LDFLAGS+=-static -L/scratchbox/tools/lib
 +LIBS+=-lsb -ldl
  endif
  
  ifeq ($(ARCH),i386)
@@@ -604,6 -602,8 +604,8 @@@ OBJS+= unin_pci.o ppc_newworld.
  # PowerPC 4xx boards
  OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
  OBJS+= ppc440.o ppc440_bamboo.o
+ # PowerPC E500 boards
+ OBJS+= ppce500_pci.o ppce500_mpc8544ds.o
  ifdef FDT_LIBS
  OBJS+= device_tree.o
  LIBS+= $(FDT_LIBS)
@@@ -659,10 -659,9 +661,10 @@@ OBJS+= arm-semi.
  OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
  OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
  OBJS+= pflash_cfi01.o gumstix.o
 -OBJS+= zaurus.o ide.o serial.o nand.o ecc.o spitz.o tosa.o tc6393xb.o
 -OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
 +OBJS+= zaurus.o ide.o serial.o nand.o nand_bpage.o ecc.o spitz.o tosa.o tc6393xb.o
 +OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap3_mmc.o omap_i2c.o
  OBJS+= omap2.o omap_dss.o soc_dma.o
 +OBJS+= omap3.o beagle.o twl4030.o
  OBJS+= omap_sx1.o palm.o tsc210x.o
  OBJS+= nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
  OBJS+= tsc2005.o bt-hci-csr.o
diff --combined cocoa.m
+++ b/cocoa.m
@@@ -57,7 -57,7 +57,7 @@@ typedef struct 
  int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
  NSWindow *normalWindow;
  id cocoaView;
- static void *screenBuffer;
+ static DisplayChangeListener *dcl;
  
  int gArgc;
  char **gArgv;
@@@ -229,7 -229,7 +229,7 @@@ int keymap[] 
  */
  };
  
 -int cocoa_keycode_to_qemu(int keycode)
 +static int cocoa_keycode_to_qemu(int keycode)
  {
      if((sizeof(keymap)/sizeof(int)) <= keycode)
      {
  {
      COCOA_DEBUG("QemuCocoaView: dealloc\n");
  
-     if (screenBuffer)
-         free(screenBuffer);
      if (dataProviderRef)
          CGDataProviderRelease(dataProviderRef);
  
      [super dealloc];
  }
  
 +- (BOOL) isOpaque
 +{
 +    return YES;
 +}
 +
  - (void) drawRect:(NSRect) rect
  {
      COCOA_DEBUG("QemuCocoaView: drawRect\n");
  
-     if ((int)screenBuffer == -1)
-         return;
      // get CoreGraphic context
      CGContextRef viewContextRef = [[NSGraphicsContext currentContext] graphicsPort];
      CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone);
              screen.height, //height
              screen.bitsPerComponent, //bitsPerComponent
              screen.bitsPerPixel, //bitsPerPixel
-             (screen.width * 4), //bytesPerRow
+             (screen.width * (screen.bitsPerComponent/2)), //bytesPerRow
  #if __LITTLE_ENDIAN__
              CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB), //colorspace for OS X >= 10.4
-             kCGImageAlphaNoneSkipLast,
+             kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
  #else
              CGColorSpaceCreateDeviceRGB(), //colorspace for OS X < 10.4 (actually ppc)
              kCGImageAlphaNoneSkipFirst, //bitmapInfo
              0, //interpolate
              kCGRenderingIntentDefault //intent
          );
 +
  // test if host support "CGImageCreateWithImageInRect" at compiletime
  #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
          if (CGImageCreateWithImageInRect == NULL) { // test if "CGImageCreateWithImageInRect" is supported on host at runtime
                  clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy;
                  clipRect.size.width = rectList[i].size.width / cdx;
                  clipRect.size.height = rectList[i].size.height / cdy;
 -                clipImageRef = CGImageCreateWithImageInRect(
 -                    imageRef,
 -                    clipRect
 -                );
 -                CGContextDrawImage (viewContextRef, cgrect(rectList[i]), clipImageRef);
 -                CGImageRelease (clipImageRef);
 +                clipImageRef = CGImageCreateWithImageInRect(imageRef, clipRect);
 +                CGContextDrawImage(viewContextRef, cgrect(rectList[i]), clipImageRef);
 +                CGImageRelease(clipImageRef);
              }
          }
  #endif
      // update screenBuffer
      if (dataProviderRef)
          CGDataProviderRelease(dataProviderRef);
-     if (screenBuffer)
-         free(screenBuffer);
-     screenBuffer = malloc( w * 4 * h );
-     ds->data = screenBuffer;
-     ds->linesize =  (w * 4);
-     ds->depth = 32;
-     ds->width = w;
-     ds->height = h;
- #ifdef __LITTLE_ENDIAN__
-     ds->bgr = 1;
- #else
-     ds->bgr = 0;
- #endif
  
-     dataProviderRef = CGDataProviderCreateWithData(NULL, screenBuffer, w * 4 * h, NULL);
+     //sync host window color space with guests
+       screen.bitsPerPixel = ds_get_bits_per_pixel(ds);
+       screen.bitsPerComponent = ds_get_bytes_per_pixel(ds) * 2;
+     dataProviderRef = CGDataProviderCreateWithData(NULL, ds_get_data(ds), w * 4 * h, NULL);
  
      // update windows
      if (isFullscreen) {
      } else {
          if (qemu_name)
              [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
 -        [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:YES];
 +        [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO];
      }
      screen.width = w;
      screen.height = h;
+       [normalWindow center];
      [self setContentDimensions];
      [self setFrame:NSMakeRect(cx, cy, cw, ch)];
  }
              if (isAbsoluteEnabled) {
                  if (p.x < 0 || p.x > screen.width || p.y < 0 || p.y > screen.height || ![[self window] isKeyWindow]) {
                      if (isTabletEnabled) { // if we leave the window, deactivate the tablet
 -                        [NSCursor unhide];
 +                        if (cursor_hide) [NSCursor unhide];
                          isTabletEnabled = FALSE;
                      }
                  } else {
                      if (!isTabletEnabled) { // if we enter the window, activate the tablet
 -                        [NSCursor hide];
 +                        if (cursor_hide) [NSCursor hide];
                          isTabletEnabled = TRUE;
                      }
                  }
          else
              [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"];
      }
 -    [NSCursor hide];
 +    if (cursor_hide) [NSCursor hide];
      CGAssociateMouseAndMouseCursorPosition(FALSE);
      isMouseGrabed = TRUE; // while isMouseGrabed = TRUE, QemuCocoaApp sends all events to [cocoaView handleEvent:]
  }
          else
              [normalWindow setTitle:@"QEMU"];
      }
 -    [NSCursor unhide];
 +    if (cursor_hide) [NSCursor unhide];
      CGAssociateMouseAndMouseCursorPosition(TRUE);
      isMouseGrabed = FALSE;
  }
          [normalWindow setTitle:[NSString stringWithFormat:@"QEMU"]];
          [normalWindow setContentView:cocoaView];
          [normalWindow makeKeyAndOrderFront:self];
+               [normalWindow center];
  
      }
      return self;
      if(returnCode == NSCancelButton) {
          exit(0);
      } else if(returnCode == NSOKButton) {
 -        char *bin = "qemu";
 +        const char *bin = "qemu";
          char *img = (char*)[ [ sheet filename ] cStringUsingEncoding:NSASCIIStringEncoding];
  
          char **argv = (char**)malloc( sizeof(char*)*3 );
@@@ -923,6 -906,7 +909,6 @@@ int main (int argc, const char * argv[]
  }
  
  
 -
  #pragma mark qemu
  static void cocoa_update(DisplayState *ds, int x, int y, int w, int h)
  {
              w * [cocoaView cdx],
              h * [cocoaView cdy]);
      }
 -    [cocoaView displayRect:rect];
 +    [cocoaView setNeedsDisplayInRect:rect];
  }
  
- static void cocoa_resize(DisplayState *ds, int w, int h)
+ static void cocoa_resize(DisplayState *ds)
  {
      COCOA_DEBUG("qemu_cocoa: cocoa_resize\n");
  
-     [cocoaView resizeContentToWidth:w height:h displayState:ds];
+     [cocoaView resizeContentToWidth:(int)(ds_get_width(ds)) height:(int)(ds_get_height(ds)) displayState:ds];
  }
  
  static void cocoa_refresh(DisplayState *ds)
  static void cocoa_cleanup(void)
  {
      COCOA_DEBUG("qemu_cocoa: cocoa_cleanup\n");
+       qemu_free(dcl);
  }
  
  void cocoa_display_init(DisplayState *ds, int full_screen)
  {
      COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n");
  
-     // register vga outpu callbacks
-     ds->dpy_update = cocoa_update;
-     ds->dpy_resize = cocoa_resize;
-     ds->dpy_refresh = cocoa_refresh;
+       dcl = qemu_mallocz(sizeof(DisplayChangeListener));
+       
+     // register vga output callbacks
+     dcl->dpy_update = cocoa_update;
+     dcl->dpy_resize = cocoa_resize;
+     dcl->dpy_refresh = cocoa_refresh;
  
-     // give window a initial Size
-     cocoa_resize(ds, 640, 400);
+       register_displaychangelistener(ds, dcl);
  
      // register cleanup function
      atexit(cocoa_cleanup);
diff --combined configure
+++ b/configure
@@@ -187,6 -187,7 +187,7 @@@ kerneldir="
  aix="no"
  blobs="yes"
  fdt="yes"
+ sdl_x11="no"
  
  # OS specific
  if check_define __linux__ ; then
@@@ -244,9 -245,9 +245,9 @@@ Darwin
  bsd="yes"
  darwin="yes"
  # on Leopard most of the system is 32-bit, so we have to ask the kernel it if we can run 64-bit userspace code
- is_x86_64=`sysctl -n hw.optional.x86_64`
- if [ "$is_x86_64" = "1" ]; then
-     cpu=x86_64
+ if [ "$cpu" = "i386" ] ; then
+     is_x86_64=`sysctl -n hw.optional.x86_64`
+     [ "$is_x86_64" = "1" ] && cpu=x86_64
  fi
  if [ "$cpu" = "x86_64" ] ; then
      OS_CFLAGS="-arch x86_64"
@@@ -805,6 -806,21 +806,21 @@@ els
      fi
  fi # -z $sdl
  
+ if test "$sdl" = "yes" ; then
+ cat > $TMPC <<EOF
+ #include <SDL.h>
+ #if defined(SDL_VIDEO_DRIVER_X11)
+ #include <X11/XKBlib.h>
+ #else
+ #error No x11 support
+ #endif
+ int main(void) { return 0; }
+ EOF
+     if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` > /dev/null 2>&1 ; then
+       sdl_x11="yes"
+     fi
+ fi
  ##########################################
  # VNC TLS detection
  if test "$vnc_tls" = "yes" ; then
    fi
  fi
  
 +#
 +# Check for xxxat() functions when we are building linux-user
 +# emulator.  This is done because older glibc versions don't
 +# have syscall stubs for these implemented.  In that case we
 +# don't provide them even if kernel supports them.
 +#
 +atfile=no
 +if [ "$linux_user" = "yes" ] ; then
 +  cat > $TMPC << EOF
 +#define _ATFILE_SOURCE
 +#include <sys/types.h>
 +#include <fcntl.h>
 +#include <unistd.h>
 +
 +int
 +main(void)
 +{ 
 +      /* try to unlink nonexisting file */
 +      return (unlinkat(AT_FDCWD, "nonexistent_file", 0));
 +}
 +EOF
 +  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
 +    atfile=yes
 +  fi
 +fi
 +
  # Check if tools are available to build documentation.
  if [ -x "`which texi2html 2>/dev/null`" ] && \
     [ -x "`which pod2man 2>/dev/null`" ]; then
@@@ -1147,7 -1137,6 +1163,7 @@@ if test "$sdl" != "no" ; the
      echo "SDL static link   $sdl_static"
  fi
  echo "curses support    $curses"
 +echo "atfile support    $atfile"
  echo "mingw32 support   $mingw32"
  echo "Audio drivers     $audio_drv_list"
  echo "Extra audio cards $audio_card_list"
@@@ -1420,6 -1409,8 +1436,8 @@@ if test "$sdl1" = "yes" ; the
    echo "CONFIG_SDL=yes" >> $config_mak
    if test "$target_softmmu" = "no" -o "$static" = "yes"; then
      echo "SDL_LIBS=$sdl_static_libs" >> $config_mak
+   elif test "$sdl_x11" = "yes" ; then
+     echo "SDL_LIBS=`$sdl_config --libs` -lX11" >> $config_mak
    else
      echo "SDL_LIBS=`$sdl_config --libs`" >> $config_mak
    fi
@@@ -1438,9 -1429,6 +1456,9 @@@ if test "$curses" = "yes" ; the
    echo "CONFIG_CURSES=yes" >> $config_mak
    echo "CURSES_LIBS=-lcurses" >> $config_mak
  fi
 +if test "$atfile" = "yes" ; then
 +  echo "#define CONFIG_ATFILE 1" >> $config_h
 +fi
  if test "$brlapi" = "yes" ; then
    echo "CONFIG_BRLAPI=yes" >> $config_mak
    echo "#define CONFIG_BRLAPI 1" >> $config_h
diff --combined hw/boards.h
@@@ -42,6 -42,7 +42,7 @@@ extern QEMUMachine heathrow_machine
  extern QEMUMachine ref405ep_machine;
  extern QEMUMachine taihu_machine;
  extern QEMUMachine bamboo_machine;
+ extern QEMUMachine mpc8544ds_machine;
  
  /* mips_r4k.c */
  extern QEMUMachine mips_machine;
@@@ -127,7 -128,4 +128,7 @@@ extern QEMUMachine musicpal_machine
  /* tosa.c */
  extern QEMUMachine tosapda_machine;
  
 +/* beagle.c */
 +extern QEMUMachine beagle_machine;
 +
  #endif
diff --combined linux-user/main.c
@@@ -1004,7 -1004,7 +1004,7 @@@ void cpu_loop (CPUSPARCState *env
          default:
              printf ("Unhandled trap: 0x%x\n", trapnr);
              cpu_dump_state(env, stderr, fprintf, 0);
 -            exit (1);
 +            _exit (1);
          }
          process_pending_signals (env);
      }
@@@ -1933,7 -1933,7 +1933,7 @@@ void cpu_loop (CPUState *env
          default:
              printf ("Unhandled trap: 0x%x\n", trapnr);
              cpu_dump_state(env, stderr, fprintf, 0);
 -            exit (1);
 +            _exit (1);
          }
          process_pending_signals (env);
      }
@@@ -2193,7 -2193,6 +2193,7 @@@ static void usage(void
             "-drop-ld-preload  drop LD_PRELOAD for target process\n"
             "-E var=value      sets/modifies targets environment variable(s)\n"
             "-U var            unsets targets environment variable(s)\n"
 +           "-0 argv0          forces target process argv[0] to be argv0\n"
             "\n"
             "Debug options:\n"
             "-d options   activate log (logfile=%s)\n"
             interp_prefix,
             x86_stack_size,
             DEBUG_LOGFILE);
-     _exit(1);
+     exit(1);
  }
  
  THREAD CPUState *thread_env;
@@@ -2234,7 -2233,7 +2234,7 @@@ void init_task_state(TaskState *ts
   
  int main(int argc, char **argv, char **envp)
  {
 -    const char *filename;
 +    char *filename = NULL;
      const char *cpu_model;
      struct target_pt_regs regs1, *regs = &regs1;
      struct image_info info1, *info = &info1;
      const char *r;
      int gdbstub_port = 0;
      char **target_environ, **wrk;
 +    char **target_argv;
 +    int target_argc;
 +    int drop_ld_preload = 0;
      envlist_t *envlist = NULL;
 +    const char *argv0 = NULL;
 +    int i;
  
      if (argc <= 1)
          usage();
                  for(item = cpu_log_items; item->mask != 0; item++) {
                      printf("%-10s %s\n", item->name, item->help);
                  }
 -                exit(1);
 +                _exit(1);
              }
              cpu_set_log(mask);
          } else if (!strcmp(r, "E")) {
              r = argv[optind++];
              if (envlist_unsetenv(envlist, r) != 0)
                  usage();
 +        } else if (!strcmp(r, "0")) {
 +            r = argv[optind++];
 +            argv0 = r;
 +        } else if (!strcmp(r,"-sbox-call")) {
 +           r = argv[optind++];
 +           filename = r;
 +           exec_path = r;
          } else if (!strcmp(r, "s")) {
              if (optind >= argc)
                  break;
              if (qemu_host_page_size == 0 ||
                  (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
                  fprintf(stderr, "page size must be a power of two\n");
 -                exit(1);
 +                _exit(1);
              }
          } else if (!strcmp(r, "g")) {
              if (optind >= argc)
  #if defined(cpu_list)
                      cpu_list(stdout, &fprintf);
  #endif
-                 _exit(1);
+                 exit(1);
              }
          } else if (!strcmp(r, "drop-ld-preload")) {
 -            (void) envlist_unsetenv(envlist, "LD_PRELOAD");
 +            drop_ld_preload = 1;
 +        } else if (!strcmp(r, "keep-ld-preload")) {
 +            drop_ld_preload = 0;
          } else if (!strcmp(r, "strace")) {
              do_strace = 1;
          } else
      }
      if (optind >= argc)
          usage();
 -    filename = argv[optind];
 -    exec_path = argv[optind];
 +    if (filename == NULL) {
 +        filename = argv[optind];
 +        exec_path = argv[optind];
 +    } else {
 +        argv0 = argv[optind];
 +    }
 +    if (drop_ld_preload) {
 +        (void) envlist_unsetenv(envlist, "LD_PRELOAD");
 +    }
  
      /* Zero out regs */
      memset(regs, 0, sizeof(struct target_pt_regs));
          cpu_model = "qemu32";
  #endif
  #elif defined(TARGET_ARM)
 -        cpu_model = "arm926";
 +        cpu_model = "any";
  #elif defined(TARGET_M68K)
          cpu_model = "any";
  #elif defined(TARGET_SPARC)
      target_environ = envlist_to_environ(envlist, NULL);
      envlist_free(envlist);
  
 -    if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
 +    /*
 +     * Prepare copy of argv vector for target.
 +     */
 +    target_argc = argc - optind;
 +    target_argv = calloc(target_argc + 1, sizeof (char *));
 +    if (target_argv == NULL) {
 +      (void) fprintf(stderr, "Unable to allocate memory for target_argv\n");
 +      exit(1);
 +    }
 +
 +    /*
 +     * If argv0 is specified (using '-0' switch) we replace
 +     * argv[0] pointer with the given one.
 +     */
 +    i = 0;
 +    if (argv0 != NULL) {
 +        target_argv[i++] = strdup(argv0);
 +    }
 +    for (; i < target_argc; i++) {
 +        target_argv[i] = strdup(argv[optind + i]);
 +    }
 +    target_argv[target_argc] = NULL;
 +
 +    if (loader_exec(filename, target_argv, target_environ, regs, info) != 0) {
          printf("Error loading %s\n", filename);
          _exit(1);
      }
  
 +    for (i = 0; i < target_argc; i++) {
 +        free(target_argv[i]);
 +    }
 +    free(target_argv);
 +
      for (wrk = target_environ; *wrk; wrk++) {
          free(*wrk);
      }