diff -Nurb qemu-0.8.2__default_FabriceB/Makefile qemu-0.8.2-solaris__20061013fri__MB/Makefile --- qemu-0.8.2__default_FabriceB/Makefile 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/Makefile 2006-10-10 07:15:18.000000000 -0400 @@ -5,14 +5,11 @@ .PHONY: all clean distclean dvi info install install-doc tar tarbin \ speed test test2 html dvi info -CFLAGS=-Wall -O2 -g -fno-strict-aliasing -I. +CFLAGS+=-Wall -O2 -g -fno-strict-aliasing -I. ifdef CONFIG_DARWIN CFLAGS+= -mdynamic-no-pic endif -ifeq ($(ARCH),sparc) -CFLAGS+=-mcpu=ultrasparc -endif -LDFLAGS=-g +LDFLAGS+=-g LIBS= DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE TOOLS=qemu-img$(EXESUF) diff -Nurb qemu-0.8.2__default_FabriceB/Makefile.target qemu-0.8.2-solaris__20061013fri__MB/Makefile.target --- qemu-0.8.2__default_FabriceB/Makefile.target 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/Makefile.target 2006-10-10 19:37:07.000000000 -0400 @@ -17,9 +17,9 @@ VPATH+=:$(SRC_PATH)/linux-user DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) endif -CFLAGS=-Wall -O2 -g -fno-strict-aliasing +CFLAGS+=-Wall -O2 -g -fno-strict-aliasing #CFLAGS+=-Werror -LDFLAGS=-g +LDFLAGS+=-g LIBS= HELPER_CFLAGS=$(CFLAGS) DYNGEN=../dyngen$(EXESUF) @@ -108,11 +108,11 @@ ifeq ($(ARCH),sparc) ifeq ($(CONFIG_SOLARIS),yes) -CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3 +CFLAGS+=-m32 -ffixed-g2 -ffixed-g3 LDFLAGS+=-m32 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0 else -CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 +CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6 LDFLAGS+=-m32 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat @@ -122,11 +122,16 @@ endif ifeq ($(ARCH),sparc64) -CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7 +CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g2 -ffixed-g4 -ffixed-g5 -ffixed-g6 -ffixed-g7 -ffixed-l0 -ffixed-l1 -ffixed-l2 -ffixed-l3 +DEFINES+=-D__sparc_v9__ +ifeq ($(CONFIG_SOLARIS),yes) LDFLAGS+=-m64 -LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0 +else +LDFLAGS+=-m64 -Wl,-T,$(SRC_PATH)/sparc64.ld OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0 endif +endif ifeq ($(ARCH),alpha) # -msmall-data is not used because we want two-instruction relocations @@ -392,7 +397,6 @@ VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS)) endif -VL_LDFLAGS= # specific flags are needed for non soft mmu emulator ifdef CONFIG_STATIC VL_LDFLAGS+=-static @@ -417,8 +421,18 @@ endif ifeq ($(ARCH),sparc64) +ifeq ($(CONFIG_SOLARIS),yes) +VL_LDFLAGS+=-m64 +else +VL_LDFLAGS+=-m64 -Wl,-T,$(SRC_PATH)/sparc64.ld +endif +endif + +ifeq ($(CONFIG_SOLARIS),yes) +ifeq ($(ARCH),x86_64) +LDFLAGS+=-m64 VL_LDFLAGS+=-m64 -VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld +endif endif ifdef CONFIG_WIN32 diff -Nurb qemu-0.8.2__default_FabriceB/configure qemu-0.8.2-solaris__20061013fri__MB/configure --- qemu-0.8.2__default_FabriceB/configure 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/configure 2006-10-10 19:41:16.000000000 -0400 @@ -24,8 +24,19 @@ cc="gcc" host_cc="gcc" ar="ar" -make="make" -install="install" + +uname_s=`uname -s` +case "$uname_s" in + SunOS|AnyNonGNU_OS) +make="gmake" +install="ginstall" +;; + *) + make="make" + install="install" + ;; +esac + strip="strip" cpu=`uname -m` target_list="" @@ -51,7 +62,7 @@ s390) cpu="s390" ;; - sparc|sun4[muv]) + sparc|sun4[cdmuv]) cpu="sparc" ;; sparc64) @@ -96,6 +107,14 @@ user="no" build_docs="no" build_acpi_tables="no" +force_64bit="no" +force_64bitflags="" +build_for_sparcv7="no" +build_for_sparcv7flags="" +build_for_sparcv8="no" +build_for_sparcv8flags="" +build_for_sparcv8plus="no" +build_for_sparcv8plusflags="" uname_release="" # OS specific @@ -243,6 +262,42 @@ ;; --enable-iasl) build_acpi_tables="yes" ;; + --force-64bit) + force_64bit="yes" + LDFLAGS="$LDFLAGS -m64" + force_64bitflags="-m64" + case "$cpu" in + i386) + echo "Forcing 64-bit mode, changing HOST-CPU from $cpu to x86_64" + cpu="x86_64" + CFLAGS="$CFLAGS -m64 -mpreferred-stack-boundary=4 -fomit-frame-pointer" + ;; + sparc*) + echo "Developers only: Forcing 64-bit mode, changing HOST-CPU from $cpu to sparc64" + + cpu="sparc64" + CFLAGS="$CFLAGS -m64 -fomit-frame-pointer" + ;; + *) + echo "Forcing 64-bit mode" + ;; + esac + ;; + --build_for_sparcv7) + build_for_sparcv7="yes" + CFLAGS="$CFLAGS -m32 -mcpu=v7 -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; + --build_for_sparcv8) + build_for_sparcv8="yes" + CFLAGS="$CFLAGS -m32 -mcpu=v8 -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; + --build_for_sparcv8plus) + build_for_sparcv8plus="yes" + CFLAGS="$CFLAGS -m32 -mcpu=ultrasparc -fomit-frame-pointer" + LDFLAGS="$LDFLAGS -m32" + ;; esac done @@ -292,6 +347,10 @@ echo " --fmod-inc path to FMOD includes" echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --enable-iasl compilation of ACPI tables with the IASL compiler" +echo " --force-64bit force 64-bit compilation (Solaris x86/x64 only)" +echo " --build_for_sparcv7 force compilation for sparcv7 HOST-CPU" +echo " --build_for_sparcv8 force compilation for sparcv8 HOST-CPU" +echo " --build_for_sparcv8plus force compilation for sparcv8plus HOST-CPU" echo "" echo "NOTE: The object files are build at the place where configure is launched" exit 1 @@ -360,6 +419,9 @@ fi exit 1 fi + if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then + kqemu="yes" + fi fi @@ -464,7 +526,8 @@ int main( void ) { return SDL_Init (SDL_INIT_VIDEO); } EOF -if $cc -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then +if $cc $force_64bitflags $build_for_sparcv7flags $build_for_sparcv8flags $build_for_sparcv8plusflags -o $TMPE `$sdl_config --cflags 2> /dev/null` $TMPC `$sdl_config --libs 2> /dev/null` 2> /dev/null ; then + _sdlversion=`$sdl_config --version | sed 's/[^0-9]//g'` if test "$_sdlversion" -lt 121 ; then sdl_too_old=yes @@ -655,6 +718,14 @@ echo "CONFIG_SOLARIS=yes" >> $config_mak echo "#define HOST_SOLARIS $solarisrev" >> $config_h fi +if test "$build_for_sparcv8plus" = "yes" ; then + echo "CONFIG___sparc_v8plus__=yes" >> $config_mak + echo "#define __sparc_v8plus__" >> $config_h +fi +if test "$cpu" = "sparc64" ; then + echo "CONFIG___sparc_v9__=yes" >> $config_mak +# echo "#define __sparc_v9__" >> $config_h +fi if test "$gdbstub" = "yes" ; then echo "CONFIG_GDBSTUB=yes" >> $config_mak echo "#define CONFIG_GDBSTUB 1" >> $config_h diff -Nurb qemu-0.8.2__default_FabriceB/cpu-all.h qemu-0.8.2-solaris__20061013fri__MB/cpu-all.h --- qemu-0.8.2__default_FabriceB/cpu-all.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/cpu-all.h 2006-10-10 19:06:03.000000000 -0400 @@ -971,7 +971,8 @@ return val; } -#elif defined(__sparc_v9__) +/* see vl.c:576 for #defined(__sparc__) */ +#elif defined(__sparc_v8plus__) || defined(__sparc_v9__) static inline int64_t cpu_get_real_ticks (void) { diff -Nurb qemu-0.8.2__default_FabriceB/cpu-exec.c qemu-0.8.2-solaris__20061013fri__MB/cpu-exec.c --- qemu-0.8.2__default_FabriceB/cpu-exec.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/cpu-exec.c 2006-10-13 05:05:16.000000000 -0400 @@ -771,9 +771,18 @@ #else gen_func(); #endif + +#if defined(__sparc__) && !defined(TARGET_I386) && !defined(TARGET_X86_64) && !defined(TARGET_PPC) +// env->current_tb = NULL; + /* reset soft MMU for next block (it can currently + only be set by a memory fault) */ + /* sparc hosts don't seem to like this method very much */ +#else env->current_tb = NULL; /* reset soft MMU for next block (it can currently only be set by a memory fault) */ +#endif + #if defined(TARGET_I386) && !defined(CONFIG_SOFTMMU) if (env->hflags & HF_SOFTMMU_MASK) { env->hflags &= ~HF_SOFTMMU_MASK; diff -Nurb qemu-0.8.2__default_FabriceB/dyngen-exec.h qemu-0.8.2-solaris__20061013fri__MB/dyngen-exec.h --- qemu-0.8.2__default_FabriceB/dyngen-exec.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/dyngen-exec.h 2006-10-11 13:21:22.000000000 -0400 @@ -38,7 +38,7 @@ // Linux/Sparc64 defines uint64_t #if !(defined (__sparc_v9__) && defined(__linux__)) /* XXX may be done for all 64 bits targets ? */ -#if defined (__x86_64__) || defined(__ia64) +#if defined (__x86_64__) || defined(__ia64) || defined(__sparc_v9__) typedef unsigned long uint64_t; #else typedef unsigned long long uint64_t; @@ -55,7 +55,7 @@ typedef signed int int32_t; // Linux/Sparc64 defines int64_t #if !(defined (__sparc_v9__) && defined(__linux__)) -#if defined (__x86_64__) || defined(__ia64) +#if defined (__x86_64__) || defined(__ia64) || defined(__sparc_v9__) typedef signed long int64_t; #else typedef signed long long int64_t; @@ -133,12 +133,18 @@ #define AREG2 "g4" #define AREG3 "g5" #define AREG4 "g6" -#else -#ifdef __sparc_v9__ -#define AREG0 "g1" -#define AREG1 "g4" -#define AREG2 "g5" -#define AREG3 "g7" +/* + * Solaris sparcv8/v8plus versus sparcv9 ABI: g0 is always 0, g1 gets clobbered + * after function call, g2 cannot be used on v9 due to ABI and libm warning, g7 + * gets clobbered, g3 does _not_ give libm caused /usr/ccs/bin/ld MSG_STO_REGISTERG3 warning + * anymore (see http://cvs.opensolaris.org/source/raw/on/usr/src/cmd/sgs/libld/common/libld.sparc.msg), + * now that we manually define -D__sparc_v9__ and therefore g3 potentially could be a usable candidate now; + * inputs or outputs cannot be used at all, due to shifting rw, + * locals can potentially be used, if they are saved and restored each time + * (see cpu-exec.c) + * + */ + #else #define AREG0 "g6" #define AREG1 "g1" @@ -153,7 +159,6 @@ #define AREG10 "l6" #define AREG11 "l7" #endif -#endif #define USE_FP_CONVERT #endif #ifdef __s390__ diff -Nurb qemu-0.8.2__default_FabriceB/dyngen.c qemu-0.8.2-solaris__20061013fri__MB/dyngen.c --- qemu-0.8.2__default_FabriceB/dyngen.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/dyngen.c 2006-10-10 09:25:26.000000000 -0400 @@ -2270,6 +2270,32 @@ reloc_offset, reloc_offset, name, addend, reloc_offset); break; + case R_SPARC_HH22: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | (((%s + %d) >> 42) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; + + case R_SPARC_LM22: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | (((%s + %d) >> 10) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; + + case R_SPARC_HM10: + fprintf(outfile, + " *(uint32_t *)(gen_code_ptr + %d) = " + "((*(uint32_t *)(gen_code_ptr + %d)) " + " & ~0x00000000) " + " | ((((%s + %d) >> 32 & 0x3ff)) & 0x00000000);\n", + reloc_offset, reloc_offset, name, addend); + break; default: error("unsupported sparc64 relocation (%d) for symbol %s", type, name); } diff -Nurb qemu-0.8.2__default_FabriceB/elf.h qemu-0.8.2-solaris__20061013fri__MB/elf.h --- qemu-0.8.2__default_FabriceB/elf.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/elf.h 2006-10-10 09:26:57.000000000 -0400 @@ -328,6 +328,9 @@ #define R_SPARC_11 31 #define R_SPARC_64 32 #define R_SPARC_OLO10 33 +#define R_SPARC_HH22 34 +#define R_SPARC_HM10 35 +#define R_SPARC_LM22 36 #define R_SPARC_WDISP16 40 #define R_SPARC_WDISP19 41 #define R_SPARC_7 43 diff -Nurb qemu-0.8.2__default_FabriceB/hw/ide.c qemu-0.8.2-solaris__20061013fri__MB/hw/ide.c --- qemu-0.8.2__default_FabriceB/hw/ide.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/hw/ide.c 2006-10-11 03:19:22.000000000 -0400 @@ -391,6 +391,9 @@ } PCIIDEState; static void ide_dma_start(IDEState *s, IDEDMAFunc *dma_cb); +static int ide_atapi_cmd_read_dma_cb(IDEState *s, + target_phys_addr_t phys_addr, + int transfer_size1); static void padstr(char *str, const char *src, int len) { @@ -454,7 +457,7 @@ put_le16(p + 49, (1 << 11) | (1 << 9) | (1 << 8)); /* DMA and LBA supported */ put_le16(p + 51, 0x200); /* PIO transfer cycle */ put_le16(p + 52, 0x200); /* DMA transfer cycle */ - put_le16(p + 53, 1 | (1 << 1) | (1 << 2)); /* words 54-58,64-70,88 are valid */ + put_le16(p + 53, 1 | 1 << 1 | 1 << 2); /* words 54-58,64-70,88 are valid */ put_le16(p + 54, s->cylinders); put_le16(p + 55, s->heads); put_le16(p + 56, s->sectors); @@ -465,6 +468,8 @@ put_le16(p + 59, 0x100 | s->mult_sectors); put_le16(p + 60, s->nb_sectors); put_le16(p + 61, s->nb_sectors >> 16); + put_le16(p + 63, 0x07 | 0x4 << 8); /* multiword dma supported */ + put_le16(p + 64, 0x03); /* pio3 and 4 supported */ put_le16(p + 63, 0x07); /* mdma0-2 supported */ put_le16(p + 65, 120); put_le16(p + 66, 120); @@ -480,8 +485,8 @@ /* 13=flush_cache_ext,12=flush_cache,10=lba48 */ put_le16(p + 86, (1 << 14) | (1 << 13) | (1 <<12) | (1 << 10)); put_le16(p + 87, (1 << 14)); - put_le16(p + 88, 0x3f | (1 << 13)); /* udma5 set and supported */ - put_le16(p + 93, 1 | (1 << 14) | 0x2000); + put_le16(p + 88, 0x3f /*| 0x20 << 8*/); /* udma5 supported and set */ + put_le16(p + 93, 1 | (1 << 1) | (1 << 3) | (1 << 13) | (1 << 14)); put_le16(p + 100, s->nb_sectors); put_le16(p + 101, s->nb_sectors >> 16); put_le16(p + 102, s->nb_sectors >> 32); @@ -513,11 +518,11 @@ padstr((uint8_t *)(p + 23), QEMU_VERSION, 8); /* firmware version */ padstr((uint8_t *)(p + 27), "QEMU CD-ROM", 40); /* model */ put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */ - put_le16(p + 49, 1 << 9); /* LBA supported, no DMA */ - put_le16(p + 53, 3); /* words 64-70, 54-58 valid */ - put_le16(p + 63, 0x103); /* DMA modes XXX: may be incorrect */ - put_le16(p + 64, 1); /* PIO modes */ - put_le16(p + 65, 0xb4); /* minimum DMA multiword tx cycle time */ + put_le16(p + 49, 1 << 8 | 1 << 9); /* dma and lba are supported */ + put_le16(p + 53, 7); /* words 64-70, 54-58, 88 valid */ + put_le16(p + 63, 0x07 | 0x4 << 8); /* multiword dma supported / chosen */ + put_le16(p + 64, 0x03); /* pio3 and 4 supported */ + put_le16(p + 65, 0xb4); /* minimum dma multiword tx cycle time */ put_le16(p + 66, 0xb4); /* recommended DMA multiword tx cycle time */ put_le16(p + 67, 0x12c); /* minimum PIO cycle time without flow control */ put_le16(p + 68, 0xb4); /* minimum PIO cycle time with IORDY flow control */ @@ -526,6 +531,7 @@ put_le16(p + 72, 30); /* in ns */ put_le16(p + 80, 0x1e); /* support up to ATA/ATAPI-4 */ + put_le16(p + 88, 0x3f /*| 0x20 << 8*/); /* udma supported and set */ memcpy(s->identify_data, p, sizeof(s->identify_data)); s->identify_set = 1; @@ -559,6 +565,7 @@ { BMDMAState *bm = s->bmdma; if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) { + BMDMAState *bm = s->bmdma; if (bm) { bm->status |= BM_STATUS_INT; } @@ -994,8 +1001,13 @@ s->elementary_transfer_size = 0; s->io_buffer_index = 0; + if (s->atapi_dma) { + s->status = READY_STAT | DRQ_STAT; + ide_dma_start(s, ide_atapi_cmd_read_dma_cb); + } else { s->status = READY_STAT; ide_atapi_cmd_reply_end(s); + } } /* start a CD-CDROM read command */ @@ -1026,6 +1038,9 @@ #endif if (s->packet_transfer_size <= 0) break; + if (s->lba == -1) + len = s->packet_transfer_size; + else { len = s->cd_sector_size - s->io_buffer_index; if (len <= 0) { /* transfert next data */ @@ -1034,6 +1049,7 @@ s->io_buffer_index = 0; len = s->cd_sector_size; } + } if (len > transfer_size) len = transfer_size; cpu_physical_memory_write(phys_addr, @@ -2372,6 +2388,11 @@ cmd646_set_irq, d, 1); } +/* pci 0x04(word): command; 0x06(word): status */ +#define PCI_COMMAND_IOACCESS 0x0001 +#define PCI_COMMAND_MEMACCESS 0x0002 +#define PCI_COMMAND_BUSMASTER 0x0004 + /* hd_table must contain 4 block drivers */ /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */ void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn) @@ -2392,6 +2413,8 @@ pci_conf[0x02] = 0x10; pci_conf[0x03] = 0x70; pci_conf[0x09] = 0x80; // legacy ATA mode + pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS | PCI_COMMAND_BUSMASTER; + pci_conf[0x09] = 0x8a; // PCI_IDE bus master API pci_conf[0x0a] = 0x01; // class_sub = PCI_IDE pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage pci_conf[0x0e] = 0x00; // header_type diff -Nurb qemu-0.8.2__default_FabriceB/kqemu.c qemu-0.8.2-solaris__20061013fri__MB/kqemu.c --- qemu-0.8.2__default_FabriceB/kqemu.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/kqemu.c 2006-10-02 12:49:47.000000000 -0400 @@ -26,6 +26,9 @@ #include #include #endif +#ifdef HOST_SOLARIS +#include +#endif #include #include #include @@ -466,6 +469,9 @@ struct kqemu_cpu_state *kenv) { int selector; +#ifdef __x86_64__ + int code64 = env->hflags & HF_CS64_MASK; +#endif selector = (env->star >> 32) & 0xffff; #ifdef __x86_64__ @@ -485,7 +491,7 @@ DESC_S_MASK | DESC_W_MASK | DESC_A_MASK); env->eflags &= ~env->fmask; - if (env->hflags & HF_CS64_MASK) + if (code64) env->eip = env->lstar; else env->eip = env->cstar; diff -Nurb qemu-0.8.2__default_FabriceB/osdep.c qemu-0.8.2-solaris__20061013fri__MB/osdep.c --- qemu-0.8.2__default_FabriceB/osdep.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/osdep.c 2006-10-02 12:49:47.000000000 -0400 @@ -27,6 +27,10 @@ #include #include #include +#ifdef HOST_SOLARIS +#include +#include +#endif #include "cpu.h" #if defined(USE_KQEMU) @@ -339,13 +343,23 @@ const char *tmpdir; char phys_ram_file[1024]; void *ptr; +#ifdef HOST_SOLARIS + struct statvfs stfs; +#else struct statfs stfs; +#endif if (phys_ram_fd < 0) { tmpdir = getenv("QEMU_TMPDIR"); +#ifdef HOST_SOLARIS + if (!tmpdir) + tmpdir = "/tmp"; + if (statvfs(tmpdir, &stfs) == 0) { +#else if (!tmpdir) tmpdir = "/dev/shm"; if (statfs(tmpdir, &stfs) == 0) { +#endif int64_t free_space; int ram_mb; diff -Nurb qemu-0.8.2__default_FabriceB/target-arm/exec.h qemu-0.8.2-solaris__20061013fri__MB/target-arm/exec.h --- qemu-0.8.2__default_FabriceB/target-arm/exec.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-arm/exec.h 2006-10-13 04:10:04.000000000 -0400 @@ -19,10 +19,17 @@ */ #include "dyngen-exec.h" +#if defined(__sparc__) +struct CPUARMState *env; +uint32_t T0; +uint32_t T1; +uint32_t T2; +#else register struct CPUARMState *env asm(AREG0); register uint32_t T0 asm(AREG1); register uint32_t T1 asm(AREG2); register uint32_t T2 asm(AREG3); +#endif /* TODO: Put these in FP regs on targets that have such things. */ /* It is ok for FT0s and FT0d to overlap. Likewise FT1s and FT1d. */ diff -Nurb qemu-0.8.2__default_FabriceB/target-i386/cpu.h qemu-0.8.2-solaris__20061013fri__MB/target-i386/cpu.h --- qemu-0.8.2__default_FabriceB/target-i386/cpu.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-i386/cpu.h 2006-10-02 12:49:47.000000000 -0400 @@ -258,6 +258,7 @@ #define CPUID_MCA (1 << 14) #define CPUID_CMOV (1 << 15) #define CPUID_PAT (1 << 16) +#define CPUID_PSE36 (1 << 17) #define CPUID_CLFLUSH (1 << 19) /* ... */ #define CPUID_MMX (1 << 23) diff -Nurb qemu-0.8.2__default_FabriceB/target-i386/helper.c qemu-0.8.2-solaris__20061013fri__MB/target-i386/helper.c --- qemu-0.8.2__default_FabriceB/target-i386/helper.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-i386/helper.c 2006-10-02 12:49:47.000000000 -0400 @@ -553,6 +553,20 @@ return 0xffff; } +#ifdef TARGET_X86_64 +#define SET_ESP(val, sp_mask)\ +do {\ + if ((sp_mask) == 0xffff)\ + ESP = (ESP & ~0xffff) | ((val) & 0xffff);\ + else if ((sp_mask) == 0xffffffffLL)\ + ESP = (uint32_t)(val);\ + else\ + ESP = (val);\ +} while (0) +#else +#define SET_ESP(val, sp_mask) ESP = (ESP & ~(sp_mask)) | ((val) & (sp_mask)) +#endif + /* XXX: add a is_user flag to have proper security support */ #define PUSHW(ssp, sp, sp_mask, val)\ {\ @@ -584,10 +598,10 @@ { SegmentCache *dt; target_ulong ptr, ssp; - int type, dpl, selector, ss_dpl, cpl, sp_mask; + int type, dpl, selector, ss_dpl, cpl; int has_error_code, new_stack, shift; uint32_t e1, e2, offset, ss, esp, ss_e1, ss_e2; - uint32_t old_eip; + uint32_t old_eip, sp_mask; has_error_code = 0; if (!is_int && !is_hw) { @@ -623,7 +637,8 @@ raise_exception_err(EXCP0B_NOSEG, intno * 8 + 2); switch_tss(intno * 8, e1, e2, SWITCH_TSS_CALL, old_eip); if (has_error_code) { - int mask, type; + int type; + uint32_t mask; /* push the error code */ type = (env->tr.flags >> DESC_TYPE_SHIFT) & 0xf; shift = type >> 3; @@ -637,7 +652,7 @@ stl_kernel(ssp, error_code); else stw_kernel(ssp, error_code); - ESP = (esp & mask) | (ESP & ~mask); + SET_ESP(esp, mask); } return; case 6: /* 286 interrupt gate */ @@ -765,7 +780,7 @@ cpu_x86_load_seg_cache(env, R_SS, ss, ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); } - ESP = (ESP & ~sp_mask) | (esp & sp_mask); + SET_ESP(esp, sp_mask); selector = (selector & ~3) | dpl; cpu_x86_load_seg_cache(env, R_CS, selector, @@ -1732,7 +1747,7 @@ PUSHW(ssp, esp, esp_mask, next_eip); } - ESP = (ESP & ~esp_mask) | (esp & esp_mask); + SET_ESP(esp, esp_mask); env->eip = new_eip; env->segs[R_CS].selector = new_cs; env->segs[R_CS].base = (new_cs << 4); @@ -1818,7 +1833,7 @@ if (new_eip > limit) raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); /* from this point, not restartable */ - ESP = (ESP & ~sp_mask) | (sp & sp_mask); + SET_ESP(sp, sp_mask); cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, get_seg_base(e1, e2), limit, e2); EIP = new_eip; @@ -1947,7 +1962,7 @@ get_seg_limit(e1, e2), e2); cpu_x86_set_cpl(env, dpl); - ESP = (ESP & ~sp_mask) | (sp & sp_mask); + SET_ESP(sp, sp_mask); EIP = offset; } #ifdef USE_KQEMU @@ -1980,7 +1995,7 @@ POPW(ssp, sp, sp_mask, new_cs); POPW(ssp, sp, sp_mask, new_eflags); } - ESP = (ESP & ~sp_mask) | (sp & sp_mask); + SET_ESP(sp, sp_mask); load_seg_vm(R_CS, new_cs); env->eip = new_eip; if (env->eflags & VM_MASK) @@ -2176,7 +2191,7 @@ sp += addend; } - ESP = (ESP & ~sp_mask) | (sp & sp_mask); + SET_ESP(sp, sp_mask); env->eip = new_eip; if (is_iret) { /* NOTE: 'cpl' is the _old_ CPL */ diff -Nurb qemu-0.8.2__default_FabriceB/target-i386/helper2.c qemu-0.8.2-solaris__20061013fri__MB/target-i386/helper2.c --- qemu-0.8.2__default_FabriceB/target-i386/helper2.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-i386/helper2.c 2006-10-10 19:10:24.000000000 -0400 @@ -92,7 +92,7 @@ env->cpuid_vendor1 = 0x756e6547; /* "Genu" */ env->cpuid_vendor2 = 0x49656e69; /* "ineI" */ env->cpuid_vendor3 = 0x6c65746e; /* "ntel" */ -#if 0 +#if (0==1) /* pentium 75-200 */ family = 5; model = 2; @@ -135,6 +135,8 @@ /* these features are needed for Win64 and aren't fully implemented */ env->cpuid_features |= CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA; + /* these features are needed for Solaris and aren't fully implemented */ + env->cpuid_features |= CPUID_PSE36; #endif } cpu_reset(env); diff -Nurb qemu-0.8.2__default_FabriceB/target-mips/exec.h qemu-0.8.2-solaris__20061013fri__MB/target-mips/exec.h --- qemu-0.8.2__default_FabriceB/target-mips/exec.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-mips/exec.h 2006-10-13 03:47:13.000000000 -0400 @@ -6,7 +6,11 @@ #include "mips-defs.h" #include "dyngen-exec.h" +#if defined(__sparc__) +struct CPUMIPSState *env; +#else register struct CPUMIPSState *env asm(AREG0); +#endif #if defined (USE_64BITS_REGS) typedef int64_t host_int_t; @@ -16,9 +20,15 @@ typedef uint32_t host_uint_t; #endif +#if defined(__sparc__) +host_uint_t T0; +host_uint_t T1; +host_uint_t T2; +#else register host_uint_t T0 asm(AREG1); register host_uint_t T1 asm(AREG2); register host_uint_t T2 asm(AREG3); +#endif #if defined (USE_HOST_FLOAT_REGS) #error "implement me." diff -Nurb qemu-0.8.2__default_FabriceB/target-sparc/exec.h qemu-0.8.2-solaris__20061013fri__MB/target-sparc/exec.h --- qemu-0.8.2__default_FabriceB/target-sparc/exec.h 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/target-sparc/exec.h 2006-10-13 03:23:09.000000000 -0400 @@ -3,23 +3,41 @@ #include "dyngen-exec.h" #include "config.h" +#if defined(__sparc__) +struct CPUSPARCState *env; +#else register struct CPUSPARCState *env asm(AREG0); +#endif + #ifdef TARGET_SPARC64 #define T0 (env->t0) #define T1 (env->t1) #define T2 (env->t2) #define REGWPTR env->regwptr #else +#if defined(__sparc__) +register uint32_t T0 asm(AREG3); +register uint32_t T1 asm(AREG2); +#else register uint32_t T0 asm(AREG1); register uint32_t T1 asm(AREG2); +#endif #undef REG_REGWPTR // Broken #ifdef REG_REGWPTR +#if defined(__sparc__) +register uint32_t *REGWPTR asm(AREG4); +#else register uint32_t *REGWPTR asm(AREG3); +#endif #define reg_REGWPTR #ifdef AREG4 +#if defined(__sparc__) +register uint32_t T2 asm(AREG0); +#else register uint32_t T2 asm(AREG4); +#endif #define reg_T2 #else #define T2 (env->t2) @@ -27,7 +45,11 @@ #else #define REGWPTR env->regwptr +#if defined(__sparc__) +register uint32_t T2 asm(AREG0); +#else register uint32_t T2 asm(AREG3); +#endif #define reg_T2 #endif #endif diff -Nurb qemu-0.8.2__default_FabriceB/vl.c qemu-0.8.2-solaris__20061013fri__MB/vl.c --- qemu-0.8.2__default_FabriceB/vl.c 2006-07-22 13:23:34.000000000 -0400 +++ qemu-0.8.2-solaris__20061013fri__MB/vl.c 2006-10-10 19:15:32.000000000 -0400 @@ -572,6 +572,44 @@ #endif /***********************************************************/ + +#if defined(__sparc__) && !defined(__sparc_v8plus__) && !defined(__sparc_v9__) + /* + * Derived from: "m68k updates #2" by Richard Zidlicky + * "crude hack to get some sort of rdtsc support" + * + * Cannot go into header file and therefore went into + * historical location in vl.c,rather than into cpu-all.h + * + * Allows you to easily set the guest's virtual core clock to an + * almost arbitrary value (that is, as how fast the virtual cpus + * should identifiy themselves to the guest OS / guest software). + * + */ + +#include +static int64_t cputicks=0; +static struct timeval lastcptcall={0,0}; + +// assume 4.0 GHz virtual cpu, min 80 ticks between rdtsc calls + +int64_t cpu_get_real_ticks(void) + { + struct timeval tp; + gettimeofday(&tp,(void*)0); + if (tp.tv_sec == lastcptcall.tv_sec && + tp.tv_usec == lastcptcall.tv_usec ){ + cputicks += 1; + } else { + cputicks=0; + lastcptcall=tp; + } + return ((int64_t)tp.tv_sec*1000000+tp.tv_usec)*4000+cputicks; + } + +#endif + + /* guest cycle counter */ static int64_t cpu_ticks_prev; diff -Nurb qemu-0.8.2__default_FabriceB/x86-64_softmmu/config.h qemu-0.8.2-solaris__20061013fri__MB/x86-64_softmmu/config.h --- qemu-0.8.2__default_FabriceB/x86-64_softmmu/config.h 1969-12-31 19:00:00.000000000 -0500 +++ qemu-0.8.2-solaris__20061013fri__MB/x86-64_softmmu/config.h 2006-10-10 11:08:33.000000000 -0400 @@ -0,0 +1,3 @@ +/* Automatically generated by configure - do not modify */ +#include "../config-host.h" +#define CONFIG_QEMU_PREFIX "/usr/gnemul/qemu-x86" diff -Nurb qemu-0.8.2__default_FabriceB/x86-64_softmmu/config.mak qemu-0.8.2-solaris__20061013fri__MB/x86-64_softmmu/config.mak --- qemu-0.8.2__default_FabriceB/x86-64_softmmu/config.mak 1969-12-31 19:00:00.000000000 -0500 +++ qemu-0.8.2-solaris__20061013fri__MB/x86-64_softmmu/config.mak 2006-10-10 11:08:33.000000000 -0400 @@ -0,0 +1,2 @@ +# Automatically generated by configure - do not modify +include ../config-host.mak