Commit 67b915a5 authored by Fabrice Bellard's avatar Fabrice Bellard
Browse files

win32 port (initial patch by kazu)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@692 c046a42c-6fe2-441c-8c8c-71466251a162
parent bb27c190
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ version 0.5.3:
  - VM save/restore commands
  - new timer API
  - more precise RTC emulation (periodic timers + time updates)
  - Win32 port (initial patch by Kazu)

version 0.5.2:

+8 −3
Original line number Diff line number Diff line
include config-host.mak

CFLAGS=-Wall -O2 -g
ifdef CONFIG_WIN32
CFLAGS+=-fpack-struct 
endif
LDFLAGS=-g
LIBS=
DEFINES+=-D_GNU_SOURCE
ifndef CONFIG_WIN32
TOOLS=qemu-mkcow
endif

all: dyngen $(TOOLS) qemu-doc.html qemu.1
all: dyngen$(EXESUF) $(TOOLS) qemu-doc.html qemu.1
	for d in $(TARGET_DIRS); do \
	make -C $$d $@ || exit 1 ; \
        done
@@ -14,7 +19,7 @@ all: dyngen $(TOOLS) qemu-doc.html qemu.1
qemu-mkcow: qemu-mkcow.o
	$(HOST_CC) -o $@ $^  $(LIBS)

dyngen: dyngen.o
dyngen$(EXESUF): dyngen.o
	$(HOST_CC) -o $@ $^  $(LIBS)

%.o: %.c
@@ -23,7 +28,7 @@ dyngen: dyngen.o
clean:
# avoid old build problems by removing potentially incorrect old files
	rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h 
	rm -f *.o *.a $(TOOLS) dyngen TAGS qemu.pod
	rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS qemu.pod
	make -C tests clean
	for d in $(TARGET_DIRS); do \
	make -C $$d $@ || exit 1 ; \
+9 −3
Original line number Diff line number Diff line
@@ -11,12 +11,12 @@ CFLAGS=-Wall -O2 -g
LDFLAGS=-g
LIBS=
HELPER_CFLAGS=$(CFLAGS)
DYNGEN=../dyngen
DYNGEN=../dyngen$(EXESUF)
# user emulator name
QEMU_USER=qemu-$(TARGET_ARCH)
# system emulator name
ifdef CONFIG_SOFTMMU
QEMU_SYSTEM=qemu
QEMU_SYSTEM=qemu$(EXESUF)
else
QEMU_SYSTEM=qemu-fast
endif
@@ -146,6 +146,9 @@ endif

DEFINES+=-D_GNU_SOURCE
LIBS+=-lm
ifdef CONFIG_WIN32
LIBS+=-lwinmm
endif

# profiling code
ifdef TARGET_GPROF
@@ -219,9 +222,12 @@ ifeq ($(ARCH),alpha)
endif

# must use static linking to avoid leaving stuff in virtual address space
VL_OBJS=vl.o osdep.o block.o monitor.o gdbstub.o \
VL_OBJS=vl.o osdep.o block.o monitor.o \
        ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o \
        fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
ifdef CONFIG_GDBSTUB
VL_OBJS+=gdbstub.o 
endif
ifeq ($(TARGET_ARCH), ppc)
VL_OBJS+= hw.o
endif
+4 −1
Original line number Diff line number Diff line
short term:
----------
- handle fast timers + add explicit clocks
- OS/2 install bug
- win 95 install bug
- handle Self Modifying Code even if modifying current TB (BE OS 5 install)
- physical memory cache (reduce qemu-fast address space size to about 32 MB)
- better code fetch
- XP security bug
- handle Self Modifying Code even if modifying current TB (BE OS 5 install)
- cycle counter for all archs
- TLB code protection support for PPC
- add sysenter/sysexit and fxsr for L4 pistachio 686
+27 −27
Original line number Diff line number Diff line
@@ -21,29 +21,11 @@
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <getopt.h>
#include <inttypes.h>
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#include <malloc.h>
#include <termios.h>
#include <sys/poll.h>
#include <errno.h>
#include <sys/wait.h>
#include <netinet/in.h>

#include "vl.h"

#define NO_THUNK_TYPE_SIZE
#include "thunk.h"
#ifndef _WIN32
#include <sys/mman.h>
#endif

#include "cow.h"

@@ -97,11 +79,14 @@ BlockDriverState *bdrv_new(const char *device_name)

int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
{
    int fd, cow_fd;
    int fd;
    int64_t size;
    char template[] = "/tmp/vl.XXXXXX";
    struct cow_header_v2 cow_header;
#ifndef _WIN32
    char template[] = "/tmp/vl.XXXXXX";
    int cow_fd;
    struct stat st;
#endif

    bs->read_only = 0;
    bs->fd = -1;
@@ -110,10 +95,18 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
    strcpy(bs->filename, filename);

    /* open standard HD image */
#ifdef _WIN32
    fd = open(filename, O_RDWR | O_BINARY);
#else
    fd = open(filename, O_RDWR | O_LARGEFILE);
#endif
    if (fd < 0) {
        /* read only image on disk */
#ifdef _WIN32
        fd = open(filename, O_RDONLY | O_BINARY);
#else
        fd = open(filename, O_RDONLY | O_LARGEFILE);
#endif
        if (fd < 0) {
            perror(filename);
            goto fail;
@@ -128,8 +121,9 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
        fprintf(stderr, "%s: could not read header\n", filename);
        goto fail;
    }
    if (cow_header.magic == htonl(COW_MAGIC) &&
        cow_header.version == htonl(COW_VERSION)) {
#ifndef _WIN32
    if (be32_to_cpu(cow_header.magic) == COW_MAGIC &&
        be32_to_cpu(cow_header.version) == COW_VERSION) {
        /* cow image found */
        size = cow_header.size;
#ifndef WORDS_BIGENDIAN
@@ -144,7 +138,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
                fprintf(stderr, "%s: could not find original disk image '%s'\n", filename, cow_header.backing_file);
                goto fail;
            }
            if (st.st_mtime != htonl(cow_header.mtime)) {
            if (st.st_mtime != be32_to_cpu(cow_header.mtime)) {
                fprintf(stderr, "%s: original raw disk image '%s' does not match saved timestamp\n", filename, cow_header.backing_file);
                goto fail;
            }
@@ -164,13 +158,16 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
        bs->cow_bitmap = bs->cow_bitmap_addr + sizeof(cow_header);
        bs->cow_sectors_offset = (bs->cow_bitmap_size + 511) & ~511;
        snapshot = 0;
    } else {
    } else 
#endif
    {
        /* standard raw image */
        size = lseek64(fd, 0, SEEK_END);
        bs->total_sectors = size / 512;
        bs->fd = fd;
    }

#ifndef _WIN32
    if (snapshot) {
        /* create a temporary COW file */
        cow_fd = mkstemp(template);
@@ -190,6 +187,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
        bs->cow_bitmap = bs->cow_bitmap_addr;
        bs->cow_sectors_offset = 0;
    }
#endif
    
    bs->inserted = 1;

@@ -206,9 +204,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot)
void bdrv_close(BlockDriverState *bs)
{
    if (bs->inserted) {
#ifndef _WIN32
        /* we unmap the mapping so that it is written to the COW file */
        if (bs->cow_bitmap_addr)
            munmap(bs->cow_bitmap_addr, bs->cow_bitmap_size);
#endif
        if (bs->cow_fd >= 0)
            close(bs->cow_fd);
        if (bs->fd >= 0)
Loading