changeset 651:0d6c67c401e0

Fix qemu build and add sh4 -append patch.
author Rob Landley <rob@landley.net>
date Wed, 25 Mar 2009 06:41:32 -0500
parents 7a4ea7f6dc3d
children dd462f3f876e
files host-tools.sh sources/patches/qemu-sh4-append.patch
diffstat 2 files changed, 57 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/host-tools.sh	Tue Mar 24 21:30:37 2009 -0500
+++ b/host-tools.sh	Wed Mar 25 06:41:32 2009 -0500
@@ -137,7 +137,6 @@
 # Build distcc (if it's not in $PATH)
 if [ -z "$(which distccd)" ]
 then
-echo build distcc
   setupfor distcc &&
   ./configure --with-included-popt --disable-Werror &&
   make -j "$CPUS" &&
@@ -175,7 +174,7 @@
 # fsck.ext2 and tune2fs.  These are installed by default in most distros
 # (which genext2fs isn't), and genext2fs doesn't have ext3 support anyway.
 
-if [ -z "$(which mke2fs)" ]
+if [ ! -f "${HOSTTOOLS}"/mke2fs ]
 then
   setupfor e2fsprogs &&
   ./configure &&
@@ -207,41 +206,41 @@
 
 # Either build qemu from source, or symlink it.
 
-if [ ! -z "$HOST_BUILD_EXTRA" ]
+if [ ! -f "${HOSTTOOLS}"/qemu ]
 then
-
-  # Build qemu.  Note that this is _very_slow_.  (It takes about as long as
-  # building a system image from scratch, including the cross compiler.)
+  if [ ! -z "$HOST_BUILD_EXTRA" ]
+  then
 
-  # It's also ugly: its wants to populate a bunch of subdirectories under
-  # --prefix, and we can't just install it in host-temp and copy out what
-  # we want because the pc-bios directory needs to exist at a hardwired
-  # absolute path.
+    # Build qemu.  Note that this is _very_slow_.  (It takes about as long as
+    # building a system image from scratch, including the cross compiler.)
 
-  if [ -z "$(which qemu)" ]
-  then
+    # It's also ugly: its wants to populate a bunch of subdirectories under
+    # --prefix, and we can't just install it in host-temp and copy out what
+    # we want because the pc-bios directory needs to exist at a hardwired
+    # absolute path, so we do the install by hand.
+
     setupfor qemu &&
     cp "$SOURCES"/patches/openbios-ppc pc-bios/openbios-ppc &&
-    ./configure --disable-gfx-check --prefix="$HOSTTOOLS/qemu-stuff" &&
+    ./configure --disable-gfx-check --prefix="$HOSTTOOLS" &&
     make -j $CPUS &&
-    make install &&
-    mv "$HOSTTOOLS/qemu-stuff/bin/*" "$HOSTTOOLS" &&
+    # Copy the executable files and ROM files
+    cp $(find -type f -perm +111 -name "qemu*") "$HOSTTOOLS" &&
+    cp -r pc-bios "$HOSTTOOLS" &&
     cd ..
 
     cleanup qemu
-  fi
-else
-
-  # Symlink qemu out of the host, if found.  Since run-from-build.sh uses
-  # $PATH=.../build/host if it exists, add the various qemu instances to that.
+  else
+    # Symlink qemu out of the host, if found.  Since run-from-build.sh uses
+    # $PATH=.../build/host if it exists, add the various qemu instances to that.
 
-  echo "$PATH" | sed 's/:/\n/g' | while read i
-  do
-    for j in $(cd "$i"; ls qemu-system-* 2>/dev/null)
+    echo "$OLDPATH" | sed 's/:/\n/g' | while read i
     do
-      ln -s "$i/$j" "$HOSTTOOLS/$j"
+      for j in $(cd "$i"; ls qemu-* 2>/dev/null)
+      do
+        ln -s "$i/$j" "$HOSTTOOLS/$j"
+      done
     done
-  done
+  fi
 fi
 
 if [ ! -z "$RECORD_COMMANDS" ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/patches/qemu-sh4-append.patch	Wed Mar 25 06:41:32 2009 -0500
@@ -0,0 +1,33 @@
+diff -ru qemu-0.10.0/hw/r2d.c qemu-0.10.0.new/hw/r2d.c
+--- qemu-0.10.0/hw/r2d.c	2009-03-04 16:54:45.000000000 -0600
++++ qemu-0.10.0.new/hw/r2d.c	2009-03-18 12:42:25.000000000 -0500
+@@ -233,20 +233,25 @@
+         pci_nic_init(pci, &nd_table[i], (i==0)? 2<<3: -1, "rtl8139");
+ 
+     /* Todo: register on board registers */
+-    {
++    if (kernel_filename) {
+       int kernel_size;
+       /* initialization which should be done by firmware */
+       stl_phys(SH7750_BCR1, 1<<3); /* cs3 SDRAM */
+       stw_phys(SH7750_BCR2, 3<<(3*2)); /* cs3 32bit */
+ 
+-      kernel_size = load_image(kernel_filename, phys_ram_base);
++      if (kernel_cmdline) {
++          kernel_size = load_image(kernel_filename, phys_ram_base + 0x80000);
++          env->pc = (SDRAM_BASE + 0x80000) | 0xa0000000;
++          pstrcpy(phys_ram_base + 0x10100, 256, kernel_cmdline);
++      } else {
++          kernel_size = load_image(kernel_filename, phys_ram_base);
++          env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */
++      }
+ 
+       if (kernel_size < 0) {
+         fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
+         exit(1);
+       }
+-
+-      env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */
+     }
+ }
+