qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Native Port of QEMU to Haiku
@ 2009-05-18 13:46 Michael Lotz
  2009-05-19  8:32 ` Stefan Weil
                   ` (4 more replies)
  0 siblings, 5 replies; 21+ messages in thread
From: Michael Lotz @ 2009-05-18 13:46 UTC (permalink / raw)
  To: qemu-devel

Hi there

I'm one of the developers that work on the Haiku OS and have also been 
maintaining the BeOS/Haiku port of QEMU for the last couple of years. 
Due to BeOS being locked into GCC 2.95.3 and our commitment to provide 
binary compatibility with BeOS R5 in the first Haiku release, getting 
this port to work and maintaining it has been a lot of work and largely 
just a hack.

Haiku however also has a native GCC 4.3.3 toolchain since some time and 
I brought the QEMU port up to date using it. Since QEMU is pure C, it 
was possible to mix the Haiku display part and audio backend compiled 
with GCC 2.95.3 with a GCC 4.3.3 compiled QEMU core (this doesn't 
require any code changes and will simply continue to work once we 
migrate fully to GCC 4). This made it possible to do a much cleaner 
port that I think could now also be commited into the QEMU repository.

Since BeOS is not going anywhere and since it is stuck with the old 
GCC, I've removed all the leftovers from the original BeOS port so the 
final patch simply adds native Haiku support to QEMU.

The patch linked below is against the 0.10.4 release sources including 
kqemu in a kqemu subdirectory. Please advice if you would be willing to 
include this work into your repository. If necessary I can split this 
up into multiple patches providing more detailed info on the different 
parts or diff it against more current sources. Please just let me know.

http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff

Regards
Michael

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
@ 2009-05-19  8:32 ` Stefan Weil
  2009-05-19  8:48 ` Avi Kivity
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Stefan Weil @ 2009-05-19  8:32 UTC (permalink / raw)
  To: Michael Lotz; +Cc: qemu-devel

Michael Lotz schrieb:
> Hi there
>
> I'm one of the developers that work on the Haiku OS and have also been 
> maintaining the BeOS/Haiku port of QEMU for the last couple of years. 
> Due to BeOS being locked into GCC 2.95.3 and our commitment to provide 
> binary compatibility with BeOS R5 in the first Haiku release, getting 
> this port to work and maintaining it has been a lot of work and largely 
> just a hack.
>
> Haiku however also has a native GCC 4.3.3 toolchain since some time and 
> I brought the QEMU port up to date using it. Since QEMU is pure C, it 
> was possible to mix the Haiku display part and audio backend compiled 
> with GCC 2.95.3 with a GCC 4.3.3 compiled QEMU core (this doesn't 
> require any code changes and will simply continue to work once we 
> migrate fully to GCC 4). This made it possible to do a much cleaner 
> port that I think could now also be commited into the QEMU repository.
>
> Since BeOS is not going anywhere and since it is stuck with the old 
> GCC, I've removed all the leftovers from the original BeOS port so the 
> final patch simply adds native Haiku support to QEMU.
>
> The patch linked below is against the 0.10.4 release sources including 
> kqemu in a kqemu subdirectory. Please advice if you would be willing to 
> include this work into your repository. If necessary I can split this 
> up into multiple patches providing more detailed info on the different 
> parts or diff it against more current sources. Please just let me know.
>
> http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff
>
> Regards
> Michael
>
>
>   

Hi,

it should be possible to get standard integral types
like int32_t from stdint.h, so special code for Haiku
in fpu/softfloat.h or kqemu/kqemu-haiku.c can be
removed.

Regards
Stefan

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
  2009-05-19  8:32 ` Stefan Weil
@ 2009-05-19  8:48 ` Avi Kivity
  2009-05-19 12:56 ` Anthony Liguori
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 21+ messages in thread
From: Avi Kivity @ 2009-05-19  8:48 UTC (permalink / raw)
  To: Michael Lotz; +Cc: qemu-devel

Michael Lotz wrote:
> The patch linked below is against the 0.10.4 release sources including 
> kqemu in a kqemu subdirectory. Please advice if you would be willing to 
> include this work into your repository. If necessary I can split this 
> up into multiple patches providing more detailed info on the different 
> parts or diff it against more current sources. Please just let me know.
>   

Please patch against the qemu.git master branch.  New ports are not 
stable branch material.  Also, consult the CODING_STYLE file.  Please 
post the patch inline instead of a link for easy review.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
  2009-05-19  8:32 ` Stefan Weil
  2009-05-19  8:48 ` Avi Kivity
@ 2009-05-19 12:56 ` Anthony Liguori
  2009-05-19 13:54 ` François Revol
  2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
  4 siblings, 0 replies; 21+ messages in thread
From: Anthony Liguori @ 2009-05-19 12:56 UTC (permalink / raw)
  To: Michael Lotz; +Cc: qemu-devel

Michael Lotz wrote:
> Hi there
>
> I'm one of the developers that work on the Haiku OS and have also been 
> maintaining the BeOS/Haiku port of QEMU for the last couple of years. 
> Due to BeOS being locked into GCC 2.95.3 and our commitment to provide 
> binary compatibility with BeOS R5 in the first Haiku release, getting 
> this port to work and maintaining it has been a lot of work and largely 
> just a hack.
>
> Haiku however also has a native GCC 4.3.3 toolchain since some time and 
> I brought the QEMU port up to date using it. Since QEMU is pure C, it 
> was possible to mix the Haiku display part and audio backend compiled 
> with GCC 2.95.3 with a GCC 4.3.3 compiled QEMU core (this doesn't 
> require any code changes and will simply continue to work once we 
> migrate fully to GCC 4). This made it possible to do a much cleaner 
> port that I think could now also be commited into the QEMU repository.
>
> Since BeOS is not going anywhere and since it is stuck with the old 
> GCC, I've removed all the leftovers from the original BeOS port so the 
> final patch simply adds native Haiku support to QEMU.
>
> The patch linked below is against the 0.10.4 release sources including 
> kqemu in a kqemu subdirectory. Please advice if you would be willing to 
> include this work into your repository. If necessary I can split this 
> up into multiple patches providing more detailed info on the different 
> parts or diff it against more current sources. Please just let me know.
>
> http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff
>   

To even consider this, you have to send this to the mailing list as a 
series of patches either inlined or attached as plain text.  A URL to a 
file with a non-text mime encoding is not easily reviewable.

Regards,

Anthony Liguori

> Regards
> Michael
>
>
>   

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
                   ` (2 preceding siblings ...)
  2009-05-19 12:56 ` Anthony Liguori
@ 2009-05-19 13:54 ` François Revol
  2009-05-19 16:56   ` Andreas Färber
  2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
  4 siblings, 1 reply; 21+ messages in thread
From: François Revol @ 2009-05-19 13:54 UTC (permalink / raw)
  To: Michael Lotz; +Cc: qemu-devel

> http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff
>

I think you missed the biggest part there, which has been discussed
previously, error signedness. Leaving it untouched will definitely get
you into trouble.

> +    fprintf(stderr, "no tap on Haiku\n");

That can be arrange, I just need to port my BONE tuntap driver to
Haiku.

François.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-19 13:54 ` François Revol
@ 2009-05-19 16:56   ` Andreas Färber
  2009-05-21  1:04     ` Ingo Weinhold
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2009-05-19 16:56 UTC (permalink / raw)
  To: François Revol; +Cc: Michael Lotz, Ingo Weinhold, qemu-devel


Am 19.05.2009 um 15:54 schrieb François Revol:

>> http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff
>>
>
> I think you missed the biggest part there, which has been discussed
> previously, error signedness. Leaving it untouched will definitely get
> you into trouble.

Didn't Ingo recently write some compatibility library for that purpose?

Andreas

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] Native Port of QEMU to Haiku
  2009-05-19 16:56   ` Andreas Färber
@ 2009-05-21  1:04     ` Ingo Weinhold
  0 siblings, 0 replies; 21+ messages in thread
From: Ingo Weinhold @ 2009-05-21  1:04 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Michael Lotz, François Revol, qemu-devel


