# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID c92fbde4074d698025204ed959755719a140e9af
# Parent 062d109ce87292cef784db169add4c649879200d
Move set/unset_vram_mapping into cirrus_vga.c, pending a fixup patch.
Signed-off-by: Yunhong Jiang <yunhong.jiang@xxxxxxxxx>
---
tools/ioemu/hw/cirrus_vga.c | 92 ++++++++++++++++++++++++++++++++++++++++++-
tools/ioemu/vl.c | 93 --------------------------------------------
tools/ioemu/vl.h | 15 +++++++
3 files changed, 106 insertions(+), 94 deletions(-)
diff -r 062d109ce872 -r c92fbde4074d tools/ioemu/hw/cirrus_vga.c
--- a/tools/ioemu/hw/cirrus_vga.c Thu May 11 22:39:44 2006 +0100
+++ b/tools/ioemu/hw/cirrus_vga.c Fri May 12 15:15:59 2006 +0100
@@ -28,6 +28,9 @@
*/
#include "vl.h"
#include "vga_int.h"
+#ifndef _WIN32
+#include <sys/mman.h>
+#endif
/*
* TODO:
@@ -2455,13 +2458,96 @@ static CPUWriteMemoryFunc *cirrus_linear
cirrus_linear_bitblt_writel,
};
+extern FILE *logfile;
+#if defined(__i386__) || defined (__x86_64__)
+static void * set_vram_mapping(unsigned long begin, unsigned long end)
+{
+ unsigned long * extent_start = NULL;
+ unsigned long nr_extents;
+ void *vram_pointer = NULL;
+ int i;
+
+ /* align begin and end address */
+ begin = begin & TARGET_PAGE_MASK;
+ end = begin + VGA_RAM_SIZE;
+ end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
+ nr_extents = (end - begin) >> TARGET_PAGE_BITS;
+
+ extent_start = malloc(sizeof(unsigned long) * nr_extents );
+ if (extent_start == NULL)
+ {
+ fprintf(stderr, "Failed malloc on set_vram_mapping\n");
+ return NULL;
+ }
+
+ memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+
+ for (i = 0; i < nr_extents; i++)
+ {
+ extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
+ }
+
+ set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+
+ if ( (vram_pointer = xc_map_foreign_batch(xc_handle, domid,
+ PROT_READ|PROT_WRITE,
+ extent_start,
+ nr_extents)) == NULL)
+ {
+ fprintf(logfile,
+ "xc_map_foreign_batch vgaram returned error %d\n", errno);
+ return NULL;
+ }
+
+ memset(vram_pointer, 0, nr_extents * TARGET_PAGE_SIZE);
+
+ free(extent_start);
+
+ return vram_pointer;
+}
+
+static int unset_vram_mapping(unsigned long begin, unsigned long end)
+{
+ unsigned long * extent_start = NULL;
+ unsigned long nr_extents;
+ int i;
+
+ /* align begin and end address */
+
+ end = begin + VGA_RAM_SIZE;
+ begin = begin & TARGET_PAGE_MASK;
+ end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
+ nr_extents = (end - begin) >> TARGET_PAGE_BITS;
+
+ extent_start = malloc(sizeof(unsigned long) * nr_extents );
+
+ if (extent_start == NULL)
+ {
+ fprintf(stderr, "Failed malloc on set_mm_mapping\n");
+ return -1;
+ }
+
+ memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
+
+ for (i = 0; i < nr_extents; i++)
+ extent_start[i] = (begin + (i * TARGET_PAGE_SIZE)) >> TARGET_PAGE_BITS;
+
+ unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
+
+ free(extent_start);
+
+ return 0;
+}
+
+#elif defined(__ia64__)
+static void * set_vram_mapping(unsigned long addr, unsigned long end) {}
+static int unset_vram_mapping(unsigned long addr, unsigned long end) {}
+#endif
+
/* Compute the memory access functions */
static void cirrus_update_memory_access(CirrusVGAState *s)
{
unsigned mode;
- extern void * set_vram_mapping(unsigned long addr, unsigned long end);
-
- extern int unset_vram_mapping(unsigned long addr, unsigned long end);
extern int vga_accelerate;
if ((s->sr[0x17] & 0x44) == 0x44) {
diff -r 062d109ce872 -r c92fbde4074d tools/ioemu/vl.c
--- a/tools/ioemu/vl.c Thu May 11 22:39:44 2006 +0100
+++ b/tools/ioemu/vl.c Fri May 12 15:15:59 2006 +0100
@@ -75,8 +75,6 @@
#endif
#endif /* CONFIG_SDL */
-#include "xenctrl.h"
-#include "xs.h"
#include "exec-all.h"
//#define DO_TB_FLUSH
@@ -2456,7 +2454,6 @@ static uint8_t *signal_stack;
#include <xg_private.h>
-#if defined(__i386__) || defined (__x86_64__)
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
@@ -2484,7 +2481,7 @@ get_vl2_table(unsigned long count, unsig
}
/* FIXME Flush the shadow page */
-static int unset_mm_mapping(int xc_handle,
+int unset_mm_mapping(int xc_handle,
uint32_t domid,
unsigned long nr_pages,
unsigned int address_bits,
@@ -2517,13 +2514,12 @@ static int unset_mm_mapping(int xc_handl
return err;
}
-static int set_mm_mapping(int xc_handle,
+int set_mm_mapping(int xc_handle,
uint32_t domid,
unsigned long nr_pages,
unsigned int address_bits,
unsigned long *extent_start)
{
- int i;
xc_dominfo_t info;
int err = 0;
@@ -2563,91 +2559,6 @@ static int set_mm_mapping(int xc_handle,
return 0;
}
-
-
-void * set_vram_mapping(unsigned long begin, unsigned long end)
-{
- unsigned long * extent_start = NULL;
- unsigned long nr_extents;
- void *vram_pointer = NULL;
- int i;
-
- /* align begin and end address */
- begin = begin & PAGE_MASK;
- end = begin + VGA_RAM_SIZE;
- end = (end + PAGE_SIZE -1 )& PAGE_MASK;
- nr_extents = (end - begin) >> PAGE_SHIFT;
-
- extent_start = malloc(sizeof(unsigned long) * nr_extents );
- if (extent_start == NULL)
- {
- fprintf(stderr, "Failed malloc on set_vram_mapping\n");
- return NULL;
- }
-
- memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
-
- for (i = 0; i < nr_extents; i++)
- {
- extent_start[i] = (begin + i * PAGE_SIZE) >> PAGE_SHIFT;
- }
-
- set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
-
- if ( (vram_pointer = xc_map_foreign_batch(xc_handle, domid,
- PROT_READ|PROT_WRITE,
- extent_start,
- nr_extents)) == NULL)
- {
- fprintf(logfile,
- "xc_map_foreign_batch vgaram returned error %d\n", errno);
- return NULL;
- }
-
- memset(vram_pointer, 0, nr_extents * PAGE_SIZE);
-
- free(extent_start);
-
- return vram_pointer;
-}
-
-int unset_vram_mapping(unsigned long begin, unsigned long end)
-{
- unsigned long * extent_start = NULL;
- unsigned long nr_extents;
- int i;
-
- /* align begin and end address */
-
- end = begin + VGA_RAM_SIZE;
- begin = begin & PAGE_MASK;
- end = (end + PAGE_SIZE -1 ) & PAGE_MASK;
- nr_extents = (end - begin) >> PAGE_SHIFT;
-
- extent_start = malloc(sizeof(unsigned long) * nr_extents );
-
- if (extent_start == NULL)
- {
- fprintf(stderr, "Failed malloc on set_mm_mapping\n");
- return -1;
- }
-
- memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
-
- for (i = 0; i < nr_extents; i++)
- extent_start[i] = (begin + (i * PAGE_SIZE)) >> PAGE_SHIFT;
-
- unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
-
- free(extent_start);
-
- return 0;
-}
-
-#elif defined(__ia64__)
-void set_vram_mapping(unsigned long addr, unsigned long end) {}
-void unset_vram_mapping(unsigned long addr, unsigned long end) {}
-#endif
int main(int argc, char **argv)
{
diff -r 062d109ce872 -r c92fbde4074d tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Thu May 11 22:39:44 2006 +0100
+++ b/tools/ioemu/vl.h Fri May 12 15:15:59 2006 +0100
@@ -38,6 +38,8 @@
#include <fcntl.h>
#include <sys/stat.h>
#include "audio/audio.h"
+#include "xenctrl.h"
+#include "xs.h"
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@@ -113,6 +115,19 @@ void qemu_system_shutdown_request(void);
void main_loop_wait(int timeout);
+int unset_mm_mapping(int xc_handle,
+ uint32_t domid,
+ unsigned long nr_pages,
+ unsigned int address_bits,
+ unsigned long *extent_start);
+int set_mm_mapping(int xc_handle,
+ uint32_t domid,
+ unsigned long nr_pages,
+ unsigned int address_bits,
+ unsigned long *extent_start);
+
+extern int xc_handle;
+extern int domid;
extern int audio_enabled;
extern int sb16_enabled;
extern int adlib_enabled;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|