ia64/xen-unstable

changeset 10050:c92fbde4074d

Move set/unset_vram_mapping into cirrus_vga.c, pending a fixup patch.
Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri May 12 15:15:59 2006 +0100 (2006-05-12)
parents 062d109ce872
children 1b55b85f8cb2
files tools/ioemu/hw/cirrus_vga.c tools/ioemu/vl.c tools/ioemu/vl.h
line diff
     1.1 --- a/tools/ioemu/hw/cirrus_vga.c	Thu May 11 22:39:44 2006 +0100
     1.2 +++ b/tools/ioemu/hw/cirrus_vga.c	Fri May 12 15:15:59 2006 +0100
     1.3 @@ -28,6 +28,9 @@
     1.4   */
     1.5  #include "vl.h"
     1.6  #include "vga_int.h"
     1.7 +#ifndef _WIN32
     1.8 +#include <sys/mman.h>
     1.9 +#endif
    1.10  
    1.11  /*
    1.12   * TODO:
    1.13 @@ -2455,13 +2458,96 @@ static CPUWriteMemoryFunc *cirrus_linear
    1.14      cirrus_linear_bitblt_writel,
    1.15  };
    1.16  
    1.17 +extern FILE *logfile;
    1.18 +#if defined(__i386__) || defined (__x86_64__)
    1.19 +static void * set_vram_mapping(unsigned long begin, unsigned long end)
    1.20 +{
    1.21 +    unsigned long * extent_start = NULL;
    1.22 +    unsigned long nr_extents;
    1.23 +    void *vram_pointer = NULL;
    1.24 +    int i;
    1.25 +
    1.26 +    /* align begin and end address */
    1.27 +    begin = begin & TARGET_PAGE_MASK;
    1.28 +    end = begin + VGA_RAM_SIZE;
    1.29 +    end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
    1.30 +    nr_extents = (end - begin) >> TARGET_PAGE_BITS;
    1.31 +
    1.32 +    extent_start = malloc(sizeof(unsigned long) * nr_extents );
    1.33 +    if (extent_start == NULL)
    1.34 +    {
    1.35 +        fprintf(stderr, "Failed malloc on set_vram_mapping\n");
    1.36 +        return NULL;
    1.37 +    }
    1.38 +
    1.39 +    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
    1.40 +
    1.41 +    for (i = 0; i < nr_extents; i++)
    1.42 +    {
    1.43 +        extent_start[i] = (begin + i * TARGET_PAGE_SIZE) >> TARGET_PAGE_BITS;
    1.44 +    }
    1.45 +
    1.46 +    set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
    1.47 +
    1.48 +    if ( (vram_pointer =  xc_map_foreign_batch(xc_handle, domid,
    1.49 +                                               PROT_READ|PROT_WRITE,
    1.50 +                                               extent_start,
    1.51 +                                               nr_extents)) == NULL)
    1.52 +    {
    1.53 +        fprintf(logfile,
    1.54 +          "xc_map_foreign_batch vgaram returned error %d\n", errno);
    1.55 +        return NULL;
    1.56 +    }
    1.57 +
    1.58 +    memset(vram_pointer, 0, nr_extents * TARGET_PAGE_SIZE);
    1.59 +
    1.60 +    free(extent_start);
    1.61 +
    1.62 +    return vram_pointer;
    1.63 +}
    1.64 +
    1.65 +static int unset_vram_mapping(unsigned long begin, unsigned long end)
    1.66 +{
    1.67 +    unsigned long * extent_start = NULL;
    1.68 +    unsigned long nr_extents;
    1.69 +    int i;
    1.70 +
    1.71 +    /* align begin and end address */
    1.72 +
    1.73 +    end = begin + VGA_RAM_SIZE;
    1.74 +    begin = begin & TARGET_PAGE_MASK;
    1.75 +    end = (end + TARGET_PAGE_SIZE -1 ) & TARGET_PAGE_MASK;
    1.76 +    nr_extents = (end - begin) >> TARGET_PAGE_BITS;
    1.77 +
    1.78 +    extent_start = malloc(sizeof(unsigned long) * nr_extents );
    1.79 +
    1.80 +    if (extent_start == NULL)
    1.81 +    {
    1.82 +        fprintf(stderr, "Failed malloc on set_mm_mapping\n");
    1.83 +        return -1;
    1.84 +    }
    1.85 +
    1.86 +    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
    1.87 +
    1.88 +    for (i = 0; i < nr_extents; i++)
    1.89 +        extent_start[i] = (begin + (i * TARGET_PAGE_SIZE)) >> TARGET_PAGE_BITS;
    1.90 +
    1.91 +    unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
    1.92 +
    1.93 +    free(extent_start);
    1.94 +
    1.95 +    return 0;
    1.96 +}
    1.97 +
    1.98 +#elif defined(__ia64__)
    1.99 +static void * set_vram_mapping(unsigned long addr, unsigned long end) {}
   1.100 +static int unset_vram_mapping(unsigned long addr, unsigned long end) {}
   1.101 +#endif
   1.102 +
   1.103  /* Compute the memory access functions */
   1.104  static void cirrus_update_memory_access(CirrusVGAState *s)
   1.105  {
   1.106      unsigned mode;
   1.107 -    extern void * set_vram_mapping(unsigned long addr, unsigned long end);
   1.108 -
   1.109 -    extern int unset_vram_mapping(unsigned long addr, unsigned long end);
   1.110      extern int vga_accelerate;
   1.111  
   1.112      if ((s->sr[0x17] & 0x44) == 0x44) {
     2.1 --- a/tools/ioemu/vl.c	Thu May 11 22:39:44 2006 +0100
     2.2 +++ b/tools/ioemu/vl.c	Fri May 12 15:15:59 2006 +0100
     2.3 @@ -75,8 +75,6 @@
     2.4  #endif
     2.5  #endif /* CONFIG_SDL */
     2.6  
     2.7 -#include "xenctrl.h"
     2.8 -#include "xs.h"
     2.9  #include "exec-all.h"
    2.10  
    2.11  //#define DO_TB_FLUSH
    2.12 @@ -2456,7 +2454,6 @@ static uint8_t *signal_stack;
    2.13  
    2.14  #include <xg_private.h>
    2.15  
    2.16 -#if defined(__i386__) || defined (__x86_64__)
    2.17  #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER)
    2.18  #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    2.19  
    2.20 @@ -2484,7 +2481,7 @@ get_vl2_table(unsigned long count, unsig
    2.21  }
    2.22  
    2.23  /* FIXME Flush the shadow page */
    2.24 -static int unset_mm_mapping(int xc_handle,
    2.25 +int unset_mm_mapping(int xc_handle,
    2.26                       uint32_t domid,
    2.27                       unsigned long nr_pages,
    2.28                       unsigned int address_bits,
    2.29 @@ -2517,13 +2514,12 @@ static int unset_mm_mapping(int xc_handl
    2.30      return err;
    2.31  }
    2.32  
    2.33 -static int set_mm_mapping(int xc_handle,
    2.34 +int set_mm_mapping(int xc_handle,
    2.35                      uint32_t domid,
    2.36                      unsigned long nr_pages,
    2.37                      unsigned int address_bits,
    2.38                      unsigned long *extent_start)
    2.39  {
    2.40 -    int i;
    2.41      xc_dominfo_t info;
    2.42      int err = 0;
    2.43  
    2.44 @@ -2564,91 +2560,6 @@ static int set_mm_mapping(int xc_handle,
    2.45      return 0;
    2.46  }
    2.47  
    2.48 -
    2.49 -void * set_vram_mapping(unsigned long begin, unsigned long end)
    2.50 -{
    2.51 -    unsigned long * extent_start = NULL;
    2.52 -    unsigned long nr_extents;
    2.53 -    void *vram_pointer = NULL;
    2.54 -    int i;
    2.55 -
    2.56 -    /* align begin and end address */
    2.57 -    begin = begin & PAGE_MASK;
    2.58 -    end = begin + VGA_RAM_SIZE;
    2.59 -    end = (end + PAGE_SIZE -1 )& PAGE_MASK;
    2.60 -    nr_extents = (end - begin) >> PAGE_SHIFT;
    2.61 -
    2.62 -    extent_start = malloc(sizeof(unsigned long) * nr_extents );
    2.63 -    if (extent_start == NULL)
    2.64 -    {
    2.65 -        fprintf(stderr, "Failed malloc on set_vram_mapping\n");
    2.66 -        return NULL;
    2.67 -    }
    2.68 -
    2.69 -    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
    2.70 -
    2.71 -    for (i = 0; i < nr_extents; i++)
    2.72 -    {
    2.73 -        extent_start[i] = (begin + i * PAGE_SIZE) >> PAGE_SHIFT;
    2.74 -    }
    2.75 -
    2.76 -    set_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
    2.77 -
    2.78 -    if ( (vram_pointer =  xc_map_foreign_batch(xc_handle, domid,
    2.79 -                                               PROT_READ|PROT_WRITE,
    2.80 -                                               extent_start,
    2.81 -                                               nr_extents)) == NULL)
    2.82 -    {
    2.83 -        fprintf(logfile,
    2.84 -          "xc_map_foreign_batch vgaram returned error %d\n", errno);
    2.85 -        return NULL;
    2.86 -    }
    2.87 -
    2.88 -    memset(vram_pointer, 0, nr_extents * PAGE_SIZE);
    2.89 -
    2.90 -    free(extent_start);
    2.91 -
    2.92 -    return vram_pointer;
    2.93 -}
    2.94 -
    2.95 -int unset_vram_mapping(unsigned long begin, unsigned long end)
    2.96 -{
    2.97 -    unsigned long * extent_start = NULL;
    2.98 -    unsigned long nr_extents;
    2.99 -    int i;
   2.100 -
   2.101 -    /* align begin and end address */
   2.102 -
   2.103 -    end = begin + VGA_RAM_SIZE;
   2.104 -    begin = begin & PAGE_MASK;
   2.105 -    end = (end + PAGE_SIZE -1 ) & PAGE_MASK;
   2.106 -    nr_extents = (end - begin) >> PAGE_SHIFT;
   2.107 -
   2.108 -    extent_start = malloc(sizeof(unsigned long) * nr_extents );
   2.109 -
   2.110 -    if (extent_start == NULL)
   2.111 -    {
   2.112 -        fprintf(stderr, "Failed malloc on set_mm_mapping\n");
   2.113 -        return -1;
   2.114 -    }
   2.115 -
   2.116 -    memset(extent_start, 0, sizeof(unsigned long) * nr_extents);
   2.117 -
   2.118 -    for (i = 0; i < nr_extents; i++)
   2.119 -        extent_start[i] = (begin + (i * PAGE_SIZE)) >> PAGE_SHIFT;
   2.120 -
   2.121 -    unset_mm_mapping(xc_handle, domid, nr_extents, 0, extent_start);
   2.122 -
   2.123 -    free(extent_start);
   2.124 -
   2.125 -    return 0;
   2.126 -}
   2.127 -
   2.128 -#elif defined(__ia64__)
   2.129 -void set_vram_mapping(unsigned long addr, unsigned long end) {}
   2.130 -void unset_vram_mapping(unsigned long addr, unsigned long end) {}
   2.131 -#endif
   2.132 -
   2.133  int main(int argc, char **argv)
   2.134  {
   2.135  #ifdef CONFIG_GDBSTUB
     3.1 --- a/tools/ioemu/vl.h	Thu May 11 22:39:44 2006 +0100
     3.2 +++ b/tools/ioemu/vl.h	Fri May 12 15:15:59 2006 +0100
     3.3 @@ -38,6 +38,8 @@
     3.4  #include <fcntl.h>
     3.5  #include <sys/stat.h>
     3.6  #include "audio/audio.h"
     3.7 +#include "xenctrl.h"
     3.8 +#include "xs.h"
     3.9  
    3.10  #ifndef O_LARGEFILE
    3.11  #define O_LARGEFILE 0
    3.12 @@ -113,6 +115,19 @@ void qemu_system_shutdown_request(void);
    3.13  
    3.14  void main_loop_wait(int timeout);
    3.15  
    3.16 +int unset_mm_mapping(int xc_handle,
    3.17 +                     uint32_t domid,
    3.18 +                     unsigned long nr_pages,
    3.19 +                     unsigned int address_bits,
    3.20 +                     unsigned long *extent_start);
    3.21 +int set_mm_mapping(int xc_handle,
    3.22 +                    uint32_t domid,
    3.23 +                    unsigned long nr_pages,
    3.24 +                    unsigned int address_bits,
    3.25 +                    unsigned long *extent_start);
    3.26 +
    3.27 +extern int xc_handle;
    3.28 +extern int domid;
    3.29  extern int audio_enabled;
    3.30  extern int sb16_enabled;
    3.31  extern int adlib_enabled;