source: trunk/packages/xen-common/xen-common/tools/ioemu/patches/xen-mm @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 4.5 KB
Line 
1Index: ioemu/hw/pc.c
2===================================================================
3--- ioemu.orig/hw/pc.c  2007-05-03 09:54:24.000000000 +0100
4+++ ioemu/hw/pc.c       2007-05-03 09:56:32.000000000 +0100
5@@ -646,7 +646,9 @@
6     }
7 
8     /* allocate RAM */
9+#ifndef CONFIG_DM              /* HVM domain owns memory */
10     cpu_register_physical_memory(0, ram_size, 0);
11+#endif
12 
13     /* BIOS load */
14     bios_offset = ram_size + vga_ram_size;
15@@ -678,8 +680,10 @@
16     ret = load_image(buf, phys_ram_base + vga_bios_offset);
17     
18     /* setup basic memory access */
19+#ifndef CONFIG_DM              /* HVM domain owns memory */
20     cpu_register_physical_memory(0xc0000, 0x10000,
21                                  vga_bios_offset | IO_MEM_ROM);
22+#endif
23 
24     /* map the last 128KB of the BIOS in ISA space */
25     isa_bios_size = bios_size;
26Index: ioemu/vl.c
27===================================================================
28--- ioemu.orig/vl.c     2007-05-03 09:54:24.000000000 +0100
29+++ ioemu/vl.c  2007-05-03 10:04:06.000000000 +0100
30@@ -88,6 +88,7 @@
31 
32 #include "exec-all.h"
33 
34+#include <xen/hvm/params.h>
35 #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup"
36 
37 //#define DEBUG_UNUSED_IOPORT
38@@ -158,6 +159,8 @@
39 int acpi_enabled = 1;
40 int fd_bootchk = 1;
41 
42+int xc_handle;
43+
44 char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'};
45 extern int domid;
46 
47@@ -5650,6 +5653,9 @@
48     QEMUMachine *machine;
49     char usb_devices[MAX_USB_CMDLINE][128];
50     int usb_devices_index;
51+    unsigned long ioreq_pfn;
52+    extern void *shared_page;
53+    unsigned long nr_pages;
54 
55     char qemu_dm_logfilename[64];
56 
57@@ -5921,11 +5927,13 @@
58                 ram_size = atol(optarg) * 1024 * 1024;
59                 if (ram_size <= 0)
60                     help();
61+#ifndef CONFIG_DM
62                 if (ram_size > PHYS_RAM_MAX_SIZE) {
63                     fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n",
64                             PHYS_RAM_MAX_SIZE / (1024 * 1024));
65                     exit(1);
66                 }
67+#endif /* !CONFIG_DM */
68                 break;
69             case QEMU_OPTION_l:
70                 {
71@@ -6137,12 +6145,53 @@
72     /* init the memory */
73     phys_ram_size = ram_size + vga_ram_size + bios_size;
74 
75+#ifdef CONFIG_DM
76+
77+    xc_handle = xc_interface_open();
78+
79+#if defined(__i386__) || defined(__x86_64__)
80+
81+    nr_pages = ram_size/PAGE_SIZE;
82+
83+    page_array = (xen_pfn_t *)malloc(nr_pages * sizeof(xen_pfn_t));
84+    if (page_array == NULL) {
85+        fprintf(logfile, "malloc returned error %d\n", errno);
86+        exit(-1);
87+    }
88+
89+    for ( i = 0; i < nr_pages; i++)
90+        page_array[i] = i;
91+
92+    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
93+                                         PROT_READ|PROT_WRITE, page_array,
94+                                         nr_pages);
95+    if (phys_ram_base == NULL) {
96+        fprintf(logfile, "batch map guest memory returned error %d\n", errno);
97+        exit(-1);
98+    }
99+
100+    xc_get_hvm_param(xc_handle, domid, HVM_PARAM_IOREQ_PFN, &ioreq_pfn);
101+    fprintf(logfile, "shared page at pfn %lx\n", ioreq_pfn);
102+    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
103+                                       PROT_READ|PROT_WRITE,
104+                                       page_array[ioreq_pfn]);
105+    if (shared_page == NULL) {
106+        fprintf(logfile, "map shared IO page returned error %d\n", errno);
107+        exit(-1);
108+    }
109+
110+    free(page_array);
111+
112+#else  /* !CONFIG_DM */
113+
114     phys_ram_base = qemu_vmalloc(phys_ram_size);
115     if (!phys_ram_base) {
116         fprintf(stderr, "Could not allocate physical memory\n");
117         exit(1);
118     }
119 
120+#endif /* !CONFIG_DM */
121+
122     /* we always create the cdrom drive, even if no disk is there */
123     bdrv_init();
124     if (cdrom_index >= 0) {
125Index: ioemu/hw/piix_pci.c
126===================================================================
127--- ioemu.orig/hw/piix_pci.c    2007-05-03 09:54:18.000000000 +0100
128+++ ioemu/hw/piix_pci.c 2007-05-03 09:56:32.000000000 +0100
129@@ -399,7 +399,7 @@
130     uint8_t elcr[2];
131 
132     pci_bios_io_addr = 0xc000;
133-    pci_bios_mem_addr = 0xf0000000;
134+    pci_bios_mem_addr = HVM_BELOW_4G_MMIO_START;
135 
136     /* activate IRQ mappings */
137     elcr[0] = 0x00;
138Index: ioemu/vl.h
139===================================================================
140--- ioemu.orig/vl.h     2007-05-03 09:54:24.000000000 +0100
141+++ ioemu/vl.h  2007-05-03 09:56:32.000000000 +0100
142@@ -39,6 +39,7 @@
143 #include <sys/stat.h>
144 #include "xenctrl.h"
145 #include "xs.h"
146+#include <xen/hvm/e820.h>
147 
148 #ifndef O_LARGEFILE
149 #define O_LARGEFILE 0
Note: See TracBrowser for help on using the repository browser.