Index: Makefile =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/Makefile,v retrieving revision 1.99 diff -u -p -r1.99 Makefile --- Makefile 5 Jan 2009 19:43:58 -0000 1.99 +++ Makefile 18 Jan 2009 17:45:41 -0000 @@ -6,15 +6,15 @@ # PORTNAME= qemu -PORTVERSION= 0.9.1s.20080620 -PORTREVISION= 3 +PORTVERSION= 0.9.1s.20090118 CATEGORIES= emulators MASTER_SITES= http://bellard.org/qemu/:release \ http://qemu-forum.ipi.fi/qemu-snapshots/:snapshot \ http://people.fruitsalad.org/nox/qemu/:snapshot \ - ${MASTER_SITE_LOCAL}:snapshot + ${MASTER_SITE_LOCAL}:snapshot \ + http://people.freebsd.org/~nox/qemu/:snapshot PKGNAMESUFFIX= -devel -DISTNAME= ${PORTNAME}-snapshot-2008-06-20_19 +DISTNAME= ${PORTNAME}-snapshot-2009-01-18_18 DISTFILES= ${DISTNAME}${EXTRACT_SUFX}:snapshot DIST_SUBDIR= qemu EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} @@ -39,18 +39,10 @@ OPTIONS= KQEMU "Build with (alpha!) acce GNUTLS "gnutls dependency (vnc encryption)" On \ PCAP "pcap dependency (networking with bpf)" On \ CDROM_DMA "IDE CDROM DMA" On \ - ALL_TARGETS "Also build dyngen targets (requires gcc34)" On + ADD_AUDIO "Emulate more audio hardware (experimental!)" Off .include -.if defined(WITHOUT_ALL_TARGETS) -CONFIGURE_ARGS+= --disable-gcc-check --target-list=i386-softmmu,sparc-softmmu,x86_64-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu,arm-softmmu,m68k-softmmu,cris-softmmu -PLIST_SUB+= DYNGEN="@comment " -.else -USE_GCC= 3.4 -PLIST_SUB+= DYNGEN="" -.endif - WITHOUT_CPU_CFLAGS=yes #to avoid problems with register allocation CFLAGS:= ${CFLAGS:C/-fno-tree-vrp//} CONFIGURE_ARGS+= --prefix=${PREFIX} --cc=${CC} @@ -71,6 +63,10 @@ LIB_DEPENDS+= gnutls:${PORTSDIR}/securit CONFIGURE_ARGS+= --enable-pcap .endif +.if defined(WITH_ADD_AUDIO) +CONFIGURE_ARGS+= --audio-card-list=ac97,adlib,cs4231a,gus +.endif + .if defined(WITH_SAMBA) RUN_DEPENDS+= ${LOCALBASE}/sbin/smbd:${PORTSDIR}/net/samba3 .endif Index: distinfo =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/distinfo,v retrieving revision 1.50 diff -u -p -r1.50 distinfo --- distinfo 8 Jul 2008 18:42:08 -0000 1.50 +++ distinfo 18 Jan 2009 17:45:59 -0000 @@ -1,3 +1,3 @@ -MD5 (qemu/qemu-snapshot-2008-06-20_19.tar.bz2) = 7201553586b59e400664b2f9ae0b17a1 -SHA256 (qemu/qemu-snapshot-2008-06-20_19.tar.bz2) = e9a3654976b923c471f572961f244f2758d15a367cfc1b32054aa2cd4391cace -SIZE (qemu/qemu-snapshot-2008-06-20_19.tar.bz2) = 2629290 +MD5 (qemu/qemu-snapshot-2009-01-18_18.tar.bz2) = 1ffc6b9b279e0361229d7585dc36a757 +SHA256 (qemu/qemu-snapshot-2009-01-18_18.tar.bz2) = 925a94fb7d20bef4406aa84f09f6f83ced73603aaacf4af3dd57b70d22f1409b +SIZE (qemu/qemu-snapshot-2009-01-18_18.tar.bz2) = 2952134 Index: pkg-plist =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/pkg-plist,v retrieving revision 1.25 diff -u -p -r1.25 pkg-plist --- pkg-plist 8 Jul 2008 18:42:08 -0000 1.25 +++ pkg-plist 18 Jan 2009 20:27:02 -0000 @@ -1,5 +1,6 @@ bin/qemu bin/qemu-img +bin/qemu-sparc64 bin/qemu-system-arm bin/qemu-system-cris bin/qemu-system-m68k @@ -7,11 +8,11 @@ bin/qemu-system-mips bin/qemu-system-mips64 bin/qemu-system-mips64el bin/qemu-system-mipsel -%%DYNGEN%%bin/qemu-system-ppc -%%DYNGEN%%bin/qemu-system-ppc64 -%%DYNGEN%%bin/qemu-system-ppcemb -%%DYNGEN%%bin/qemu-system-sh4 -%%DYNGEN%%bin/qemu-system-sh4eb +bin/qemu-system-ppc +bin/qemu-system-ppc64 +bin/qemu-system-ppcemb +bin/qemu-system-sh4 +bin/qemu-system-sh4eb bin/qemu-system-sparc bin/qemu-system-x86_64 @unexec if cmp -s %D/etc/qemu-ifup.sample %D/etc/qemu-ifup; then rm -f %D/etc/qemu-ifup; fi @@ -27,12 +28,15 @@ etc/qemu-ifdown.sample %%DATADIR%%/vgabios.bin %%DATADIR%%/vgabios-cirrus.bin %%DATADIR%%/ppc_rom.bin +%%DATADIR%%/openbios-ppc %%DATADIR%%/openbios-sparc32 %%DATADIR%%/openbios-sparc64 %%DATADIR%%/video.x +%%DATADIR%%/pxe-e1000.bin %%DATADIR%%/pxe-ne2k_pci.bin %%DATADIR%%/pxe-rtl8139.bin %%DATADIR%%/pxe-pcnet.bin +%%DATADIR%%/bamboo.dtb %%DATADIR%%/keymaps/ar %%DATADIR%%/keymaps/common %%DATADIR%%/keymaps/da Index: files/patch-90_security =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-90_security,v retrieving revision 1.5 diff -u -p -r1.5 patch-90_security --- files/patch-90_security 8 Jul 2008 18:42:09 -0000 1.5 +++ files/patch-90_security 18 Jan 2009 17:25:27 -0000 @@ -80,45 +80,7 @@ Index: qemu-0.8.2/hw/sb16.c } return dma_pos; -Index: qemu-0.8.2/slirp/slirp.c -=================================================================== ---- qemu-0.8.2.orig/slirp/slirp.c 2006-07-22 20:23:34.000000000 +0300 -+++ qemu-0.8.2/slirp/slirp.c 2007-04-20 06:05:59.000000000 +0300 -@@ -611,6 +611,10 @@ void slirp_input(const uint8_t *pkt, int - if (!m) - return; - /* Note: we add to align the IP header */ -+ /* taviso: large values in ne2k TCNT register may exceed msize on transmit */ -+ if (M_FREEROOM(m) < pkt_len + 2) { -+ m_inc(m, pkt_len + 2); -+ } - m->m_len = pkt_len + 2; - memcpy(m->m_data + 2, pkt, pkt_len); - -Index: qemu-0.8.2/target-i386/translate.c -=================================================================== ---- qemu-0.8.2.orig/target-i386/translate.c 2006-07-22 20:23:34.000000000 +0300 -+++ qemu-0.8.2/target-i386/translate.c 2007-04-20 06:05:59.000000000 +0300 -@@ -5292,6 +5297,7 @@ static target_ulong disas_insn(DisasCont - gen_jmp_im(pc_start - s->cs_base); - gen_op_into(s->pc - pc_start); - break; -+#ifdef WANT_ICEBP - case 0xf1: /* icebp (undocumented, exits to external debugger) */ - #if 1 - gen_debug(s, pc_start - s->cs_base); -@@ -5301,6 +5307,7 @@ static target_ulong disas_insn(DisasCont - cpu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM); - #endif - break; -+#endif /* icebp */ - case 0xfa: /* cli */ - if (!s->vm86) { - if (s->cpl <= s->iopl) { -Index: qemu-0.8.2/vl.c -=================================================================== ---- qemu-0.8.2.orig/vl.c 2007-04-20 06:05:59.000000000 +0300 -+++ qemu-0.8.2/vl.c 2007-04-20 06:05:59.000000000 +0300 +Index: qemu-0.8.2/net.c @@ -3139,8 +3139,8 @@ typedef struct NetSocketState { VLANClientState *vc; int fd; @@ -157,23 +119,6 @@ Index: qemu-0.8.2/vl.c s->index += l; buf += l; size -= l; -Index: qemu/block.c -@@ -539,8 +539,15 @@ - return -ENOMEDIUM; - if (bs->read_only) - return -EACCES; -+ if (sector_num < 0) -+ return -EACCES; - if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { - memcpy(bs->boot_sector_data, buf, 512); -+ } -+ { -+ unsigned int ns = sector_num * 512; -+ if (ns < 0) -+ return -EACCES; - } - if (drv->bdrv_pwrite) { - int ret, len; Index: qemu/hw/i8259.c @@ -302,7 +302,8 @@ s->init4 = val & 1; Index: files/patch-CVE-2008-0928 =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-CVE-2008-0928,v retrieving revision 1.2 diff -u -p -r1.2 patch-CVE-2008-0928 --- files/patch-CVE-2008-0928 4 Dec 2008 22:36:46 -0000 1.2 +++ files/patch-CVE-2008-0928 18 Jan 2009 17:49:44 -0000 @@ -16,17 +16,10 @@ diff -u -p -u -p -r1.15 -r1.16 return ret; if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header)) Index: qemu/block-qcow2.c -=================================================================== -RCS file: /sources/qemu/qemu/block-qcow2.c,v -retrieving revision 1.10 -retrieving revision 1.11 -diff -u -p -u -p -r1.10 -r1.11 ---- block-qcow2.c 11 Nov 2007 02:51:16 -0000 1.10 -+++ block-qcow2.c 11 Mar 2008 17:17:58 -0000 1.11 -@@ -191,7 +191,7 @@ static int qcow_open(BlockDriverState *b - int len, i, shift, ret; - QCowHeader header; - +@@ -197,7 +197,7 @@ static int qcow_open(BlockDriverState *b + flags |= BDRV_O_CACHE_WB; + flags &= ~BDRV_O_CACHE_DEF; + } - ret = bdrv_file_open(&s->hd, filename, flags); + ret = bdrv_file_open(&s->hd, filename, flags | BDRV_O_AUTOGROW); if (ret < 0) @@ -49,18 +42,27 @@ diff -u -p -u -p -r1.19 -r1.20 if (ret < 0) return ret; if (bdrv_pread(s->hd, 0, &magic, sizeof(magic)) != sizeof(magic)) -Index: qemu/block.c -@@ -24,6 +24,9 @@ - #include "qemu-common.h" - #ifndef QEMU_IMG - #include "console.h" -+extern int vm_running; -+#else +Index: qemu/qemu-img.c +@@ -34,6 +34,8 @@ + /* Default to cache=writeback as data integrity is not important for qemu-tcg. */ + #define BRDV_O_FLAGS BDRV_O_CACHE_WB + +int vm_running = 0; - #endif - #include "block_int.h" ++ + static void noreturn error(const char *fmt, ...) + { + va_list ap; +Index: qemu/block.c +@@ -36,6 +36,8 @@ + #define SECTOR_BITS 9 + #define SECTOR_SIZE (1 << SECTOR_BITS) -@@ -124,6 +128,75 @@ ++extern int vm_running; ++ + typedef struct BlockDriverAIOCBSync { + BlockDriverAIOCB common; + QEMUBH *bh; +@@ -122,6 +122,75 @@ void path_combine(char *dest, int dest_s } } @@ -136,7 +138,7 @@ Index: qemu/block.c static void bdrv_register(BlockDriver *bdrv) { -@@ -335,6 +389,10 @@ int bdrv_open2(BlockDriverState *bs, con +@@ -334,6 +388,10 @@ int bdrv_open2(BlockDriverState *bs, con bs->read_only = 0; bs->is_temporary = 0; bs->encrypted = 0; @@ -147,7 +149,7 @@ Index: qemu/block.c if (flags & BDRV_O_SNAPSHOT) { BlockDriverState *bs1; -@@ -379,6 +437,7 @@ int bdrv_open2(BlockDriverState *bs, con +@@ -390,6 +448,7 @@ int bdrv_open2(BlockDriverState *bs, con } bs->drv = drv; bs->opaque = qemu_mallocz(drv->instance_size); @@ -155,7 +157,7 @@ Index: qemu/block.c if (bs->opaque == NULL && drv->instance_size > 0) return -1; /* Note: for compatibility, we open disk image files as RDWR, and -@@ -444,6 +503,7 @@ void bdrv_close(BlockDriverState *bs) +@@ -455,6 +514,7 @@ void bdrv_close(BlockDriverState *bs) bs->drv = NULL; /* call the change callback */ @@ -163,25 +165,25 @@ Index: qemu/block.c bs->media_changed = 1; if (bs->change_cb) bs->change_cb(bs->change_opaque); -@@ -509,6 +569,8 @@ int bdrv_read(BlockDriverState *bs, int6 +@@ -527,6 +587,8 @@ int bdrv_read(BlockDriverState *bs, int6 if (!drv) return -ENOMEDIUM; + if (bdrv_rd_badreq_sectors(bs, sector_num, nb_sectors)) + return -EDOM; - if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { - memcpy(buf, bs->boot_sector_data, 512); - sector_num++; -@@ -549,6 +611,8 @@ int bdrv_write(BlockDriverState *bs, int + if (drv->bdrv_pread) { + int ret, len; + len = nb_sectors * 512; +@@ -559,6 +621,8 @@ int bdrv_write(BlockDriverState *bs, int return -ENOMEDIUM; if (bs->read_only) return -EACCES; + if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors)) + return -EDOM; - if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { - memcpy(bs->boot_sector_data, buf, 512); - } -@@ -674,6 +738,8 @@ int bdrv_pread(BlockDriverState *bs, int + if (drv->bdrv_pwrite) { + int ret, len; + len = nb_sectors * 512; +@@ -681,6 +745,8 @@ int bdrv_pread(BlockDriverState *bs, int return -ENOMEDIUM; if (!drv->bdrv_pread) return bdrv_pread_em(bs, offset, buf1, count1); @@ -190,7 +192,7 @@ Index: qemu/block.c return drv->bdrv_pread(bs, offset, buf1, count1); } -@@ -689,6 +755,8 @@ int bdrv_pwrite(BlockDriverState *bs, in +@@ -696,6 +762,8 @@ int bdrv_pwrite(BlockDriverState *bs, in return -ENOMEDIUM; if (!drv->bdrv_pwrite) return bdrv_pwrite_em(bs, offset, buf1, count1); @@ -199,7 +201,7 @@ Index: qemu/block.c return drv->bdrv_pwrite(bs, offset, buf1, count1); } -@@ -955,6 +1023,8 @@ int bdrv_write_compressed(BlockDriverSta +@@ -987,6 +1055,8 @@ int bdrv_write_compressed(BlockDriverSta return -ENOMEDIUM; if (!drv->bdrv_write_compressed) return -ENOTSUP; @@ -208,40 +210,34 @@ Index: qemu/block.c return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors); } -@@ -1101,6 +1171,8 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDri +@@ -1133,6 +1203,8 @@ BlockDriverAIOCB *bdrv_aio_read(BlockDri if (!drv) return NULL; + if (bdrv_rd_badreq_sectors(bs, sector_num, nb_sectors)) + return NULL; - /* XXX: we assume that nb_sectors == 0 is suppored by the async read */ - if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { -@@ -1132,6 +1204,8 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr + ret = drv->bdrv_aio_read(bs, sector_num, buf, nb_sectors, cb, opaque); + +@@ -1156,6 +1228,8 @@ BlockDriverAIOCB *bdrv_aio_write(BlockDr return NULL; if (bs->read_only) return NULL; + if (bdrv_wr_badreq_sectors(bs, sector_num, nb_sectors)) + return NULL; - if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) { - memcpy(bs->boot_sector_data, buf, 512); - } + + ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque); + Index: qemu/block.h =================================================================== -RCS file: /sources/qemu/qemu/block.h,v -retrieving revision 1.6 -retrieving revision 1.7 -diff -u -p -u -p -r1.6 -r1.7 ---- block.h 24 Dec 2007 16:10:43 -0000 1.6 -+++ block.h 11 Mar 2008 17:17:59 -0000 1.7 -@@ -45,6 +45,7 @@ typedef struct QEMUSnapshotInfo { - it (default for - bdrv_file_open()) */ - #define BDRV_O_DIRECT 0x0020 -+#define BDRV_O_AUTOGROW 0x0040 /* Allow backing file to extend when writing past end of file */ +@@ -50,6 +50,7 @@ + #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */ + #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */ + #define BDRV_O_CACHE_DEF 0x0080 /* use default caching */ ++#define BDRV_O_AUTOGROW 0x0100 /* Allow backing file to extend when writing past end of file */ + + #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF) - #ifndef QEMU_IMG - void bdrv_info(void); Index: qemu/block_int.h =================================================================== RCS file: /sources/qemu/qemu/block_int.h,v Index: files/patch-CVE-2008-4539 =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-CVE-2008-4539,v retrieving revision 1.1 diff -u -p -r1.1 patch-CVE-2008-4539 --- files/patch-CVE-2008-4539 2 Nov 2008 22:59:10 -0000 1.1 +++ files/patch-CVE-2008-4539 18 Jan 2009 17:25:27 -0000 @@ -1,27 +0,0 @@ -Index: qemu/hw/cirrus_vga.c -=================================================================== ---- trunk/hw/cirrus_vga.c 2008-11-01 00:53:30 UTC (rev 5586) -+++ trunk/hw/cirrus_vga.c 2008-11-01 00:53:39 UTC (rev 5587) -@@ -785,15 +785,14 @@ - - static int cirrus_bitblt_videotovideo_copy(CirrusVGAState * s) - { -+ if (BLTUNSAFE(s)) -+ return 0; -+ - if (s->ds->dpy_copy) { - cirrus_do_copy(s, s->cirrus_blt_dstaddr - s->start_addr, - s->cirrus_blt_srcaddr - s->start_addr, - s->cirrus_blt_width, s->cirrus_blt_height); - } else { -- -- if (BLTUNSAFE(s)) -- return 0; -- - (*s->cirrus_rop) (s, s->vram_ptr + - (s->cirrus_blt_dstaddr & s->cirrus_addr_mask), - s->vram_ptr + - - - - Index: files/patch-be =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-be,v retrieving revision 1.6 diff -u -p -r1.6 patch-be --- files/patch-be 25 Mar 2007 16:33:01 -0000 1.6 +++ files/patch-be 18 Jan 2009 17:25:27 -0000 @@ -1,19 +0,0 @@ -Index: qemu/vl.c -@@ -541,7 +541,7 @@ - static void init_get_clock(void) - { - use_rt_clock = 0; --#if defined(__linux__) -+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) - { - struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { -@@ -553,7 +553,7 @@ - - static int64_t get_clock(void) - { --#if defined(__linux__) -+#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) - if (use_rt_clock) { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); Index: files/patch-bg =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-bg,v retrieving revision 1.8 diff -u -p -r1.8 patch-bg --- files/patch-bg 3 Apr 2008 20:18:40 -0000 1.8 +++ files/patch-bg 18 Jan 2009 17:53:56 -0000 @@ -1,3 +1,13 @@ +Index: qemu/Makefile +@@ -11,7 +11,7 @@ + LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS) + + CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@ +-CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE ++CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DSMBD_COMMAND=\"${LOCALBASE}/sbin/smbd\" -I${LOCALBASE}/include -DPREFIX=\"${PREFIX}\" + LIBS= + ifdef CONFIG_STATIC + LDFLAGS += -static Index: qemu/Makefile.target @@ -179,7 +179,7 @@ @@ -8,8 +18,10 @@ Index: qemu/Makefile.target LIBS+=-lm ifndef CONFIG_USER_ONLY LIBS+=-lz -Index: qemu/vl.c -@@ -133,10 +133,12 @@ +Index: qemu/net.h +@@ -99,12 +99,14 @@ + int slirp_is_inited(void); + void net_client_check(void); -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" @@ -20,7 +32,7 @@ Index: qemu/vl.c #define SMBD_COMMAND "/usr/sfw/sbin/smbd" #else #define SMBD_COMMAND "/usr/sbin/smbd" -+#endif #endif ++#endif - //#define DEBUG_UNUSED_IOPORT + #endif Index: files/patch-block.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-block.c,v retrieving revision 1.5 diff -u -p -r1.5 patch-block.c --- files/patch-block.c 10 Mar 2007 17:03:05 -0000 1.5 +++ files/patch-block.c 18 Jan 2009 17:25:27 -0000 @@ -1,10 +0,0 @@ -Index: qemu/block.c -@@ -381,7 +381,7 @@ - else - open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT); - ret = drv->bdrv_open(bs, filename, open_flags); -- if (ret == -EACCES && !(flags & BDRV_O_FILE)) { -+ if ((ret == -EACCES || ret == -EPERM) && !(flags & BDRV_O_FILE)) { - ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY); - bs->read_only = 1; - } Index: files/patch-bsdusb.patch =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-bsdusb.patch,v retrieving revision 1.10 diff -u -p -r1.10 patch-bsdusb.patch --- files/patch-bsdusb.patch 11 Mar 2008 23:34:13 -0000 1.10 +++ files/patch-bsdusb.patch 18 Jan 2009 17:25:27 -0000 @@ -1,691 +0,0 @@ -Index: qemu/configure -@@ -139,6 +139,7 @@ - oss="yes" - linux="yes" - linux_user="yes" -+usb="linux" - if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" - fi -@@ -148,6 +149,7 @@ - if [ "$bsd" = "yes" ] ; then - if [ "$darwin" != "yes" ] ; then - make="gmake" -+ usb="bsd" - fi - fi - -@@ -786,6 +788,19 @@ - fi - - echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h -+ -+# USB host support -+case "$usb" in -+linux) -+ echo "HOST_USB=linux" >> $conig_mak -+;; -+bsd) -+ echo "HOST_USB=bsd" >> $config_mak -+;; -+*) -+ echo "HOST_USB=stub" >> $config_mak -+;; -+esac - - for target in $target_list; do - target_dir="$target" -Index: qemu/Makefile -@@ -58,7 +58,7 @@ - OBJS+=ssd0303.o ssd0323.o ads7846.o stellaris_input.o - OBJS+=scsi-disk.o cdrom.o - OBJS+=scsi-generic.o --OBJS+=usb.o usb-hub.o usb-linux.o usb-hid.o usb-msd.o usb-wacom.o usb-serial.o -+OBJS+=usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o usb-serial.o - OBJS+=sd.o ssi-sd.o - - ifdef CONFIG_WIN32 -Index: qemu/usb-stub.c -@@ -0,0 +1,11 @@ -+#include "vl.h" -+ -+void usb_host_info(void) -+{ -+ term_printf("USB host devices not supported\n"); -+} -+ -+USBDevice *usb_host_device_open(const char *devname) -+{ -+ return NULL; -+} -Index: qemu/usb-bsd.c -@@ -0,0 +1,601 @@ -+/* -+ * BSD host USB redirector -+ * -+ * Copyright (c) 2006 Lonnie Mendez -+ * Portions of code and concepts borrowed from -+ * usb-linux.c and libusb's bsd.c and are copyright their respective owners. -+ * -+ * 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 "qemu-common.h" -+#include "hw/usb.h" -+ -+/* usb.h declares these */ -+#undef USB_SPEED_HIGH -+#undef USB_SPEED_FULL -+#undef USB_SPEED_LOW -+ -+#include -+#include -+#include -+ -+/* This value has maximum potential at 16. -+ * You should also set hw.usb.debug to gain -+ * more detailed view. -+ */ -+//#define DEBUG -+#define UGEN_DEBUG_LEVEL 0 -+ -+ -+typedef int USBScanFunc(void *opaque, int bus_num, int addr, int class_id, -+ int vendor_id, int product_id, -+ const char *product_name, int speed); -+static int usb_host_find_device(int *pbus_num, int *paddr, -+ const char *devname); -+ -+typedef struct USBHostDevice { -+ USBDevice dev; -+ int ep_fd[USB_MAX_ENDPOINTS]; -+ int devfd; -+ char devpath[32]; -+} USBHostDevice; -+ -+ -+static int ensure_ep_open(USBHostDevice *dev, int ep, int mode) -+{ -+ char buf[32]; -+ int fd; -+ -+ /* Get the address for this endpoint */ -+ ep = UE_GET_ADDR(ep); -+ -+ if (dev->ep_fd[ep] < 0) { -+#if __FreeBSD__ -+ snprintf(buf, sizeof(buf) - 1, "%s.%d", dev->devpath, ep); -+#else -+ snprintf(buf, sizeof(buf) - 1, "%s.%02d", dev->devpath, ep); -+#endif -+ /* Try to open it O_RDWR first for those devices which have in and out -+ * endpoints with the same address (eg 0x02 and 0x82) -+ */ -+ fd = open(buf, O_RDWR); -+ if (fd < 0 && errno == ENXIO) -+ fd = open(buf, mode); -+ if (fd < 0) { -+#ifdef DEBUG -+ printf("ensure_ep_open: failed to open device endpoint %s: %s\n", -+ buf, strerror(errno)); -+#endif -+ } -+ dev->ep_fd[ep] = fd; -+ } -+ -+ return dev->ep_fd[ep]; -+} -+ -+static void ensure_eps_closed(USBHostDevice *dev) -+{ -+ int epnum = 1; -+ -+ if (!dev) -+ return; -+ -+ while (epnum < USB_MAX_ENDPOINTS) { -+ if (dev->ep_fd[epnum] >= 0) { -+ close(dev->ep_fd[epnum]); -+ dev->ep_fd[epnum] = -1; -+ } -+ epnum++; -+ } -+} -+ -+static void usb_host_handle_reset(USBDevice *dev) -+{ -+#if 0 -+ USBHostDevice *s = (USBHostDevice *)dev; -+#endif -+} -+ -+/* XXX: -+ * -check device states against transfer requests -+ * and return appropriate response -+ */ -+static int usb_host_handle_control(USBDevice *dev, -+ int request, -+ int value, -+ int index, -+ int length, -+ uint8_t *data) -+{ -+ USBHostDevice *s = (USBHostDevice *)dev; -+ struct usb_ctl_request req; -+ struct usb_alt_interface aiface; -+ int ret, timeout = 50; -+ -+ if ((request >> 8) == UT_WRITE_DEVICE && -+ (request & 0xff) == UR_SET_ADDRESS) { -+ -+ /* specific SET_ADDRESS support */ -+ dev->addr = value; -+ return 0; -+ } else if ((request >> 8) == UT_WRITE_DEVICE && -+ (request & 0xff) == UR_SET_CONFIG) { -+ -+ ensure_eps_closed(s); /* can't do this without all eps closed */ -+ -+ ret = ioctl(s->devfd, USB_SET_CONFIG, &value); -+ if (ret < 0) { -+#ifdef DEBUG -+ printf("handle_control: failed to set configuration - %s\n", -+ strerror(errno)); -+#endif -+ return USB_RET_STALL; -+ } -+ -+ return 0; -+ } else if ((request >> 8) == UT_WRITE_INTERFACE && -+ (request & 0xff) == UR_SET_INTERFACE) { -+ -+ aiface.uai_interface_index = index; -+ aiface.uai_alt_no = value; -+ -+ ensure_eps_closed(s); /* can't do this without all eps closed */ -+ ret = ioctl(s->devfd, USB_SET_ALTINTERFACE, &aiface); -+ if (ret < 0) { -+#ifdef DEBUG -+ printf("handle_control: failed to set alternate interface - %s\n", -+ strerror(errno)); -+#endif -+ return USB_RET_STALL; -+ } -+ -+ return 0; -+ } else { -+ req.ucr_request.bmRequestType = request >> 8; -+ req.ucr_request.bRequest = request & 0xff; -+ USETW(req.ucr_request.wValue, value); -+ USETW(req.ucr_request.wIndex, index); -+ USETW(req.ucr_request.wLength, length); -+ req.ucr_data = data; -+ req.ucr_flags = USBD_SHORT_XFER_OK; -+ -+ ret = ioctl(s->devfd, USB_SET_TIMEOUT, &timeout); -+#if (__NetBSD__ || __OpenBSD__) -+ if (ret < 0 && errno != EINVAL) { -+#else -+ if (ret < 0) { -+#endif -+#ifdef DEBUG -+ printf("handle_control: setting timeout failed - %s\n", -+ strerror(errno)); -+#endif -+ } -+ -+ ret = ioctl(s->devfd, USB_DO_REQUEST, &req); -+ /* ugen returns EIO for usbd_do_request_ no matter what -+ * happens with the transfer */ -+ if (ret < 0) { -+#ifdef DEBUG -+ printf("handle_control: error after request - %s\n", -+ strerror(errno)); -+#endif -+ return USB_RET_NAK; // STALL -+ } else { -+ return req.ucr_actlen; -+ } -+ } -+} -+ -+static int usb_host_handle_data(USBDevice *dev, USBPacket *p) -+{ -+ USBHostDevice *s = (USBHostDevice *)dev; -+ int ret, fd, mode; -+ int one = 1, shortpacket = 0, timeout = 50; -+ sigset_t new_mask, old_mask; -+ uint8_t devep = p->devep; -+ -+ /* protect data transfers from SIGALRM signal */ -+ sigemptyset(&new_mask); -+ sigaddset(&new_mask, SIGALRM); -+ sigprocmask(SIG_BLOCK, &new_mask, &old_mask); -+ -+ if (p->pid == USB_TOKEN_IN) { -+ devep |= 0x80; -+ mode = O_RDONLY; -+ shortpacket = 1; -+ } else { -+ mode = O_WRONLY; -+ } -+ -+ fd = ensure_ep_open(s, devep, mode); -+ if (fd < 0) { -+ sigprocmask(SIG_SETMASK, &old_mask, NULL); -+ return USB_RET_NODEV; -+ } -+ -+ if (ioctl(fd, USB_SET_TIMEOUT, &timeout) < 0) { -+#ifdef DEBUG -+ printf("handle_data: failed to set timeout - %s\n", -+ strerror(errno)); -+#endif -+ } -+ -+ if (shortpacket) { -+ if (ioctl(fd, USB_SET_SHORT_XFER, &one) < 0) { -+#ifdef DEBUG -+ printf("handle_data: failed to set short xfer mode - %s\n", -+ strerror(errno)); -+#endif -+ sigprocmask(SIG_SETMASK, &old_mask, NULL); -+ } -+ } -+ -+ if (p->pid == USB_TOKEN_IN) -+ ret = read(fd, p->data, p->len); -+ else -+ ret = write(fd, p->data, p->len); -+ -+ sigprocmask(SIG_SETMASK, &old_mask, NULL); -+ -+ if (ret < 0) { -+#ifdef DEBUG -+ printf("handle_data: error after %s data - %s\n", -+ pid == USB_TOKEN_IN ? "reading" : "writing", strerror(errno)); -+#endif -+ switch(errno) { -+ case ETIMEDOUT: -+ case EINTR: -+ return USB_RET_NAK; -+ default: -+ return USB_RET_STALL; -+ } -+ } else { -+ return ret; -+ } -+} -+ -+static void usb_host_handle_destroy(USBDevice *opaque) -+{ -+ USBHostDevice *s = (USBHostDevice *)opaque; -+ int i; -+ -+ for (i = 0; i < USB_MAX_ENDPOINTS; i++) -+ if (s->ep_fd[i] >= 0) -+ close(s->ep_fd[i]); -+ -+ if (s->devfd < 0) -+ return; -+ -+ close(s->devfd); -+ -+ qemu_free(s); -+} -+ -+USBDevice *usb_host_device_open(const char *devname) -+{ -+ struct usb_device_info bus_info, dev_info; -+ USBHostDevice *dev; -+ char ctlpath[PATH_MAX + 1]; -+ char buspath[PATH_MAX + 1]; -+ int bfd, dfd, bus, address, i; -+ int ugendebug = UGEN_DEBUG_LEVEL; -+ -+ if (usb_host_find_device(&bus, &address, devname) < 0) -+ return NULL; -+ -+ snprintf(buspath, PATH_MAX, "/dev/usb%d", bus); -+ -+ bfd = open(buspath, O_RDWR); -+ if (bfd < 0) { -+#ifdef DEBUG -+ printf("usb_host_device_open: failed to open usb bus - %s\n", -+ strerror(errno)); -+#endif -+ return NULL; -+ } -+ -+ bus_info.udi_addr = address; -+ if (ioctl(bfd, USB_DEVICEINFO, &bus_info) < 0) { -+#ifdef DEBUG -+ printf("usb_host_device_open: failed to grab bus information - %s\n", -+ strerror(errno)); -+#endif -+ return NULL; -+ } -+ -+#if __FreeBSD__ -+ snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]); -+#else -+ snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]); -+#endif -+ -+ dfd = open(ctlpath, O_RDWR); -+ if (dfd < 0) { -+ dfd = open(ctlpath, O_RDONLY); -+ if (dfd < 0) { -+#ifdef DEBUG -+ printf("usb_host_device_open: failed to open usb device %s - %s\n", -+ ctlpath, strerror(errno)); -+#endif -+ } -+ } -+ -+ if (dfd >= 0) { -+ dev = qemu_mallocz(sizeof(USBHostDevice)); -+ if (!dev) -+ goto fail; -+ dev->devfd = dfd; -+ -+ if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) { -+#ifdef DEBUG -+ printf("usb_host_device_open: failed to grab device info - %s\n", -+ strerror(errno)); -+#endif -+ goto fail; -+ } -+ -+ if (dev_info.udi_speed == 1) -+ dev->dev.speed = USB_SPEED_LOW - 1; -+ else -+ dev->dev.speed = USB_SPEED_FULL - 1; -+ -+ dev->dev.handle_packet = usb_generic_handle_packet; -+ -+ dev->dev.handle_reset = usb_host_handle_reset; -+ dev->dev.handle_control = usb_host_handle_control; -+ dev->dev.handle_data = usb_host_handle_data; -+ dev->dev.handle_destroy = usb_host_handle_destroy; -+ -+ if (strncmp(dev_info.udi_product, "product", 7) != 0) -+ pstrcpy(dev->dev.devname, sizeof(dev->dev.devname), -+ dev_info.udi_product); -+ else -+ snprintf(dev->dev.devname, sizeof(dev->dev.devname), -+ "host:%s", devname); -+ -+ pstrcpy(dev->devpath, sizeof(dev->devpath), "/dev/"); -+ strcat(dev->devpath, dev_info.udi_devnames[0]); -+ -+ /* Mark the endpoints as not yet open */ -+ for (i = 0; i < USB_MAX_ENDPOINTS; i++) -+ dev->ep_fd[i] = -1; -+ -+ ioctl(dfd, USB_SETDEBUG, &ugendebug); -+ -+ return (USBDevice *)dev; -+ } -+ -+fail: -+ return NULL; -+} -+ -+static int usb_host_scan(void *opaque, USBScanFunc *func) -+{ -+ struct usb_device_info bus_info; -+ struct usb_device_info dev_info; -+ uint16_t vendor_id, product_id, class_id, speed; -+ int bfd, dfd, bus, address; -+ char busbuf[20], devbuf[20], product_name[256]; -+ int ret = 0; -+ -+ for (bus = 0; bus < 10; bus++) { -+ -+ snprintf(busbuf, sizeof(busbuf) - 1, "/dev/usb%d", bus); -+ bfd = open(busbuf, O_RDWR); -+ if (bfd < 0) -+ continue; -+ -+ for (address = 1; address < 127; address++) { -+ -+ bus_info.udi_addr = address; -+ if (ioctl(bfd, USB_DEVICEINFO, &bus_info) < 0) -+ continue; -+ -+ /* only list devices that can be used by generic layer */ -+ if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0) -+ continue; -+ -+#if __FreeBSD__ -+ snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]); -+#else -+ snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]); -+#endif -+ -+ dfd = open(devbuf, O_RDONLY); -+ if (dfd < 0) { -+#ifdef DEBUG -+ printf("usb_host_scan: couldn't open device %s - %s\n", devbuf, -+ strerror(errno)); -+#endif -+ continue; -+ } -+ -+ if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) -+ printf("usb_host_scan: couldn't get device information for %s - %s\n", -+ devbuf, strerror(errno)); -+ -+ // XXX: might need to fixup endianess of word values before copying over -+ -+ vendor_id = dev_info.udi_vendorNo; -+ product_id = dev_info.udi_productNo; -+ class_id = dev_info.udi_class; -+ speed = dev_info.udi_speed; -+ -+ if (strncmp(dev_info.udi_product, "product", 7) != 0) -+ pstrcpy(product_name, sizeof(product_name), -+ dev_info.udi_product); -+ else -+ product_name[0] = '\0'; -+ -+ ret = func(opaque, bus, address, class_id, vendor_id, -+ product_id, product_name, speed); -+ -+ close(dfd); -+ -+ if (ret) -+ goto the_end; -+ } -+ -+ close(bfd); -+ } -+ -+the_end: -+ return ret; -+} -+ -+typedef struct FindDeviceState { -+ int vendor_id; -+ int product_id; -+ int bus_num; -+ int addr; -+} FindDeviceState; -+ -+static int usb_host_find_device_scan(void *opaque, int bus_num, int addr, -+ int class_id, -+ int vendor_id, int product_id, -+ const char *product_name, int speed) -+{ -+ FindDeviceState *s = opaque; -+ if (vendor_id == s->vendor_id && -+ product_id == s->product_id) { -+ s->bus_num = bus_num; -+ s->addr = addr; -+ return 1; -+ } else { -+ return 0; -+ } -+} -+ -+ -+/* the syntax is : -+ 'bus.addr' (decimal numbers) or -+ 'vendor_id:product_id' (hexa numbers) */ -+static int usb_host_find_device(int *pbus_num, int *paddr, -+ const char *devname) -+{ -+ const char *p; -+ int ret; -+ FindDeviceState fs; -+ -+ p = strchr(devname, '.'); -+ if (p) { -+ *pbus_num = strtoul(devname, NULL, 0); -+ *paddr = strtoul(p + 1, NULL, 0); -+ return 0; -+ } -+ p = strchr(devname, ':'); -+ if (p) { -+ fs.vendor_id = strtoul(devname, NULL, 16); -+ fs.product_id = strtoul(p + 1, NULL, 16); -+ ret = usb_host_scan(&fs, usb_host_find_device_scan); -+ if (ret) { -+ *pbus_num = fs.bus_num; -+ *paddr = fs.addr; -+ return 0; -+ } -+ } -+ return -1; -+} -+ -+/**********************/ -+/* USB host device info */ -+ -+struct usb_class_info { -+ int class; -+ const char *class_name; -+}; -+ -+static const struct usb_class_info usb_class_info[] = { -+ { USB_CLASS_AUDIO, "Audio"}, -+ { USB_CLASS_COMM, "Communication"}, -+ { USB_CLASS_HID, "HID"}, -+ { USB_CLASS_HUB, "Hub" }, -+ { USB_CLASS_PHYSICAL, "Physical" }, -+ { USB_CLASS_PRINTER, "Printer" }, -+ { USB_CLASS_MASS_STORAGE, "Storage" }, -+ { USB_CLASS_CDC_DATA, "Data" }, -+ { USB_CLASS_APP_SPEC, "Application Specific" }, -+ { USB_CLASS_VENDOR_SPEC, "Vendor Specific" }, -+ { USB_CLASS_STILL_IMAGE, "Still Image" }, -+ { USB_CLASS_CSCID, "Smart Card" }, -+ { USB_CLASS_CONTENT_SEC, "Content Security" }, -+ { -1, NULL } -+}; -+ -+static const char *usb_class_str(uint8_t class) -+{ -+ const struct usb_class_info *p; -+ for (p = usb_class_info; p->class != -1; p++) { -+ if (p->class == class) -+ break; -+ } -+ return p->class_name; -+} -+ -+void usb_info_device(int bus_num, int addr, int class_id, -+ int vendor_id, int product_id, -+ const char *product_name, -+ int speed) -+{ -+ const char *class_str, *speed_str; -+ -+ switch(speed) { -+ case USB_SPEED_LOW: -+ speed_str = "1.5"; -+ break; -+ case USB_SPEED_FULL: -+ speed_str = "12"; -+ break; -+ case USB_SPEED_HIGH: -+ speed_str = "480"; -+ break; -+ default: -+ speed_str = "?"; -+ break; -+ } -+ -+ term_printf(" Device %d.%d, speed %s Mb/s\n", -+ bus_num, addr, speed_str); -+ class_str = usb_class_str(class_id); -+ if (class_str) -+ term_printf(" %s:", class_str); -+ else -+ term_printf(" Class %02x:", class_id); -+ term_printf(" USB device %04x:%04x", vendor_id, product_id); -+ if (product_name[0] != '\0') -+ term_printf(", %s", product_name); -+ term_printf("\n"); -+} -+ -+static int usb_host_info_device(void *opaque, int bus_num, int addr, -+ int class_id, -+ int vendor_id, int product_id, -+ const char *product_name, -+ int speed) -+{ -+ usb_info_device(bus_num, addr, class_id, vendor_id, product_id, -+ product_name, speed); -+ return 0; -+} -+ -+void usb_host_info(void) -+{ -+ usb_host_scan(NULL, usb_host_info_device); -+} -Index: qemu/usb-linux.c -@@ -23,7 +23,6 @@ - */ - #include "vl.h" - --#if defined(__linux__) - #include - #include - #include -@@ -505,18 +504,3 @@ - { - usb_host_scan(NULL, usb_host_info_device); - } -- --#else -- --void usb_host_info(void) --{ -- term_printf("USB host devices not supported\n"); --} -- --/* XXX: modify configure to compile the right host driver */ --USBDevice *usb_host_device_open(const char *devname) --{ -- return NULL; --} -- --#endif Index: files/patch-bt =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-bt,v retrieving revision 1.6 diff -u -p -r1.6 patch-bt --- files/patch-bt 9 Aug 2007 20:03:30 -0000 1.6 +++ files/patch-bt 18 Jan 2009 17:25:27 -0000 @@ -1,4 +1,4 @@ -Index: qemu/vl.c +Index: qemu/net.c @@ -76,6 +76,11 @@ #endif #endif Index: files/patch-cpu-exec.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-cpu-exec.c,v retrieving revision 1.5 diff -u -p -r1.5 patch-cpu-exec.c --- files/patch-cpu-exec.c 8 Jul 2008 18:42:09 -0000 1.5 +++ files/patch-cpu-exec.c 18 Jan 2009 17:25:27 -0000 @@ -1,27 +1,66 @@ Index: qemu/cpu-exec.c -@@ -394,16 +394,18 @@ - (env->eflags & IF_MASK && - !(env->hflags & HF_INHIBIT_IRQ_MASK))))) { - int intno; -- svm_check_intercept(SVM_EXIT_INTR); - env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ); - intno = cpu_get_pic_interrupt(env); -- if (loglevel & CPU_LOG_TB_IN_ASM) { -- fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno); -+ if (intno>=0) { -+ svm_check_intercept(SVM_EXIT_INTR); -+ if (loglevel & CPU_LOG_TB_IN_ASM) { -+ fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno); -+ } -+ do_interrupt(intno, 0, 0, 0, 1); -+ /* ensure that no TB jump will be modified as -+ the program flow was changed */ -+ next_tb = 0; - } -- do_interrupt(intno, 0, 0, 0, 1); -- /* ensure that no TB jump will be modified as -- the program flow was changed */ -- next_tb = 0; - #if !defined(CONFIG_USER_ONLY) - } else if ((interrupt_request & CPU_INTERRUPT_VIRQ) && - (env->eflags & IF_MASK) && +@@ -1158,6 +1158,12 @@ + # define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext->ss.eip)) + # define TRAP_sig(context) ((context)->uc_mcontext->es.trapno) + # define ERROR_sig(context) ((context)->uc_mcontext->es.err) ++#elif defined(__FreeBSD__) ++# include ++ ++# define EIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_eip)) ++# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) ++# define ERROR_sig(context) ((context)->uc_mcontext.mc_err) + #else + # define EIP_sig(context) ((context)->uc_mcontext.gregs[REG_EIP]) + # define TRAP_sig(context) ((context)->uc_mcontext.gregs[REG_TRAPNO]) +@@ -1168,7 +1174,11 @@ + void *puc) + { + siginfo_t *info = pinfo; ++#ifdef __FreeBSD__ ++ ucontext_t *uc = puc; ++#else + struct ucontext *uc = puc; ++#endif + unsigned long pc; + int trapno; + +@@ -1194,6 +1204,12 @@ + + #define QEMU_UC_MCONTEXT_GREGS(uc, reg) (uc)->uc_mcontext.__gregs[(reg)] + #define QEMU_UC_MACHINE_PC(uc) _UC_MACHINE_PC(uc) ++#elif defined(__FreeBSD__) ++# include ++ ++# define RIP_sig(context) (*((unsigned long*)&(context)->uc_mcontext.mc_rip)) ++# define TRAP_sig(context) ((context)->uc_mcontext.mc_trapno) ++# define ERROR_sig(context) ((context)->uc_mcontext.mc_err) + #else + #define QEMU_UC_MCONTEXT_GREGS(uc, reg) (uc)->uc_mcontext.gregs[(reg)] + #define QEMU_UC_MACHINE_PC(uc) QEMU_UC_MCONTEXT_GREGS(uc, REG_RIP) +@@ -1204,17 +1220,25 @@ + { + siginfo_t *info = pinfo; + unsigned long pc; +-#ifdef __NetBSD__ ++#if defined(__NetBSD__) || defined(__FreeBSD__) + ucontext_t *uc = puc; + #else + struct ucontext *uc = puc; + #endif + ++#ifdef __FreeBSD__ ++ pc = RIP_sig(uc); ++ return handle_cpu_signal(pc, (unsigned long)info->si_addr, ++ TRAP_sig(uc) == 0xe ? ++ (ERROR_sig(uc) >> 1) & 1 : 0, ++ &uc->uc_sigmask, puc); ++#else + pc = QEMU_UC_MACHINE_PC(uc); + return handle_cpu_signal(pc, (unsigned long)info->si_addr, + QEMU_UC_MCONTEXT_GREGS(uc, REG_TRAPNO) == 0xe ? + (QEMU_UC_MCONTEXT_GREGS(uc, REG_ERR) >> 1) & 1 : 0, + &uc->uc_sigmask, puc); ++#endif + } + + #elif defined(__powerpc__) Index: files/patch-exec.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-exec.c,v retrieving revision 1.3 diff -u -p -r1.3 patch-exec.c --- files/patch-exec.c 8 Jul 2008 18:42:09 -0000 1.3 +++ files/patch-exec.c 18 Jan 2009 17:25:27 -0000 @@ -1,30 +0,0 @@ -Index: qemu/exec.c -@@ -405,6 +405,28 @@ - exit(1); - } - } -+#elif defined(__FreeBSD__) -+ { -+ int flags; -+ void *addr = NULL; -+ flags = MAP_PRIVATE | MAP_ANONYMOUS; -+#if defined(__x86_64__) -+ /* FreeBSD doesn't have MAP_32BIT, use MAP_FIXED and assume -+ * 0x40000000 is free */ -+ flags |= MAP_FIXED; -+ addr = (void *)0x40000000; -+ /* Cannot map more than that */ -+ if (code_gen_buffer_size > (800 * 1024 * 1024)) -+ code_gen_buffer_size = (800 * 1024 * 1024); -+#endif -+ code_gen_buffer = mmap(addr, code_gen_buffer_size, -+ PROT_WRITE | PROT_READ | PROT_EXEC, -+ flags, -1, 0); -+ if (code_gen_buffer == MAP_FAILED) { -+ fprintf(stderr, "Could not allocate dynamic translator buffer\n"); -+ exit(1); -+ } -+ } - #else - code_gen_buffer = qemu_malloc(code_gen_buffer_size); - if (!code_gen_buffer) { Index: files/patch-fbsd =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-fbsd,v retrieving revision 1.12 diff -u -p -r1.12 patch-fbsd --- files/patch-fbsd 8 Jul 2008 18:42:09 -0000 1.12 +++ files/patch-fbsd 18 Jan 2009 17:25:27 -0000 @@ -20,14 +20,23 @@ Index: qemu/Makefile rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS *.pod *~ */*~ $(MAKE) -C tests clean Index: qemu/Makefile.target -@@ -651,8 +651,8 @@ +@@ -472,7 +472,7 @@ + # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object + # that the kernel ELF loader considers as an executable. I think this + # is the simplest way to make it self virtualizable! +-LDFLAGS+=-Wl,-shared ++#LDFLAGS+=-Wl,-shared + endif + endif + +@@ -663,8 +663,8 @@ main.o: CFLAGS+=-p endif -$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a -- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) +- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) +$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a ../bsd/libmath.a -+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) ../bsd/libmath.a ++ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(OS_LDFLAGS) ../bsd/libmath.a endif # !CONFIG_USER_ONLY @@ -90,17 +99,16 @@ Index: qemu/fpu/softfloat-native.h #define fabsf(f) ((float)fabs(f)) #else #include -@@ -60,7 +80,9 @@ - /*---------------------------------------------------------------------------- +@@ -109,6 +109,8 @@ | Software IEC/IEEE floating-point rounding mode. *----------------------------------------------------------------------------*/ -#if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) +#if (defined(_BSD) && !defined(__APPLE__) && \ -+ (!defined(__FreeBSD__) || __FreeBSD_version < 500000)) || \ -+ defined(HOST_SOLARIS) - enum { - float_round_nearest_even = FP_RN, - float_round_down = FP_RM, ++ (!defined(__FreeBSD__) || __FreeBSD_version < 500000)) || \ ++ defined(HOST_SOLARIS) + #if defined(__OpenBSD__) + #define FE_RM FP_RM + #define FE_RP FP_RP Index: qemu/fpu/softfloat.h @@ -84,7 +84,8 @@ #define FLOAT128 @@ -113,20 +121,20 @@ Index: qemu/fpu/softfloat.h #endif #endif /* !CONFIG_SOFTFLOAT */ Index: qemu/target-ppc/op_helper.c -@@ -303,6 +303,13 @@ - FT0 = sqrt(FT0); +@@ -293,6 +293,13 @@ + uint32_t exp = (u.ll >> 52) & 0x7FF; + return ((0 < exp) && (exp < 0x7FF)); } - ++#else +#ifndef isnormal +#define isnormal(x) \ + ((sizeof (x) == sizeof (float)) ? __isnormalf(x) \ + : (sizeof (x) == sizeof (double)) ? __isnormal(x) \ + : __isnormall(x)) +#endif -+ - void do_fres (void) - { - union { + #endif + + uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf) Index: qemu/x86_64.ld @@ -2,7 +2,7 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") @@ -137,3 +145,23 @@ Index: qemu/x86_64.ld SECTIONS { /* Read-only sections, merged into text segment: */ +@@ -59,8 +59,6 @@ + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) } +- .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } +- .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN (0x100000) - ((0x100000 - .) & (0x100000 - 1)); . = DATA_SEGMENT_ALIGN (0x100000, 0x1000); +@@ -86,8 +84,8 @@ + .data1 : { *(.data1) } + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } +- .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) } +- .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table) } ++ .eh_frame : { KEEP (*(.eh_frame)) } ++ .gcc_except_table : { *(.gcc_except_table) } + .dynamic : { *(.dynamic) } + .ctors : + { Index: files/patch-hw-vmware_vga.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-hw-vmware_vga.c,v retrieving revision 1.1 diff -u -p -r1.1 patch-hw-vmware_vga.c --- files/patch-hw-vmware_vga.c 2 May 2007 19:55:07 -0000 1.1 +++ files/patch-hw-vmware_vga.c 18 Jan 2009 17:25:27 -0000 @@ -1,12 +1,74 @@ Index: qemu/hw/vmware_vga.c -@@ -26,8 +26,8 @@ +@@ -28,9 +28,9 @@ #define VERBOSE #define EMBED_STDVGA #undef DIRECT_VRAM -#define HW_RECT_ACCEL -#define HW_FILL_ACCEL +-#define HW_MOUSE_ACCEL +/* #define HW_RECT_ACCEL */ +/* #define HW_FILL_ACCEL */ - #define HW_MOUSE_ACCEL ++/* #define HW_MOUSE_ACCEL */ #ifdef EMBED_STDVGA + # include "vga_int.h" +@@ -76,6 +76,7 @@ + uint32_t wblue; + int syncing; + int fb_size; ++ int empty; + + union { + uint32_t *fifo; +@@ -487,7 +488,7 @@ + + static inline int vmsvga_fifo_empty(struct vmsvga_state_s *s) + { +- if (!s->config || !s->enable) ++ if (!s->config || !s->enable || s->empty) + return 1; + return (s->cmd->next_cmd == s->cmd->stop); + } +@@ -495,6 +496,10 @@ + static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s) + { + uint32_t cmd = s->fifo[CMD(stop) >> 2]; ++ if (s->cmd->next_cmd == s->cmd->stop) { ++ s->empty = 1; ++ return 0; ++ } + s->cmd->stop = cpu_to_le32(CMD(stop) + 4); + if (CMD(stop) >= CMD(max)) + s->cmd->stop = s->cmd->min; +@@ -512,6 +517,7 @@ + int args = 0; + int x, y, dx, dy, width, height; + struct vmsvga_cursor_definition_s cursor; ++ s->empty = 0; + while (!vmsvga_fifo_empty(s)) + switch (cmd = vmsvga_fifo_read(s)) { + case SVGA_CMD_UPDATE: +@@ -533,6 +539,7 @@ + vmsvga_fill_rect(s, colour, x, y, width, height); + break; + #else ++ args = 0; + goto badcmd; + #endif + +@@ -547,6 +554,7 @@ + vmsvga_copy_rect(s, x, y, dx, dy, width, height); + break; + #else ++ args = 0; + goto badcmd; + #endif + +@@ -609,6 +617,7 @@ + break; /* Nop */ + + default: ++ args = 0; + badcmd: + while (args --) + vmsvga_fifo_read(s); Index: files/patch-osdep.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-osdep.c,v retrieving revision 1.4 diff -u -p -r1.4 patch-osdep.c --- files/patch-osdep.c 8 Jul 2008 18:42:09 -0000 1.4 +++ files/patch-osdep.c 18 Jan 2009 17:25:27 -0000 @@ -1,43 +0,0 @@ -Index: qemu/osdep.c -@@ -68,7 +68,9 @@ - - #if defined(USE_KQEMU) - -+#ifndef __FreeBSD__ - #include -+#endif - #include - #include - -@@ -79,6 +81,7 @@ - const char *tmpdir; - char phys_ram_file[1024]; - void *ptr; -+#ifndef __FreeBSD__ - #ifdef HOST_SOLARIS - struct statvfs stfs; - #else -@@ -138,7 +141,9 @@ - } - unlink(phys_ram_file); - } -+#endif - size = (size + 4095) & ~4095; -+#ifndef __FreeBSD__ - ftruncate(phys_ram_fd, phys_ram_size + size); - ptr = mmap(NULL, - size, -@@ -148,6 +153,13 @@ - fprintf(stderr, "Could not map physical memory\n"); - exit(1); - } -+#else -+ ptr = malloc(size); -+ if (ptr == NULL) { -+ fprintf(stderr, "Could not allocate physical memory\n"); -+ exit(1); -+ } -+#endif - phys_ram_size += size; - return ptr; - } Index: files/patch-target-i386-translate.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-target-i386-translate.c,v retrieving revision 1.3 diff -u -p -r1.3 patch-target-i386-translate.c --- files/patch-target-i386-translate.c 8 Jul 2008 18:42:09 -0000 1.3 +++ files/patch-target-i386-translate.c 18 Jan 2009 17:25:27 -0000 @@ -1,16 +0,0 @@ -Index: qemu/target-i386/translate.c -@@ -3330,8 +3330,12 @@ - op1_offset = offsetof(CPUX86State,xmm_regs[reg]); - tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); - sse_op2 = sse_op_table3[(s->dflag == 2) * 2 + ((b >> 8) - 2)]; -- tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); -- tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_tmp2_i32); -+ if (ot == OT_LONG) { -+ tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); -+ tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_tmp2_i32); -+ } else { -+ tcg_gen_helper_0_2(sse_op2, cpu_ptr0, cpu_T[0]); -+ } - break; - case 0x02c: /* cvttps2pi */ - case 0x12c: /* cvttpd2pi */ Index: files/patch-tcg-i386-tcg-target.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-tcg-i386-tcg-target.c,v retrieving revision 1.1 diff -u -p -r1.1 patch-tcg-i386-tcg-target.c --- files/patch-tcg-i386-tcg-target.c 8 Jul 2008 18:42:09 -0000 1.1 +++ files/patch-tcg-i386-tcg-target.c 18 Jan 2009 17:25:27 -0000 @@ -1,28 +0,0 @@ -Index: qemu/tcg/i386/tcg-target.c -@@ -360,22 +360,22 @@ - case TCG_COND_LT: - tcg_out_brcond(s, TCG_COND_LT, args[1], args[3], const_args[3], args[5]); - tcg_out_jxx(s, JCC_JNE, label_next); -- tcg_out_brcond(s, TCG_COND_LT, args[0], args[2], const_args[2], args[5]); -+ tcg_out_brcond(s, TCG_COND_LTU, args[0], args[2], const_args[2], args[5]); - break; - case TCG_COND_LE: - tcg_out_brcond(s, TCG_COND_LT, args[1], args[3], const_args[3], args[5]); - tcg_out_jxx(s, JCC_JNE, label_next); -- tcg_out_brcond(s, TCG_COND_LE, args[0], args[2], const_args[2], args[5]); -+ tcg_out_brcond(s, TCG_COND_LEU, args[0], args[2], const_args[2], args[5]); - break; - case TCG_COND_GT: - tcg_out_brcond(s, TCG_COND_GT, args[1], args[3], const_args[3], args[5]); - tcg_out_jxx(s, JCC_JNE, label_next); -- tcg_out_brcond(s, TCG_COND_GT, args[0], args[2], const_args[2], args[5]); -+ tcg_out_brcond(s, TCG_COND_GTU, args[0], args[2], const_args[2], args[5]); - break; - case TCG_COND_GE: - tcg_out_brcond(s, TCG_COND_GT, args[1], args[3], const_args[3], args[5]); - tcg_out_jxx(s, JCC_JNE, label_next); -- tcg_out_brcond(s, TCG_COND_GE, args[0], args[2], const_args[2], args[5]); -+ tcg_out_brcond(s, TCG_COND_GEU, args[0], args[2], const_args[2], args[5]); - break; - case TCG_COND_LTU: - tcg_out_brcond(s, TCG_COND_LTU, args[1], args[3], const_args[3], args[5]); Index: files/patch-vl.c =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-vl.c,v retrieving revision 1.11 diff -u -p -r1.11 patch-vl.c --- files/patch-vl.c 8 Jul 2008 18:42:09 -0000 1.11 +++ files/patch-vl.c 18 Jan 2009 17:25:27 -0000 @@ -1,39 +1,28 @@ Index: qemu/vl.c -@@ -1727,6 +1728,7 @@ - chr->chr_ioctl = pp_ioctl; - return chr; - } -+#endif /* defined(__linux__) */ - +@@ -75,6 +75,7 @@ + #include + #ifdef __FreeBSD__ + #include ++#include #else - CharDriverState *qemu_chr_open_pty(void) -@@ -2334,7 +2334,7 @@ - } - #endif - --#if defined(__linux__) || defined(__sun__) -+#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) - static CharDriverState *qemu_chr_open_pty(void) - { - struct termios tty; -@@ -3036,7 +3036,7 @@ - return qemu_chr_open_pp(filename); - } else + #include #endif --#if defined(__linux__) || defined(__sun__) -+#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) - if (strstart(filename, "/dev/", NULL)) { - return qemu_chr_open_tty(filename); - } else -@@ -8423,6 +8423,11 @@ - nb_nics = 0; - /* default mac address of the first network interface */ +@@ -9850,15 +9850,15 @@ + phys_ram_size += ram_size; + } -+#ifdef __FreeBSD__ -+ if (modfind("aio") == -1) -+ fprintf(stderr, "warning: aio not (kld)loaded, may cause `Invalid system call' traps on disk IO\n"); -+#endif ++ /* init the dynamic translator */ ++ cpu_exec_init_all(tb_size * 1024 * 1024); + - optind = 1; - for(;;) { - if (optind >= argc) + phys_ram_base = qemu_vmalloc(phys_ram_size); + if (!phys_ram_base) { + fprintf(stderr, "Could not allocate physical memory\n"); + exit(1); + } + +- /* init the dynamic translator */ +- cpu_exec_init_all(tb_size * 1024 * 1024); +- + bdrv_init(); + + /* we always create the cdrom drive, even if no disk is there */ Index: files/patch-vl.c-ppbus =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-vl.c-ppbus,v retrieving revision 1.5 diff -u -p -r1.5 patch-vl.c-ppbus --- files/patch-vl.c-ppbus 9 Aug 2007 20:03:30 -0000 1.5 +++ files/patch-vl.c-ppbus 18 Jan 2009 17:25:27 -0000 @@ -1,92 +0,0 @@ -Index: qemu/vl.c -@@ -78,8 +78,10 @@ - #endif - #ifdef __FreeBSD__ - #include - #include - #include -+#include -+#include - #endif - - #if defined(CONFIG_SLIRP) -@@ -1728,7 +1730,64 @@ - chr->chr_ioctl = pp_ioctl; - return chr; - } --#endif /* defined(__linux__) */ -+#if defined(__FreeBSD__) -+static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) -+{ -+ int fd = (int)chr->opaque; -+ uint8_t b; -+ -+ switch(cmd) { -+ case CHR_IOCTL_PP_READ_DATA: -+ if (ioctl(fd, PPIGDATA, &b) < 0) -+ return -ENOTSUP; -+ *(uint8_t *)arg = b; -+ break; -+ case CHR_IOCTL_PP_WRITE_DATA: -+ b = *(uint8_t *)arg; -+ if (ioctl(fd, PPISDATA, &b) < 0) -+ return -ENOTSUP; -+ break; -+ case CHR_IOCTL_PP_READ_CONTROL: -+ if (ioctl(fd, PPIGCTRL, &b) < 0) -+ return -ENOTSUP; -+ *(uint8_t *)arg = b; -+ break; -+ case CHR_IOCTL_PP_WRITE_CONTROL: -+ b = *(uint8_t *)arg; -+ if (ioctl(fd, PPISCTRL, &b) < 0) -+ return -ENOTSUP; -+ break; -+ case CHR_IOCTL_PP_READ_STATUS: -+ if (ioctl(fd, PPIGSTATUS, &b) < 0) -+ return -ENOTSUP; -+ *(uint8_t *)arg = b; -+ break; -+ default: -+ return -ENOTSUP; -+ } -+ return 0; -+} -+ -+CharDriverState *qemu_chr_open_pp(const char *filename) -+{ -+ CharDriverState *chr; -+ int fd; -+ -+ fd = open(filename, O_RDWR); -+ if (fd < 0) -+ return NULL; -+ -+ chr = qemu_mallocz(sizeof(CharDriverState)); -+ if (!chr) { -+ close(fd); -+ return NULL; -+ } -+ chr->opaque = (void *)fd; -+ chr->chr_write = null_chr_write; -+ chr->chr_ioctl = pp_ioctl; -+ return chr; -+} -+#endif - - #else - CharDriverState *qemu_chr_open_pty(void) -@@ -2562,6 +2622,13 @@ - #endif - #if defined(__linux__) - if (strstart(filename, "/dev/parport", NULL)) { -+ return qemu_chr_open_pp(filename); -+ } else -+ if (strstart(filename, "/dev/", NULL)) { -+ return qemu_chr_open_tty(filename); -+ } else -+#elif defined(__FreeBSD__) -+ if (strstart(filename, "/dev/ppi", NULL)) { - return qemu_chr_open_pp(filename); - } else - if (strstart(filename, "/dev/", NULL)) { Index: files/patch-vl.c-serial =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/patch-vl.c-serial,v retrieving revision 1.2 diff -u -p -r1.2 patch-vl.c-serial --- files/patch-vl.c-serial 10 Mar 2007 17:03:05 -0000 1.2 +++ files/patch-vl.c-serial 18 Jan 2009 17:25:27 -0000 @@ -1,4 +1,4 @@ -Index: qemu/vl.c +Index: qemu/qemu-char.c @@ -1606,10 +1606,13 @@ cfsetospeed(&tty, spd); Index: files/pcap-patch =================================================================== RCS file: /home/pcvs/ports/emulators/qemu-devel/files/pcap-patch,v retrieving revision 1.1 diff -u -p -r1.1 pcap-patch --- files/pcap-patch 2 Aug 2008 18:29:39 -0000 1.1 +++ files/pcap-patch 18 Jan 2009 18:33:36 -0000 @@ -86,11 +86,10 @@ if test "$slirp" = "yes" ; then echo "CONFIG_SLIRP=yes" >> $config_mak echo "#define CONFIG_SLIRP 1" >> $config_h ---- vl.c.orig 2008-07-18 15:19:26.000000000 -0400 -+++ vl.c 2008-07-18 15:31:25.000000000 -0400 -@@ -102,6 +102,13 @@ - int inet_aton(const char *cp, struct in_addr *ia); - #endif +Index: net.c +@@ -105,6 +105,13 @@ + + #include "qemu_socket.h" +#if defined(CONFIG_PCAP) +#if defined(_WIN32) @@ -102,8 +101,8 @@ #if defined(CONFIG_SLIRP) #include "libslirp.h" #endif -@@ -3914,6 +3921,164 @@ - } +@@ -450,6 +457,164 @@ + return max_len; } +#if defined(CONFIG_PCAP) @@ -134,7 +133,7 @@ + pcap_dispatch(s->handle, 1, (pcap_handler)&pcap_callback, (u_char *)s->vc); +} + -+static int net_pcap_init(VLANState *vlan, char *ifname) ++static int net_pcap_init(VLANState *vlan, const char *model, const char *name, char *ifname) +{ + PCAPState *s = NULL; + struct bpf_program fcode = { 0, NULL }; @@ -231,7 +230,7 @@ +#endif /* HAVE_BPF */ +#endif /* _WIN32 */ + -+ s->vc = qemu_new_vlan_client(vlan, pcap_receive, NULL, s); ++ s->vc = qemu_new_vlan_client(vlan, model, name, pcap_receive, NULL, s); + snprintf(s->vc->info_str, sizeof(s->vc->info_str), "pcap redirector"); + +#if defined(_WIN32) @@ -267,7 +266,7 @@ #if defined(CONFIG_SLIRP) /* slirp network adapter */ -@@ -4983,6 +5150,16 @@ +@@ -1681,6 +1846,16 @@ are wanted */ ret = 0; } else @@ -276,14 +275,16 @@ + char ifname[64]; + vlan->nb_host_devs++; + if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) -+ ret = net_pcap_init(vlan, NULL); ++ ret = net_pcap_init(vlan, device, name, NULL); + else -+ ret = net_pcap_init(vlan, ifname); ++ ret = net_pcap_init(vlan, device, name, ifname); + } else +#endif #ifdef CONFIG_SLIRP if (!strcmp(device, "user")) { if (get_param_value(buf, sizeof(buf), "hostname", p)) { +--- vl.c.orig 2008-07-18 15:19:26.000000000 -0400 ++++ vl.c 2008-07-18 15:31:25.000000000 -0400 @@ -7398,6 +7575,10 @@ "Network options:\n" "-net nic[,vlan=n][,macaddr=addr][,model=type]\n" Index: files/patch-dynticks @@ -0,0 +1,99 @@ +Index: qemu/configure +@@ -1025,11 +1025,26 @@ + rt=yes + fi + ++########################################## ++# posix timer probe ++cat > $TMPC < ++int main(void) { timer_create(CLOCK_REALTIME, (struct sigevent *)NULL, (timer_t *)NULL); return 0; } ++EOF ++posixtimer=no ++if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then ++ posixtimer=yes ++elif $cc $ARCH_CFLAGS -o $TMPE $TMPC -lrt 2> /dev/null ; then ++ posixtimer=yes ++ rt=yes ++fi ++ + if test "$rt" = "yes" ; then + # Hack, we should have a general purpose LIBS for this sort of thing + AIOLIBS="$AIOLIBS -lrt" + fi + ++ + if test "$mingw32" = "yes" ; then + if test -z "$prefix" ; then + prefix="c:\\\\Program Files\\\\Qemu" +@@ -1403,6 +1418,9 @@ + echo "#define HAVE_FDT 1" >> $config_h + echo "FDT_LIBS=-lfdt" >> $config_mak + fi ++if test "$posixtimer" = "yes" ; then ++ echo "#define HAVE_POSIX_TIMER 1" >> $config_h ++fi + + # XXX: suppress that + if [ "$bsd" = "yes" ] ; then +Index: qemu/vl.c +@@ -918,12 +918,16 @@ + static int unix_start_timer(struct qemu_alarm_timer *t); + static void unix_stop_timer(struct qemu_alarm_timer *t); + +-#ifdef __linux__ ++#ifdef HAVE_POSIX_TIMER + + static int dynticks_start_timer(struct qemu_alarm_timer *t); + static void dynticks_stop_timer(struct qemu_alarm_timer *t); + static void dynticks_rearm_timer(struct qemu_alarm_timer *t); + ++#endif ++ ++#ifdef __linux__ ++ + static int hpet_start_timer(struct qemu_alarm_timer *t); + static void hpet_stop_timer(struct qemu_alarm_timer *t); + +@@ -1001,9 +1005,11 @@ + + static struct qemu_alarm_timer alarm_timers[] = { + #ifndef _WIN32 +-#ifdef __linux__ ++#ifdef HAVE_POSIX_TIMER + {"dynticks", ALARM_FLAG_DYNTICKS, dynticks_start_timer, + dynticks_stop_timer, dynticks_rearm_timer, NULL}, ++#endif ++#ifdef __linux__ + /* HPET - if available - is preferred */ + {"hpet", 0, hpet_start_timer, hpet_stop_timer, NULL, NULL}, + /* ...otherwise try RTC */ +@@ -1361,7 +1367,7 @@ + return delta; + } + +-#if defined(__linux__) || defined(_WIN32) ++#if defined(HAVE_POSIX_TIMER) || defined(_WIN32) + static uint64_t qemu_next_deadline_dyntick(void) + { + int64_t delta; +@@ -1506,6 +1512,10 @@ + close(rtc_fd); + } + ++#endif /* defined(__linux__) */ ++ ++#ifdef HAVE_POSIX_TIMER ++ + static int dynticks_start_timer(struct qemu_alarm_timer *t) + { + struct sigevent ev; +@@ -1577,7 +1587,7 @@ + } + } + +-#endif /* defined(__linux__) */ ++#endif /* defined(HAVE_POSIX_TIMER) */ + + static int unix_start_timer(struct qemu_alarm_timer *t) + { Index: files/patch-sigev_signo @@ -0,0 +1,30 @@ +Index: qemu/posix-aio-compat.h +@@ -29,7 +29,7 @@ + int aio_fildes; + void *aio_buf; + size_t aio_nbytes; +- int sigev_signo; ++ int ev_signo; + off_t aio_offset; + + /* private */ +Index: qemu/posix-aio-compat.c +@@ -94,7 +94,7 @@ + idle_threads++; + pthread_mutex_unlock(&lock); + +- kill(getpid(), aiocb->sigev_signo); ++ kill(getpid(), aiocb->ev_signo); + } + + idle_threads--; +Index: qemu/block-raw-posix.c +@@ -579,7 +579,7 @@ + if (!acb) + return NULL; + acb->aiocb.aio_fildes = s->fd; +- acb->aiocb.sigev_signo = SIGUSR2; ++ acb->aiocb.ev_signo = SIGUSR2; + acb->aiocb.aio_buf = buf; + if (nb_sectors < 0) + acb->aiocb.aio_nbytes = -nb_sectors;