Index: ioemu/hw/pc.c =================================================================== --- ioemu.orig/hw/pc.c 2007-05-03 19:08:13.000000000 +0100 +++ ioemu/hw/pc.c 2007-05-03 19:08:19.000000000 +0100 @@ -481,7 +481,9 @@ } /* allocate RAM */ +#ifndef CONFIG_DM /* HVM domain owns memory */ cpu_register_physical_memory(0, ram_size, 0); +#endif /* BIOS load */ bios_offset = ram_size + vga_ram_size; @@ -510,8 +512,10 @@ ret = load_image(buf, phys_ram_base + vga_bios_offset); /* setup basic memory access */ +#ifndef CONFIG_DM /* HVM domain owns memory */ cpu_register_physical_memory(0xc0000, 0x10000, vga_bios_offset | IO_MEM_ROM); +#endif /* map the last 128KB of the BIOS in ISA space */ isa_bios_size = bios_size; Index: ioemu/vl.c =================================================================== --- ioemu.orig/vl.c 2007-05-03 19:08:13.000000000 +0100 +++ ioemu/vl.c 2007-05-03 19:08:57.000000000 +0100 @@ -89,6 +89,7 @@ #include "exec-all.h" +#include #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup" #ifdef __sun__ #define SMBD_COMMAND "/usr/sfw/sbin/smbd" @@ -175,6 +176,8 @@ int semihosting_enabled = 0; int autostart = 1; +int xc_handle; + char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'}; extern int domid; @@ -6565,6 +6568,9 @@ char usb_devices[MAX_USB_CMDLINE][128]; int usb_devices_index; int fds[2]; + unsigned long ioreq_pfn; + extern void *shared_page; + unsigned long nr_pages; char qemu_dm_logfilename[64]; @@ -6839,11 +6845,13 @@ ram_size = atol(optarg) * 1024 * 1024; if (ram_size <= 0) help(); +#ifndef CONFIG_DM if (ram_size > PHYS_RAM_MAX_SIZE) { fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n", PHYS_RAM_MAX_SIZE / (1024 * 1024)); exit(1); } +#endif /* !CONFIG_DM */ break; case QEMU_OPTION_l: { @@ -7153,12 +7161,53 @@ phys_ram_size += ret; } +#ifdef CONFIG_DM + + xc_handle = xc_interface_open(); + +#if defined(__i386__) || defined(__x86_64__) + + nr_pages = ram_size/PAGE_SIZE; + + page_array = (xen_pfn_t *)malloc(nr_pages * sizeof(xen_pfn_t)); + if (page_array == NULL) { + fprintf(logfile, "malloc returned error %d\n", errno); + exit(-1); + } + + for ( i = 0; i < nr_pages; i++) + page_array[i] = i; + + phys_ram_base = xc_map_foreign_batch(xc_handle, domid, + PROT_READ|PROT_WRITE, page_array, + nr_pages); + if (phys_ram_base == NULL) { + fprintf(logfile, "batch map guest memory returned error %d\n", errno); + exit(-1); + } + + xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn); + fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn); + shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE, + PROT_READ|PROT_WRITE, + page_array[ioreq_pfn]); + if (shared_page == NULL) { + fprintf(logfile, "map shared IO page returned error %d\n", errno); + exit(-1); + } + + free(page_array); + +#else /* !CONFIG_DM */ + phys_ram_base = qemu_vmalloc(phys_ram_size); if (!phys_ram_base) { fprintf(stderr, "Could not allocate physical memory\n"); exit(1); } +#endif /* !CONFIG_DM */ + /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); if (cdrom_index >= 0) { Index: ioemu/vl.h =================================================================== --- ioemu.orig/vl.h 2007-05-03 19:08:13.000000000 +0100 +++ ioemu/vl.h 2007-05-03 19:08:19.000000000 +0100 @@ -39,6 +39,7 @@ #include #include "xenctrl.h" #include "xs.h" +#include #ifndef O_LARGEFILE #define O_LARGEFILE 0