On 2009-05-19 at 18:56:08 [+0200], Andreas Färber <andreas.faerber@web.de> 
wrote:
> 
> Am 19.05.2009 um 15:54 schrieb François Revol:
> 
> >> http://haiku.mlotz.ch/qemu-0.10.4-haiku.diff
> >>
> >
> > I think you missed the biggest part there, which has been discussed
> > previously, error signedness. Leaving it untouched will definitely get
> > you into trouble.
> 
> Didn't Ingo recently write some compatibility library for that purpose?

Yep, one has to actively use it when building, though:

  http://dev.haiku-os.org/changeset/29653

CU, Ingo

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 0/8] Add Haiku host support
  2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
                   ` (3 preceding siblings ...)
  2009-05-19 13:54 ` François Revol
@ 2010-09-19 22:50 ` Andreas Färber
  2010-09-19 22:50   ` [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku Andreas Färber
                     ` (2 more replies)
  4 siblings, 3 replies; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber

Hello,

The following patch series together with qemu_madvise() allows to build and
run QEMU on Haiku, using GCC 4.x.

Patches 1-5 add support for Haiku hosts to build ppc-softmmu.
They are based on qemu_madvise() v7, since Haiku does not have madvise(),
but they do not depend on it themselves so could be cherry-picked.

Patch 6 fixes a build warning.

The following patches are based on mmlr's 0.10.4 port and are not intended
for upstream inclusion at this time:

Patch 7 is needed for successful runtime execution.

Patch 8 is included as a test case and to show where things are moving wrt C++.

Not yet included is his native Haiku audio backend, also using C++.

Another issue that Michael had addressed and that I would like to see fixed
differently is a mismatch between softfloat headers and sources wrt int types.
I'll post a separate RFC since it's not strictly related to Haiku.

Regards,
Andreas

Andreas Färber (8):
  configure: Add basic support for Haiku
  configure: Don't rely on special pthreads library
  Haiku doesn't have libm
  nbd: Haiku has _IO() in its BSD compatibility layer
  tap: Add stub for Haiku
  slirp: Silence warning on Haiku
  qemu_malloc: Use areas on Haiku for sizes > 1 MiB
  ui: Haiku frontend

 Makefile        |    2 +
 Makefile.objs   |    2 +
 Makefile.target |    2 +
 configure       |   33 +++-
 console.h       |    3 +
 nbd.c           |    2 +-
 net/tap-haiku.c |   61 ++++++
 qemu-malloc.c   |   53 +++++
 rules.mak       |    6 +-
 slirp/slirp.h   |    4 +-
 ui/haiku.cpp    |  607 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/haiku.h      |   96 +++++++++
 vl.c            |   10 +-
 13 files changed, 869 insertions(+), 12 deletions(-)
 create mode 100644 net/tap-haiku.c
 create mode 100644 ui/haiku.cpp
 create mode 100644 ui/haiku.h

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku
  2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
@ 2010-09-19 22:50   ` Andreas Färber
  2010-09-19 22:50     ` [Qemu-devel] [PATCH 2/8] configure: Don't rely on special pthreads library Andreas Färber
  2010-09-20 19:04   ` [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support Ingo Weinhold
  2010-10-03  7:47   ` [Qemu-devel] " Blue Swirl
  2 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel
  Cc: haikuports-devs, Andreas Färber, François Revol,
	Ingo Weinhold

From: Andreas Färber <andreas.faerber>

For compatibility with BeOS, Haiku's error codes are negative whereas recent
POSIX versions require them to be positive. As spotted by François, some
parts of QEMU code rely on this, so use a mapper library to convert them
to positive ones.

Cc: François Revol <revol@free.fr>
Cc: Ingo Weinhold <ingo_weinhold@gmx.de>

Haiku has network functions in libnetwork.so. It doesn't ship libutil.so.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 configure |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 6a21bf2..da32a1c 100755
--- a/configure
+++ b/configure
@@ -315,6 +315,7 @@ io_thread="no"
 mixemu="no"
 kerneldir=""
 aix="no"
+haiku="no"
 blobs="yes"
 pkgversion=""
 check_utests="no"
@@ -332,6 +333,8 @@ elif check_define __OpenBSD__ ; then
   targetos='OpenBSD'
 elif check_define __sun__ ; then
   targetos='SunOS'
+elif check_define __HAIKU__ ; then
+  targetos='Haiku'
 else
   targetos=`uname -s`
 fi
@@ -447,6 +450,11 @@ AIX)
   aix="yes"
   make="gmake"
 ;;
+Haiku)
+  haiku="yes"
+  QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
+  LIBS="-lposix_error_mapper -lnetwork $LIBS"
+;;
 *)
   audio_drv_list="oss"
   audio_possible_drivers="oss alsa sdl esd pa"
@@ -2026,7 +2034,7 @@ elif compile_prog "" "-lrt" ; then
 fi
 
 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
-        "$aix" != "yes" ; then
+        "$aix" != "yes" -a "$haiku" != "yes" ; then
     libs_softmmu="-lutil $libs_softmmu"
 fi
 
@@ -2340,6 +2348,9 @@ if test "$solaris" = "yes" ; then
     echo "CONFIG_NEEDS_LIBSUNMATH=y" >> $config_host_mak
   fi
 fi
+if test "$haiku" = "yes" ; then
+  echo "CONFIG_HAIKU=y" >> $config_host_mak
+fi
 if test "$static" = "yes" ; then
   echo "CONFIG_STATIC=y" >> $config_host_mak
 fi
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 2/8] configure: Don't rely on special pthreads library
  2010-09-19 22:50   ` [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku Andreas Färber
@ 2010-09-19 22:50     ` Andreas Färber
  2010-09-19 22:50       ` [Qemu-devel] [PATCH 3/8] Haiku doesn't have libm Andreas Färber
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber

Haiku has pthreads integrated into its libroot.so library. No linker arguments
are needed for it, so don't fail if -lpthread and similar don't link.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 configure |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index da32a1c..2ba35a4 100755
--- a/configure
+++ b/configure
@@ -1706,13 +1706,17 @@ cat > $TMPC << EOF
 #include <pthread.h>
 int main(void) { pthread_create(0,0,0,0); return 0; }
 EOF
-for pthread_lib in $PTHREADLIBS_LIST; do
-  if compile_prog "" "$pthread_lib" ; then
-    pthread=yes
-    LIBS="$pthread_lib $LIBS"
-    break
-  fi
-done
+if compile_prog "" "" ; then
+  pthread=yes
+else
+  for pthread_lib in $PTHREADLIBS_LIST; do
+    if compile_prog "" "$pthread_lib" ; then
+      pthread=yes
+      LIBS="$pthread_lib $LIBS"
+      break
+    fi
+  done
+fi
 
 if test "$mingw32" != yes -a "$pthread" = no; then
   echo
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 3/8] Haiku doesn't have libm
  2010-09-19 22:50     ` [Qemu-devel] [PATCH 2/8] configure: Don't rely on special pthreads library Andreas Färber
@ 2010-09-19 22:50       ` Andreas Färber
  2010-09-19 22:50         ` [Qemu-devel] [PATCH 4/8] nbd: Haiku has _IO() in its BSD compatibility layer Andreas Färber
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber

Math functions are integrated into Haiku's libroot.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 Makefile.target |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index a4e80b1..296f252 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -31,7 +31,9 @@ endif
 
 PROGS=$(QEMU_PROG)
 
+ifndef CONFIG_HAIKU
 LIBS+=-lm
+endif
 
 kvm.o kvm-all.o vhost.o vhost_net.o: QEMU_CFLAGS+=$(KVM_CFLAGS)
 
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 4/8] nbd: Haiku has _IO() in its BSD compatibility layer
  2010-09-19 22:50       ` [Qemu-devel] [PATCH 3/8] Haiku doesn't have libm Andreas Färber
@ 2010-09-19 22:50         ` Andreas Färber
  2010-09-19 22:50           ` [Qemu-devel] [PATCH 5/8] tap: Add stub for Haiku Andreas Färber
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 nbd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/nbd.c b/nbd.c
index 011b50f..d4c0ab2 100644
--- a/nbd.c
+++ b/nbd.c
@@ -23,7 +23,7 @@
 #ifndef _WIN32
 #include <sys/ioctl.h>
 #endif
-#ifdef __sun__
+#if defined(__sun__) || defined(__HAIKU__)
 #include <sys/ioccom.h>
 #endif
 #include <ctype.h>
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 5/8] tap: Add stub for Haiku
  2010-09-19 22:50         ` [Qemu-devel] [PATCH 4/8] nbd: Haiku has _IO() in its BSD compatibility layer Andreas Färber
@ 2010-09-19 22:50           ` Andreas Färber
  2010-09-19 22:50             ` [Qemu-devel] [PATCH 6/8] slirp: Silence warning on Haiku Andreas Färber
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber

Adapted from AIX code.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 Makefile.objs   |    1 +
 net/tap-haiku.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)
 create mode 100644 net/tap-haiku.c

diff --git a/Makefile.objs b/Makefile.objs
index 3ef6d80..f702ad4 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -31,6 +31,7 @@ net-nested-$(CONFIG_WIN32) += tap-win32.o
 net-nested-$(CONFIG_BSD) += tap-bsd.o
 net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
 net-nested-$(CONFIG_AIX) += tap-aix.o
+net-nested-$(CONFIG_HAIKU) += tap-haiku.o
 net-nested-$(CONFIG_SLIRP) += slirp.o
 net-nested-$(CONFIG_VDE) += vde.o
 net-obj-y += $(addprefix net/, $(net-nested-y))
diff --git a/net/tap-haiku.c b/net/tap-haiku.c
new file mode 100644
index 0000000..91dda8e
--- /dev/null
+++ b/net/tap-haiku.c
@@ -0,0 +1,61 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "net/tap.h"
+#include <stdio.h>
+
+int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required)
+{
+    fprintf(stderr, "no tap on Haiku\n");
+    return -1;
+}
+
+int tap_set_sndbuf(int fd, QemuOpts *opts)
+{
+    return 0;
+}
+
+int tap_probe_vnet_hdr(int fd)
+{
+    return 0;
+}
+
+int tap_probe_has_ufo(int fd)
+{
+    return 0;
+}
+
+int tap_probe_vnet_hdr_len(int fd, int len)
+{
+    return 0;
+}
+
+void tap_fd_set_vnet_hdr_len(int fd, int len)
+{
+}
+
+void tap_fd_set_offload(int fd, int csum, int tso4,
+                        int tso6, int ecn, int ufo)
+{
+}
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [PATCH 6/8] slirp: Silence warning on Haiku
  2010-09-19 22:50           ` [Qemu-devel] [PATCH 5/8] tap: Add stub for Haiku Andreas Färber
@ 2010-09-19 22:50             ` Andreas Färber
  2010-09-19 22:50               ` [Qemu-devel] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Andreas Färber
  0 siblings, 1 reply; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber, Jan Kiszka

Haiku has O_BINARY in fcntl.h.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Cc: Jan Kiszka <jan.kiszka@web.de>
---
 slirp/slirp.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/slirp/slirp.h b/slirp/slirp.h
index 3a5d592..6c7488c 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -24,7 +24,9 @@ typedef char *caddr_t;
 #else
 # define ioctlsocket ioctl
 # define closesocket(s) close(s)
-# define O_BINARY 0
+# if !defined(__HAIKU__)
+#  define O_BINARY 0
+# endif
 #endif
 
 #include <sys/types.h>
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB
  2010-09-19 22:50             ` [Qemu-devel] [PATCH 6/8] slirp: Silence warning on Haiku Andreas Färber
@ 2010-09-19 22:50               ` Andreas Färber
  2010-09-19 22:50                 ` [Qemu-devel] [FYI 8/8] ui: Haiku frontend Andreas Färber
  2010-09-20 12:26                 ` [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Oliver Tappe
  0 siblings, 2 replies; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Andreas Färber, Michael Lotz

Works around a calloc() SEGV in Haiku's libroot.
Cf. http://dev.haiku-os.org/ticket/6637

Ported to HEAD based on a patch by Michael "mmlr" Lotz.
Also consider the limit when reallocating.

Cc: Michael Lotz <mmlr@mlotz.ch>
---
 configure     |    1 +
 qemu-malloc.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 2ba35a4..3a0d50e 100755
--- a/configure
+++ b/configure
@@ -2354,6 +2354,7 @@ if test "$solaris" = "yes" ; then
 fi
 if test "$haiku" = "yes" ; then
   echo "CONFIG_HAIKU=y" >> $config_host_mak
+  echo "CONFIG_HAIKU_USE_AREAS=y" >> $config_host_mak
 fi
 if test "$static" = "yes" ; then
   echo "CONFIG_STATIC=y" >> $config_host_mak
diff --git a/qemu-malloc.c b/qemu-malloc.c
index ecffb67..ea75a6a 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -25,6 +25,11 @@
 #include "trace.h"
 #include <stdlib.h>
 
+#ifdef CONFIG_HAIKU_USE_AREAS
+#include <OS.h>
+static area_id sHeapArea = 0;
+#endif
+
 static void *oom_check(void *ptr)
 {
     if (ptr == NULL) {
@@ -36,7 +41,18 @@ static void *oom_check(void *ptr)
 void qemu_free(void *ptr)
 {
     trace_qemu_free(ptr);
+#ifdef CONFIG_HAIKU_USE_AREAS
+    if (ptr != NULL) {
+        area_id area = area_for(ptr);
+        if (area == sHeapArea) {
+#endif
     free(ptr);
+#ifdef CONFIG_HAIKU_USE_AREAS
+        } else {
+            delete_area(area);
+        }
+    }
+#endif
 }
 
 static int allow_zero_malloc(void)
@@ -54,7 +70,23 @@ void *qemu_malloc(size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
+#ifdef CONFIG_HAIKU_USE_AREAS
+    if (size >= 1024 * 1024) {
+        if (create_area("qemu large alloc area", &ptr, B_ANY_ADDRESS,
+            ((size + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE,
+            B_NO_LOCK, B_READ_AREA | B_WRITE_AREA) < B_OK) {
+            ptr = NULL;
+        }
+        ptr = oom_check(ptr);
+    } else {
+#endif
     ptr = oom_check(malloc(size ? size : 1));
+#ifdef CONFIG_HAIKU_USE_AREAS
+        if (sHeapArea == 0) {
+            sHeapArea = area_for(ptr);
+        }
+    }
+#endif
     trace_qemu_malloc(size, ptr);
     return ptr;
 }
@@ -65,7 +97,28 @@ void *qemu_realloc(void *ptr, size_t size)
     if (!size && !allow_zero_malloc()) {
         abort();
     }
+#ifdef CONFIG_HAIKU_USE_AREAS
+    area_id area = 0;
+    if (ptr != NULL) {
+        area = area_for(ptr);
+    }
+    if ((area == 0 || area == sHeapArea) && size < 1024 * 1024) {
+#endif
     newptr = oom_check(realloc(ptr, size ? size : 1));
+#ifdef CONFIG_HAIKU_USE_AREAS
+    } else if (area == 0 || area == sHeapArea) {
+        free(ptr);
+        newptr = qemu_malloc(size);
+    } else {
+        if (resize_area(area,
+            ((size + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE) == B_OK) {
+            newptr = ptr;
+        } else {
+            newptr = NULL;
+        }
+        newptr = oom_check(newptr);
+    }
+#endif
     trace_qemu_realloc(ptr, size, newptr);
     return newptr;
 }
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] [FYI 8/8] ui: Haiku frontend
  2010-09-19 22:50               ` [Qemu-devel] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Andreas Färber
@ 2010-09-19 22:50                 ` Andreas Färber
  2010-09-20 12:26                 ` [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Oliver Tappe
  1 sibling, 0 replies; 21+ messages in thread
From: Andreas Färber @ 2010-09-19 22:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: haikuports-devs, Blue Swirl, Andreas Färber, Michael Lotz

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 23820 bytes --]

Since Haiku is still in development and raw builds don't contain the
SDL or a VNC client, a native frontend is convenient. mmlr had maintained
a basic one for BeOS/Haiku until the kqemu drop. The code has been ported
to HEAD but is not yet fully updated to match CODING_STYLE.

Cc: Michael Lotz <mmlr@mlotz.ch>

Haiku's native APIs are C++ based, so we need a new make rule.
Some enabled GCC warnings are not applicable to C++ code and cause warnings.

Cc: Blue Swirl <blauwirbel@gmail.com>

Note that this frontend is another candidate user of a central qemu_main()
prototype, like Cocoa. It would also be candidate for a generic argv check
for non-graphic mode, to be shared with Cocoa.
---
 Makefile      |    2 +
 Makefile.objs |    1 +
 configure     |    1 +
 console.h     |    3 +
 rules.mak     |    6 +-
 ui/haiku.cpp  |  607 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ui/haiku.h    |   96 +++++++++
 vl.c          |   10 +-
 8 files changed, 724 insertions(+), 2 deletions(-)
 create mode 100644 ui/haiku.cpp
 create mode 100644 ui/haiku.h

diff --git a/Makefile b/Makefile
index ab91d42..64eea3e 100644
--- a/Makefile
+++ b/Makefile
@@ -98,6 +98,8 @@ QEMU_CFLAGS+=$(CURL_CFLAGS)
 
 ui/cocoa.o: ui/cocoa.m
 
+ui/haiku.o: ui/haiku.cpp
+
 ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS)
 
 ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
diff --git a/Makefile.objs b/Makefile.objs
index f702ad4..6ae0e14 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -112,6 +112,7 @@ ui-obj-y += vnc-enc-tight.o vnc-palette.o
 ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
 ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
 ui-obj-$(CONFIG_COCOA) += cocoa.o
+ui-obj-$(CONFIG_HAIKU) += haiku.o
 ifdef CONFIG_VNC_THREAD
 ui-obj-y += vnc-jobs-async.o
 else
diff --git a/configure b/configure
index 3a0d50e..b533990 100755
--- a/configure
+++ b/configure
@@ -454,6 +454,7 @@ Haiku)
   haiku="yes"
   QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS $QEMU_CFLAGS"
   LIBS="-lposix_error_mapper -lnetwork $LIBS"
+  LIBS="-lstdc++ -lbe -lgame $LIBS"
 ;;
 *)
   audio_drv_list="oss"
diff --git a/console.h b/console.h
index aafb031..9a8268a 100644
--- a/console.h
+++ b/console.h
@@ -364,6 +364,9 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
 /* cocoa.m */
 void cocoa_display_init(DisplayState *ds, int full_screen);
 
+/* haiku.cpp */
+void haiku_display_init(DisplayState *ds, int full_screen);
+
 /* vnc.c */
 void vnc_display_init(DisplayState *ds);
 void vnc_display_close(DisplayState *ds);
diff --git a/rules.mak b/rules.mak
index c843a13..29481b9 100644
--- a/rules.mak
+++ b/rules.mak
@@ -8,6 +8,7 @@ MAKEFLAGS += -rR
 %.d:
 %.h:
 %.c:
+%.cpp:
 %.m:
 %.mak:
 
@@ -23,6 +24,9 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 %.o: %.m
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
+%.o: %.cpp
+	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CXX   $(TARGET_DIR)$@")
+
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
 %$(EXESUF): %.o
@@ -39,7 +43,7 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
               >/dev/null 2>&1 && echo OK), $2, $3)
 
-VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi
+VPATH_SUFFIXES = %.c %.h %.S %.m %.cpp %.mak %.texi
 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
 
 # Generate timestamp files for .h include files
diff --git a/ui/haiku.cpp b/ui/haiku.cpp
new file mode 100644
index 0000000..37b9414
--- /dev/null
+++ b/ui/haiku.cpp
@@ -0,0 +1,607 @@
+/*
+ * QEMU Haiku display driver
+ *
+ * Copyright (c) 2010 Andreas Färber
+ * Copyright (c) 2005-2009 Michael Lotz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "haiku.h"
+
+#include <stdio.h>
+
+#include <Path.h>
+#include <Screen.h>
+#include <WindowScreen.h>
+
+
+extern "C" {
+
+#include "qemu-common.h"
+#include "console.h"
+#include "sysemu.h"
+
+int qemu_main(int argc, char **argv, char** envp);
+
+}
+
+
+QEMUApplication *gApplication;
+QEMUWindow *gWindow;
+QEMUView *gView;
+bool gFullScreen;
+int gWidth = 100;
+int gHeight = 100;
+BPoint gCenter;
+BPoint gPreviousLocation;
+
+
+// Haiku keycode to scancode table
+static const uint8
+haiku_to_pc_key[] = {
+	0x00,	/* 0x00 */						0x01,	/* 0x01 Esc */
+	0x3b,	/* 0x02 F1 */					0x3c,	/* 0x03 F2 */
+	0x3d,	/* 0x04 F3 */					0x3e,	/* 0x05 F4 */
+	0x3f,	/* 0x06 F5 */					0x40,	/* 0x07 F6 */
+	0x41,	/* 0x08 F7 */					0x42,	/* 0x09 F8 */
+	0x43,	/* 0x0a F9 */					0x44,	/* 0x0b F10 */
+	0x57,	/* 0x0c F11 */					0x58,	/* 0x0d F12 */
+	0xb7,	/* 0x0e Print Screen */			0x46,	/* 0x0f Scroll Lock */
+	0xc5,	/* 0x10 Pause */				0x29,	/* 0x11 Grave */
+	0x02,	/* 0x12 1 */					0x03,	/* 0x13 2 */
+	0x04,	/* 0x14 3 */					0x05,	/* 0x15 4 */
+	0x06,	/* 0x16 5 */					0x07,	/* 0x17 6 */
+	0x08,	/* 0x18 7 */					0x09,	/* 0x19 8 */
+	0x0a,	/* 0x1a 9 */					0x0b,	/* 0x1b 0 */
+	0x0c,	/* 0x1c Minus */				0x0d,	/* 0x1d Equals */
+	0x0e,	/* 0x1e Backspace */			0xd2,	/* 0x1f Insert */
+	0xc7,	/* 0x20 Home */					0xc9,	/* 0x21 Page Up */
+	0x45,	/* 0x22 Num Lock */				0xb5,	/* 0x23 KP Divide */
+	0x37,	/* 0x24 KP Multiply */			0x4a,	/* 0x25 KP Subtract */
+	0x0f,	/* 0x26 Tab */					0x10,	/* 0x27 Q */
+	0x11,	/* 0x28 W */					0x12,	/* 0x29 E */
+	0x13,	/* 0x2a R */					0x14,	/* 0x2b T */
+	0x15,	/* 0x2c Y */					0x16,	/* 0x2d U */
+	0x17,	/* 0x2e I */					0x18,	/* 0x2f O */
+	0x19,	/* 0x30 P */					0x1a,	/* 0x31 Left Bracket */
+	0x1b,	/* 0x32 Right Bracket */		0x2b,	/* 0x33 Backslash */
+	0xd3,	/* 0x34 Delete */				0xcf,	/* 0x35 End */
+	0xd1,	/* 0x36 Page Down */			0x47,	/* 0x37 KP 7 */
+	0x48,	/* 0x38 KP 8 */					0x49,	/* 0x39 KP 9 */
+	0x4e,	/* 0x3a KP Add */				0x3a,	/* 0x3b Caps Lock */
+	0x1e,	/* 0x3c A */					0x1f,	/* 0x3d S */
+	0x20,	/* 0x3e D */					0x21,	/* 0x3f F */
+	0x22,	/* 0x40 G */					0x23,	/* 0x41 H */
+	0x24,	/* 0x42 J */					0x25,	/* 0x43 K */
+	0x26,	/* 0x44 L */					0x27,	/* 0x45 Semicolon */
+	0x28,	/* 0x46 Single Quote */			0x1c,	/* 0x47 Enter */
+	0x4b,	/* 0x48 KP 4 */					0x4c,	/* 0x49 KP 5 */
+	0x4d,	/* 0x4a KP 6 */					0x2a,	/* 0x4b Left Shift */
+	0x2c,	/* 0x4c Z */					0x2d,	/* 0x4d X */
+	0x2e,	/* 0x4e C */					0x2f,	/* 0x4f V */
+	0x30,	/* 0x50 B */					0x31,	/* 0x51 N */
+	0x32,	/* 0x52 M */					0x33,	/* 0x53 Comma */
+	0x34,	/* 0x54 Period */				0x35,	/* 0x55 Slash */
+	0x36,	/* 0x56 Right Shift */			0xc8,	/* 0x57 Up */
+	0x4f,	/* 0x58 KP 1 */					0x50,	/* 0x59 KP 2 */
+	0x51,	/* 0x5a KP 3 */					0x9c,	/* 0x5b KP Enter */
+	0x1d,	/* 0x5c Left Control */			0x38,	/* 0x5d Left Alt */
+	0x39,	/* 0x5e Space */				0xb8,	/* 0x5f Right Alt */
+	0x9d,	/* 0x60 Right Control */		0xcb,	/* 0x61 Left */
+	0xd0,	/* 0x62 Down */					0xcd,	/* 0x63 Right */
+	0x52,	/* 0x64 KP 0 */					0x53,	/* 0x65 KP . */
+	0xdb,	/* 0x66 Left Windows */			0xdc,	/* 0x67 Right Windows */
+	0xdd,	/* 0x68 Menu */					0x56,	/* 0x69 */
+	0x7d,	/* 0x6a Macron */				0x73,	/* 0x6b Backslash */
+	0x7b,	/* 0x6c Muhenkan */				0x79,	/* 0x6d Henkan */
+	0x70,	/* 0x6e Hiragana Katakana */	0x00,	/* 0x6f */
+	0x00,	/* 0x70 */						0x00,	/* 0x71 */
+	0x00,	/* 0x72 */						0x00,	/* 0x73 */
+	0x00,	/* 0x74 */						0x00,	/* 0x75 */
+	0x00,	/* 0x76 */						0x00,	/* 0x77 */
+	0x00,	/* 0x78 */						0x00,	/* 0x79 */
+	0x00,	/* 0x7a */						0x00,	/* 0x7b */
+	0x00,	/* 0x7c */						0x00,	/* 0x7d */
+	0x54,	/* 0x7e Alt SysRq */			0xc6,	/* 0x7f Control Break */
+};
+
+
+int
+main(int argc, char **argv)
+{
+    for (int i = 1; i < argc; i++) {
+        if (strcmp(argv[i], "-nographic") == 0 ||
+            strcmp(argv[i], "-curses") == 0 ||
+            strcmp(argv[i], "-vnc") == 0) {
+        	return qemu_main(argc, argv, NULL);
+        }
+    }
+    QEMUApplication *app = new QEMUApplication(argc, argv);
+    app->Run();
+    delete app;
+    return 0;
+}
+
+
+QEMUApplication::QEMUApplication(int argc, char **argv)
+    :   BApplication("application/x-vnd.qemu.QEMU"),
+        fThread(0),
+        fWindow(NULL)
+{
+    gApplication = this;
+
+    fArgC = argc;
+    fArgV = argv;
+
+    fThread = spawn_thread(&RunQEMUMain, "qemu_main", B_LOW_PRIORITY, this);
+    resume_thread(fThread);
+}
+
+
+bool
+QEMUApplication::QuitRequested()
+{
+    qemu_system_shutdown_request();
+    return true;
+}
+
+
+void
+QEMUApplication::InitDisplay()
+{
+    fWindow = new QEMUWindow();
+    fWindow->Show();
+}
+
+
+int32
+QEMUApplication::RunQEMUMain(void *arg)
+{
+    QEMUApplication *app = (QEMUApplication *)arg;
+    qemu_main(app->fArgC, app->fArgV, NULL);
+    app->PostMessage(B_QUIT_REQUESTED);
+    return B_OK;
+}
+
+
+QEMUWindow::QEMUWindow()
+    :   BWindow(BRect(100, 100, 150, 150), "QEMU", B_TITLED_WINDOW,
+            B_QUIT_ON_WINDOW_CLOSE | B_NOT_RESIZABLE)
+{
+    gWindow = this;
+    fView = new QEMUView(Bounds());
+    AddChild(fView);
+    fView->MakeFocus();
+}
+
+
+QEMUView::QEMUView(BRect frame)
+    :   BView(frame, "fView", B_FOLLOW_ALL, B_WILL_DRAW),
+        fBitmap(NULL)
+{
+    gView = this;
+    fBitmap = new BBitmap(frame, 0, B_RGBA32);
+    AddFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, &MessageFilter));
+}
+
+
+QEMUView::~QEMUView()
+{
+    if (gFullScreen) {
+        BScreen().SetMode(&fDisplayMode);
+    }
+}
+
+
+void
+QEMUView::UpdateFullScreen()
+{
+    if (!gFullScreen) {
+        return;
+    }
+
+    BScreen screen;
+    display_mode current;
+    display_mode *modes;
+    display_mode *mode;
+    uint32 count;
+
+    screen.GetMode(&current);
+    screen.GetModeList(&modes, &count);
+
+    for (uint32 i = 0; i < count; i++) {
+        mode = &modes[i];
+        if (mode->virtual_width == gWidth
+            && mode->virtual_height == gHeight
+            && mode->space == current.space) {
+            screen.SetMode(mode);
+            break;
+        }
+    }
+
+    gWindow->MoveTo(0, 0);
+}
+
+
+void
+QEMUView::CenterMouse(bool &warp)
+{
+    BRect window = gWindow->Frame();
+    BPoint center = window.LeftTop() + gCenter;
+    set_mouse_position((int32)center.x, (int32)center.y);
+    warp = true;
+}
+
+
+void
+QEMUView::StartGrab(bool &grab)
+{
+    gApplication->HideCursor();
+    gWindow->SetTitle("QEMU - Press Ctrl-Alt to exit grab");
+    grab = true;
+}
+
+
+void
+QEMUView::EndGrab(bool &grab, int32 modifiers)
+{
+    gApplication->ShowCursor();
+    gWindow->SetTitle("QEMU");
+    grab = false;
+
+	// reset any set modifiers
+	if (modifiers & B_LEFT_SHIFT_KEY)
+		kbd_put_keycode(0xaa);
+	if (modifiers & B_RIGHT_SHIFT_KEY)
+		kbd_put_keycode(0xb6);
+
+	if (modifiers & B_LEFT_COMMAND_KEY)
+		kbd_put_keycode(0xb8);
+	if (modifiers & B_RIGHT_COMMAND_KEY) {
+		kbd_put_keycode(0xe0);
+		kbd_put_keycode(0xb8);
+	}
+
+	if (modifiers & B_LEFT_CONTROL_KEY)
+		kbd_put_keycode(0x9d);
+	if (modifiers & B_RIGHT_CONTROL_KEY) {
+		kbd_put_keycode(0xe0);
+		kbd_put_keycode(0x9d);
+	}
+
+	if (modifiers & B_LEFT_OPTION_KEY) {
+		kbd_put_keycode(0xe0);
+		kbd_put_keycode(0xdb);
+	}
+	if (modifiers & B_RIGHT_OPTION_KEY) {
+		kbd_put_keycode(0xe0);
+		kbd_put_keycode(0xdc);
+	}
+}
+
+
+filter_result
+QEMUView::MessageFilter(BMessage *message, BHandler **target,
+	BMessageFilter *filter)
+{
+	static bool sGrabInput = false;
+	static bool sMouseWarp = false;
+	static int32 sMouseButtons = 0;
+	bool keyDown = false;
+
+	switch (message->what) {
+		case B_KEY_DOWN:
+		case B_UNMAPPED_KEY_DOWN:
+			keyDown = true;
+			// fall
+
+		case B_KEY_UP:
+		case B_UNMAPPED_KEY_UP: {
+			int32 modifiers;
+			message->FindInt32("modifiers", &modifiers);
+
+			int32 key;
+			message->FindInt32("key", &key);
+			uint8 keycode = haiku_to_pc_key[(uint8)key];
+
+			int32 mask = (B_COMMAND_KEY | B_CONTROL_KEY);
+			if (!keyDown && sGrabInput && (modifiers & mask)
+				&& (key == 0x5d || key == 0x5c)) {
+					EndGrab(sGrabInput, modifiers);
+					return B_SKIP_MESSAGE;
+			}
+
+			if (keyDown && (modifiers & mask) == mask) {
+				switch (key) {
+					case 0x3f: { /* f - fullscreen */
+						BScreen screen;
+						if (!gFullScreen) {
+							screen.GetMode(&gView->fDisplayMode);
+							gWindow->MoveTo(0, 0);
+							gFullScreen = true;
+						} else {
+							screen.SetMode(&gView->fDisplayMode);
+							gWindow->MoveTo(gView->fWindowLocation);
+							gFullScreen = false;
+						}
+
+						UpdateFullScreen();
+						if (is_graphic_console()) {
+							vga_hw_invalidate();
+							vga_hw_update();
+						}
+
+						return B_SKIP_MESSAGE;
+					} break;
+
+					case 0x52: { /* m - pseudo fullscreen */
+						BPoint location = gWindow->Frame().LeftTop();
+						if (location.x == 0 && location.y == 0)
+							gWindow->MoveTo(gPreviousLocation);
+						else {
+							gPreviousLocation = location;
+							gWindow->MoveTo(0, 0);
+						}
+
+						if (is_graphic_console()) {
+							vga_hw_invalidate();
+							vga_hw_update();
+						}
+
+						return B_SKIP_MESSAGE;
+					} break;
+
+					case 0x12 ... 0x1a: { /* 1 to 9 - switch console */
+						console_select(key - 0x12);
+						if (is_graphic_console()) {
+							vga_hw_invalidate();
+							vga_hw_update();
+						}
+
+						return B_SKIP_MESSAGE;
+					} break;
+				}
+			} else if (!is_graphic_console()) {
+				if (!keyDown)
+					return B_SKIP_MESSAGE;
+
+				int32 rawChar;
+				message->FindInt32("raw_char", &rawChar);
+
+				int keysym = 0;
+				if (modifiers & (B_LEFT_CONTROL_KEY | B_RIGHT_CONTROL_KEY)) {
+					switch(rawChar) {
+						case B_UP_ARROW: keysym = QEMU_KEY_CTRL_UP; break;
+						case B_DOWN_ARROW: keysym = QEMU_KEY_CTRL_DOWN; break;
+						case B_LEFT_ARROW: keysym = QEMU_KEY_CTRL_LEFT; break;
+						case B_RIGHT_ARROW: keysym = QEMU_KEY_CTRL_RIGHT; break;
+						case B_HOME: keysym = QEMU_KEY_CTRL_HOME; break;
+						case B_END: keysym = QEMU_KEY_CTRL_END; break;
+						case B_PAGE_UP: keysym = QEMU_KEY_CTRL_PAGEUP; break;
+						case B_PAGE_DOWN: keysym = QEMU_KEY_CTRL_PAGEDOWN; break;
+					}
+				} else {
+					switch(rawChar) {
+						case B_UP_ARROW: keysym = QEMU_KEY_UP; break;
+						case B_DOWN_ARROW: keysym = QEMU_KEY_DOWN; break;
+						case B_LEFT_ARROW: keysym = QEMU_KEY_LEFT; break;
+						case B_RIGHT_ARROW: keysym = QEMU_KEY_RIGHT; break;
+						case B_HOME: keysym = QEMU_KEY_HOME; break;
+						case B_END: keysym = QEMU_KEY_END; break;
+						case B_PAGE_UP: keysym = QEMU_KEY_PAGEUP; break;
+						case B_PAGE_DOWN: keysym = QEMU_KEY_PAGEDOWN; break;
+						case B_BACKSPACE: keysym = QEMU_KEY_BACKSPACE; break;
+						case B_DELETE: keysym = QEMU_KEY_DELETE; break;
+					}
+				}
+
+				if (keysym)
+					kbd_put_keysym(keysym);
+				else {
+					const char *bytes;
+					if (message->FindString("bytes", &bytes) == B_OK && bytes[0] != 0)
+						kbd_put_keysym(bytes[0]);
+				}
+				return B_SKIP_MESSAGE;
+			}
+
+			if (keycode & 0x80)
+				kbd_put_keycode(0xe0);
+
+			if (keyDown)
+				kbd_put_keycode(keycode & 0x7f);
+			else
+				kbd_put_keycode(keycode | 0x80);
+
+			return B_SKIP_MESSAGE;
+		} break;
+
+		case B_MOUSE_MOVED: {
+			if (!sGrabInput)
+				break;
+
+			if (sMouseWarp) {
+				sMouseWarp = false;
+				return B_SKIP_MESSAGE;
+			}
+
+			BPoint where;
+			message->FindPoint("where", &where);
+			BPoint delta = where - gCenter;
+
+			// Haiku buttons are the same as QEMU
+			kbd_mouse_event((int)delta.x, (int)delta.y, 0, sMouseButtons);
+
+			CenterMouse(sMouseWarp);
+			return B_SKIP_MESSAGE;
+		} break;
+
+		case B_MOUSE_DOWN:
+		case B_MOUSE_UP: {
+			int32 buttons;
+			message->FindInt32("buttons", &buttons);
+
+			if (!sGrabInput) {
+				if (message->what == B_MOUSE_DOWN
+					&& (buttons & B_PRIMARY_MOUSE_BUTTON)) {
+					CenterMouse(sMouseWarp);
+					StartGrab(sGrabInput);
+				}
+				break;
+			}
+
+			sMouseButtons = buttons;
+			// Haiku buttons are the same as QEMU
+			kbd_mouse_event(0, 0, 0, sMouseButtons);
+			return B_SKIP_MESSAGE;
+		} break;
+
+		case B_MOUSE_WHEEL_CHANGED: {
+			if (!sGrabInput)
+				break;
+
+			float delta;
+			message->FindFloat("be:wheel_delta_y", &delta);
+			kbd_mouse_event(0, 0, (int)delta, sMouseButtons);
+			return B_SKIP_MESSAGE;
+		} break;
+	}
+
+	return B_DISPATCH_MESSAGE;
+}
+
+
+void
+QEMUView::Update(BPoint point, int width, int height)
+{
+    LockLooper();
+    fBitmap->ImportBits(fFrameBuffer, fFrameBufferSize, fBytesPerRow,
+        fColorSpace, point, point, width, height);
+
+    Draw(BRect(point.x, point.y, point.x + width, point.y + height));
+    UnlockLooper();
+}
+
+
+void
+QEMUView::Draw(BRect updateRect)
+{
+    if (fBitmap == NULL) {
+        return;
+    }
+
+    DrawBitmap(fBitmap, updateRect, updateRect);
+}
+
+
+void
+QEMUView::UpdateFrameBuffer(int width, int height, uchar *bits,
+	int bytesPerRow, int bitsPerPixel)
+{
+	if (LockLooper()) {
+		delete fBitmap;
+		fBitmap = new BBitmap(BRect(0, 0, width - 1, height - 1), 0, B_RGBA32);
+		fFrameBuffer = bits;
+		fFrameBufferSize = bytesPerRow * height;
+		fBytesPerRow = bytesPerRow;
+
+		switch (bitsPerPixel) {
+			case 32:
+				fColorSpace = B_RGB32;
+				break;
+			case 24:
+				fColorSpace = B_RGB24;
+				break;
+			case 16:
+				fColorSpace = B_RGB16;
+				break;
+			case 15:
+				fColorSpace = B_RGB15;
+				break;
+			case 8:
+				fColorSpace = B_CMAP8;
+				break;
+			default:
+				printf("unsupported display depth %d\n", bitsPerPixel);
+				break;
+		}
+
+		UnlockLooper();
+	}
+}
+
+
+// QEMU C interface
+extern "C" {
+
+static void haiku_update(DisplayState *ds, int x, int y, int w, int h);
+static void haiku_resize(DisplayState *ds);
+static void haiku_refresh(DisplayState *ds);
+
+};
+
+
+static void
+haiku_update(DisplayState *ds, int x, int y, int w, int h)
+{
+    //printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
+    gView->Update(BPoint(x, y), w, h);
+}
+
+
+static void
+haiku_resize(DisplayState *ds)
+{
+    //printf("resizing\n");
+    gWidth = ds_get_width(ds);
+    gHeight = ds_get_height(ds);
+    gCenter.x = (int32)(gWidth / 2);
+    gCenter.y = (int32)(gHeight / 2);
+    gWindow->ResizeTo(gWidth - 1, gHeight - 1);
+    gWindow->SetZoomLimits(gWidth, gHeight);
+    gView->UpdateFrameBuffer(ds_get_width(ds), ds_get_height(ds),
+        ds_get_data(ds), ds_get_linesize(ds), ds_get_bits_per_pixel(ds));
+    gView->UpdateFullScreen();
+}
+
+
+static void
+haiku_refresh(DisplayState *ds)
+{
+    //printf("refreshing\n");
+    if (is_graphic_console()) {
+        vga_hw_update();
+    }
+}
+
+
+void
+haiku_display_init(DisplayState *ds, int fullScreen)
+{
+    gApplication->InitDisplay();
+    gFullScreen = fullScreen != 0;
+
+    DisplayChangeListener *displayChangeListener
+        = (DisplayChangeListener *)qemu_mallocz(sizeof(DisplayChangeListener));
+    displayChangeListener->dpy_update = haiku_update;
+    displayChangeListener->dpy_resize = haiku_resize;
+    displayChangeListener->dpy_refresh = haiku_refresh;
+    register_displaychangelistener(ds, displayChangeListener);
+}
diff --git a/ui/haiku.h b/ui/haiku.h
new file mode 100644
index 0000000..2c342d2
--- /dev/null
+++ b/ui/haiku.h
@@ -0,0 +1,96 @@
+/*
+ * QEMU Haiku display driver
+ * 
+ * Copyright (c) 2005-2009 Michael Lotz
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef _HAIKU_H_
+#define _HAIKU_H_
+
+#include <Accelerant.h>
+#include <Application.h>
+#include <Bitmap.h>
+#include <MessageFilter.h>
+#include <View.h>
+#include <Window.h>
+
+class QEMUWindow;
+class QEMUView;
+
+class QEMUApplication : public BApplication {
+public:
+							QEMUApplication(int argc, char **argv);
+
+virtual	bool				QuitRequested();
+		void				InitDisplay();
+
+private:
+static	int32				RunQEMUMain(void *arg);
+
+		int					fArgC;
+		char **				fArgV;
+
+		thread_id			fThread;
+		QEMUWindow *		fWindow;
+};
+
+
+class QEMUWindow : public BWindow {
+public:
+							QEMUWindow();
+
+private:
+		QEMUView *			fView;
+};
+
+
+class QEMUView : public BView {
+public:
+							QEMUView(BRect frame);
+virtual						~QEMUView();
+
+		void				Update(BPoint point, int width, int height);
+virtual	void				Draw(BRect updateRect);
+
+		void				UpdateFrameBuffer(int width, int height,
+								uchar *bits, int bytesPerRow,
+								int bitsPerPixel);
+
+static	void				UpdateFullScreen();
+static	void				CenterMouse(bool &warp);
+static	void				StartGrab(bool &grab);
+static	void				EndGrab(bool &grab, int32 modifiers);
+
+private:
+static	filter_result		MessageFilter(BMessage *message, BHandler **target,
+								BMessageFilter *filter);
+
+		BBitmap *			fBitmap;
+		BPoint				fWindowLocation;
+		display_mode		fDisplayMode;
+
+		uint8 *				fFrameBuffer;
+		uint32				fFrameBufferSize;
+		uint32				fBytesPerRow;
+		color_space			fColorSpace;
+};
+
+#endif
diff --git a/vl.c b/vl.c
index d352d18..7641763 100644
--- a/vl.c
+++ b/vl.c
@@ -1799,6 +1799,10 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
     return popt;
 }
 
+#ifdef CONFIG_HAIKU
+#define main qemu_main
+#endif
+
 int main(int argc, char **argv, char **envp)
 {
     const char *gdbstub_dev = NULL;
@@ -2919,7 +2923,7 @@ int main(int argc, char **argv, char **envp)
     ds = get_displaystate();
 
     if (display_type == DT_DEFAULT) {
-#if defined(CONFIG_SDL) || defined(CONFIG_COCOA)
+#if defined(CONFIG_SDL) || defined(CONFIG_COCOA) || defined(CONFIG_HAIKU)
         display_type = DT_SDL;
 #else
         display_type = DT_VNC;
@@ -2945,6 +2949,10 @@ int main(int argc, char **argv, char **envp)
     case DT_SDL:
         cocoa_display_init(ds, full_screen);
         break;
+#elif defined(CONFIG_HAIKU)
+    case DT_SDL:
+        haiku_display_init(ds, full_screen);
+        break;
 #endif
     case DT_VNC:
         vnc_display_init(ds);
-- 
1.7.1.rc2.7.g3e7f1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB
  2010-09-19 22:50               ` [Qemu-devel] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Andreas Färber
  2010-09-19 22:50                 ` [Qemu-devel] [FYI 8/8] ui: Haiku frontend Andreas Färber
@ 2010-09-20 12:26                 ` Oliver Tappe
  2010-09-21 22:29                   ` Andreas Färber
  1 sibling, 1 reply; 21+ messages in thread
From: Oliver Tappe @ 2010-09-20 12:26 UTC (permalink / raw)
  To: HaikuPorts developers discussion list
  Cc: Andreas Färber, Michael Lotz, qemu-devel

Hi Andreas,

On 2010-09-20 at 00:50:49 [+0200], Andreas Färber <andreas.faerber@web.de> wrote:
> Works around a calloc() SEGV in Haiku's libroot.
> Cf. http://dev.haiku-os.org/ticket/6637
> 
> Ported to HEAD based on a patch by Michael "mmlr" Lotz.
> Also consider the limit when reallocating.

Were you able to run any image in qemu on haiku with this? 

I'm asking because of haiku ticket #6606, which is about some problematic behaviour 
with respect to qemu not being able to resize an area (in effect aborting). Looking at 
the patch, I'd say it should still do the same ...

cheers,
	Oliver

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support
  2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
  2010-09-19 22:50   ` [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku Andreas Färber
@ 2010-09-20 19:04   ` Ingo Weinhold
  2010-09-21 20:54     ` Andreas Färber
  2010-10-03  7:47   ` [Qemu-devel] " Blue Swirl
  2 siblings, 1 reply; 21+ messages in thread
From: Ingo Weinhold @ 2010-09-20 19:04 UTC (permalink / raw)
  To: HaikuPorts developers discussion list; +Cc: Andreas Färber, qemu-devel


On 2010-09-20 at 00:50:42 [+0200], Andreas Färber <andreas.faerber@web.de> wrote:
> The following patch series together with qemu_madvise() allows to build and
> run QEMU on Haiku, using GCC 4.x.
> 
> Patches 1-5 add support for Haiku hosts to build ppc-softmmu.
> They are based on qemu_madvise() v7, since Haiku does not have madvise(),
> but they do not depend on it themselves so could be cherry-picked.

I didn't spot anything related to madvise() in any of the patches. Anyway, Haiku does 
have posix_madvise(), which, unlike madvise(), is part of POSIX.

CU, Ingo

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support
  2010-09-20 19:04   ` [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support Ingo Weinhold
@ 2010-09-21 20:54     ` Andreas Färber
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Färber @ 2010-09-21 20:54 UTC (permalink / raw)
  To: HaikuPorts developers discussion list; +Cc: qemu-devel

Am 20.09.2010 um 21:04 schrieb Ingo Weinhold:

> On 2010-09-20 at 00:50:42 [+0200], Andreas Färber <andreas.faerber@web.de 
> > wrote:
>> The following patch series together with qemu_madvise() allows to  
>> build and
>> run QEMU on Haiku, using GCC 4.x.
>>
>> Patches 1-5 add support for Haiku hosts to build ppc-softmmu.
>> They are based on qemu_madvise() v7, since Haiku does not have  
>> madvise(),
>> but they do not depend on it themselves so could be cherry-picked.
>
> I didn't spot anything related to madvise() in any of the patches.

My saying. :)

> Anyway, Haiku does
> have posix_madvise(), which, unlike madvise(), is part of POSIX.

...which is exactly what qemu_madvise() takes care of, using a  
configure check.

http://repo.or.cz/w/qemu/afaerber.git/commit/e88131d2177cf12dba99c13fe5ff6a21d8fb7dc1

Unfortunately posix_madvise() doesn't supply us with the full spectrum  
of advice flags KVM needs, so we can't prefer it over madvise()  
despite being part of POSIX.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB
  2010-09-20 12:26                 ` [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Oliver Tappe
@ 2010-09-21 22:29                   ` Andreas Färber
  0 siblings, 0 replies; 21+ messages in thread
From: Andreas Färber @ 2010-09-21 22:29 UTC (permalink / raw)
  To: HaikuPorts developers discussion list; +Cc: Michael Lotz, qemu-devel

Hi,

Am 20.09.2010 um 14:26 schrieb Oliver Tappe:

> On 2010-09-20 at 00:50:49 [+0200], Andreas Färber <andreas.faerber@web.de 
> > wrote:
>> Works around a calloc() SEGV in Haiku's libroot.
>> Cf. http://dev.haiku-os.org/ticket/6637
>>
>> Ported to HEAD based on a patch by Michael "mmlr" Lotz.
>> Also consider the limit when reallocating.
>
> Were you able to run any image in qemu on haiku with this?

As indicated, I built the ppc-softmmu system emulation. I was able to  
both play around in OpenBIOS [1] and to try booting Haiku/ppc [2],  
which doesn't go far due to OpenBIOS ofmem issues (cf. #6071).

i386-softmmu needs more patches to compile. Haiku's math.h is missing  
some POSIX macros like isless[equal], isgreater, isunordered. That  
should be fixed in Haiku imo instead of being worked around in QEMU.  
QEMU's softfloat code has a wild mix of int32 and int though that may  
need to be remedied then, I have a patch in preparation for that.

[1] qemu-system-ppc /dev/null
[2] qemu-system-ppc -boot d -cdrom path/to/haiku-boot-cd-ppc.iso

> I'm asking because of haiku ticket #6606, which is about some  
> problematic behaviour
> with respect to qemu not being able to resize an area (in effect  
> aborting). Looking at
> the patch, I'd say it should still do the same ...

I had taken a look at #6606 and tried
LD_PRELOAD=libroot-icu-addon.so qemu-system-ppc /dev/null -nographic
without any luck.

Note that vanilla QEMU does not use any areas at all, it uses  
malloc(), calloc(), realloc() and free().
The areas were just a workaround my mmlr and, to not miscredit him, he  
had the following explanation in his patch:

+/*
+ The reason for the following mess is that somehow large allocations  
seem
+ to cause memory curruption. Most likely this is a bug in either  
Haiku or
+ QEMU. Since I wasn't able to repoduce the issue with other Haiku  
software
+ my first guess would go to QEMU, but who knows. In any case the hack  
below
+ makes larger allocations (>= 1MB) using areas instead of using the  
heap
+ to work around said issue. TODO: remove this when the reason is  
found/fixed!
+*/

(I personally rather believe it's a bug in Haiku and that most BeOS/ 
Haiku apps don't encounter it since they use C++ new/new[]/delete/ 
delete[] but no realloc. But no one knows for sure until we've found  
out.)

As seen in this patch of mine, QEMU has a new tracing framework that  
should (once it compiles - Haiku doesn't have clock_gettime) show us  
all successful (re)allocations and a build configured with --disable- 
strip shows us the crashing calloc args in gdb, so we could exactly  
reproduce the allocations and find out if that triggers it or not.

Andreas

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [Qemu-devel] [PATCH 0/8] Add Haiku host support
  2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
  2010-09-19 22:50   ` [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku Andreas Färber
  2010-09-20 19:04   ` [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support Ingo Weinhold
@ 2010-10-03  7:47   ` Blue Swirl
  2 siblings, 0 replies; 21+ messages in thread
From: Blue Swirl @ 2010-10-03  7:47 UTC (permalink / raw)
  To: Andreas Färber; +Cc: haikuports-devs, qemu-devel

Thanks, applied 1 to 6.

On Sun, Sep 19, 2010 at 10:50 PM, Andreas Färber <andreas.faerber@web.de> wrote:
> Hello,
>
> The following patch series together with qemu_madvise() allows to build and
> run QEMU on Haiku, using GCC 4.x.
>
> Patches 1-5 add support for Haiku hosts to build ppc-softmmu.
> They are based on qemu_madvise() v7, since Haiku does not have madvise(),
> but they do not depend on it themselves so could be cherry-picked.
>
> Patch 6 fixes a build warning.
>
> The following patches are based on mmlr's 0.10.4 port and are not intended
> for upstream inclusion at this time:
>
> Patch 7 is needed for successful runtime execution.
>
> Patch 8 is included as a test case and to show where things are moving wrt C++.
>
> Not yet included is his native Haiku audio backend, also using C++.
>
> Another issue that Michael had addressed and that I would like to see fixed
> differently is a mismatch between softfloat headers and sources wrt int types.
> I'll post a separate RFC since it's not strictly related to Haiku.
>
> Regards,
> Andreas
>
> Andreas Färber (8):
>  configure: Add basic support for Haiku
>  configure: Don't rely on special pthreads library
>  Haiku doesn't have libm
>  nbd: Haiku has _IO() in its BSD compatibility layer
>  tap: Add stub for Haiku
>  slirp: Silence warning on Haiku
>  qemu_malloc: Use areas on Haiku for sizes > 1 MiB
>  ui: Haiku frontend
>
>  Makefile        |    2 +
>  Makefile.objs   |    2 +
>  Makefile.target |    2 +
>  configure       |   33 +++-
>  console.h       |    3 +
>  nbd.c           |    2 +-
>  net/tap-haiku.c |   61 ++++++
>  qemu-malloc.c   |   53 +++++
>  rules.mak       |    6 +-
>  slirp/slirp.h   |    4 +-
>  ui/haiku.cpp    |  607 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  ui/haiku.h      |   96 +++++++++
>  vl.c            |   10 +-
>  13 files changed, 869 insertions(+), 12 deletions(-)
>  create mode 100644 net/tap-haiku.c
>  create mode 100644 ui/haiku.cpp
>  create mode 100644 ui/haiku.h
>
>
>

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-10-03  7:47 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-18 13:46 [Qemu-devel] Native Port of QEMU to Haiku Michael Lotz
2009-05-19  8:32 ` Stefan Weil
2009-05-19  8:48 ` Avi Kivity
2009-05-19 12:56 ` Anthony Liguori
2009-05-19 13:54 ` François Revol
2009-05-19 16:56   ` Andreas Färber
2009-05-21  1:04     ` Ingo Weinhold
2010-09-19 22:50 ` [Qemu-devel] [PATCH 0/8] Add Haiku host support Andreas Färber
2010-09-19 22:50   ` [Qemu-devel] [PATCH 1/8] configure: Add basic support for Haiku Andreas Färber
2010-09-19 22:50     ` [Qemu-devel] [PATCH 2/8] configure: Don't rely on special pthreads library Andreas Färber
2010-09-19 22:50       ` [Qemu-devel] [PATCH 3/8] Haiku doesn't have libm Andreas Färber
2010-09-19 22:50         ` [Qemu-devel] [PATCH 4/8] nbd: Haiku has _IO() in its BSD compatibility layer Andreas Färber
2010-09-19 22:50           ` [Qemu-devel] [PATCH 5/8] tap: Add stub for Haiku Andreas Färber
2010-09-19 22:50             ` [Qemu-devel] [PATCH 6/8] slirp: Silence warning on Haiku Andreas Färber
2010-09-19 22:50               ` [Qemu-devel] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Andreas Färber
2010-09-19 22:50                 ` [Qemu-devel] [FYI 8/8] ui: Haiku frontend Andreas Färber
2010-09-20 12:26                 ` [Qemu-devel] Re: [HaikuPorts-devs] [FYI 7/8] qemu_malloc: Use areas on Haiku for sizes > 1 MiB Oliver Tappe
2010-09-21 22:29                   ` Andreas Färber
2010-09-20 19:04   ` [Qemu-devel] Re: [HaikuPorts-devs] [PATCH 0/8] Add Haiku host support Ingo Weinhold
2010-09-21 20:54     ` Andreas Färber
2010-10-03  7:47   ` [Qemu-devel] " Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).